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: 68.6 % 357 245
Test Date: 2026-07-28 12:11:00 Functions: 78.9 % 19 15

            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 :     struct RaResponseEidList *asyncRsp = NULL;
      26            4 :     unsigned int phyId = ctxHandle->attr.phyId;
      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 :     union OpGetEidByIpData *asyncData = NULL;
      70            1 :     struct RaResponseEidList *asyncRsp = 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            1 : int RaHdcCtxLmemRegisterAsync(struct RaCtxHandle *ctxHandle, struct MrRegInfoT *lmemInfo, 
      91              :     struct RaLmemHandle *lmemHandle, void **reqHandle)
      92              : {
      93            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
      94            1 :     unsigned int phyId = ctxHandle->attr.phyId;
      95            1 :     union OpLmemRegInfoData asyncData = {0};
      96              :     int ret;
      97              : 
      98            1 :     ret = RaHdcCtxPrepareLmemRegister(ctxHandle, lmemInfo, &asyncData);
      99            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_lmem]prepare register failed ret[%d], phyId[%u] devIndex[%u]",
     100              :         ret, phyId, ctxHandle->devIndex), ret);
     101              : 
     102            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     103            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     104              :         hccp_err("[init][ra_hdc_lmem]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     105              :         phyId, ctxHandle->devIndex), -ENOMEM);
     106              : 
     107            1 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     108            1 :     reqHandleTmp->privData = (void *)&lmemInfo->out;
     109            1 :     reqHandleTmp->privHandle = (void *)lmemHandle;
     110            1 :     ret = RaHdcSendMsgAsync(RA_RS_LMEM_REG, phyId, (char *)&asyncData, sizeof(union OpLmemRegInfoData),
     111              :         reqHandleTmp);
     112            1 :     if (ret != 0) {
     113            0 :         hccp_err("[init][ra_hdc_lmem]hdc async send message failed ret[%d], phyId[%u], devIndex[0x%x]",
     114              :             ret, phyId, ctxHandle->devIndex);
     115            0 :         free(reqHandleTmp);
     116            0 :         reqHandleTmp = NULL;
     117            0 :         return ret;
     118              :     }
     119              : 
     120            1 :     *reqHandle = (void *)reqHandleTmp;
     121            1 :     return 0;
     122              : }
     123              : 
     124            1 : void RaHdcAsyncHandleLmemRegister(struct RaRequestHandle *reqHandle)
     125              : {
     126            1 :     union OpLmemRegInfoData *asyncData = NULL;
     127            1 :     struct RaLmemHandle *lmemHandle = NULL;
     128            1 :     struct MemRegInfo *info = NULL;
     129              :     int ret;
     130              : 
     131            1 :     asyncData = (union OpLmemRegInfoData *)reqHandle->recvBuf;
     132            1 :     lmemHandle = (struct RaLmemHandle *)reqHandle->privHandle;
     133            1 :     info = (struct MemRegInfo *)reqHandle->privData;
     134            1 :     ret = memcpy_s(info, sizeof(struct MemRegInfo), &asyncData->rxData.memInfo, sizeof(struct MemRegInfoT));
     135            1 :     if (ret != 0) {
     136            1 :         hccp_err("[init][ra_hdc_lmem]memcpy_s mem_info failed ret[%d], phyId[%u] devIndex[0x%x]",
     137              :             ret, reqHandle->phyId, reqHandle->devIndex);
     138            1 :         reqHandle->opRet = -ESAFEFUNC;
     139            1 :         return;
     140              :     }
     141              : 
     142            0 :     lmemHandle->addr = info->ub.targetSegHandle;
     143            0 :     return;
     144              : }
     145              : 
     146            2 : int RaHdcCtxLmemUnregisterAsync(struct RaCtxHandle *ctxHandle, struct RaLmemHandle *lmemHandle,
     147              :     void **reqHandle)
     148              : {
     149            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     150            2 :     union OpLmemUnregInfoData asyncData = {0};
     151            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     152            2 :     int ret = 0;
     153              : 
     154            2 :     asyncData.txData.phyId = phyId;
     155            2 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     156            2 :     asyncData.txData.addr = lmemHandle->addr;
     157            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     158            2 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     159              :         hccp_err("[deinit][ra_hdc_lmem]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     160              :         phyId, ctxHandle->devIndex), -ENOMEM);
     161              : 
     162            2 :     ret = RaHdcSendMsgAsync(RA_RS_LMEM_UNREG, phyId, (char *)&asyncData, sizeof(union OpLmemUnregInfoData),
     163              :         reqHandleTmp);
     164            2 :     if (ret != 0) {
     165            0 :         hccp_err("[deinit][ra_hdc_lmem]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     166              :             ret, phyId, ctxHandle->devIndex);
     167            0 :         free(reqHandleTmp);
     168            0 :         reqHandleTmp = NULL;
     169            0 :         return ret;
     170              :     }
     171              : 
     172            2 :     *reqHandle = (void *)reqHandleTmp;
     173            2 :     return 0;
     174              : }
     175              : 
     176            2 : int RaHdcCtxQpCreateAsync(struct RaCtxHandle *ctxHandle, struct QpCreateAttr *attr,
     177              :         struct QpCreateInfo *info, struct RaCtxQpHandle *qpHandle, void **reqHandle)
     178              : {
     179            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     180            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     181            2 :     union OpCtxQpCreateData asyncData = {0};
     182              :     int ret;
     183              : 
     184            2 :     ret = RaHdcCtxPrepareQpCreate(ctxHandle, attr, &asyncData);
     185            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_qp]prepare qp_create failed ret[%d], phyId[%u] devIndex[0x%x]",
     186              :         ret, phyId, ctxHandle->devIndex), ret);
     187              : 
     188            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     189            2 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     190              :         hccp_err("[init][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     191              :         phyId, ctxHandle->devIndex), -ENOMEM);
     192            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     193            2 :     reqHandleTmp->privData = (void *)info;
     194            2 :     qpHandle->ctxHandle = ctxHandle;
     195            2 :     qpHandle->devIndex = ctxHandle->devIndex;
     196            2 :     qpHandle->phyId = ctxHandle->attr.phyId;
     197            2 :     qpHandle->protocol = ctxHandle->protocol;
     198            2 :     (void)memcpy_s(&qpHandle->qpAttr, sizeof(struct QpCreateAttr), attr, sizeof(struct QpCreateAttr));
     199            2 :     reqHandleTmp->privHandle = (void *)qpHandle;
     200              : 
     201            2 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_CREATE, phyId, (char *)&asyncData,
     202              :         sizeof(union OpCtxQpCreateData), reqHandleTmp);
     203            2 :     if (ret != 0) {
     204            0 :         hccp_err("[init][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     205              :             ret, phyId, ctxHandle->devIndex);
     206            0 :         free(reqHandleTmp);
     207            0 :         reqHandleTmp = NULL;
     208            0 :         return ret;
     209              :     }
     210              : 
     211            2 :     *reqHandle = (void *)reqHandleTmp;
     212            2 :     return 0;
     213              : }
     214              : 
     215            0 : void RaHdcAsyncHandleQpCreate(struct RaRequestHandle *reqHandle)
     216              : {
     217            0 :     union OpCtxQpCreateData *asyncData = NULL;
     218            0 :     struct RaCtxQpHandle *qpHandle = NULL;
     219            0 :     struct QpCreateInfo *info = NULL;
     220              : 
     221            0 :     asyncData = (union OpCtxQpCreateData *)reqHandle->recvBuf;
     222            0 :     info = (struct QpCreateInfo *)reqHandle->privData;
     223            0 :     qpHandle = (struct RaCtxQpHandle *)reqHandle->privHandle;
     224            0 :     (void)memcpy_s(info, sizeof(struct QpCreateInfo), &asyncData->rxData.qpInfo, sizeof(struct QpCreateInfo));
     225            0 :     qpHandle->id = info->ub.id;
     226            0 :     (void)memcpy_s(&qpHandle->qpInfo, sizeof(struct QpCreateInfo), info, sizeof(struct QpCreateInfo));
     227              : 
     228            0 :     return;
     229              : }
     230              : 
     231            1 : int RaHdcCtxQpDestroyAsync(struct RaCtxQpHandle *qpHandle, void **reqHandle)
     232              : {
     233            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     234            1 :     union OpCtxQpDestroyData asyncData = {0};
     235            1 :     unsigned int phyId = qpHandle->phyId;
     236              :     int ret;
     237              : 
     238            1 :     asyncData.txData.phyId = phyId;
     239            1 :     asyncData.txData.devIndex = qpHandle->devIndex;
     240            1 :     asyncData.txData.id = qpHandle->id;
     241              : 
     242            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     243            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     244              :         hccp_err("[deinit][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     245              :         phyId, qpHandle->devIndex), -ENOMEM);
     246              : 
     247            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_DESTROY, phyId, (char *)&asyncData,
     248              :         sizeof(union OpCtxQpDestroyData), reqHandleTmp);
     249            1 :     if (ret != 0) {
     250            0 :         hccp_err("[deinit][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     251              :             ret, phyId, qpHandle->devIndex);
     252            0 :         free(reqHandleTmp);
     253            0 :         reqHandleTmp = NULL;
     254            0 :         return ret;
     255              :     }
     256              : 
     257            1 :     *reqHandle = (void *)reqHandleTmp;
     258            1 :     return 0;
     259              : }
     260              : 
     261            1 : int RaHdcCtxQpImportAsync(struct RaCtxHandle *ctxHandle, struct QpImportInfoT *info,
     262              :     struct RaCtxRemQpHandle *remQpHandle, void **reqHandle)
     263              : {
     264            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     265            1 :     unsigned int phyId = ctxHandle->attr.phyId;
     266            1 :     union OpCtxQpImportData asyncData = {0};
     267            1 :     int ret = 0;
     268              : 
     269            1 :     ret = RaHdcCtxPrepareQpImport(ctxHandle, info, &asyncData);
     270            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_hdc_qp]prepare qp_import failed ret[%d], phyId[%u] devIndex[0x%x]",
     271              :         ret, phyId, ctxHandle->devIndex), ret);
     272              : 
     273            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     274            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     275              :         hccp_err("[init][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     276              :         phyId, ctxHandle->devIndex), -ENOMEM);
     277              : 
     278            1 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     279            1 :     reqHandleTmp->privData = (void *)&info->out;
     280            1 :     remQpHandle->devIndex = ctxHandle->devIndex;
     281            1 :     remQpHandle->phyId = ctxHandle->attr.phyId;
     282            1 :     remQpHandle->protocol = ctxHandle->protocol;
     283            1 :     reqHandleTmp->privHandle = (void *)remQpHandle;
     284              : 
     285            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_IMPORT, phyId, (char *)&asyncData,
     286              :         sizeof(union OpCtxQpImportData), reqHandleTmp);
     287            1 :     if (ret != 0) {
     288            0 :         hccp_err("[init][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     289              :             ret, phyId, ctxHandle->devIndex);
     290            0 :         free(reqHandleTmp);
     291            0 :         reqHandleTmp = NULL;
     292            0 :         return ret;
     293              :     }
     294              : 
     295            1 :     *reqHandle = (void *)reqHandleTmp;
     296            1 :     return 0;
     297              : }
     298              : 
     299            1 : void RaHdcAsyncHandleQpImport(struct RaRequestHandle *reqHandle)
     300              : {
     301            1 :     struct RaCtxRemQpHandle *remQpHandle = NULL;
     302            1 :     union OpCtxQpImportData *asyncData = NULL;
     303            1 :     struct QpImportInfo *info = NULL;
     304              : 
     305            1 :     asyncData = (union OpCtxQpImportData *)reqHandle->recvBuf;
     306            1 :     info = (struct QpImportInfo *)reqHandle->privData;
     307            1 :     remQpHandle = (struct RaCtxRemQpHandle *)reqHandle->privHandle;
     308              : 
     309            1 :     info->ub.tjettyHandle = asyncData->rxData.info.tjettyHandle;
     310            1 :     info->ub.tpn = asyncData->rxData.info.tpn;
     311            1 :     remQpHandle->id = asyncData->rxData.remJettyId;
     312              : 
     313            1 :     return;
     314              : }
     315              : 
     316            1 : int RaHdcCtxQpUnimportAsync(struct RaCtxRemQpHandle *remQpHandle, void **reqHandle)
     317              : {
     318            1 :     struct RaRequestHandle *reqHandleTmp = NULL;
     319            1 :     union OpCtxQpUnimportData asyncData = {0};
     320            1 :     unsigned int phyId = remQpHandle->phyId;
     321              :     int ret;
     322              : 
     323            1 :     asyncData.txData.phyId = phyId;
     324            1 :     asyncData.txData.devIndex = remQpHandle->devIndex;
     325            1 :     asyncData.txData.remJettyId = remQpHandle->id;
     326              : 
     327            1 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     328            1 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     329              :         hccp_err("[deinit][ra_hdc_qp]calloc req_handle_tmp failed, phyId[%u], devIndex[0x%x]",
     330              :         phyId, remQpHandle->devIndex), -ENOMEM);
     331              : 
     332            1 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_UNIMPORT, phyId, (char *)&asyncData,
     333              :         sizeof(union OpCtxQpUnimportData), reqHandleTmp);
     334            1 :     if (ret != 0) {
     335            0 :         hccp_err("[deinit][ra_hdc_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     336              :             ret, phyId, remQpHandle->devIndex);
     337            0 :         free(reqHandleTmp);
     338            0 :         reqHandleTmp = NULL;
     339            0 :         return ret;
     340              :     }
     341              : 
     342            1 :     *reqHandle = (void *)reqHandleTmp;
     343            1 :     return 0;
     344              : }
     345              : 
     346            2 : int RaHdcGetTpInfoListAsync(struct RaCtxHandle *ctxHandle, struct GetTpCfg *cfg, struct HccpTpInfo infoList[],
     347              :     unsigned int *num, void **reqHandle)
     348              : {
     349            2 :     struct RaResponseTpInfoList *asyncRsp = NULL;
     350            2 :     struct RaRequestHandle *reqHandleTmp = NULL;
     351            2 :     union OpGetTpInfoListData asyncData = {0};
     352            2 :     unsigned int phyId = ctxHandle->attr.phyId;
     353            2 :     int ret = 0;
     354              : 
     355            2 :     asyncRsp = (struct RaResponseTpInfoList *)calloc(1, sizeof(struct RaResponseTpInfoList));
     356            2 :     CHK_PRT_RETURN(asyncRsp == NULL,
     357              :         hccp_err("[get][ra_hdc_tp_info]calloc async_rsp failed, phyId[%u] devIndex[0x%x]",
     358              :         phyId, ctxHandle->devIndex), -ENOMEM);
     359            2 :     asyncRsp->infoList = infoList;
     360            2 :     asyncRsp->num = num;
     361              : 
     362            2 :     asyncData.txData.phyId = phyId;
     363            2 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     364            2 :     asyncData.txData.num = *num;
     365            2 :     (void)memcpy_s(&asyncData.txData.cfg, sizeof(struct GetTpCfg), cfg, sizeof(struct GetTpCfg));
     366              : 
     367            2 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     368            2 :     if (reqHandleTmp == NULL) {
     369            0 :         hccp_err("[get][ra_hdc_tp_info]calloc RaRequestHandle failed, phyId[%u], devIndex[0x%x]",
     370              :             phyId, ctxHandle->devIndex);
     371            0 :         ret = -ENOMEM;
     372            0 :         goto out;
     373              :     }
     374              : 
     375            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     376            2 :     reqHandleTmp->privData = (void *)asyncRsp;
     377            2 :     ret = RaHdcSendMsgAsync(RA_RS_GET_TP_INFO_LIST, phyId, (char *)&asyncData,
     378              :         sizeof(union OpGetTpInfoListData), reqHandleTmp);
     379            2 :     if (ret != 0) {
     380            1 :         hccp_err("[get][ra_hdc_tp_info]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     381              :             ret, phyId, ctxHandle->devIndex);
     382            1 :         free(reqHandleTmp);
     383            1 :         reqHandleTmp = NULL;
     384            1 :         goto out;
     385              :     }
     386              : 
     387            1 :     *reqHandle = (void *)reqHandleTmp;
     388            1 :     return 0;
     389            1 : out:
     390            1 :     free(asyncRsp);
     391            1 :     asyncRsp = NULL;
     392            1 :     return ret;
     393              : }
     394              : 
     395            4 : void RaHdcAsyncHandleTpInfoList(struct RaRequestHandle *reqHandle)
     396              : {
     397            4 :     struct RaResponseTpInfoList *asyncRsp = NULL;
     398            4 :     union OpGetTpInfoListData *asyncData = NULL;
     399              :     int ret;
     400              : 
     401            4 :     if (reqHandle->opRet != 0) {
     402            1 :         goto out;
     403              :     }
     404            3 :     asyncData = (union OpGetTpInfoListData *)reqHandle->recvBuf;
     405            3 :     asyncRsp = (struct RaResponseTpInfoList *)reqHandle->privData;
     406            3 :     if (asyncData->rxData.num == 0) {
     407            1 :         *asyncRsp->num = asyncData->rxData.num;
     408            1 :         goto out;
     409              :     }
     410              : 
     411            2 :     ret = memcpy_s(asyncRsp->infoList, (*asyncRsp->num) * sizeof(struct HccpTpInfo),
     412            2 :         asyncData->rxData.infoList, asyncData->rxData.num * sizeof(struct HccpTpInfo));
     413            2 :     if (ret != 0) {
     414            1 :         hccp_err("[get][ra_hdc_tp_info]memcpy_s tp_info failed ret[%d] *async_rsp->num[%u] rx_data.num[%u], "
     415              :             "phyId[%u] devIndex[0x%x]", ret, *asyncRsp->num, asyncData->rxData.num,
     416              :             reqHandle->phyId, reqHandle->devIndex);
     417            1 :         reqHandle->opRet = -ESAFEFUNC;
     418            1 :         goto out;
     419              :     }
     420            1 :     *asyncRsp->num = asyncData->rxData.num;
     421            4 : out:
     422            4 :     free(reqHandle->privData);
     423            4 :     reqHandle->privData = NULL;
     424            4 :     return;
     425              : }
     426              : 
     427            0 : int RaHdcGetTpAttrAsync(struct RaCtxHandle *ctxHandle, uint64_t tpHandle, uint32_t *attrBitmap,
     428              :     struct TpAttr *attr, void **reqHandle)
     429              : {
     430            0 :     struct RaResponseGetTpAttr *asyncRsp = NULL;
     431            0 :     struct RaRequestHandle *reqHandleTmp = NULL;
     432            0 :     unsigned int phyId = ctxHandle->attr.phyId;
     433            0 :     union OpGetTpAttrData asyncData = {0};
     434            0 :     int ret = 0;
     435              : 
     436            0 :     asyncRsp = (struct RaResponseGetTpAttr *)calloc(1, sizeof(struct RaResponseGetTpAttr));
     437            0 :     CHK_PRT_RETURN(asyncRsp == NULL,
     438              :         hccp_err("[get][ra_hdc_tp_attr]calloc ra_response_get_tp_attr failed, phyId[%u] devIndex[0x%x]",
     439              :         phyId, ctxHandle->devIndex), -ENOMEM);
     440            0 :     asyncRsp->attr = attr;
     441            0 :     asyncRsp->attrBitmap = attrBitmap;
     442              : 
     443            0 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     444            0 :     asyncData.txData.phyId = phyId;
     445            0 :     asyncData.txData.tpHandle = tpHandle;
     446            0 :     asyncData.txData.attrBitmap = *attrBitmap;
     447            0 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     448            0 :     if (reqHandleTmp == NULL) {
     449            0 :         hccp_err("[get][ra_hdc_tp_attr]calloc RaRequestHandle failed, phyId[%u] devIndex[0x%x]",
     450              :             phyId, ctxHandle->devIndex);
     451            0 :         ret = -ENOMEM;
     452            0 :         goto out;
     453              :     }
     454              : 
     455            0 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     456            0 :     reqHandleTmp->privData = (void *)asyncRsp;
     457            0 :     ret = RaHdcSendMsgAsync(RA_RS_GET_TP_ATTR, phyId, (char *)&asyncData,
     458              :         sizeof(union OpGetTpAttrData), reqHandleTmp);
     459            0 :     if (ret != 0) {
     460            0 :         hccp_err("[get][ra_hdc_tp_attr]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     461              :             ret, phyId, ctxHandle->devIndex);
     462            0 :         free(reqHandleTmp);
     463            0 :         reqHandleTmp = NULL;
     464            0 :         goto out;
     465              :     }
     466              : 
     467            0 :     *reqHandle = (void *)reqHandleTmp;
     468            0 :     return 0;
     469            0 : out:
     470            0 :     free(asyncRsp);
     471            0 :     asyncRsp = NULL;
     472            0 :     return ret;
     473              : }
     474              : 
     475            0 : void RaHdcAsyncHandleGetTpAttr(struct RaRequestHandle *reqHandle)
     476              : {
     477            0 :     struct RaResponseGetTpAttr *asyncRsp = NULL;
     478            0 :     union OpGetTpAttrData *asyncData = NULL;
     479              : 
     480            0 :     if (reqHandle->opRet != 0) {
     481            0 :         goto out;
     482              :     }
     483            0 :     asyncData = (union OpGetTpAttrData *)reqHandle->recvBuf;
     484            0 :     asyncRsp = (struct RaResponseGetTpAttr *)reqHandle->privData;
     485            0 :     *asyncRsp->attrBitmap = asyncData->rxData.attrBitmap;
     486            0 :     (void)memcpy_s(asyncRsp->attr, sizeof(struct TpAttr), &asyncData->rxData.attr, sizeof(struct TpAttr));
     487              : 
     488            0 : out:
     489            0 :     free(reqHandle->privData);
     490            0 :     reqHandle->privData = NULL;
     491            0 :     return;
     492              : }
     493              : 
     494            0 : int RaHdcSetTpAttrAsync(struct RaCtxHandle *ctxHandle, uint64_t tpHandle, uint32_t attrBitmap,
     495              :     struct TpAttr *attr, void **reqHandle)
     496              : {
     497            0 :     struct RaRequestHandle *reqHandleTmp = NULL;
     498            0 :     unsigned int phyId = ctxHandle->attr.phyId;
     499            0 :     union OpSetTpAttrData asyncData = {0};
     500            0 :     int ret = 0;
     501              : 
     502            0 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     503            0 :     asyncData.txData.phyId = phyId;
     504            0 :     asyncData.txData.tpHandle = tpHandle;
     505            0 :     asyncData.txData.attrBitmap = attrBitmap;
     506            0 :     (void)memcpy_s(&asyncData.txData.attr, sizeof(struct TpAttr), attr, sizeof(struct TpAttr));
     507            0 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     508            0 :     CHK_PRT_RETURN(reqHandleTmp == NULL,
     509              :         hccp_err("[set][ra_hdc_tp_attr]calloc RaRequestHandle failed, phyId[%u] devIndex[0x%x]",
     510              :         phyId, ctxHandle->devIndex), -ENOMEM);
     511              : 
     512            0 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     513            0 :     ret = RaHdcSendMsgAsync(RA_RS_SET_TP_ATTR, phyId, (char *)&asyncData,
     514              :         sizeof(union OpSetTpAttrData), reqHandleTmp);
     515            0 :     if (ret != 0) {
     516            0 :         hccp_err("[set][ra_hdc_tp_attr]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     517              :             ret, phyId, ctxHandle->devIndex);
     518            0 :         free(reqHandleTmp);
     519            0 :         reqHandleTmp = NULL;
     520            0 :         return ret;
     521              :     }
     522              : 
     523            0 :     *reqHandle = (void *)reqHandleTmp;
     524            0 :     return 0;
     525              : }
     526              : 
     527            6 : STATIC int QpDestroyBatchParamCheck(struct RaCtxHandle *ctxHandle, void *qpHandle[],
     528              :     unsigned int ids[], unsigned int *num)
     529              : {
     530            6 :     struct RaCtxQpHandle *qpHandleTmp = NULL;
     531              :     unsigned int i;
     532              : 
     533            9 :     for (i = 0; i < *num; ++i) {
     534            6 :         qpHandleTmp = (struct RaCtxQpHandle *)qpHandle[i];
     535            6 :         CHK_PRT_RETURN(qpHandleTmp == NULL,
     536              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]qp_handle[%u] is NULL", i), -EINVAL);
     537            5 :         CHK_PRT_RETURN(qpHandleTmp->ctxHandle == NULL,
     538              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]ctx_handle[%u] is NULL", i), -EINVAL);
     539            4 :         CHK_PRT_RETURN(qpHandleTmp->ctxHandle != ctxHandle,
     540              :             hccp_err("[destroy_batch][ra_hdc_ctx_qp]qp_handle[%u]->ctx_handle is different from others", i), -EINVAL);
     541              : 
     542            3 :         ids[i] = qpHandleTmp->id;
     543              :     }
     544              : 
     545            3 :     return 0;
     546              : }
     547              : 
     548            4 : int RaHdcCtxQpDestroyBatchAsync(struct RaCtxHandle *ctxHandle, void *qpHandle[],
     549              :     unsigned int *num, void **reqHandle)
     550              : {
     551            4 :     union OpCtxQpDestroyBatchData asyncData = {0};
     552            4 :     struct RaRequestHandle *reqHandleTmp = NULL;
     553            4 :     unsigned int phyId = ctxHandle->attr.phyId;
     554              :     int ret;
     555              : 
     556            4 :     ret = QpDestroyBatchParamCheck(ctxHandle, qpHandle, asyncData.txData.ids, num);
     557            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("[destroy_batch][ra_hdc_ctx_qp]param check failed, phyId[%u] devIndex[0x%x]",
     558              :         phyId, ctxHandle->devIndex), ret);
     559              : 
     560            3 :     asyncData.txData.phyId = phyId;
     561            3 :     asyncData.txData.devIndex = ctxHandle->devIndex;
     562            3 :     asyncData.txData.num = *num;
     563              : 
     564            3 :     reqHandleTmp = (struct RaRequestHandle *)calloc(1, sizeof(struct RaRequestHandle));
     565            3 :     CHK_PRT_RETURN(reqHandleTmp == NULL, hccp_err("[destroy_batch][ra_hdc_ctx_qp]calloc RaRequestHandle failed, "
     566              :         "phyId[%u] devIndex[0x%x]", phyId, ctxHandle->devIndex), -ENOMEM);
     567              : 
     568            2 :     reqHandleTmp->devIndex = ctxHandle->devIndex;
     569            2 :     reqHandleTmp->privData = (void *)num;
     570            2 :     ret = RaHdcSendMsgAsync(RA_RS_CTX_QP_DESTROY_BATCH, phyId, (char *)&asyncData,
     571              :         sizeof(union OpCtxQpDestroyBatchData), reqHandleTmp);
     572            2 :     if (ret != 0) {
     573            1 :         hccp_err("[destroy_batch][ra_hdc_ctx_qp]hdc async send message failed ret[%d], phyId[%u] devIndex[0x%x]",
     574              :             ret, phyId, ctxHandle->devIndex);
     575            1 :         free(reqHandleTmp);
     576            1 :         reqHandleTmp = NULL;
     577            1 :         return ret;
     578              :     }
     579              : 
     580            1 :     *reqHandle = (void *)reqHandleTmp;
     581            1 :     return 0;
     582              : }
     583              : 
     584            1 : void RaHdcAsyncHandleQpDestroyBatch(struct RaRequestHandle *reqHandle)
     585              : {
     586            1 :     union OpCtxQpDestroyBatchData *asyncData = NULL;
     587            1 :     unsigned int *num = NULL;
     588              : 
     589            1 :     asyncData = (union OpCtxQpDestroyBatchData *)reqHandle->recvBuf;
     590            1 :     num = (unsigned int *)reqHandle->privData;
     591            1 :     *num = asyncData->rxData.num;
     592              : 
     593            1 :     return;
     594              : }
        

Generated by: LCOV version 2.0-1