Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _IAVF_RXTX_H_
6 : : #define _IAVF_RXTX_H_
7 : :
8 : : /* IAVF does not support 16-byte descriptors */
9 : : #ifdef RTE_NET_INTEL_USE_16BYTE_DESC
10 : : #undef RTE_NET_INTEL_USE_16BYTE_DESC
11 : : #endif
12 : :
13 : : #include "../common/rx.h"
14 : : #include "../common/tx.h"
15 : :
16 : : /* In QLEN must be whole number of 32 descriptors. */
17 : : #define IAVF_ALIGN_RING_DESC 32
18 : : #define IAVF_MIN_RING_DESC 64
19 : : #define IAVF_MAX_RING_DESC 4096
20 : : #define IAVF_DMA_MEM_ALIGN 4096
21 : : /* Base address of the HW descriptor ring should be 128B aligned. */
22 : : #define IAVF_RING_BASE_ALIGN 128
23 : :
24 : : /* used for Rx Bulk Allocate */
25 : : #define IAVF_RX_MAX_BURST CI_RX_MAX_BURST
26 : :
27 : : /* Max data buffer size must be 16K - 128 bytes */
28 : : #define IAVF_RX_MAX_DATA_BUF_SIZE (16 * 1024 - 128)
29 : :
30 : : /* used for Vector PMD */
31 : : #define IAVF_VPMD_RX_BURST CI_VPMD_RX_BURST
32 : : #define IAVF_VPMD_TX_BURST 32
33 : : #define IAVF_VPMD_RXQ_REARM_THRESH CI_VPMD_RX_REARM_THRESH
34 : : #define IAVF_VPMD_DESCS_PER_LOOP CI_VPMD_DESCS_PER_LOOP
35 : : #define IAVF_VPMD_DESCS_PER_LOOP_WIDE CI_VPMD_DESCS_PER_LOOP_WIDE
36 : : #define IAVF_VPMD_TX_MAX_FREE_BUF 64
37 : :
38 : : #define IAVF_TX_NO_VECTOR_FLAGS ( \
39 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \
40 : : RTE_ETH_TX_OFFLOAD_QINQ_INSERT | \
41 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
42 : : RTE_ETH_TX_OFFLOAD_TCP_TSO | \
43 : : RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | \
44 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | \
45 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | \
46 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | \
47 : : RTE_ETH_TX_OFFLOAD_SECURITY)
48 : :
49 : : #define IAVF_TX_VECTOR_OFFLOAD ( \
50 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \
51 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | \
52 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \
53 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)
54 : :
55 : : #define IAVF_TX_VECTOR_OFFLOAD_CTX ( \
56 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | \
57 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
58 : :
59 : : #define IAVF_RX_VECTOR_OFFLOAD ( \
60 : : RTE_ETH_RX_OFFLOAD_CHECKSUM | \
61 : : RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \
62 : : RTE_ETH_RX_OFFLOAD_VLAN | \
63 : : RTE_ETH_RX_OFFLOAD_RSS_HASH | \
64 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP)
65 : :
66 : : /**
67 : : * According to the vlan capabilities returned by the driver and FW, the vlan tci
68 : : * needs to be inserted to the L2TAG1 or L2TAG2 fields.
69 : : * If L2TAG1, it should be inserted to the L2TAG1 field in data desc.
70 : : * If L2TAG2, it should be inserted to the L2TAG2 field in ctx desc.
71 : : * Besides, tunneling parameters and other fields need be configured in ctx desc
72 : : * if the outer checksum offload is enabled.
73 : : */
74 : :
75 : : #define IAVF_VECTOR_PATH 0
76 : : #define IAVF_VECTOR_OFFLOAD_PATH 1
77 : : #define IAVF_VECTOR_CTX_OFFLOAD_PATH 2
78 : : #define IAVF_VECTOR_CTX_PATH 3
79 : :
80 : : #define DEFAULT_TX_RS_THRESH 32
81 : : #define DEFAULT_TX_FREE_THRESH 32
82 : :
83 : : #define IAVF_MIN_TSO_MSS 256
84 : : #define IAVF_MAX_TSO_MSS 9668
85 : : #define IAVF_TSO_MAX_SEG UINT8_MAX
86 : : #define IAVF_TX_MAX_MTU_SEG 8
87 : :
88 : : #define IAVF_TX_MIN_PKT_LEN 17
89 : :
90 : : #define IAVF_TX_CKSUM_OFFLOAD_MASK ( \
91 : : RTE_MBUF_F_TX_IP_CKSUM | \
92 : : RTE_MBUF_F_TX_L4_MASK | \
93 : : RTE_MBUF_F_TX_TCP_SEG | \
94 : : RTE_MBUF_F_TX_UDP_SEG | \
95 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
96 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM)
97 : :
98 : : #define IAVF_TX_OFFLOAD_MASK ( \
99 : : RTE_MBUF_F_TX_OUTER_IPV6 | \
100 : : RTE_MBUF_F_TX_OUTER_IPV4 | \
101 : : RTE_MBUF_F_TX_IPV6 | \
102 : : RTE_MBUF_F_TX_IPV4 | \
103 : : RTE_MBUF_F_TX_VLAN | \
104 : : RTE_MBUF_F_TX_IP_CKSUM | \
105 : : RTE_MBUF_F_TX_L4_MASK | \
106 : : RTE_MBUF_F_TX_TCP_SEG | \
107 : : RTE_MBUF_F_TX_UDP_SEG | \
108 : : RTE_MBUF_F_TX_TUNNEL_MASK | \
109 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM | \
110 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM | \
111 : : RTE_MBUF_F_TX_SEC_OFFLOAD)
112 : :
113 : : #define IAVF_TX_OFFLOAD_NOTSUP_MASK \
114 : : (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IAVF_TX_OFFLOAD_MASK)
115 : :
116 : : /* HW requires that TX buffer size ranges from 1B up to (16K-1)B. */
117 : : #define IAVF_MAX_DATA_PER_TXD \
118 : : (IAVF_TXD_QW1_TX_BUF_SZ_MASK >> IAVF_TXD_QW1_TX_BUF_SZ_SHIFT)
119 : :
120 : : #define IAVF_TX_LLDP_DYNFIELD "intel_pmd_dynfield_tx_lldp"
121 : : #define IAVF_CHECK_TX_LLDP(m) \
122 : : ((rte_pmd_iavf_tx_lldp_dynfield_offset > 0) && \
123 : : (*RTE_MBUF_DYNFIELD((m), \
124 : : rte_pmd_iavf_tx_lldp_dynfield_offset, \
125 : : uint8_t *)))
126 : :
127 : : extern uint64_t iavf_timestamp_dynflag;
128 : : extern int iavf_timestamp_dynfield_offset;
129 : : extern int rte_pmd_iavf_tx_lldp_dynfield_offset;
130 : :
131 : : typedef void (*iavf_rxd_to_pkt_fields_t)(struct ci_rx_queue *rxq,
132 : : struct rte_mbuf *mb,
133 : : volatile union ci_rx_flex_desc *rxdp);
134 : :
135 : : struct iavf_rxq_ops {
136 : : void (*release_mbufs)(struct ci_rx_queue *rxq);
137 : : };
138 : :
139 : : struct iavf_txq_ops {
140 : : void (*release_mbufs)(struct ci_tx_queue *txq);
141 : : };
142 : :
143 : :
144 : : struct iavf_rx_queue_stats {
145 : : uint64_t reserved;
146 : : struct iavf_ipsec_crypto_stats ipsec_crypto;
147 : : };
148 : :
149 : : /* Offload features */
150 : : union iavf_tx_offload {
151 : : uint64_t data;
152 : : struct {
153 : : uint64_t l2_len:7; /* L2 (MAC) Header Length. */
154 : : uint64_t l3_len:9; /* L3 (IP) Header Length. */
155 : : uint64_t l4_len:8; /* L4 Header Length. */
156 : : uint64_t tso_segsz:16; /* TCP TSO segment size */
157 : : /* uint64_t unused : 24; */
158 : : };
159 : : };
160 : :
161 : : /* Rx Flex Descriptor
162 : : * RxDID Profile ID 16-21
163 : : * Flex-field 0: RSS hash lower 16-bits
164 : : * Flex-field 1: RSS hash upper 16-bits
165 : : * Flex-field 2: Flow ID lower 16-bits
166 : : * Flex-field 3: Flow ID upper 16-bits
167 : : * Flex-field 4: AUX0
168 : : * Flex-field 5: AUX1
169 : : */
170 : : struct iavf_32b_rx_flex_desc_comms {
171 : : /* Qword 0 */
172 : : u8 rxdid;
173 : : u8 mir_id_umb_cast;
174 : : __le16 ptype_flexi_flags0;
175 : : __le16 pkt_len;
176 : : __le16 hdr_len_sph_flex_flags1;
177 : :
178 : : /* Qword 1 */
179 : : __le16 status_error0;
180 : : __le16 l2tag1;
181 : : __le32 rss_hash;
182 : :
183 : : /* Qword 2 */
184 : : __le16 status_error1;
185 : : u8 flexi_flags2;
186 : : u8 ts_low;
187 : : __le16 l2tag2_1st;
188 : : __le16 l2tag2_2nd;
189 : :
190 : : /* Qword 3 */
191 : : __le32 flow_id;
192 : : union {
193 : : struct {
194 : : __le16 aux0;
195 : : __le16 aux1;
196 : : } flex;
197 : : __le32 ts_high;
198 : : } flex_ts;
199 : : };
200 : :
201 : : /* Rx Flex Descriptor
202 : : * RxDID Profile ID 22-23 (swap Hash and FlowID)
203 : : * Flex-field 0: Flow ID lower 16-bits
204 : : * Flex-field 1: Flow ID upper 16-bits
205 : : * Flex-field 2: RSS hash lower 16-bits
206 : : * Flex-field 3: RSS hash upper 16-bits
207 : : * Flex-field 4: AUX0
208 : : * Flex-field 5: AUX1
209 : : */
210 : : struct iavf_32b_rx_flex_desc_comms_ovs {
211 : : /* Qword 0 */
212 : : u8 rxdid;
213 : : u8 mir_id_umb_cast;
214 : : __le16 ptype_flexi_flags0;
215 : : __le16 pkt_len;
216 : : __le16 hdr_len_sph_flex_flags1;
217 : :
218 : : /* Qword 1 */
219 : : __le16 status_error0;
220 : : __le16 l2tag1;
221 : : __le32 flow_id;
222 : :
223 : : /* Qword 2 */
224 : : __le16 status_error1;
225 : : u8 flexi_flags2;
226 : : u8 ts_low;
227 : : __le16 l2tag2_1st;
228 : : __le16 l2tag2_2nd;
229 : :
230 : : /* Qword 3 */
231 : : __le32 rss_hash;
232 : : union {
233 : : struct {
234 : : __le16 aux0;
235 : : __le16 aux1;
236 : : } flex;
237 : : __le32 ts_high;
238 : : } flex_ts;
239 : : };
240 : :
241 : : /* Rx Flex Descriptor
242 : : * RxDID Profile ID 24 Inline IPsec
243 : : * Flex-field 0: RSS hash lower 16-bits
244 : : * Flex-field 1: RSS hash upper 16-bits
245 : : * Flex-field 2: Flow ID lower 16-bits
246 : : * Flex-field 3: Flow ID upper 16-bits
247 : : * Flex-field 4: Inline IPsec SAID lower 16-bits
248 : : * Flex-field 5: Inline IPsec SAID upper 16-bits
249 : : */
250 : : struct iavf_32b_rx_flex_desc_comms_ipsec {
251 : : /* Qword 0 */
252 : : u8 rxdid;
253 : : u8 mir_id_umb_cast;
254 : : __le16 ptype_flexi_flags0;
255 : : __le16 pkt_len;
256 : : __le16 hdr_len_sph_flex_flags1;
257 : :
258 : : /* Qword 1 */
259 : : __le16 status_error0;
260 : : __le16 l2tag1;
261 : : __le32 rss_hash;
262 : :
263 : : /* Qword 2 */
264 : : __le16 status_error1;
265 : : u8 flexi_flags2;
266 : : u8 ts_low;
267 : : __le16 l2tag2_1st;
268 : : __le16 l2tag2_2nd;
269 : :
270 : : /* Qword 3 */
271 : : __le32 flow_id;
272 : : __le32 ipsec_said;
273 : : };
274 : :
275 : : enum iavf_rxtx_rel_mbufs_type {
276 : : IAVF_REL_MBUFS_DEFAULT = 0,
277 : : IAVF_REL_MBUFS_SSE_VEC = 1,
278 : : IAVF_REL_MBUFS_AVX512_VEC = 2,
279 : : IAVF_REL_MBUFS_NEON_VEC = 3,
280 : : };
281 : :
282 : : /* Receive Flex Descriptor profile IDs: There are a total
283 : : * of 64 profiles where profile IDs 0/1 are for legacy; and
284 : : * profiles 2-63 are flex profiles that can be programmed
285 : : * with a specific metadata (profile 7 reserved for HW)
286 : : */
287 : : enum iavf_rxdid {
288 : : IAVF_RXDID_LEGACY_0 = 0,
289 : : IAVF_RXDID_LEGACY_1 = 1,
290 : : IAVF_RXDID_FLEX_NIC = 2,
291 : : IAVF_RXDID_FLEX_NIC_2 = 6,
292 : : IAVF_RXDID_HW = 7,
293 : : IAVF_RXDID_COMMS_GENERIC = 16,
294 : : IAVF_RXDID_COMMS_AUX_VLAN = 17,
295 : : IAVF_RXDID_COMMS_AUX_IPV4 = 18,
296 : : IAVF_RXDID_COMMS_AUX_IPV6 = 19,
297 : : IAVF_RXDID_COMMS_AUX_IPV6_FLOW = 20,
298 : : IAVF_RXDID_COMMS_AUX_TCP = 21,
299 : : IAVF_RXDID_COMMS_OVS_1 = 22,
300 : : IAVF_RXDID_COMMS_OVS_2 = 23,
301 : : IAVF_RXDID_COMMS_IPSEC_CRYPTO = 24,
302 : : IAVF_RXDID_COMMS_AUX_IP_OFFSET = 25,
303 : : IAVF_RXDID_LAST = 63,
304 : : };
305 : :
306 : : enum iavf_rx_flex_desc_status_error_0_bits {
307 : : /* Note: These are predefined bit offsets */
308 : : IAVF_RX_FLEX_DESC_STATUS0_DD_S = 0,
309 : : IAVF_RX_FLEX_DESC_STATUS0_EOF_S,
310 : : IAVF_RX_FLEX_DESC_STATUS0_HBO_S,
311 : : IAVF_RX_FLEX_DESC_STATUS0_L3L4P_S,
312 : : IAVF_RX_FLEX_DESC_STATUS0_XSUM_IPE_S,
313 : : IAVF_RX_FLEX_DESC_STATUS0_XSUM_L4E_S,
314 : : IAVF_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S,
315 : : IAVF_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S,
316 : : IAVF_RX_FLEX_DESC_STATUS0_LPBK_S,
317 : : IAVF_RX_FLEX_DESC_STATUS0_IPV6EXADD_S,
318 : : IAVF_RX_FLEX_DESC_STATUS0_RXE_S,
319 : : IAVF_RX_FLEX_DESC_STATUS0_CRCP_S,
320 : : IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S,
321 : : IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S,
322 : : IAVF_RX_FLEX_DESC_STATUS0_XTRMD0_VALID_S,
323 : : IAVF_RX_FLEX_DESC_STATUS0_XTRMD1_VALID_S,
324 : : IAVF_RX_FLEX_DESC_STATUS0_LAST /* this entry must be last!!! */
325 : : };
326 : :
327 : : enum iavf_rx_flex_desc_status_error_1_bits {
328 : : /* Note: These are predefined bit offsets */
329 : : /* Bits 3:0 are reserved for inline ipsec status */
330 : : IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_0 = 0,
331 : : IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_1,
332 : : IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_2,
333 : : IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_3,
334 : : IAVF_RX_FLEX_DESC_STATUS1_NAT_S,
335 : : IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_PROCESSED,
336 : : /* [10:6] reserved */
337 : : IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S = 11,
338 : : IAVF_RX_FLEX_DESC_STATUS1_XTRMD2_VALID_S = 12,
339 : : IAVF_RX_FLEX_DESC_STATUS1_XTRMD3_VALID_S = 13,
340 : : IAVF_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S = 14,
341 : : IAVF_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S = 15,
342 : : IAVF_RX_FLEX_DESC_STATUS1_LAST /* this entry must be last!!! */
343 : : };
344 : :
345 : : #define IAVF_RX_FLEX_DESC_IPSEC_CRYPTO_STATUS_MASK ( \
346 : : BIT(IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_0) | \
347 : : BIT(IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_1) | \
348 : : BIT(IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_2) | \
349 : : BIT(IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_STATUS_3))
350 : :
351 : : enum iavf_rx_flex_desc_ipsec_crypto_status {
352 : : IAVF_IPSEC_CRYPTO_STATUS_SUCCESS = 0,
353 : : IAVF_IPSEC_CRYPTO_STATUS_SAD_MISS,
354 : : IAVF_IPSEC_CRYPTO_STATUS_NOT_PROCESSED,
355 : : IAVF_IPSEC_CRYPTO_STATUS_ICV_CHECK_FAIL,
356 : : IAVF_IPSEC_CRYPTO_STATUS_LENGTH_ERR,
357 : : /* Reserved */
358 : : IAVF_IPSEC_CRYPTO_STATUS_MISC_ERR = 0xF
359 : : };
360 : :
361 : :
362 : :
363 : : #define IAVF_TXD_DATA_QW1_DTYPE_SHIFT (0)
364 : : #define IAVF_TXD_DATA_QW1_DTYPE_MASK (0xFUL << IAVF_TXD_QW1_DTYPE_SHIFT)
365 : :
366 : : #define IAVF_TXD_DATA_QW1_CMD_SHIFT (4)
367 : : #define IAVF_TXD_DATA_QW1_CMD_MASK (0x3FFUL << IAVF_TXD_DATA_QW1_CMD_SHIFT)
368 : :
369 : : #define IAVF_TXD_DATA_QW1_OFFSET_SHIFT (16)
370 : : #define IAVF_TXD_DATA_QW1_OFFSET_MASK (0x3FFFFULL << \
371 : : IAVF_TXD_DATA_QW1_OFFSET_SHIFT)
372 : :
373 : : #define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT (IAVF_TXD_DATA_QW1_OFFSET_SHIFT)
374 : : #define IAVF_TXD_DATA_QW1_OFFSET_MACLEN_MASK \
375 : : (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_MACLEN_SHIFT)
376 : :
377 : : #define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT \
378 : : (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_IPLEN_SHIFT)
379 : : #define IAVF_TXD_DATA_QW1_OFFSET_IPLEN_MASK \
380 : : (0x7FUL << IAVF_TXD_DATA_QW1_OFFSET_IPLEN_SHIFT)
381 : :
382 : : #define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT \
383 : : (IAVF_TXD_DATA_QW1_OFFSET_SHIFT + IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT)
384 : : #define IAVF_TXD_DATA_QW1_OFFSET_L4LEN_MASK \
385 : : (0xFUL << IAVF_TXD_DATA_QW1_OFFSET_L4LEN_SHIFT)
386 : :
387 : : #define IAVF_TXD_DATA_QW1_MACLEN_MASK \
388 : : (0x7FUL << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT)
389 : : #define IAVF_TXD_DATA_QW1_IPLEN_MASK \
390 : : (0x7FUL << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT)
391 : : #define IAVF_TXD_DATA_QW1_L4LEN_MASK \
392 : : (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT)
393 : : #define IAVF_TXD_DATA_QW1_FCLEN_MASK \
394 : : (0xFUL << IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT)
395 : :
396 : : #define IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT (34)
397 : : #define IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK \
398 : : (0x3FFFULL << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT)
399 : :
400 : : #define IAVF_TXD_DATA_QW1_L2TAG1_SHIFT (48)
401 : : #define IAVF_TXD_DATA_QW1_L2TAG1_MASK \
402 : : (0xFFFFULL << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT)
403 : :
404 : : #define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT (11)
405 : : #define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_MASK \
406 : : (0x7UL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT)
407 : :
408 : : #define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT (14)
409 : : #define IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_MASK \
410 : : (0xFUL << IAVF_TXD_CTX_QW1_IPSEC_PARAMS_ICVLEN_SHIFT)
411 : :
412 : : #define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT (30)
413 : : #define IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_MASK \
414 : : (0x3FFFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT)
415 : :
416 : : #define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_SHIFT (30)
417 : : #define IAVF_TXD_CTX_QW1_TSYNC_PARAMS_TLEN_MASK \
418 : : (0x3FUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_TLEN_SHIFT)
419 : :
420 : : #define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT (50)
421 : : #define IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_MASK \
422 : : (0x3FFFUL << IAVF_TXD_CTX_QW1_SEG_PARAMS_MSS_SHIFT)
423 : :
424 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT (0)
425 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_MASK (0x3UL)
426 : :
427 : : enum iavf_tx_ctx_desc_tunnel_external_ip_type {
428 : : IAVF_TX_CTX_DESC_EIPT_NONE,
429 : : IAVF_TX_CTX_DESC_EIPT_IPV6,
430 : : IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD,
431 : : IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD
432 : : };
433 : :
434 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT (2)
435 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_MASK (0x7FUL)
436 : :
437 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_SHIFT (9)
438 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNT_MASK (0x3UL)
439 : :
440 : : enum iavf_tx_ctx_desc_tunnel_l4_tunnel_type {
441 : : IAVF_TX_CTX_DESC_L4_TUN_TYP_NO_UDP_GRE,
442 : : IAVF_TX_CTX_DESC_L4_TUN_TYP_UDP,
443 : : IAVF_TX_CTX_DESC_L4_TUN_TYP_GRE
444 : : };
445 : :
446 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT (11)
447 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_MASK (0x1UL)
448 : :
449 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_SHIFT (12)
450 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4TUNLEN_MASK (0x7FUL)
451 : :
452 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_SHIFT (19)
453 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_DECTTL_MASK (0xFUL)
454 : :
455 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_SHIFT (23)
456 : : #define IAVF_TXD_CTX_QW0_TUN_PARAMS_L4T_CS_MASK (0x1UL)
457 : :
458 : : #define IAVF_TXD_CTX_QW0_L2TAG2_PARAM (32)
459 : : #define IAVF_TXD_CTX_QW0_L2TAG2_MASK (0xFFFFUL)
460 : :
461 : :
462 : : #define IAVF_RX_FLEX_DESC_IPSEC_CRYPTO_SAID_MASK (0xFFFFF)
463 : :
464 : : /* for iavf_32b_rx_flex_desc.ptype_flex_flags0 member */
465 : : #define IAVF_RX_FLEX_DESC_PTYPE_M (0x3FF) /* 10-bits */
466 : :
467 : :
468 : : /* for iavf_32b_rx_flex_desc.ptype_flex_flags0 member */
469 : : #define IAVF_RX_FLEX_DESC_PTYPE_M (0x3FF) /* 10-bits */
470 : :
471 : : /* for iavf_32b_rx_flex_desc.pkt_len member */
472 : : #define IAVF_RX_FLX_DESC_PKT_LEN_M (0x3FFF) /* 14-bits */
473 : :
474 : : int iavf_dev_rx_queue_setup(struct rte_eth_dev *dev,
475 : : uint16_t queue_idx,
476 : : uint16_t nb_desc,
477 : : unsigned int socket_id,
478 : : const struct rte_eth_rxconf *rx_conf,
479 : : struct rte_mempool *mp);
480 : :
481 : : int iavf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
482 : : int iavf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
483 : : void iavf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
484 : : int iavf_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
485 : : struct rte_eth_burst_mode *mode);
486 : : int iavf_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
487 : : struct rte_eth_burst_mode *mode);
488 : : int iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
489 : : uint16_t queue_idx,
490 : : uint16_t nb_desc,
491 : : unsigned int socket_id,
492 : : const struct rte_eth_txconf *tx_conf);
493 : : int iavf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
494 : : int iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
495 : : int iavf_dev_tx_done_cleanup(void *txq, uint32_t free_cnt);
496 : : void iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid);
497 : : void iavf_stop_queues(struct rte_eth_dev *dev);
498 : : uint16_t iavf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
499 : : uint16_t nb_pkts);
500 : : uint16_t iavf_recv_pkts_flex_rxd(void *rx_queue,
501 : : struct rte_mbuf **rx_pkts,
502 : : uint16_t nb_pkts);
503 : : uint16_t iavf_recv_scattered_pkts(void *rx_queue,
504 : : struct rte_mbuf **rx_pkts,
505 : : uint16_t nb_pkts);
506 : : uint16_t iavf_recv_scattered_pkts_flex_rxd(void *rx_queue,
507 : : struct rte_mbuf **rx_pkts,
508 : : uint16_t nb_pkts);
509 : : uint16_t iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
510 : : uint16_t nb_pkts);
511 : : uint16_t iavf_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
512 : : uint16_t nb_pkts);
513 : : void iavf_set_rx_function(struct rte_eth_dev *dev);
514 : : void iavf_set_tx_function(struct rte_eth_dev *dev);
515 : : void iavf_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
516 : : struct rte_eth_rxq_info *qinfo);
517 : : void iavf_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
518 : : struct rte_eth_txq_info *qinfo);
519 : : uint32_t iavf_dev_rxq_count(void *rx_queue);
520 : : int iavf_dev_rx_desc_status(void *rx_queue, uint16_t offset);
521 : : int iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset);
522 : :
523 : : uint16_t iavf_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
524 : : uint16_t nb_pkts);
525 : : uint16_t iavf_recv_pkts_vec_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts,
526 : : uint16_t nb_pkts);
527 : : uint16_t iavf_recv_scattered_pkts_vec(void *rx_queue,
528 : : struct rte_mbuf **rx_pkts,
529 : : uint16_t nb_pkts);
530 : : uint16_t iavf_recv_scattered_pkts_vec_flex_rxd(void *rx_queue,
531 : : struct rte_mbuf **rx_pkts,
532 : : uint16_t nb_pkts);
533 : : uint16_t iavf_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
534 : : uint16_t nb_pkts);
535 : : uint16_t iavf_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts,
536 : : uint16_t nb_pkts);
537 : : uint16_t iavf_recv_pkts_vec_avx2_offload(void *rx_queue, struct rte_mbuf **rx_pkts,
538 : : uint16_t nb_pkts);
539 : : uint16_t iavf_recv_pkts_vec_avx2_flex_rxd(void *rx_queue,
540 : : struct rte_mbuf **rx_pkts,
541 : : uint16_t nb_pkts);
542 : : uint16_t iavf_recv_pkts_vec_avx2_flex_rxd_offload(void *rx_queue,
543 : : struct rte_mbuf **rx_pkts,
544 : : uint16_t nb_pkts);
545 : : uint16_t iavf_recv_scattered_pkts_vec_avx2(void *rx_queue,
546 : : struct rte_mbuf **rx_pkts,
547 : : uint16_t nb_pkts);
548 : : uint16_t iavf_recv_scattered_pkts_vec_avx2_offload(void *rx_queue,
549 : : struct rte_mbuf **rx_pkts,
550 : : uint16_t nb_pkts);
551 : : uint16_t iavf_recv_scattered_pkts_vec_avx2_flex_rxd(void *rx_queue,
552 : : struct rte_mbuf **rx_pkts,
553 : : uint16_t nb_pkts);
554 : : uint16_t iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload(void *rx_queue,
555 : : struct rte_mbuf **rx_pkts,
556 : : uint16_t nb_pkts);
557 : : uint16_t iavf_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
558 : : uint16_t nb_pkts);
559 : : uint16_t iavf_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
560 : : uint16_t nb_pkts);
561 : : uint16_t iavf_xmit_pkts_vec_avx2_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
562 : : uint16_t nb_pkts);
563 : : int iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc);
564 : : int iavf_rx_vec_dev_check(struct rte_eth_dev *dev);
565 : : int iavf_tx_vec_dev_check(struct rte_eth_dev *dev);
566 : : int iavf_rxq_vec_setup(struct ci_rx_queue *rxq);
567 : : int iavf_txq_vec_setup(struct ci_tx_queue *txq);
568 : : uint16_t iavf_recv_pkts_vec_avx512(void *rx_queue, struct rte_mbuf **rx_pkts,
569 : : uint16_t nb_pkts);
570 : : uint16_t iavf_recv_pkts_vec_avx512_offload(void *rx_queue,
571 : : struct rte_mbuf **rx_pkts,
572 : : uint16_t nb_pkts);
573 : : uint16_t iavf_recv_pkts_vec_avx512_flex_rxd(void *rx_queue,
574 : : struct rte_mbuf **rx_pkts,
575 : : uint16_t nb_pkts);
576 : : uint16_t iavf_recv_pkts_vec_avx512_flex_rxd_offload(void *rx_queue,
577 : : struct rte_mbuf **rx_pkts,
578 : : uint16_t nb_pkts);
579 : : uint16_t iavf_recv_scattered_pkts_vec_avx512(void *rx_queue,
580 : : struct rte_mbuf **rx_pkts,
581 : : uint16_t nb_pkts);
582 : : uint16_t iavf_recv_scattered_pkts_vec_avx512_offload(void *rx_queue,
583 : : struct rte_mbuf **rx_pkts,
584 : : uint16_t nb_pkts);
585 : : uint16_t iavf_recv_scattered_pkts_vec_avx512_flex_rxd(void *rx_queue,
586 : : struct rte_mbuf **rx_pkts,
587 : : uint16_t nb_pkts);
588 : : uint16_t iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload(void *rx_queue,
589 : : struct rte_mbuf **rx_pkts,
590 : : uint16_t nb_pkts);
591 : : uint16_t iavf_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
592 : : uint16_t nb_pkts);
593 : : uint16_t iavf_xmit_pkts_vec_avx512_offload(void *tx_queue,
594 : : struct rte_mbuf **tx_pkts,
595 : : uint16_t nb_pkts);
596 : : uint16_t iavf_xmit_pkts_vec_avx512_ctx_offload(void *tx_queue, struct rte_mbuf **tx_pkts,
597 : : uint16_t nb_pkts);
598 : : uint16_t iavf_xmit_pkts_vec_avx512_ctx(void *tx_queue, struct rte_mbuf **tx_pkts,
599 : : uint16_t nb_pkts);
600 : : int iavf_txq_vec_setup_avx512(struct ci_tx_queue *txq);
601 : :
602 : : uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
603 : :
604 : : void iavf_set_default_ptype_table(struct rte_eth_dev *dev);
605 : : void iavf_tx_queue_release_mbufs_avx512(struct ci_tx_queue *txq);
606 : : void iavf_rx_queue_release_mbufs_sse(struct ci_rx_queue *rxq);
607 : : void iavf_tx_queue_release_mbufs_sse(struct ci_tx_queue *txq);
608 : : void iavf_rx_queue_release_mbufs_neon(struct ci_rx_queue *rxq);
609 : :
610 : : static inline
611 : : void iavf_dump_rx_descriptor(struct ci_rx_queue *rxq,
612 : : const volatile void *desc,
613 : : uint16_t rx_id)
614 : : {
615 : : const volatile union ci_rx_desc *rx_desc = desc;
616 : :
617 : : printf("Queue %d Rx_desc %d: QW0: 0x%016"PRIx64" QW1: 0x%016"PRIx64
618 : : " QW2: 0x%016"PRIx64" QW3: 0x%016"PRIx64"\n", rxq->queue_id,
619 : : rx_id, rx_desc->read.pkt_addr, rx_desc->read.hdr_addr,
620 : : rx_desc->read.rsvd1, rx_desc->read.rsvd2);
621 : : }
622 : :
623 : : /* All the descriptors are 16 bytes, so just use one of them
624 : : * to print the qwords
625 : : */
626 : : static inline
627 : : void iavf_dump_tx_descriptor(const struct ci_tx_queue *txq,
628 : : const volatile void *desc, uint16_t tx_id)
629 : : {
630 : : const char *name;
631 : : const volatile struct iavf_tx_desc *tx_desc = desc;
632 : : enum iavf_tx_desc_dtype_value type;
633 : :
634 : :
635 : : type = (enum iavf_tx_desc_dtype_value)
636 : : rte_le_to_cpu_64(tx_desc->cmd_type_offset_bsz &
637 : : rte_cpu_to_le_64(IAVF_TXD_DATA_QW1_DTYPE_MASK));
638 : : switch (type) {
639 : : case IAVF_TX_DESC_DTYPE_DATA:
640 : : name = "Tx_data_desc";
641 : : break;
642 : : case IAVF_TX_DESC_DTYPE_CONTEXT:
643 : : name = "Tx_context_desc";
644 : : break;
645 : : case IAVF_TX_DESC_DTYPE_IPSEC:
646 : : name = "Tx_IPsec_desc";
647 : : break;
648 : : default:
649 : : name = "unknown_desc";
650 : : break;
651 : : }
652 : :
653 : : printf("Queue %d %s %d: QW0: 0x%016"PRIx64" QW1: 0x%016"PRIx64"\n",
654 : : txq->queue_id, name, tx_id, tx_desc->buffer_addr,
655 : : tx_desc->cmd_type_offset_bsz);
656 : : }
657 : :
658 : : #define FDIR_PROC_ENABLE_PER_QUEUE(ad, on) do { \
659 : : int i; \
660 : : for (i = 0; i < (ad)->dev_data->nb_rx_queues; i++) { \
661 : : struct ci_rx_queue *rxq = (ad)->dev_data->rx_queues[i]; \
662 : : if (!rxq) \
663 : : continue; \
664 : : rxq->fdir_enabled = on; \
665 : : } \
666 : : PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
667 : : } while (0)
668 : :
669 : : /* Enable/disable flow director Rx processing in data path. */
670 : : static inline
671 : 0 : void iavf_fdir_rx_proc_enable(struct iavf_adapter *ad, bool on)
672 : : {
673 [ # # ]: 0 : if (on) {
674 : : /* enable flow director processing */
675 [ # # # # ]: 0 : FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
676 : 0 : ad->fdir_ref_cnt++;
677 : : } else {
678 [ # # ]: 0 : if (ad->fdir_ref_cnt >= 1) {
679 : 0 : ad->fdir_ref_cnt--;
680 : :
681 [ # # ]: 0 : if (ad->fdir_ref_cnt == 0)
682 [ # # # # ]: 0 : FDIR_PROC_ENABLE_PER_QUEUE(ad, on);
683 : : }
684 : : }
685 : 0 : }
686 : :
687 : : static inline
688 : : uint64_t iavf_tstamp_convert_32b_64b(uint64_t time, uint32_t in_timestamp)
689 : : {
690 : : const uint64_t mask = 0xFFFFFFFF;
691 : : uint32_t delta;
692 : : uint64_t ns;
693 : :
694 : 0 : delta = (in_timestamp - (uint32_t)(time & mask));
695 [ # # # # : 0 : if (delta > (mask / 2)) {
# # ]
696 : 0 : delta = ((uint32_t)(time & mask) - in_timestamp);
697 : 0 : ns = time - delta;
698 : : } else {
699 : 0 : ns = time + delta;
700 : : }
701 : :
702 : : return ns;
703 : : }
704 : :
705 : : #ifdef RTE_LIBRTE_IAVF_DEBUG_DUMP_DESC
706 : : #define IAVF_DUMP_RX_DESC(rxq, desc, rx_id) \
707 : : iavf_dump_rx_descriptor(rxq, desc, rx_id)
708 : : #define IAVF_DUMP_TX_DESC(txq, desc, tx_id) \
709 : : iavf_dump_tx_descriptor(txq, desc, tx_id)
710 : : #else
711 : : #define IAVF_DUMP_RX_DESC(rxq, desc, rx_id) do { } while (0)
712 : : #define IAVF_DUMP_TX_DESC(txq, desc, tx_id) do { } while (0)
713 : : #endif
714 : :
715 : : #endif /* _IAVF_RXTX_H_ */
|