LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_service/ctx - rs_ctx.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 81.1 % 491 398
Test Date: 2026-08-04 10:52:23 Functions: 86.1 % 36 31

            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 "dl_hal_function.h"
      13              : #include "dl_ibverbs_function.h"
      14              : #include "dl_urma_function.h"
      15              : #include "dl_ccu_function.h"
      16              : #include "dl_net_function.h"
      17              : #include "hccp_ctx.h"
      18              : #include "ra_rs_ctx.h"
      19              : #include "ra_rs_err.h"
      20              : #include "rs_inner.h"
      21              : #include "rs_ctx_inner.h"
      22              : #include "rs_ub.h"
      23              : #include "rs_ub_tp.h"
      24              : #include "rs_ub_dfx.h"
      25              : #include "rs_ctx.h"
      26              : 
      27            0 : int RsGetChipProtocol(unsigned int chipId, enum NetworkMode hccpMode, enum ProtocolTypeT *protocol,
      28              :     unsigned int logicId)
      29              : {
      30              : #define CHIP_NAME_950 "950"
      31              : #define CHIP_NAME_910_96 "910_96"
      32            0 :     halChipInfo chipInfo = {0};
      33              :     int ret;
      34              : 
      35              :     // set default protocol to RDMA for compatibility issue
      36            0 :     *protocol = PROTOCOL_RDMA;
      37              :     // other modes skip to get protocol
      38            0 :     if (hccpMode != NETWORK_OFFLINE) {
      39            0 :         return 0;
      40              :     }
      41              : 
      42            0 :     ret = DlHalGetChipInfo(logicId, &chipInfo);
      43            0 :     CHK_PRT_RETURN(ret != 0, hccp_warn("hal get chip info unsuccessful, chipId[%u], logicId[%u], ret[%d]",
      44              :         chipId, logicId, ret), 0);
      45              : 
      46            0 :     if ((strncmp((char *)chipInfo.name, CHIP_NAME_950, sizeof(CHIP_NAME_950) - 1) == 0) ||
      47            0 :         (strncmp((char *)chipInfo.name, CHIP_NAME_910_96, sizeof(CHIP_NAME_910_96) - 1) == 0)) {
      48            0 :         *protocol = PROTOCOL_UDMA;
      49              :     }
      50            0 :     return 0;
      51              : }
      52              : 
      53            0 : int RsCtxApiInit(enum NetworkMode hccpMode, enum ProtocolTypeT protocol)
      54              : {
      55            0 :     int ret = 0;
      56              : 
      57              :     // other modes skip to init api
      58            0 :     if (hccpMode != NETWORK_OFFLINE) {
      59            0 :         return ret;
      60              :     }
      61              : 
      62            0 :     switch (protocol) {
      63            0 :         case PROTOCOL_RDMA:
      64            0 :             ret = RsApiInit();
      65            0 :             CHK_PRT_RETURN(ret != 0, hccp_err("RsApiInit failed, protocol[%u], ret[%d]", protocol, ret), ret);
      66            0 :             break;
      67            0 :         case PROTOCOL_UDMA:
      68            0 :             ret = RsUbApiInit();
      69            0 :             CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_api_init failed, protocol[%u], ret[%d]", protocol, ret), ret);
      70            0 :             ret = RsCcuApiInit();
      71            0 :             if (ret != 0) {
      72            0 :                 hccp_err("rs_ccu_api_init failed, protocol[%u], ret[%d]", protocol, ret);
      73            0 :                 RsUbApiDeinit();
      74            0 :                 return ret;
      75              :             }
      76            0 :             ret = RsNetApiInit();
      77            0 :             if (ret != 0) {
      78            0 :                 hccp_err("rs_net_api_init failed, protocol[%u], ret[%d]", protocol, ret);
      79            0 :                 RsCcuApiDeinit();
      80            0 :                 RsUbApiDeinit();
      81            0 :                 return ret;
      82              :             }
      83            0 :             break;
      84            0 :         default:
      85            0 :             hccp_err("unsupported protocol[%u]", protocol);
      86            0 :             return -EINVAL;
      87              :     }
      88              : 
      89            0 :     return ret;
      90              : }
      91              : 
      92            0 : int RsCtxApiDeinit(enum NetworkMode hccpMode, enum ProtocolTypeT protocol)
      93              : {
      94              :     // other modes skip to deinit api
      95            0 :     if (hccpMode != NETWORK_OFFLINE) {
      96            0 :         return 0;
      97              :     }
      98              : 
      99            0 :     switch (protocol) {
     100            0 :         case PROTOCOL_RDMA:
     101            0 :             RsApiDeinit();
     102            0 :             break;
     103            0 :         case PROTOCOL_UDMA:
     104            0 :             RsUbApiDeinit();
     105            0 :             RsCcuApiDeinit();
     106            0 :             RsNetApiDeinit();
     107            0 :             break;
     108            0 :         default:
     109            0 :             hccp_err("unsupported protocol[%u]", protocol);
     110            0 :             return -EINVAL;
     111              :     }
     112            0 :     return 0;
     113              : }
     114              : 
     115            1 : RS_ATTRI_VISI_DEF int RsGetDevEidInfoNum(unsigned int phyId, unsigned int *num)
     116              : {
     117            1 :     int ret = 0;
     118              : 
     119            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     120              : 
     121            1 :     ret = RsUbGetDevEidInfoNum(phyId, num);
     122            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_get_dev_eid_info_num failed, phyId:%u, ret:%d", phyId, ret), ret);
     123              : 
     124            1 :     return ret;
     125              : }
     126              : 
     127            1 : RS_ATTRI_VISI_DEF int RsGetDevEidInfoList(unsigned int phyId, struct HccpDevEidInfo infoList[],
     128              :     unsigned int startIndex, unsigned int count)
     129              : {
     130            1 :     int ret = 0;
     131              : 
     132            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
     133              : 
     134            1 :     ret = RsUbGetDevEidInfoList(phyId, infoList, startIndex, count);
     135            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_get_dev_eid_info_list failed, phyId:%u, ret:%d", phyId, ret), ret);
     136              : 
     137            1 :     return ret;
     138              : }
     139              : 
     140            1 : RS_ATTRI_VISI_DEF int RsCtxInit(struct CtxInitAttr *attr, unsigned int *devIndex, struct DevBaseAttr *devAttr)
     141              : {
     142            1 :     struct rs_cb *rscb = NULL;
     143              :     unsigned int phyId;
     144            1 :     int ret = 0;
     145              : 
     146            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     147            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devIndex);
     148            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devAttr);
     149            1 :     phyId = attr->phyId;
     150            1 :     ret = RsGetRsCb(phyId, &rscb);
     151            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("RsGetRsCb failed, ret:%d", ret), ret);
     152              : 
     153              : #ifdef CUSTOM_INTERFACE
     154              :     // setup sharemem for pingmesh
     155            1 :     ret = RsSetupSharemem(rscb, false, phyId);
     156            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("RsSetupSharemem failed, phyId:%u, ret:%d", phyId, ret), ret);
     157              : #endif
     158              : 
     159            1 :     ret = RsUbCtxInit(rscb, attr, devIndex, devAttr);
     160            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_init failed, devIndex:0x%x, ret:%d", *devIndex, ret), ret);
     161              : 
     162            1 :     return ret;
     163              : }
     164              : 
     165            0 : RS_ATTRI_VISI_DEF int RsCtxGetAsyncEvents(struct RaRsDevInfo *devInfo, struct AsyncEvent asyncEvents[],
     166              :     unsigned int *num)
     167              : {
     168            0 :     struct RsUbDevCb *devCb = NULL;
     169            0 :     struct rs_cb *rscb = NULL;
     170            0 :     int ret = 0;
     171              : 
     172            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     173            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(asyncEvents);
     174            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     175              : 
     176            0 :     CHK_PRT_RETURN(*num == 0, hccp_err("num can not be 0"), -EINVAL);
     177              : 
     178            0 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     179            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     180              : 
     181            0 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     182            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     183              : 
     184            0 :     RsUbCtxGetAsyncEvents(devCb, asyncEvents, num);
     185              : 
     186            0 :     return ret;
     187              : }
     188              : 
     189            1 : RS_ATTRI_VISI_DEF int RsCtxDeinit(struct RaRsDevInfo *devInfo)
     190              : {
     191            1 :     struct RsUbDevCb *devCb = NULL;
     192            1 :     struct rs_cb *rscb = NULL;
     193            1 :     int ret = 0;
     194              : 
     195            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     196              : 
     197            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     198            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     199              : 
     200            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     201            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb fail, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     202              : 
     203            1 :     ret = RsUbCtxDeinit(devCb);
     204            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs ub ctx deinit failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     205              : 
     206            1 :     return ret;
     207              : }
     208              : 
     209            4 : RS_ATTRI_VISI_DEF int RsGetEidByIp(struct RaRsDevInfo *devInfo, struct IpInfo ip[], union HccpEid eid[],
     210              :     unsigned int *num)
     211              : {
     212            4 :     struct RsUbDevCb *devCb = NULL;
     213            4 :     struct rs_cb *rscb = NULL;
     214            4 :     int ret = 0;
     215              : 
     216            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     217            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(ip);
     218            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(eid);
     219            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     220              : 
     221            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     222            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     223              : 
     224            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     225            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     226              : 
     227            2 :     ret = RsUbGetEidByIp(devCb, ip, eid, num);
     228            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get_eid_by_ip failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     229              : 
     230            1 :     return ret;
     231              : }
     232              : 
     233            4 : RS_ATTRI_VISI_DEF int RsGetIpByEid(struct RaRsDevInfo *devInfo, union HccpEid eid[], struct IpInfo ip[],
     234              :     unsigned int *num)
     235              : {
     236            4 :     struct RsUbDevCb *devCb = NULL;
     237            4 :     struct rs_cb *rscb = NULL;
     238            4 :     int ret = 0;
     239              : 
     240            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     241            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(eid);
     242            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(ip);
     243            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     244              : 
     245            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     246            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     247              : 
     248            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     249            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     250              : 
     251            2 :     ret = RsUbGetIpByEid(devCb, eid, ip, num);
     252            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("RsUbGetIpByEid failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     253              : 
     254            1 :     return ret;
     255              : }
     256              : 
     257            2 : RS_ATTRI_VISI_DEF int RsGetTpInfoList(struct RaRsDevInfo *devInfo, struct GetTpCfg *cfg,
     258              :     struct HccpTpInfo infoList[], unsigned int *num)
     259              : {
     260            2 :     struct RsUbDevCb *devCb = NULL;
     261            2 :     struct rs_cb *rscb = NULL;
     262            2 :     int ret = 0;
     263              : 
     264            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     265            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(cfg);
     266            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
     267            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     268              : 
     269            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     270            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     271              : 
     272            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     273            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     274              :         ret);
     275            1 :     ret = RsUbGetTpInfoList(devCb, cfg, infoList, num);
     276              : 
     277            1 :     return ret;
     278              : }
     279              : 
     280            5 : RS_ATTRI_VISI_DEF int RsGetTpAttr(struct RaRsDevInfo *devInfo, unsigned int *attrBitmap,
     281              :     const uint64_t tpHandle, struct TpAttr *attr)
     282              : {
     283            5 :     struct RsUbDevCb *devCb = NULL;
     284            5 :     struct rs_cb *rscb = NULL;
     285            5 :     int ret = 0;
     286              : 
     287            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     288            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(attrBitmap);
     289            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     290              : 
     291            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     292            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     293              : 
     294            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     295            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     296            1 :     ret = RsUbGetTpAttr(devCb, attrBitmap, tpHandle, attr);
     297              : 
     298            1 :     return ret;
     299              : }
     300              : 
     301            4 : RS_ATTRI_VISI_DEF int RsSetTpAttr(struct RaRsDevInfo *devInfo, const unsigned int attrBitmap,
     302              :     const uint64_t tpHandle, struct TpAttr *attr)
     303              : {
     304            4 :     struct RsUbDevCb *devCb = NULL;
     305            4 :     struct rs_cb *rscb = NULL;
     306            4 :     int ret = 0;
     307              : 
     308            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     309            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     310              : 
     311            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     312            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     313              : 
     314            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     315            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     316            1 :     ret = RsUbSetTpAttr(devCb, attrBitmap, tpHandle, attr);
     317              : 
     318            1 :     return ret;
     319              : }
     320              : 
     321            1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdAlloc(struct RaRsDevInfo *devInfo, unsigned long long *addr,
     322              :     unsigned int *tokenId)
     323              : {
     324            1 :     struct RsUbDevCb *devCb = NULL;
     325            1 :     struct rs_cb *rscb = NULL;
     326              :     int ret;
     327              : 
     328            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     329            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(addr);
     330            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(tokenId);
     331              : 
     332            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     333            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     334              : 
     335            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     336            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     337              : 
     338            1 :     ret = RsUbCtxTokenIdAlloc(devCb, addr, tokenId);
     339            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_alloc failed, ret:%d, devIndex:0x%x",
     340              :         ret, devInfo->devIndex), ret);
     341              : 
     342            1 :     return ret;
     343              : }
     344              : 
     345            1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdFree(struct RaRsDevInfo *devInfo, unsigned long long addr)
     346              : {
     347            1 :     struct RsUbDevCb *devCb = NULL;
     348            1 :     struct rs_cb *rscb = NULL;
     349              :     int ret;
     350              : 
     351            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     352              : 
     353            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     354            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     355              : 
     356            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     357            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     358              : 
     359            1 :     ret = RsUbCtxTokenIdFree(devCb, addr);
     360            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_free failed, ret:%d, devIndex:0x%x",
     361              :         ret, devInfo->devIndex), ret);
     362              : 
     363            1 :     return ret;
     364              : }
     365              : 
     366            1 : RS_ATTRI_VISI_DEF int RsCtxLmemReg(struct RaRsDevInfo *devInfo, struct MemRegAttrT *memAttr,
     367              :     struct MemRegInfoT *memInfo)
     368              : {
     369            1 :     struct RsUbDevCb *devCb = NULL;
     370            1 :     struct rs_cb *rscb = NULL;
     371              :     int ret;
     372              : 
     373            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     374            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
     375            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
     376              : 
     377            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     378            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     379              : 
     380            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     381            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     382              : 
     383            1 :     ret = RsUbCtxLmemReg(devCb, memAttr, memInfo);
     384            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_reg failed, ret:%d, devIndex:0x%x",
     385              :         ret, devInfo->devIndex), ret);
     386              : 
     387            1 :     return ret;
     388              : }
     389              : 
     390            1 : RS_ATTRI_VISI_DEF int RsCtxLmemUnreg(struct RaRsDevInfo *devInfo, unsigned long long addr)
     391              : {
     392            1 :     struct RsUbDevCb *devCb = NULL;
     393            1 :     struct rs_cb *rscb = NULL;
     394              :     int ret;
     395              : 
     396            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     397              : 
     398            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     399            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     400              : 
     401            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     402            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     403              : 
     404            1 :     ret = RsUbCtxLmemUnreg(devCb, addr);
     405            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_unreg failed, ret:%d devIndex:0x%x",
     406              :         ret, devInfo->devIndex), ret);
     407              : 
     408            1 :     return ret;
     409              : }
     410              : 
     411            1 : RS_ATTRI_VISI_DEF int RsCtxRmemImport(struct RaRsDevInfo *devInfo, struct MemImportAttrT *memAttr,
     412              :     struct MemImportInfoT *memInfo)
     413              : {
     414            1 :     struct RsUbDevCb *devCb = NULL;
     415            1 :     struct rs_cb *rscb = NULL;
     416              :     int ret;
     417              : 
     418            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     419            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
     420            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
     421              : 
     422            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     423            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     424              : 
     425            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     426            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     427              : 
     428            1 :     ret = RsUbCtxRmemImport(devCb, memAttr, memInfo);
     429            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_import failed, ret:%d devIndex:0x%x",
     430              :         ret, devInfo->devIndex), ret);
     431              : 
     432            1 :     return ret;
     433              : }
     434              : 
     435            1 : RS_ATTRI_VISI_DEF int RsCtxRmemUnimport(struct RaRsDevInfo *devInfo, unsigned long long addr)
     436              : {
     437            1 :     struct RsUbDevCb *devCb = NULL;
     438            1 :     struct rs_cb *rscb = NULL;
     439              :     int ret;
     440              : 
     441            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     442              : 
     443            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     444            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     445              : 
     446            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     447            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     448              : 
     449            1 :     ret = RsUbCtxRmemUnimport(devCb, addr);
     450            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_unimport failed, ret:%d devIndex:0x%x",
     451              :         ret, devInfo->devIndex), ret);
     452              : 
     453            1 :     return ret;
     454              : }
     455              : 
     456            1 : RS_ATTRI_VISI_DEF int RsCtxChanCreate(struct RaRsDevInfo *devInfo, union DataPlaneCstmFlag dataPlaneFlag,
     457              :     unsigned long long *addr, int *fd)
     458              : {
     459            1 :     struct RsUbDevCb *devCb = NULL;
     460            1 :     struct rs_cb *rscb = NULL;
     461              :     int ret;
     462              : 
     463            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     464            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(addr);
     465              : 
     466            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     467            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     468              : 
     469            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     470            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     471              : 
     472            1 :     ret = RsUbCtxChanCreate(devCb, dataPlaneFlag, addr, fd);
     473            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_create failed, ret:%d devIndex:0x%x",
     474              :         ret, devInfo->devIndex), ret);
     475              : 
     476            1 :     return ret;
     477              : }
     478              : 
     479            1 : RS_ATTRI_VISI_DEF int RsCtxChanDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
     480              : {
     481            1 :     struct RsUbDevCb *devCb = NULL;
     482            1 :     struct rs_cb *rscb = NULL;
     483              :     int ret;
     484              : 
     485            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     486              : 
     487            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     488            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     489              : 
     490            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     491            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     492              : 
     493            1 :     ret = RsUbCtxChanDestroy(devCb, addr);
     494            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_destroy failed, ret:%d devIndex:0x%x",
     495              :         ret, devInfo->devIndex), ret);
     496              : 
     497            1 :     return ret;
     498              : }
     499              : 
     500            1 : RS_ATTRI_VISI_DEF int RsCtxCqCreate(struct RaRsDevInfo *devInfo, struct CtxCqAttr *attr,
     501              :     struct CtxCqInfo *info)
     502              : {
     503            1 :     struct RsUbDevCb *devCb = NULL;
     504            1 :     struct rs_cb *rscb = NULL;
     505              :     int ret;
     506              : 
     507            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     508            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     509            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(info);
     510              : 
     511            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     512            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     513              : 
     514            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     515            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     516              : 
     517            1 :     ret = RsUbCtxJfcCreate(devCb, attr, info);
     518            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_create failed, ret:%d devIndex:0x%x",
     519              :         ret, devInfo->devIndex), ret);
     520              : 
     521            1 :     return ret;
     522              : }
     523              : 
     524            1 : RS_ATTRI_VISI_DEF int RsCtxCqDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
     525              : {
     526            1 :     struct RsUbDevCb *devCb = NULL;
     527            1 :     struct rs_cb *rscb = NULL;
     528              :     int ret;
     529              : 
     530            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     531              : 
     532            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     533            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     534              : 
     535            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     536            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     537              : 
     538            1 :     ret = RsUbCtxJfcDestroy(devCb, addr);
     539            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_destroy failed, ret:%d devIndex:0x%x",
     540              :         ret, devInfo->devIndex), ret);
     541              : 
     542            1 :     return ret;
     543              : }
     544              : 
     545            1 : RS_ATTRI_VISI_DEF int RsCtxQpCreate(struct RaRsDevInfo *devInfo, struct CtxQpAttr *qpAttr,
     546              :     struct QpCreateInfo *qpInfo)
     547              : {
     548            1 :     struct RsUbDevCb *devCb = NULL;
     549            1 :     struct rs_cb *rscb = NULL;
     550              :     int ret;
     551              : 
     552            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     553            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(qpAttr);
     554            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(qpInfo);
     555              : 
     556            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     557            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     558              : 
     559            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     560            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     561              : 
     562            1 :     ret = RsUbCtxJettyCreate(devCb, qpAttr, qpInfo);
     563            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_create failed, ret:%d devIndex:0x%x",
     564              :         ret, devInfo->devIndex), ret);
     565              : 
     566            1 :     return ret;
     567              : }
     568              : 
     569            1 : RS_ATTRI_VISI_DEF int RsCtxQpDestroy(struct RaRsDevInfo *devInfo, unsigned int id)
     570              : {
     571            1 :     struct RsUbDevCb *devCb = NULL;
     572            1 :     struct rs_cb *rscb = NULL;
     573              :     int ret;
     574              : 
     575            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     576              : 
     577            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     578            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     579              : 
     580            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     581            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     582              : 
     583            1 :     ret = RsUbCtxJettyDestroy(devCb, id);
     584            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_destroy failed, ret:%d devIndex:0x%x",
     585              :         ret, devInfo->devIndex), ret);
     586              : 
     587            1 :     return ret;
     588              : }
     589              : 
     590            1 : RS_ATTRI_VISI_DEF int RsCtxQpImport(struct RaRsDevInfo *devInfo, struct RsJettyImportAttr *importAttr,
     591              :     struct RsJettyImportInfo *importInfo)
     592              : {
     593            1 :     struct RsUbDevCb *devCb = NULL;
     594            1 :     struct rs_cb *rscb = NULL;
     595              :     int ret;
     596              : 
     597            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     598            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(importAttr);
     599            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(importInfo);
     600              : 
     601            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     602            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     603              : 
     604            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     605            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     606              : 
     607            1 :     ret = RsUbCtxJettyImport(devCb, importAttr, importInfo);
     608            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_import failed, ret:%d devIndex:0x%x",
     609              :         ret, devInfo->devIndex), ret);
     610              : 
     611            1 :     return ret;
     612              : }
     613              : 
     614            1 : RS_ATTRI_VISI_DEF int RsCtxQpUnimport(struct RaRsDevInfo *devInfo, unsigned char rawRemJettyId[], unsigned int size)
     615              : {
     616            1 :     struct RsUbDevCb *devCb = NULL;
     617            1 :     struct rs_cb *rscb = NULL;
     618              :     int ret;
     619              : 
     620            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     621              : 
     622            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     623            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     624              : 
     625            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     626            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     627              : 
     628            1 :     ret = RsUbCtxJettyUnimport(devCb, rawRemJettyId, size);
     629            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unimport failed, ret:%d devIndex:0x%x",
     630              :         ret, devInfo->devIndex), ret);
     631              : 
     632            1 :     return ret;
     633              : }
     634              : 
     635            1 : RS_ATTRI_VISI_DEF int RsCtxQpBind(struct RaRsDevInfo *devInfo, struct RsCtxQpInfo *localQpInfo,
     636              :     struct RsCtxQpInfo *remoteQpInfo)
     637              : {
     638            1 :     struct RsUbDevCb *devCb = NULL;
     639            1 :     struct rs_cb *rscb = NULL;
     640              :     int ret;
     641              : 
     642            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     643            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(localQpInfo);
     644            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(remoteQpInfo);
     645              : 
     646            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     647            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     648              : 
     649            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     650            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     651              : 
     652            1 :     ret = RsUbCtxJettyBind(devCb, localQpInfo, remoteQpInfo);
     653            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_bind failed, ret:%d devIndex:0x%x",
     654              :         ret, devInfo->devIndex), ret);
     655              : 
     656            1 :     return ret;
     657              : }
     658              : 
     659            1 : RS_ATTRI_VISI_DEF int RsCtxQpUnbind(struct RaRsDevInfo *devInfo, unsigned int qpId)
     660              : {
     661            1 :     struct RsUbDevCb *devCb = NULL;
     662            1 :     struct rs_cb *rscb = NULL;
     663              :     int ret;
     664              : 
     665            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     666              : 
     667            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     668            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     669              : 
     670            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     671            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     672              : 
     673            1 :     ret = RsUbCtxJettyUnbind(devCb, qpId);
     674            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unbind failed, ret:%d devIndex:0x%x",
     675              :         ret, devInfo->devIndex), ret);
     676              : 
     677            1 :     return ret;
     678              : }
     679              : 
     680            1 : RS_ATTRI_VISI_DEF int RsCtxBatchSendWr(struct WrlistBaseInfo *baseInfo, struct BatchSendWrData *wrData,
     681              :     struct SendWrResp *wrResp, struct WrlistSendCompleteNum *wrlistNum)
     682              : {
     683            1 :     struct rs_cb *rscb = NULL;
     684              :     int ret;
     685              : 
     686            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(baseInfo);
     687            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrData);
     688            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrResp);
     689            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrlistNum);
     690              : 
     691            1 :     ret = RsGetRsCb(baseInfo->phyId, &rscb);
     692            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     693              : 
     694            1 :     switch (rscb->protocol) {
     695            1 :         case PROTOCOL_UDMA:
     696            1 :             ret = RsUbCtxBatchSendWr(rscb, baseInfo, wrData, wrResp, wrlistNum);
     697            1 :             break;
     698            0 :         default:
     699            0 :             hccp_err("protocol[%d] not support", rscb->protocol);
     700            0 :             return -EINVAL;
     701              :     }
     702            1 :     return ret;
     703              : }
     704              : 
     705            1 : RS_ATTRI_VISI_DEF int RsCtxUpdateCi(struct RaRsDevInfo *devInfo, unsigned int qpId, uint16_t ci)
     706              : {
     707            1 :     struct RsUbDevCb *devCb = NULL;
     708            1 :     struct rs_cb *rscb = NULL;
     709              :     int ret;
     710              : 
     711            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     712              : 
     713            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     714            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     715              : 
     716            1 :     switch (rscb->protocol) {
     717            1 :         case PROTOCOL_UDMA:
     718            1 :             ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     719            1 :             CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     720              :                 ret);
     721            1 :             ret = RsUbCtxJettyUpdateCi(devCb, qpId, ci);
     722            1 :             break;
     723            0 :         default:
     724            0 :             hccp_err("protocol[%d] not support", rscb->protocol);
     725            0 :             return -EINVAL;
     726              :     }
     727            1 :     return ret;
     728              : }
     729              : 
     730            5 : RS_ATTRI_VISI_DEF int RsCtxQpDestroyBatch(struct RaRsDevInfo *devInfo, unsigned int ids[], unsigned int *num)
     731              : {
     732            5 :     struct RsUbDevCb *devCb = NULL;
     733            5 :     struct rs_cb *rscb = NULL;
     734              :     int ret;
     735              : 
     736            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     737            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(ids);
     738            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     739              : 
     740            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     741            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     742              : 
     743            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     744            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     745            1 :     ret = RsUbCtxJettyDestroyBatch(devCb, ids, num);
     746              : 
     747            1 :     return ret;
     748              : }
     749              : 
     750            6 : RS_ATTRI_VISI_DEF int RsCtxQpQueryBatch(struct RaRsDevInfo *devInfo, unsigned int ids[],
     751              :     struct JettyAttr attr[], unsigned int *num)
     752              : {
     753            6 :     struct RsUbDevCb *devCb = NULL;
     754            6 :     struct rs_cb *rscb = NULL;
     755              :     int ret;
     756              : 
     757            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     758            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(ids);
     759            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     760            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     761              : 
     762            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     763            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     764              : 
     765            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     766            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     767            1 :     ret = RsUbCtxQueryJettyBatch(devCb, ids, attr, num);
     768              : 
     769            1 :     return ret;
     770              : }
     771              : 
     772            7 : RS_ATTRI_VISI_DEF int RsCtxGetAuxInfo(struct RaRsDevInfo *devInfo, struct HccpAuxInfoIn *infoIn,
     773              :     struct HccpAuxInfoOut *infoOut)
     774              : {
     775            7 :     struct RsUbDevCb *devCb = NULL;
     776            7 :     struct rs_cb *rscb = NULL;
     777              :     int ret;
     778              : 
     779            7 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     780            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoIn);
     781            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoOut);
     782              : 
     783            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     784            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     785              : 
     786            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     787            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     788              : 
     789            2 :     ret = RsUbCtxGetAuxInfo(devCb, infoIn, infoOut);
     790            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_get_aux_info failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     791              :         ret);
     792              : 
     793            1 :     return ret;
     794              : }
     795              : 
     796            7 : RS_ATTRI_VISI_DEF int RsCtxGetCrErrInfoList(struct RaRsDevInfo *devInfo, struct CrErrInfo infoList[],
     797              :     unsigned int *num)
     798              : {
     799            7 :     struct RsCtxJettyCb *jettyCbCurr = NULL;
     800            7 :     struct RsCtxJettyCb *jettyCbNext = NULL;
     801            7 :     struct RsUbDevCb *devCb = NULL;
     802            7 :     unsigned int crErrIdx = 0;
     803            7 :     struct rs_cb *rscb = NULL;
     804            7 :     unsigned int numTmp = 0;
     805            7 :     int ret = 0;
     806              : 
     807            7 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     808            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
     809            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     810              : 
     811            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     812            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     813              : 
     814            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     815            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     816              : 
     817            2 :     if (RsListEmpty(&devCb->jettyList)) {
     818            1 :         *num = 0;
     819            1 :         return ret;
     820              :     }
     821              : 
     822            1 :     numTmp = *num;
     823            1 :     RS_LIST_GET_HEAD_ENTRY(jettyCbCurr, jettyCbNext, &devCb->jettyList, list, struct RsCtxJettyCb);
     824            2 :     for (; (&jettyCbCurr->list) != &devCb->jettyList; jettyCbCurr = jettyCbNext,
     825            1 :         jettyCbNext = list_entry(jettyCbNext->list.next, struct RsCtxJettyCb, list)) {
     826            1 :         if (jettyCbCurr->crErrInfo.info.status != 0) {
     827            1 :             RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->crErrInfo.mutex);
     828            1 :             infoList[crErrIdx].status = jettyCbCurr->crErrInfo.info.status;
     829            1 :             infoList[crErrIdx].jettyId = jettyCbCurr->crErrInfo.info.jettyId;
     830            1 :             infoList[crErrIdx].time = jettyCbCurr->crErrInfo.info.time;
     831            1 :             jettyCbCurr->crErrInfo.info.status = 0;
     832            1 :             RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->crErrInfo.mutex);
     833            1 :             RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
     834            1 :             jettyCbCurr->devCb->cqeErrCnt--;
     835            1 :             RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
     836            1 :             crErrIdx++;
     837            1 :             if (crErrIdx == numTmp) {
     838            0 :                 break;
     839              :             }
     840              :         }
     841              :     }
     842              : 
     843            1 :     *num = crErrIdx;
     844            1 :     return ret;
     845              : }
     846              : 
     847            0 : RS_ATTRI_VISI_DEF int RsCtxGetUbContext(struct RaRsDevInfo *devInfo, unsigned int id, unsigned int contextType,
     848              :     uint8_t context[], unsigned int *len)
     849              : {
     850            0 :     struct RsUbDevCb *devCb = NULL;
     851            0 :     struct rs_cb *rscb = NULL;
     852            0 :     int ret = 0;
     853              : 
     854            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     855            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(context);
     856            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(len);
     857            0 :     CHK_PRT_RETURN(*len < CONTEXT_MAX_LEN, hccp_err("len:%u less than %u", *len, CONTEXT_MAX_LEN), -EINVAL);
     858              : 
     859            0 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     860            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     861              : 
     862            0 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     863            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get devCb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     864              : 
     865            0 :     if (contextType == CONTEXT_TYPE_JETTY) {
     866            0 :         ret = RsUbGetJettyContext(devCb, id, context, len);
     867              :     } else {
     868            0 :         hccp_err("invalid contextType:%u, devIndex:0x%x", contextType, devInfo->devIndex);
     869            0 :         ret = -EINVAL;
     870              :     }
     871              : 
     872            0 :     return ret;
     873              : }
        

Generated by: LCOV version 2.0-1