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

Generated by: LCOV version 2.0-1