LCOV - code coverage report
Current view: top level - drivers/net/nfp - nfp_rxtx.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 2 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2014-2021 Netronome Systems, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef __NFP_RXTX_H__
       7                 :            : #define __NFP_RXTX_H__
       8                 :            : 
       9                 :            : #include <ethdev_driver.h>
      10                 :            : 
      11                 :            : /* Descriptor alignment */
      12                 :            : #define NFP_ALIGN_RING_DESC 128
      13                 :            : 
      14                 :            : struct nfp_net_dp_buf {
      15                 :            :         struct rte_mbuf *mbuf;
      16                 :            : };
      17                 :            : 
      18                 :            : struct nfp_tx_ipsec_desc_msg {
      19                 :            :         uint32_t sa_idx;        /**< SA index in driver table */
      20                 :            :         uint32_t enc;           /**< IPsec enable flag */
      21                 :            :         union {
      22                 :            :                 uint64_t value;
      23                 :            :                 struct {
      24                 :            :                         uint32_t low;
      25                 :            :                         uint32_t hi;
      26                 :            :                 };
      27                 :            :         } esn;                  /**< Extended Sequence Number */
      28                 :            : };
      29                 :            : 
      30                 :            : struct __rte_aligned(64) nfp_net_txq {
      31                 :            :         /** Backpointer to nfp_net structure */
      32                 :            :         struct nfp_net_hw *hw;
      33                 :            :         struct nfp_net_hw_priv *hw_priv;
      34                 :            : 
      35                 :            :         /**
      36                 :            :          * For each descriptor keep a reference to the mbuf and
      37                 :            :          * DMA address used until completion is signalled.
      38                 :            :          */
      39                 :            :         struct nfp_net_dp_buf *txbufs;
      40                 :            : 
      41                 :            :         /**
      42                 :            :          * Information about the host side queue location.
      43                 :            :          * It is the virtual address for the queue.
      44                 :            :          */
      45                 :            :         union {
      46                 :            :                 struct nfp_net_nfd3_tx_desc *txds;
      47                 :            :                 struct nfp_net_nfdk_tx_desc *ktxds;
      48                 :            :         };
      49                 :            : 
      50                 :            :         /**
      51                 :            :          * Host side read and write pointer, they are free running and
      52                 :            :          * have little relation to the QCP pointers.
      53                 :            :          */
      54                 :            :         uint32_t wr_p;
      55                 :            :         uint32_t rd_p;
      56                 :            : 
      57                 :            :         /** The size of the queue in number of descriptors. */
      58                 :            :         uint32_t tx_count;
      59                 :            : 
      60                 :            :         uint32_t tx_free_thresh;
      61                 :            : 
      62                 :            :         /** The index of the QCP queue relative to the TX queue BAR. */
      63                 :            :         uint32_t tx_qcidx;
      64                 :            : 
      65                 :            :         /** The queue index from Linux's perspective. */
      66                 :            :         uint16_t qidx;
      67                 :            :         uint16_t port_id;
      68                 :            : 
      69                 :            :         /** Used by NFDk only */
      70                 :            :         uint16_t data_pending;
      71                 :            : 
      72                 :            :         /** Used by NFDk vector xmit only */
      73                 :            :         bool simple_always;
      74                 :            : 
      75                 :            :         /**
      76                 :            :          * At this point 58 bytes have been used for all the fields in the
      77                 :            :          * TX critical path. We have room for 5 bytes and still all placed
      78                 :            :          * in a cache line.
      79                 :            :          */
      80                 :            :         uint64_t dma;
      81                 :            : 
      82                 :            :         /** TX pointer ring write back area (indexed by queue id) */
      83                 :            :         uint64_t *txrwb;
      84                 :            : 
      85                 :            :         /** TX pointer ring write back area DMA address */
      86                 :            :         uint64_t txrwb_dma;
      87                 :            : 
      88                 :            :         /** Point to the base of the queue structure on the NFP. */
      89                 :            :         uint8_t *qcp_q;
      90                 :            : };
      91                 :            : 
      92                 :            : /* RX and freelist descriptor format */
      93                 :            : #define PCIE_DESC_RX_DD                 (1 << 7)
      94                 :            : #define PCIE_DESC_RX_META_LEN_MASK      (0x7f)
      95                 :            : 
      96                 :            : /* Flags in the RX descriptor */
      97                 :            : #define PCIE_DESC_RX_RSS                (1 << 15)
      98                 :            : #define PCIE_DESC_RX_I_IP4_CSUM         (1 << 14)
      99                 :            : #define PCIE_DESC_RX_I_IP4_CSUM_OK      (1 << 13)
     100                 :            : #define PCIE_DESC_RX_I_TCP_CSUM         (1 << 12)
     101                 :            : #define PCIE_DESC_RX_I_TCP_CSUM_OK      (1 << 11)
     102                 :            : #define PCIE_DESC_RX_I_UDP_CSUM         (1 << 10)
     103                 :            : #define PCIE_DESC_RX_I_UDP_CSUM_OK      (1 <<  9)
     104                 :            : #define PCIE_DESC_RX_SPARE              (1 <<  8)
     105                 :            : #define PCIE_DESC_RX_EOP                (1 <<  7)
     106                 :            : #define PCIE_DESC_RX_IP4_CSUM           (1 <<  6)
     107                 :            : #define PCIE_DESC_RX_IP4_CSUM_OK        (1 <<  5)
     108                 :            : #define PCIE_DESC_RX_TCP_CSUM           (1 <<  4)
     109                 :            : #define PCIE_DESC_RX_TCP_CSUM_OK        (1 <<  3)
     110                 :            : #define PCIE_DESC_RX_UDP_CSUM           (1 <<  2)
     111                 :            : #define PCIE_DESC_RX_UDP_CSUM_OK        (1 <<  1)
     112                 :            : #define PCIE_DESC_RX_VLAN               (1 <<  0)
     113                 :            : 
     114                 :            : #define PCIE_DESC_RX_L4_CSUM_OK         (PCIE_DESC_RX_TCP_CSUM_OK | \
     115                 :            :                                          PCIE_DESC_RX_UDP_CSUM_OK)
     116                 :            : 
     117                 :            : struct nfp_net_rx_desc {
     118                 :            :         union {
     119                 :            :                 /** Freelist descriptor. */
     120                 :            :                 struct {
     121                 :            :                         uint16_t dma_addr_hi;  /**< High bits of buffer address. */
     122                 :            :                         uint8_t spare;         /**< Reserved, must be zero. */
     123                 :            :                         uint8_t dd;            /**< Whether descriptor available. */
     124                 :            :                         uint32_t dma_addr_lo;  /**< Low bits of buffer address. */
     125                 :            :                 } __rte_packed fld;
     126                 :            : 
     127                 :            :                 /** RX descriptor. */
     128                 :            :                 struct {
     129                 :            :                         uint16_t data_len;     /**< Length of frame + metadata. */
     130                 :            :                         uint8_t reserved;      /**< Reserved, must be zero. */
     131                 :            :                         uint8_t meta_len_dd;   /**< Length of metadata + done flag. */
     132                 :            : 
     133                 :            :                         uint16_t flags;        /**< RX flags. */
     134                 :            :                         uint16_t offload_info; /**< Offloading info. */
     135                 :            :                 } __rte_packed rxd;
     136                 :            : 
     137                 :            :                 /** Reserved. */
     138                 :            :                 uint32_t vals[2];
     139                 :            :         };
     140                 :            : };
     141                 :            : 
     142                 :            : struct __rte_aligned(64) nfp_net_rxq {
     143                 :            :         /** Backpointer to nfp_net structure */
     144                 :            :         struct nfp_net_hw *hw;
     145                 :            :         struct nfp_net_hw_priv *hw_priv;
     146                 :            : 
     147                 :            :         /**
     148                 :            :          * Point to the base addresses of the freelist queue
     149                 :            :          * controller peripheral queue structures on the NFP.
     150                 :            :          */
     151                 :            :         uint8_t *qcp_fl;
     152                 :            : 
     153                 :            :         /**
     154                 :            :          * For each buffer placed on the freelist, record the
     155                 :            :          * associated mbuf.
     156                 :            :          */
     157                 :            :         struct nfp_net_dp_buf *rxbufs;
     158                 :            : 
     159                 :            :         /**
     160                 :            :          * Information about the host side queue location.
     161                 :            :          * It is the virtual address for the queue.
     162                 :            :          */
     163                 :            :         struct nfp_net_rx_desc *rxds;
     164                 :            : 
     165                 :            :         /**
     166                 :            :          * The mempool is created by the user specifying a mbuf size.
     167                 :            :          * We save here the reference of the mempool needed in the RX
     168                 :            :          * path and the mbuf size for checking received packets can be
     169                 :            :          * safely copied to the mbuf using the NFP_NET_RX_OFFSET.
     170                 :            :          */
     171                 :            :         struct rte_mempool *mem_pool;
     172                 :            : 
     173                 :            :         /**
     174                 :            :          * Host side read pointer, free running and have little relation
     175                 :            :          * to the QCP pointers. It is where the driver start reading
     176                 :            :          * descriptors for newly arrive packets from.
     177                 :            :          */
     178                 :            :         uint32_t rd_p;
     179                 :            : 
     180                 :            :         uint16_t mbuf_size;
     181                 :            : 
     182                 :            :         /**
     183                 :            :          * Next two fields are used for giving more free descriptors
     184                 :            :          * to the NFP.
     185                 :            :          */
     186                 :            :         uint16_t rx_free_thresh;
     187                 :            :         uint16_t nb_rx_hold;
     188                 :            : 
     189                 :            :         /** Referencing dev->data->port_id */
     190                 :            :         uint16_t port_id;
     191                 :            : 
     192                 :            :         /** The queue index from Linux's perspective */
     193                 :            :         uint16_t qidx;
     194                 :            : 
     195                 :            :         /**
     196                 :            :          * At this point 62 bytes have been used for all the fields in the
     197                 :            :          * RX critical path. We have room for 2 bytes and still all placed
     198                 :            :          * in a cache line.
     199                 :            :          */
     200                 :            : 
     201                 :            :         /** The size of the queue in number of descriptors */
     202                 :            :         uint16_t rx_count;
     203                 :            : 
     204                 :            :         /**
     205                 :            :          * The index of the QCP queue relative to the RX queue BAR
     206                 :            :          * used for the freelist.
     207                 :            :          */
     208                 :            :         uint32_t fl_qcidx;
     209                 :            : 
     210                 :            :         /** DMA address of the queue */
     211                 :            :         uint64_t dma;
     212                 :            : };
     213                 :            : 
     214                 :            : static inline void
     215                 :            : nfp_net_mbuf_alloc_failed(struct nfp_net_rxq *rxq)
     216                 :            : {
     217                 :          0 :         rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
     218                 :          0 : }
     219                 :            : 
     220                 :            : void nfp_net_rx_cksum(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
     221                 :            :                 struct rte_mbuf *mb);
     222                 :            : int nfp_net_rx_freelist_setup(struct rte_eth_dev *dev);
     223                 :            : uint32_t nfp_net_rx_queue_count(void *rx_queue);
     224                 :            : uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
     225                 :            :                 uint16_t nb_pkts);
     226                 :            : void nfp_net_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
     227                 :            : void nfp_net_reset_rx_queue(struct nfp_net_rxq *rxq);
     228                 :            : int nfp_net_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
     229                 :            :                 uint16_t nb_desc, unsigned int socket_id,
     230                 :            :                 const struct rte_eth_rxconf *rx_conf,
     231                 :            :                 struct rte_mempool *mp);
     232                 :            : void nfp_net_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
     233                 :            : void nfp_net_reset_tx_queue(struct nfp_net_txq *txq);
     234                 :            : 
     235                 :            : int nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
     236                 :            :                 uint16_t queue_idx,
     237                 :            :                 uint16_t nb_desc,
     238                 :            :                 unsigned int socket_id,
     239                 :            :                 const struct rte_eth_txconf *tx_conf);
     240                 :            : uint32_t nfp_net_tx_free_bufs(struct nfp_net_txq *txq);
     241                 :            : void nfp_net_rx_queue_info_get(struct rte_eth_dev *dev,
     242                 :            :                 uint16_t queue_id,
     243                 :            :                 struct rte_eth_rxq_info *qinfo);
     244                 :            : void nfp_net_tx_queue_info_get(struct rte_eth_dev *dev,
     245                 :            :                 uint16_t queue_id,
     246                 :            :                 struct rte_eth_txq_info *qinfo);
     247                 :            : void nfp_net_recv_pkts_set(struct rte_eth_dev *eth_dev);
     248                 :            : void nfp_net_parse_ptype(struct nfp_net_rxq *rxq,
     249                 :            :                 struct nfp_net_rx_desc *rxds,
     250                 :            :                 struct rte_mbuf *mb);
     251                 :            : 
     252                 :            : #endif /* __NFP_RXTX_H__ */

Generated by: LCOV version 1.14