LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/hdc - ra_hdc_ctx.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.1 % 461 420
Test Date: 2026-07-28 12:11:00 Functions: 97.4 % 38 37

            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 <stdlib.h>
      12              : #include <string.h>
      13              : #include <arpa/inet.h>
      14              : #include <unistd.h>
      15              : #include <errno.h>
      16              : #include "securec.h"
      17              : #include "user_log.h"
      18              : #include "hccp_ctx.h"
      19              : #include "ra.h"
      20              : #include "ra_ctx.h"
      21              : #include "ra_ctx_comm.h"
      22              : #include "ra_rs_err.h"
      23              : #include "ra_hdc.h"
      24              : #include "ra_hdc_ctx.h"
      25              : 
      26            1 : int RaHdcGetDevEidInfoNum(struct RaInfo info, unsigned int *num)
      27              : {
      28            1 :     union OpGetDevEidInfoNumData opData = {0};
      29              :     int ret;
      30              : 
      31            1 :     *num = 0;
      32            1 :     opData.txData.phyId = info.phyId;
      33            1 :     ret = RaHdcProcessMsg(RA_RS_GET_DEV_EID_INFO_NUM, info.phyId, (char *)&opData,
      34              :         sizeof(union OpGetDevEidInfoNumData));
      35            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][eid]hdc message process failed ret[%d], phyId[%u]",
      36              :         ret, info.phyId), ret);
      37              : 
      38            1 :     *num = opData.rxData.num;
      39            1 :     return 0;
      40              : }
      41              : 
      42            2 : STATIC int RaHdcGetDevEidSubInfoList(unsigned int phyId, struct HccpDevEidInfo infoList[],
      43              :     unsigned int startIndex, unsigned int count)
      44              : {
      45            2 :     union OpGetDevEidInfoListData opData = {0};
      46              :     int ret;
      47              : 
      48            2 :     opData.txData.phyId = phyId;
      49            2 :     opData.txData.startIndex = startIndex;
      50            2 :     opData.txData.count = count;
      51            2 :     ret = RaHdcProcessMsg(RA_RS_GET_DEV_EID_INFO_LIST, phyId, (char *)&opData,
      52              :         sizeof(union OpGetDevEidInfoListData));
      53            2 :     CHK_PRT_RETURN(ret, hccp_err("[get][eid]hdc message process failed ret[%d], phyId[%u]", ret, phyId), ret);
      54              : 
      55            2 :     (void)memcpy_s(infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM,
      56              :         opData.rxData.infoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM);
      57            2 :     return 0;
      58              : }
      59              : 
      60            1 : int RaHdcGetDevEidInfoList(unsigned int phyId, struct HccpDevEidInfo infoList[], unsigned int *num)
      61              : {
      62            1 :     struct HccpDevEidInfo subInfoList[MAX_DEV_INFO_TRANS_NUM] = {0};
      63            1 :     unsigned int infoSize = *num;
      64            1 :     unsigned int remainCount = 0;
      65            1 :     unsigned int startIndex = 0;
      66            1 :     int ret = 0;
      67              : 
      68            1 :     *num = 0;
      69              :     // get MAX_DEV_INFO_TRANS_NUM num of eid info every time: will fallthrough here
      70            2 :     for (startIndex = 0; startIndex + MAX_DEV_INFO_TRANS_NUM <= infoSize; startIndex += MAX_DEV_INFO_TRANS_NUM) {
      71            1 :         ret = RaHdcGetDevEidSubInfoList(phyId, subInfoList, startIndex, MAX_DEV_INFO_TRANS_NUM);
      72            1 :         CHK_PRT_RETURN(ret != 0, hccp_err("[get][eid]get sub_info_list failed, ret(%d) phyId(%u) "
      73              :             "startIndex(%u) count(%d)", ret, phyId, startIndex, MAX_DEV_INFO_TRANS_NUM), ret);
      74              : 
      75            1 :         *num += MAX_DEV_INFO_TRANS_NUM;
      76            1 :         (void)memcpy_s(infoList + startIndex, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM,
      77              :             subInfoList, sizeof(struct HccpDevEidInfo) * MAX_DEV_INFO_TRANS_NUM);
      78              :     }
      79              : 
      80            1 :     remainCount = infoSize % MAX_DEV_INFO_TRANS_NUM;
      81            1 :     if (remainCount == 0) {
      82            0 :         return ret;
      83              :     }
      84              : 
      85              :     // get remain count of eid info
      86            1 :     ret = RaHdcGetDevEidSubInfoList(phyId, subInfoList, startIndex, remainCount);
      87            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][eid]get sub_info_list failed, ret(%d) phyId(%u) "
      88              :         "startIndex(%u) remainCount(%u)", ret, phyId, startIndex, remainCount), ret);
      89              : 
      90            1 :     *num += remainCount;
      91            1 :     (void)memcpy_s(infoList + startIndex, sizeof(struct HccpDevEidInfo) * remainCount,
      92              :         subInfoList, sizeof(struct HccpDevEidInfo) * remainCount);
      93            1 :     return ret;
      94              : }
      95              : 
      96            1 : int RaHdcCtxInit(struct RaCtxHandle *ctxHandle, struct CtxInitAttr *attr, unsigned int *devIndex,
      97              :     struct DevBaseAttr *devAttr)
      98              : {
      99            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     100            1 :     union OpCtxInitData opData = {0};
     101              :     int ret;
     102              : 
     103            1 :     (void)memcpy_s(&(opData.txData.attr), sizeof(struct CtxInitAttr), attr, sizeof(struct CtxInitAttr));
     104            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_INIT, attr->phyId, (char *)&opData, sizeof(union OpCtxInitData));
     105            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_ctx]hdc message process failed ret[%d], phyId[%u]",
     106              :         ret, phyId), ret);
     107              : 
     108            1 :     *devIndex = opData.rxData.devIndex;
     109            1 :     (void)memcpy_s(devAttr, sizeof(struct DevBaseAttr), &opData.rxData.devAttr, sizeof(struct DevBaseAttr));
     110              : 
     111            1 :     return 0;
     112              : }
     113              : 
     114            0 : int RaHdcCtxGetAsyncEvents(struct RaCtxHandle *ctxHandle, struct AsyncEvent events[], unsigned int *num)
     115              : {
     116            0 :     union OpCtxGetAsyncEventsData opData = {0};
     117            0 :     unsigned int phyId = ctxHandle->attr.phyId;
     118            0 :     unsigned int expectedNum = *num;
     119              :     unsigned int i;
     120            0 :     int ret = 0;
     121              : 
     122            0 :     opData.txData.phyId = phyId;
     123            0 :     opData.txData.devIndex = ctxHandle->devIndex;
     124            0 :     opData.txData.num = *num;
     125            0 :     ret = RaHdcProcessMsg(RA_RS_CTX_GET_ASYNC_EVENTS, phyId, (char *)&opData,
     126              :         sizeof(union OpCtxGetAsyncEventsData));
     127              : 
     128            0 :     CHK_PRT_RETURN(opData.rxData.num > expectedNum, hccp_err("[get][async_events]rxData.num:%u > expectedNum:%u,"
     129              :         " phyId:%u dev_index:0x%x", opData.rxData.num, expectedNum, phyId, ctxHandle->devIndex), -EINVAL);
     130              : 
     131            0 :     for (i = 0; i < opData.rxData.num; i++) {
     132            0 :         (void)memcpy_s(&events[i], sizeof(struct AsyncEvent), &opData.rxData.events[i], sizeof(struct AsyncEvent));
     133              :     }
     134            0 :     *num = opData.rxData.num;
     135              : 
     136            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][async_events]hdc message process failed ret:%d, phyId:%u"
     137              :         " dev_index:0x%x", ret, phyId, ctxHandle->devIndex), ret);
     138              : 
     139            0 :     return ret;
     140              : }
     141              : 
     142            1 : int RaHdcCtxDeinit(struct RaCtxHandle *ctxHandle)
     143              : {
     144            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     145            1 :     union OpCtxDeinitData opData = {0};
     146              :     int ret;
     147              : 
     148            1 :     opData.txData.phyId = phyId;
     149            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     150            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_DEINIT, phyId, (char *)&opData, sizeof(union OpCtxDeinitData));
     151            1 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ra_hdc_ctx]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     152              :         ret, phyId, ctxHandle->devIndex), ret);
     153              : 
     154            1 :     return 0;
     155              : }
     156              : 
     157            4 : void RaHdcPrepareGetEidByIp(struct RaCtxHandle *ctxHandle, struct IpInfo ip[], unsigned int ipNum,
     158              :     union OpGetEidByIpData *opData)
     159              : {
     160            4 :     unsigned int i = 0;
     161              : 
     162            4 :     opData->txData.phyId = ctxHandle->attr.phyId;
     163            4 :     opData->txData.devIndex = ctxHandle->devIndex;
     164            4 :     opData->txData.num = ipNum;
     165          132 :     for (i = 0; i < ipNum; i++) {
     166          128 :         (void)memcpy_s(&opData->txData.ip[i], sizeof(struct IpInfo), &ip[i], sizeof(struct IpInfo));
     167              :     }
     168            4 : }
     169              : 
     170            1 : int RaHdcGetEidResults(union OpGetEidByIpData *opData, unsigned int ipNum, union HccpEid eid[],
     171              :     unsigned int *num)
     172              : {
     173            1 :     unsigned int i = 0;
     174              : 
     175            1 :     *num = 0;
     176            1 :     CHK_PRT_RETURN(opData->rxData.num > ipNum, hccp_err("[get][eid_by_ip]rx_data.num:%u > ip_num:%u",
     177              :         opData->rxData.num, ipNum), -EINVAL);
     178              : 
     179            1 :     *num = opData->rxData.num;
     180            2 :     for (i = 0; i < opData->rxData.num; i++) {
     181            1 :         (void)memcpy_s(&eid[i], sizeof(union HccpEid), &opData->rxData.eid[i], sizeof(union HccpEid));
     182              :     }
     183              : 
     184            1 :     return 0;
     185              : }
     186              : 
     187            2 : int RaHdcGetEidByIp(struct RaCtxHandle *ctxHandle, struct IpInfo ip[], union HccpEid eid[], unsigned int *num)
     188              : {
     189            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     190            2 :     union OpGetEidByIpData opData = {0};
     191            2 :     unsigned int ipNum = *num;
     192            2 :     int retTmp = 0;
     193            2 :     int ret = 0;
     194              : 
     195            2 :     RaHdcPrepareGetEidByIp(ctxHandle, ip, ipNum, &opData);
     196            2 :     ret = RaHdcProcessMsg(RA_RS_GET_EID_BY_IP, phyId, (char *)&opData, sizeof(union OpGetEidByIpData));
     197              : 
     198            2 :     retTmp = RaHdcGetEidResults(&opData, ipNum, eid, num);
     199            2 :     CHK_PRT_RETURN(retTmp != 0, hccp_err("[get][eid_by_ip]ra_hdc_get_eid_results failed ret[%d], phyId[%u]"
     200              :         " devIndex[0x%x]", retTmp, phyId, ctxHandle->devIndex), retTmp);
     201              : 
     202            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][eid_by_ip]hdc message process failed ret[%d], phyId[%u]"
     203              :         " devIndex[0x%x]", ret, phyId, ctxHandle->devIndex), ret);
     204              : 
     205            1 :     return ret;
     206              : }
     207              : 
     208            2 : int RaHdcCtxTokenIdAlloc(struct RaCtxHandle *ctxHandle, struct HccpTokenId *info,
     209              :     struct RaTokenIdHandle *tokenIdHandle)
     210              : {
     211            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     212            2 :     union OpTokenIdAllocData opData = {0};
     213              :     int ret;
     214              : 
     215            2 :     opData.txData.phyId = phyId;
     216            2 :     opData.txData.devIndex = ctxHandle->devIndex;
     217              : 
     218            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_TOKEN_ID_ALLOC, phyId, (char *)&opData,
     219              :         sizeof(union OpTokenIdAllocData));
     220            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_token_id]hdc message process failed ret[%d], phyId[%u] "
     221              :         "devIndex[%u]", ret, phyId, ctxHandle->devIndex), ret);
     222              : 
     223            2 :     info->tokenId = opData.rxData.tokenId;
     224            2 :     tokenIdHandle->addr = opData.rxData.addr;
     225            2 :     return 0;
     226              : }
     227              : 
     228            1 : int RaHdcCtxTokenIdFree(struct RaCtxHandle *ctxHandle, struct RaTokenIdHandle *tokenIdHandle)
     229              : {
     230            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     231            1 :     union OpTokenIdFreeData opData = {0};
     232              :     int ret;
     233              : 
     234            1 :     opData.txData.phyId = phyId;
     235            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     236            1 :     opData.txData.addr = tokenIdHandle->addr;
     237            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_TOKEN_ID_FREE, phyId, (char *)&opData,
     238              :         sizeof(union OpTokenIdFreeData));
     239            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[deinit][ra_token_id]hdc message process failed ret[%d], phyId[%u] "
     240              :         "devIndex[%u]", ret, phyId, ctxHandle->devIndex), ret);
     241              : 
     242            1 :     return 0;
     243              : }
     244              : 
     245            3 : int RaHdcCtxPrepareLmemRegister(struct RaCtxHandle *ctxHandle, struct MrRegInfoT *lmemInfo,
     246              :     union OpLmemRegInfoData *opData)
     247              : {
     248            3 :     struct MemRegAttrT *memAttr = NULL;
     249            3 :     int ret = 0;
     250              : 
     251            3 :     memAttr = &(opData->txData.memAttr);
     252            3 :     opData->txData.phyId = ctxHandle->attr.phyId;
     253            3 :     opData->txData.devIndex = ctxHandle->devIndex;
     254            3 :     ret = RaCtxPrepareLmemRegister(lmemInfo, memAttr);
     255            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_lmem]ra_ctx_prepare_lmem_register failed, ret[%d]", ret), ret);
     256              : 
     257            3 :     return 0;
     258              : }
     259              : 
     260            2 : int RaHdcCtxLmemRegister(struct RaCtxHandle *ctxHandle, struct MrRegInfoT *lmemInfo,
     261              :     struct RaLmemHandle *lmemHandle)
     262              : {
     263            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     264            2 :     union OpLmemRegInfoData opData = {0};
     265              :     int ret;
     266              : 
     267            2 :     ret = RaHdcCtxPrepareLmemRegister(ctxHandle, lmemInfo, &opData);
     268            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_lmem]prepare register failed ret[%d], phyId[%u] devIndex[%u]",
     269              :         ret, phyId, ctxHandle->devIndex), ret);
     270              : 
     271            2 :     ret = RaHdcProcessMsg(RA_RS_LMEM_REG, phyId, (char *)&opData, sizeof(union OpLmemRegInfoData));
     272            2 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_lmem]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     273              :         ret, phyId, ctxHandle->devIndex), ret);
     274              : 
     275            2 :     RaCtxGetLmemInfo(&(opData.rxData.memInfo), lmemInfo, lmemHandle);
     276              : 
     277            2 :     return 0;
     278              : }
     279              : 
     280            1 : int RaHdcCtxLmemUnregister(struct RaCtxHandle *ctxHandle, struct RaLmemHandle *lmemHandle)
     281              : {
     282            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     283            1 :     union OpLmemUnregInfoData opData = {0};
     284              :     int ret;
     285              : 
     286            1 :     opData.txData.phyId = phyId;
     287            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     288            1 :     opData.txData.addr = lmemHandle->addr;
     289            1 :     ret = RaHdcProcessMsg(RA_RS_LMEM_UNREG, phyId, (char *)&opData, sizeof(union OpLmemUnregInfoData));
     290            1 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ra_hdc_lmem]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     291              :         ret, phyId, ctxHandle->devIndex), ret);
     292              : 
     293            1 :     return 0;
     294              : }
     295              : 
     296            1 : STATIC void RaHdcPrepareRmemImport(struct RaCtxHandle *ctxHandle, union OpRmemImportInfoData *opData,
     297              :     struct MrImportInfoT *rmemInfo)
     298              : {
     299            1 :     struct MemImportAttrT *memAttr = NULL;
     300              : 
     301            1 :     memAttr = &(opData->txData.memAttr);
     302            1 :     opData->txData.phyId = ctxHandle->attr.phyId;
     303            1 :     opData->txData.devIndex = ctxHandle->devIndex;
     304            1 :     RaCtxPrepareRmemImport(rmemInfo, memAttr);
     305            1 : }
     306              : 
     307            1 : int RaHdcCtxRmemImport(struct RaCtxHandle *ctxHandle, struct MrImportInfoT *rmemInfo)
     308              : {
     309            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     310            1 :     union OpRmemImportInfoData opData = {0};
     311              :     int ret;
     312              : 
     313            1 :     RaHdcPrepareRmemImport(ctxHandle, &opData, rmemInfo);
     314              : 
     315            1 :     ret = RaHdcProcessMsg(RA_RS_RMEM_IMPORT, phyId, (char *)&opData, sizeof(union OpRmemImportInfoData));
     316            1 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_rmem]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     317              :         ret, phyId, ctxHandle->devIndex), ret);
     318              : 
     319            1 :     rmemInfo->out.ub.targetSegHandle = opData.rxData.memInfo.ub.targetSegHandle;
     320            1 :     return 0;
     321              : }
     322              : 
     323            1 : int RaHdcCtxRmemUnimport(struct RaCtxHandle *ctxHandle, struct RaRmemHandle *rmemHandle)
     324              : {
     325            1 :     union OpRmemUnimportInfoData opData = {0};
     326            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     327              :     int ret;
     328              : 
     329            1 :     opData.txData.phyId = phyId;
     330            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     331            1 :     opData.txData.addr = rmemHandle->addr;
     332            1 :     ret = RaHdcProcessMsg(RA_RS_RMEM_UNIMPORT, phyId, (char *)&opData, sizeof(union OpRmemUnimportInfoData));
     333            1 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ra_hdc_rmem]hdc message process failed ret[%d], phyId[%u], devIndex[%u]",
     334              :         ret, phyId, ctxHandle->devIndex), ret);
     335              : 
     336            1 :     return 0;
     337              : }
     338              : 
     339            1 : int RaHdcCtxChanCreate(struct RaCtxHandle *ctxHandle, struct ChanInfoT *chanInfo,
     340              :     struct RaChanHandle *chanHandle)
     341              : {
     342            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     343            1 :     union OpCtxChanCreateData opData = {0};
     344              :     int ret;
     345              : 
     346            1 :     opData.txData.phyId = phyId;
     347            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     348            1 :     opData.txData.dataPlaneFlag = chanInfo->in.dataPlaneFlag;
     349            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_CHAN_CREATE, phyId, (char *)&opData, sizeof(union OpCtxChanCreateData));
     350            1 :     CHK_PRT_RETURN(ret, hccp_err("[init][ctx_chan]hdc message process failed ret[%d], phyId[%u], devIndex[%u]",
     351              :         ret, phyId, ctxHandle->devIndex), ret);
     352              : 
     353            1 :     chanHandle->addr = opData.rxData.addr;
     354            1 :     chanInfo->out.fd = opData.rxData.fd;
     355            1 :     return 0;
     356              : }
     357              : 
     358            1 : int RaHdcCtxChanDestroy(struct RaCtxHandle *ctxHandle, struct RaChanHandle *chanHandle)
     359              : {
     360            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     361            1 :     union OpCtxChanDestroyData opData = {0};
     362              :     int ret;
     363              : 
     364            1 :     opData.txData.phyId = phyId;
     365            1 :     opData.txData.devIndex = ctxHandle->devIndex;
     366            1 :     opData.txData.addr = chanHandle->addr;
     367              : 
     368            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_CHAN_DESTROY, phyId, (char *)&opData, sizeof(union OpCtxChanDestroyData));
     369            1 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ctx_chan]hdc message process failed ret[%d], phyId[%u], devIndex[%u]",
     370              :         ret, phyId, ctxHandle->devIndex), ret);
     371              : 
     372            1 :     return 0;
     373              : }
     374              : 
     375            3 : STATIC void RaHdcPrepareCqCreate(struct RaCtxHandle *ctxHandle, union OpCtxCqCreateData *opData,
     376              :     struct CqInfoT *info)
     377              : {
     378            3 :     struct CtxCqAttr *cqAttr = NULL;
     379              : 
     380            3 :     cqAttr = &(opData->txData.attr);
     381            3 :     opData->txData.phyId = ctxHandle->attr.phyId;
     382            3 :     opData->txData.devIndex = ctxHandle->devIndex;
     383            3 :     RaCtxPrepareCqCreate(info, cqAttr);
     384            3 :     if (opData->txData.attr.ub.mode == JFC_MODE_CCU_POLL && info->in.ub.ccuExCfg.valid) {
     385            2 :         opData->txData.attr.ub.ccuExCfg.valid = info->in.ub.ccuExCfg.valid;
     386            2 :         opData->txData.attr.ub.ccuExCfg.cqeFlag = info->in.ub.ccuExCfg.cqeFlag;
     387              :     }
     388            3 : }
     389              : 
     390            3 : int RaHdcCtxCqCreate(struct RaCtxHandle *ctxHandle, struct CqInfoT *info, struct RaCqHandle *cqHandle)
     391              : {
     392            3 :     unsigned int phyId = ctxHandle->attr.phyId;
     393            3 :     union OpCtxCqCreateData opData = {0};
     394              :     int ret;
     395              : 
     396            3 :     RaHdcPrepareCqCreate(ctxHandle, &opData, info);
     397              : 
     398            3 :     ret = RaHdcProcessMsg(RA_RS_CTX_CQ_CREATE, phyId, (char *)&opData, sizeof(union OpCtxCqCreateData));
     399            3 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_cq]hdc message process failed ret[%d], phyId[%u], devIndex[%u]",
     400              :         ret, phyId, ctxHandle->devIndex), ret);
     401              : 
     402            3 :     cqHandle->addr = opData.rxData.info.addr;
     403            3 :     RaCtxGetCqCreateInfo(&opData.rxData.info, info);
     404            3 :     return 0;
     405              : }
     406              : 
     407            2 : int RaHdcCtxCqDestroy(struct RaCtxHandle *ctxHandle, struct RaCqHandle *cqHandle)
     408              : {
     409            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     410            2 :     union OpCtxCqDestroyData opData = {0};
     411              :     int ret;
     412              : 
     413            2 :     opData.txData.phyId = phyId;
     414            2 :     opData.txData.devIndex = ctxHandle->devIndex;
     415            2 :     opData.txData.addr = cqHandle->addr;
     416            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_CQ_DESTROY, phyId, (char *)&opData, sizeof(union OpCtxCqDestroyData));
     417            2 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ra_cq]hdc message process failed ret[%d], phyId[%u], devIndex[%u]",
     418              :         ret, phyId, ctxHandle->devIndex), ret);
     419              : 
     420            2 :     return 0;
     421              : }
     422              : 
     423            5 : int RaHdcCtxPrepareQpCreate(struct RaCtxHandle *ctxHandle, struct QpCreateAttr *qpAttr,
     424              :     union OpCtxQpCreateData *opData)
     425              : {
     426            5 :     struct CtxQpAttr *ctxQpAttr = NULL;
     427            5 :     int ret = 0;
     428              : 
     429            5 :     opData->txData.phyId = ctxHandle->attr.phyId;
     430            5 :     opData->txData.devIndex = ctxHandle->devIndex;
     431            5 :     ctxQpAttr = &opData->txData.qpAttr;
     432            5 :     ret = RaCtxPrepareQpCreate(qpAttr, ctxQpAttr);
     433            5 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_qp]ra_ctx_prepare_qp_create failed, ret[%d]", ret), ret);
     434              : 
     435            5 :     if (ctxQpAttr->ub.mode == JETTY_MODE_CCU_TA_CACHE) {
     436            2 :         ctxQpAttr->ub.taCacheMode.lockFlag = qpAttr->ub.taCacheMode.lockFlag;
     437            2 :         ctxQpAttr->ub.taCacheMode.sqeBufIdx = qpAttr->ub.taCacheMode.sqeBufIdx;
     438              :     } else {
     439            3 :         ctxQpAttr->ub.extMode.sq = qpAttr->ub.extMode.sq;
     440            3 :         ctxQpAttr->ub.extMode.piType = qpAttr->ub.extMode.piType;
     441            3 :         ctxQpAttr->ub.extMode.cstmFlag = qpAttr->ub.extMode.cstmFlag;
     442            3 :         ctxQpAttr->ub.extMode.sqebbNum = qpAttr->ub.extMode.sqebbNum;
     443              :     }
     444              : 
     445            5 :     return 0;
     446              : }
     447              : 
     448            3 : int RaHdcCtxQpCreate(struct RaCtxHandle *ctxHandle, struct QpCreateAttr *qpAttr,
     449              :     struct QpCreateInfo *qpInfo, struct RaCtxQpHandle *qpHandle)
     450              : {
     451            3 :     unsigned int devIndex = ctxHandle->devIndex;
     452            3 :     unsigned int phyId = ctxHandle->attr.phyId;
     453            3 :     union OpCtxQpCreateData opData = {0};
     454              :     int ret;
     455              : 
     456            3 :     ret = RaHdcCtxPrepareQpCreate(ctxHandle, qpAttr, &opData);
     457            3 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_qp]prepare qp_create failed ret[%d], phyId[%u] devIndex[%u]",
     458              :         ret, phyId, devIndex), ret);
     459              : 
     460            3 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_CREATE, phyId, (char *)&opData, sizeof(union OpCtxQpCreateData));
     461            3 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     462              :         ret, phyId, devIndex), ret);
     463              : 
     464            3 :     RaCtxGetQpCreateInfo(ctxHandle, qpAttr, &(opData.rxData.qpInfo), qpHandle);
     465            3 :     (void)memcpy_s(qpInfo, sizeof(struct QpCreateInfo), &(opData.rxData.qpInfo), sizeof(struct QpCreateInfo));
     466              : 
     467            3 :     return 0;
     468              : }
     469              : 
     470            2 : int RaHdcCtxQpDestroy(struct RaCtxQpHandle *qpHandle)
     471              : {
     472            2 :     unsigned int phyId = qpHandle->phyId;
     473            2 :     union OpCtxQpDestroyData opData = {0};
     474              :     int ret;
     475              : 
     476            2 :     opData.txData.phyId = phyId;
     477            2 :     opData.txData.devIndex = qpHandle->devIndex;
     478            2 :     opData.txData.id = qpHandle->id;
     479              : 
     480            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_DESTROY, phyId, (char *)&opData, sizeof(union OpCtxQpDestroyData));
     481            2 :     CHK_PRT_RETURN(ret == -ENODEV, hccp_warn("[deinit][ra_hdc_qp]hdc message process ret[%d], phyId[%u] devIndex[%u]",
     482              :         ret, phyId, qpHandle->devIndex), ret);
     483            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[deinit][ra_hdc_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     484              :         ret, phyId, qpHandle->devIndex), ret);
     485            2 :     return 0;
     486              : }
     487              : 
     488            2 : int RaHdcCtxPrepareQpImport(struct RaCtxHandle *ctxHandle, struct QpImportInfoT *qpInfo,
     489              :     union OpCtxQpImportData *opData)
     490              : {
     491            2 :     struct RaRsJettyImportAttr *importAttr = NULL;
     492              : 
     493            2 :     importAttr = &(opData->txData.attr);
     494            2 :     opData->txData.devIndex = ctxHandle->devIndex;
     495            2 :     opData->txData.phyId = ctxHandle->attr.phyId;
     496            2 :     opData->txData.key = qpInfo->in.key;
     497            2 :     RaCtxPrepareQpImport(qpInfo, importAttr);
     498              : 
     499            2 :     return 0;
     500              : }
     501              : 
     502            1 : int RaHdcCtxQpImport(struct RaCtxHandle *ctxHandle, struct QpImportInfoT *qpInfo,
     503              :     struct RaCtxRemQpHandle *remQpHandle)
     504              : {
     505            1 :     unsigned int devIndex = ctxHandle->devIndex;
     506            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     507            1 :     union OpCtxQpImportData opData = {0};
     508              :     int ret;
     509              : 
     510            1 :     ret = RaHdcCtxPrepareQpImport(ctxHandle, qpInfo, &opData);
     511            1 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_qp]prepare qp_import failed ret[%d], phyId[%u] devIndex[%u]",
     512              :         ret, phyId, devIndex), ret);
     513              : 
     514            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_IMPORT, phyId, (char *)&opData, sizeof(union OpCtxQpImportData));
     515            1 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     516              :         ret, phyId, devIndex), ret);
     517              : 
     518            1 :     RaCtxGetQpImportInfo(ctxHandle, qpInfo, &(opData.rxData.info), remQpHandle);
     519            1 :     remQpHandle->id = opData.rxData.remJettyId;
     520              : 
     521            1 :     return 0;
     522              : }
     523              : 
     524            1 : int RaHdcCtxQpUnimport(struct RaCtxRemQpHandle *remQpHandle)
     525              : {
     526            1 :     unsigned int phyId = remQpHandle->phyId;
     527            1 :     union OpCtxQpUnimportData opData = {0};
     528              :     int ret;
     529              : 
     530            1 :     opData.txData.phyId = phyId;
     531            1 :     opData.txData.devIndex = remQpHandle->devIndex;
     532            1 :     opData.txData.remJettyId = remQpHandle->id;
     533            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_UNIMPORT, phyId, (char *)&opData, sizeof(union OpCtxQpUnimportData));
     534            1 :     CHK_PRT_RETURN(ret, hccp_err("[deinit][ra_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     535              :         ret, phyId, remQpHandle->devIndex), ret);
     536              : 
     537            1 :     return 0;
     538              : }
     539              : 
     540            1 : int RaHdcCtxQpBind(struct RaCtxQpHandle *qpHandle, struct RaCtxRemQpHandle *remQpHandle)
     541              : {
     542            1 :     unsigned int devIndex = qpHandle->devIndex;
     543            1 :     unsigned int phyId = qpHandle->phyId;
     544            1 :     union OpCtxQpBindData opData = {0};
     545              :     int ret;
     546              : 
     547            1 :     opData.txData.phyId = qpHandle->phyId;
     548            1 :     opData.txData.devIndex = qpHandle->devIndex;
     549            1 :     opData.txData.id = qpHandle->id;
     550            1 :     opData.txData.remId = remQpHandle->id;
     551              : 
     552            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_BIND, phyId, (char *)&opData, sizeof(union OpCtxQpBindData));
     553            1 :     CHK_PRT_RETURN(ret, hccp_err("[init][ra_hdc_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     554              :         ret, phyId, devIndex), ret);
     555              : 
     556            1 :     return 0;
     557              : }
     558              : 
     559            2 : int RaHdcCtxQpUnbind(struct RaCtxQpHandle *qpHandle)
     560              : {
     561            2 :     union OpCtxQpUnbindData opData = {0};
     562            2 :     unsigned int phyId = qpHandle->phyId;
     563              :     int ret;
     564              : 
     565            2 :     opData.txData.phyId = phyId;
     566            2 :     opData.txData.devIndex = qpHandle->devIndex;
     567            2 :     opData.txData.id = qpHandle->id;
     568              : 
     569            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_QP_UNBIND, phyId, (char *)&opData, sizeof(union OpCtxQpUnbindData));
     570            2 :     CHK_PRT_RETURN(ret == -ENODEV, hccp_warn("[deinit][ra_qp]hdc message process ret[%d], phyId[%u] devIndex[%u]",
     571              :         ret, phyId, qpHandle->devIndex), ret);
     572            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[deinit][ra_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     573              :         ret, phyId, qpHandle->devIndex), ret);
     574            1 :     return 0;
     575              : }
     576              : 
     577            2 : STATIC int RaHdcSendWrDataProtocolInit(struct SendWrData *wr, struct BatchSendWrData *wrData,
     578              :     enum ProtocolTypeT protocol, bool *isInline)
     579              : {
     580            2 :     struct RaCtxRemQpHandle *remQpHandle = NULL;
     581            2 :     struct RaRmemHandle *rmemHandle = NULL;
     582              :     int ret;
     583              : 
     584            2 :     if (protocol == PROTOCOL_UDMA) {
     585            1 :         *isInline = (wr->ub.flags.bs.inlineFlag != 0);
     586            1 :         wrData->ub.userCtx = wr->ub.userCtx;
     587            1 :         wrData->ub.opcode = wr->ub.opcode;
     588            1 :         wrData->ub.flags = wr->ub.flags;
     589              :         /* nop no need to init other infos */
     590            1 :         if (wr->ub.opcode == RA_UB_OPC_NOP) {
     591            0 :             return 0;
     592              :         }
     593            1 :         remQpHandle = (struct RaCtxRemQpHandle *)wr->ub.remQpHandle;
     594            1 :         wrData->ub.remJetty = remQpHandle->id;
     595              :         /* notify */
     596            1 :         if (wr->ub.opcode == RA_UB_OPC_WRITE_NOTIFY) {
     597            0 :             wrData->ub.notifyInfo.notifyAddr = wr->ub.notifyInfo.notifyAddr;
     598            0 :             wrData->ub.notifyInfo.notifyData = wr->ub.notifyInfo.notifyData;
     599            0 :             rmemHandle = (struct RaRmemHandle *)(wr->ub.notifyInfo.notifyHandle);
     600            0 :             wrData->ub.notifyInfo.notifyHandle = rmemHandle->addr;
     601              :         }
     602              :     } else {
     603            1 :         *isInline = ((wr->rdma.flags & RA_SEND_INLINE) != 0);
     604            1 :         ret = memcpy_s(&wrData->rdma, sizeof(wrData->rdma),
     605            1 :             &(wr->rdma), sizeof(wr->rdma));
     606            1 :         CHK_PRT_RETURN(ret, hccp_err("[send][ra_hdc_ctx]memcpy_s protocol failed, ret[%d]", ret),
     607              :             -ESAFEFUNC);
     608              :     }
     609              : 
     610            2 :     return 0;
     611              : }
     612              : 
     613            2 : STATIC int RaHdcSendWrDataInit(struct RaCtxQpHandle *qpHandle, struct SendWrData wrList[],
     614              :     union OpCtxBatchSendWrData *opData, unsigned int completeCnt, unsigned int sendNum)
     615              : {
     616            2 :     unsigned int currBatchNum = (sendNum - completeCnt) >= MAX_CTX_WR_NUM ?
     617              :         MAX_CTX_WR_NUM : (sendNum - completeCnt);
     618            2 :     struct RaLmemHandle *lmemHandle = NULL;
     619            2 :     struct RaRmemHandle *rmemHandle = NULL;
     620            2 :     struct BatchSendWrData *hdcWr = NULL;
     621            2 :     struct SendWrData *wr = NULL;
     622              :     unsigned int i, j;
     623              :     bool isInline;
     624              :     int ret;
     625              : 
     626            2 :     (void)memset_s(opData, sizeof(union OpCtxBatchSendWrData), 0, sizeof(union OpCtxBatchSendWrData));
     627            2 :     opData->txData.baseInfo.phyId = qpHandle->phyId;
     628            2 :     opData->txData.baseInfo.devIndex = qpHandle->devIndex;
     629            2 :     opData->txData.baseInfo.qpn = qpHandle->id;
     630            2 :     opData->txData.sendNum = currBatchNum;
     631              : 
     632            4 :     for (i = 0; i < currBatchNum; i++) {
     633            2 :         wr = &wrList[completeCnt + i];
     634            2 :         hdcWr = &opData->txData.wrData[i];
     635              :         /* protocol cfg */
     636            2 :         ret = RaHdcSendWrDataProtocolInit(wr, hdcWr, qpHandle->protocol, &isInline);
     637            2 :         if (ret != 0) {
     638            0 :             hccp_err("[send][ra_hdc_ctx]init protocol cfg failed, ret[%d], wr[%u]",
     639              :                 ret, (completeCnt + i));
     640            0 :             return ret;
     641              :         }
     642              : 
     643              :         /* nop no need init other infos */
     644            2 :         if (qpHandle->protocol == PROTOCOL_UDMA && wr->ub.opcode == RA_UB_OPC_NOP) {
     645            0 :             continue;
     646              :         }
     647              : 
     648              :         /* lmem */
     649            2 :         if (isInline) {
     650            2 :             ret = memcpy_s(hdcWr->inlineData, MAX_INLINE_SIZE, wr->inlineData, wr->inlineSize);
     651            2 :             CHK_PRT_RETURN(ret, hccp_err("[send][ra_hdc_ctx]memcpy_s inline data failed, ret[%d]",
     652              :                 ret), -ESAFEFUNC);
     653            2 :             hdcWr->inlineSize = wr->inlineSize;
     654              :         } else {
     655            0 :             for (j = 0; j < wr->numSge; j++) {
     656            0 :                 hdcWr->sges[j].addr = wr->sges[j].addr;
     657            0 :                 hdcWr->sges[j].len = wr->sges[j].len;
     658            0 :                 lmemHandle = (struct RaLmemHandle *)wr->sges[j].lmemHandle;
     659            0 :                 hdcWr->sges[j].devLmemHandle = lmemHandle->addr;
     660              :             }
     661            0 :             hdcWr->numSge = wr->numSge;
     662              :         }
     663              : 
     664              :         /* rmem */
     665            2 :         hdcWr->remoteAddr = wr->remoteAddr;
     666            2 :         rmemHandle = (struct RaRmemHandle *)(wr->rmemHandle);
     667            2 :         hdcWr->devRmemHandle = rmemHandle->addr;
     668              : 
     669              :         /* inline reduce */
     670            2 :         hdcWr->ub.reduceInfo = wr->ub.reduceInfo;
     671              : 
     672              :         /* imm data */
     673            2 :         hdcWr->immData = wr->immData;
     674              :     }
     675              : 
     676            2 :     return 0;
     677              : }
     678              : 
     679            2 : int RaHdcCtxBatchSendWr(struct RaCtxQpHandle *qpHandle, struct SendWrData wrList[],
     680              :     struct SendWrResp opResp[], unsigned int sendNum, unsigned int *completeNum)
     681              : {
     682            2 :     union OpCtxBatchSendWrData opData = {0};
     683            2 :     unsigned int completeCnt = 0;
     684              :     unsigned int currSendNum;
     685            2 :     bool isFinished = false;
     686            2 :     int ret = 0;
     687              : 
     688            2 :     while (completeCnt < sendNum) {
     689            2 :         ret = RaHdcSendWrDataInit(qpHandle, wrList, &opData, completeCnt, sendNum);
     690            2 :         if (ret != 0) {
     691            0 :             hccp_err("[send][ra_hdc_ctx]ra_hdc_send_wr_data_init failed, ret[%d] phyId[%u] devIndex[%u] qp_id[%u]",
     692              :                 ret, qpHandle->phyId, qpHandle->devIndex, qpHandle->id);
     693            0 :             break;
     694              :         }
     695              : 
     696            2 :         currSendNum = opData.txData.sendNum;
     697            2 :         ret = RaHdcProcessMsg(RA_RS_CTX_BATCH_SEND_WR, qpHandle->phyId, (char *)&opData,
     698              :             sizeof(union OpCtxBatchSendWrData));
     699              : 
     700            2 :         if (opData.rxData.completeNum > currSendNum) {
     701            0 :             hccp_err("[send][ra_hdc_ctx]complete_num[%u] is larger than send_num[%u], ret[%d]",
     702              :                 opData.rxData.completeNum, currSendNum, ret);
     703            0 :             ret = -EINVAL;
     704            0 :             break;
     705              :         }
     706            2 :         if (ret != 0 || opData.rxData.completeNum < currSendNum) {
     707            2 :             hccp_err("[send][ra_hdc_ctx]batch send wr failed, ret[%d], sendNum[%u], completeNum[%u]",
     708              :                 ret, currSendNum, opData.rxData.completeNum);
     709            2 :             ret = -EOPENSRC;
     710            2 :             isFinished = true;
     711              :         }
     712              : 
     713            2 :         ret = memcpy_s(&opResp[completeCnt], (sizeof(struct SendWrResp) * (sendNum - completeCnt)),
     714            2 :             opData.rxData.wrResp, (sizeof(struct SendWrResp) * opData.rxData.completeNum));
     715            2 :         if (ret != 0) {
     716            0 :             hccp_err("[send][ra_hdc_ctx]memcpy_s wr_resp failed, ret[%d]", ret);
     717            0 :             break;
     718              :         }
     719              : 
     720            2 :         completeCnt = completeCnt + opData.rxData.completeNum;
     721            2 :         if (isFinished) {
     722            2 :             break;
     723              :         }
     724              :     }
     725              : 
     726            2 :     *completeNum = completeCnt;
     727            2 :     return ret;
     728              : }
     729              : 
     730            1 : int RaHdcCtxUpdateCi(struct RaCtxQpHandle *qpHandle, uint16_t ci)
     731              : {
     732            1 :     unsigned int phyId = qpHandle->phyId;
     733            1 :     union OpCtxUpdateCiData opData = {0};
     734              :     int ret;
     735              : 
     736            1 :     opData.txData.phyId = phyId;
     737            1 :     opData.txData.devIndex = qpHandle->devIndex;
     738            1 :     opData.txData.jettyId = qpHandle->id;
     739            1 :     opData.txData.ci = ci;
     740              : 
     741            1 :     ret = RaHdcProcessMsg(RA_RS_CTX_UPDATE_CI, phyId, (char *)&opData, sizeof(union OpCtxUpdateCiData));
     742            1 :     CHK_PRT_RETURN(ret, hccp_err("[update][ra_qp]hdc message process failed ret[%d], phyId[%u] devIndex[%u]",
     743              :         ret, phyId, qpHandle->devIndex), ret);
     744              : 
     745            1 :     return 0;
     746              : }
     747              : 
     748            3 : int RaHdcCtxQpQueryBatch(unsigned int phyId, unsigned int devIndex, unsigned int ids[],
     749              :     struct JettyAttr attr[], unsigned int *num)
     750              : {
     751            3 :     union OpCtxQpQueryBatchData opData = {0};
     752              :     int ret, retTmp;
     753              : 
     754            3 :     opData.txData.phyId = phyId;
     755            3 :     opData.txData.devIndex = devIndex;
     756            3 :     opData.txData.num = *num;
     757            3 :     (void)memcpy_s(opData.txData.ids, sizeof(unsigned int) * (*num), ids, sizeof(unsigned int) * (*num));
     758            3 :     ret = RaHdcProcessMsg(RA_RS_CTX_QUERY_QP_BATCH, phyId, (char *)&opData,
     759              :         sizeof(union OpCtxQpQueryBatchData));
     760            3 :     CHK_PRT_RETURN(opData.rxData.num > *num, hccp_err("[query][ra_qp]op_data.rx_data.num[%u] is larger than num[%u], "
     761              :         "ret[%d]", opData.rxData.num, *num, ret), ret);
     762              : 
     763            2 :     if(ret != 0 || opData.rxData.num < *num) {
     764            2 :         hccp_err("[query][ra_qp]hdc message process failed ret[%d], phyId[%u], num[%u], opData.rxData.num[%u]",
     765              :             ret, phyId, *num, opData.rxData.num);
     766            2 :         ret = -EOPENSRC;
     767              :     }
     768              : 
     769            2 :     retTmp = memcpy_s(attr, sizeof(struct JettyAttr) * (*num), opData.rxData.attr,
     770            2 :         sizeof(struct JettyAttr) * opData.rxData.num);
     771            2 :     CHK_PRT_RETURN(retTmp != 0, hccp_err("[query][ra_qp]memcpy_s failed, ret[%d], phyId[%u], num[%u],"
     772              :         "opData.rxData.num[%u]", ret, phyId, *num, opData.rxData.num), ret);
     773              : 
     774            2 :     *num = opData.rxData.num;
     775            2 :     return ret;
     776              : }
     777              : 
     778            2 : int RaHdcCtxGetAuxInfo(struct RaCtxHandle *ctxHandle, struct HccpAuxInfoIn *in, struct HccpAuxInfoOut *out)
     779              : {
     780            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     781            2 :     union OpCtxGetAuxInfoData opData = {0};
     782            2 :     int ret = 0;
     783              : 
     784            2 :     opData.txData.phyId = phyId;
     785            2 :     opData.txData.devIndex = ctxHandle->devIndex;
     786            2 :     (void)memcpy_s(&(opData.txData.info), sizeof(struct HccpAuxInfoIn), in, sizeof(struct HccpAuxInfoIn));
     787            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_GET_AUX_INFO, phyId, (char *)&opData,
     788              :         sizeof(union OpCtxGetAuxInfoData));
     789            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][aux_info]hdc message process failed ret[%d], phyId[%u] "
     790              :         "devIndex[0x%x]", ret, phyId, ctxHandle->devIndex), ret);
     791              : 
     792            1 :     (void)memcpy_s(&(out->auxInfoType), sizeof(unsigned int) * AUX_INFO_NUM_MAX,
     793              :         &(opData.rxData.info.auxInfoType), sizeof(unsigned int) * AUX_INFO_NUM_MAX);
     794            1 :     (void)memcpy_s(&(out->auxInfoValue), sizeof(unsigned int) * AUX_INFO_NUM_MAX,
     795              :         &(opData.rxData.info.auxInfoValue), sizeof(unsigned int) * AUX_INFO_NUM_MAX);
     796            1 :     out->auxInfoNum = opData.rxData.info.auxInfoNum;
     797            1 :     return ret;
     798              : }
     799              : 
     800            2 : int RaHdcCtxGetCrErrInfoList(struct RaCtxHandle *ctxHandle, struct CrErrInfo *infoList, unsigned int *num)
     801              : {
     802            2 :     union OpCtxGetCrErrInfoListData opData = {0};
     803            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     804            2 :     unsigned int expectedNum = *num;
     805              :     unsigned int i;
     806            2 :     int ret = 0;
     807              : 
     808            2 :     opData.txData.phyId = phyId;
     809            2 :     opData.txData.devIndex = ctxHandle->devIndex;
     810            2 :     opData.txData.num = *num;
     811            2 :     ret = RaHdcProcessMsg(RA_RS_CTX_GET_CR_ERR_INFO_LIST, phyId, (char *)&opData,
     812              :         sizeof(union OpCtxGetCrErrInfoListData));
     813              : 
     814            2 :     if (opData.rxData.num > expectedNum) {
     815            0 :         hccp_err("[get][cr_err_info_list]rx_data.num(%u) > expected_num(%u), phyId(%u) devIndex(0x%x)",
     816              :             opData.rxData.num, expectedNum, phyId, ctxHandle->devIndex);
     817            0 :         return -EINVAL;
     818              :     }
     819              : 
     820            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][cr_err_info_list]hdc message process failed ret[%d], phyId[%u]"
     821              :         " devIndex[0x%x]", ret, phyId, ctxHandle->devIndex), ret);
     822              : 
     823            1 :     for (i = 0; i < opData.rxData.num; i++) {
     824            0 :         (void)memcpy_s(&infoList[i], sizeof(struct CrErrInfo),
     825            0 :             &opData.rxData.infoList[i], sizeof(struct CrErrInfo));
     826              :     }
     827            1 :     *num = opData.rxData.num;
     828              : 
     829            1 :     return ret;
     830              : }
     831              : 
     832            3 : int RaHdcCtxGetJettyContext(struct RaCtxQpHandle *qpHandle, uint8_t context[], unsigned int *len)
     833              : {
     834            3 :     union OpCtxGetContextData opData = {0};
     835            3 :     unsigned int phyId = qpHandle->phyId;
     836            3 :     int ret = 0;
     837              : 
     838            3 :     opData.txData.phyId = phyId;
     839            3 :     opData.txData.devIndex = qpHandle->devIndex;
     840            3 :     opData.txData.id = qpHandle->id;
     841            3 :     opData.txData.contextType = CONTEXT_TYPE_JETTY;
     842            3 :     opData.txData.len = *len;
     843            3 :     ret = RaHdcProcessMsg(RA_RS_CTX_GET_UB_CONTEXT, phyId, (char *)&opData,
     844              :         sizeof(union OpCtxGetContextData));
     845            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][jettyContext]hdc message process failed ret:%d, phyId:%u"
     846              :         " devIndex:0x%x", ret, phyId, qpHandle->devIndex), ret);
     847              : 
     848            2 :     ret = memcpy_s(context, *len, opData.rxData.context, opData.rxData.len);
     849            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[get][jettyContext]memcpy_s for context failed, ret:%d", ret), -ESAFEFUNC);
     850            1 :     *len = opData.rxData.len;
     851            1 :     return ret;
     852              : }
        

Generated by: LCOV version 2.0-1