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: 80.5 % 476 383
Test Date: 2026-07-28 12:11:00 Functions: 85.7 % 35 30

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "securec.h"
      12              : #include "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            2 : RS_ATTRI_VISI_DEF int RsGetTpInfoList(struct RaRsDevInfo *devInfo, struct GetTpCfg *cfg,
     234              :     struct HccpTpInfo infoList[], unsigned int *num)
     235              : {
     236            2 :     struct RsUbDevCb *devCb = NULL;
     237            2 :     struct rs_cb *rscb = NULL;
     238            2 :     int ret = 0;
     239              : 
     240            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     241            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(cfg);
     242            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
     243            2 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     244              : 
     245            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     246            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     247              : 
     248            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     249            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     250              :         ret);
     251            1 :     ret = RsUbGetTpInfoList(devCb, cfg, infoList, num);
     252              : 
     253            1 :     return ret;
     254              : }
     255              : 
     256            5 : RS_ATTRI_VISI_DEF int RsGetTpAttr(struct RaRsDevInfo *devInfo, unsigned int *attrBitmap,
     257              :     const uint64_t tpHandle, struct TpAttr *attr)
     258              : {
     259            5 :     struct RsUbDevCb *devCb = NULL;
     260            5 :     struct rs_cb *rscb = NULL;
     261            5 :     int ret = 0;
     262              : 
     263            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     264            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(attrBitmap);
     265            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     266              : 
     267            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     268            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     269              : 
     270            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     271            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     272            1 :     ret = RsUbGetTpAttr(devCb, attrBitmap, tpHandle, attr);
     273              : 
     274            1 :     return ret;
     275              : }
     276              : 
     277            4 : RS_ATTRI_VISI_DEF int RsSetTpAttr(struct RaRsDevInfo *devInfo, const unsigned int attrBitmap,
     278              :     const uint64_t tpHandle, struct TpAttr *attr)
     279              : {
     280            4 :     struct RsUbDevCb *devCb = NULL;
     281            4 :     struct rs_cb *rscb = NULL;
     282            4 :     int ret = 0;
     283              : 
     284            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     285            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     286              : 
     287            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     288            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     289              : 
     290            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     291            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     292            1 :     ret = RsUbSetTpAttr(devCb, attrBitmap, tpHandle, attr);
     293              : 
     294            1 :     return ret;
     295              : }
     296              : 
     297            1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdAlloc(struct RaRsDevInfo *devInfo, unsigned long long *addr,
     298              :     unsigned int *tokenId)
     299              : {
     300            1 :     struct RsUbDevCb *devCb = NULL;
     301            1 :     struct rs_cb *rscb = NULL;
     302              :     int ret;
     303              : 
     304            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     305            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(addr);
     306            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(tokenId);
     307              : 
     308            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     309            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     310              : 
     311            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     312            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     313              : 
     314            1 :     ret = RsUbCtxTokenIdAlloc(devCb, addr, tokenId);
     315            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_alloc failed, ret:%d, devIndex:0x%x",
     316              :         devInfo->devIndex, ret), ret);
     317              : 
     318            1 :     return ret;
     319              : }
     320              : 
     321            1 : RS_ATTRI_VISI_DEF int RsCtxTokenIdFree(struct RaRsDevInfo *devInfo, unsigned long long addr)
     322              : {
     323            1 :     struct RsUbDevCb *devCb = NULL;
     324            1 :     struct rs_cb *rscb = NULL;
     325              :     int ret;
     326              : 
     327            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     328              : 
     329            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     330            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     331              : 
     332            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     333            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     334              : 
     335            1 :     ret = RsUbCtxTokenIdFree(devCb, addr);
     336            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_token_id_free failed, ret:%d, devIndex:0x%x",
     337              :         devInfo->devIndex, ret), ret);
     338              : 
     339            1 :     return ret;
     340              : }
     341              : 
     342            1 : RS_ATTRI_VISI_DEF int RsCtxLmemReg(struct RaRsDevInfo *devInfo, struct MemRegAttrT *memAttr,
     343              :     struct MemRegInfoT *memInfo)
     344              : {
     345            1 :     struct RsUbDevCb *devCb = NULL;
     346            1 :     struct rs_cb *rscb = NULL;
     347              :     int ret;
     348              : 
     349            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     350            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
     351            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
     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 = RsUbCtxLmemReg(devCb, memAttr, memInfo);
     360            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_reg failed, ret:%d, devIndex:0x%x",
     361              :         devInfo->devIndex, ret), ret);
     362              : 
     363            1 :     return ret;
     364              : }
     365              : 
     366            1 : RS_ATTRI_VISI_DEF int RsCtxLmemUnreg(struct RaRsDevInfo *devInfo, unsigned long long addr)
     367              : {
     368            1 :     struct RsUbDevCb *devCb = NULL;
     369            1 :     struct rs_cb *rscb = NULL;
     370              :     int ret;
     371              : 
     372            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     373              : 
     374            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     375            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     376              : 
     377            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     378            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     379              : 
     380            1 :     ret = RsUbCtxLmemUnreg(devCb, addr);
     381            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_lmem_unreg failed, ret:%d devIndex:0x%x",
     382              :         ret, devInfo->devIndex), ret);
     383              : 
     384            1 :     return ret;
     385              : }
     386              : 
     387            1 : RS_ATTRI_VISI_DEF int RsCtxRmemImport(struct RaRsDevInfo *devInfo, struct MemImportAttrT *memAttr,
     388              :     struct MemImportInfoT *memInfo)
     389              : {
     390            1 :     struct RsUbDevCb *devCb = NULL;
     391            1 :     struct rs_cb *rscb = NULL;
     392              :     int ret;
     393              : 
     394            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     395            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memAttr);
     396            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(memInfo);
     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 = RsUbCtxRmemImport(devCb, memAttr, memInfo);
     405            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_import 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 RsCtxRmemUnimport(struct RaRsDevInfo *devInfo, unsigned long long addr)
     412              : {
     413            1 :     struct RsUbDevCb *devCb = NULL;
     414            1 :     struct rs_cb *rscb = NULL;
     415              :     int ret;
     416              : 
     417            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     418              : 
     419            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     420            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     421              : 
     422            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     423            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     424              : 
     425            1 :     ret = RsUbCtxRmemUnimport(devCb, addr);
     426            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_rmem_unimport failed, ret:%d devIndex:0x%x",
     427              :         ret, devInfo->devIndex), ret);
     428              : 
     429            1 :     return ret;
     430              : }
     431              : 
     432            1 : RS_ATTRI_VISI_DEF int RsCtxChanCreate(struct RaRsDevInfo *devInfo, union DataPlaneCstmFlag dataPlaneFlag,
     433              :     unsigned long long *addr, int *fd)
     434              : {
     435            1 :     struct RsUbDevCb *devCb = NULL;
     436            1 :     struct rs_cb *rscb = NULL;
     437              :     int ret;
     438              : 
     439            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     440            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(addr);
     441              : 
     442            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     443            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     444              : 
     445            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     446            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     447              : 
     448            1 :     ret = RsUbCtxChanCreate(devCb, dataPlaneFlag, addr, fd);
     449            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_create failed, ret:%d devIndex:0x%x",
     450              :         ret, devInfo->devIndex), ret);
     451              : 
     452            1 :     return ret;
     453              : }
     454              : 
     455            1 : RS_ATTRI_VISI_DEF int RsCtxChanDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
     456              : {
     457            1 :     struct RsUbDevCb *devCb = NULL;
     458            1 :     struct rs_cb *rscb = NULL;
     459              :     int ret;
     460              : 
     461            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     462              : 
     463            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     464            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     465              : 
     466            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     467            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     468              : 
     469            1 :     ret = RsUbCtxChanDestroy(devCb, addr);
     470            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_chan_destroy failed, ret:%d devIndex:0x%x",
     471              :         ret, devInfo->devIndex), ret);
     472              : 
     473            1 :     return ret;
     474              : }
     475              : 
     476            1 : RS_ATTRI_VISI_DEF int RsCtxCqCreate(struct RaRsDevInfo *devInfo, struct CtxCqAttr *attr,
     477              :     struct CtxCqInfo *info)
     478              : {
     479            1 :     struct RsUbDevCb *devCb = NULL;
     480            1 :     struct rs_cb *rscb = NULL;
     481              :     int ret;
     482              : 
     483            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     484            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     485            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(info);
     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 = RsUbCtxJfcCreate(devCb, attr, info);
     494            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_create 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 RsCtxCqDestroy(struct RaRsDevInfo *devInfo, unsigned long long addr)
     501              : {
     502            1 :     struct RsUbDevCb *devCb = NULL;
     503            1 :     struct rs_cb *rscb = NULL;
     504              :     int ret;
     505              : 
     506            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     507              : 
     508            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     509            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     510              : 
     511            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     512            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     513              : 
     514            1 :     ret = RsUbCtxJfcDestroy(devCb, addr);
     515            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jfc_destroy failed, ret:%d devIndex:0x%x",
     516              :         ret, devInfo->devIndex), ret);
     517              : 
     518            1 :     return ret;
     519              : }
     520              : 
     521            1 : RS_ATTRI_VISI_DEF int RsCtxQpCreate(struct RaRsDevInfo *devInfo, struct CtxQpAttr *qpAttr,
     522              :     struct QpCreateInfo *qpInfo)
     523              : {
     524            1 :     struct RsUbDevCb *devCb = NULL;
     525            1 :     struct rs_cb *rscb = NULL;
     526              :     int ret;
     527              : 
     528            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     529            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(qpAttr);
     530            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(qpInfo);
     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 = RsUbCtxJettyCreate(devCb, qpAttr, qpInfo);
     539            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_create 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 RsCtxQpDestroy(struct RaRsDevInfo *devInfo, unsigned int id)
     546              : {
     547            1 :     struct RsUbDevCb *devCb = NULL;
     548            1 :     struct rs_cb *rscb = NULL;
     549              :     int ret;
     550              : 
     551            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     552              : 
     553            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     554            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     555              : 
     556            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     557            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     558              : 
     559            1 :     ret = RsUbCtxJettyDestroy(devCb, id);
     560            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_destroy failed, ret:%d devIndex:0x%x",
     561              :         ret, devInfo->devIndex), ret);
     562              : 
     563            1 :     return ret;
     564              : }
     565              : 
     566            1 : RS_ATTRI_VISI_DEF int RsCtxQpImport(struct RaRsDevInfo *devInfo, struct RsJettyImportAttr *importAttr,
     567              :     struct RsJettyImportInfo *importInfo)
     568              : {
     569            1 :     struct RsUbDevCb *devCb = NULL;
     570            1 :     struct rs_cb *rscb = NULL;
     571              :     int ret;
     572              : 
     573            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     574            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(importAttr);
     575            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(importInfo);
     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 = RsUbCtxJettyImport(devCb, importAttr, importInfo);
     584            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_import 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 RsCtxQpUnimport(struct RaRsDevInfo *devInfo, unsigned int remJettyId)
     591              : {
     592            1 :     struct RsUbDevCb *devCb = NULL;
     593            1 :     struct rs_cb *rscb = NULL;
     594              :     int ret;
     595              : 
     596            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     597              : 
     598            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     599            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     600              : 
     601            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     602            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     603              : 
     604            1 :     ret = RsUbCtxJettyUnimport(devCb, remJettyId);
     605            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unimport failed, ret:%d devIndex:0x%x",
     606              :         ret, devInfo->devIndex), ret);
     607              : 
     608            1 :     return ret;
     609              : }
     610              : 
     611            1 : RS_ATTRI_VISI_DEF int RsCtxQpBind(struct RaRsDevInfo *devInfo, struct RsCtxQpInfo *localQpInfo,
     612              :     struct RsCtxQpInfo *remoteQpInfo)
     613              : {
     614            1 :     struct RsUbDevCb *devCb = NULL;
     615            1 :     struct rs_cb *rscb = NULL;
     616              :     int ret;
     617              : 
     618            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     619            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(localQpInfo);
     620            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(remoteQpInfo);
     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 = RsUbCtxJettyBind(devCb, localQpInfo, remoteQpInfo);
     629            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_bind 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 RsCtxQpUnbind(struct RaRsDevInfo *devInfo, unsigned int qpId)
     636              : {
     637            1 :     struct RsUbDevCb *devCb = NULL;
     638            1 :     struct rs_cb *rscb = NULL;
     639              :     int ret;
     640              : 
     641            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     642              : 
     643            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     644            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     645              : 
     646            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     647            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     648              : 
     649            1 :     ret = RsUbCtxJettyUnbind(devCb, qpId);
     650            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_jetty_unbind failed, ret:%d devIndex:0x%x",
     651              :         ret, devInfo->devIndex), ret);
     652              : 
     653            1 :     return ret;
     654              : }
     655              : 
     656            1 : RS_ATTRI_VISI_DEF int RsCtxBatchSendWr(struct WrlistBaseInfo *baseInfo, struct BatchSendWrData *wrData,
     657              :     struct SendWrResp *wrResp, struct WrlistSendCompleteNum *wrlistNum)
     658              : {
     659            1 :     struct rs_cb *rscb = NULL;
     660              :     int ret;
     661              : 
     662            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(baseInfo);
     663            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrData);
     664            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrResp);
     665            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(wrlistNum);
     666              : 
     667            1 :     ret = RsGetRsCb(baseInfo->phyId, &rscb);
     668            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     669              : 
     670            1 :     switch (rscb->protocol) {
     671            1 :         case PROTOCOL_UDMA:
     672            1 :             ret = RsUbCtxBatchSendWr(rscb, baseInfo, wrData, wrResp, wrlistNum);
     673            1 :             break;
     674            0 :         default:
     675            0 :             hccp_err("protocol[%d] not support", rscb->protocol);
     676            0 :             return -EINVAL;
     677              :     }
     678            1 :     return ret;
     679              : }
     680              : 
     681            1 : RS_ATTRI_VISI_DEF int RsCtxUpdateCi(struct RaRsDevInfo *devInfo, unsigned int qpId, uint16_t ci)
     682              : {
     683            1 :     struct RsUbDevCb *devCb = NULL;
     684            1 :     struct rs_cb *rscb = NULL;
     685              :     int ret;
     686              : 
     687            1 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     688              : 
     689            1 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     690            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     691              : 
     692            1 :     switch (rscb->protocol) {
     693            1 :         case PROTOCOL_UDMA:
     694            1 :             ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     695            1 :             CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     696              :                 ret);
     697            1 :             ret = RsUbCtxJettyUpdateCi(devCb, qpId, ci);
     698            1 :             break;
     699            0 :         default:
     700            0 :             hccp_err("protocol[%d] not support", rscb->protocol);
     701            0 :             return -EINVAL;
     702              :     }
     703            1 :     return ret;
     704              : }
     705              : 
     706            5 : RS_ATTRI_VISI_DEF int RsCtxQpDestroyBatch(struct RaRsDevInfo *devInfo, unsigned int ids[], unsigned int *num)
     707              : {
     708            5 :     struct RsUbDevCb *devCb = NULL;
     709            5 :     struct rs_cb *rscb = NULL;
     710              :     int ret;
     711              : 
     712            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     713            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(ids);
     714            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     715              : 
     716            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     717            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     718              : 
     719            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     720            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     721            1 :     ret = RsUbCtxJettyDestroyBatch(devCb, ids, num);
     722              : 
     723            1 :     return ret;
     724              : }
     725              : 
     726            6 : RS_ATTRI_VISI_DEF int RsCtxQpQueryBatch(struct RaRsDevInfo *devInfo, unsigned int ids[],
     727              :     struct JettyAttr attr[], unsigned int *num)
     728              : {
     729            6 :     struct RsUbDevCb *devCb = NULL;
     730            6 :     struct rs_cb *rscb = NULL;
     731              :     int ret;
     732              : 
     733            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     734            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(ids);
     735            4 :     RS_CHECK_POINTER_NULL_RETURN_INT(attr);
     736            3 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     737              : 
     738            2 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     739            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     740              : 
     741            1 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     742            1 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     743            1 :     ret = RsUbCtxQueryJettyBatch(devCb, ids, attr, num);
     744              : 
     745            1 :     return ret;
     746              : }
     747              : 
     748            7 : RS_ATTRI_VISI_DEF int RsCtxGetAuxInfo(struct RaRsDevInfo *devInfo, struct HccpAuxInfoIn *infoIn,
     749              :     struct HccpAuxInfoOut *infoOut)
     750              : {
     751            7 :     struct RsUbDevCb *devCb = NULL;
     752            7 :     struct rs_cb *rscb = NULL;
     753              :     int ret;
     754              : 
     755            7 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     756            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoIn);
     757            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoOut);
     758              : 
     759            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     760            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     761              : 
     762            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     763            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     764              : 
     765            2 :     ret = RsUbCtxGetAuxInfo(devCb, infoIn, infoOut);
     766            2 :     CHK_PRT_RETURN(ret != 0, hccp_err("rs_ub_ctx_get_aux_info failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex),
     767              :         ret);
     768              : 
     769            1 :     return ret;
     770              : }
     771              : 
     772            7 : RS_ATTRI_VISI_DEF int RsCtxGetCrErrInfoList(struct RaRsDevInfo *devInfo, struct CrErrInfo infoList[],
     773              :     unsigned int *num)
     774              : {
     775            7 :     struct RsCtxJettyCb *jettyCbCurr = NULL;
     776            7 :     struct RsCtxJettyCb *jettyCbNext = NULL;
     777            7 :     struct RsUbDevCb *devCb = NULL;
     778            7 :     unsigned int crErrIdx = 0;
     779            7 :     struct rs_cb *rscb = NULL;
     780            7 :     unsigned int numTmp = 0;
     781            7 :     int ret = 0;
     782              : 
     783            7 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     784            6 :     RS_CHECK_POINTER_NULL_RETURN_INT(infoList);
     785            5 :     RS_CHECK_POINTER_NULL_RETURN_INT(num);
     786              : 
     787            4 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     788            4 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     789              : 
     790            3 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     791            3 :     CHK_PRT_RETURN(ret != 0, hccp_err("get dev_cb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     792              : 
     793            2 :     if (RsListEmpty(&devCb->jettyList)) {
     794            1 :         *num = 0;
     795            1 :         return ret;
     796              :     }
     797              : 
     798            1 :     numTmp = *num;
     799            1 :     RS_LIST_GET_HEAD_ENTRY(jettyCbCurr, jettyCbNext, &devCb->jettyList, list, struct RsCtxJettyCb);
     800            2 :     for (; (&jettyCbCurr->list) != &devCb->jettyList; jettyCbCurr = jettyCbNext,
     801            1 :         jettyCbNext = list_entry(jettyCbNext->list.next, struct RsCtxJettyCb, list)) {
     802            1 :         if (jettyCbCurr->crErrInfo.info.status != 0) {
     803            1 :             RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->crErrInfo.mutex);
     804            1 :             infoList[crErrIdx].status = jettyCbCurr->crErrInfo.info.status;
     805            1 :             infoList[crErrIdx].jettyId = jettyCbCurr->crErrInfo.info.jettyId;
     806            1 :             infoList[crErrIdx].time = jettyCbCurr->crErrInfo.info.time;
     807            1 :             jettyCbCurr->crErrInfo.info.status = 0;
     808            1 :             RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->crErrInfo.mutex);
     809            1 :             RS_PTHREAD_MUTEX_LOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
     810            1 :             jettyCbCurr->devCb->cqeErrCnt--;
     811            1 :             RS_PTHREAD_MUTEX_ULOCK(&jettyCbCurr->devCb->cqeErrCntMutex);
     812            1 :             crErrIdx++;
     813            1 :             if (crErrIdx == numTmp) {
     814            0 :                 break;
     815              :             }
     816              :         }
     817              :     }
     818              : 
     819            1 :     *num = crErrIdx;
     820            1 :     return ret;
     821              : }
     822              : 
     823            0 : RS_ATTRI_VISI_DEF int RsCtxGetUbContext(struct RaRsDevInfo *devInfo, unsigned int id, unsigned int contextType,
     824              :     uint8_t context[], unsigned int *len)
     825              : {
     826            0 :     struct RsUbDevCb *devCb = NULL;
     827            0 :     struct rs_cb *rscb = NULL;
     828            0 :     int ret = 0;
     829              : 
     830            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(devInfo);
     831            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(context);
     832            0 :     RS_CHECK_POINTER_NULL_RETURN_INT(len);
     833            0 :     CHK_PRT_RETURN(*len < CONTEXT_MAX_LEN, hccp_err("len:%u less than %u", *len, CONTEXT_MAX_LEN), -EINVAL);
     834              : 
     835            0 :     ret = RsGetRsCb(devInfo->phyId, &rscb);
     836            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get rscb failed, ret:%d", ret), ret);
     837              : 
     838            0 :     ret = RsUbGetDevCb(rscb, devInfo->devIndex, &devCb);
     839            0 :     CHK_PRT_RETURN(ret != 0, hccp_err("get devCb failed, ret:%d devIndex:0x%x", ret, devInfo->devIndex), ret);
     840              : 
     841            0 :     if (contextType == CONTEXT_TYPE_JETTY) {
     842            0 :         ret = RsUbGetJettyContext(devCb, id, context, len);
     843              :     } else {
     844            0 :         hccp_err("invalid contextType:%u, devIndex:0x%x", contextType, devInfo->devIndex);
     845            0 :         ret = -EINVAL;
     846              :     }
     847              : 
     848            0 :     return ret;
     849              : }
        

Generated by: LCOV version 2.0-1