LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/socket - hccl_network.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 68.6 % 35 24
Test Date: 2026-07-28 12:11:00 Functions: 75.0 % 16 12

            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 HCCL_NETWORK_H
      12              : #define HCCL_NETWORK_H
      13              : 
      14              : #include "hccl_network_pub.h"
      15              : #include "hccl_common.h"
      16              : #include "hccl_ip_address.h"
      17              : #include "hccl_net_dev.h"
      18              : #include "rma_buffer_mgr.h"
      19              : #include "local_ipc_rma_buffer.h"
      20              : #include "local_rdma_rma_buffer.h"
      21              : 
      22              : namespace hccl {
      23              : class NetDevContext {
      24              : public:
      25              :     using LocalIpcRmaBufferMgr = RmaBufferMgr<BufferKey<uintptr_t, u64>, std::shared_ptr<LocalIpcRmaBuffer>>;
      26              :     using LocalRdmaRmaBufferMgr = RmaBufferMgr<BufferKey<uintptr_t, u64>, std::shared_ptr<LocalRdmaRmaBuffer>>;
      27              : 
      28          383 :     NetDevContext() {}
      29          375 :     ~NetDevContext() {}
      30              :     HcclResult Init(NicType nicType, s32 devicePhyId, s32 deviceLogicId, HcclIpAddress localIp,
      31              :         HcclIpAddress backupIp = HcclIpAddress(0));
      32              :     HcclResult Deinit();
      33              :     HcclResult InitV2(const HcclNetDevInfos *info);
      34              :     HcclResult GetinfoConfig(const HcclNetDevInfos *info);
      35              :     HcclResult ConvertIP(const HcclAddress address);
      36              :     HcclResult DeinitV2();
      37              :     void SetTlsStatus(TlsStatus tlsStatus);
      38              :     void SetIsNotNeedGetTlsStatus(bool isNotNeedGetTlsStatus);
      39              :     std::mutex mu_;
      40              : 
      41          356 :     NicType GetNicType() const
      42              :     {
      43          356 :         return nicType_;
      44              :     }
      45              : 
      46          566 :     HcclIpAddress GetLocalIp() const
      47              :     {
      48          566 :         return localIp_;
      49              :     }
      50              : 
      51          270 :     HcclIpAddress GetBackupIp() const
      52              :     {
      53          270 :         return backupIp_;
      54              :     }
      55              : 
      56          300 :     s32 GetPhyId() const
      57              :     {
      58          300 :         return devicePhyId_;
      59              :     }
      60              : 
      61          286 :     s32 GetLogicId() const
      62              :     {
      63          286 :         return deviceLogicId_;
      64              :     }
      65            0 :     HcclNetDevDeployment GetNetDevDeployment() const
      66              :     {
      67            0 :         return netDevDeployment_;
      68              :     }
      69              : 
      70            0 :     bool GetIsBackup() const
      71              :     {
      72            0 :         return isBackup_;
      73              :     }
      74           13 :     NICDeployment GetNicDeployment() const
      75              :     {
      76           13 :         return nicDeployment_;
      77              :     }
      78           38 :     bool IsNotNeedGetTlsStatus()
      79              :     {
      80           38 :         return isNotNeedGetTlsStatus_;
      81              :     }
      82           38 :     TlsStatus GettlsStatus()
      83              :     {
      84           38 :         return tlsStatus_;
      85              :     }
      86           20 :     HcclProtoType GetProtoType() const
      87              :     {
      88           20 :         return protoType_;
      89              :     }
      90            0 :     void SetProtoType(u32 proto)
      91              :     {
      92            0 :         protoType_ = (HcclProtoType)proto;
      93            0 :     }
      94              : 
      95           41 :     std::shared_ptr<LocalIpcRmaBufferMgr> GetlocalIpcRmaBufferMgr()
      96              :     {
      97           41 :         if (!localIpcRmaBufferMgr_) {
      98            8 :             EXCEPTION_CATCH((localIpcRmaBufferMgr_ = std::make_shared<LocalIpcRmaBufferMgr>()),
      99              :                 return nullptr);
     100              :         }
     101           41 :         return localIpcRmaBufferMgr_;
     102              :     }
     103              : 
     104            0 :     std::shared_ptr<LocalRdmaRmaBufferMgr> GetlocalRdmaRmaBufferMgr()
     105              :     {
     106            0 :         if (!localRdmaRmaBufferMgr_) {
     107            0 :             EXCEPTION_CATCH((localRdmaRmaBufferMgr_ = std::make_shared<LocalRdmaRmaBufferMgr>()),
     108              :                 return nullptr);
     109              :         }
     110            0 :         return localRdmaRmaBufferMgr_;
     111              :     }
     112              : 
     113              : private:
     114              :     NICDeployment nicDeployment_;
     115              :     s32 devicePhyId_;
     116              :     s32 deviceLogicId_;
     117              :     HcclIpAddress localIp_;
     118              :     HcclIpAddress backupIp_;
     119              :     NicType nicType_;
     120              :     bool isHostUseDevNic_{false};
     121              :     SocketHandle hostSocketHandle_{nullptr};
     122              :     HcclProtoType protoType_{HCCL_PROTO_TYPE_RESERVED};
     123              :     HcclNetDevDeployment netDevDeployment_;
     124              :     void *handle_ {nullptr};
     125              :     bool isBackup_;
     126              :     TlsStatus tlsStatus_ = TlsStatus::UNKNOWN;
     127              :     bool isNotNeedGetTlsStatus_ = false;
     128              :     std::shared_ptr<LocalIpcRmaBufferMgr> localIpcRmaBufferMgr_{nullptr};
     129              :     std::shared_ptr<LocalRdmaRmaBufferMgr> localRdmaRmaBufferMgr_{nullptr};
     130              : };
     131              : }
     132              : 
     133              : #endif
        

Generated by: LCOV version 2.0-1