LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/common - dlra_function.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.4 % 290 265
Test Date: 2026-08-17 10:19:35 Functions: 77.8 % 9 7

            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              : #include "dlra_function.h"
      12              : 
      13              : #include <string>
      14              : #include <map>
      15              : #include "hccl_dl.h"
      16              : #include "log.h"
      17              : 
      18              : namespace hccl {
      19              : 
      20              : std::atomic<unsigned> DlRaFunction::Init::initCount(0);
      21              : DlRaFunction* DlRaFunction::hcclDlRaFunction = nullptr;
      22              : 
      23          537 : DlRaFunction::Init::Init()
      24              : {
      25          537 :     if (initCount.fetch_add(1) == 0) {
      26           46 :         DlRaFunction::hcclDlRaFunction = new (std::nothrow) DlRaFunction;
      27           46 :         CHK_PRT_CONT(
      28              :             DlRaFunction::hcclDlRaFunction == nullptr, HCCL_ERROR("[DlRaFunction][Init] hcclDlRaFunction new failed"));
      29              :     }
      30          537 : }
      31              : 
      32          537 : DlRaFunction::Init::~Init()
      33              : {
      34          537 :     if (initCount.fetch_sub(1) == 0) {
      35            0 :         if (DlRaFunction::GetInstance().handle_ != nullptr) {
      36            0 :             (void)HcclDlclose(DlRaFunction::GetInstance().handle_);
      37            0 :             DlRaFunction::GetInstance().handle_ = nullptr;
      38              :         }
      39            0 :         delete DlRaFunction::hcclDlRaFunction;
      40              :     }
      41          537 : }
      42              : 
      43         2672 : DlRaFunction& DlRaFunction::GetInstance() { return *hcclDlRaFunction; }
      44              : 
      45           46 : DlRaFunction::DlRaFunction() : handle_(nullptr) {}
      46              : 
      47            0 : DlRaFunction::~DlRaFunction() {}
      48              : 
      49          611 : HcclResult DlRaFunction::DlRaFunctionRdmaInit()
      50              : {
      51          611 :     dlRaGetQpDepth = (int (*)(RdmaHandle, unsigned int*, unsigned int*))HcclDlsym(handle_, "RaGetTsqpDepth");
      52          611 :     CHK_SMART_PTR_NULL(dlRaGetQpDepth);
      53          611 :     dlRaSetQpDepth = (int (*)(RdmaHandle, unsigned int, unsigned int*))HcclDlsym(handle_, "RaSetTsqpDepth");
      54          611 :     CHK_SMART_PTR_NULL(dlRaSetQpDepth);
      55          611 :     dlRaQpCreate = (int (*)(RdmaHandle, int, int, QpHandle*))HcclDlsym(handle_, "RaQpCreate");
      56          611 :     CHK_SMART_PTR_NULL(dlRaQpCreate);
      57          611 :     dlRaQpDestroy = (int (*)(QpHandle))HcclDlsym(handle_, "RaQpDestroy");
      58          611 :     CHK_SMART_PTR_NULL(dlRaQpDestroy);
      59          611 :     dlRaQpDestroyWithoutCQ = (int (*)(QpHandle))HcclDlsym(handle_, "RaQpDestroyWithoutCQ");
      60          611 :     CHK_SMART_PTR_NULL(dlRaQpDestroyWithoutCQ);
      61          611 :     dlRaGetQpContext = (int (*)(void*, void**, void**, void**))HcclDlsym(handle_, "RaGetQpContext");
      62          611 :     CHK_SMART_PTR_NULL(dlRaGetQpContext);
      63          611 :     dlRaQpConnectAsync = (int (*)(QpHandle, const SocketHandle))HcclDlsym(handle_, "RaQpConnectAsync");
      64          611 :     CHK_SMART_PTR_NULL(dlRaQpConnectAsync);
      65          611 :     dlRaGetQpStatus = (int (*)(QpHandle, int*))HcclDlsym(handle_, "RaGetQpStatus");
      66          611 :     CHK_SMART_PTR_NULL(dlRaGetQpStatus);
      67          611 :     dlRaMrDereg = (int (*)(QpHandle, struct MrInfoT*))HcclDlsym(handle_, "RaMrDereg");
      68          611 :     CHK_SMART_PTR_NULL(dlRaMrDereg);
      69          611 :     dlRaMrReg = (int (*)(QpHandle, struct MrInfoT*))HcclDlsym(handle_, "RaMrReg");
      70          611 :     CHK_SMART_PTR_NULL(dlRaMrReg);
      71          611 :     dlRaGetNotifyMrInfo = (int (*)(RdmaHandle, struct MrInfoT*))HcclDlsym(handle_, "RaGetNotifyMrInfo");
      72          611 :     CHK_SMART_PTR_NULL(dlRaGetNotifyMrInfo);
      73          611 :     dlRaRdmaDeInit = (int (*)(RdmaHandle, u32))HcclDlsym(handle_, "RaRdevDeinit");
      74          611 :     CHK_SMART_PTR_NULL(dlRaRdmaDeInit);
      75          611 :     dlRaRdmaInitWithAttr = (int (*)(struct RdevInitInfo, struct rdev, RdmaHandle*))HcclDlsym(handle_, "RaRdevInitV2");
      76          611 :     CHK_SMART_PTR_NULL(dlRaRdmaInitWithAttr);
      77          611 :     dlRaRdmaInitWithBackupAttr = (int (*)(struct RdevInitInfo*, struct rdev*, struct rdev*, RdmaHandle*))HcclDlsym(
      78          611 :         handle_, "RaRdevInitWithBackup");
      79          611 :     CHK_SMART_PTR_NULL(dlRaRdmaInitWithBackupAttr);
      80          611 :     dlRaRdmaGetHandle = (int (*)(unsigned int, RdmaHandle*))HcclDlsym(handle_, "RaRdevGetHandle");
      81          611 :     dlRaRdmaInit = (int (*)(int, u32, struct rdev, RdmaHandle*))HcclDlsym(handle_, "RaRdevInit");
      82          611 :     CHK_SMART_PTR_NULL(dlRaRdmaInit);
      83          611 :     dlRaSendWr = (int (*)(QpHandle, struct SendWr*, struct SendWrRsp*))HcclDlsym(handle_, "RaSendWr");
      84          611 :     CHK_SMART_PTR_NULL(dlRaSendWr);
      85          611 :     dlRaSendWrV2 = (int (*)(QpHandle, struct SendWrV2*, struct SendWrRsp*))HcclDlsym(handle_, "RaSendWrV2");
      86          611 :     CHK_SMART_PTR_NULL(dlRaSendWrV2);
      87          611 :     dlRaSendWrVerbs = (int (*)(QpHandle, struct SendWrVerbs*, struct SendWrRsp*))HcclDlsym(handle_, "RaSendWrVerbs");
      88          611 :     CHK_SMART_PTR_NULL(dlRaSendWrVerbs);
      89          611 :     dlRaRecvWrVerbs = (int (*)(QpHandle, struct RecvWrVerbs*))HcclDlsym(handle_, "RaRecvWrVerbs");
      90          611 :     CHK_SMART_PTR_NULL(dlRaRecvWrVerbs);
      91          611 :     dlRaPollCq = (int (*)(QpHandle, bool, unsigned int, void*))HcclDlsym(handle_, "RaPollCq");
      92          611 :     CHK_SMART_PTR_NULL(dlRaPollCq);
      93          611 :     dlRaPollTypicalCq = (int (*)(void*, unsigned int, void*))HcclDlsym(handle_, "RaPollTypicalCq");
      94          611 :     CHK_SMART_PTR_NULL(dlRaPollTypicalCq);
      95            0 :     dlRaSendWrlist = (int (*)(
      96              :         QpHandle handle, struct SendWrlistData wr[], struct SendWrRsp op_rsp[], unsigned int sendNum,
      97          611 :         unsigned int* completeNum))HcclDlsym(handle_, "RaSendWrlist");
      98          611 :     if (dlRaSendWrlist == nullptr) {
      99            0 :         HCCL_WARNING("dlRaSendWrlist is nullptr, can not use RaSendWrlist");
     100              :     }
     101            0 :     dlRaSendWrlistExt = (int (*)(
     102              :         QpHandle handle, struct SendWrlistDataExt wr[], struct SendWrRsp op_rsp[], unsigned int sendNum,
     103          611 :         unsigned int* completeNum))HcclDlsym(handle_, "RaSendWrlistExt");
     104          611 :     if (dlRaSendWrlistExt == nullptr) {
     105            0 :         HCCL_WARNING("dlRaSendWrlistExt is nullptr, can not use ra_send_wrlist_ext");
     106              :     }
     107            0 :     dlRaSendNormalWrlist = (int (*)(
     108              :         QpHandle handle, struct WrInfo wr[], struct SendWrRsp opRsp[], unsigned int sendNum,
     109          611 :         unsigned int* completeNum))HcclDlsym(handle_, "RaSendNormalWrlist");
     110          611 :     CHK_SMART_PTR_NULL(dlRaSendNormalWrlist);
     111              :     dlRaRegGlobalMr
     112          611 :         = (int (*)(const RdmaHandle, struct MrInfoT* info, MrHandle* mrHandle))HcclDlsym(handle_, "RaRegisterMr");
     113          611 :     CHK_SMART_PTR_NULL(dlRaRegGlobalMr);
     114          611 :     dlRaDeRegGlobalMr = (int (*)(const RdmaHandle, MrHandle mrHandle))HcclDlsym(handle_, "RaDeregisterMr");
     115          611 :     CHK_SMART_PTR_NULL(dlRaDeRegGlobalMr);
     116          611 :     dlRaCreateCq = (int (*)(RdmaHandle, struct CqAttr*))HcclDlsym(handle_, "RaCqCreate");
     117          611 :     CHK_SMART_PTR_NULL(dlRaCreateCq);
     118          611 :     dlRaDestroyCq = (int (*)(RdmaHandle, struct CqAttr*))HcclDlsym(handle_, "RaCqDestroy");
     119          611 :     CHK_SMART_PTR_NULL(dlRaDestroyCq);
     120              :     dlRaNormalQpCreate
     121          611 :         = (int (*)(RdmaHandle, struct ibv_qp_init_attr*, void**, void**))HcclDlsym(handle_, "RaNormalQpCreate");
     122          611 :     CHK_SMART_PTR_NULL(dlRaNormalQpCreate);
     123          611 :     dlRaNormalQpDestroy = (int (*)(QpHandle))HcclDlsym(handle_, "RaNormalQpDestroy");
     124          611 :     CHK_SMART_PTR_NULL(dlRaNormalQpDestroy);
     125          611 :     dlRaSetQpAttrQos = (int (*)(QpHandle, struct QosAttr*))HcclDlsym(handle_, "RaSetQpAttrQos");
     126          611 :     CHK_SMART_PTR_NULL(dlRaSetQpAttrQos);
     127          611 :     dlRaSetQpAttrTimeOut = (int (*)(QpHandle, u32*))HcclDlsym(handle_, "RaSetQpAttrTimeout");
     128          611 :     CHK_SMART_PTR_NULL(dlRaSetQpAttrTimeOut);
     129          611 :     dlRaSetQpAttrRetryCnt = (int (*)(QpHandle, u32*))HcclDlsym(handle_, "RaSetQpAttrRetryCnt");
     130          611 :     CHK_SMART_PTR_NULL(dlRaSetQpAttrRetryCnt);
     131          611 :     dlRaCreateCompChannel = (int (*)(const void*, void**))HcclDlsym(handle_, "RaCreateCompChannel");
     132          611 :     CHK_SMART_PTR_NULL(dlRaCreateCompChannel);
     133          611 :     dlRaDestroyCompChannel = (int (*)(const void*, void*))HcclDlsym(handle_, "RaDestroyCompChannel");
     134          611 :     CHK_SMART_PTR_NULL(dlRaDestroyCompChannel);
     135          611 :     dlRaGetCqeErrInfo = (int (*)(unsigned int phyId, struct CqeErrInfo*))HcclDlsym(handle_, "RaGetCqeErrInfo");
     136          611 :     CHK_SMART_PTR_NULL(dlRaGetCqeErrInfo);
     137              :     dlRaGetCqeErrInfoList
     138          611 :         = (int (*)(RdmaHandle, struct CqeErrInfo*, u32*))HcclDlsym(handle_, "RaRdevGetCqeErrInfoList");
     139          611 :     CHK_SMART_PTR_NULL(dlRaGetCqeErrInfoList);
     140          611 :     dlRaGetQpAttr = (int (*)(QpHandle, struct QpAttr*))HcclDlsym(handle_, "RaGetQpAttr");
     141          611 :     CHK_SMART_PTR_NULL(dlRaGetQpAttr);
     142          611 :     dlRaCreateSrq = (int (*)(const void*, struct SrqAttr*))HcclDlsym(handle_, "RaCreateSrq");
     143          611 :     CHK_SMART_PTR_NULL(dlRaCreateSrq);
     144          611 :     dlRaDestroyeSrq = (int (*)(const void*, struct SrqAttr*))HcclDlsym(handle_, "RaDestroySrq");
     145          611 :     CHK_SMART_PTR_NULL(dlRaDestroyeSrq);
     146              :     dlRaQpCreateWithAttrs
     147          611 :         = (int (*)(RdmaHandle, struct QpExtAttrs*, QpHandle*))HcclDlsym(handle_, "RaQpCreateWithAttrs");
     148          611 :     CHK_SMART_PTR_NULL(dlRaQpCreateWithAttrs);
     149              :     dlRaTypicalQpCreate
     150          611 :         = (int (*)(RdmaHandle, int, int, struct TypicalQp*, QpHandle*))HcclDlsym(handle_, "RaTypicalQpCreate");
     151          611 :     CHK_SMART_PTR_NULL(dlRaTypicalQpCreate);
     152              :     dlRaTypicalQpModify
     153          611 :         = (int (*)(QpHandle, struct TypicalQp*, struct TypicalQp*))HcclDlsym(handle_, "RaTypicalQpModify");
     154          611 :     CHK_SMART_PTR_NULL(dlRaTypicalQpModify);
     155          611 :     dlRaTypicalSendWr = (int (*)(QpHandle, struct SendWr*, struct SendWrRsp*))HcclDlsym(handle_, "RaTypicalSendWr");
     156          611 :     CHK_SMART_PTR_NULL(dlRaTypicalSendWr);
     157              :     dlRaTypicalCqCreate
     158          611 :         = (int (*)(RdmaHandle, unsigned int, unsigned int*, void**))HcclDlsym(handle_, "RaTypicalCqCreate");
     159          611 :     CHK_SMART_PTR_NULL(dlRaTypicalCqCreate);
     160          611 :     dlRaTypicalCqDestroy = (int (*)(RdmaHandle, unsigned int, void*))HcclDlsym(handle_, "RaTypicalCqDestroy");
     161          611 :     CHK_SMART_PTR_NULL(dlRaTypicalCqDestroy);
     162              :     dlRaQpCreateWithCQWithAttrs
     163          611 :         = (int (*)(RdmaHandle, struct QpExtAttrs*, unsigned int, unsigned int, QpHandle*))HcclDlsym(
     164          611 :             handle_, "RaQpCreateWithCQWithAttrs");
     165          611 :     CHK_SMART_PTR_NULL(dlRaQpCreateWithCQWithAttrs);
     166              :     dlRaAiQpCreate
     167          611 :         = (int (*)(RdmaHandle, struct QpExtAttrs*, struct AiQpInfo*, QpHandle*))HcclDlsym(handle_, "RaAiQpCreate");
     168          611 :     CHK_SMART_PTR_NULL(dlRaAiQpCreate);
     169              :     dlRaRecvWrlist
     170            0 :         = (int (*)(QpHandle handle, struct RecvWrlistData* wr, unsigned int recvNum, unsigned int* completeNum))
     171          611 :             HcclDlsym(handle_, "RaRecvWrlist");
     172          611 :     if (dlRaRecvWrlist == nullptr) {
     173            0 :         HCCL_WARNING("dlRaRecvWrlist is nullptr, can not use ra_recv_wrlist");
     174              :     }
     175          611 :     dlRaGetRdmaLiteStatus = (int (*)(RdmaHandle, int*))HcclDlsym(handle_, "RaRdevGetSupportLite");
     176          611 :     CHK_SMART_PTR_NULL(dlRaGetRdmaLiteStatus);
     177              : 
     178          611 :     dlRaQpBatchModify = (int (*)(RdmaHandle rdmaHandle, void** qpHandle, unsigned int num, int expectStatus))HcclDlsym(
     179          611 :         handle_, "RaQpBatchModify");
     180          611 :     if (dlRaQpBatchModify == nullptr) {
     181            0 :         HCCL_ERROR("dlRaQpBatchModify is nullptr, can not use ra_qp_batch_modify");
     182              :     }
     183          611 :     CHK_SMART_PTR_NULL(dlRaQpBatchModify);
     184              : 
     185          611 :     dlRaPingInit = (int (*)(struct PingInitAttr*, struct PingInitInfo*, void**))HcclDlsym(handle_, "RaPingInit");
     186          611 :     if (dlRaPingInit == nullptr) {
     187          611 :         HCCL_WARNING("Current package doesn't have dlRaPingInit, please check!");
     188              :     }
     189          611 :     dlRaPingDeinit = (int (*)(void*))HcclDlsym(handle_, "RaPingDeinit");
     190          611 :     if (dlRaPingDeinit == nullptr) {
     191          611 :         HCCL_WARNING("Current package doesn't have dlRaPingDeinit, please check!");
     192              :     }
     193          611 :     dlRaPingTargetAdd = (int (*)(void*, struct PingTargetInfo target[], uint32_t))HcclDlsym(handle_, "RaPingTargetAdd");
     194          611 :     if (dlRaPingTargetAdd == nullptr) {
     195          611 :         HCCL_WARNING("Current package doesn't have dlRaPingTargetAdd, please check!");
     196              :     }
     197              :     dlRaPingTargetDel
     198          611 :         = (int (*)(void*, struct PingTargetCommInfo target[], uint32_t))HcclDlsym(handle_, "RaPingTargetDel");
     199          611 :     if (dlRaPingTargetDel == nullptr) {
     200          611 :         HCCL_WARNING("Current package doesn't have dlRaPingTargetDel, please check!");
     201              :     }
     202          611 :     dlRaPingTaskStart = (int (*)(void*, struct PingTaskAttr*))HcclDlsym(handle_, "RaPingTaskStart");
     203          611 :     if (dlRaPingTaskStart == nullptr) {
     204          611 :         HCCL_WARNING("Current package doesn't have dlRaPingTaskStart, please check!");
     205              :     }
     206          611 :     dlRaPingTaskStop = (int (*)(void*))HcclDlsym(handle_, "RaPingTaskStop");
     207          611 :     if (dlRaPingTaskStop == nullptr) {
     208          611 :         HCCL_WARNING("Current package doesn't have dlRaPingTaskStop, please check!");
     209              :     }
     210              :     dlRaPingGetResults
     211          611 :         = (int (*)(void*, struct PingTargetResult target[], uint32_t*))HcclDlsym(handle_, "RaPingGetResults");
     212          611 :     if (dlRaPingGetResults == nullptr) {
     213          611 :         HCCL_WARNING("Current package doesn't have dlRaPingGetResults, please check!");
     214              :     }
     215              : 
     216          611 :     dlRaIsFirstUsed = (int (*)(int))HcclDlsym(handle_, "RaIsFirstUsed");
     217          611 :     CHK_SMART_PTR_NULL(dlRaIsFirstUsed);
     218              : 
     219          611 :     dlRaIsLastUsed = (int (*)(int))HcclDlsym(handle_, "RaIsLastUsed");
     220          611 :     CHK_SMART_PTR_NULL(dlRaIsLastUsed);
     221              : 
     222          611 :     dlRaRdevGetPortStatus = (int (*)(RdmaHandle, enum PortStatus*))HcclDlsym(handle_, "RaRdevGetPortStatus");
     223          611 :     CHK_SMART_PTR_NULL(dlRaRdevGetPortStatus);
     224              : 
     225          611 :     dlRaRemapMr = (int (*)(RdmaHandle, struct MemRemapInfo info[], unsigned int num))HcclDlsym(handle_, "RaRemapMr");
     226          611 :     if (dlRaRemapMr == nullptr) {
     227            0 :         HCCL_WARNING("Current package doesn't have dlRaRemapMr, please check!");
     228              :     }
     229              : 
     230          611 :     dlH2DTlvInit = (int (*)(struct TlvInitInfo*, uint32_t*, void**))HcclDlsym(handle_, "RaTlvInit");
     231          611 :     if (dlH2DTlvInit == nullptr) {
     232            0 :         HCCL_WARNING("Current package doesn't have dlH2DTlvInit, please check!");
     233              :     }
     234          611 :     dlH2DTlvDeinit = (int (*)(void*))HcclDlsym(handle_, "RaTlvDeinit");
     235          611 :     if (dlH2DTlvDeinit == nullptr) {
     236            0 :         HCCL_WARNING("Current package doesn't have dlH2DTlvDeinit, please check!");
     237              :     }
     238              :     dlH2DTlvRequest
     239          611 :         = (int (*)(void*, unsigned int, struct TlvMsg[], struct TlvMsg[]))HcclDlsym(handle_, "RaTlvRequest");
     240          611 :     if (dlH2DTlvRequest == nullptr) {
     241            0 :         HCCL_WARNING("Current package doesn't have H2DTlvRequest, please check!");
     242              :     }
     243          611 :     return HCCL_SUCCESS;
     244              : }
     245              : 
     246          611 : HcclResult DlRaFunction::DlRaFunctionSocketInit()
     247              : {
     248              :     dlRaGetNotifyBaseAddr
     249          611 :         = (int (*)(RdmaHandle, unsigned long long*, unsigned long long*))HcclDlsym(handle_, "RaGetNotifyBaseAddr");
     250          611 :     CHK_SMART_PTR_NULL(dlRaGetNotifyBaseAddr);
     251              :     dlRaGetSockets
     252          611 :         = (int (*)(unsigned int, struct SocketInfoT[], unsigned int, unsigned int*))HcclDlsym(handle_, "RaGetSockets");
     253          611 :     CHK_SMART_PTR_NULL(dlRaGetSockets);
     254          611 :     dlRaSocketBatchClose = (int (*)(struct SocketCloseInfoT[], unsigned int))HcclDlsym(handle_, "RaSocketBatchClose");
     255          611 :     CHK_SMART_PTR_NULL(dlRaSocketBatchClose);
     256              :     dlRaSocketBatchConnect
     257          611 :         = (int (*)(struct SocketConnectInfoT[], unsigned int num))HcclDlsym(handle_, "RaSocketBatchConnect");
     258          611 :     CHK_SMART_PTR_NULL(dlRaSocketBatchConnect);
     259              :     dlRaSocketBatchAbort
     260          611 :         = (int (*)(struct SocketConnectInfoT[], unsigned int num))HcclDlsym(handle_, "RaSocketBatchAbort");
     261          611 :     CHK_SMART_PTR_NULL(dlRaSocketBatchAbort);
     262          611 :     dlRaSocketDeInit = (int (*)(SocketHandle))HcclDlsym(handle_, "RaSocketDeinit");
     263          611 :     CHK_SMART_PTR_NULL(dlRaSocketDeInit);
     264          611 :     dlRaSocketInit = (int (*)(int, struct rdev, SocketHandle*))HcclDlsym(handle_, "RaSocketInit");
     265          611 :     CHK_SMART_PTR_NULL(dlRaSocketInit);
     266          611 :     dlRaSocketInitV1 = (int (*)(int, struct SocketInitInfoT, SocketHandle*))HcclDlsym(handle_, "RaSocketInitV1");
     267          611 :     CHK_SMART_PTR_NULL(dlRaSocketInitV1);
     268              :     dlRaSocketListenStart
     269          611 :         = (int (*)(struct SocketListenInfoT[], unsigned int))HcclDlsym(handle_, "RaSocketListenStart");
     270          611 :     CHK_SMART_PTR_NULL(dlRaSocketListenStart);
     271          611 :     dlRaSocketAcceptCreditAdd = (int (*)(struct SocketListenInfoT[], unsigned int, unsigned int))HcclDlsym(
     272          611 :         handle_, "RaSocketAcceptCreditAdd");
     273          611 :     CHK_SMART_PTR_NULL(dlRaSocketAcceptCreditAdd);
     274          611 :     dlRaSocketListenStop = (int (*)(struct SocketListenInfoT[], unsigned int))HcclDlsym(handle_, "RaSocketListenStop");
     275          611 :     CHK_SMART_PTR_NULL(dlRaSocketListenStop);
     276          611 :     dlRaSocketRecv = (int (*)(const FdHandle, const void*, unsigned long long, unsigned long long*))HcclDlsym(
     277          611 :         handle_, "RaSocketRecv");
     278          611 :     CHK_SMART_PTR_NULL(dlRaSocketRecv);
     279          611 :     dlRaSocketSend = (int (*)(const FdHandle, const void*, unsigned long long, unsigned long long*))HcclDlsym(
     280          611 :         handle_, "RaSocketSend");
     281          611 :     CHK_SMART_PTR_NULL(dlRaSocketSend);
     282              :     dlRaSocketSendAsync
     283          611 :         = (int (*)(const FdHandle, const void*, unsigned long long, unsigned long long*, void**))HcclDlsym(
     284          611 :             handle_, "RaSocketSendAsync");
     285          611 :     if (dlRaSocketSendAsync == nullptr) {
     286          611 :         HCCL_WARNING("dlRaSocketSendAsync is nullptr, can not use RaSocketSendAsync");
     287              :     }
     288          611 :     dlRaSocketRecvAsync = (int (*)(const FdHandle, void*, unsigned long long, unsigned long long*, void**))HcclDlsym(
     289          611 :         handle_, "RaSocketRecvAsync");
     290          611 :     if (dlRaSocketRecvAsync == nullptr) {
     291          611 :         HCCL_WARNING("dlRaSocketRecvAsync is nullptr, can not use RaSocketRecvAsync");
     292              :     }
     293          611 :     dlRaGetAsyncReqResult = (int (*)(void*, int*))HcclDlsym(handle_, "RaGetAsyncReqResult");
     294          611 :     if (dlRaGetAsyncReqResult == nullptr) {
     295          611 :         HCCL_WARNING("dlRaGetAsyncReqResult is nullptr, can not use RaGetAsyncReqResult");
     296              :     }
     297          611 :     dlRaSocketSetWhiteListStatus = (int (*)(unsigned int))HcclDlsym(handle_, "RaSocketSetWhiteListStatus");
     298          611 :     CHK_SMART_PTR_NULL(dlRaSocketSetWhiteListStatus);
     299          611 :     dlRaSocketGetWhiteListStatus = (int (*)(unsigned int*))HcclDlsym(handle_, "RaSocketGetWhiteListStatus");
     300          611 :     CHK_SMART_PTR_NULL(dlRaSocketGetWhiteListStatus);
     301              :     dlRaSocketWhiteListAdd
     302          611 :         = (int (*)(SocketHandle, struct SocketWlistInfoT[], unsigned int))HcclDlsym(handle_, "RaSocketWhiteListAdd");
     303          611 :     CHK_SMART_PTR_NULL(dlRaSocketWhiteListAdd);
     304              :     dlRaSocketWhiteListDel
     305          611 :         = (int (*)(SocketHandle, struct SocketWlistInfoT[], unsigned int))HcclDlsym(handle_, "RaSocketWhiteListDel");
     306          611 :     CHK_SMART_PTR_NULL(dlRaSocketWhiteListDel);
     307              :     /* 考虑兼容性问题,这里不校验dlRaGetIfNum是否为空,在使用处校验 */
     308          611 :     dlRaGetIfNum = (int (*)(struct RaGetIfattr* config, unsigned int* num))HcclDlsym(handle_, "RaGetIfnum");
     309          611 :     if (dlRaGetIfNum == nullptr) {
     310            0 :         HCCL_WARNING("dlRaGetIfNum is nullptr, can not use ra_get_ifnum");
     311              :     }
     312              : 
     313              :     dlRaGetIfAddress
     314          611 :         = (int (*)(struct RaGetIfattr* config, struct InterfaceInfo interface_infos[], unsigned int* num))HcclDlsym(
     315          611 :             handle_, "RaGetIfaddrs");
     316          611 :     CHK_SMART_PTR_NULL(dlRaGetIfAddress);
     317              :     dlRaGetInterfaceVersion
     318          611 :         = (int (*)(unsigned int phyId, unsigned int interface_opcode, unsigned int* interface_version))HcclDlsym(
     319          611 :             handle_, "RaGetInterfaceVersion");
     320          611 :     if (dlRaGetInterfaceVersion == nullptr) {
     321            0 :         HCCL_WARNING("dlRaGetInterfaceVersion is nullptr, can not use ra_get_interface_version");
     322              :     }
     323          611 :     dlRaEpollCtlAdd = (int (*)(const FdHandle fdHandle, RaEpollEvent event))HcclDlsym(handle_, "RaEpollCtlAdd");
     324          611 :     CHK_SMART_PTR_NULL(dlRaEpollCtlAdd);
     325          611 :     dlRaEpollCtlMod = (int (*)(const FdHandle fdHandle, RaEpollEvent event))HcclDlsym(handle_, "RaEpollCtlMod");
     326          611 :     CHK_SMART_PTR_NULL(dlRaEpollCtlMod);
     327          611 :     dlRaEpollCtlDel = (int (*)(const FdHandle fdHandle))HcclDlsym(handle_, "RaEpollCtlDel");
     328          611 :     CHK_SMART_PTR_NULL(dlRaEpollCtlDel);
     329              :     dlRaSetRecvDataCallback
     330          611 :         = (int (*)(const SocketHandle socketHandle, const void* callback))HcclDlsym(handle_, "RaSetTcpRecvCallback");
     331          611 :     CHK_SMART_PTR_NULL(dlRaSetRecvDataCallback);
     332              : 
     333          611 :     dlRaCreateEventHandle = (int (*)(int* event_handle))HcclDlsym(handle_, "RaCreateEventHandle");
     334          611 :     if (dlRaCreateEventHandle == nullptr) {
     335            0 :         HCCL_WARNING("dlRaCreateEventHandle is nullptr, can not use ra_create_event_handle");
     336              :     }
     337          611 :     dlRaCtlEventHandle = (int (*)(int event_handle, const void* fdHandle, int opcode, RaEpollEvent event))HcclDlsym(
     338          611 :         handle_, "RaCtlEventHandle");
     339          611 :     if (dlRaCtlEventHandle == nullptr) {
     340            0 :         HCCL_WARNING("dlRaCtlEventHandle is nullptr, can not use ra_ctl_event_handle");
     341              :     }
     342            0 :     dlRaWaitEventHandle = (int (*)(
     343              :         int event_handle, struct SocketEventInfoT* event_infos, int timeout, unsigned int maxevents,
     344          611 :         unsigned int* events_num))HcclDlsym(handle_, "RaWaitEventHandle");
     345          611 :     if (dlRaWaitEventHandle == nullptr) {
     346            0 :         HCCL_WARNING("dlRaWaitEventHandle is nullptr, can not use ra_wait_event_handle");
     347              :     }
     348          611 :     dlRaDestroyEventHandle = (int (*)(int* event_handle))HcclDlsym(handle_, "RaDestroyEventHandle");
     349          611 :     if (dlRaDestroyEventHandle == nullptr) {
     350            0 :         HCCL_WARNING("dlRaDestroyEventHandle is nullptr, can not use ra_destroy_event_handle");
     351              :     }
     352              : 
     353              :     dlRaGetSocketVnicIpInfos
     354          611 :         = (int (*)(unsigned int, enum IdType, unsigned int*, unsigned int, struct IpInfo infos[]))HcclDlsym(
     355          611 :             handle_, "RaSocketGetVnicIpInfos");
     356          611 :     CHK_SMART_PTR_NULL(dlRaGetSocketVnicIpInfos);
     357              : 
     358          611 :     dlRaRaGetTlsEnable = (int (*)(struct RaInfo*, bool*))HcclDlsym(handle_, "RaGetTlsEnable");
     359          611 :     if (dlRaRaGetTlsEnable == nullptr) {
     360            0 :         HCCL_WARNING("dlRaRaGetTlsEnable is nullptr, can not use ra_get_tls_enable");
     361              :     }
     362              : 
     363          611 :     dlRaSaveSnapShot = (int (*)(struct RaInfo*, enum SaveSnapshotAction))HcclDlsym(handle_, "RaSaveSnapshot");
     364          611 :     CHK_SMART_PTR_NULL(dlRaSaveSnapShot);
     365              : 
     366          611 :     dlRaRestoreSnapShot = (int (*)(struct RaInfo*))HcclDlsym(handle_, "RaRestoreSnapshot");
     367          611 :     CHK_SMART_PTR_NULL(dlRaRestoreSnapShot);
     368              : 
     369          611 :     dlRaGetHccnCfg = (int (*)(struct RaInfo*, enum HccnCfgKey, char*, int*))HcclDlsym(handle_, "RaGetHccnCfg");
     370          611 :     if (dlRaGetHccnCfg == nullptr) {
     371          611 :         HCCL_WARNING("dlRaGetHccnCfg is nullptr, can not use RaGetHccnCfg");
     372              :     }
     373          611 :     dlRaGetSecRandom = (int (*)(struct RaInfo* info, unsigned int*))HcclDlsym(handle_, "RaGetSecRandom");
     374          611 :     if (dlRaGetSecRandom == nullptr) {
     375          611 :         HCCL_WARNING("dlRaGetSecRandom is nullptr, can not use RaGetSecRandom");
     376              :     }
     377          611 :     dlRaGetDevEidInfoNum = (int (*)(RaInfo info, unsigned int*))HcclDlsym(handle_, "RaGetDevEidInfoNum");
     378          611 :     if (dlRaGetDevEidInfoNum == nullptr) {
     379          611 :         HCCL_WARNING("dlRaGetDevEidInfoNum is nullptr, can not use RaGetDevEidInfoNum");
     380              :     }
     381          611 :     dlRaGetDevEidInfoList = (int (*)(RaInfo info, struct HccpDevEidInfo* eid_info, unsigned int*))HcclDlsym(
     382          611 :         handle_, "RaGetDevEidInfoList");
     383          611 :     if (dlRaGetDevEidInfoList == nullptr) {
     384          611 :         HCCL_WARNING("dlRaGetDevEidInfoList is nullptr, can not use RaGetDevEidInfoList");
     385              :     }
     386          611 :     return HCCL_SUCCESS;
     387              : }
     388              : 
     389          611 : HcclResult DlRaFunction::DlRaFunctionInit()
     390              : {
     391          611 :     std::lock_guard<std::mutex> lock(handleMutex_);
     392          611 :     if (handle_ == nullptr) {
     393            8 :         handle_ = HcclDlopen("libra.so", RTLD_NOW);
     394            8 :         const char* errMsg = dlerror();
     395            8 :         CHK_PRT_RET(
     396              :             handle_ == nullptr,
     397              :             HCCL_ERROR(
     398              :                 "dlopen [%s] failed, %s", "libra.so",
     399              :                 (errMsg == nullptr) ? "please check the file exist or permission denied." : errMsg),
     400              :             HCCL_E_OPEN_FILE_FAILURE);
     401              :     }
     402          611 :     dlRaInit = (int (*)(struct RaInitConfig*))HcclDlsym(handle_, "RaInit");
     403          611 :     CHK_SMART_PTR_NULL(dlRaInit);
     404          611 :     dlRaDeInit = (int (*)(struct RaInitConfig*))HcclDlsym(handle_, "RaDeinit");
     405          611 :     CHK_SMART_PTR_NULL(dlRaDeInit);
     406          611 :     CHK_RET(DlRaFunctionRdmaInit());
     407          611 :     CHK_RET(DlRaFunctionSocketInit());
     408              : 
     409          611 :     return HCCL_SUCCESS;
     410          611 : }
     411              : } // namespace hccl
        

Generated by: LCOV version 2.0-1