LCOV - code coverage report
Current view: top level - drivers/net/nfp/nfdk - nfp_nfdk.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 5 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2023 Corigine, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef __NFP_NFDK_H__
       7                 :            : #define __NFP_NFDK_H__
       8                 :            : 
       9                 :            : #include "../nfp_rxtx.h"
      10                 :            : 
      11                 :            : #define NFDK_TX_DESC_PER_SIMPLE_PKT     2
      12                 :            : 
      13                 :            : #define NFDK_TX_MAX_DATA_PER_HEAD       0x00001000    /* 4K */
      14                 :            : #define NFDK_TX_MAX_DATA_PER_DESC       0x00004000    /* 16K */
      15                 :            : #define NFDK_TX_MAX_DATA_PER_BLOCK      0x00010000    /* 64K */
      16                 :            : 
      17                 :            : /* The mask of 'dma_len_xx' of address descriptor */
      18                 :            : #define NFDK_DESC_TX_DMA_LEN_HEAD       0x0FFF        /* [0,11] */
      19                 :            : #define NFDK_DESC_TX_DMA_LEN            0x3FFF        /* [0,13] */
      20                 :            : 
      21                 :            : /* The mask of upper 4 bit of first address descriptor */
      22                 :            : #define NFDK_DESC_TX_TYPE_HEAD          0xF000        /* [12,15] */
      23                 :            : 
      24                 :            : /* The value of upper 4 bit of first address descriptor */
      25                 :            : #define NFDK_DESC_TX_TYPE_GATHER        1
      26                 :            : #define NFDK_DESC_TX_TYPE_TSO           2
      27                 :            : #define NFDK_DESC_TX_TYPE_SIMPLE        8
      28                 :            : 
      29                 :            : /* The 'end of chain' flag of address descriptor */
      30                 :            : #define NFDK_DESC_TX_EOP                RTE_BIT32(14)
      31                 :            : 
      32                 :            : /* Flags in the host metadata descriptor */
      33                 :            : #define NFDK_DESC_TX_CHAIN_META         RTE_BIT32(3)
      34                 :            : #define NFDK_DESC_TX_ENCAP              RTE_BIT32(2)
      35                 :            : #define NFDK_DESC_TX_L4_CSUM            RTE_BIT32(1)
      36                 :            : #define NFDK_DESC_TX_L3_CSUM            RTE_BIT32(0)
      37                 :            : 
      38                 :            : #define NFDK_TX_DESC_BLOCK_SZ           256
      39                 :            : #define NFDK_TX_DESC_BLOCK_CNT          (NFDK_TX_DESC_BLOCK_SZ /         \
      40                 :            :                                         sizeof(struct nfp_net_nfdk_tx_desc))
      41                 :            : #define NFDK_TX_DESC_STOP_CNT           (NFDK_TX_DESC_BLOCK_CNT *        \
      42                 :            :                                         NFDK_TX_DESC_PER_SIMPLE_PKT)
      43                 :            : #define D_BLOCK_CPL(idx)               (NFDK_TX_DESC_BLOCK_CNT -        \
      44                 :            :                                         (idx) % NFDK_TX_DESC_BLOCK_CNT)
      45                 :            : /* Convenience macro for wrapping descriptor index on ring size */
      46                 :            : #define D_IDX(ring, idx)               ((idx) & ((ring)->tx_count - 1))
      47                 :            : 
      48                 :            : /*
      49                 :            :  * A full TX descriptor consists of one or more address descriptors,
      50                 :            :  * followed by a TX metadata descriptor, and finally a TSO descriptor for
      51                 :            :  * TSO packets.
      52                 :            :  *
      53                 :            :  * --> Header address descriptor:
      54                 :            :  * Bit    3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
      55                 :            :  * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
      56                 :            :  * Word  +-+-+---+-----------------------+-------------------------------+
      57                 :            :  *    0  |S|E| TP|     dma_len_12        |         dma_addr_hi           |
      58                 :            :  *       +-+-+---+-----------------------+-------------------------------+
      59                 :            :  *    1  |                          dma_addr_lo                          |
      60                 :            :  *       +---------------------------------------------------------------+
      61                 :            :  *
      62                 :            :  * --> Subsequent address descriptor(s):
      63                 :            :  * Bit    3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
      64                 :            :  * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
      65                 :            :  * Word  +-+-+---------------------------+-------------------------------+
      66                 :            :  *    0  |S|E|         dma_len_14        |          dma_addr_hi          |
      67                 :            :  *       +-+-+---------------------------+-------------------------------+
      68                 :            :  *    1  |                          dma_addr_lo                          |
      69                 :            :  *       +---------------------------------------------------------------+
      70                 :            :  *
      71                 :            :  * S - Simple Packet descriptor
      72                 :            :  * TP - Type of descriptor
      73                 :            :  * E - End of chain
      74                 :            :  * dma_len - length of the host memory in bytes -1
      75                 :            :  * dma_addr_hi - bits [47:32] of host memory address
      76                 :            :  * dma_addr_lo - bits [31:0] of host memory address
      77                 :            :  *
      78                 :            :  * --> Metadata descriptor
      79                 :            :  * Bit     3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
      80                 :            :  * -----\  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
      81                 :            :  * Word   +-------+-----------------------+---------------------+---+-----+
      82                 :            :  *    0   |  ZERO |   Rsvd (64b support)  |       TBD meta      | MT| CSUM|
      83                 :            :  *        +-------+-----------------------+---------------------+---+-----+
      84                 :            :  *    1   |                           TBD meta                            |
      85                 :            :  *        +---------------------------------------------------------------+
      86                 :            :  *
      87                 :            :  * --> TSO descriptor
      88                 :            :  * The following is only present if TP above indicates LSO:
      89                 :            :  * Bit    3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
      90                 :            :  * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
      91                 :            :  * Word  +---------------+---------------+---+---------------------------+
      92                 :            :  *    0  | total_segments|   header_len  |sp0|          mss              |
      93                 :            :  *       +---------------+---------------+---+---------------------------+
      94                 :            :  *    1  |               sp1             |       L4      |      L3       |
      95                 :            :  *       +---------------------------------------------------------------+
      96                 :            :  *
      97                 :            :  * total_segments - LSO: Total number of segments
      98                 :            :  * header_len - LSO: length of the LSO header in bytes
      99                 :            :  * sp0 - Spare Bits (ZERO)
     100                 :            :  * mss - LSO: TCP MSS, maximum segment size of TCP payload
     101                 :            :  * sp1 - Spare Bits (ZERO)
     102                 :            :  * L4 - Layer 4 data
     103                 :            :  * L3 - Layer 3 data
     104                 :            :  */
     105                 :            : struct nfp_net_nfdk_tx_desc {
     106                 :            :         union {
     107                 :            :                 /** Address descriptor */
     108                 :            :                 struct {
     109                 :            :                         uint16_t dma_addr_hi;  /**< High bits of host buf address */
     110                 :            :                         uint16_t dma_len_type; /**< Length to DMA for this desc */
     111                 :            :                         uint32_t dma_addr_lo;  /**< Low 32bit of host buf addr */
     112                 :            :                 };
     113                 :            : 
     114                 :            :                 /** TSO descriptor */
     115                 :            :                 struct {
     116                 :            :                         uint16_t mss;          /**< MSS to be used for LSO */
     117                 :            :                         uint8_t lso_hdrlen;    /**< LSO, TCP payload offset */
     118                 :            :                         uint8_t lso_totsegs;   /**< LSO, total segments */
     119                 :            :                         uint8_t l3_offset;     /**< L3 header offset */
     120                 :            :                         uint8_t l4_offset;     /**< L4 header offset */
     121                 :            :                         uint16_t lso_meta_res; /**< Rsvd bits in TSO metadata */
     122                 :            :                 };
     123                 :            : 
     124                 :            :                 /** Metadata descriptor */
     125                 :            :                 struct {
     126                 :            :                         uint8_t flags;         /**< TX Flags, see @NFDK_DESC_TX_* */
     127                 :            :                         uint8_t reserved[7];   /**< Meta byte place holder */
     128                 :            :                 };
     129                 :            : 
     130                 :            :                 uint32_t vals[2];
     131                 :            :                 uint64_t raw;
     132                 :            :         };
     133                 :            : };
     134                 :            : 
     135                 :            : static inline uint32_t
     136                 :            : nfp_net_nfdk_free_tx_desc(struct nfp_net_txq *txq)
     137                 :            : {
     138                 :            :         uint32_t free_desc;
     139                 :            : 
     140   [ #  #  #  #  :          0 :         if (txq->wr_p >= txq->rd_p)
                   #  # ]
     141                 :          0 :                 free_desc = txq->tx_count - (txq->wr_p - txq->rd_p);
     142                 :            :         else
     143                 :          0 :                 free_desc = txq->rd_p - txq->wr_p;
     144                 :            : 
     145                 :            :         return (free_desc > NFDK_TX_DESC_STOP_CNT) ?
     146   [ #  #  #  # ]:          0 :                         (free_desc - NFDK_TX_DESC_STOP_CNT) : 0;
     147                 :            : }
     148                 :            : 
     149                 :            : /**
     150                 :            :  * Check if the TX queue free descriptors is below tx_free_threshold
     151                 :            :  * for firmware of nfdk
     152                 :            :  *
     153                 :            :  * This function uses the host copy* of read/write pointers.
     154                 :            :  *
     155                 :            :  * @param txq
     156                 :            :  *   TX queue to check
     157                 :            :  */
     158                 :            : static inline bool
     159                 :            : nfp_net_nfdk_txq_full(struct nfp_net_txq *txq)
     160                 :            : {
     161         [ #  # ]:          0 :         return (nfp_net_nfdk_free_tx_desc(txq) < txq->tx_free_thresh);
     162                 :            : }
     163                 :            : 
     164                 :            : uint32_t nfp_flower_nfdk_pkt_add_metadata(struct rte_mbuf *mbuf,
     165                 :            :                 uint32_t port_id);
     166                 :            : uint16_t nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
     167                 :            :                 struct rte_mbuf **tx_pkts,
     168                 :            :                 uint16_t nb_pkts,
     169                 :            :                 bool repr_flag);
     170                 :            : uint16_t nfp_net_nfdk_xmit_pkts(void *tx_queue,
     171                 :            :                 struct rte_mbuf **tx_pkts,
     172                 :            :                 uint16_t nb_pkts);
     173                 :            : int nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
     174                 :            :                 uint16_t queue_idx,
     175                 :            :                 uint16_t nb_desc,
     176                 :            :                 unsigned int socket_id,
     177                 :            :                 const struct rte_eth_txconf *tx_conf);
     178                 :            : int nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
     179                 :            :                 struct rte_mbuf *pkt);
     180                 :            : 
     181                 :            : #endif /* __NFP_NFDK_H__ */

Generated by: LCOV version 1.14