LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/hdc/async - ra_hdc_async_ctx.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 71.0 % 403 286
Test Date: 2026-08-04 10:52:23 Functions: 81.0 % 21 17

            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 "ra_async.h"
      14              : #include "ra_rs_comm.h"
      15              : #include "ra_rs_err.h"
      16              : #include "ra_rs_ctx.h"
      17              : #include "ra_hdc_ctx.h"
      18              : #include "ra_hdc_async.h"
      19              : #include "ra_hdc_async_ctx.h"
      20              : 
      21            4 : int RaHdcGetEidByIpAsync(struct RaCtxHandle *ctxHandle, struct IpInfo ip[], union HccpEid eid[],
      22              :     unsigned int *num, void **reqHandle)
      23              : {
      24            4 :     struct RaRequestHandle *reqHandleTmp = NULL;
      25            4 :     unsigned int phyId = ctxHandle->attr.phyId;
      26            4 :     struct RaResponseEidList *asyncRsp = NULL;
      27            4 :     union OpGetEidByIpData asyncData = {0};
      28            4 :     int ret = 0;
      29              : 
      30            4 :     asyncRsp = (struct RaResponseEidList *)calloc(1, sizeof(struct RaResponseEidList));
      31            4 :     CHK_PRT_RETURN(asyncRsp == NULL,
      32              :         hccp_err("[get][eid_by_ip]calloc async_rsp failed, phyId[%u] devIndex[0x%x]",
      33              :         phyId, ctxHandle->devIndex), -ENOMEM);
      34            2 :     asyncRsp->eidList = eid;
      35            2 :     asyncRsp->num = num;
      36              : 
      37            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
      38            2 :     if (reqHandleTmp == NULL) {
      39            0 :         hccp_err("[get][eid_by_ip]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
      40              :             phyId, ctxHandle->devIndex);
      41            0 :         ret = -ENOMEM;
      42            0 :         goto out;
      43              :     }
      44              : 
      45            2 :     RaHdcPrepareGetEidByIp(ctxHandle, ip, *num, &asyncData);
      46            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
      47            2 :     reqHandleTmp->privData = (void *)asyncRsp;
      48            2 :     ret = RaHdcSendMsgAsync(RA_RS_GET_EID_BY_IP, phyId, (char *)&asyncData, sizeof(union OpGetEidByIpData),
      49              :         reqHandleTmp);
      50            2 :     if (ret != 0) {
      51            1 :         hccp_err("[get][eid_by_ip]hdc async send message failed ret[%d], phyId[%u], devIndex[0x%x]",
      52              :             ret, phyId, ctxHandle->devIndex);
      53            1 :         free(reqHandleTmp);
      54            1 :         reqHandleTmp = NULL;
      55            1 :         goto out;
      56              :     }
      57              : 
      58            1 :     *reqHandle = (void *)reqHandleTmp;
      59            1 :     return ret;
      60              : 
      61            1 : out:
      62            1 :     free(asyncRsp);
      63            1 :     asyncRsp = NULL;
      64            1 :     return ret;
      65              : }
      66              : 
      67            1 : void RaHdcAsyncHandleGetEidByIp(struct RaRequestHandle *reqHandle)
      68              : {
      69            1 :     struct RaResponseEidList *asyncRsp = NULL;
      70            1 :     union OpGetEidByIpData *asyncData = NULL;
      71            1 :     unsigned int ipNum = 0;
      72            1 :     int ret = 0;
      73              : 
      74            1 :     asyncData = (union OpGetEidByIpData *)reqHandle->recvBuf;
      75            1 :     asyncRsp = (struct RaResponseEidList *)reqHandle->privData;
      76            1 :     ipNum = *asyncRsp->num;
      77              : 
      78            1 :     ret = RaHdcGetEidResults(asyncData, ipNum, asyncRsp->eidList, asyncRsp->num);
      79            1 :     if (ret != 0) {
      80            0 :         hccp_err("[get][eid_by_ip]ra_hdc_get_eid_results failed ret[%d], phyId[%u] devIndex[0x%x]", ret,
      81              :             reqHandle->phyId, reqHandle->devIndex);
      82            0 :         reqHandle->opRet = ret;
      83              :     }
      84              : 
      85            1 :     free(reqHandle->privData);
      86            1 :     reqHandle->privData = NULL;
      87            1 :     return;
      88              : }
      89              : 
      90            4 : int RaHdcGetIpByEidAsync(struct RaCtxHandle *ctxHandle, union HccpEid eid[], struct IpInfo ip[],
      91              :     unsigned int *num, void **reqHandle)
      92              : {
      93            4 :     struct RaRequestHandle *reqHandleTmp = NULL;
      94            4 :     unsigned int phyId = ctxHandle->attr.phyId;
      95            4 :     struct RaResponseIpList *asyncRsp = NULL;
      96            4 :     union OpGetIpByEidData asyncData = {0};
      97            4 :     int ret = 0;
      98              : 
      99            4 :     asyncRsp = (struct RaResponseIpList *)calloc(1, sizeof(struct RaResponseIpList));
     100            4 :     CHK_PRT_RETURN(asyncRsp == NULL,
     101              :         hccp_err("[get][IpByEid]calloc asyncRsp failed, phyId[%u] devIndex[0x%x]",
     102              :         phyId, ctxHandle->devIndex), -ENOMEM);
     103            2 :     asyncRsp->ipList = ip;
     104            2 :     asyncRsp->num = num;
     105              : 
     106            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     107            2 :     if (reqHandleTmp == NULL) {
     108            0 :         hccp_err("[get][IpByEid]calloc reqHandleTmp failed, phyId[%u], devIndex[0x%x]",
     109              :             phyId, ctxHandle->devIndex);
     110            0 :         ret = -ENOMEM;
     111            0 :         goto free_async;
     112              :     }
     113              : 
     114            2 :     RaHdcPrepareGetIpByEid(ctxHandle, eid, *num, &asyncData);
     115            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     116            2 :     reqHandleTmp->privData = (void *)asyncRsp;
     117            2 :     ret = RaHdcSendMsgAsync(RA_RS_GET_IP_BY_EID, phyId, (char *)&asyncData, sizeof(union OpGetIpByEidData),
     118              :         reqHandleTmp);
     119            2 :     if (ret != 0) {
     120            1 :         hccp_err("[get][IpByEid]hdc async send message failed ret[%d], phyId[%u], devIndex[0x%x]",
     121              :             ret, phyId, ctxHandle->devIndex);
     122            1 :         free(reqHandleTmp);
     123            1 :         reqHandleTmp = NULL;
     124            1 :         goto free_async;
     125              :     }
     126              : 
     127            1 :     *reqHandle = (void *)reqHandleTmp;
     128            1 :     return ret;
     129              : 
     130            1 : free_async:
     131            1 :     free(asyncRsp);
     132            1 :     asyncRsp = NULL;
     133            1 :     return ret;
     134              : }
     135              : 
     136            1 : void RaHdcAsyncHandleGetIpByEid(struct RaRequestHandle *reqHandle)
     137              : {
     138            1 :     union OpGetIpByEidData *asyncData = NULL;
     139            1 :     struct RaResponseIpList *asyncRsp = NULL;
     140            1 :     unsigned int eidNum = 0;
     141            1 :     int ret = 0;
     142              : 
     143            1 :     asyncData = (union OpGetIpByEidData *)reqHandle->recvBuf;
     144            1 :     asyncRsp = (struct RaResponseIpList *)reqHandle->privData;
     145            1 :     eidNum = *asyncRsp->num;
     146              : 
     147            1 :     ret = RaHdcGetIpResults(asyncData, eidNum, asyncRsp->ipList, asyncRsp->num);
     148            1 :     if (ret != 0) {
     149            0 :         hccp_err("[get][IpByEid]RaHdcGetIpResults failed ret[%d], phyId[%u] devIndex[0x%x]", ret,
     150              :             reqHandle->phyId, reqHandle->devIndex);
     151            0 :         reqHandle->opRet = ret;
     152              :     }
     153              : 
     154            1 :     free(reqHandle->privData);
     155            1 :     reqHandle->privData = NULL;
     156            1 :     return;
     157              : }
     158              : 
     159            1 : int RaHdcCtxLmemRegisterAsync(struct RaCtxHandle *ctxHandle, struct MrRegInfoT *lmemInfo, 
     160              :     struct RaLmemHandle *lmemHandle, void **reqHandle)
     161              : {
     162            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     163            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     164            1 :     union OpLmemRegInfoData asyncData = {0};
     165              :     int ret;
     166              : 
     167            1 :     ret = RaHdcCtxPrepareLmemRegister(ctxHandle, lmemInfo, &asyncData);
     168            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_lmem]prepare register failed ret[%d], phyId[%u] devIndex[%u]",
     169              :         ret, phyId, ctxHandle->devIndex), ret);
     170              : 
     171            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     172            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     173              :         hccp_err("[init][ra_hdc_lmem]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     174              :         phyId, ctxHandle->devIndex), -ENOMEM);
     175              : 
     176            1 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     177            1 :     reqHandleTmp->privData = (void *)&lmemInfo->out;
     178            1 :     reqHandleTmp->privHandle = (void *)lmemHandle;
     179            1 :     ret = RaHdcSendMsgAsync(RA_RS_LMEM_REG, phyId, (char *)&asyncData, sizeof(union OpLmemRegInfoData),
     180              :         reqHandleTmp);
     181            1 :     if (ret != 0) {
     182            0 :         hccp_err("[init][ra_hdc_lmem]hdc async send message failed ret[%d], phyId[%u], devIndex[0x%x]",
     183              :             ret, phyId, ctxHandle->devIndex);
     184            0 :         free(reqHandleTmp);
     185            0 :         reqHandleTmp = NULL;
     186            0 :         return ret;
     187              :     }
     188              : 
     189            1 :     *reqHandle = (void *)reqHandleTmp;
     190            1 :     return 0;
     191              : }
     192              : 
     193            1 : void RaHdcAsyncHandleLmemRegister(struct RaRequestHandle *reqHandle)
     194              : {
     195            1 :     union OpLmemRegInfoData *asyncData = NULL;
     196            1 :     struct RaLmemHandle *lmemHandle = NULL;
     197            1 :     struct MemRegInfo *info = NULL;
     198              :     int ret;
     199              : 
     200            1 :     asyncData = (union OpLmemRegInfoData *)reqHandle->recvBuf;
     201            1 :     lmemHandle = (struct RaLmemHandle *)reqHandle->privHandle;
     202            1 :     info = (struct MemRegInfo *)reqHandle->privData;
     203            1 :     ret = memcpy_s(info, sizeof(struct MemRegInfo), &asyncData->rxData.memInfo, sizeof(struct MemRegInfoT));
     204            1 :     if (ret != 0) {
     205            1 :         hccp_err("[init][ra_hdc_lmem]memcpy_s mem_info failed ret[%d], phyId[%u] devIndex[0x%x]",
     206              :             ret, reqHandle->phyId, reqHandle->devIndex);
     207            1 :         reqHandle->opRet = -ESAFEFUNC;
     208            1 :         return;
     209              :     }
     210              : 
     211            0 :     lmemHandle->addr = info->ub.targetSegHandle;
     212            0 :     return;
     213              : }
     214              : 
     215            2 : int RaHdcCtxLmemUnregisterAsync(struct RaCtxHandle *ctxHandle, struct RaLmemHandle *lmemHandle,
     216              :     void **reqHandle)
     217              : {
     218            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     219            2 :     union OpLmemUnregInfoData asyncData = {0};
     220            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     221            2 :     int ret = 0;
     222              : 
     223            2 :     asyncData.txData.phyId = phyId;
     224            2 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     225            2 :     asyncData.txData.addr = lmemHandle->addr;
     226            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     227            2 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     228              :         hccp_err("[deinit][ra_hdc_lmem]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     229              :         phyId, ctxHandle->devIndex), -ENOMEM);
     230              : 
     231            2 :     ret = RaHdcSendMsgAsync(RA_RS_LMEM_UNREG, phyId, (char *)&asyncData, sizeof(union OpLmemUnregInfoData),
     232              :         reqHandleTmp);
     233            2 :     if (ret != 0) {
     234            0 :         hccp_err("[deinit][ra_hdc_lmem]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     235              :             ret, phyId, ctxHandle->devIndex);
     236            0 :         free(reqHandleTmp);
     237            0 :         reqHandleTmp = NULL;
     238            0 :         return ret;
     239              :     }
     240              : 
     241            2 :     *reqHandle = (void *)reqHandleTmp;
     242            2 :     return 0;
     243              : }
     244              : 
     245            2 : int RaHdcCtxQpCreateAsync(struct RaCtxHandle *ctxHandle, struct QpCreateAttr *attr,
     246              :         struct QpCreateInfo *info, struct RaCtxQpHandle *qpHandle, void **reqHandle)
     247              : {
     248            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     249            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     250            2 :     union OpCtxQpCreateData asyncData = {0};
     251              :     int ret;
     252              : 
     253            2 :     ret = RaHdcCtxPrepareQpCreate(ctxHandle, attr, &asyncData);
     254            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_qp]prepare qp_create failed ret[%d], phyId[%u] devIndex[0x%x]",
     255              :         ret, phyId, ctxHandle->devIndex), ret);
     256              : 
     257            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     258            2 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     259              :         hccp_err("[init][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     260              :         phyId, ctxHandle->devIndex), -ENOMEM);
     261            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     262            2 :     reqHandleTmp->privData = (void *)info;
     263            2 :     qpHandle->ctxHandle = ctxHandle;
     264            2 :     qpHandle->devIndex = ctxHandle->devIndex;
     265            2 :     qpHandle->phyId = ctxHandle->attr.phyId;
     266            2 :     qpHandle->protocol = ctxHandle->protocol;
     267            2 :     (void)memcpy_s(&qpHandle->qpAttr, sizeof(struct QpCreateAttr), attr, sizeof(struct QpCreateAttr));
     268            2 :     reqHandleTmp->privHandle = (void *)qpHandle;
     269              : 
     270            2 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_CREATE, phyId, (char *)&asyncData,
     271              :         sizeof(union OpCtxQpCreateData), reqHandleTmp);
     272            2 :     if (ret != 0) {
     273            0 :         hccp_err("[init][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     274              :             ret, phyId, ctxHandle->devIndex);
     275            0 :         free(reqHandleTmp);
     276            0 :         reqHandleTmp = NULL;
     277            0 :         return ret;
     278              :     }
     279              : 
     280            2 :     *reqHandle = (void *)reqHandleTmp;
     281            2 :     return 0;
     282              : }
     283              : 
     284            0 : void RaHdcAsyncHandleQpCreate(struct RaRequestHandle *reqHandle)
     285              : {
     286            0 :     union OpCtxQpCreateData *asyncData = NULL;
     287            0 :     struct RaCtxQpHandle *qpHandle = NULL;
     288            0 :     struct QpCreateInfo *info = NULL;
     289              : 
     290            0 :     asyncData = (union OpCtxQpCreateData *)reqHandle->recvBuf;
     291            0 :     info = (struct QpCreateInfo *)reqHandle->privData;
     292            0 :     qpHandle = (struct RaCtxQpHandle *)reqHandle->privHandle;
     293            0 :     (void)memcpy_s(info, sizeof(struct QpCreateInfo), &asyncData->rxData.qpInfo, sizeof(struct QpCreateInfo));
     294            0 :     qpHandle->id = info->ub.id;
     295            0 :     (void)memcpy_s(&qpHandle->qpInfo, sizeof(struct QpCreateInfo), info, sizeof(struct QpCreateInfo));
     296              : 
     297            0 :     return;
     298              : }
     299              : 
     300            1 : int RaHdcCtxQpDestroyAsync(struct RaCtxQpHandle *qpHandle, void **reqHandle)
     301              : {
     302            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     303            1 :     union OpCtxQpDestroyData asyncData = {0};
     304            1 :     unsigned int phyId = qpHandle->phyId;
     305              :     int ret;
     306              : 
     307            1 :     asyncData.txData.phyId = phyId;
     308            1 :     asyncData.txData.devIndex = qpHandle->devIndex;
     309            1 :     asyncData.txData.id = qpHandle->id;
     310              : 
     311            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     312            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     313              :         hccp_err("[deinit][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     314              :         phyId, qpHandle->devIndex), -ENOMEM);
     315              : 
     316            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_DESTROY, phyId, (char *)&asyncData,
     317              :         sizeof(union OpCtxQpDestroyData), reqHandleTmp);
     318            1 :     if (ret != 0) {
     319            0 :         hccp_err("[deinit][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     320              :             ret, phyId, qpHandle->devIndex);
     321            0 :         free(reqHandleTmp);
     322            0 :         reqHandleTmp = NULL;
     323            0 :         return ret;
     324              :     }
     325              : 
     326            1 :     *reqHandle = (void *)reqHandleTmp;
     327            1 :     return 0;
     328              : }
     329              : 
     330            1 : int RaHdcCtxQpImportAsync(struct RaCtxHandle *ctxHandle, struct QpImportInfoT *info,
     331              :     struct RaCtxRemQpHandle *remQpHandle, void **reqHandle)
     332              : {
     333            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     334            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     335            1 :     union OpCtxQpImportData asyncData = {0};
     336            1 :     int ret = 0;
     337              : 
     338            1 :     ret = RaHdcCtxPrepareQpImport(ctxHandle, info, &asyncData);
     339            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_qp]prepare qp_import failed ret[%d], phyId[%u] devIndex[0x%x]",
     340              :         ret, phyId, ctxHandle->devIndex), ret);
     341              : 
     342            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     343            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     344              :         hccp_err("[init][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     345              :         phyId, ctxHandle->devIndex), -ENOMEM);
     346              : 
     347            1 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     348            1 :     reqHandleTmp->privData = (void *)&info->out;
     349            1 :     remQpHandle->devIndex = ctxHandle->devIndex;
     350            1 :     remQpHandle->phyId = ctxHandle->attr.phyId;
     351            1 :     remQpHandle->protocol = ctxHandle->protocol;
     352            1 :     remQpHandle->qpKey = info->in.key;
     353            1 :     reqHandleTmp->privHandle = (void *)remQpHandle;
     354              : 
     355            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_IMPORT, phyId, (char *)&asyncData,
     356              :         sizeof(union OpCtxQpImportData), reqHandleTmp);
     357            1 :     if (ret != 0) {
     358            0 :         hccp_err("[init][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     359              :             ret, phyId, ctxHandle->devIndex);
     360            0 :         free(reqHandleTmp);
     361            0 :         reqHandleTmp = NULL;
     362            0 :         return ret;
     363              :     }
     364              : 
     365            1 :     *reqHandle = (void *)reqHandleTmp;
     366            1 :     return 0;
     367              : }
     368              : 
     369            1 : void RaHdcAsyncHandleQpImport(struct RaRequestHandle *reqHandle)
     370              : {
     371            1 :     struct RaCtxRemQpHandle *remQpHandle = NULL;
     372            1 :     union OpCtxQpImportData *asyncData = NULL;
     373            1 :     struct QpImportInfo *info = NULL;
     374              : 
     375            1 :     asyncData = (union OpCtxQpImportData *)reqHandle->recvBuf;
     376            1 :     info = (struct QpImportInfo *)reqHandle->privData;
     377            1 :     remQpHandle = (struct RaCtxRemQpHandle *)reqHandle->privHandle;
     378              : 
     379            1 :     info->ub.tjettyHandle = asyncData->rxData.info.tjettyHandle;
     380            1 :     info->ub.tpn = asyncData->rxData.info.tpn;
     381            1 :     remQpHandle->id = asyncData->rxData.remJettyId;
     382              : 
     383            1 :     return;
     384              : }
     385              : 
     386            1 : int RaHdcCtxQpUnimportAsync(struct RaCtxRemQpHandle *remQpHandle, void **reqHandle)
     387              : {
     388            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     389            1 :     union OpCtxQpUnimportData asyncData = {0};
     390            1 :     unsigned int phyId = remQpHandle->phyId;
     391              :     int ret;
     392              : 
     393            1 :     asyncData.txData.phyId = phyId;
     394            1 :     asyncData.txData.devIndex = remQpHandle->devIndex;
     395            1 :     (void)memcpy_s(asyncData.txData.rawRemJettyId, REM_JETTY_ID_SIZE, remQpHandle->qpKey.value, REM_JETTY_ID_SIZE);
     396              : 
     397            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     398            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     399              :         hccp_err("[deinit][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     400              :         phyId, remQpHandle->devIndex), -ENOMEM);
     401              : 
     402            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_UNIMPORT, phyId, (char *)&asyncData,
     403              :         sizeof(union OpCtxQpUnimportData), reqHandleTmp);
     404            1 :     if (ret != 0) {
     405            0 :         hccp_err("[deinit][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     406              :             ret, phyId, remQpHandle->devIndex);
     407            0 :         free(reqHandleTmp);
     408            0 :         reqHandleTmp = NULL;
     409            0 :         return ret;
     410              :     }
     411              : 
     412            1 :     *reqHandle = (void *)reqHandleTmp;
     413            1 :     return 0;
     414              : }
     415              : 
     416            2 : int RaHdcGetTpInfoListAsync(struct RaCtxHandle *ctxHandle, struct GetTpCfg *cfg, struct HccpTpInfo infoList[],
     417              :     unsigned int *num, void **reqHandle)
     418              : {
     419            2 :     struct RaResponseTpInfoList *asyncRsp = NULL;
     420            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     421            2 :     union OpGetTpInfoListData asyncData = {0};
     422            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     423            2 :     int ret = 0;
     424              : 
     425            2 :     asyncRsp = (struct RaResponseTpInfoList *)calloc(1, sizeof(struct RaResponseTpInfoList));
     426            2 :     CHK_PRT_RETURN(asyncRsp == NULL,
     427              :         hccp_err("[get][ra_hdc_tp_info]calloc async_rsp failed, phyId[%u] devIndex[0x%x]",
     428              :         phyId, ctxHandle->devIndex), -ENOMEM);
     429            2 :     asyncRsp->infoList = infoList;
     430            2 :     asyncRsp->num = num;
     431              : 
     432            2 :     asyncData.txData.phyId = phyId;
     433            2 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     434            2 :     asyncData.txData.num = *num;
     435            2 :     (void)memcpy_s(&asyncData.txData.cfg, sizeof(struct GetTpCfg), cfg, sizeof(struct GetTpCfg));
     436              : 
     437            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     438            2 :     if (reqHandleTmp == NULL) {
     439            0 :         hccp_err("[get][ra_hdc_tp_info]calloc RaRequestHandle failed, phyId[%u], devIndex[0x%x]",
     440              :             phyId, ctxHandle->devIndex);
     441            0 :         ret = -ENOMEM;
     442            0 :         goto out;
     443              :     }
     444              : 
     445            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     446            2 :     reqHandleTmp->privData = (void *)asyncRsp;
     447            2 :     ret = RaHdcSendMsgAsync(RA_RS_GET_TP_INFO_LIST, phyId, (char *)&asyncData,
     448              :         sizeof(union OpGetTpInfoListData), reqHandleTmp);
     449            2 :     if (ret != 0) {
     450            1 :         hccp_err("[get][ra_hdc_tp_info]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     451              :             ret, phyId, ctxHandle->devIndex);
     452            1 :         free(reqHandleTmp);
     453            1 :         reqHandleTmp = NULL;
     454            1 :         goto out;
     455              :     }
     456              : 
     457            1 :     *reqHandle = (void *)reqHandleTmp;
     458            1 :     return 0;
     459            1 : out:
     460            1 :     free(asyncRsp);
     461            1 :     asyncRsp = NULL;
     462            1 :     return ret;
     463              : }
     464              : 
     465            4 : void RaHdcAsyncHandleTpInfoList(struct RaRequestHandle *reqHandle)
     466              : {
     467            4 :     struct RaResponseTpInfoList *asyncRsp = NULL;
     468            4 :     union OpGetTpInfoListData *asyncData = NULL;
     469              :     int ret;
     470              : 
     471            4 :     if (reqHandle->opRet != 0) {
     472            1 :         goto out;
     473              :     }
     474            3 :     asyncData = (union OpGetTpInfoListData *)reqHandle->recvBuf;
     475            3 :     asyncRsp = (struct RaResponseTpInfoList *)reqHandle->privData;
     476            3 :     if (asyncData->rxData.num == 0) {
     477            1 :         *asyncRsp->num = asyncData->rxData.num;
     478            1 :         goto out;
     479              :     }
     480              : 
     481            2 :     ret = memcpy_s(asyncRsp->infoList, (*asyncRsp->num) * sizeof(struct HccpTpInfo),
     482            2 :         asyncData->rxData.infoList, asyncData->rxData.num * sizeof(struct HccpTpInfo));
     483            2 :     if (ret != 0) {
     484            1 :         hccp_err("[get][ra_hdc_tp_info]memcpy_s tp_info failed ret[%d] *async_rsp->num[%u] rx_data.num[%u], "
     485              :             "phyId[%u] devIndex[0x%x]", ret, *asyncRsp->num, asyncData->rxData.num,
     486              :             reqHandle->phyId, reqHandle->devIndex);
     487            1 :         reqHandle->opRet = -ESAFEFUNC;
     488            1 :         goto out;
     489              :     }
     490            1 :     *asyncRsp->num = asyncData->rxData.num;
     491            4 : out:
     492            4 :     free(reqHandle->privData);
     493            4 :     reqHandle->privData = NULL;
     494            4 :     return;
     495              : }
     496              : 
     497            0 : int RaHdcGetTpAttrAsync(struct RaCtxHandle *ctxHandle, uint64_t tpHandle, uint32_t *attrBitmap,
     498              :     struct TpAttr *attr, void **reqHandle)
     499              : {
     500            0 :     struct RaResponseGetTpAttr *asyncRsp = NULL;
     501            0 :     struct RaRequestHandle *reqHandleTmp = NULL;
     502            0 :     unsigned int phyId = ctxHandle->attr.phyId;
     503            0 :     union OpGetTpAttrData asyncData = {0};
     504            0 :     int ret = 0;
     505              : 
     506            0 :     asyncRsp = (struct RaResponseGetTpAttr *)calloc(1, sizeof(struct RaResponseGetTpAttr));
     507            0 :     CHK_PRT_RETURN(asyncRsp == NULL,
     508              :         hccp_err("[get][ra_hdc_tp_attr]calloc ra_response_get_tp_attr failed, phyId[%u] devIndex[0x%x]",
     509              :         phyId, ctxHandle->devIndex), -ENOMEM);
     510            0 :     asyncRsp->attr = attr;
     511            0 :     asyncRsp->attrBitmap = attrBitmap;
     512              : 
     513            0 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     514            0 :     asyncData.txData.phyId = phyId;
     515            0 :     asyncData.txData.tpHandle = tpHandle;
     516            0 :     asyncData.txData.attrBitmap = *attrBitmap;
     517            0 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     518            0 :     if (reqHandleTmp == NULL) {
     519            0 :         hccp_err("[get][ra_hdc_tp_attr]calloc RaRequestHandle failed, phyId[%u] devIndex[0x%x]",
     520              :             phyId, ctxHandle->devIndex);
     521            0 :         ret = -ENOMEM;
     522            0 :         goto out;
     523              :     }
     524              : 
     525            0 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     526            0 :     reqHandleTmp->privData = (void *)asyncRsp;
     527            0 :     ret = RaHdcSendMsgAsync(RA_RS_GET_TP_ATTR, phyId, (char *)&asyncData,
     528              :         sizeof(union OpGetTpAttrData), reqHandleTmp);
     529            0 :     if (ret != 0) {
     530            0 :         hccp_err("[get][ra_hdc_tp_attr]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     531              :             ret, phyId, ctxHandle->devIndex);
     532            0 :         free(reqHandleTmp);
     533            0 :         reqHandleTmp = NULL;
     534            0 :         goto out;
     535              :     }
     536              : 
     537            0 :     *reqHandle = (void *)reqHandleTmp;
     538            0 :     return 0;
     539            0 : out:
     540            0 :     free(asyncRsp);
     541            0 :     asyncRsp = NULL;
     542            0 :     return ret;
     543              : }
     544              : 
     545            0 : void RaHdcAsyncHandleGetTpAttr(struct RaRequestHandle *reqHandle)
     546              : {
     547            0 :     struct RaResponseGetTpAttr *asyncRsp = NULL;
     548            0 :     union OpGetTpAttrData *asyncData = NULL;
     549              : 
     550            0 :     if (reqHandle->opRet != 0) {
     551            0 :         goto out;
     552              :     }
     553            0 :     asyncData = (union OpGetTpAttrData *)reqHandle->recvBuf;
     554            0 :     asyncRsp = (struct RaResponseGetTpAttr *)reqHandle->privData;
     555            0 :     *asyncRsp->attrBitmap = asyncData->rxData.attrBitmap;
     556            0 :     (void)memcpy_s(asyncRsp->attr, sizeof(struct TpAttr), &asyncData->rxData.attr, sizeof(struct TpAttr));
     557              : 
     558            0 : out:
     559            0 :     free(reqHandle->privData);
     560            0 :     reqHandle->privData = NULL;
     561            0 :     return;
     562              : }
     563              : 
     564            0 : int RaHdcSetTpAttrAsync(struct RaCtxHandle *ctxHandle, uint64_t tpHandle, uint32_t attrBitmap,
     565              :     struct TpAttr *attr, void **reqHandle)
     566              : {
     567            0 :     struct RaRequestHandle *reqHandleTmp = NULL;
     568            0 :     unsigned int phyId = ctxHandle->attr.phyId;
     569            0 :     union OpSetTpAttrData asyncData = {0};
     570            0 :     int ret = 0;
     571              : 
     572            0 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     573            0 :     asyncData.txData.phyId = phyId;
     574            0 :     asyncData.txData.tpHandle = tpHandle;
     575            0 :     asyncData.txData.attrBitmap = attrBitmap;
     576            0 :     (void)memcpy_s(&asyncData.txData.attr, sizeof(struct TpAttr), attr, sizeof(struct TpAttr));
     577            0 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     578            0 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     579              :         hccp_err("[set][ra_hdc_tp_attr]calloc RaRequestHandle failed, phyId[%u] devIndex[0x%x]",
     580              :         phyId, ctxHandle->devIndex), -ENOMEM);
     581              : 
     582            0 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     583            0 :     ret = RaHdcSendMsgAsync(RA_RS_SET_TP_ATTR, phyId, (char *)&asyncData,
     584              :         sizeof(union OpSetTpAttrData), reqHandleTmp);
     585            0 :     if (ret != 0) {
     586            0 :         hccp_err("[set][ra_hdc_tp_attr]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     587              :             ret, phyId, ctxHandle->devIndex);
     588            0 :         free(reqHandleTmp);
     589            0 :         reqHandleTmp = NULL;
     590            0 :         return ret;
     591              :     }
     592              : 
     593            0 :     *reqHandle = (void *)reqHandleTmp;
     594            0 :     return 0;
     595              : }
     596              : 
     597            6 : STATIC int QpDestroyBatchParamCheck(struct RaCtxHandle *ctxHandle, void *qpHandle[],
     598              :     unsigned int ids[], unsigned int *num)
     599              : {
     600            6 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     601              :     unsigned int i;
     602              : 
     603            9 :     for (i = 0; i < *num; ++i) {
     604            6 :         qpHandleTmp = (struct RaCtxQpHandle *)qpHandle[i];
     605            6 :         CHK_PRT_RETURN(qpHandleTmp == NULL,
     606              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]qp_handle[%u] is NULL", i), -EINVAL);
     607            5 :         CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL,
     608              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]ctx_handle[%u] is NULL", i), -EINVAL);
     609            4 :         CHK_PRT_RETURN(qpHandleTmp->ctxHandle != ctxHandle,
     610              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]qp_handle[%u]->ctx_handle is different from others", i), -EINVAL);
     611              : 
     612            3 :         ids[i] = qpHandleTmp->id;
     613              :     }
     614              : 
     615            3 :     return 0;
     616              : }
     617              : 
     618            4 : int RaHdcCtxQpDestroyBatchAsync(struct RaCtxHandle *ctxHandle, void *qpHandle[],
     619              :     unsigned int *num, void **reqHandle)
     620              : {
     621            4 :     union OpCtxQpDestroyBatchData asyncData = {0};
     622            4 :     struct RaRequestHandle *reqHandleTmp = NULL;
     623            4 :     unsigned int phyId = ctxHandle->attr.phyId;
     624              :     int ret;
     625              : 
     626            4 :     ret = QpDestroyBatchParamCheck(ctxHandle, qpHandle, asyncData.txData.ids, num);
     627            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("[destroy_batch][ra_hdc_ctx_qp]param check failed, phyId[%u] devIndex[0x%x]",
     628              :         phyId, ctxHandle->devIndex), ret);
     629              : 
     630            3 :     asyncData.txData.phyId = phyId;
     631            3 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     632            3 :     asyncData.txData.num = *num;
     633              : 
     634            3 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     635            3 :     CHK_PRT_RETURN(reqHandleTmp == NULL, hccp_err("[destroy_batch][ra_hdc_ctx_qp]calloc RaRequestHandle failed, "
     636              :         "phyId[%u] devIndex[0x%x]", phyId, ctxHandle->devIndex), -ENOMEM);
     637              : 
     638            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     639            2 :     reqHandleTmp->privData = (void *)num;
     640            2 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_DESTROY_BATCH, phyId, (char *)&asyncData,
     641              :         sizeof(union OpCtxQpDestroyBatchData), reqHandleTmp);
     642            2 :     if (ret != 0) {
     643            1 :         hccp_err("[destroy_batch][ra_hdc_ctx_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     644              :             ret, phyId, ctxHandle->devIndex);
     645            1 :         free(reqHandleTmp);
     646            1 :         reqHandleTmp = NULL;
     647            1 :         return ret;
     648              :     }
     649              : 
     650            1 :     *reqHandle = (void *)reqHandleTmp;
     651            1 :     return 0;
     652              : }
     653              : 
     654            1 : void RaHdcAsyncHandleQpDestroyBatch(struct RaRequestHandle *reqHandle)
     655              : {
     656            1 :     union OpCtxQpDestroyBatchData *asyncData = NULL;
     657            1 :     unsigned int *num = NULL;
     658              : 
     659            1 :     asyncData = (union OpCtxQpDestroyBatchData *)reqHandle->recvBuf;
     660            1 :     num = (unsigned int *)reqHandle->privData;
     661            1 :     *num = asyncData->rxData.num;
     662              : 
     663            1 :     return;
     664              : }
        

Generated by: LCOV version 2.0-1