LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_service/ctx - rs_ctx_inner.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 66.7 % 6 4
Test Date: 2026-08-18 17:47:01 Functions: 66.7 % 3 2

            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              : #ifndef RS_CTX_INNER_H
      12              : #define RS_CTX_INNER_H
      13              : 
      14              : #include <pthread.h>
      15              : #include <urma_types.h>
      16              : #include "hccp_ctx.h"
      17              : #include "rs_inner.h"
      18              : #include "rs_list.h"
      19              : 
      20              : #define DEV_INDEX_DIEID_OFFSET 8U
      21              : #define DEV_INDEX_CNT_OFFSET 16U
      22              : #define DEV_INDEX_UE_INFO_MASK 0x0000FFFFUL
      23              : #define CI_ADDR_BUFFER_ALIGN_4K_PAGE_SIZE 4096U
      24              : #define WQE_BB_SIZE 64ULL
      25              : #define UB_ID_OFFSET 16U
      26              : 
      27              : struct RsUbDevCb {
      28              :     struct rs_cb *rscb;
      29              :     unsigned int phyId;
      30              :     unsigned int eidIndex;
      31              :     union HccpEid eid;
      32              :     urma_context_t *urmaCtx;
      33              :     urma_device_t *urmaDev;
      34              :     unsigned int index;
      35              :     struct DevBaseAttr devAttr;
      36              : 
      37              :     unsigned int cqeErrCnt;
      38              :     pthread_mutex_t cqeErrCntMutex;
      39              : 
      40              :     pthread_mutex_t mutex;
      41              :     unsigned int asyncEventCnt;
      42              :     unsigned int jfceCnt;
      43              :     unsigned int jfcCnt;
      44              :     unsigned int jettyCnt;
      45              :     unsigned int rjettyCnt;
      46              :     unsigned int tokenIdCnt;
      47              :     unsigned int lsegCnt;
      48              :     unsigned int rsegCnt;
      49              :     struct RsListHead asyncEventList;
      50              :     struct RsListHead jfceList;
      51              :     struct RsListHead jfcList;
      52              :     struct RsListHead jettyList;
      53              :     struct RsListHead rjettyList;
      54              :     struct RsListHead tokenIdList;
      55              :     struct RsListHead lsegList;
      56              :     struct RsListHead rsegList;
      57              :     struct RsListHead list;
      58              : 
      59              :     urma_jfc_t *shareJfc;
      60              :     urma_jfr_t *shareJfr;
      61              : };
      62              : 
      63              : struct RsCtxAsyncEventCb {
      64              :     struct RsUbDevCb *devCb;
      65              :     urma_async_event_t asyncEvent;
      66              :     unsigned int resId;
      67              :     unsigned int len;
      68              :     char context[CONTEXT_MAX_LEN];
      69              :     struct RsListHead list;
      70              : };
      71              : 
      72              : struct RsCtxJfceCb {
      73              :     struct RsUbDevCb *devCb;
      74              :     uint64_t jfceAddr; // urma_jfce_t *
      75              :     union DataPlaneCstmFlag dataPlaneFlag;
      76              :     struct RsListHead list;
      77              : };
      78              : 
      79              : struct RsCtxJfcCb {
      80              :     struct RsUbDevCb *devCb;
      81              :     uint64_t jfcAddr;
      82              :     enum JfcMode jfcType;
      83              :     uint32_t depth;
      84              :     uint32_t jfcId;
      85              :     uint64_t bufAddr;
      86              :     uint64_t swdbAddr;
      87              :     struct RsListHead list;
      88              :     struct {
      89              :         bool valid;
      90              :         uint32_t cqeFlag;
      91              :     } ccuExCfg;
      92              : };
      93              : 
      94              : struct RsCrErrInfo {
      95              :     pthread_mutex_t mutex;
      96              :     struct CrErrInfo info;
      97              : };
      98              : 
      99              : struct RsCtxJettyCb {
     100              :     struct RsUbDevCb *devCb;
     101              :     urma_jetty_t *jetty;
     102              :     int jettyMode;
     103              :     uint32_t jettyId;
     104              :     int transportMode;
     105              :     unsigned int state;
     106              :     unsigned int txDepth;
     107              :     unsigned int rxDepth;
     108              :     urma_jetty_flag_t flag;
     109              :     urma_jfs_flag_t jfsFlag;
     110              :     uint64_t tokenIdAddr; /**< NULL means unspecified */
     111              :     unsigned int tokenValue;
     112              :     uint8_t priority;
     113              :     uint8_t rnrRetry;
     114              :     uint8_t errTimeout;
     115              :     union {
     116              :         struct {
     117              :             struct JettyQueCfgEx sq;
     118              :             bool piType;
     119              :             union CstmJfsFlag cstmFlag;
     120              :             uint32_t sqebbNum;
     121              :         } extMode;
     122              :         struct {
     123              :             bool lockFlag;
     124              :             uint32_t sqeBufIdx;
     125              :         } taCacheMode;
     126              :     };
     127              :     uint64_t sqBuffVa;
     128              :     uint64_t dbAddr;
     129              :     uint32_t dbTokenId;
     130              :     uint64_t dbSegHandle;
     131              :     pthread_mutex_t mutex;
     132              :     uint32_t lastPi;
     133              :     struct CtxQpShareInfo *qpShareInfoAddr;
     134              :     struct RsCrErrInfo crErrInfo;
     135              :     struct RsListHead list;
     136              :     uint64_t scqIndex;
     137              :     uint64_t rcqIndex;
     138              : };
     139              : 
     140              : struct RsTokenIdCb {
     141              :     struct RsUbDevCb *devCb;
     142              :     urma_token_id_t *tokenId;
     143              :     struct RsListHead list;
     144              : };
     145              : 
     146              : struct RsCtxRemJettyCb {
     147              :     struct RsUbDevCb *devCb;
     148              :     urma_target_jetty_t *tjetty;
     149              :     struct QpKey jettyKey;
     150              :     enum JettyImportMode mode;
     151              :     unsigned int tokenValue;
     152              :     enum JettyGrpPolicy policy;
     153              :     enum TargetType type;
     154              :     union ImportJettyFlag flag;
     155              :     uint32_t tpType;
     156              :     struct JettyImportExpCfg expImportCfg;
     157              :     unsigned int state;
     158              :     struct RsListHead list;
     159              : };
     160              : 
     161              : struct RsSegInfo {
     162              :     uint64_t addr;
     163              :     uint64_t len;
     164              :     urma_seg_t seg;
     165              : };
     166              : 
     167              : struct RsSegCb {
     168              :     struct RsUbDevCb *devCb;
     169              : 
     170              :     struct RsSegInfo segInfo;
     171              :     uint32_t state;
     172              : 
     173              :     urma_token_t tokenValue;
     174              :     urma_target_seg_t *segment;
     175              : 
     176              :     struct RsListHead list;
     177              : };
     178              : 
     179              : struct UdmaVaInfo {
     180              :     enum res_addr_type resType;
     181              :     int pid;
     182              :     uint64_t va;
     183              :     uint64_t len;
     184              : };
     185              : 
     186            3 : STATIC inline uint32_t RsGenerateUeInfo(uint32_t dieId, uint32_t funcId)
     187              : {
     188            3 :     return (dieId << DEV_INDEX_DIEID_OFFSET) | funcId;
     189              : }
     190              : 
     191            1 : STATIC inline uint32_t RsGenerateDevIndex(uint32_t devCnt, uint32_t dieId, uint32_t funcId)
     192              : {
     193            1 :     return (devCnt << DEV_INDEX_CNT_OFFSET) | RsGenerateUeInfo(dieId, funcId);
     194              : }
     195              : 
     196            0 : STATIC inline uint32_t RsGenerateMmapResId(uint32_t id, uint32_t dieId, uint32_t funcId)
     197              : {
     198            0 :     return (id << UB_ID_OFFSET) | RsGenerateUeInfo(dieId, funcId);
     199              : }
     200              : 
     201              : #endif // RS_CTX_INNER_H
        

Generated by: LCOV version 2.0-1