LCOV - code coverage report
Current view: top level - base_comm/resources/endpoints - uboe_endpoint.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 24 24
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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              : #include "uboe_endpoint.h"
      12              : #include "endpoint_mgr.h"
      13              : #include "log.h"
      14              : #include "hccl/hccl_res.h"
      15              : #include "urma_mem.h"
      16              : #include "proc_reged_mem_mgr_cache.h"
      17              : #include "adapter_rts_common.h"
      18              : 
      19              : namespace hcomm {
      20              : 
      21           13 : UboeEndpoint::UboeEndpoint(const EndpointDesc &endpointDesc)
      22           13 :     : UboeUbgEndpointHelper(endpointDesc)
      23              : {
      24           13 : }
      25              : 
      26           26 : UboeEndpoint::~UboeEndpoint() noexcept
      27              : {
      28           13 :     ProcRegedMemMgrCache::GetInstance().Release(cacheKey_);
      29           26 : }
      30              : 
      31           13 : HcclResult UboeEndpoint::Init()
      32              : {
      33           13 :     HCCL_INFO("[%s] localEndpoint protocol[%d]", __func__, endpointDesc_.protocol);
      34              : 
      35           13 :     Hccl::IpAddress ipAddr{};
      36           13 :     CHK_RET(CommAddrToIpAddress(endpointDesc_.commAddr, ipAddr));
      37              : 
      38              :     s32 deviceLogicId;
      39              :     u32 devPhyId;
      40           11 :     CHK_RET(hrtGetDevice(&deviceLogicId));
      41           11 :     CHK_RET(hrtGetDevicePhyIdByIndex(deviceLogicId, devPhyId));
      42           11 :     endpointDesc_.loc.device.devPhyId = devPhyId;
      43              : 
      44           11 :     Hccl::HccpHdcManager::GetInstance().Init(deviceLogicId);
      45           11 :     auto &rdmaHandleMgr = Hccl::RdmaHandleManager::GetInstance();
      46           11 :     Hccl::IpAddress eidAddress{};
      47           11 :     rdmaHandleMgr.UboeIpv4ToEid(ipAddr, eidAddress, devPhyId);
      48           11 :     EXCEPTION_CATCH(ctxHandle_ = static_cast<void *>(rdmaHandleMgr.GetByIp(endpointDesc_.loc.device.devPhyId, eidAddress)), 
      49              :         return HCCL_E_PARA);
      50           11 :     CHK_PTR_NULL(ctxHandle_);
      51           11 :     HCCL_INFO("%s success, devPhyId[%u], eidAddress[%s], ctxHandle[%p]",
      52              :         __func__, devPhyId, eidAddress.Describe().c_str(), ctxHandle_);
      53              : 
      54           11 :     cacheKey_ = MemMgrCacheKey{devPhyId, COMM_PROTOCOL_UBC_CTP, ipAddr, LocTypeToPortType(endpointDesc_.loc.locType)};
      55           11 :     auto &cache = ProcRegedMemMgrCache::GetInstance();
      56           13 :     EXCEPTION_CATCH(regedMemMgr_ = cache.GetOrCreate(cacheKey_, [this]() {
      57              :         auto m = std::make_shared<UbRegedMemMgr>();
      58              :         m->rdmaHandle_ = this->ctxHandle_;
      59              :         return m;
      60              :     }), return HCCL_E_INTERNAL);
      61              : 
      62           11 :     return HcclResult::HCCL_SUCCESS;
      63              : }
      64              : 
      65              : }
      66              : 
        

Generated by: LCOV version 2.0-1