LCOV - code coverage report
Current view: top level - base_comm/resources/endpoints - ub_rtp_endpoint.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.5 % 21 19
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 2 2

            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 "ub_rtp_endpoint.h"
      12              : #include "endpoint_mgr.h"
      13              : #include "log.h"
      14              : #include "hccl/hccl_res.h"
      15              : #include "urma_mem.h"
      16              : #include "adapter_rts_common.h"
      17              : 
      18              : namespace hcomm {
      19              : 
      20            2 : UbRtpEndpoint::UbRtpEndpoint(const EndpointDesc& endpointDesc) : UboeUbRtpEndpointHelper(endpointDesc) {}
      21              : 
      22            2 : HcclResult UbRtpEndpoint::Init()
      23              : {
      24            2 :     HCCL_INFO("[%s] localEndpoint protocol[%d]", __func__, endpointDesc_.protocol);
      25              : 
      26            2 :     DevType deviceType = DevType::DEV_TYPE_COUNT;
      27            2 :     CHK_RET(hrtGetDeviceType(deviceType));
      28            2 :     if (deviceType != DevType::DEV_TYPE_950 && deviceType != DevType::DEV_TYPE_960) {
      29            0 :         HCCL_ERROR(
      30              :             "[%s] UB_RTP protocol only support DEV_TYPE_950/960, current deviceType=%d", __func__,
      31              :             static_cast<int>(deviceType));
      32            0 :         return HCCL_E_NOT_SUPPORT;
      33              :     }
      34              : 
      35              :     // UB_RTP 直接从 EID type CommAddr 获取地址,不做 IP→EID 转换
      36            2 :     Hccl::IpAddress eidAddr{};
      37            2 :     CHK_RET(CommAddrToIpAddress(endpointDesc_.commAddr, eidAddr));
      38              : 
      39              :     s32 deviceLogicId;
      40              :     u32 devPhyId;
      41            2 :     CHK_RET(hrtGetDevice(&deviceLogicId));
      42            2 :     CHK_RET(hrtGetDevicePhyIdByIndex(static_cast<u32>(deviceLogicId), devPhyId));
      43            2 :     endpointDesc_.loc.device.devPhyId = devPhyId;
      44              : 
      45            2 :     Hccl::HccpHdcManager::GetInstance().Init(deviceLogicId);
      46              :     // UB_RTP 直接用 EID 地址获取 rdmaHandle,不做 IP→EID 查询
      47            2 :     auto& rdmaHandleMgr = Hccl::RdmaHandleManager::GetInstance();
      48            2 :     EXCEPTION_CATCH(
      49              :         ctxHandle_ = static_cast<void*>(rdmaHandleMgr.GetByIp(endpointDesc_.loc.device.devPhyId, eidAddr)),
      50              :         return HCCL_E_PARA);
      51            2 :     CHK_PTR_NULL(ctxHandle_);
      52            2 :     HCCL_INFO(
      53              :         "%s success, devPhyId[%u], eidAddr[%s], ctxHandle[%p]", __func__, devPhyId, eidAddr.Describe().c_str(),
      54              :         ctxHandle_);
      55              : 
      56            2 :     EXCEPTION_CATCH(regedMemMgr_ = std::make_unique<UbRegedMemMgr>(), return HCCL_E_INTERNAL);
      57            2 :     regedMemMgr_->rdmaHandle_ = ctxHandle_;
      58              : 
      59            2 :     return HcclResult::HCCL_SUCCESS;
      60              : }
      61              : 
      62              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1