LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/adapter/ctx - ra_adp_ctx.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.4 % 294 254
Test Date: 2026-07-28 12:11:00 Functions: 93.8 % 32 30

            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_ctx.h"
      14              : #include "ra_hdc_ctx.h"
      15              : #include "ra_hdc_async_ctx.h"
      16              : #include "ra_rs_ctx.h"
      17              : #include "ra_rs_comm.h"
      18              : #include "rs_ctx.h"
      19              : #include "ra_adp.h"
      20              : #include "ra_adp_ctx.h"
      21              : 
      22              : struct RsCtxOps gRaRsCtxOps = {
      23              :     .getDevEidInfoNum = RsGetDevEidInfoNum,
      24              :     .getDevEidInfoList = RsGetDevEidInfoList,
      25              :     .ctxInit = RsCtxInit,
      26              :     .ctxGetAsyncEvents = RsCtxGetAsyncEvents,
      27              :     .ctxDeinit = RsCtxDeinit,
      28              :     .getEidByIp = RsGetEidByIp,
      29              :     .getTpInfoList = RsGetTpInfoList,
      30              :     .getTpAttr = RsGetTpAttr,
      31              :     .setTpAttr = RsSetTpAttr,
      32              :     .ctxTokenIdAlloc = RsCtxTokenIdAlloc,
      33              :     .ctxTokenIdFree = RsCtxTokenIdFree,
      34              :     .ctxLmemReg = RsCtxLmemReg,
      35              :     .ctxLmemUnreg = RsCtxLmemUnreg,
      36              :     .ctxRmemImport = RsCtxRmemImport,
      37              :     .ctxRmemUnimport = RsCtxRmemUnimport,
      38              :     .ctxChanCreate = RsCtxChanCreate,
      39              :     .ctxChanDestroy = RsCtxChanDestroy,
      40              :     .ctxCqCreate = RsCtxCqCreate,
      41              :     .ctxCqDestroy = RsCtxCqDestroy,
      42              :     .ctxQpCreate = RsCtxQpCreate,
      43              :     .ctxQpQueryBatch = RsCtxQpQueryBatch,
      44              :     .ctxQpDestroy = RsCtxQpDestroy,
      45              :     .ctxQpDestroyBatch = RsCtxQpDestroyBatch,
      46              :     .ctxQpImport = RsCtxQpImport,
      47              :     .ctxQpUnimport = RsCtxQpUnimport,
      48              :     .ctxQpBind = RsCtxQpBind,
      49              :     .ctxQpUnbind = RsCtxQpUnbind,
      50              :     .ctxBatchSendWr = RsCtxBatchSendWr,
      51              :     .ctxUpdateCi = RsCtxUpdateCi,
      52              :     .ctxGetAuxInfo = RsCtxGetAuxInfo,
      53              :     .ctxGetCrErrInfoList = RsCtxGetCrErrInfoList,
      54              :     .ctxGetUbContext = RsCtxGetUbContext,
      55              : };
      56              : 
      57            1 : int RaRsGetDevEidInfoNum(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      58              : {
      59            1 :     union OpGetDevEidInfoNumData *opData = (union OpGetDevEidInfoNumData *)(inBuf +
      60              :         sizeof(struct MsgHead));
      61            1 :     unsigned int num = 0;
      62              : 
      63              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetDevEidInfoNumData), sizeof(struct MsgHead), rcvBufLen,
      64              :         opResult);
      65              : 
      66            1 :     *opResult = gRaRsCtxOps.getDevEidInfoNum(opData->txData.phyId, &num);
      67            1 :     CHK_PRT_RETURN(*opResult != 0, hccp_err("[get][eid]get_dev_eid_info_num failed, ret[%d].", *opResult), 0);
      68              : 
      69            1 :     opData = (union OpGetDevEidInfoNumData *)(outBuf + sizeof(struct MsgHead));
      70            1 :     opData->rxData.num = num;
      71            1 :     return 0;
      72              : }
      73              : 
      74            1 : int RaRsGetDevEidInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      75              : {
      76            1 :     union OpGetDevEidInfoListData *opData = (union OpGetDevEidInfoListData *)(inBuf +
      77              :         sizeof(struct MsgHead));
      78            1 :     struct HccpDevEidInfo infoList[MAX_DEV_INFO_TRANS_NUM] = {0};
      79              : 
      80              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetDevEidInfoListData), sizeof(struct MsgHead), rcvBufLen,
      81              :         opResult);
      82              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.count, 0, MAX_DEV_INFO_TRANS_NUM, opResult);
      83              : 
      84            1 :     *opResult = gRaRsCtxOps.getDevEidInfoList(opData->txData.phyId, infoList,
      85              :         opData->txData.startIndex, opData->txData.count);
      86            1 :     CHK_PRT_RETURN(*opResult != 0, hccp_err("[get][eid]get_dev_eid_info_list failed, ret[%d].", *opResult), 0);
      87              : 
      88            1 :     opData = (union OpGetDevEidInfoListData *)(outBuf + sizeof(struct MsgHead));
      89            1 :     (void)memcpy_s(opData->rxData.infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM,
      90              :         infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM);
      91            1 :     return 0;
      92              : }
      93              : 
      94            1 : int RaRsCtxInit(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      95              : {
      96            1 :     union OpCtxInitData *opDataOut = (union OpCtxInitData *)(outBuf + sizeof(struct MsgHead));
      97            1 :     union OpCtxInitData *opData = (union OpCtxInitData *)(inBuf + sizeof(struct MsgHead));
      98              : 
      99              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxInitData), sizeof(struct MsgHead), rcvBufLen, opResult);
     100              : 
     101            1 :     *opResult = gRaRsCtxOps.ctxInit(&opData->txData.attr, &opDataOut->rxData.devIndex,
     102              :         &opDataOut->rxData.devAttr);
     103            1 :     if (*opResult != 0) {
     104            0 :         hccp_err("[init][ra_rs_ctx]init failed, ret[%d]", *opResult);
     105              :     }
     106              : 
     107            1 :     return 0;
     108              : }
     109              : 
     110            0 : int RaRsCtxGetAsyncEvents(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     111              : {
     112            0 :     union OpCtxGetAsyncEventsData *opDataOut =
     113              :         (union OpCtxGetAsyncEventsData *)(outBuf + sizeof(struct MsgHead));
     114            0 :     union OpCtxGetAsyncEventsData *opData =
     115              :         (union OpCtxGetAsyncEventsData *)(inBuf + sizeof(struct MsgHead));
     116            0 :     struct RaRsDevInfo devInfo = {0};
     117              : 
     118              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetAsyncEventsData), sizeof(struct MsgHead), rcvBufLen,
     119              :         opResult);
     120              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, ASYNC_EVENT_MAX_NUM, opResult);
     121              : 
     122            0 :     opDataOut->rxData.num = opData->txData.num;
     123            0 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     124            0 :     *opResult = gRaRsCtxOps.ctxGetAsyncEvents(&devInfo, opDataOut->rxData.events,
     125              :         &opDataOut->rxData.num);
     126            0 :     if (*opResult != 0) {
     127            0 :         hccp_err("[get][async_events]ctx_get_async_events failed, ret[%d] phyId[%u] devIndex[0x%x]",
     128              :             *opResult, devInfo.phyId, devInfo.devIndex);
     129              :     }
     130              : 
     131            0 :     return 0;
     132              : }
     133              : 
     134            1 : int RaRsCtxDeinit(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     135              : {
     136            1 :     union OpCtxDeinitData *opData = (union OpCtxDeinitData *)(inBuf + sizeof(struct MsgHead));
     137            1 :     struct RaRsDevInfo devInfo = {0};
     138              : 
     139              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxDeinitData), sizeof(struct MsgHead), rcvBufLen, opResult);
     140              : 
     141            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     142            1 :     *opResult = gRaRsCtxOps.ctxDeinit(&devInfo);
     143            1 :     if (*opResult != 0) {
     144            0 :         hccp_err("[deinit][ra_rs_ctx]deinit failed, ret[%d] phyId[%u] devIndex[0x%x]",
     145              :             *opResult, devInfo.phyId, devInfo.devIndex);
     146              :     }
     147              : 
     148            1 :     return 0;
     149              : }
     150              : 
     151            3 : int RaRsGetEidByIp(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     152              : {
     153            3 :     union OpGetEidByIpData *opDataOut = (union OpGetEidByIpData *)(outBuf + sizeof(struct MsgHead));
     154            3 :     union OpGetEidByIpData *opData = (union OpGetEidByIpData *)(inBuf + sizeof(struct MsgHead));
     155            3 :     struct RaRsDevInfo devInfo = {0};
     156              : 
     157              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetEidByIpData), sizeof(struct MsgHead), rcvBufLen, opResult);
     158              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, GET_EID_BY_IP_MAX_NUM, opResult);
     159              : 
     160            3 :     opDataOut->rxData.num = opData->txData.num;
     161            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     162            3 :     *opResult = gRaRsCtxOps.getEidByIp(&devInfo, opData->txData.ip, opDataOut->rxData.eid,
     163              :         &opDataOut->rxData.num);
     164            3 :     if (*opResult != 0) {
     165            1 :         hccp_err("[get][eid_by_ip]get_eid_by_ip failed, ret[%d], phyId[%u]", *opResult,
     166              :             opData->txData.phyId);
     167              :     }
     168              : 
     169            3 :     return 0;
     170              : }
     171              : 
     172            3 : int RaRsGetTpInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     173              : {
     174            3 :     union OpGetTpInfoListData *opDataOut = (union OpGetTpInfoListData *)(outBuf + sizeof(struct MsgHead));
     175            3 :     union OpGetTpInfoListData *opData = (union OpGetTpInfoListData *)(inBuf + sizeof(struct MsgHead));
     176            3 :     struct RaRsDevInfo devInfo = {0};
     177              : 
     178              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetTpInfoListData), sizeof(struct MsgHead), rcvBufLen,
     179              :         opResult);
     180              : 
     181              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_TPID_INFO_NUM, opResult);
     182            3 :     opDataOut->rxData.num = opData->txData.num;
     183            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     184            3 :     *opResult = gRaRsCtxOps.getTpInfoList(&devInfo, &opData->txData.cfg, opDataOut->rxData.infoList,
     185              :         &opDataOut->rxData.num);
     186            3 :     if (*opResult != 0) {
     187            1 :         hccp_err("[get][ra_rs_ctx]get_tp_info_list failed, ret[%d] phyId[%u] devIndex[0x%x]",
     188              :             *opResult, devInfo.phyId, devInfo.devIndex);
     189              :     }
     190              : 
     191            3 :     return 0;
     192              : }
     193              : 
     194            1 : int RaRsGetTpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     195              : {
     196            1 :     union OpGetTpAttrData *opDataOut = (union OpGetTpAttrData *)(outBuf + sizeof(struct MsgHead));
     197            1 :     union OpGetTpAttrData *opData = (union OpGetTpAttrData *)(inBuf + sizeof(struct MsgHead));
     198            1 :     struct RaRsDevInfo devInfo = {0};
     199              : 
     200              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetTpAttrData), sizeof(struct MsgHead), rcvBufLen,
     201              :         opResult);
     202              : 
     203            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     204            1 :     opDataOut->rxData.attrBitmap = opData->txData.attrBitmap;
     205            1 :     *opResult = gRaRsCtxOps.getTpAttr(&devInfo, &opDataOut->rxData.attrBitmap,
     206              :         opData->txData.tpHandle, &opDataOut->rxData.attr);
     207            1 :     if (*opResult != 0) {
     208            0 :         hccp_err("[get_tp_attr][ra_rs_ctx]get attr failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
     209              :     }
     210              : 
     211            1 :     return 0;
     212              : }
     213              : 
     214            1 : int RaRsSetTpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     215              : {
     216            1 :     union OpSetTpAttrData *opData = (union OpSetTpAttrData *)(inBuf + sizeof(struct MsgHead));
     217            1 :     struct RaRsDevInfo devInfo = {0};
     218              : 
     219              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpSetTpAttrData), sizeof(struct MsgHead), rcvBufLen,
     220              :         opResult);
     221              : 
     222            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     223            1 :     *opResult = gRaRsCtxOps.setTpAttr(&devInfo, opData->txData.attrBitmap,
     224              :         opData->txData.tpHandle, &opData->txData.attr);
     225            1 :     if (*opResult != 0) {
     226            0 :         hccp_err("[set_tp_attr][ra_rs_ctx]set attr failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
     227              :     }
     228              : 
     229            1 :     return 0;
     230              : }
     231              : 
     232            1 : int RaRsCtxTokenIdAlloc(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     233              : {
     234            1 :     union OpTokenIdAllocData *opDataOut = (union OpTokenIdAllocData *)(outBuf + sizeof(struct MsgHead));
     235            1 :     union OpTokenIdAllocData *opData = (union OpTokenIdAllocData *)(inBuf + sizeof(struct MsgHead));
     236            1 :     struct RaRsDevInfo devInfo = {0};
     237              : 
     238              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTokenIdAllocData), sizeof(struct MsgHead), rcvBufLen,
     239              :         opResult);
     240              : 
     241            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     242            1 :     *opResult = gRaRsCtxOps.ctxTokenIdAlloc(&devInfo, &opDataOut->rxData.addr,
     243              :         &opDataOut->rxData.tokenId);
     244            1 :     if (*opResult != 0) {
     245            0 :         hccp_err("[init][ra_rs_token_id]alloc failed, ret[%d] phyId[%u] devIndex[0x%x]",
     246              :             *opResult, devInfo.phyId, devInfo.devIndex);
     247              :     }
     248            1 :     return 0;
     249              : }
     250              : 
     251            1 : int RaRsCtxTokenIdFree(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     252              : {
     253            1 :     union OpTokenIdFreeData *opData = (union OpTokenIdFreeData *)(inBuf + sizeof(struct MsgHead));
     254            1 :     struct RaRsDevInfo devInfo = {0};
     255              : 
     256              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTokenIdFreeData), sizeof(struct MsgHead), rcvBufLen,
     257              :         opResult);
     258              : 
     259            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     260            1 :     *opResult = gRaRsCtxOps.ctxTokenIdFree(&devInfo, opData->txData.addr);
     261            1 :     if (*opResult != 0) {
     262            0 :         hccp_err("[deinit][ra_rs_token_id]free failed, ret[%d] phyId[%u] devIndex[0x%x]",
     263              :             *opResult, devInfo.phyId, devInfo.devIndex);
     264              :     }
     265            1 :     return 0;
     266              : }
     267              : 
     268            1 : int RaRsLmemReg(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     269              : {
     270            1 :     union OpLmemRegInfoData *opDataOut = (union OpLmemRegInfoData *)(outBuf + sizeof(struct MsgHead));
     271            1 :     union OpLmemRegInfoData *opData = (union OpLmemRegInfoData *)(inBuf + sizeof(struct MsgHead));
     272            1 :     struct RaRsDevInfo devInfo = {0};
     273              : 
     274              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpLmemRegInfoData), sizeof(struct MsgHead), rcvBufLen, opResult);
     275              : 
     276            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     277            1 :     *opResult = gRaRsCtxOps.ctxLmemReg(&devInfo, &opData->txData.memAttr, &opDataOut->rxData.memInfo);
     278            1 :     if (*opResult != 0) {
     279            0 :         hccp_err("[init][ra_rs_lmem]reg failed, ret[%d] phyId[%u] devIndex[0x%x]",
     280              :             *opResult, devInfo.phyId, devInfo.devIndex);
     281              :     }
     282              : 
     283            1 :     return 0;
     284              : }
     285              : 
     286            1 : int RaRsLmemUnreg(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     287              : {
     288            1 :     union OpLmemUnregInfoData *opData = (union OpLmemUnregInfoData *)(inBuf + sizeof(struct MsgHead));
     289            1 :     struct RaRsDevInfo devInfo = {0};
     290              : 
     291              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpLmemUnregInfoData), sizeof(struct MsgHead), rcvBufLen,
     292              :         opResult);
     293              : 
     294            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     295            1 :     *opResult = gRaRsCtxOps.ctxLmemUnreg(&devInfo, opData->txData.addr);
     296            1 :     if (*opResult != 0) {
     297            0 :         hccp_err("[deinit][ra_rs_lmem]unreg failed, ret[%d] phyId[%u] devIndex[0x%x]",
     298              :             *opResult, devInfo.phyId, devInfo.devIndex);
     299              :     }
     300              : 
     301            1 :     return 0;
     302              : }
     303              : 
     304            1 : int RaRsRmemImport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     305              : {
     306            1 :     union OpRmemImportInfoData *opDataOut = (union OpRmemImportInfoData *)(outBuf + sizeof(struct MsgHead));
     307            1 :     union OpRmemImportInfoData *opData = (union OpRmemImportInfoData *)(inBuf + sizeof(struct MsgHead));
     308            1 :     struct RaRsDevInfo devInfo = {0};
     309              : 
     310              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpRmemImportInfoData), sizeof(struct MsgHead), rcvBufLen,
     311              :         opResult);
     312              : 
     313            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     314            1 :     *opResult = gRaRsCtxOps.ctxRmemImport(&devInfo, &opData->txData.memAttr, &opDataOut->rxData.memInfo);
     315            1 :     if (*opResult != 0) {
     316            0 :         hccp_err("[init][ra_rs_rmem]import failed, ret[%d] phyId[%u] devIndex[0x%x]",
     317              :             *opResult, devInfo.phyId, devInfo.devIndex);
     318              :     }
     319              : 
     320            1 :     return 0;
     321              : }
     322              : 
     323            1 : int RaRsRmemUnimport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     324              : {
     325            1 :     union OpRmemUnimportInfoData *opData = (union OpRmemUnimportInfoData *)(inBuf + sizeof(struct MsgHead));
     326            1 :     struct RaRsDevInfo devInfo = {0};
     327              : 
     328              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpRmemUnimportInfoData), sizeof(struct MsgHead), rcvBufLen,
     329              :         opResult);
     330              : 
     331            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     332            1 :     *opResult = gRaRsCtxOps.ctxRmemUnimport(&devInfo, opData->txData.addr);
     333            1 :     if (*opResult != 0) {
     334            0 :         hccp_err("[deinit][ra_rs_rmem]unimport failed, ret[%d] phyId[%u] devIndex[0x%x]",
     335              :             *opResult, devInfo.phyId, devInfo.devIndex);
     336              :     }
     337              : 
     338            1 :     return 0;
     339              : }
     340              : 
     341            1 : int RaRsCtxChanCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     342              : {
     343            1 :     union OpCtxChanCreateData *opDataOut = (union OpCtxChanCreateData *)(outBuf + sizeof(struct MsgHead));
     344            1 :     union OpCtxChanCreateData *opData = (union OpCtxChanCreateData *)(inBuf + sizeof(struct MsgHead));
     345            1 :     struct RaRsDevInfo devInfo = {0};
     346              : 
     347              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxChanCreateData), sizeof(struct MsgHead), rcvBufLen,
     348              :         opResult);
     349              : 
     350            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     351            1 :     *opResult = gRaRsCtxOps.ctxChanCreate(&devInfo, opData->txData.dataPlaneFlag,
     352              :         &opDataOut->rxData.addr, &opDataOut->rxData.fd);
     353            1 :     if (*opResult != 0) {
     354            0 :         hccp_err("[init][ra_rs_chan]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
     355              :             *opResult, devInfo.phyId, devInfo.devIndex);
     356              :     }
     357              : 
     358            1 :     return 0;
     359              : }
     360              : 
     361            1 : int RaRsCtxChanDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     362              : {
     363            1 :     union OpCtxChanDestroyData *opData = (union OpCtxChanDestroyData *)(inBuf + sizeof(struct MsgHead));
     364            1 :     struct RaRsDevInfo devInfo = {0};
     365              : 
     366              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxChanDestroyData), sizeof(struct MsgHead), rcvBufLen, opResult);
     367              : 
     368            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     369            1 :     *opResult = gRaRsCtxOps.ctxChanDestroy(&devInfo, opData->txData.addr);
     370            1 :     if (*opResult != 0) {
     371            0 :         hccp_err("[deinit][ra_rs_chan]destroy failed, ret[%d] phyId[%u] devIndex[0x%x]",
     372              :             *opResult, devInfo.phyId, devInfo.devIndex);
     373              :     }
     374              : 
     375            1 :     return 0;
     376              : }
     377              : 
     378            1 : int RaRsCtxCqCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     379              : {
     380            1 :     union OpCtxCqCreateData *opDataOut = (union OpCtxCqCreateData *)(outBuf + sizeof(struct MsgHead));
     381            1 :     union OpCtxCqCreateData *opData = (union OpCtxCqCreateData *)(inBuf + sizeof(struct MsgHead));
     382            1 :     struct RaRsDevInfo devInfo = {0};
     383              : 
     384              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxCqCreateData), sizeof(struct MsgHead), rcvBufLen, opResult);
     385              : 
     386            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     387            1 :     *opResult = gRaRsCtxOps.ctxCqCreate(&devInfo, &opData->txData.attr, &opDataOut->rxData.info);
     388            1 :     if (*opResult != 0) {
     389            0 :         hccp_err("[init][ra_rs_cq]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
     390              :             *opResult, devInfo.phyId, devInfo.devIndex);
     391              :     }
     392              : 
     393            1 :     return 0;
     394              : }
     395              : 
     396            1 : int RaRsCtxCqDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     397              : {
     398            1 :     union OpCtxCqDestroyData *opData = (union OpCtxCqDestroyData *)(inBuf + sizeof(struct MsgHead));
     399            1 :     struct RaRsDevInfo devInfo = {0};
     400              : 
     401              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxCqDestroyData), sizeof(struct MsgHead), rcvBufLen,
     402              :         opResult);
     403              : 
     404            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     405            1 :     *opResult = gRaRsCtxOps.ctxCqDestroy(&devInfo, opData->txData.addr);
     406            1 :     if (*opResult != 0) {
     407            0 :         hccp_err("[deinit][ra_rs_cq]destroy failed, ret[%d] phyId[%u] devIndex[0x%x]",
     408              :             *opResult, devInfo.phyId, devInfo.devIndex);
     409              :     }
     410              : 
     411            1 :     return 0;
     412              : }
     413              : 
     414            1 : int RaRsCtxQpCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     415              : {
     416            1 :     union OpCtxQpCreateData *opDataOut = (union OpCtxQpCreateData *)(outBuf + sizeof(struct MsgHead));
     417            1 :     union OpCtxQpCreateData *opData = (union OpCtxQpCreateData *)(inBuf + sizeof(struct MsgHead));
     418            1 :     struct RaRsDevInfo devInfo = {0};
     419              : 
     420              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpCreateData), sizeof(struct MsgHead), rcvBufLen, opResult);
     421              : 
     422            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     423            1 :     *opResult = gRaRsCtxOps.ctxQpCreate(&devInfo, &opData->txData.qpAttr, &opDataOut->rxData.qpInfo);
     424            1 :     if (*opResult != 0) {
     425            0 :         hccp_err("[init][ra_rs_qp]create failed, ret[%d] phyId[%u] devIndex[0x%x]",
     426              :             *opResult, devInfo.phyId, devInfo.devIndex);
     427              :     }
     428              : 
     429            1 :     return 0;
     430              : }
     431              : 
     432            3 : int RaRsCtxQpQueryBatch(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     433              : {
     434            3 :     union OpCtxQpQueryBatchData *opData = (union OpCtxQpQueryBatchData *)(inBuf + sizeof(struct MsgHead));
     435            3 :     union OpCtxQpQueryBatchData *opDataOut = (union OpCtxQpQueryBatchData *)(outBuf +
     436              :         sizeof(struct MsgHead));
     437            3 :     struct RaRsDevInfo devInfo = {0};
     438              : 
     439              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpQueryBatchData), sizeof(struct MsgHead), rcvBufLen,
     440              :         opResult);
     441              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_QP_QUERY_NUM, opResult);
     442              : 
     443            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     444            3 :     opDataOut->rxData.num = opData->txData.num;
     445            3 :     *opResult = gRaRsCtxOps.ctxQpQueryBatch(&devInfo, opData->txData.ids, opDataOut->rxData.attr,
     446              :         &opDataOut->rxData.num);
     447            3 :     if (*opResult != 0) {
     448            1 :         hccp_err("[qp_batch][ra_rs_ctx]query failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
     449              :     }
     450              : 
     451            3 :     return 0;
     452              : }
     453              : 
     454            1 : int RaRsCtxQpDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     455              : {
     456            1 :     union OpCtxQpDestroyData *opData = (union OpCtxQpDestroyData *)(inBuf + sizeof(struct MsgHead));
     457            1 :     struct RaRsDevInfo devInfo = {0};
     458              : 
     459              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpDestroyData), sizeof(struct MsgHead), rcvBufLen,
     460              :         opResult);
     461              : 
     462            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     463              : 
     464            1 :     *opResult = gRaRsCtxOps.ctxQpDestroy(&devInfo, opData->txData.id);
     465            1 :     CHK_PRT_RETURN(*opResult == -ENODEV, hccp_warn("[deinit][ra_rs_qp]jetty not found, ret[%d] phyId[%u] "
     466              :         "devIndex[0x%x] qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
     467            1 :     CHK_PRT_RETURN(*opResult != 0, hccp_err("[deinit][ra_rs_qp]destroy failed, ret[%d] phyId[%u] devIndex[0x%x] "
     468              :         "qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
     469            1 :     return 0;
     470              : }
     471              : 
     472            3 : int RaRsCtxQpDestroyBatch(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     473              : {
     474            3 :     union OpCtxQpDestroyBatchData *opDataOut = (union OpCtxQpDestroyBatchData *)(outBuf +
     475              :         sizeof(struct MsgHead));
     476            3 :     union OpCtxQpDestroyBatchData *opData = (union OpCtxQpDestroyBatchData *)(inBuf +
     477              :         sizeof(struct MsgHead));
     478            3 :     struct RaRsDevInfo devInfo = {0};
     479              : 
     480              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpDestroyBatchData), sizeof(struct MsgHead), rcvBufLen,
     481              :         opResult);
     482              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, HCCP_MAX_QP_DESTROY_BATCH_NUM, opResult);
     483              : 
     484            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     485            3 :     opDataOut->rxData.num = opData->txData.num;
     486            3 :     *opResult = gRaRsCtxOps.ctxQpDestroyBatch(&devInfo, opData->txData.ids, &opDataOut->rxData.num);
     487            3 :     if (*opResult != 0) {
     488            1 :         hccp_err("[qp_batch][ra_rs_ctx]destroy failed, ret[%d], phyId[%u]", *opResult, opData->txData.phyId);
     489              :     }
     490              : 
     491            3 :     return 0;
     492              : }
     493              : 
     494            1 : int RaRsCtxQpImport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     495              : {
     496            1 :     union OpCtxQpImportData *opDataOut = (union OpCtxQpImportData *)(outBuf + sizeof(struct MsgHead));
     497            1 :     union OpCtxQpImportData *opData = (union OpCtxQpImportData *)(inBuf + sizeof(struct MsgHead));
     498            1 :     struct RsJettyImportAttr importAttr = {0};
     499            1 :     struct RsJettyImportInfo importInfo = {0};
     500            1 :     struct RaRsDevInfo devInfo = {0};
     501              : 
     502              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpImportData), sizeof(struct MsgHead), rcvBufLen, opResult);
     503              : 
     504            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     505            1 :     importAttr.key = opData->txData.key;
     506            1 :     importAttr.attr = opData->txData.attr;
     507            1 :     *opResult = gRaRsCtxOps.ctxQpImport(&devInfo, &importAttr, &importInfo);
     508            1 :     if (*opResult != 0) {
     509            0 :         hccp_err("[init][ra_rs_qp]import failed, ret[%d] phyId[%u] devIndex[0x%x]",
     510              :             *opResult, devInfo.phyId, devInfo.devIndex);
     511              :     }
     512              : 
     513            1 :     opDataOut->rxData.remJettyId = importInfo.remJettyId;
     514            1 :     opDataOut->rxData.info = importInfo.info;
     515              : 
     516            1 :     return 0;
     517              : }
     518              : 
     519            1 : int RaRsCtxQpUnimport(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     520              : {
     521            1 :     union OpCtxQpUnimportData *opData = (union OpCtxQpUnimportData *)(inBuf + sizeof(struct MsgHead));
     522            1 :     struct RaRsDevInfo devInfo = {0};
     523              : 
     524              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpUnimportData), sizeof(struct MsgHead), rcvBufLen,
     525              :         opResult);
     526              : 
     527            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     528            1 :     *opResult = gRaRsCtxOps.ctxQpUnimport(&devInfo, opData->txData.remJettyId);
     529            1 :     if (*opResult != 0) {
     530            0 :         hccp_err("[deinit][ra_rs_qp]unimport failed, ret[%d] phyId[%u] devIndex[0x%x] rem_qp_id[%u]",
     531              :             *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.remJettyId);
     532              :     }
     533              : 
     534            1 :     return 0;
     535              : }
     536              : 
     537            1 : int RaRsCtxQpBind(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     538              : {
     539            1 :     union OpCtxQpBindData *opData = (union OpCtxQpBindData *)(inBuf + sizeof(struct MsgHead));
     540            1 :     struct RsCtxQpInfo remoteQpInfo = {0};
     541            1 :     struct RsCtxQpInfo localQpInfo = {0};
     542            1 :     struct RaRsDevInfo devInfo = {0};
     543              : 
     544              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpBindData), sizeof(struct MsgHead), rcvBufLen, opResult);
     545              : 
     546            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     547            1 :     localQpInfo.id = opData->txData.id;
     548            1 :     localQpInfo.key = opData->txData.localQpKey;
     549            1 :     remoteQpInfo.id = opData->txData.remId;
     550            1 :     remoteQpInfo.key = opData->txData.remoteQpKey;
     551            1 :     *opResult = gRaRsCtxOps.ctxQpBind(&devInfo, &localQpInfo, &remoteQpInfo);
     552            1 :     if (*opResult != 0) {
     553            0 :         hccp_err("[init][ra_rs_qp]bind failed, ret[%d] phyId[%u] devIndex[0x%x] qpId[%u] rem_qp_id[%u]",
     554              :             *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id, opData->txData.remId);
     555              :     }
     556              : 
     557            1 :     return 0;
     558              : }
     559              : 
     560            1 : int RaRsCtxQpUnbind(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     561              : {
     562            1 :     union OpCtxQpUnbindData *opData = (union OpCtxQpUnbindData *)(inBuf + sizeof(struct MsgHead));
     563            1 :     struct RaRsDevInfo devInfo = {0};
     564              : 
     565              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxQpUnbindData), sizeof(struct MsgHead), rcvBufLen, opResult);
     566              : 
     567            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     568              : 
     569            1 :     *opResult = gRaRsCtxOps.ctxQpUnbind(&devInfo, opData->txData.id);
     570            1 :     CHK_PRT_RETURN(*opResult == -ENODEV, hccp_warn("[deinit][ra_rs_qp]jetty not found, ret[%d] phyId[%u] "
     571              :         "devIndex[0x%x] qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
     572            1 :     CHK_PRT_RETURN(*opResult != 0, hccp_err("[deinit][ra_rs_qp]unbind failed, ret[%d] phyId[%u] devIndex[0x%x] "
     573              :         "qpId[%u]", *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.id), 0);
     574            1 :     return 0;
     575              : }
     576              : 
     577            1 : int RaRsCtxBatchSendWr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     578              : {
     579            1 :     union OpCtxBatchSendWrData *opData = (union OpCtxBatchSendWrData *)(inBuf + sizeof(struct MsgHead));
     580            1 :     union OpCtxBatchSendWrData *opDataOut = (union OpCtxBatchSendWrData *)(outBuf +
     581              :         sizeof(struct MsgHead));
     582            1 :     struct WrlistSendCompleteNum wrlistNum = {0};
     583              : 
     584              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxBatchSendWrData), sizeof(struct MsgHead), rcvBufLen,
     585              :         opResult);
     586              : 
     587            1 :     wrlistNum.sendNum = opData->txData.sendNum;
     588            1 :     wrlistNum.completeNum = &opDataOut->rxData.completeNum;
     589            2 :     *opResult = gRaRsCtxOps.ctxBatchSendWr(&opData->txData.baseInfo, opData->txData.wrData,
     590            1 :         opDataOut->rxData.wrResp, &wrlistNum);
     591            1 :     if (*opResult != 0) {
     592            0 :         hccp_err("[send][ra_rs_ctx]batch send wr failed, ret[%d] qpId[%u] sendNum[%d] completeNum[%d]",
     593              :             *opResult, opData->txData.baseInfo.qpn, wrlistNum.sendNum, *wrlistNum.completeNum);
     594              :     }
     595              : 
     596            1 :     return 0;
     597              : }
     598              : 
     599            1 : int RaRsCtxUpdateCi(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     600              : {
     601            1 :     union OpCtxUpdateCiData *opData = (union OpCtxUpdateCiData *)(inBuf + sizeof(struct MsgHead));
     602            1 :     struct RaRsDevInfo devInfo = {0};
     603              : 
     604              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxUpdateCiData), sizeof(struct MsgHead), rcvBufLen, opResult);
     605              : 
     606            1 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     607            1 :     *opResult = gRaRsCtxOps.ctxUpdateCi(&devInfo, opData->txData.jettyId, opData->txData.ci);
     608            1 :     if (*opResult != 0) {
     609            0 :         hccp_err("[update_ci][ra_rs_ctx]update ci failed, ret[%d] phyId[%u] devIndex[0x%x] qpId[%u]",
     610              :             *opResult, devInfo.phyId, devInfo.devIndex, opData->txData.jettyId);
     611              :     }
     612              : 
     613            1 :     return 0;
     614              : }
     615              : 
     616            3 : int RaRsCtxGetAuxInfo(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     617              : {
     618            3 :     union OpCtxGetAuxInfoData *opDataOut = (union OpCtxGetAuxInfoData *)(outBuf + sizeof(struct MsgHead));
     619            3 :     union OpCtxGetAuxInfoData *opData = (union OpCtxGetAuxInfoData *)(inBuf + sizeof(struct MsgHead));
     620            3 :     struct RaRsDevInfo devInfo = {0};
     621              : 
     622              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetAuxInfoData), sizeof(struct MsgHead), rcvBufLen,
     623              :         opResult);
     624              : 
     625            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     626            3 :     *opResult = gRaRsCtxOps.ctxGetAuxInfo(&devInfo, &opData->txData.info, &opDataOut->rxData.info);
     627            3 :     if (*opResult != 0) {
     628            1 :         hccp_err("[get_aux_info][ra_rs_ctx]get aux info failed, ret[%d] phyId[%u] devIndex[0x%x]", *opResult,
     629              :             devInfo.phyId, devInfo.devIndex);
     630              :     }
     631              : 
     632            3 :     return 0;
     633              : }
     634              : 
     635            3 : int RaRsCtxGetCrErrInfoList(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     636              : {
     637            3 :     union OpCtxGetCrErrInfoListData *opDataOut =
     638              :         (union OpCtxGetCrErrInfoListData *)(outBuf + sizeof(struct MsgHead));
     639            3 :     union OpCtxGetCrErrInfoListData *opData =
     640              :         (union OpCtxGetCrErrInfoListData *)(inBuf + sizeof(struct MsgHead));
     641            3 :     struct RaRsDevInfo devInfo = {0};
     642              : 
     643              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetCrErrInfoListData), sizeof(struct MsgHead), rcvBufLen,
     644              :         opResult);
     645              :     HCCP_CHECK_PARAM_LEN_RET_HOST(opData->txData.num, 0, CR_ERR_INFO_MAX_NUM, opResult);
     646              : 
     647            3 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     648            3 :     opDataOut->rxData.num = opData->txData.num;
     649            3 :     *opResult = gRaRsCtxOps.ctxGetCrErrInfoList(&devInfo, opDataOut->rxData.infoList,
     650              :         &opDataOut->rxData.num);
     651            3 :     if (*opResult != 0) {
     652            1 :         hccp_err("[get][cr_err]ctx_get_cr_err_info_list failed, ret[%d], phyId[%u]", *opResult,
     653              :             opData->txData.phyId);
     654              :     }
     655              : 
     656            3 :     return 0;
     657              : }
     658              : 
     659            0 : int RaRsCtxGetUbContext(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     660              : {
     661            0 :     union OpCtxGetContextData *opDataOut =
     662              :         (union OpCtxGetContextData *)(outBuf + sizeof(struct MsgHead));
     663            0 :     union OpCtxGetContextData *opData =
     664              :         (union OpCtxGetContextData *)(inBuf + sizeof(struct MsgHead));
     665            0 :     struct RaRsDevInfo devInfo = {0};
     666              : 
     667              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpCtxGetContextData), sizeof(struct MsgHead), rcvBufLen,
     668              :         opResult);
     669              : 
     670            0 :     RaRsSetDevInfo(&devInfo, opData->txData.phyId, opData->txData.devIndex);
     671            0 :     opDataOut->rxData.len = opData->txData.len;
     672            0 :     *opResult = gRaRsCtxOps.ctxGetUbContext(&devInfo, opData->txData.id, opData->txData.contextType, opDataOut->rxData.context,
     673              :         &opDataOut->rxData.len);
     674            0 :     if (*opResult != 0) {
     675            0 :         hccp_err("[get][jettyContext]ctxGetJettyContext failed, ret:%d, phyId:%u devIndex:0x%x", *opResult,
     676              :             devInfo.phyId, devInfo.devIndex);
     677              :     }
     678              : 
     679            0 :     return 0;
     680              : }
        

Generated by: LCOV version 2.0-1