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>
21 * The maximum number of descriptors is limited by design as
22 * DPDK uses uint16_t variables for these values
24 #define NFP_NET_MAX_TX_DESC (32 * 1024)
25 #define NFP_NET_MIN_TX_DESC 64
27 #define NFP_NET_MAX_RX_DESC (32 * 1024)
28 #define NFP_NET_MIN_RX_DESC 64
30 /* Descriptor alignment */
31 #define NFP_ALIGN_RING_DESC 128
33 /* TX descriptor format */
34 #define PCIE_DESC_TX_EOP (1 << 7)
35 #define PCIE_DESC_TX_OFFSET_MASK (0x7f)
37 /* Flags in the host TX descriptor */
38 #define PCIE_DESC_TX_CSUM (1 << 7)
39 #define PCIE_DESC_TX_IP4_CSUM (1 << 6)
40 #define PCIE_DESC_TX_TCP_CSUM (1 << 5)
41 #define PCIE_DESC_TX_UDP_CSUM (1 << 4)
42 #define PCIE_DESC_TX_VLAN (1 << 3)
43 #define PCIE_DESC_TX_LSO (1 << 2)
44 #define PCIE_DESC_TX_ENCAP_NONE (0)
45 #define PCIE_DESC_TX_ENCAP_VXLAN (1 << 1)
46 #define PCIE_DESC_TX_ENCAP_GRE (1 << 0)
48 struct nfp_net_tx_desc {
51 uint8_t dma_addr_hi; /* High bits of host buf address */
52 __le16 dma_len; /* Length to DMA for this desc */
53 uint8_t offset_eop; /* Offset in buf where pkt starts +
54 * highest bit is eop flag.
56 __le32 dma_addr_lo; /* Low 32bit of host buf addr */
58 __le16 mss; /* MSS to be used for LSO */
59 uint8_t lso_hdrlen; /* LSO, where the data starts */
60 uint8_t flags; /* TX Flags, see @PCIE_DESC_TX_* */
65 * L3 and L4 header offsets required
71 __le16 vlan; /* VLAN tag to add if indicated */
73 __le16 data_len; /* Length of frame + meta data */
80 struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
83 * Queue information: @qidx is the queue index from Linux's
84 * perspective. @tx_qcidx is the index of the Queue
85 * Controller Peripheral queue relative to the TX queue BAR.
86 * @cnt is the size of the queue in number of
87 * descriptors. @qcp_q is a pointer to the base of the queue
88 * structure on the NFP
93 * Read and Write pointers. @wr_p and @rd_p are host side pointer,
94 * they are free running and have little relation to the QCP pointers *
95 * @qcp_rd_p is a local copy queue controller peripheral read pointer
103 uint32_t tx_free_thresh;
106 * For each descriptor keep a reference to the mbuf and
107 * DMA address used until completion is signalled.
110 struct rte_mbuf *mbuf;
114 * Information about the host side queue location. @txds is
115 * the virtual address for the queue, @dma is the DMA address
116 * of the queue and @size is the size in bytes for the queue
119 struct nfp_net_tx_desc *txds;
122 * At this point 48 bytes have been used for all the fields in the
123 * TX critical path. We have room for 8 bytes and still all placed
124 * in a cache line. We are not using the threshold values below but
125 * if we need to, we can add the most used in the remaining bytes.
127 uint32_t tx_rs_thresh; /* not used by now. Future? */
128 uint32_t tx_pthresh; /* not used by now. Future? */
129 uint32_t tx_hthresh; /* not used by now. Future? */
130 uint32_t tx_wthresh; /* not used by now. Future? */
137 /* RX and freelist descriptor format */
138 #define PCIE_DESC_RX_DD (1 << 7)
139 #define PCIE_DESC_RX_META_LEN_MASK (0x7f)
141 /* Flags in the RX descriptor */
142 #define PCIE_DESC_RX_RSS (1 << 15)
143 #define PCIE_DESC_RX_I_IP4_CSUM (1 << 14)
144 #define PCIE_DESC_RX_I_IP4_CSUM_OK (1 << 13)
145 #define PCIE_DESC_RX_I_TCP_CSUM (1 << 12)
146 #define PCIE_DESC_RX_I_TCP_CSUM_OK (1 << 11)
147 #define PCIE_DESC_RX_I_UDP_CSUM (1 << 10)
148 #define PCIE_DESC_RX_I_UDP_CSUM_OK (1 << 9)
149 #define PCIE_DESC_RX_SPARE (1 << 8)
150 #define PCIE_DESC_RX_EOP (1 << 7)
151 #define PCIE_DESC_RX_IP4_CSUM (1 << 6)
152 #define PCIE_DESC_RX_IP4_CSUM_OK (1 << 5)
153 #define PCIE_DESC_RX_TCP_CSUM (1 << 4)
154 #define PCIE_DESC_RX_TCP_CSUM_OK (1 << 3)
155 #define PCIE_DESC_RX_UDP_CSUM (1 << 2)
156 #define PCIE_DESC_RX_UDP_CSUM_OK (1 << 1)
157 #define PCIE_DESC_RX_VLAN (1 << 0)
159 #define PCIE_DESC_RX_L4_CSUM_OK (PCIE_DESC_RX_TCP_CSUM_OK | \
160 PCIE_DESC_RX_UDP_CSUM_OK)
162 struct nfp_net_rx_desc {
164 /* Freelist descriptor */
187 struct nfp_net_rx_buff {
188 struct rte_mbuf *mbuf;
192 struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
195 * @qcp_fl and @qcp_rx are pointers to the base addresses of the
196 * freelist and RX queue controller peripheral queue structures on the
203 * Read and Write pointers. @wr_p and @rd_p are host side
204 * pointer, they are free running and have little relation to
205 * the QCP pointers. @wr_p is where the driver adds new
206 * freelist descriptors and @rd_p is where the driver start
207 * reading descriptors for newly arrive packets from.
212 * For each buffer placed on the freelist, record the
215 struct nfp_net_rx_buff *rxbufs;
218 * Information about the host side queue location. @rxds is
219 * the virtual address for the queue
221 struct nfp_net_rx_desc *rxds;
224 * The mempool is created by the user specifying a mbuf size.
225 * We save here the reference of the mempool needed in the RX
226 * path and the mbuf size for checking received packets can be
227 * safely copied to the mbuf using the NFP_NET_RX_OFFSET
229 struct rte_mempool *mem_pool;
233 * Next two fields are used for giving more free descriptors
236 uint16_t rx_free_thresh;
239 /* the size of the queue in number of descriptors */
243 * Fields above this point fit in a single cache line and are all used
244 * in the RX critical path. Fields below this point are just used
245 * during queue configuration or not used at all (yet)
248 /* referencing dev->data->port_id */
251 uint8_t crc_len; /* Not used by now */
252 uint8_t drop_en; /* Not used by now */
254 /* DMA address of the queue */
258 * Queue information: @qidx is the queue index from Linux's
259 * perspective. @fl_qcidx is the index of the Queue
260 * Controller peripheral queue relative to the RX queue BAR
261 * used for the freelist and @rx_qcidx is the Queue Controller
262 * Peripheral index for the RX queue.
269 #endif /* _NFP_RXTX_H_ */
272 * c-file-style: "Linux"
273 * indent-tabs-mode: t