LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/client - ra_ctx.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 82.4 % 472 389
Test Date: 2026-08-18 17:47:01 Functions: 97.2 % 36 35

            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 "securec.h"
      12              : #include "user_log.h"
      13              : #include "hccp_common.h"
      14              : #include "hccp_ctx.h"
      15              : #include "ra.h"
      16              : #include "ra_hdc_ctx.h"
      17              : #include "ra_peer_ctx.h"
      18              : #include "ra_ctx.h"
      19              : 
      20              : struct RaCtxOps gRaHdcCtxOps = {
      21              :     .raCtxInit = RaHdcCtxInit,
      22              :     .raCtxGetAsyncEvents = RaHdcCtxGetAsyncEvents,
      23              :     .raCtxDeinit = RaHdcCtxDeinit,
      24              :     .raCtxGetEidByIp = RaHdcGetEidByIp,
      25              :     .raCtxGetIpByEid = RaHdcGetIpByEid,
      26              :     .raCtxTokenIdAlloc = RaHdcCtxTokenIdAlloc,
      27              :     .raCtxTokenIdFree = RaHdcCtxTokenIdFree,
      28              :     .raCtxLmemRegister = RaHdcCtxLmemRegister,
      29              :     .raCtxLmemUnregister = RaHdcCtxLmemUnregister,
      30              :     .raCtxRmemImport = RaHdcCtxRmemImport,
      31              :     .raCtxRmemUnimport = RaHdcCtxRmemUnimport,
      32              :     .raCtxChanCreate = RaHdcCtxChanCreate,
      33              :     .raCtxChanDestroy = RaHdcCtxChanDestroy,
      34              :     .raCtxCqCreate = RaHdcCtxCqCreate,
      35              :     .raCtxCqDestroy = RaHdcCtxCqDestroy,
      36              :     .raCtxQpCreate = RaHdcCtxQpCreate,
      37              :     .raCtxQpDestroy = RaHdcCtxQpDestroy,
      38              :     .raCtxQpImport = RaHdcCtxQpImport,
      39              :     .raCtxQpUnimport = RaHdcCtxQpUnimport,
      40              :     .raCtxQpBind = RaHdcCtxQpBind,
      41              :     .raCtxQpUnbind = RaHdcCtxQpUnbind,
      42              :     .raCtxBatchSendWr = RaHdcCtxBatchSendWr,
      43              :     .raCtxUpdateCi = RaHdcCtxUpdateCi,
      44              :     .raCtxQueryQpBatch = RaHdcCtxQpQueryBatch,
      45              :     .raCtxGetAuxInfo = RaHdcCtxGetAuxInfo,
      46              :     .raCtxGetJettyContext = RaHdcCtxGetJettyContext,
      47              : };
      48              : 
      49              : struct RaCtxOps gRaPeerCtxOps = {
      50              :     .raCtxInit = RaPeerCtxInit,
      51              :     .raCtxGetAsyncEvents = RaPeerCtxGetAsyncEvents,
      52              :     .raCtxDeinit = RaPeerCtxDeinit,
      53              :     .raCtxGetEidByIp = RaPeerGetEidByIp,
      54              :     .raCtxGetIpByEid = RaPeerGetIpByEid,
      55              :     .raCtxTokenIdAlloc = RaPeerCtxTokenIdAlloc,
      56              :     .raCtxTokenIdFree = RaPeerCtxTokenIdFree,
      57              :     .raCtxLmemRegister = RaPeerCtxLmemRegister,
      58              :     .raCtxLmemUnregister = RaPeerCtxLmemUnregister,
      59              :     .raCtxRmemImport = RaPeerCtxRmemImport,
      60              :     .raCtxRmemUnimport = RaPeerCtxRmemUnimport,
      61              :     .raCtxChanCreate = RaPeerCtxChanCreate,
      62              :     .raCtxChanDestroy = RaPeerCtxChanDestroy,
      63              :     .raCtxCqCreate = RaPeerCtxCqCreate,
      64              :     .raCtxCqDestroy = RaPeerCtxCqDestroy,
      65              :     .raCtxQpCreate = RaPeerCtxQpCreate,
      66              :     .raCtxQpDestroy = RaPeerCtxQpDestroy,
      67              :     .raCtxQpImport = RaPeerCtxQpImport,
      68              :     .raCtxQpUnimport = RaPeerCtxQpUnimport,
      69              :     .raCtxQpBind = RaPeerCtxQpBind,
      70              :     .raCtxQpUnbind = RaPeerCtxQpUnbind,
      71              :     .raCtxBatchSendWr = NULL,
      72              :     .raCtxUpdateCi = NULL,
      73              :     .raCtxQueryQpBatch = NULL,
      74              :     .raCtxGetAuxInfo = NULL,
      75              :     .raCtxGetJettyContext = RaPeerCtxGetJettyContext,
      76              : };
      77              : 
      78            3 : HCCP_ATTRI_VISI_DEF int RaGetDevEidInfoNum(struct RaInfo info, unsigned int *num)
      79              : {
      80              :     int ret;
      81              : 
      82            3 :     CHK_PRT_RETURN(num == NULL, hccp_err("[get][eid]num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
      83            3 :     CHK_PRT_RETURN(info.phyId >= RA_MAX_PHY_ID_NUM,
      84              :         hccp_err("[get][eid]phy_id(%u) must smaller than %u", info.phyId, RA_MAX_PHY_ID_NUM),
      85              :         ConverReturnCode(RDMA_OP, -EINVAL));
      86              : 
      87            3 :     hccp_run_info("Input parameters: phy_id[%u], nic_position:[%d]", info.phyId, info.mode);
      88            3 :     if (info.mode == NETWORK_OFFLINE) {
      89            1 :         ret = RaHdcGetDevEidInfoNum(info, num);
      90            1 :         CHK_PRT_RETURN(ret != 0,
      91              :             hccp_err("[get][eid]ra_hdc_get_dev_eid_info_num failed, ret(%d) phyId(%u)", ret, info.phyId),
      92              :             ConverReturnCode(RDMA_OP, ret));
      93            2 :     } else if (info.mode == NETWORK_PEER_ONLINE) {
      94            2 :         ret = RaPeerGetDevEidInfoNum(info, num);
      95            2 :         CHK_PRT_RETURN(ret != 0,
      96              :             hccp_err("[get][eid]ra_peer_get_dev_eid_info_num failed, ret(%d) phyId(%u)", ret, info.phyId),
      97              :             ConverReturnCode(RDMA_OP, ret));
      98              :     } else {
      99            0 :         hccp_err("[get][eid]mode(%d) do not support, phyId(%u)", info.mode, info.phyId);
     100            0 :         return ConverReturnCode(RDMA_OP, -EINVAL);
     101              :     }
     102              : 
     103            2 :     return 0;
     104              : }
     105              : 
     106            3 : HCCP_ATTRI_VISI_DEF int RaGetDevEidInfoList(struct RaInfo info, struct HccpDevEidInfo infoList[], unsigned int *num)
     107              : {
     108              :     int ret;
     109              : 
     110            3 :     CHK_PRT_RETURN(infoList == NULL || num == NULL, hccp_err("[get][eid]info_list or num is NULL"),
     111              :         ConverReturnCode(RDMA_OP, -EINVAL));
     112            3 :     CHK_PRT_RETURN(info.phyId >= RA_MAX_PHY_ID_NUM,
     113              :         hccp_err("[get][eid]phy_id(%u) must smaller than %u", info.phyId, RA_MAX_PHY_ID_NUM),
     114              :         ConverReturnCode(RDMA_OP, -EINVAL));
     115              : 
     116            3 :     hccp_run_info("Input parameters: phy_id[%u], nic_position:[%d]", info.phyId, info.mode);
     117            3 :     if (info.mode == NETWORK_OFFLINE) {
     118            1 :         ret = RaHdcGetDevEidInfoList(info.phyId, infoList, num);
     119            1 :         CHK_PRT_RETURN(ret != 0,
     120              :             hccp_err("[get][eid]ra_hdc_get_dev_eid_info_list failed, ret(%d) phyId(%u)", ret, info.phyId),
     121              :             ConverReturnCode(RDMA_OP, ret));
     122            2 :     } else if (info.mode == NETWORK_PEER_ONLINE) {
     123            2 :         ret = RaPeerGetDevEidInfoList(info.phyId, infoList, num);
     124            2 :         CHK_PRT_RETURN(ret != 0,
     125              :             hccp_err("[get][eid]ra_peer_get_dev_eid_info_list failed, ret(%d) phyId(%u)", ret, info.phyId),
     126              :             ConverReturnCode(RDMA_OP, ret));
     127              :     } else {
     128            0 :         hccp_err("[get][eid]mode(%d) do not support, phyId(%u)", info.mode, info.phyId);
     129            0 :         return ConverReturnCode(RDMA_OP, -EINVAL);
     130              :     }
     131              : 
     132            2 :     return 0;
     133              : }
     134              : 
     135            1 : STATIC int RaGetInitCtxHandle(struct CtxInitCfg *cfg, struct CtxInitAttr *attr, struct RaCtxHandle *ctxHandle)
     136              : {
     137            1 :     ctxHandle->protocol = PROTOCOL_UDMA;
     138              : 
     139            1 :     if (cfg->mode == NETWORK_OFFLINE) {
     140            1 :         ctxHandle->ctxOps = &gRaHdcCtxOps;
     141            0 :     } else if (cfg->mode == NETWORK_PEER_ONLINE) {
     142            0 :         ctxHandle->ctxOps = &gRaPeerCtxOps;
     143              :     } else {
     144            0 :         hccp_err("[init][ra_ctx]mode(%d) do not support, phyId(%u)", cfg->mode, attr->phyId);
     145            0 :         return -EINVAL;
     146              :     }
     147              : 
     148            1 :     CHK_PRT_RETURN(ctxHandle->ctxOps->raCtxInit == NULL,
     149              :         hccp_err("[init][ra_ctx]ra_ctx_init is NULL, phyId(%u)", attr->phyId), -EINVAL);
     150              : 
     151            1 :     (void)memcpy_s(&(ctxHandle->attr), sizeof(struct CtxInitAttr), attr, sizeof(struct CtxInitAttr));
     152            1 :     return 0;
     153              : }
     154              : 
     155            1 : HCCP_ATTRI_VISI_DEF int RaCtxInit(struct CtxInitCfg *cfg, struct CtxInitAttr *attr, void **ctxHandle)
     156              : {
     157            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     158              :     int ret;
     159              : 
     160            1 :     CHK_PRT_RETURN(cfg == NULL || attr == NULL || ctxHandle == NULL,
     161              :         hccp_err("[init][ra_ctx]cfg or attr or ctx_handle is NULL"), ConverReturnCode(HCCP_INIT, -EINVAL));
     162            1 :     CHK_PRT_RETURN(attr->phyId >= RA_MAX_PHY_ID_NUM,
     163              :         hccp_err("[init][ra_ctx]phy_id(%u) must smaller than %u", attr->phyId, RA_MAX_PHY_ID_NUM),
     164              :         ConverReturnCode(HCCP_INIT, -EINVAL));
     165              : 
     166            1 :     ctxHandleTmp = calloc(1, sizeof(struct RaCtxHandle));
     167            1 :     CHK_PRT_RETURN(ctxHandleTmp == NULL,
     168              :         hccp_err("[init][ra_ctx]calloc ctx_handle failed, errno(%d) phyId(%u)", errno, attr->phyId),
     169              :         ConverReturnCode(HCCP_INIT, -ENOMEM));
     170              : 
     171            1 :     ret = RaGetInitCtxHandle(cfg, attr, ctxHandleTmp);
     172            1 :     if (ret != 0) {
     173            0 :         hccp_err("[init][ra_ctx]ra_get_init_ctx_handle failed, ret(%d) phyId(%u)", ret, attr->phyId);
     174            0 :         goto err;
     175              :     }
     176              : 
     177            1 :     hccp_run_info("Input parameters: phy_id[%u], nic_position:[%d]", attr->phyId, cfg->mode);
     178            1 :     ret = ctxHandleTmp->ctxOps->raCtxInit(ctxHandleTmp, attr, &(ctxHandleTmp->devIndex), &(ctxHandleTmp->devAttr));
     179            1 :     if (ret != 0) {
     180            0 :         hccp_err("[init][ra_ctx]ctx init failed, ret(%d) phyId(%u)", ret, attr->phyId);
     181            0 :         goto err;
     182              :     }
     183              : 
     184            1 :     *ctxHandle = (void *)ctxHandleTmp;
     185            1 :     return 0;
     186              : 
     187            0 : err:
     188            0 :     free(ctxHandleTmp);
     189            0 :     ctxHandleTmp = NULL;
     190            0 :     return ConverReturnCode(HCCP_INIT, ret);
     191              : }
     192              : 
     193            1 : HCCP_ATTRI_VISI_DEF int RaGetDevBaseAttr(void *ctxHandle, struct DevBaseAttr *attr)
     194              : {
     195            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     196              : 
     197            1 :     CHK_PRT_RETURN(ctxHandle == NULL || attr == NULL, hccp_err("[get][dev_attr]ctx_handle or attr is NULL"),
     198              :         ConverReturnCode(RDMA_OP, -EINVAL));
     199              : 
     200            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     201            1 :     (void)memcpy_s(attr, sizeof(struct DevBaseAttr), &(ctxHandleTmp->devAttr), sizeof(struct DevBaseAttr));
     202              : 
     203            1 :     hccp_info("[get][dev_attr]phy_id(%u), devIndex(%u)", ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex);
     204            1 :     return 0;
     205              : }
     206              : 
     207            0 : HCCP_ATTRI_VISI_DEF int RaCtxGetAsyncEvents(void *ctxHandle, struct AsyncEvent events[], unsigned int *num)
     208              : {
     209            0 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     210            0 :     int ret = 0;
     211              : 
     212            0 :     CHK_PRT_RETURN(ctxHandle == NULL || events == NULL || num == NULL,
     213              :         hccp_err("[get][async_events]ctx_handle or events or num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     214              : 
     215            0 :     CHK_PRT_RETURN(*num == 0 || *num > ASYNC_EVENT_MAX_NUM,
     216              :         hccp_err("[get][async_events]num:%u must greater than 0"
     217              :                  " and less or equal to %d",
     218              :             *num, ASYNC_EVENT_MAX_NUM),
     219              :         ConverReturnCode(RDMA_OP, -EINVAL));
     220              : 
     221            0 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     222            0 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxGetAsyncEvents == NULL,
     223              :         hccp_err("[get][async_events]ctx_ops or ra_ctx_get_async_events is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     224              : 
     225            0 :     ret = ctxHandleTmp->ctxOps->raCtxGetAsyncEvents(ctxHandleTmp, events, num);
     226            0 :     CHK_PRT_RETURN(ret != 0,
     227              :         hccp_err("[get][async_events]get async events failed, ret:%d phyId(%u) devIndex:0x%x", ret,
     228              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     229              :         ConverReturnCode(RDMA_OP, ret));
     230              : 
     231            0 :     return ConverReturnCode(RDMA_OP, ret);
     232              : }
     233              : 
     234            1 : HCCP_ATTRI_VISI_DEF int RaCtxDeinit(void *ctxHandle)
     235              : {
     236            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     237              :     int ret;
     238              : 
     239            1 :     CHK_PRT_RETURN(ctxHandle == NULL, hccp_err("[deinit][ra_ctx]ctx_handle is NULL"),
     240              :         ConverReturnCode(RDMA_OP, -EINVAL));
     241              : 
     242            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     243            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxDeinit == NULL,
     244              :         hccp_err("[deinit][ra_ctx]ctx_ops or ra_ctx_deinit is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     245              : 
     246            1 :     hccp_run_info("Input parameters: phy_id[%u], devIndex[%u], protocol[%d]", ctxHandleTmp->attr.phyId,
     247              :         ctxHandleTmp->devIndex, ctxHandleTmp->protocol);
     248            1 :     ret = ctxHandleTmp->ctxOps->raCtxDeinit(ctxHandleTmp);
     249            1 :     if (ret != 0) {
     250            0 :         hccp_err("[deinit][ra_ctx]ctx deinit failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     251              :             ctxHandleTmp->devIndex);
     252              :     }
     253              : 
     254            1 :     ctxHandleTmp->ctxOps = NULL;
     255            1 :     free(ctxHandleTmp);
     256            1 :     ctxHandleTmp = NULL;
     257            1 :     return ConverReturnCode(HCCP_INIT, ret);
     258              : }
     259              : 
     260            5 : HCCP_ATTRI_VISI_DEF int RaGetEidByIp(void *ctxHandle, struct IpInfo ip[], union HccpEid eid[], unsigned int *num)
     261              : {
     262            5 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     263            5 :     int ret = 0;
     264              : 
     265            5 :     CHK_PRT_RETURN(ctxHandle == NULL || ip == NULL || eid == NULL || num == NULL,
     266              :         hccp_err("[get][eid_by_ip]ctx_handle or ip or eid or num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     267              : 
     268            4 :     CHK_PRT_RETURN(*num == 0 || *num > HCCP_EID_IP_QUERY_MAX_NUM,
     269              :         hccp_err("[get][eid_by_ip]num(%u) must greater than 0"
     270              :                  " and less or equal to %d",
     271              :             *num, HCCP_EID_IP_QUERY_MAX_NUM),
     272              :         ConverReturnCode(RDMA_OP, -EINVAL));
     273              : 
     274            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     275              : 
     276            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxGetEidByIp == NULL,
     277              :         hccp_err("[get][eid_by_ip]ctx_ops or ra_ctx_get_eid_by_ip is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     278              : 
     279            2 :     hccp_run_info("Input parameters: phyId:%u, devIndex:0x%x num:%u", ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex,
     280              :         *num);
     281              : 
     282            2 :     ret = ctxHandleTmp->ctxOps->raCtxGetEidByIp(ctxHandle, ip, eid, num);
     283            2 :     CHK_PRT_RETURN(ret != 0,
     284              :         hccp_err("[get][eid_by_ip]ra_ctx_get_eid_by_ip failed, ret(%d) phyId(%u) devIndex(0x%x)", ret,
     285              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     286              :         ConverReturnCode(RDMA_OP, ret));
     287              : 
     288            1 :     return ConverReturnCode(RDMA_OP, ret);
     289              : }
     290              : 
     291            5 : HCCP_ATTRI_VISI_DEF int RaGetIpByEid(void *ctxHandle, union HccpEid eid[], struct IpInfo ip[], unsigned int *num)
     292              : {
     293            5 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     294            5 :     int ret = 0;
     295              : 
     296            5 :     CHK_PRT_RETURN(ctxHandle == NULL || eid == NULL || ip == NULL || num == NULL,
     297              :         hccp_err("[get][IpByEid]ctxHandle or eid or ip or num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     298              : 
     299            4 :     CHK_PRT_RETURN(*num == 0 || *num > HCCP_EID_IP_QUERY_MAX_NUM,
     300              :         hccp_err("[get][IpByEid]num(%u) must greater than 0"
     301              :                  " and less or equal to %d",
     302              :             *num, HCCP_EID_IP_QUERY_MAX_NUM),
     303              :         ConverReturnCode(RDMA_OP, -EINVAL));
     304              : 
     305            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     306              : 
     307            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxGetIpByEid == NULL,
     308              :         hccp_err("[get][IpByEid]ctxOps or raCtxGetIpByEid is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     309              : 
     310            2 :     hccp_run_info("Input parameters: phy_id:%u, devIndex:0x%x num:%u", ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex,
     311              :         *num);
     312              : 
     313            2 :     ret = ctxHandleTmp->ctxOps->raCtxGetIpByEid(ctxHandle, eid, ip, num);
     314            2 :     CHK_PRT_RETURN(ret != 0,
     315              :         hccp_err("[get][IpByEid]raCtxGetIpByEid failed, ret(%d) phyId(%u) devIndex(0x%x)", ret,
     316              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     317              :         ConverReturnCode(RDMA_OP, ret));
     318              : 
     319            1 :     return ConverReturnCode(RDMA_OP, ret);
     320              : }
     321              : 
     322            4 : HCCP_ATTRI_VISI_DEF int RaCtxTokenIdAlloc(void *ctxHandle, struct HccpTokenId *info, void **tokenIdHandle)
     323              : {
     324            4 :     struct RaTokenIdHandle *tokenIdHandleTmp = NULL;
     325            4 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     326              :     int ret;
     327              : 
     328            4 :     CHK_PRT_RETURN(ctxHandle == NULL || info == NULL || tokenIdHandle == NULL,
     329              :         hccp_err("[init][ra_token_id]ctx_handle or info or token_id_handle is NULL"),
     330              :         ConverReturnCode(RDMA_OP, -EINVAL));
     331              : 
     332            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     333            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxTokenIdAlloc == NULL,
     334              :         hccp_err("[init][ra_token_id]ctx_ops or ra_ctx_token_id_alloc is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     335              : 
     336            3 :     tokenIdHandleTmp = (struct RaTokenIdHandle *)calloc(1, sizeof(struct RaTokenIdHandle));
     337            3 :     CHK_PRT_RETURN(tokenIdHandleTmp == NULL,
     338              :         hccp_err("[init][ra_token_id]calloc token_id_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     339              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     340              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     341              : 
     342            3 :     ret = ctxHandleTmp->ctxOps->raCtxTokenIdAlloc(ctxHandleTmp, info, tokenIdHandleTmp);
     343            3 :     if (ret != 0) {
     344            1 :         hccp_err("[init][ra_token_id]alloc failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     345              :             ctxHandleTmp->devIndex);
     346            1 :         goto err;
     347              :     }
     348              : 
     349            2 :     *tokenIdHandle = (void *)tokenIdHandleTmp;
     350            2 :     return 0;
     351              : 
     352            1 : err:
     353            1 :     free(tokenIdHandleTmp);
     354            1 :     tokenIdHandleTmp = NULL;
     355            1 :     return ConverReturnCode(RDMA_OP, ret);
     356              : }
     357              : 
     358            3 : HCCP_ATTRI_VISI_DEF int RaCtxTokenIdFree(void *ctxHandle, void *tokenIdHandle)
     359              : {
     360            3 :     struct RaTokenIdHandle *tokenIdHandleTmp = NULL;
     361            3 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     362              :     int ret;
     363              : 
     364            3 :     CHK_PRT_RETURN(ctxHandle == NULL || tokenIdHandle == NULL,
     365              :         hccp_err("[deinit][ra_token_id]ctx_handle or token_id_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     366              : 
     367            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     368            2 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxTokenIdFree == NULL,
     369              :         hccp_err("[deinit][ra_token_id]ctx_ops or ra_ctx_token_id_free is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     370              : 
     371            2 :     tokenIdHandleTmp = (struct RaTokenIdHandle *)tokenIdHandle;
     372            2 :     ret = ctxHandleTmp->ctxOps->raCtxTokenIdFree(ctxHandleTmp, tokenIdHandleTmp);
     373            2 :     if (ret != 0) {
     374            1 :         hccp_err("[deinit][ra_token_id]free failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     375              :             ctxHandleTmp->devIndex);
     376              :     }
     377              : 
     378            2 :     free(tokenIdHandleTmp);
     379            2 :     tokenIdHandleTmp = NULL;
     380            2 :     return ConverReturnCode(RDMA_OP, ret);
     381              : }
     382              : 
     383            2 : HCCP_ATTRI_VISI_DEF int RaCtxLmemRegister(void *ctxHandle, struct MrRegInfoT *lmemInfo, void **lmemHandle)
     384              : {
     385            2 :     struct RaLmemHandle *lmemHandleTmp = NULL;
     386            2 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     387              :     int ret;
     388              : 
     389            2 :     CHK_PRT_RETURN(ctxHandle == NULL || lmemInfo == NULL || lmemHandle == NULL,
     390              :         hccp_err("[init][ra_lmem]ctx_handle or lmem_info or lmem_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     391              : 
     392            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     393            2 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxLmemRegister == NULL,
     394              :         hccp_err("[init][ra_lmem]ctx_ops or ra_ctx_lmem_register is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     395              : 
     396            2 :     lmemHandleTmp = calloc(1, sizeof(struct RaLmemHandle));
     397            2 :     CHK_PRT_RETURN(lmemHandleTmp == NULL,
     398              :         hccp_err("[init][ra_lmem]calloc lmem_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     399              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     400              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     401              : 
     402            2 :     ret = ctxHandleTmp->ctxOps->raCtxLmemRegister(ctxHandleTmp, lmemInfo, lmemHandleTmp);
     403            2 :     if (ret != 0) {
     404            0 :         hccp_err("[init][ra_lmem]register failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     405              :             ctxHandleTmp->devIndex);
     406            0 :         goto err;
     407              :     }
     408              : 
     409            2 :     *lmemHandle = (void *)lmemHandleTmp;
     410            2 :     return 0;
     411              : 
     412            0 : err:
     413            0 :     free(lmemHandleTmp);
     414            0 :     lmemHandleTmp = NULL;
     415            0 :     return ConverReturnCode(RDMA_OP, ret);
     416              : }
     417              : 
     418            1 : HCCP_ATTRI_VISI_DEF int RaCtxLmemUnregister(void *ctxHandle, void *lmemHandle)
     419              : {
     420            1 :     struct RaLmemHandle *lmemHandleTmp = NULL;
     421            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     422              :     int ret;
     423              : 
     424            1 :     CHK_PRT_RETURN(ctxHandle == NULL || lmemHandle == NULL,
     425              :         hccp_err("[deinit][ra_lmem]ctx_handle or lmem_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     426              : 
     427            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     428            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxLmemUnregister == NULL,
     429              :         hccp_err("[deinit][ra_lmem]ctx_ops or ra_ctx_lmem_unregister is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     430              : 
     431            1 :     lmemHandleTmp = (struct RaLmemHandle *)lmemHandle;
     432            1 :     ret = ctxHandleTmp->ctxOps->raCtxLmemUnregister(ctxHandleTmp, lmemHandleTmp);
     433            1 :     if (ret != 0) {
     434            0 :         hccp_err("[deinit][ra_lmem]unregister failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     435              :             ctxHandleTmp->devIndex);
     436              :     }
     437              : 
     438            1 :     free(lmemHandleTmp);
     439            1 :     lmemHandleTmp = NULL;
     440            1 :     return ConverReturnCode(RDMA_OP, ret);
     441              : }
     442              : 
     443            1 : HCCP_ATTRI_VISI_DEF int RaCtxRmemImport(void *ctxHandle, struct MrImportInfoT *rmemInfo, void **rmemHandle)
     444              : {
     445            1 :     struct RaRmemHandle *rmemHandleTmp = NULL;
     446            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     447              :     int ret;
     448              : 
     449            1 :     CHK_PRT_RETURN(ctxHandle == NULL || rmemInfo == NULL || rmemHandle == NULL,
     450              :         hccp_err("[init][ra_rmem]ctx_handle or rmem_info or rmem_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     451              : 
     452            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     453            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxRmemImport == NULL,
     454              :         hccp_err("[init][ra_rmem]ctx_ops is NULL or ra_ctx_rmem_import ops is NULL"),
     455              :         ConverReturnCode(RDMA_OP, -EINVAL));
     456              : 
     457            1 :     rmemHandleTmp = calloc(1, sizeof(struct RaRmemHandle));
     458            1 :     CHK_PRT_RETURN(rmemHandleTmp == NULL,
     459              :         hccp_err("[init][ra_rmem]calloc rmem_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     460              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     461              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     462              : 
     463            1 :     ret = ctxHandleTmp->ctxOps->raCtxRmemImport(ctxHandleTmp, rmemInfo);
     464            1 :     if (ret != 0) {
     465            0 :         hccp_err("[init][ra_lmem]import failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     466              :             ctxHandleTmp->devIndex);
     467            0 :         goto err;
     468              :     }
     469              : 
     470            1 :     rmemHandleTmp->key = rmemInfo->in.key;
     471            1 :     rmemHandleTmp->addr = rmemInfo->out.ub.targetSegHandle;
     472            1 :     *rmemHandle = (void *)rmemHandleTmp;
     473            1 :     return 0;
     474              : 
     475            0 : err:
     476            0 :     free(rmemHandleTmp);
     477            0 :     rmemHandleTmp = NULL;
     478            0 :     return ConverReturnCode(RDMA_OP, ret);
     479              : }
     480              : 
     481            1 : HCCP_ATTRI_VISI_DEF int RaCtxRmemUnimport(void *ctxHandle, void *rmemHandle)
     482              : {
     483            1 :     struct RaRmemHandle *rmemHandleTmp = NULL;
     484            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     485              :     int ret;
     486              : 
     487            1 :     CHK_PRT_RETURN(ctxHandle == NULL || rmemHandle == NULL,
     488              :         hccp_err("[deinit][ra_rmem]ctx_handle or rmem_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     489              : 
     490            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     491            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxRmemUnimport == NULL,
     492              :         hccp_err("[deinit][ra_rmem]ctx_ops or ra_ctx_rmem_unimport is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     493              : 
     494            1 :     rmemHandleTmp = (struct RaRmemHandle *)rmemHandle;
     495            1 :     ret = ctxHandleTmp->ctxOps->raCtxRmemUnimport(ctxHandleTmp, rmemHandleTmp);
     496            1 :     if (ret != 0) {
     497            0 :         hccp_err("[deinit][ra_rmem]unimport failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     498              :             ctxHandleTmp->devIndex);
     499              :     }
     500              : 
     501            1 :     free(rmemHandleTmp);
     502            1 :     rmemHandleTmp = NULL;
     503            1 :     return ConverReturnCode(RDMA_OP, ret);
     504              : }
     505              : 
     506            1 : HCCP_ATTRI_VISI_DEF int RaCtxChanCreate(void *ctxHandle, struct ChanInfoT *chanInfo, void **chanHandle)
     507              : {
     508            1 :     struct RaChanHandle *chanHandleTmp = NULL;
     509            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     510              :     int ret;
     511              : 
     512            1 :     CHK_PRT_RETURN(ctxHandle == NULL || chanInfo == NULL || chanHandle == NULL,
     513              :         hccp_err("[init][ra_chan]ctx_handle or chan_info or chan_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     514              : 
     515            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     516            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxChanCreate == NULL,
     517              :         hccp_err("[init][ra_chan]ctx_ops or ra_ctx_chan_create ops is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     518              : 
     519            1 :     chanHandleTmp = (struct RaChanHandle *)calloc(1, sizeof(struct RaChanHandle));
     520            1 :     CHK_PRT_RETURN(chanHandleTmp == NULL,
     521              :         hccp_err("[init][ra_chan]calloc chan_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     522              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     523              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     524              : 
     525            1 :     ret = ctxHandleTmp->ctxOps->raCtxChanCreate(ctxHandleTmp, chanInfo, chanHandleTmp);
     526            1 :     if (ret != 0) {
     527            0 :         hccp_err("[init][ra_chan]create failed, ret(%d)", ret);
     528            0 :         goto err;
     529              :     }
     530              : 
     531            1 :     *chanHandle = (void *)chanHandleTmp;
     532            1 :     return 0;
     533              : 
     534            0 : err:
     535            0 :     free(chanHandleTmp);
     536            0 :     chanHandleTmp = NULL;
     537            0 :     return ConverReturnCode(RDMA_OP, ret);
     538              : }
     539              : 
     540            1 : HCCP_ATTRI_VISI_DEF int RaCtxChanDestroy(void *ctxHandle, void *chanHandle)
     541              : {
     542            1 :     struct RaChanHandle *chanHandleTmp = NULL;
     543            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     544              :     int ret;
     545              : 
     546            1 :     CHK_PRT_RETURN(ctxHandle == NULL || chanHandle == NULL,
     547              :         hccp_err("[deinit][ra_chan]ctx_handle or chan_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     548              : 
     549            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     550            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxChanDestroy == NULL,
     551              :         hccp_err("[deinit][ra_chan]ctx_ops or ra_ctx_chan_destroy is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     552              : 
     553            1 :     chanHandleTmp = (struct RaChanHandle *)chanHandle;
     554            1 :     ret = ctxHandleTmp->ctxOps->raCtxChanDestroy(ctxHandleTmp, chanHandleTmp);
     555            1 :     if (ret != 0) {
     556            0 :         hccp_err("[deinit][ra_chan]destroy failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     557              :             ctxHandleTmp->devIndex);
     558              :     }
     559              : 
     560            1 :     free(chanHandleTmp);
     561            1 :     chanHandleTmp = NULL;
     562            1 :     return ConverReturnCode(RDMA_OP, ret);
     563              : }
     564              : 
     565            4 : HCCP_ATTRI_VISI_DEF int RaCtxCqCreate(void *ctxHandle, struct CqInfoT *info, void **cqHandle)
     566              : {
     567            4 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     568            4 :     struct RaCqHandle *cqHandleTmp = NULL;
     569              :     int ret;
     570              : 
     571            4 :     CHK_PRT_RETURN(ctxHandle == NULL || info == NULL || cqHandle == NULL,
     572              :         hccp_err("[init][ra_cq]ctx_handle or info or cq_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     573              : 
     574            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     575            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxCqCreate == NULL,
     576              :         hccp_err("[init][ra_cq]ctx_ops or ra_ctx_cq_create ops is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     577              : 
     578            3 :     cqHandleTmp = (struct RaCqHandle *)calloc(1, sizeof(struct RaCqHandle));
     579            3 :     CHK_PRT_RETURN(cqHandleTmp == NULL,
     580              :         hccp_err("[init][ra_cq]calloc cq_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     581              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     582              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     583              : 
     584            3 :     ret = ctxHandleTmp->ctxOps->raCtxCqCreate(ctxHandleTmp, info, cqHandleTmp);
     585            3 :     if (ret != 0) {
     586            0 :         hccp_err("[init][ra_cq]create failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     587              :             ctxHandleTmp->devIndex);
     588            0 :         goto err;
     589              :     }
     590              : 
     591            3 :     *cqHandle = (void *)cqHandleTmp;
     592            3 :     return 0;
     593              : 
     594            0 : err:
     595            0 :     free(cqHandleTmp);
     596            0 :     cqHandleTmp = NULL;
     597            0 :     return ConverReturnCode(RDMA_OP, ret);
     598              : }
     599              : 
     600            2 : HCCP_ATTRI_VISI_DEF int RaCtxCqDestroy(void *ctxHandle, void *cqHandle)
     601              : {
     602            2 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     603            2 :     struct RaCqHandle *cqHandleTmp = NULL;
     604              :     int ret;
     605              : 
     606            2 :     CHK_PRT_RETURN(ctxHandle == NULL || cqHandle == NULL, hccp_err("[deinit][ra_cq]ctx_handle or cq_handle is NULL"),
     607              :         ConverReturnCode(RDMA_OP, -EINVAL));
     608              : 
     609            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     610            2 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxCqDestroy == NULL,
     611              :         hccp_err("[deinit][ra_cq]ctx_ops or ra_ctx_cq_destroy is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     612              : 
     613            2 :     cqHandleTmp = (struct RaCqHandle *)cqHandle;
     614            2 :     ret = ctxHandleTmp->ctxOps->raCtxCqDestroy(ctxHandleTmp, cqHandleTmp);
     615            2 :     if (ret != 0) {
     616            0 :         hccp_err("[deinit][ra_cq]destroy failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     617              :             ctxHandleTmp->devIndex);
     618              :     }
     619              : 
     620            2 :     free(cqHandleTmp);
     621            2 :     cqHandleTmp = NULL;
     622            2 :     return ConverReturnCode(RDMA_OP, ret);
     623              : }
     624              : 
     625            4 : HCCP_ATTRI_VISI_DEF int RaCtxQpCreate(void *ctxHandle, struct QpCreateAttr *attr, struct QpCreateInfo *info,
     626              :     void **qpHandle)
     627              : {
     628            4 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     629            4 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     630              :     int ret;
     631              : 
     632            4 :     CHK_PRT_RETURN(ctxHandle == NULL || attr == NULL || info == NULL || qpHandle == NULL,
     633              :         hccp_err("[init][ra_qp]ctx_handle or attr or info or qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     634              : 
     635            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     636            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxQpCreate == NULL,
     637              :         hccp_err("[init][ra_qp]ctx_ops or ra_ctx_qp_create is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     638              : 
     639            3 :     qpHandleTmp = calloc(1, sizeof(struct RaCtxQpHandle));
     640            3 :     CHK_PRT_RETURN(qpHandleTmp == NULL,
     641              :         hccp_err("[init][ra_qp]calloc qp_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     642              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     643              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     644              : 
     645            3 :     ret = ctxHandleTmp->ctxOps->raCtxQpCreate(ctxHandleTmp, attr, info, qpHandleTmp);
     646            3 :     if (ret != 0) {
     647            0 :         hccp_err("[init][ra_qp]create failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     648              :             ctxHandleTmp->devIndex);
     649            0 :         goto err;
     650              :     }
     651              : 
     652            3 :     *qpHandle = (void *)qpHandleTmp;
     653            3 :     return 0;
     654              : 
     655            0 : err:
     656            0 :     free(qpHandleTmp);
     657            0 :     qpHandleTmp = NULL;
     658            0 :     return ConverReturnCode(RDMA_OP, ret);
     659              : }
     660              : 
     661            6 : STATIC int QpQueryBatchParamCheck(void *qpHandle[], unsigned int *num, unsigned int phyId, unsigned int ids[])
     662              : {
     663            6 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     664              :     unsigned int i;
     665              : 
     666            8 :     for (i = 0; i < *num; i++) {
     667            7 :         qpHandleTmp = (struct RaCtxQpHandle *)qpHandle[i];
     668            7 :         CHK_PRT_RETURN(qpHandleTmp == NULL, hccp_err("[query][ra_qp]qp_handle[%u] is NULL", i), -EINVAL);
     669            6 :         CHK_PRT_RETURN(qpHandleTmp->phyId != phyId,
     670              :             hccp_err("[query][ra_qp]qp_handle[%u] comes from different devices, phyId[%u] != qpHandle[0]->phyId(%u)", i,
     671              :                 qpHandleTmp->phyId, phyId),
     672              :             -EINVAL);
     673            5 :         CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     674              :                            qpHandleTmp->ctxHandle->ctxOps->raCtxQueryQpBatch == NULL,
     675              :             hccp_err("[query][ra_qp]ctx_handle or ctx_ops or ra_ctx_query_qp_batch is NULL"), -EINVAL);
     676              : 
     677            2 :         ids[i] = qpHandleTmp->id;
     678              :     }
     679              : 
     680            1 :     return 0;
     681              : }
     682              : 
     683            6 : HCCP_ATTRI_VISI_DEF int RaCtxQpQueryBatch(void *qpHandle[], struct JettyAttr attr[], unsigned int *num)
     684              : {
     685            6 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     686            6 :     unsigned int ids[HCCP_MAX_QP_QUERY_NUM] = {0};
     687              :     unsigned int phyId, devIndex;
     688              :     int ret;
     689              : 
     690            6 :     CHK_PRT_RETURN(qpHandle == NULL || attr == NULL, hccp_err("[query][ra_qp]qp_handle or attr is NULL"),
     691              :         ConverReturnCode(RDMA_OP, -EINVAL));
     692            4 :     CHK_PRT_RETURN(num == NULL, hccp_err("num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     693            3 :     CHK_PRT_RETURN(*num == 0 || *num > HCCP_MAX_QP_QUERY_NUM,
     694              :         hccp_err("[query][ra_qp]num(%u) is out of range(0, %u]", *num, HCCP_MAX_QP_QUERY_NUM),
     695              :         ConverReturnCode(RDMA_OP, -EINVAL));
     696              : 
     697            2 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle[0];
     698            2 :     CHK_PRT_RETURN(qpHandleTmp == NULL, hccp_err("[query][ra_qp]qp_handle[0] is NULL"), -EINVAL);
     699            2 :     phyId = qpHandleTmp->phyId;
     700            2 :     devIndex = qpHandleTmp->devIndex;
     701              : 
     702            2 :     ret = QpQueryBatchParamCheck(qpHandle, num, phyId, ids);
     703            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[query][ra_qp]qp_query_batch_param_check failed, ret(%d)", ret),
     704              :         ConverReturnCode(RDMA_OP, ret));
     705              : 
     706            2 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxQueryQpBatch(phyId, devIndex, ids, attr, num);
     707            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[query][ra_qp]query_qp_batch failed, ret(%d)", ret),
     708              :         ConverReturnCode(RDMA_OP, ret));
     709              : 
     710            1 :     return ConverReturnCode(RDMA_OP, ret);
     711              : }
     712              : 
     713            2 : HCCP_ATTRI_VISI_DEF int RaCtxQpDestroy(void *qpHandle)
     714              : {
     715            2 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     716              :     int ret;
     717              : 
     718            2 :     CHK_PRT_RETURN(qpHandle == NULL, hccp_err("[deinit][ra_qp]qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     719              : 
     720            2 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
     721            2 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     722              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxQpDestroy == NULL,
     723              :         hccp_err("[deinit][ra_qp]ctx_handle or ctx_ops "
     724              :                  "or ra_ctx_qp_destroy is NULL"),
     725              :         ConverReturnCode(RDMA_OP, -EINVAL));
     726              : 
     727            2 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxQpDestroy(qpHandleTmp);
     728            2 :     if (ret == -ENODEV) {
     729            0 :         hccp_warn("[deinit][ra_qp]destroy unsuccessful, ret(%d) phyId(%u) devIndex(%u) qp_id(%u)", ret,
     730              :             qpHandleTmp->phyId, qpHandleTmp->devIndex, qpHandleTmp->id);
     731            0 :         goto out;
     732              :     }
     733            2 :     if (ret != 0) {
     734            0 :         hccp_err("[deinit][ra_qp]destroy failed, ret(%d) phyId(%u) devIndex(%u) qp_id(%u)", ret, qpHandleTmp->phyId,
     735              :             qpHandleTmp->devIndex, qpHandleTmp->id);
     736              :     }
     737              : 
     738            2 : out:
     739            2 :     free(qpHandleTmp);
     740            2 :     qpHandleTmp = NULL;
     741            2 :     return ConverReturnCode(RDMA_OP, ret);
     742              : }
     743              : 
     744            4 : HCCP_ATTRI_VISI_DEF int RaCtxGetTpInfoList(void *ctxHandle, struct GetTpCfg *cfg, struct HccpTpInfo infoList[],
     745              :     unsigned int *num)
     746              : {
     747            4 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     748            4 :     int ret = 0;
     749              : 
     750            4 :     CHK_PRT_RETURN(ctxHandle == NULL || cfg == NULL, hccp_err("[get][RaTpInfo]ctxHandle or cfg is NULL"),
     751              :         ConverReturnCode(RDMA_OP, -EINVAL));
     752            3 :     CHK_PRT_RETURN(infoList == NULL || num == NULL, hccp_err("[get][RaTpInfo]infoList or num is NULL"),
     753              :         ConverReturnCode(RDMA_OP, -EINVAL));
     754            2 :     CHK_PRT_RETURN(*num == 0 || *num > HCCP_MAX_TPID_INFO_NUM,
     755              :         hccp_err("[get][RaTpInfo]*num(%u) is out of range[0, %d]", *num, HCCP_MAX_TPID_INFO_NUM),
     756              :         ConverReturnCode(RDMA_OP, -EINVAL));
     757              : 
     758            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     759            1 :     ret = RaPeerCtxGetTpInfoList(ctxHandleTmp, cfg, infoList, num);
     760            1 :     return ConverReturnCode(RDMA_OP, ret);
     761              : }
     762              : 
     763            3 : HCCP_ATTRI_VISI_DEF int RaCtxGetTpAttr(void *ctxHandle, uint64_t tpHandle, uint32_t *attrBitmap, struct TpAttr *attr)
     764              : {
     765            3 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     766            3 :     int ret = 0;
     767              : 
     768            3 :     CHK_PRT_RETURN(ctxHandle == NULL || attrBitmap == NULL || attr == NULL,
     769              :         hccp_err("[get][RaTpAttr]ctxHandle or attrBitmap or attr is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     770              : 
     771            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     772            2 :     ret = RaPeerCtxGetTpAttr(ctxHandleTmp, tpHandle, attrBitmap, attr);
     773            2 :     CHK_PRT_RETURN(ret != 0,
     774              :         hccp_err("[get][RaTpAttr]RaPeerCtxGetTpAttr failed, ret[%d] phyId[%u] devIndex[0x%x]", ret,
     775              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     776              :         ConverReturnCode(RDMA_OP, ret));
     777              : 
     778            1 :     return ConverReturnCode(RDMA_OP, ret);
     779              : }
     780              : 
     781            3 : HCCP_ATTRI_VISI_DEF int RaCtxSetTpAttr(void *ctxHandle, uint64_t tpHandle, uint32_t attrBitmap, struct TpAttr *attr)
     782              : {
     783            3 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     784            3 :     int ret = 0;
     785              : 
     786            3 :     CHK_PRT_RETURN(ctxHandle == NULL || attr == NULL, hccp_err("[set][RaTpAttr]ctxHandle or attr or attr is NULL"),
     787              :         ConverReturnCode(RDMA_OP, -EINVAL));
     788              : 
     789            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     790            2 :     ret = RaPeerCtxSetTpAttr(ctxHandleTmp, tpHandle, attrBitmap, attr);
     791            2 :     CHK_PRT_RETURN(ret != 0,
     792              :         hccp_err("[set][RaTpAttr]RaPeerCtxSetTpAttr failed, ret[%d] phyId[%u] devIndex[0x%x]", ret,
     793              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     794              :         ConverReturnCode(RDMA_OP, ret));
     795              : 
     796            1 :     return ConverReturnCode(RDMA_OP, ret);
     797              : }
     798              : 
     799            1 : HCCP_ATTRI_VISI_DEF int RaCtxQpImport(void *ctxHandle, struct QpImportInfoT *qpInfo, void **remQpHandle)
     800              : {
     801            1 :     struct RaCtxRemQpHandle *remQpHandleTmp = NULL;
     802            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     803              :     int ret;
     804              : 
     805            1 :     CHK_PRT_RETURN(ctxHandle == NULL || qpInfo == NULL || remQpHandle == NULL,
     806              :         hccp_err("[init][ra_qp]ctx_handle or qp_info or rem_qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     807              : 
     808            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     809            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxQpImport == NULL,
     810              :         hccp_err("[init][ra_qp]ctx_ops or ra_ctx_qp_import is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     811              : 
     812            1 :     remQpHandleTmp = calloc(1, sizeof(struct RaCtxRemQpHandle));
     813            1 :     CHK_PRT_RETURN(remQpHandleTmp == NULL,
     814              :         hccp_err("[init][ra_qp]calloc rem_qp_handle_tmp failed, errno(%d) phyId(%u) devIndex(%u)", errno,
     815              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
     816              :         ConverReturnCode(RDMA_OP, -ENOMEM));
     817              : 
     818            1 :     ret = ctxHandleTmp->ctxOps->raCtxQpImport(ctxHandleTmp, qpInfo, remQpHandleTmp);
     819            1 :     if (ret != 0) {
     820            0 :         hccp_err("[init][ra_qp]import failed, ret(%d) phyId(%u) devIndex(%u)", ret, ctxHandleTmp->attr.phyId,
     821              :             ctxHandleTmp->devIndex);
     822            0 :         goto err;
     823              :     }
     824              : 
     825            1 :     *remQpHandle = (void *)remQpHandleTmp;
     826            1 :     return 0;
     827              : 
     828            0 : err:
     829            0 :     free(remQpHandleTmp);
     830            0 :     remQpHandleTmp = NULL;
     831            0 :     return ConverReturnCode(RDMA_OP, ret);
     832              : }
     833              : 
     834            1 : HCCP_ATTRI_VISI_DEF int RaCtxQpUnimport(void *ctxHandle, void *remQpHandle)
     835              : {
     836            1 :     struct RaCtxRemQpHandle *remQpHandleTmp = NULL;
     837            1 :     struct RaCtxHandle *ctxHandleTmp = NULL;
     838              :     int ret;
     839              : 
     840            1 :     CHK_PRT_RETURN(ctxHandle == NULL || remQpHandle == NULL,
     841              :         hccp_err("[deinit][ra_qp]ctx_handle or rem_qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     842              : 
     843            1 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
     844            1 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxQpUnimport == NULL,
     845              :         hccp_err("[deinit][ra_qp]ctx_ops or ra_ctx_qp_unimport is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     846              : 
     847            1 :     remQpHandleTmp = (struct RaCtxRemQpHandle *)remQpHandle;
     848            1 :     ret = ctxHandleTmp->ctxOps->raCtxQpUnimport(remQpHandleTmp);
     849            1 :     if (ret != 0) {
     850            0 :         hccp_err("[deinit][ra_qp]unimport failed, ret(%d) phyId(%u) devIndex(%u) qp_id(%u)", ret, remQpHandleTmp->phyId,
     851              :             remQpHandleTmp->devIndex, remQpHandleTmp->id);
     852              :     }
     853              : 
     854            1 :     free(remQpHandleTmp);
     855            1 :     remQpHandleTmp = NULL;
     856            1 :     return ConverReturnCode(RDMA_OP, ret);
     857              : }
     858              : 
     859            1 : HCCP_ATTRI_VISI_DEF int RaCtxQpBind(void *qpHandle, void *remQpHandle)
     860              : {
     861            1 :     struct RaCtxRemQpHandle *remQpHandleTmp = NULL;
     862            1 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     863              :     int ret;
     864              : 
     865            1 :     CHK_PRT_RETURN(qpHandle == NULL || remQpHandle == NULL, hccp_err("[init][ra_qp]qp_handle or rem_qp_handle is NULL"),
     866              :         ConverReturnCode(RDMA_OP, -EINVAL));
     867              : 
     868            1 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
     869            1 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     870              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxQpBind == NULL,
     871              :         hccp_err("[init][ra_qp]ctx_handle or ctx_ops "
     872              :                  "or ra_ctx_qp_bind is NULL"),
     873              :         ConverReturnCode(RDMA_OP, -EINVAL));
     874              : 
     875            1 :     remQpHandleTmp = (struct RaCtxRemQpHandle *)remQpHandle;
     876            1 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxQpBind(qpHandleTmp, remQpHandleTmp);
     877            1 :     CHK_PRT_RETURN(ret != 0,
     878              :         hccp_err("[init][ra_qp]bind failed, ret(%d) phyId(%u) devIndex(%u) "
     879              :                  "local_id(%u) remote_id(%u)",
     880              :             ret, qpHandleTmp->ctxHandle->attr.phyId, qpHandleTmp->ctxHandle->devIndex, qpHandleTmp->id,
     881              :             remQpHandleTmp->id),
     882              :         ConverReturnCode(RDMA_OP, ret));
     883              : 
     884            1 :     return 0;
     885              : }
     886              : 
     887            2 : HCCP_ATTRI_VISI_DEF int RaCtxQpUnbind(void *qpHandle)
     888              : {
     889            2 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     890              :     int ret;
     891              : 
     892            2 :     CHK_PRT_RETURN(qpHandle == NULL, hccp_err("[deinit][ra_qp]qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     893              : 
     894            2 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
     895            2 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     896              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxQpUnbind == NULL,
     897              :         hccp_err("[deinit][ra_qp]ctx_handle or ctx_ops "
     898              :                  "or ra_ctx_qp_unbind is NULL"),
     899              :         ConverReturnCode(RDMA_OP, -EINVAL));
     900              : 
     901            2 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxQpUnbind(qpHandleTmp);
     902            2 :     CHK_PRT_RETURN(ret == -ENODEV,
     903              :         hccp_warn("[deinit][ra_qp]unbind unsuccessful, ret(%d) phyId(%u) devIndex(%u)", ret,
     904              :             qpHandleTmp->ctxHandle->attr.phyId, qpHandleTmp->ctxHandle->devIndex),
     905              :         ConverReturnCode(RDMA_OP, ret));
     906              : 
     907            1 :     CHK_PRT_RETURN(ret != 0,
     908              :         hccp_err("[deinit][ra_qp]unbind failed, ret(%d) phyId(%u) devIndex(%u)", ret,
     909              :             qpHandleTmp->ctxHandle->attr.phyId, qpHandleTmp->ctxHandle->devIndex),
     910              :         ConverReturnCode(RDMA_OP, ret));
     911            1 :     return ConverReturnCode(RDMA_OP, ret);
     912              : }
     913              : 
     914            2 : STATIC int RaCtxBatchSendWrCheck(struct RaCtxQpHandle *qpHandle, struct SendWrData wrList[], unsigned int num)
     915              : {
     916            2 :     enum ProtocolTypeT protocol = qpHandle->protocol;
     917            2 :     bool isInline = false;
     918              :     unsigned int i, j;
     919              : 
     920            4 :     for (i = 0; i < num; i++) {
     921              :         // NOP opcode no need to check
     922            2 :         if (protocol == PROTOCOL_UDMA && wrList[i].ub.opcode == RA_UB_OPC_NOP) {
     923            0 :             continue;
     924              :         }
     925              : 
     926            2 :         CHK_PRT_RETURN(wrList[i].rmemHandle == NULL, hccp_err("[send][ra_qp]wr[%u] rmem_handle is NULL", i), -EINVAL);
     927              : 
     928            3 :         isInline = ((protocol == PROTOCOL_RDMA && (wrList[i].rdma.flags & RA_SEND_INLINE) != 0) ||
     929            1 :                     (protocol == PROTOCOL_UDMA && wrList[i].ub.flags.bs.inlineFlag != 0));
     930            2 :         if (!isInline) {
     931            0 :             CHK_PRT_RETURN((wrList[i].sges == NULL), hccp_err("[send][ra_qp]wr[%u] sges is NULL", i), -EINVAL);
     932              : 
     933            0 :             for (j = 0; j < wrList[i].numSge; j++) {
     934            0 :                 CHK_PRT_RETURN((wrList[i].sges[j].lmemHandle == NULL),
     935              :                     hccp_err("[send][ra_qp]wr[%u] sges[%u] lmem_handle is NULL", i, j), -EINVAL);
     936              :             }
     937            2 :         } else if (wrList[i].inlineData == NULL) {
     938            0 :             hccp_err("[send][ra_qp]wr[%u] inline_data is NULL", i);
     939            0 :             return -EINVAL;
     940              :         }
     941              : 
     942            2 :         if (protocol == PROTOCOL_UDMA) {
     943            1 :             if (wrList[i].ub.remQpHandle == NULL ||
     944            1 :                 (wrList[i].ub.opcode == RA_UB_OPC_WRITE_NOTIFY && wrList[i].ub.notifyInfo.notifyHandle == NULL)) {
     945            0 :                 hccp_err("[send][ra_qp]wr[%u] opcode[%d] rem_qp_handle or notify_handle is NULL", i,
     946              :                     wrList[i].ub.opcode);
     947            0 :                 return -EINVAL;
     948              :             }
     949              : 
     950              :             // checkreduce, only write & write with notify & read op supportreduce
     951            1 :             if ((wrList[i].ub.opcode != RA_UB_OPC_WRITE && wrList[i].ub.opcode != RA_UB_OPC_WRITE_NOTIFY &&
     952            0 :                     wrList[i].ub.opcode != RA_UB_OPC_READ) &&
     953            0 :                 wrList[i].ub.reduceInfo.reduceEn) {
     954            0 :                 hccp_err("[send][ra_qp]wr[%u] opcode[%d] not supportreduce", i, wrList[i].ub.opcode);
     955            0 :                 return -EINVAL;
     956              :             }
     957              :         }
     958              :     }
     959              : 
     960            2 :     return 0;
     961              : }
     962              : 
     963            2 : HCCP_ATTRI_VISI_DEF int RaBatchSendWr(void *qpHandle, struct SendWrData wrList[], struct SendWrResp opResp[],
     964              :     unsigned int num, unsigned int *completeNum)
     965              : {
     966            2 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     967              :     int ret;
     968              : 
     969            2 :     CHK_PRT_RETURN(qpHandle == NULL || wrList == NULL || opResp == NULL || num == 0 || completeNum == NULL,
     970              :         hccp_err("[send][ra_qp]qp_handle or wr_list or op_resp or complete_num is NULL, or num[%u] is 0", num),
     971              :         ConverReturnCode(RDMA_OP, -EINVAL));
     972              : 
     973            2 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
     974            2 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     975              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxBatchSendWr == NULL,
     976              :         hccp_err("[send][ra_qp]ctx_handle or ctx_ops or ra_ctx_batch_send_wr is NULL"),
     977              :         ConverReturnCode(RDMA_OP, -EINVAL));
     978              : 
     979            2 :     ret = RaCtxBatchSendWrCheck(qpHandleTmp, wrList, num);
     980            2 :     CHK_PRT_RETURN(ret != 0,
     981              :         hccp_err("[send][ra_qp]check failed, ret(%d), protocol(%d) phyId(%u), devIndex(%u)", ret, qpHandleTmp->protocol,
     982              :             qpHandleTmp->ctxHandle->attr.phyId, qpHandleTmp->ctxHandle->devIndex),
     983              :         ConverReturnCode(RDMA_OP, ret));
     984              : 
     985            2 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxBatchSendWr(qpHandleTmp, wrList, opResp, num, completeNum);
     986            2 :     return ConverReturnCode(RDMA_OP, ret);
     987              : }
     988              : 
     989            1 : HCCP_ATTRI_VISI_DEF int RaCtxUpdateCi(void *qpHandle, uint16_t ci)
     990              : {
     991            1 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     992              :     int ret;
     993              : 
     994            1 :     CHK_PRT_RETURN(qpHandle == NULL, hccp_err("[update][ra_qp]qp_handle is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
     995              : 
     996            1 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
     997            1 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
     998              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxUpdateCi == NULL,
     999              :         hccp_err("[update][ra_qp]ctx_handle or ctx_ops "
    1000              :                  "or ra_ctx_update_ci is NULL"),
    1001              :         ConverReturnCode(RDMA_OP, -EINVAL));
    1002              : 
    1003            1 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxUpdateCi(qpHandleTmp, ci);
    1004            1 :     return ConverReturnCode(RDMA_OP, ret);
    1005              : }
    1006              : 
    1007            5 : HCCP_ATTRI_VISI_DEF int RaCtxGetAuxInfo(void *ctxHandle, struct HccpAuxInfoIn *in, struct HccpAuxInfoOut *out)
    1008              : {
    1009            5 :     struct RaCtxHandle *ctxHandleTmp = NULL;
    1010            5 :     int ret = 0;
    1011              : 
    1012            5 :     CHK_PRT_RETURN(ctxHandle == NULL || in == NULL || out == NULL,
    1013              :         hccp_err("[get][aux_info]ctx_handle or in or out is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
    1014              : 
    1015            4 :     CHK_PRT_RETURN(in->type < AUX_INFO_IN_TYPE_CQE || in->type >= AUX_INFO_IN_TYPE_MAX,
    1016              :         hccp_err("[get][aux_info]in->type(%d) must greater or equal to %d and less than %d", in->type,
    1017              :             AUX_INFO_IN_TYPE_CQE, AUX_INFO_IN_TYPE_MAX),
    1018              :         ConverReturnCode(RDMA_OP, -EINVAL));
    1019              : 
    1020            3 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
    1021            3 :     CHK_PRT_RETURN(ctxHandleTmp->ctxOps == NULL || ctxHandleTmp->ctxOps->raCtxGetAuxInfo == NULL,
    1022              :         hccp_err("[get][aux_info]ctx_ops or ra_ctx_get_aux_info is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
    1023              : 
    1024            2 :     ret = ctxHandleTmp->ctxOps->raCtxGetAuxInfo(ctxHandle, in, out);
    1025            2 :     CHK_PRT_RETURN(ret != 0,
    1026              :         hccp_err("[get][aux_info]ra_ctx_get_aux_info failed, ret(%d) phyId(%u) devIndex(0x%x)", ret,
    1027              :             ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
    1028              :         ConverReturnCode(RDMA_OP, ret));
    1029              : 
    1030            1 :     return ConverReturnCode(RDMA_OP, ret);
    1031              : }
    1032              : 
    1033            7 : HCCP_ATTRI_VISI_DEF int RaCtxGetCrErrInfoList(void *ctxHandle, struct CrErrInfo *infoList, unsigned int *num)
    1034              : {
    1035            7 :     struct RaCtxHandle *ctxHandleTmp = NULL;
    1036              :     int ret;
    1037              : 
    1038            7 :     CHK_PRT_RETURN(ctxHandle == NULL || infoList == NULL || num == NULL,
    1039              :         hccp_err("[get][cr_err_info_list]ctx_handle or info_list or num is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
    1040              : 
    1041            4 :     CHK_PRT_RETURN(*num == 0 || *num > CR_ERR_INFO_MAX_NUM,
    1042              :         hccp_err("[get][cr_err_info_list]num:%u must greater "
    1043              :                  "than 0 and less or equal to %d",
    1044              :             *num, CR_ERR_INFO_MAX_NUM),
    1045              :         ConverReturnCode(RDMA_OP, -EINVAL));
    1046              : 
    1047            2 :     ctxHandleTmp = (struct RaCtxHandle *)ctxHandle;
    1048              : 
    1049            2 :     hccp_run_info("Input parameters: phy_id(%u), devIndex(0x%x) num(%u)", ctxHandleTmp->attr.phyId,
    1050              :         ctxHandleTmp->devIndex, *num);
    1051              : 
    1052            2 :     ret = RaHdcCtxGetCrErrInfoList(ctxHandleTmp, infoList, num);
    1053            2 :     CHK_PRT_RETURN(ret != 0,
    1054              :         hccp_err("[get][cr_err_info_list]ra_hdc_ctx_get_cr_err_info_list failed, ret:%d "
    1055              :                  "phyId:%u devIndex:0x%x",
    1056              :             ret, ctxHandleTmp->attr.phyId, ctxHandleTmp->devIndex),
    1057              :         ConverReturnCode(RDMA_OP, ret));
    1058              : 
    1059            1 :     return ConverReturnCode(RDMA_OP, ret);
    1060              : }
    1061              : 
    1062            8 : HCCP_ATTRI_VISI_DEF int RaCtxGetJettyContext(void *qpHandle, uint8_t context[], unsigned int *len)
    1063              : {
    1064            8 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
    1065            8 :     int ret = 0;
    1066              : 
    1067            8 :     CHK_PRT_RETURN(qpHandle == NULL || context == NULL || len == NULL,
    1068              :         hccp_err("[get][jettyContext]qpHandle or context or len is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
    1069              : 
    1070            5 :     CHK_PRT_RETURN(*len < CONTEXT_MAX_LEN, hccp_err("[get][jettyContext]len:%u less than %d", *len, CONTEXT_MAX_LEN),
    1071              :         ConverReturnCode(RDMA_OP, -EINVAL));
    1072              : 
    1073            4 :     qpHandleTmp = (struct RaCtxQpHandle *)qpHandle;
    1074            4 :     CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL || qpHandleTmp->ctxHandle->ctxOps == NULL ||
    1075              :                        qpHandleTmp->ctxHandle->ctxOps->raCtxGetJettyContext == NULL,
    1076              :         hccp_err("[get][jettyContext]ctxHandle or"
    1077              :                  " ctxOps or raCtxGetJettyContext is NULL"),
    1078              :         ConverReturnCode(RDMA_OP, -EINVAL));
    1079              : 
    1080            2 :     hccp_run_info("Input parameters: phyId:%u, devIndex:0x%x jettyId:%u len:%u", qpHandleTmp->phyId,
    1081              :         qpHandleTmp->devIndex, qpHandleTmp->qpInfo.ub.id, *len);
    1082              : 
    1083            2 :     ret = qpHandleTmp->ctxHandle->ctxOps->raCtxGetJettyContext(qpHandleTmp, context, len);
    1084            2 :     CHK_PRT_RETURN(ret != 0,
    1085              :         hccp_err("[get][jettyContext]raCtxGetJettyContext failed, ret:%d phyId:%u devIndex"
    1086              :                  ":0x%x",
    1087              :             ret, qpHandleTmp->phyId, qpHandleTmp->devIndex),
    1088              :         ConverReturnCode(RDMA_OP, ret));
    1089              : 
    1090            1 :     return ConverReturnCode(RDMA_OP, ret);
    1091              : }
        

Generated by: LCOV version 2.0-1