1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2014-2021 Netronome Systems, Inc.
7 * vim:shiftwidth=8:noexpandtab
9 * @file dpdk/pmd/nfp_rxtx.h
11 * Netronome NFP Rx/Tx specific header file
17 #include <linux/types.h>
20 #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
22 #define NFP_HASH_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4)
23 #define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8)
25 #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \
26 ((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM))
29 * The maximum number of descriptors is limited by design as
30 * DPDK uses uint16_t variables for these values
32 #define NFP_NET_MAX_TX_DESC (32 * 1024)
33 #define NFP_NET_MIN_TX_DESC 256
35 #define NFP_NET_MAX_RX_DESC (32 * 1024)
36 #define NFP_NET_MIN_RX_DESC 256
38 /* Descriptor alignment */
39 #define NFP_ALIGN_RING_DESC 128
41 /* TX descriptor format */
42 #define PCIE_DESC_TX_EOP (1 << 7)
43 #define PCIE_DESC_TX_OFFSET_MASK (0x7f)
45 /* Flags in the host TX descriptor */
46 #define PCIE_DESC_TX_CSUM (1 << 7)
47 #define PCIE_DESC_TX_IP4_CSUM (1 << 6)
48 #define PCIE_DESC_TX_TCP_CSUM (1 << 5)
49 #define PCIE_DESC_TX_UDP_CSUM (1 << 4)
50 #define PCIE_DESC_TX_VLAN (1 << 3)
51 #define PCIE_DESC_TX_LSO (1 << 2)
52 #define PCIE_DESC_TX_ENCAP_NONE (0)
53 #define PCIE_DESC_TX_ENCAP_VXLAN (1 << 1)
54 #define PCIE_DESC_TX_ENCAP_GRE (1 << 0)
56 struct nfp_net_tx_desc {
59 uint8_t dma_addr_hi; /* High bits of host buf address */
60 __le16 dma_len; /* Length to DMA for this desc */
61 uint8_t offset_eop; /* Offset in buf where pkt starts +
62 * highest bit is eop flag.
64 __le32 dma_addr_lo; /* Low 32bit of host buf addr */
66 __le16 mss; /* MSS to be used for LSO */
67 uint8_t lso_hdrlen; /* LSO, where the data starts */
68 uint8_t flags; /* TX Flags, see @PCIE_DESC_TX_* */
73 * L3 and L4 header offsets required
79 __le16 vlan; /* VLAN tag to add if indicated */
81 __le16 data_len; /* Length of frame + meta data */
88 struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
91 * Queue information: @qidx is the queue index from Linux's
92 * perspective. @tx_qcidx is the index of the Queue
93 * Controller Peripheral queue relative to the TX queue BAR.
94 * @cnt is the size of the queue in number of
95 * descriptors. @qcp_q is a pointer to the base of the queue
96 * structure on the NFP
101 * Read and Write pointers. @wr_p and @rd_p are host side pointer,
102 * they are free running and have little relation to the QCP pointers *
103 * @qcp_rd_p is a local copy queue controller peripheral read pointer
111 uint32_t tx_free_thresh;
114 * For each descriptor keep a reference to the mbuf and
115 * DMA address used until completion is signalled.
118 struct rte_mbuf *mbuf;
122 * Information about the host side queue location. @txds is
123 * the virtual address for the queue, @dma is the DMA address
124 * of the queue and @size is the size in bytes for the queue
127 struct nfp_net_tx_desc *txds;
130 * At this point 48 bytes have been used for all the fields in the
131 * TX critical path. We have room for 8 bytes and still all placed
132 * in a cache line. We are not using the threshold values below but
133 * if we need to, we can add the most used in the remaining bytes.
135 uint32_t tx_rs_thresh; /* not used by now. Future? */
136 uint32_t tx_pthresh; /* not used by now. Future? */
137 uint32_t tx_hthresh; /* not used by now. Future? */
138 uint32_t tx_wthresh; /* not used by now. Future? */
145 /* RX and freelist descriptor format */
146 #define PCIE_DESC_RX_DD (1 << 7)
147 #define PCIE_DESC_RX_META_LEN_MASK (0x7f)
149 /* Flags in the RX descriptor */
150 #define PCIE_DESC_RX_RSS (1 << 15)
151 #define PCIE_DESC_RX_I_IP4_CSUM (1 << 14)
152 #define PCIE_DESC_RX_I_IP4_CSUM_OK (1 << 13)
153 #define PCIE_DESC_RX_I_TCP_CSUM (1 << 12)
154 #define PCIE_DESC_RX_I_TCP_CSUM_OK (1 << 11)
155 #define PCIE_DESC_RX_I_UDP_CSUM (1 << 10)
156 #define PCIE_DESC_RX_I_UDP_CSUM_OK (1 << 9)
157 #define PCIE_DESC_RX_SPARE (1 << 8)
158 #define PCIE_DESC_RX_EOP (1 << 7)
159 #define PCIE_DESC_RX_IP4_CSUM (1 << 6)
160 #define PCIE_DESC_RX_IP4_CSUM_OK (1 << 5)
161 #define PCIE_DESC_RX_TCP_CSUM (1 << 4)
162 #define PCIE_DESC_RX_TCP_CSUM_OK (1 << 3)
163 #define PCIE_DESC_RX_UDP_CSUM (1 << 2)
164 #define PCIE_DESC_RX_UDP_CSUM_OK (1 << 1)
165 #define PCIE_DESC_RX_VLAN (1 << 0)
167 #define PCIE_DESC_RX_L4_CSUM_OK (PCIE_DESC_RX_TCP_CSUM_OK | \
168 PCIE_DESC_RX_UDP_CSUM_OK)
170 struct nfp_net_rx_desc {
172 /* Freelist descriptor */
195 struct nfp_net_rx_buff {
196 struct rte_mbuf *mbuf;
200 struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
203 * @qcp_fl and @qcp_rx are pointers to the base addresses of the
204 * freelist and RX queue controller peripheral queue structures on the
211 * Read and Write pointers. @wr_p and @rd_p are host side
212 * pointer, they are free running and have little relation to
213 * the QCP pointers. @wr_p is where the driver adds new
214 * freelist descriptors and @rd_p is where the driver start
215 * reading descriptors for newly arrive packets from.
220 * For each buffer placed on the freelist, record the
223 struct nfp_net_rx_buff *rxbufs;
226 * Information about the host side queue location. @rxds is
227 * the virtual address for the queue
229 struct nfp_net_rx_desc *rxds;
232 * The mempool is created by the user specifying a mbuf size.
233 * We save here the reference of the mempool needed in the RX
234 * path and the mbuf size for checking received packets can be
235 * safely copied to the mbuf using the NFP_NET_RX_OFFSET
237 struct rte_mempool *mem_pool;
241 * Next two fields are used for giving more free descriptors
244 uint16_t rx_free_thresh;
247 /* the size of the queue in number of descriptors */
251 * Fields above this point fit in a single cache line and are all used
252 * in the RX critical path. Fields below this point are just used
253 * during queue configuration or not used at all (yet)
256 /* referencing dev->data->port_id */
259 uint8_t crc_len; /* Not used by now */
260 uint8_t drop_en; /* Not used by now */
262 /* DMA address of the queue */
266 * Queue information: @qidx is the queue index from Linux's
267 * perspective. @fl_qcidx is the index of the Queue
268 * Controller peripheral queue relative to the RX queue BAR
269 * used for the freelist and @rx_qcidx is the Queue Controller
270 * Peripheral index for the RX queue.
277 int nfp_net_rx_freelist_setup(struct rte_eth_dev *dev);
278 uint32_t nfp_net_rx_queue_count(struct rte_eth_dev *dev,
280 uint16_t nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
282 void nfp_net_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
283 void nfp_net_reset_rx_queue(struct nfp_net_rxq *rxq);
284 int nfp_net_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
285 uint16_t nb_desc, unsigned int socket_id,
286 const struct rte_eth_rxconf *rx_conf,
287 struct rte_mempool *mp);
288 void nfp_net_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
289 void nfp_net_reset_tx_queue(struct nfp_net_txq *txq);
290 int nfp_net_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
291 uint16_t nb_desc, unsigned int socket_id,
292 const struct rte_eth_txconf *tx_conf);
293 uint16_t nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
296 #endif /* _NFP_RXTX_H_ */
299 * c-file-style: "Linux"
300 * indent-tabs-mode: t