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-01-22 16:13:49 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                 :            : #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
      12                 :            : 
      13                 :            : /* Maximum number of NFP packet metadata fields. */
      14                 :            : #define NFP_META_MAX_FIELDS      8
      15                 :            : 
      16                 :            : /* Describe the raw metadata format. */
      17                 :            : struct nfp_net_meta_raw {
      18                 :            :         uint32_t header; /**< Field type header (see format in nfp.rst) */
      19                 :            :         uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */
      20                 :            :         uint8_t length; /**< Number of valid fields in @header */
      21                 :            : };
      22                 :            : 
      23                 :            : /* Descriptor alignment */
      24                 :            : #define NFP_ALIGN_RING_DESC 128
      25                 :            : 
      26                 :            : struct nfp_net_dp_buf {
      27                 :            :         struct rte_mbuf *mbuf;
      28                 :            : };
      29                 :            : 
      30                 :            : struct nfp_tx_ipsec_desc_msg {
      31                 :            :         uint32_t sa_idx;        /**< SA index in driver table */
      32                 :            :         uint32_t enc;           /**< IPsec enable flag */
      33                 :            :         union {
      34                 :            :                 uint64_t value;
      35                 :            :                 struct {
      36                 :            :                         uint32_t low;
      37                 :            :                         uint32_t hi;
      38                 :            :                 };
      39                 :            :         } esn;                  /**< Extended Sequence Number */
      40                 :            : };
      41                 :            : 
      42                 :            : struct nfp_net_txq {
      43                 :            :         /** Backpointer to nfp_net structure */
      44                 :            :         struct nfp_net_hw *hw;
      45                 :            : 
      46                 :            :         /** Point to the base of the queue structure on the NFP. */
      47                 :            :         uint8_t *qcp_q;
      48                 :            : 
      49                 :            :         /**
      50                 :            :          * Host side read and write pointer, they are free running and
      51                 :            :          * have little relation to the QCP pointers.
      52                 :            :          */
      53                 :            :         uint32_t wr_p;
      54                 :            :         uint32_t rd_p;
      55                 :            : 
      56                 :            :         /** The size of the queue in number of descriptors. */
      57                 :            :         uint32_t tx_count;
      58                 :            : 
      59                 :            :         uint32_t tx_free_thresh;
      60                 :            : 
      61                 :            :         /**
      62                 :            :          * For each descriptor keep a reference to the mbuf and
      63                 :            :          * DMA address used until completion is signalled.
      64                 :            :          */
      65                 :            :         struct nfp_net_dp_buf *txbufs;
      66                 :            : 
      67                 :            :         /**
      68                 :            :          * Information about the host side queue location.
      69                 :            :          * It is the virtual address for the queue.
      70                 :            :          */
      71                 :            :         union {
      72                 :            :                 struct nfp_net_nfd3_tx_desc *txds;
      73                 :            :                 struct nfp_net_nfdk_tx_desc *ktxds;
      74                 :            :         };
      75                 :            : 
      76                 :            :         /** The index of the QCP queue relative to the TX queue BAR. */
      77                 :            :         uint32_t tx_qcidx;
      78                 :            : 
      79                 :            :         /** The queue index from Linux's perspective. */
      80                 :            :         uint16_t qidx;
      81                 :            :         uint16_t port_id;
      82                 :            : 
      83                 :            :         /** Used by NFDk only */
      84                 :            :         uint16_t data_pending;
      85                 :            : 
      86                 :            :         /**
      87                 :            :          * At this point 58 bytes have been used for all the fields in the
      88                 :            :          * TX critical path. We have room for 6 bytes and still all placed
      89                 :            :          * in a cache line.
      90                 :            :          */
      91                 :            :         uint64_t dma;
      92                 :            : } __rte_aligned(64);
      93                 :            : 
      94                 :            : /* RX and freelist descriptor format */
      95                 :            : #define PCIE_DESC_RX_DD                 (1 << 7)
      96                 :            : #define PCIE_DESC_RX_META_LEN_MASK      (0x7f)
      97                 :            : 
      98                 :            : /* Flags in the RX descriptor */
      99                 :            : #define PCIE_DESC_RX_RSS                (1 << 15)
     100                 :            : #define PCIE_DESC_RX_I_IP4_CSUM         (1 << 14)
     101                 :            : #define PCIE_DESC_RX_I_IP4_CSUM_OK      (1 << 13)
     102                 :            : #define PCIE_DESC_RX_I_TCP_CSUM         (1 << 12)
     103                 :            : #define PCIE_DESC_RX_I_TCP_CSUM_OK      (1 << 11)
     104                 :            : #define PCIE_DESC_RX_I_UDP_CSUM         (1 << 10)
     105                 :            : #define PCIE_DESC_RX_I_UDP_CSUM_OK      (1 <<  9)
     106                 :            : #define PCIE_DESC_RX_SPARE              (1 <<  8)
     107                 :            : #define PCIE_DESC_RX_EOP                (1 <<  7)
     108                 :            : #define PCIE_DESC_RX_IP4_CSUM           (1 <<  6)
     109                 :            : #define PCIE_DESC_RX_IP4_CSUM_OK        (1 <<  5)
     110                 :            : #define PCIE_DESC_RX_TCP_CSUM           (1 <<  4)
     111                 :            : #define PCIE_DESC_RX_TCP_CSUM_OK        (1 <<  3)
     112                 :            : #define PCIE_DESC_RX_UDP_CSUM           (1 <<  2)
     113                 :            : #define PCIE_DESC_RX_UDP_CSUM_OK        (1 <<  1)
     114                 :            : #define PCIE_DESC_RX_VLAN               (1 <<  0)
     115                 :            : 
     116                 :            : #define PCIE_DESC_RX_L4_CSUM_OK         (PCIE_DESC_RX_TCP_CSUM_OK | \
     117                 :            :                                          PCIE_DESC_RX_UDP_CSUM_OK)
     118                 :            : 
     119                 :            : struct nfp_net_rx_desc {
     120                 :            :         union {
     121                 :            :                 /** Freelist descriptor. */
     122                 :            :                 struct {
     123                 :            :                         uint16_t dma_addr_hi;  /**< High bits of buffer address. */
     124                 :            :                         uint8_t spare;         /**< Reserved, must be zero. */
     125                 :            :                         uint8_t dd;            /**< Whether descriptor available. */
     126                 :            :                         uint32_t dma_addr_lo;  /**< Low bits of buffer address. */
     127                 :            :                 } __rte_packed fld;
     128                 :            : 
     129                 :            :                 /** RX descriptor. */
     130                 :            :                 struct {
     131                 :            :                         uint16_t data_len;     /**< Length of frame + metadata. */
     132                 :            :                         uint8_t reserved;      /**< Reserved, must be zero. */
     133                 :            :                         uint8_t meta_len_dd;   /**< Length of metadata + done flag. */
     134                 :            : 
     135                 :            :                         uint16_t flags;        /**< RX flags. */
     136                 :            :                         uint16_t offload_info; /**< Offloading info. */
     137                 :            :                 } __rte_packed rxd;
     138                 :            : 
     139                 :            :                 /** Reserved. */
     140                 :            :                 uint32_t vals[2];
     141                 :            :         };
     142                 :            : };
     143                 :            : 
     144                 :            : struct nfp_net_rxq {
     145                 :            :         /** Backpointer to nfp_net structure */
     146                 :            :         struct nfp_net_hw *hw;
     147                 :            : 
     148                 :            :         /**
     149                 :            :          * Point to the base addresses of the freelist queue
     150                 :            :          * controller peripheral queue structures on the NFP.
     151                 :            :          */
     152                 :            :         uint8_t *qcp_fl;
     153                 :            : 
     154                 :            :         /**
     155                 :            :          * Host side read pointer, free running and have little relation
     156                 :            :          * to the QCP pointers. It is where the driver start reading
     157                 :            :          * descriptors for newly arrive packets from.
     158                 :            :          */
     159                 :            :         uint32_t rd_p;
     160                 :            : 
     161                 :            :         /**
     162                 :            :          * The index of the QCP queue relative to the RX queue BAR
     163                 :            :          * used for the freelist.
     164                 :            :          */
     165                 :            :         uint32_t fl_qcidx;
     166                 :            : 
     167                 :            :         /**
     168                 :            :          * For each buffer placed on the freelist, record the
     169                 :            :          * associated mbuf.
     170                 :            :          */
     171                 :            :         struct nfp_net_dp_buf *rxbufs;
     172                 :            : 
     173                 :            :         /**
     174                 :            :          * Information about the host side queue location.
     175                 :            :          * It is the virtual address for the queue.
     176                 :            :          */
     177                 :            :         struct nfp_net_rx_desc *rxds;
     178                 :            : 
     179                 :            :         /**
     180                 :            :          * The mempool is created by the user specifying a mbuf size.
     181                 :            :          * We save here the reference of the mempool needed in the RX
     182                 :            :          * path and the mbuf size for checking received packets can be
     183                 :            :          * safely copied to the mbuf using the NFP_NET_RX_OFFSET.
     184                 :            :          */
     185                 :            :         struct rte_mempool *mem_pool;
     186                 :            :         uint16_t mbuf_size;
     187                 :            : 
     188                 :            :         /**
     189                 :            :          * Next two fields are used for giving more free descriptors
     190                 :            :          * to the NFP.
     191                 :            :          */
     192                 :            :         uint16_t rx_free_thresh;
     193                 :            :         uint16_t nb_rx_hold;
     194                 :            : 
     195                 :            :          /** The size of the queue in number of descriptors */
     196                 :            :         uint16_t rx_count;
     197                 :            : 
     198                 :            :         /** Referencing dev->data->port_id */
     199                 :            :         uint16_t port_id;
     200                 :            : 
     201                 :            :         /** The queue index from Linux's perspective */
     202                 :            :         uint16_t qidx;
     203                 :            : 
     204                 :            :         /**
     205                 :            :          * At this point 60 bytes have been used for all the fields in the
     206                 :            :          * RX critical path. We have room for 4 bytes and still all placed
     207                 :            :          * in a cache line.
     208                 :            :          */
     209                 :            : 
     210                 :            :         /** DMA address of the queue */
     211                 :            :         uint64_t dma;
     212                 :            : } __rte_aligned(64);
     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_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
     242                 :            :                 struct rte_mbuf *pkt,
     243                 :            :                 uint8_t layer);
     244                 :            : void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
     245                 :            :                 struct nfp_net_txq *txq,
     246                 :            :                 struct rte_mbuf *pkt,
     247                 :            :                 uint8_t layer,
     248                 :            :                 uint8_t ipsec_layer);
     249                 :            : 
     250                 :            : #endif /* __NFP_RXTX_H__ */

Generated by: LCOV version 1.14