LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/common - net_device.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.0 % 18 9
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #ifndef HCCLV2_PLT_NET_DEVICE_H
      12              : #define HCCLV2_PLT_NET_DEVICE_H
      13              : 
      14              : #include "orion_adapter_hccp.h"
      15              : #include "inner_net_dev.h"
      16              : #include "buffer_key.h"
      17              : #include "hccl_net_dev_defs.h"
      18              : 
      19              : namespace Hccl {
      20              : 
      21              : class HcclNetDevice {
      22              : public:
      23            4 :     static HcclProtoType ConvertHcclProtoToLinkProto(Hccl::LinkProtoType type)
      24              :     {
      25            4 :         switch (type) {
      26            0 :             case Hccl::LinkProtoType::HCCS_PCIE:
      27            0 :                 return HCCL_PROTO_TYPE_RESERVED;
      28            0 :             case Hccl::LinkProtoType::TCP:
      29            0 :                 return HCCL_PROTO_TYPE_TCP;
      30            0 :             case Hccl::LinkProtoType::RDMA:
      31            0 :                 return HCCL_PROTO_TYPE_ROCE;
      32            4 :             case Hccl::LinkProtoType::UB:
      33            4 :                 return HCCL_PROTO_TYPE_UBC_TP;
      34            0 :             default:
      35            0 :                 return HCCL_PROTO_TYPE_RESERVED;
      36              :         }
      37              :     }
      38              : 
      39            4 :     static HcclNetDevDeployment ConvertDeploymentType(Hccl::PortDeploymentType type)
      40              :     {
      41            4 :         if (type == Hccl::PortDeploymentType::DEV_NET) {
      42            3 :             return HCCL_NETDEV_DEPLOYMENT_DEVICE;
      43            1 :         } else if (type == Hccl::PortDeploymentType::HOST_NET) {
      44            0 :             return HCCL_NETDEV_DEPLOYMENT_HOST;
      45              :         } else {
      46            1 :             return HCCL_NETDEV_DEPLOYMENT_RESERVED;
      47              :         }
      48              :     }
      49              :     HcclNetDevice(const NetDevInfo& info);
      50              :     ~HcclNetDevice();
      51              : 
      52              :     // NetDevInfo 读写函数
      53              :     NetDevInfo GetNetDevInfo() const;
      54              : 
      55              :     // Getter 方法:返回 ndev_ 的当前值
      56              :     InnerNetDev* GetInnerNetDev() const;
      57              : 
      58              :     // Setter 方法:允许外部修改 ndev_ 的值
      59              :     void SetInnerNetDev(InnerNetDev* value);
      60              : 
      61              :     RdmaHandle GetRdmaHandle() const;
      62              : 
      63              :     std::pair<TokenIdHandle, uint32_t> GetTokenIdInfo(const BufferKey<uintptr_t, u64>& bufKey) const;
      64              :     void PutTokenIdInfo(const BufferKey<uintptr_t, u64>& bufKey, TokenIdHandle tokenIdHandle) const;
      65              :     bool IsUB();
      66              : 
      67              : private:
      68              :     NetDevInfo netDevInfo_;
      69              :     InnerNetDev* ndev_;
      70              : };
      71              : 
      72              : } // namespace Hccl
      73              : 
      74              : #endif // HCCLV2_PLT_NET_DEVICE_H
        

Generated by: LCOV version 2.0-1