LCOV - code coverage report
Current view: top level - drivers/net/bnxt - bnxt_ring.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 39 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 60 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2014-2023 Broadcom
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef _BNXT_RING_H_
       7                 :            : #define _BNXT_RING_H_
       8                 :            : 
       9                 :            : #include <inttypes.h>
      10                 :            : 
      11                 :            : #include <rte_memory.h>
      12                 :            : 
      13                 :            : #define RING_ADV(idx, n)                ((idx) + (n))
      14                 :            : #define RING_NEXT(idx)                  RING_ADV(idx, 1)
      15                 :            : #define RING_IDX(ring, idx)             ((idx) & (ring)->ring_mask)
      16                 :            : 
      17                 :            : #define DB_IDX_MASK                                             0xffffff
      18                 :            : #define DB_IDX_VALID                                            (0x1 << 26)
      19                 :            : #define DB_IRQ_DIS                                              (0x1 << 27)
      20                 :            : #define DB_KEY_TX                                               (0x0 << 28)
      21                 :            : #define DB_KEY_RX                                               (0x1 << 28)
      22                 :            : #define DB_KEY_CP                                               (0x2 << 28)
      23                 :            : #define DB_KEY_ST                                               (0x3 << 28)
      24                 :            : #define DB_KEY_TX_PUSH                                          (0x4 << 28)
      25                 :            : #define DB_LONG_TX_PUSH                                         (0x2 << 24)
      26                 :            : 
      27                 :            : #define DEFAULT_CP_RING_SIZE    4096
      28                 :            : #define DEFAULT_RX_RING_SIZE    256
      29                 :            : #define DEFAULT_TX_RING_SIZE    256
      30                 :            : 
      31                 :            : #define AGG_RING_SIZE_FACTOR    4
      32                 :            : #define AGG_RING_MULTIPLIER     2
      33                 :            : 
      34                 :            : /* These assume 4k pages */
      35                 :            : #define MAX_RX_DESC_CNT (8 * 1024)
      36                 :            : #define MAX_TX_DESC_CNT (4 * 1024)
      37                 :            : #define MAX_CP_DESC_CNT (16 * 1024)
      38                 :            : 
      39                 :            : #define INVALID_HW_RING_ID      ((uint16_t)-1)
      40                 :            : #define INVALID_STATS_CTX_ID    ((uint16_t)-1)
      41                 :            : #define MPC_HW_COS_ID           ((uint16_t)-2)
      42                 :            : 
      43                 :            : struct bnxt_ring {
      44                 :            :         void                    *bd;
      45                 :            :         rte_iova_t              bd_dma;
      46                 :            :         uint32_t                ring_size;
      47                 :            :         uint32_t                ring_mask;
      48                 :            : 
      49                 :            :         int                     vmem_size;
      50                 :            :         void                    **vmem;
      51                 :            : 
      52                 :            :         uint16_t                fw_ring_id; /* Ring id filled by Chimp FW */
      53                 :            :         uint16_t                fw_rx_ring_id;
      54                 :            :         const void              *mem_zone;
      55                 :            : };
      56                 :            : 
      57                 :            : struct bnxt_ring_grp_info {
      58                 :            :         uint16_t        fw_stats_ctx;
      59                 :            :         uint16_t        fw_grp_id;
      60                 :            :         uint16_t        rx_fw_ring_id;
      61                 :            :         uint16_t        cp_fw_ring_id;
      62                 :            :         uint16_t        ag_fw_ring_id;
      63                 :            : };
      64                 :            : 
      65                 :            : struct bnxt;
      66                 :            : struct bnxt_tx_ring_info;
      67                 :            : struct bnxt_rx_ring_info;
      68                 :            : struct bnxt_cp_ring_info;
      69                 :            : void bnxt_free_ring(struct bnxt_ring *ring);
      70                 :            : int bnxt_alloc_ring_grps(struct bnxt *bp);
      71                 :            : int bnxt_alloc_rings(struct bnxt *bp, unsigned int socket_id, uint16_t qidx,
      72                 :            :                             struct bnxt_tx_queue *txq,
      73                 :            :                             struct bnxt_rx_queue *rxq,
      74                 :            :                             struct bnxt_cp_ring_info *cp_ring_info,
      75                 :            :                             struct bnxt_cp_ring_info *nq_ring_info,
      76                 :            :                             const char *suffix);
      77                 :            : int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index);
      78                 :            : int bnxt_alloc_hwrm_rings(struct bnxt *bp);
      79                 :            : int bnxt_alloc_async_cp_ring(struct bnxt *bp);
      80                 :            : void bnxt_free_async_cp_ring(struct bnxt *bp);
      81                 :            : int bnxt_alloc_async_ring_struct(struct bnxt *bp);
      82                 :            : int bnxt_alloc_rxtx_nq_ring(struct bnxt *bp);
      83                 :            : void bnxt_free_rxtx_nq_ring(struct bnxt *bp);
      84                 :            : void bnxt_init_dflt_coal(struct bnxt_coal *coal);
      85                 :            : int bnxt_alloc_cmpl_ring(struct bnxt *bp, int queue_index,
      86                 :            :                          struct bnxt_cp_ring_info *cpr);
      87                 :            : void bnxt_set_db(struct bnxt *bp,
      88                 :            :                  struct bnxt_db_info *db,
      89                 :            :                  uint32_t ring_type,
      90                 :            :                  uint32_t map_idx,
      91                 :            :                  uint32_t fid,
      92                 :            :                  uint32_t ring_mask);
      93                 :            : 
      94                 :            : static inline void bnxt_db_write(struct bnxt_db_info *db, uint32_t idx)
      95                 :            : {
      96   [ #  #  #  #  :          0 :         uint32_t db_idx = DB_RING_IDX(db, idx);
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      97                 :          0 :         void *doorbell = db->doorbell;
      98                 :            : 
      99   [ #  #  #  #  :          0 :         if (db->db_64) {
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     100                 :          0 :                 uint64_t key_idx = db->db_key64 | db_idx;
     101                 :            : 
     102                 :          0 :                 rte_compiler_barrier();
     103                 :            :                 rte_write64_relaxed(key_idx, doorbell);
     104                 :            :         } else {
     105                 :          0 :                 uint32_t key_idx = db->db_key32 | db_idx;
     106                 :            : 
     107                 :            :                 rte_write32(key_idx, doorbell);
     108                 :            :         }
     109                 :            : }
     110                 :            : 
     111                 :            : static inline void bnxt_db_mpc_write(struct bnxt_db_info *db, uint32_t idx, uint32_t epoch)
     112                 :            : {
     113         [ #  # ]:          0 :         uint32_t db_idx = DB_RING_IDX(db, idx);
     114                 :          0 :         void *doorbell = db->doorbell;
     115                 :            : 
     116         [ #  # ]:          0 :         if (likely(db->db_64)) {
     117                 :          0 :                 uint64_t key_idx = db->db_key64 | db_idx |
     118                 :          0 :                         (epoch << 24);
     119                 :            :                 rte_write64_relaxed(key_idx, doorbell);
     120                 :            :         } else {
     121                 :          0 :                 uint32_t key_idx = db->db_key32 | db_idx;
     122                 :            : 
     123                 :            :                 rte_write32_relaxed(key_idx, doorbell);
     124                 :            :         }
     125                 :            : }
     126                 :            : 
     127                 :            : /* Ring an NQ doorbell and disable interrupts for the ring. */
     128                 :            : static inline void bnxt_db_nq(struct bnxt_cp_ring_info *cpr)
     129                 :            : {
     130   [ #  #  #  # ]:          0 :         uint32_t db_idx = DB_RING_IDX(&cpr->cp_db, cpr->cp_raw_cons);
     131                 :          0 :         uint64_t key_idx = cpr->cp_db.db_key64 | DBR_TYPE_NQ | db_idx;
     132                 :          0 :         void *doorbell = cpr->cp_db.doorbell;
     133                 :            : 
     134                 :            : 
     135   [ #  #  #  # ]:          0 :         if (unlikely(!cpr->cp_db.db_64))
     136                 :            :                 return;
     137                 :            : 
     138                 :            :         rte_write64(key_idx, doorbell);
     139                 :            : }
     140                 :            : 
     141                 :            : /* Ring an NQ doorbell and enable interrupts for the ring. */
     142                 :            : static inline void bnxt_db_nq_arm(struct bnxt_cp_ring_info *cpr)
     143                 :            : {
     144   [ #  #  #  # ]:          0 :         uint32_t db_idx = DB_RING_IDX(&cpr->cp_db, cpr->cp_raw_cons);
     145                 :          0 :         uint64_t key_idx = cpr->cp_db.db_key64 | DBR_TYPE_NQ_ARM | db_idx;
     146                 :          0 :         void *doorbell = cpr->cp_db.doorbell;
     147                 :            : 
     148   [ #  #  #  # ]:          0 :         if (unlikely(!cpr->cp_db.db_64))
     149                 :            :                 return;
     150                 :            : 
     151                 :            :         rte_write64(key_idx, doorbell);
     152                 :            : }
     153                 :            : 
     154                 :          0 : static inline void bnxt_db_cq(struct bnxt_cp_ring_info *cpr)
     155                 :            : {
     156                 :            :         struct bnxt_db_info *db = &cpr->cp_db;
     157         [ #  # ]:          0 :         uint32_t idx = DB_RING_IDX(&cpr->cp_db, cpr->cp_raw_cons);
     158                 :            : 
     159         [ #  # ]:          0 :         if (db->db_64) {
     160                 :          0 :                 uint64_t key_idx = db->db_key64 | idx;
     161                 :          0 :                 void *doorbell = db->doorbell;
     162                 :            : 
     163                 :          0 :                 rte_compiler_barrier();
     164                 :            :                 rte_write64_relaxed(key_idx, doorbell);
     165                 :            :         } else {
     166                 :            :                 uint32_t cp_raw_cons = cpr->cp_raw_cons;
     167                 :            : 
     168                 :          0 :                 rte_compiler_barrier();
     169         [ #  # ]:          0 :                 B_CP_DIS_DB(cpr, cp_raw_cons);
     170                 :            :         }
     171                 :          0 : }
     172                 :            : 
     173                 :          0 : static inline void bnxt_db_mpc_cq(struct bnxt_cp_ring_info *cpr)
     174                 :            : {
     175                 :            :         struct bnxt_db_info *db = &cpr->cp_db;
     176         [ #  # ]:          0 :         uint32_t idx = DB_RING_IDX(&cpr->cp_db, cpr->cp_raw_cons);
     177                 :            : 
     178         [ #  # ]:          0 :         if (likely(db->db_64)) {
     179                 :          0 :                 uint64_t key_idx = db->db_key64 | idx |
     180                 :          0 :                         (cpr->epoch << 24);
     181                 :          0 :                 void *doorbell = db->doorbell;
     182                 :            : 
     183                 :          0 :                 rte_compiler_barrier();
     184                 :            :                 rte_write64_relaxed(key_idx, doorbell);
     185                 :            :         } else {
     186                 :            :                 uint32_t cp_raw_cons = cpr->cp_raw_cons;
     187                 :            : 
     188                 :          0 :                 rte_compiler_barrier();
     189         [ #  # ]:          0 :                 B_CP_DIS_DB(cpr, cp_raw_cons);
     190                 :            :         }
     191                 :          0 : }
     192                 :            : 
     193                 :            : #endif

Generated by: LCOV version 1.14