4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 #include <sys/queue.h>
44 #include <rte_string_fns.h>
45 #include <rte_memzone.h>
47 #include <rte_malloc.h>
48 #include <rte_ether.h>
49 #include <rte_ethdev.h>
54 #include "i40e_logs.h"
55 #include "base/i40e_prototype.h"
56 #include "base/i40e_type.h"
57 #include "i40e_ethdev.h"
58 #include "i40e_rxtx.h"
60 #define DEFAULT_TX_RS_THRESH 32
61 #define DEFAULT_TX_FREE_THRESH 32
62 #define I40E_MAX_PKT_TYPE 256
64 #define I40E_TX_MAX_BURST 32
66 #define I40E_DMA_MEM_ALIGN 4096
68 /* Base address of the HW descriptor ring should be 128B aligned. */
69 #define I40E_RING_BASE_ALIGN 128
71 #define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
72 ETH_TXQ_FLAGS_NOOFFLOADS)
74 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
76 #define I40E_TX_CKSUM_OFFLOAD_MASK ( \
79 PKT_TX_OUTER_IP_CKSUM)
81 static uint16_t i40e_xmit_pkts_simple(void *tx_queue,
82 struct rte_mbuf **tx_pkts,
86 i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
88 if (rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
89 (1 << I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)) {
90 mb->ol_flags |= PKT_RX_VLAN_PKT;
92 rte_le_to_cpu_16(rxdp->wb.qword0.lo_dword.l2tag1);
93 PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
94 rte_le_to_cpu_16(rxdp->wb.qword0.lo_dword.l2tag1));
98 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
99 if (rte_le_to_cpu_16(rxdp->wb.qword2.ext_status) &
100 (1 << I40E_RX_DESC_EXT_STATUS_L2TAG2P_SHIFT)) {
101 mb->ol_flags |= PKT_RX_QINQ_PKT;
102 mb->vlan_tci_outer = mb->vlan_tci;
103 mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.qword2.l2tag2_2);
104 PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
105 rte_le_to_cpu_16(rxdp->wb.qword2.l2tag2_1),
106 rte_le_to_cpu_16(rxdp->wb.qword2.l2tag2_2));
108 mb->vlan_tci_outer = 0;
111 PMD_RX_LOG(DEBUG, "Mbuf vlan_tci: %u, vlan_tci_outer: %u",
112 mb->vlan_tci, mb->vlan_tci_outer);
115 /* Translate the rx descriptor status to pkt flags */
116 static inline uint64_t
117 i40e_rxd_status_to_pkt_flags(uint64_t qword)
121 /* Check if RSS_HASH */
122 flags = (((qword >> I40E_RX_DESC_STATUS_FLTSTAT_SHIFT) &
123 I40E_RX_DESC_FLTSTAT_RSS_HASH) ==
124 I40E_RX_DESC_FLTSTAT_RSS_HASH) ? PKT_RX_RSS_HASH : 0;
126 /* Check if FDIR Match */
127 flags |= (qword & (1 << I40E_RX_DESC_STATUS_FLM_SHIFT) ?
133 static inline uint64_t
134 i40e_rxd_error_to_pkt_flags(uint64_t qword)
137 uint64_t error_bits = (qword >> I40E_RXD_QW1_ERROR_SHIFT);
139 #define I40E_RX_ERR_BITS 0x3f
140 if (likely((error_bits & I40E_RX_ERR_BITS) == 0))
142 /* If RXE bit set, all other status bits are meaningless */
143 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_RXE_SHIFT))) {
144 flags |= PKT_RX_MAC_ERR;
148 /* If RECIPE bit set, all other status indications should be ignored */
149 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_RECIPE_SHIFT))) {
150 flags |= PKT_RX_RECIP_ERR;
153 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_HBO_SHIFT)))
154 flags |= PKT_RX_HBUF_OVERFLOW;
155 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_IPE_SHIFT)))
156 flags |= PKT_RX_IP_CKSUM_BAD;
157 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_L4E_SHIFT)))
158 flags |= PKT_RX_L4_CKSUM_BAD;
159 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_EIPE_SHIFT)))
160 flags |= PKT_RX_EIP_CKSUM_BAD;
161 if (unlikely(error_bits & (1 << I40E_RX_DESC_ERROR_OVERSIZE_SHIFT)))
162 flags |= PKT_RX_OVERSIZE;
167 /* Function to check and set the ieee1588 timesync index and get the
170 #ifdef RTE_LIBRTE_IEEE1588
171 static inline uint64_t
172 i40e_get_iee15888_flags(struct rte_mbuf *mb, uint64_t qword)
174 uint64_t pkt_flags = 0;
175 uint16_t tsyn = (qword & (I40E_RXD_QW1_STATUS_TSYNVALID_MASK
176 | I40E_RXD_QW1_STATUS_TSYNINDX_MASK))
177 >> I40E_RX_DESC_STATUS_TSYNINDX_SHIFT;
179 if ((mb->packet_type & RTE_PTYPE_L2_MASK)
180 == RTE_PTYPE_L2_ETHER_TIMESYNC)
181 pkt_flags = PKT_RX_IEEE1588_PTP;
183 pkt_flags |= PKT_RX_IEEE1588_TMST;
184 mb->timesync = tsyn & 0x03;
191 /* For each value it means, datasheet of hardware can tell more details
193 * @note: fix i40e_dev_supported_ptypes_get() if any change here.
195 static inline uint32_t
196 i40e_rxd_pkt_type_mapping(uint8_t ptype)
198 static const uint32_t type_table[UINT8_MAX + 1] __rte_cache_aligned = {
201 [1] = RTE_PTYPE_L2_ETHER,
202 [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
203 /* [3] - [5] reserved */
204 [6] = RTE_PTYPE_L2_ETHER_LLDP,
205 /* [7] - [10] reserved */
206 [11] = RTE_PTYPE_L2_ETHER_ARP,
207 /* [12] - [21] reserved */
209 /* Non tunneled IPv4 */
210 [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
212 [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
213 RTE_PTYPE_L4_NONFRAG,
214 [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
217 [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
219 [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
221 [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
225 [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
226 RTE_PTYPE_TUNNEL_IP |
227 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
228 RTE_PTYPE_INNER_L4_FRAG,
229 [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
230 RTE_PTYPE_TUNNEL_IP |
231 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
232 RTE_PTYPE_INNER_L4_NONFRAG,
233 [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
234 RTE_PTYPE_TUNNEL_IP |
235 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
236 RTE_PTYPE_INNER_L4_UDP,
238 [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
239 RTE_PTYPE_TUNNEL_IP |
240 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
241 RTE_PTYPE_INNER_L4_TCP,
242 [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
243 RTE_PTYPE_TUNNEL_IP |
244 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
245 RTE_PTYPE_INNER_L4_SCTP,
246 [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
247 RTE_PTYPE_TUNNEL_IP |
248 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
249 RTE_PTYPE_INNER_L4_ICMP,
252 [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
253 RTE_PTYPE_TUNNEL_IP |
254 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
255 RTE_PTYPE_INNER_L4_FRAG,
256 [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
257 RTE_PTYPE_TUNNEL_IP |
258 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
259 RTE_PTYPE_INNER_L4_NONFRAG,
260 [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
261 RTE_PTYPE_TUNNEL_IP |
262 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
263 RTE_PTYPE_INNER_L4_UDP,
265 [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
266 RTE_PTYPE_TUNNEL_IP |
267 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
268 RTE_PTYPE_INNER_L4_TCP,
269 [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
270 RTE_PTYPE_TUNNEL_IP |
271 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
272 RTE_PTYPE_INNER_L4_SCTP,
273 [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
274 RTE_PTYPE_TUNNEL_IP |
275 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
276 RTE_PTYPE_INNER_L4_ICMP,
278 /* IPv4 --> GRE/Teredo/VXLAN */
279 [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
280 RTE_PTYPE_TUNNEL_GRENAT,
282 /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
283 [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
284 RTE_PTYPE_TUNNEL_GRENAT |
285 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
286 RTE_PTYPE_INNER_L4_FRAG,
287 [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
288 RTE_PTYPE_TUNNEL_GRENAT |
289 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
290 RTE_PTYPE_INNER_L4_NONFRAG,
291 [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
292 RTE_PTYPE_TUNNEL_GRENAT |
293 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
294 RTE_PTYPE_INNER_L4_UDP,
296 [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
297 RTE_PTYPE_TUNNEL_GRENAT |
298 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
299 RTE_PTYPE_INNER_L4_TCP,
300 [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
301 RTE_PTYPE_TUNNEL_GRENAT |
302 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
303 RTE_PTYPE_INNER_L4_SCTP,
304 [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
305 RTE_PTYPE_TUNNEL_GRENAT |
306 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
307 RTE_PTYPE_INNER_L4_ICMP,
309 /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
310 [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
311 RTE_PTYPE_TUNNEL_GRENAT |
312 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
313 RTE_PTYPE_INNER_L4_FRAG,
314 [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
315 RTE_PTYPE_TUNNEL_GRENAT |
316 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
317 RTE_PTYPE_INNER_L4_NONFRAG,
318 [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
319 RTE_PTYPE_TUNNEL_GRENAT |
320 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
321 RTE_PTYPE_INNER_L4_UDP,
323 [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
324 RTE_PTYPE_TUNNEL_GRENAT |
325 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
326 RTE_PTYPE_INNER_L4_TCP,
327 [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
328 RTE_PTYPE_TUNNEL_GRENAT |
329 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
330 RTE_PTYPE_INNER_L4_SCTP,
331 [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
332 RTE_PTYPE_TUNNEL_GRENAT |
333 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
334 RTE_PTYPE_INNER_L4_ICMP,
336 /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
337 [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
338 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
340 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
341 [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
342 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
343 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
344 RTE_PTYPE_INNER_L4_FRAG,
345 [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
346 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
347 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
348 RTE_PTYPE_INNER_L4_NONFRAG,
349 [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
350 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
351 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
352 RTE_PTYPE_INNER_L4_UDP,
354 [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
355 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
356 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
357 RTE_PTYPE_INNER_L4_TCP,
358 [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
359 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
360 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
361 RTE_PTYPE_INNER_L4_SCTP,
362 [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
363 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
364 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
365 RTE_PTYPE_INNER_L4_ICMP,
367 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
368 [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
369 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
370 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
371 RTE_PTYPE_INNER_L4_FRAG,
372 [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
373 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
374 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
375 RTE_PTYPE_INNER_L4_NONFRAG,
376 [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
377 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
378 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
379 RTE_PTYPE_INNER_L4_UDP,
381 [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
382 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
383 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
384 RTE_PTYPE_INNER_L4_TCP,
385 [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
386 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
387 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
388 RTE_PTYPE_INNER_L4_SCTP,
389 [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
390 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
391 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
392 RTE_PTYPE_INNER_L4_ICMP,
394 /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN */
395 [73] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
396 RTE_PTYPE_TUNNEL_GRENAT |
397 RTE_PTYPE_INNER_L2_ETHER_VLAN,
399 /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv4 */
400 [74] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
401 RTE_PTYPE_TUNNEL_GRENAT |
402 RTE_PTYPE_INNER_L2_ETHER_VLAN |
403 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
404 RTE_PTYPE_INNER_L4_FRAG,
405 [75] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
406 RTE_PTYPE_TUNNEL_GRENAT |
407 RTE_PTYPE_INNER_L2_ETHER_VLAN |
408 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
409 RTE_PTYPE_INNER_L4_NONFRAG,
410 [76] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
411 RTE_PTYPE_TUNNEL_GRENAT |
412 RTE_PTYPE_INNER_L2_ETHER_VLAN |
413 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
414 RTE_PTYPE_INNER_L4_UDP,
416 [78] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
417 RTE_PTYPE_TUNNEL_GRENAT |
418 RTE_PTYPE_INNER_L2_ETHER_VLAN |
419 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
420 RTE_PTYPE_INNER_L4_TCP,
421 [79] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
422 RTE_PTYPE_TUNNEL_GRENAT |
423 RTE_PTYPE_INNER_L2_ETHER_VLAN |
424 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
425 RTE_PTYPE_INNER_L4_SCTP,
426 [80] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
427 RTE_PTYPE_TUNNEL_GRENAT |
428 RTE_PTYPE_INNER_L2_ETHER_VLAN |
429 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
430 RTE_PTYPE_INNER_L4_ICMP,
432 /* IPv4 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv6 */
433 [81] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
434 RTE_PTYPE_TUNNEL_GRENAT |
435 RTE_PTYPE_INNER_L2_ETHER_VLAN |
436 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
437 RTE_PTYPE_INNER_L4_FRAG,
438 [82] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
439 RTE_PTYPE_TUNNEL_GRENAT |
440 RTE_PTYPE_INNER_L2_ETHER_VLAN |
441 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
442 RTE_PTYPE_INNER_L4_NONFRAG,
443 [83] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
444 RTE_PTYPE_TUNNEL_GRENAT |
445 RTE_PTYPE_INNER_L2_ETHER_VLAN |
446 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
447 RTE_PTYPE_INNER_L4_UDP,
449 [85] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
450 RTE_PTYPE_TUNNEL_GRENAT |
451 RTE_PTYPE_INNER_L2_ETHER_VLAN |
452 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
453 RTE_PTYPE_INNER_L4_TCP,
454 [86] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
455 RTE_PTYPE_TUNNEL_GRENAT |
456 RTE_PTYPE_INNER_L2_ETHER_VLAN |
457 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
458 RTE_PTYPE_INNER_L4_SCTP,
459 [87] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
460 RTE_PTYPE_TUNNEL_GRENAT |
461 RTE_PTYPE_INNER_L2_ETHER_VLAN |
462 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
463 RTE_PTYPE_INNER_L4_ICMP,
465 /* Non tunneled IPv6 */
466 [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
468 [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
469 RTE_PTYPE_L4_NONFRAG,
470 [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
473 [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
475 [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
477 [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
481 [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
482 RTE_PTYPE_TUNNEL_IP |
483 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
484 RTE_PTYPE_INNER_L4_FRAG,
485 [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
486 RTE_PTYPE_TUNNEL_IP |
487 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
488 RTE_PTYPE_INNER_L4_NONFRAG,
489 [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
490 RTE_PTYPE_TUNNEL_IP |
491 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
492 RTE_PTYPE_INNER_L4_UDP,
494 [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
495 RTE_PTYPE_TUNNEL_IP |
496 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
497 RTE_PTYPE_INNER_L4_TCP,
498 [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
499 RTE_PTYPE_TUNNEL_IP |
500 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
501 RTE_PTYPE_INNER_L4_SCTP,
502 [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
503 RTE_PTYPE_TUNNEL_IP |
504 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
505 RTE_PTYPE_INNER_L4_ICMP,
508 [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
509 RTE_PTYPE_TUNNEL_IP |
510 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
511 RTE_PTYPE_INNER_L4_FRAG,
512 [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
513 RTE_PTYPE_TUNNEL_IP |
514 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
515 RTE_PTYPE_INNER_L4_NONFRAG,
516 [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
517 RTE_PTYPE_TUNNEL_IP |
518 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
519 RTE_PTYPE_INNER_L4_UDP,
521 [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
522 RTE_PTYPE_TUNNEL_IP |
523 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
524 RTE_PTYPE_INNER_L4_TCP,
525 [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
526 RTE_PTYPE_TUNNEL_IP |
527 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
528 RTE_PTYPE_INNER_L4_SCTP,
529 [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
530 RTE_PTYPE_TUNNEL_IP |
531 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
532 RTE_PTYPE_INNER_L4_ICMP,
534 /* IPv6 --> GRE/Teredo/VXLAN */
535 [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
536 RTE_PTYPE_TUNNEL_GRENAT,
538 /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
539 [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
540 RTE_PTYPE_TUNNEL_GRENAT |
541 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
542 RTE_PTYPE_INNER_L4_FRAG,
543 [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
544 RTE_PTYPE_TUNNEL_GRENAT |
545 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
546 RTE_PTYPE_INNER_L4_NONFRAG,
547 [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
548 RTE_PTYPE_TUNNEL_GRENAT |
549 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
550 RTE_PTYPE_INNER_L4_UDP,
552 [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
553 RTE_PTYPE_TUNNEL_GRENAT |
554 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
555 RTE_PTYPE_INNER_L4_TCP,
556 [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
557 RTE_PTYPE_TUNNEL_GRENAT |
558 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
559 RTE_PTYPE_INNER_L4_SCTP,
560 [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
561 RTE_PTYPE_TUNNEL_GRENAT |
562 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
563 RTE_PTYPE_INNER_L4_ICMP,
565 /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
566 [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
567 RTE_PTYPE_TUNNEL_GRENAT |
568 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
569 RTE_PTYPE_INNER_L4_FRAG,
570 [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
571 RTE_PTYPE_TUNNEL_GRENAT |
572 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
573 RTE_PTYPE_INNER_L4_NONFRAG,
574 [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
575 RTE_PTYPE_TUNNEL_GRENAT |
576 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
577 RTE_PTYPE_INNER_L4_UDP,
579 [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
580 RTE_PTYPE_TUNNEL_GRENAT |
581 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
582 RTE_PTYPE_INNER_L4_TCP,
583 [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
584 RTE_PTYPE_TUNNEL_GRENAT |
585 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
586 RTE_PTYPE_INNER_L4_SCTP,
587 [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
588 RTE_PTYPE_TUNNEL_GRENAT |
589 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
590 RTE_PTYPE_INNER_L4_ICMP,
592 /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
593 [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
594 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
596 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
597 [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
598 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
599 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
600 RTE_PTYPE_INNER_L4_FRAG,
601 [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
602 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
603 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
604 RTE_PTYPE_INNER_L4_NONFRAG,
605 [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
606 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
607 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
608 RTE_PTYPE_INNER_L4_UDP,
610 [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
611 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
612 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
613 RTE_PTYPE_INNER_L4_TCP,
614 [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
615 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
616 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
617 RTE_PTYPE_INNER_L4_SCTP,
618 [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
619 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
620 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
621 RTE_PTYPE_INNER_L4_ICMP,
623 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
624 [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
625 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
626 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
627 RTE_PTYPE_INNER_L4_FRAG,
628 [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
629 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
630 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
631 RTE_PTYPE_INNER_L4_NONFRAG,
632 [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
633 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
634 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
635 RTE_PTYPE_INNER_L4_UDP,
637 [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
638 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
639 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
640 RTE_PTYPE_INNER_L4_TCP,
641 [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
642 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
643 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
644 RTE_PTYPE_INNER_L4_SCTP,
645 [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
646 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
647 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
648 RTE_PTYPE_INNER_L4_ICMP,
650 /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN */
651 [139] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
652 RTE_PTYPE_TUNNEL_GRENAT |
653 RTE_PTYPE_INNER_L2_ETHER_VLAN,
655 /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv4 */
656 [140] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
657 RTE_PTYPE_TUNNEL_GRENAT |
658 RTE_PTYPE_INNER_L2_ETHER_VLAN |
659 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
660 RTE_PTYPE_INNER_L4_FRAG,
661 [141] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
662 RTE_PTYPE_TUNNEL_GRENAT |
663 RTE_PTYPE_INNER_L2_ETHER_VLAN |
664 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
665 RTE_PTYPE_INNER_L4_NONFRAG,
666 [142] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
667 RTE_PTYPE_TUNNEL_GRENAT |
668 RTE_PTYPE_INNER_L2_ETHER_VLAN |
669 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
670 RTE_PTYPE_INNER_L4_UDP,
672 [144] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
673 RTE_PTYPE_TUNNEL_GRENAT |
674 RTE_PTYPE_INNER_L2_ETHER_VLAN |
675 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
676 RTE_PTYPE_INNER_L4_TCP,
677 [145] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
678 RTE_PTYPE_TUNNEL_GRENAT |
679 RTE_PTYPE_INNER_L2_ETHER_VLAN |
680 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
681 RTE_PTYPE_INNER_L4_SCTP,
682 [146] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
683 RTE_PTYPE_TUNNEL_GRENAT |
684 RTE_PTYPE_INNER_L2_ETHER_VLAN |
685 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
686 RTE_PTYPE_INNER_L4_ICMP,
688 /* IPv6 --> GRE/Teredo/VXLAN --> MAC/VLAN --> IPv6 */
689 [147] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
690 RTE_PTYPE_TUNNEL_GRENAT |
691 RTE_PTYPE_INNER_L2_ETHER_VLAN |
692 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
693 RTE_PTYPE_INNER_L4_FRAG,
694 [148] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
695 RTE_PTYPE_TUNNEL_GRENAT |
696 RTE_PTYPE_INNER_L2_ETHER_VLAN |
697 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
698 RTE_PTYPE_INNER_L4_NONFRAG,
699 [149] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
700 RTE_PTYPE_TUNNEL_GRENAT |
701 RTE_PTYPE_INNER_L2_ETHER_VLAN |
702 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
703 RTE_PTYPE_INNER_L4_UDP,
705 [151] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
706 RTE_PTYPE_TUNNEL_GRENAT |
707 RTE_PTYPE_INNER_L2_ETHER_VLAN |
708 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
709 RTE_PTYPE_INNER_L4_TCP,
710 [152] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
711 RTE_PTYPE_TUNNEL_GRENAT |
712 RTE_PTYPE_INNER_L2_ETHER_VLAN |
713 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
714 RTE_PTYPE_INNER_L4_SCTP,
715 [153] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
716 RTE_PTYPE_TUNNEL_GRENAT |
717 RTE_PTYPE_INNER_L2_ETHER_VLAN |
718 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
719 RTE_PTYPE_INNER_L4_ICMP,
721 /* All others reserved */
724 return type_table[ptype];
727 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK 0x03
728 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_FD_ID 0x01
729 #define I40E_RX_DESC_EXT_STATUS_FLEXBH_FLEX 0x02
730 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK 0x03
731 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX 0x01
733 static inline uint64_t
734 i40e_rxd_build_fdir(volatile union i40e_rx_desc *rxdp, struct rte_mbuf *mb)
737 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
738 uint16_t flexbh, flexbl;
740 flexbh = (rte_le_to_cpu_32(rxdp->wb.qword2.ext_status) >>
741 I40E_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
742 I40E_RX_DESC_EXT_STATUS_FLEXBH_MASK;
743 flexbl = (rte_le_to_cpu_32(rxdp->wb.qword2.ext_status) >>
744 I40E_RX_DESC_EXT_STATUS_FLEXBL_SHIFT) &
745 I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK;
748 if (flexbh == I40E_RX_DESC_EXT_STATUS_FLEXBH_FD_ID) {
750 rte_le_to_cpu_32(rxdp->wb.qword3.hi_dword.fd_id);
751 flags |= PKT_RX_FDIR_ID;
752 } else if (flexbh == I40E_RX_DESC_EXT_STATUS_FLEXBH_FLEX) {
754 rte_le_to_cpu_32(rxdp->wb.qword3.hi_dword.flex_bytes_hi);
755 flags |= PKT_RX_FDIR_FLX;
757 if (flexbl == I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX) {
759 rte_le_to_cpu_32(rxdp->wb.qword3.lo_dword.flex_bytes_lo);
760 flags |= PKT_RX_FDIR_FLX;
764 rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd_id);
765 flags |= PKT_RX_FDIR_ID;
770 i40e_txd_enable_checksum(uint64_t ol_flags,
773 union i40e_tx_offload tx_offload,
774 uint32_t *cd_tunneling)
776 /* UDP tunneling packet TX checksum offload */
777 if (ol_flags & PKT_TX_OUTER_IP_CKSUM) {
779 *td_offset |= (tx_offload.outer_l2_len >> 1)
780 << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
782 if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
783 *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
784 else if (ol_flags & PKT_TX_OUTER_IPV4)
785 *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4_NO_CSUM;
786 else if (ol_flags & PKT_TX_OUTER_IPV6)
787 *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
789 /* Now set the ctx descriptor fields */
790 *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
791 I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT |
792 (tx_offload.l2_len >> 1) <<
793 I40E_TXD_CTX_QW0_NATLEN_SHIFT;
796 *td_offset |= (tx_offload.l2_len >> 1)
797 << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
799 /* Enable L3 checksum offloads */
800 if (ol_flags & PKT_TX_IP_CKSUM) {
801 *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
802 *td_offset |= (tx_offload.l3_len >> 2)
803 << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
804 } else if (ol_flags & PKT_TX_IPV4) {
805 *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4;
806 *td_offset |= (tx_offload.l3_len >> 2)
807 << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
808 } else if (ol_flags & PKT_TX_IPV6) {
809 *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV6;
810 *td_offset |= (tx_offload.l3_len >> 2)
811 << I40E_TX_DESC_LENGTH_IPLEN_SHIFT;
814 if (ol_flags & PKT_TX_TCP_SEG) {
815 *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_TCP;
816 *td_offset |= (tx_offload.l4_len >> 2)
817 << I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
821 /* Enable L4 checksum offloads */
822 switch (ol_flags & PKT_TX_L4_MASK) {
823 case PKT_TX_TCP_CKSUM:
824 *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_TCP;
825 *td_offset |= (sizeof(struct tcp_hdr) >> 2) <<
826 I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
828 case PKT_TX_SCTP_CKSUM:
829 *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_SCTP;
830 *td_offset |= (sizeof(struct sctp_hdr) >> 2) <<
831 I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
833 case PKT_TX_UDP_CKSUM:
834 *td_cmd |= I40E_TX_DESC_CMD_L4T_EOFT_UDP;
835 *td_offset |= (sizeof(struct udp_hdr) >> 2) <<
836 I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
843 static inline struct rte_mbuf *
844 rte_rxmbuf_alloc(struct rte_mempool *mp)
848 m = __rte_mbuf_raw_alloc(mp);
849 __rte_mbuf_sanity_check_raw(m, 0);
854 /* Construct the tx flags */
855 static inline uint64_t
856 i40e_build_ctob(uint32_t td_cmd,
861 return rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DATA |
862 ((uint64_t)td_cmd << I40E_TXD_QW1_CMD_SHIFT) |
863 ((uint64_t)td_offset << I40E_TXD_QW1_OFFSET_SHIFT) |
864 ((uint64_t)size << I40E_TXD_QW1_TX_BUF_SZ_SHIFT) |
865 ((uint64_t)td_tag << I40E_TXD_QW1_L2TAG1_SHIFT));
869 i40e_xmit_cleanup(struct i40e_tx_queue *txq)
871 struct i40e_tx_entry *sw_ring = txq->sw_ring;
872 volatile struct i40e_tx_desc *txd = txq->tx_ring;
873 uint16_t last_desc_cleaned = txq->last_desc_cleaned;
874 uint16_t nb_tx_desc = txq->nb_tx_desc;
875 uint16_t desc_to_clean_to;
876 uint16_t nb_tx_to_clean;
878 desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
879 if (desc_to_clean_to >= nb_tx_desc)
880 desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
882 desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
883 if ((txd[desc_to_clean_to].cmd_type_offset_bsz &
884 rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
885 rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE)) {
886 PMD_TX_FREE_LOG(DEBUG, "TX descriptor %4u is not done "
887 "(port=%d queue=%d)", desc_to_clean_to,
888 txq->port_id, txq->queue_id);
892 if (last_desc_cleaned > desc_to_clean_to)
893 nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
896 nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
899 txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
901 txq->last_desc_cleaned = desc_to_clean_to;
902 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
908 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
909 check_rx_burst_bulk_alloc_preconditions(struct i40e_rx_queue *rxq)
911 check_rx_burst_bulk_alloc_preconditions(__rte_unused struct i40e_rx_queue *rxq)
916 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
917 if (!(rxq->rx_free_thresh >= RTE_PMD_I40E_RX_MAX_BURST)) {
918 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
919 "rxq->rx_free_thresh=%d, "
920 "RTE_PMD_I40E_RX_MAX_BURST=%d",
921 rxq->rx_free_thresh, RTE_PMD_I40E_RX_MAX_BURST);
923 } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
924 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
925 "rxq->rx_free_thresh=%d, "
926 "rxq->nb_rx_desc=%d",
927 rxq->rx_free_thresh, rxq->nb_rx_desc);
929 } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
930 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
931 "rxq->nb_rx_desc=%d, "
932 "rxq->rx_free_thresh=%d",
933 rxq->nb_rx_desc, rxq->rx_free_thresh);
935 } else if (!(rxq->nb_rx_desc < (I40E_MAX_RING_DESC -
936 RTE_PMD_I40E_RX_MAX_BURST))) {
937 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
938 "rxq->nb_rx_desc=%d, "
939 "I40E_MAX_RING_DESC=%d, "
940 "RTE_PMD_I40E_RX_MAX_BURST=%d",
941 rxq->nb_rx_desc, I40E_MAX_RING_DESC,
942 RTE_PMD_I40E_RX_MAX_BURST);
952 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
953 #define I40E_LOOK_AHEAD 8
954 #if (I40E_LOOK_AHEAD != 8)
955 #error "PMD I40E: I40E_LOOK_AHEAD must be 8\n"
958 i40e_rx_scan_hw_ring(struct i40e_rx_queue *rxq)
960 volatile union i40e_rx_desc *rxdp;
961 struct i40e_rx_entry *rxep;
966 int32_t s[I40E_LOOK_AHEAD], nb_dd;
967 int32_t i, j, nb_rx = 0;
970 rxdp = &rxq->rx_ring[rxq->rx_tail];
971 rxep = &rxq->sw_ring[rxq->rx_tail];
973 qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
974 rx_status = (qword1 & I40E_RXD_QW1_STATUS_MASK) >>
975 I40E_RXD_QW1_STATUS_SHIFT;
977 /* Make sure there is at least 1 packet to receive */
978 if (!(rx_status & (1 << I40E_RX_DESC_STATUS_DD_SHIFT)))
982 * Scan LOOK_AHEAD descriptors at a time to determine which
983 * descriptors reference packets that are ready to be received.
985 for (i = 0; i < RTE_PMD_I40E_RX_MAX_BURST; i+=I40E_LOOK_AHEAD,
986 rxdp += I40E_LOOK_AHEAD, rxep += I40E_LOOK_AHEAD) {
987 /* Read desc statuses backwards to avoid race condition */
988 for (j = I40E_LOOK_AHEAD - 1; j >= 0; j--) {
989 qword1 = rte_le_to_cpu_64(\
990 rxdp[j].wb.qword1.status_error_len);
991 s[j] = (qword1 & I40E_RXD_QW1_STATUS_MASK) >>
992 I40E_RXD_QW1_STATUS_SHIFT;
995 /* Compute how many status bits were set */
996 for (j = 0, nb_dd = 0; j < I40E_LOOK_AHEAD; j++)
997 nb_dd += s[j] & (1 << I40E_RX_DESC_STATUS_DD_SHIFT);
1001 /* Translate descriptor info to mbuf parameters */
1002 for (j = 0; j < nb_dd; j++) {
1004 qword1 = rte_le_to_cpu_64(\
1005 rxdp[j].wb.qword1.status_error_len);
1006 pkt_len = ((qword1 & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
1007 I40E_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;
1008 mb->data_len = pkt_len;
1009 mb->pkt_len = pkt_len;
1011 i40e_rxd_to_vlan_tci(mb, &rxdp[j]);
1012 pkt_flags = i40e_rxd_status_to_pkt_flags(qword1);
1013 pkt_flags |= i40e_rxd_error_to_pkt_flags(qword1);
1015 i40e_rxd_pkt_type_mapping((uint8_t)((qword1 &
1016 I40E_RXD_QW1_PTYPE_MASK) >>
1017 I40E_RXD_QW1_PTYPE_SHIFT));
1018 if (pkt_flags & PKT_RX_RSS_HASH)
1019 mb->hash.rss = rte_le_to_cpu_32(\
1020 rxdp[j].wb.qword0.hi_dword.rss);
1021 if (pkt_flags & PKT_RX_FDIR)
1022 pkt_flags |= i40e_rxd_build_fdir(&rxdp[j], mb);
1024 #ifdef RTE_LIBRTE_IEEE1588
1025 pkt_flags |= i40e_get_iee15888_flags(mb, qword1);
1027 mb->ol_flags |= pkt_flags;
1031 for (j = 0; j < I40E_LOOK_AHEAD; j++)
1032 rxq->rx_stage[i + j] = rxep[j].mbuf;
1034 if (nb_dd != I40E_LOOK_AHEAD)
1038 /* Clear software ring entries */
1039 for (i = 0; i < nb_rx; i++)
1040 rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
1045 static inline uint16_t
1046 i40e_rx_fill_from_stage(struct i40e_rx_queue *rxq,
1047 struct rte_mbuf **rx_pkts,
1051 struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
1053 nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
1055 for (i = 0; i < nb_pkts; i++)
1056 rx_pkts[i] = stage[i];
1058 rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
1059 rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
1065 i40e_rx_alloc_bufs(struct i40e_rx_queue *rxq)
1067 volatile union i40e_rx_desc *rxdp;
1068 struct i40e_rx_entry *rxep;
1069 struct rte_mbuf *mb;
1070 uint16_t alloc_idx, i;
1074 /* Allocate buffers in bulk */
1075 alloc_idx = (uint16_t)(rxq->rx_free_trigger -
1076 (rxq->rx_free_thresh - 1));
1077 rxep = &(rxq->sw_ring[alloc_idx]);
1078 diag = rte_mempool_get_bulk(rxq->mp, (void *)rxep,
1079 rxq->rx_free_thresh);
1080 if (unlikely(diag != 0)) {
1081 PMD_DRV_LOG(ERR, "Failed to get mbufs in bulk");
1085 rxdp = &rxq->rx_ring[alloc_idx];
1086 for (i = 0; i < rxq->rx_free_thresh; i++) {
1087 if (likely(i < (rxq->rx_free_thresh - 1)))
1088 /* Prefetch next mbuf */
1089 rte_prefetch0(rxep[i + 1].mbuf);
1092 rte_mbuf_refcnt_set(mb, 1);
1094 mb->data_off = RTE_PKTMBUF_HEADROOM;
1096 mb->port = rxq->port_id;
1097 dma_addr = rte_cpu_to_le_64(\
1098 rte_mbuf_data_dma_addr_default(mb));
1099 rxdp[i].read.hdr_addr = 0;
1100 rxdp[i].read.pkt_addr = dma_addr;
1103 /* Update rx tail regsiter */
1105 I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
1107 rxq->rx_free_trigger =
1108 (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
1109 if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
1110 rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
1115 static inline uint16_t
1116 rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1118 struct i40e_rx_queue *rxq = (struct i40e_rx_queue *)rx_queue;
1124 if (rxq->rx_nb_avail)
1125 return i40e_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1127 nb_rx = (uint16_t)i40e_rx_scan_hw_ring(rxq);
1128 rxq->rx_next_avail = 0;
1129 rxq->rx_nb_avail = nb_rx;
1130 rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
1132 if (rxq->rx_tail > rxq->rx_free_trigger) {
1133 if (i40e_rx_alloc_bufs(rxq) != 0) {
1136 PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
1137 "port_id=%u, queue_id=%u",
1138 rxq->port_id, rxq->queue_id);
1139 rxq->rx_nb_avail = 0;
1140 rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
1141 for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
1142 rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
1148 if (rxq->rx_tail >= rxq->nb_rx_desc)
1151 if (rxq->rx_nb_avail)
1152 return i40e_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1158 i40e_recv_pkts_bulk_alloc(void *rx_queue,
1159 struct rte_mbuf **rx_pkts,
1162 uint16_t nb_rx = 0, n, count;
1164 if (unlikely(nb_pkts == 0))
1167 if (likely(nb_pkts <= RTE_PMD_I40E_RX_MAX_BURST))
1168 return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
1171 n = RTE_MIN(nb_pkts, RTE_PMD_I40E_RX_MAX_BURST);
1172 count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
1173 nb_rx = (uint16_t)(nb_rx + count);
1174 nb_pkts = (uint16_t)(nb_pkts - count);
1181 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */
1184 i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1186 struct i40e_rx_queue *rxq;
1187 volatile union i40e_rx_desc *rx_ring;
1188 volatile union i40e_rx_desc *rxdp;
1189 union i40e_rx_desc rxd;
1190 struct i40e_rx_entry *sw_ring;
1191 struct i40e_rx_entry *rxe;
1192 struct rte_mbuf *rxm;
1193 struct rte_mbuf *nmb;
1197 uint16_t rx_packet_len;
1198 uint16_t rx_id, nb_hold;
1205 rx_id = rxq->rx_tail;
1206 rx_ring = rxq->rx_ring;
1207 sw_ring = rxq->sw_ring;
1209 while (nb_rx < nb_pkts) {
1210 rxdp = &rx_ring[rx_id];
1211 qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
1212 rx_status = (qword1 & I40E_RXD_QW1_STATUS_MASK)
1213 >> I40E_RXD_QW1_STATUS_SHIFT;
1215 /* Check the DD bit first */
1216 if (!(rx_status & (1 << I40E_RX_DESC_STATUS_DD_SHIFT)))
1219 nmb = rte_rxmbuf_alloc(rxq->mp);
1225 rxe = &sw_ring[rx_id];
1227 if (unlikely(rx_id == rxq->nb_rx_desc))
1230 /* Prefetch next mbuf */
1231 rte_prefetch0(sw_ring[rx_id].mbuf);
1234 * When next RX descriptor is on a cache line boundary,
1235 * prefetch the next 4 RX descriptors and next 8 pointers
1238 if ((rx_id & 0x3) == 0) {
1239 rte_prefetch0(&rx_ring[rx_id]);
1240 rte_prefetch0(&sw_ring[rx_id]);
1245 rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(nmb));
1246 rxdp->read.hdr_addr = 0;
1247 rxdp->read.pkt_addr = dma_addr;
1249 rx_packet_len = ((qword1 & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
1250 I40E_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;
1252 rxm->data_off = RTE_PKTMBUF_HEADROOM;
1253 rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
1256 rxm->pkt_len = rx_packet_len;
1257 rxm->data_len = rx_packet_len;
1258 rxm->port = rxq->port_id;
1260 i40e_rxd_to_vlan_tci(rxm, &rxd);
1261 pkt_flags = i40e_rxd_status_to_pkt_flags(qword1);
1262 pkt_flags |= i40e_rxd_error_to_pkt_flags(qword1);
1264 i40e_rxd_pkt_type_mapping((uint8_t)((qword1 &
1265 I40E_RXD_QW1_PTYPE_MASK) >> I40E_RXD_QW1_PTYPE_SHIFT));
1266 if (pkt_flags & PKT_RX_RSS_HASH)
1268 rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
1269 if (pkt_flags & PKT_RX_FDIR)
1270 pkt_flags |= i40e_rxd_build_fdir(&rxd, rxm);
1272 #ifdef RTE_LIBRTE_IEEE1588
1273 pkt_flags |= i40e_get_iee15888_flags(rxm, qword1);
1275 rxm->ol_flags |= pkt_flags;
1277 rx_pkts[nb_rx++] = rxm;
1279 rxq->rx_tail = rx_id;
1282 * If the number of free RX descriptors is greater than the RX free
1283 * threshold of the queue, advance the receive tail register of queue.
1284 * Update that register with the value of the last processed RX
1285 * descriptor minus 1.
1287 nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
1288 if (nb_hold > rxq->rx_free_thresh) {
1289 rx_id = (uint16_t) ((rx_id == 0) ?
1290 (rxq->nb_rx_desc - 1) : (rx_id - 1));
1291 I40E_PCI_REG_WRITE(rxq->qrx_tail, rx_id);
1294 rxq->nb_rx_hold = nb_hold;
1300 i40e_recv_scattered_pkts(void *rx_queue,
1301 struct rte_mbuf **rx_pkts,
1304 struct i40e_rx_queue *rxq = rx_queue;
1305 volatile union i40e_rx_desc *rx_ring = rxq->rx_ring;
1306 volatile union i40e_rx_desc *rxdp;
1307 union i40e_rx_desc rxd;
1308 struct i40e_rx_entry *sw_ring = rxq->sw_ring;
1309 struct i40e_rx_entry *rxe;
1310 struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1311 struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1312 struct rte_mbuf *nmb, *rxm;
1313 uint16_t rx_id = rxq->rx_tail;
1314 uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
1320 while (nb_rx < nb_pkts) {
1321 rxdp = &rx_ring[rx_id];
1322 qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
1323 rx_status = (qword1 & I40E_RXD_QW1_STATUS_MASK) >>
1324 I40E_RXD_QW1_STATUS_SHIFT;
1326 /* Check the DD bit */
1327 if (!(rx_status & (1 << I40E_RX_DESC_STATUS_DD_SHIFT)))
1330 nmb = rte_rxmbuf_alloc(rxq->mp);
1335 rxe = &sw_ring[rx_id];
1337 if (rx_id == rxq->nb_rx_desc)
1340 /* Prefetch next mbuf */
1341 rte_prefetch0(sw_ring[rx_id].mbuf);
1344 * When next RX descriptor is on a cache line boundary,
1345 * prefetch the next 4 RX descriptors and next 8 pointers
1348 if ((rx_id & 0x3) == 0) {
1349 rte_prefetch0(&rx_ring[rx_id]);
1350 rte_prefetch0(&sw_ring[rx_id]);
1356 rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(nmb));
1358 /* Set data buffer address and data length of the mbuf */
1359 rxdp->read.hdr_addr = 0;
1360 rxdp->read.pkt_addr = dma_addr;
1361 rx_packet_len = (qword1 & I40E_RXD_QW1_LENGTH_PBUF_MASK) >>
1362 I40E_RXD_QW1_LENGTH_PBUF_SHIFT;
1363 rxm->data_len = rx_packet_len;
1364 rxm->data_off = RTE_PKTMBUF_HEADROOM;
1367 * If this is the first buffer of the received packet, set the
1368 * pointer to the first mbuf of the packet and initialize its
1369 * context. Otherwise, update the total length and the number
1370 * of segments of the current scattered packet, and update the
1371 * pointer to the last mbuf of the current packet.
1375 first_seg->nb_segs = 1;
1376 first_seg->pkt_len = rx_packet_len;
1378 first_seg->pkt_len =
1379 (uint16_t)(first_seg->pkt_len +
1381 first_seg->nb_segs++;
1382 last_seg->next = rxm;
1386 * If this is not the last buffer of the received packet,
1387 * update the pointer to the last mbuf of the current scattered
1388 * packet and continue to parse the RX ring.
1390 if (!(rx_status & (1 << I40E_RX_DESC_STATUS_EOF_SHIFT))) {
1396 * This is the last buffer of the received packet. If the CRC
1397 * is not stripped by the hardware:
1398 * - Subtract the CRC length from the total packet length.
1399 * - If the last buffer only contains the whole CRC or a part
1400 * of it, free the mbuf associated to the last buffer. If part
1401 * of the CRC is also contained in the previous mbuf, subtract
1402 * the length of that CRC part from the data length of the
1406 if (unlikely(rxq->crc_len > 0)) {
1407 first_seg->pkt_len -= ETHER_CRC_LEN;
1408 if (rx_packet_len <= ETHER_CRC_LEN) {
1409 rte_pktmbuf_free_seg(rxm);
1410 first_seg->nb_segs--;
1411 last_seg->data_len =
1412 (uint16_t)(last_seg->data_len -
1413 (ETHER_CRC_LEN - rx_packet_len));
1414 last_seg->next = NULL;
1416 rxm->data_len = (uint16_t)(rx_packet_len -
1420 first_seg->port = rxq->port_id;
1421 first_seg->ol_flags = 0;
1422 i40e_rxd_to_vlan_tci(first_seg, &rxd);
1423 pkt_flags = i40e_rxd_status_to_pkt_flags(qword1);
1424 pkt_flags |= i40e_rxd_error_to_pkt_flags(qword1);
1425 first_seg->packet_type =
1426 i40e_rxd_pkt_type_mapping((uint8_t)((qword1 &
1427 I40E_RXD_QW1_PTYPE_MASK) >> I40E_RXD_QW1_PTYPE_SHIFT));
1428 if (pkt_flags & PKT_RX_RSS_HASH)
1430 rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
1431 if (pkt_flags & PKT_RX_FDIR)
1432 pkt_flags |= i40e_rxd_build_fdir(&rxd, rxm);
1434 #ifdef RTE_LIBRTE_IEEE1588
1435 pkt_flags |= i40e_get_iee15888_flags(first_seg, qword1);
1437 first_seg->ol_flags |= pkt_flags;
1439 /* Prefetch data of first segment, if configured to do so. */
1440 rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1441 first_seg->data_off));
1442 rx_pkts[nb_rx++] = first_seg;
1446 /* Record index of the next RX descriptor to probe. */
1447 rxq->rx_tail = rx_id;
1448 rxq->pkt_first_seg = first_seg;
1449 rxq->pkt_last_seg = last_seg;
1452 * If the number of free RX descriptors is greater than the RX free
1453 * threshold of the queue, advance the Receive Descriptor Tail (RDT)
1454 * register. Update the RDT with the value of the last processed RX
1455 * descriptor minus 1, to guarantee that the RDT register is never
1456 * equal to the RDH register, which creates a "full" ring situtation
1457 * from the hardware point of view.
1459 nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
1460 if (nb_hold > rxq->rx_free_thresh) {
1461 rx_id = (uint16_t)(rx_id == 0 ?
1462 (rxq->nb_rx_desc - 1) : (rx_id - 1));
1463 I40E_PCI_REG_WRITE(rxq->qrx_tail, rx_id);
1466 rxq->nb_rx_hold = nb_hold;
1471 /* Check if the context descriptor is needed for TX offloading */
1472 static inline uint16_t
1473 i40e_calc_context_desc(uint64_t flags)
1475 static uint64_t mask = PKT_TX_OUTER_IP_CKSUM |
1479 #ifdef RTE_LIBRTE_IEEE1588
1480 mask |= PKT_TX_IEEE1588_TMST;
1483 return (flags & mask) ? 1 : 0;
1486 /* set i40e TSO context descriptor */
1487 static inline uint64_t
1488 i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
1490 uint64_t ctx_desc = 0;
1491 uint32_t cd_cmd, hdr_len, cd_tso_len;
1493 if (!tx_offload.l4_len) {
1494 PMD_DRV_LOG(DEBUG, "L4 length set to 0");
1499 * in case of tunneling packet, the outer_l2_len and
1500 * outer_l3_len must be 0.
1502 hdr_len = tx_offload.outer_l2_len +
1503 tx_offload.outer_l3_len +
1508 cd_cmd = I40E_TX_CTX_DESC_TSO;
1509 cd_tso_len = mbuf->pkt_len - hdr_len;
1510 ctx_desc |= ((uint64_t)cd_cmd << I40E_TXD_CTX_QW1_CMD_SHIFT) |
1511 ((uint64_t)cd_tso_len <<
1512 I40E_TXD_CTX_QW1_TSO_LEN_SHIFT) |
1513 ((uint64_t)mbuf->tso_segsz <<
1514 I40E_TXD_CTX_QW1_MSS_SHIFT);
1520 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
1522 struct i40e_tx_queue *txq;
1523 struct i40e_tx_entry *sw_ring;
1524 struct i40e_tx_entry *txe, *txn;
1525 volatile struct i40e_tx_desc *txd;
1526 volatile struct i40e_tx_desc *txr;
1527 struct rte_mbuf *tx_pkt;
1528 struct rte_mbuf *m_seg;
1529 uint32_t cd_tunneling_params;
1541 uint64_t buf_dma_addr;
1542 union i40e_tx_offload tx_offload = {0};
1545 sw_ring = txq->sw_ring;
1547 tx_id = txq->tx_tail;
1548 txe = &sw_ring[tx_id];
1550 /* Check if the descriptor ring needs to be cleaned. */
1551 if (txq->nb_tx_free < txq->tx_free_thresh)
1552 i40e_xmit_cleanup(txq);
1554 for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
1560 tx_pkt = *tx_pkts++;
1561 RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
1563 ol_flags = tx_pkt->ol_flags;
1564 tx_offload.l2_len = tx_pkt->l2_len;
1565 tx_offload.l3_len = tx_pkt->l3_len;
1566 tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
1567 tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
1568 tx_offload.l4_len = tx_pkt->l4_len;
1569 tx_offload.tso_segsz = tx_pkt->tso_segsz;
1571 /* Calculate the number of context descriptors needed. */
1572 nb_ctx = i40e_calc_context_desc(ol_flags);
1575 * The number of descriptors that must be allocated for
1576 * a packet equals to the number of the segments of that
1577 * packet plus 1 context descriptor if needed.
1579 nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
1580 tx_last = (uint16_t)(tx_id + nb_used - 1);
1583 if (tx_last >= txq->nb_tx_desc)
1584 tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
1586 if (nb_used > txq->nb_tx_free) {
1587 if (i40e_xmit_cleanup(txq) != 0) {
1592 if (unlikely(nb_used > txq->tx_rs_thresh)) {
1593 while (nb_used > txq->nb_tx_free) {
1594 if (i40e_xmit_cleanup(txq) != 0) {
1603 /* Descriptor based VLAN insertion */
1604 if (ol_flags & (PKT_TX_VLAN_PKT | PKT_TX_QINQ_PKT)) {
1605 tx_flags |= tx_pkt->vlan_tci <<
1606 I40E_TX_FLAG_L2TAG1_SHIFT;
1607 tx_flags |= I40E_TX_FLAG_INSERT_VLAN;
1608 td_cmd |= I40E_TX_DESC_CMD_IL2TAG1;
1609 td_tag = (tx_flags & I40E_TX_FLAG_L2TAG1_MASK) >>
1610 I40E_TX_FLAG_L2TAG1_SHIFT;
1613 /* Always enable CRC offload insertion */
1614 td_cmd |= I40E_TX_DESC_CMD_ICRC;
1616 /* Enable checksum offloading */
1617 cd_tunneling_params = 0;
1618 if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) {
1619 i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
1620 tx_offload, &cd_tunneling_params);
1624 /* Setup TX context descriptor if required */
1625 volatile struct i40e_tx_context_desc *ctx_txd =
1626 (volatile struct i40e_tx_context_desc *)\
1628 uint16_t cd_l2tag2 = 0;
1629 uint64_t cd_type_cmd_tso_mss =
1630 I40E_TX_DESC_DTYPE_CONTEXT;
1632 txn = &sw_ring[txe->next_id];
1633 RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
1634 if (txe->mbuf != NULL) {
1635 rte_pktmbuf_free_seg(txe->mbuf);
1639 /* TSO enabled means no timestamp */
1640 if (ol_flags & PKT_TX_TCP_SEG)
1641 cd_type_cmd_tso_mss |=
1642 i40e_set_tso_ctx(tx_pkt, tx_offload);
1644 #ifdef RTE_LIBRTE_IEEE1588
1645 if (ol_flags & PKT_TX_IEEE1588_TMST)
1646 cd_type_cmd_tso_mss |=
1647 ((uint64_t)I40E_TX_CTX_DESC_TSYN <<
1648 I40E_TXD_CTX_QW1_CMD_SHIFT);
1652 ctx_txd->tunneling_params =
1653 rte_cpu_to_le_32(cd_tunneling_params);
1654 if (ol_flags & PKT_TX_QINQ_PKT) {
1655 cd_l2tag2 = tx_pkt->vlan_tci_outer;
1656 cd_type_cmd_tso_mss |=
1657 ((uint64_t)I40E_TX_CTX_DESC_IL2TAG2 <<
1658 I40E_TXD_CTX_QW1_CMD_SHIFT);
1660 ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
1661 ctx_txd->type_cmd_tso_mss =
1662 rte_cpu_to_le_64(cd_type_cmd_tso_mss);
1664 PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]:\n"
1665 "tunneling_params: %#x;\n"
1668 "type_cmd_tso_mss: %#"PRIx64";\n",
1670 ctx_txd->tunneling_params,
1673 ctx_txd->type_cmd_tso_mss);
1675 txe->last_id = tx_last;
1676 tx_id = txe->next_id;
1683 txn = &sw_ring[txe->next_id];
1686 rte_pktmbuf_free_seg(txe->mbuf);
1689 /* Setup TX Descriptor */
1690 slen = m_seg->data_len;
1691 buf_dma_addr = rte_mbuf_data_dma_addr(m_seg);
1693 PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n"
1694 "buf_dma_addr: %#"PRIx64";\n"
1699 tx_pkt, tx_id, buf_dma_addr,
1700 td_cmd, td_offset, slen, td_tag);
1702 txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr);
1703 txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd,
1704 td_offset, slen, td_tag);
1705 txe->last_id = tx_last;
1706 tx_id = txe->next_id;
1708 m_seg = m_seg->next;
1709 } while (m_seg != NULL);
1711 /* The last packet data descriptor needs End Of Packet (EOP) */
1712 td_cmd |= I40E_TX_DESC_CMD_EOP;
1713 txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
1714 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
1716 if (txq->nb_tx_used >= txq->tx_rs_thresh) {
1717 PMD_TX_FREE_LOG(DEBUG,
1718 "Setting RS bit on TXD id="
1719 "%4u (port=%d queue=%d)",
1720 tx_last, txq->port_id, txq->queue_id);
1722 td_cmd |= I40E_TX_DESC_CMD_RS;
1724 /* Update txq RS bit counters */
1725 txq->nb_tx_used = 0;
1728 txd->cmd_type_offset_bsz |=
1729 rte_cpu_to_le_64(((uint64_t)td_cmd) <<
1730 I40E_TXD_QW1_CMD_SHIFT);
1736 PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
1737 (unsigned) txq->port_id, (unsigned) txq->queue_id,
1738 (unsigned) tx_id, (unsigned) nb_tx);
1740 I40E_PCI_REG_WRITE(txq->qtx_tail, tx_id);
1741 txq->tx_tail = tx_id;
1746 static inline int __attribute__((always_inline))
1747 i40e_tx_free_bufs(struct i40e_tx_queue *txq)
1749 struct i40e_tx_entry *txep;
1752 if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
1753 rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
1754 rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
1757 txep = &(txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)]);
1759 for (i = 0; i < txq->tx_rs_thresh; i++)
1760 rte_prefetch0((txep + i)->mbuf);
1762 if (txq->txq_flags & (uint32_t)ETH_TXQ_FLAGS_NOREFCOUNT) {
1763 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
1764 rte_mempool_put(txep->mbuf->pool, txep->mbuf);
1768 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
1769 rte_pktmbuf_free_seg(txep->mbuf);
1774 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
1775 txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
1776 if (txq->tx_next_dd >= txq->nb_tx_desc)
1777 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
1779 return txq->tx_rs_thresh;
1782 /* Populate 4 descriptors with data from 4 mbufs */
1784 tx4(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkts)
1789 for (i = 0; i < 4; i++, txdp++, pkts++) {
1790 dma_addr = rte_mbuf_data_dma_addr(*pkts);
1791 txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
1792 txdp->cmd_type_offset_bsz =
1793 i40e_build_ctob((uint32_t)I40E_TD_CMD, 0,
1794 (*pkts)->data_len, 0);
1798 /* Populate 1 descriptor with data from 1 mbuf */
1800 tx1(volatile struct i40e_tx_desc *txdp, struct rte_mbuf **pkts)
1804 dma_addr = rte_mbuf_data_dma_addr(*pkts);
1805 txdp->buffer_addr = rte_cpu_to_le_64(dma_addr);
1806 txdp->cmd_type_offset_bsz =
1807 i40e_build_ctob((uint32_t)I40E_TD_CMD, 0,
1808 (*pkts)->data_len, 0);
1811 /* Fill hardware descriptor ring with mbuf data */
1813 i40e_tx_fill_hw_ring(struct i40e_tx_queue *txq,
1814 struct rte_mbuf **pkts,
1817 volatile struct i40e_tx_desc *txdp = &(txq->tx_ring[txq->tx_tail]);
1818 struct i40e_tx_entry *txep = &(txq->sw_ring[txq->tx_tail]);
1819 const int N_PER_LOOP = 4;
1820 const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
1821 int mainpart, leftover;
1824 mainpart = (nb_pkts & ((uint32_t) ~N_PER_LOOP_MASK));
1825 leftover = (nb_pkts & ((uint32_t) N_PER_LOOP_MASK));
1826 for (i = 0; i < mainpart; i += N_PER_LOOP) {
1827 for (j = 0; j < N_PER_LOOP; ++j) {
1828 (txep + i + j)->mbuf = *(pkts + i + j);
1830 tx4(txdp + i, pkts + i);
1832 if (unlikely(leftover > 0)) {
1833 for (i = 0; i < leftover; ++i) {
1834 (txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
1835 tx1(txdp + mainpart + i, pkts + mainpart + i);
1840 static inline uint16_t
1841 tx_xmit_pkts(struct i40e_tx_queue *txq,
1842 struct rte_mbuf **tx_pkts,
1845 volatile struct i40e_tx_desc *txr = txq->tx_ring;
1849 * Begin scanning the H/W ring for done descriptors when the number
1850 * of available descriptors drops below tx_free_thresh. For each done
1851 * descriptor, free the associated buffer.
1853 if (txq->nb_tx_free < txq->tx_free_thresh)
1854 i40e_tx_free_bufs(txq);
1856 /* Use available descriptor only */
1857 nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
1858 if (unlikely(!nb_pkts))
1861 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
1862 if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
1863 n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
1864 i40e_tx_fill_hw_ring(txq, tx_pkts, n);
1865 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
1866 rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
1867 I40E_TXD_QW1_CMD_SHIFT);
1868 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
1872 /* Fill hardware descriptor ring with mbuf data */
1873 i40e_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
1874 txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
1876 /* Determin if RS bit needs to be set */
1877 if (txq->tx_tail > txq->tx_next_rs) {
1878 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
1879 rte_cpu_to_le_64(((uint64_t)I40E_TX_DESC_CMD_RS) <<
1880 I40E_TXD_QW1_CMD_SHIFT);
1882 (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
1883 if (txq->tx_next_rs >= txq->nb_tx_desc)
1884 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
1887 if (txq->tx_tail >= txq->nb_tx_desc)
1890 /* Update the tx tail register */
1892 I40E_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
1898 i40e_xmit_pkts_simple(void *tx_queue,
1899 struct rte_mbuf **tx_pkts,
1904 if (likely(nb_pkts <= I40E_TX_MAX_BURST))
1905 return tx_xmit_pkts((struct i40e_tx_queue *)tx_queue,
1909 uint16_t ret, num = (uint16_t)RTE_MIN(nb_pkts,
1912 ret = tx_xmit_pkts((struct i40e_tx_queue *)tx_queue,
1913 &tx_pkts[nb_tx], num);
1914 nb_tx = (uint16_t)(nb_tx + ret);
1915 nb_pkts = (uint16_t)(nb_pkts - ret);
1924 * Find the VSI the queue belongs to. 'queue_idx' is the queue index
1925 * application used, which assume having sequential ones. But from driver's
1926 * perspective, it's different. For example, q0 belongs to FDIR VSI, q1-q64
1927 * to MAIN VSI, , q65-96 to SRIOV VSIs, q97-128 to VMDQ VSIs. For application
1928 * running on host, q1-64 and q97-128 can be used, total 96 queues. They can
1929 * use queue_idx from 0 to 95 to access queues, while real queue would be
1930 * different. This function will do a queue mapping to find VSI the queue
1933 static struct i40e_vsi*
1934 i40e_pf_get_vsi_by_qindex(struct i40e_pf *pf, uint16_t queue_idx)
1936 /* the queue in MAIN VSI range */
1937 if (queue_idx < pf->main_vsi->nb_qps)
1938 return pf->main_vsi;
1940 queue_idx -= pf->main_vsi->nb_qps;
1942 /* queue_idx is greater than VMDQ VSIs range */
1943 if (queue_idx > pf->nb_cfg_vmdq_vsi * pf->vmdq_nb_qps - 1) {
1944 PMD_INIT_LOG(ERR, "queue_idx out of range. VMDQ configured?");
1948 return pf->vmdq[queue_idx / pf->vmdq_nb_qps].vsi;
1952 i40e_get_queue_offset_by_qindex(struct i40e_pf *pf, uint16_t queue_idx)
1954 /* the queue in MAIN VSI range */
1955 if (queue_idx < pf->main_vsi->nb_qps)
1958 /* It's VMDQ queues */
1959 queue_idx -= pf->main_vsi->nb_qps;
1961 if (pf->nb_cfg_vmdq_vsi)
1962 return queue_idx % pf->vmdq_nb_qps;
1964 PMD_INIT_LOG(ERR, "Fail to get queue offset");
1965 return (uint16_t)(-1);
1970 i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1972 struct i40e_rx_queue *rxq;
1974 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1976 PMD_INIT_FUNC_TRACE();
1978 if (rx_queue_id < dev->data->nb_rx_queues) {
1979 rxq = dev->data->rx_queues[rx_queue_id];
1981 err = i40e_alloc_rx_queue_mbufs(rxq);
1983 PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
1989 /* Init the RX tail regieter. */
1990 I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
1992 err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE);
1995 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
1998 i40e_rx_queue_release_mbufs(rxq);
1999 i40e_reset_rx_queue(rxq);
2001 dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
2008 i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
2010 struct i40e_rx_queue *rxq;
2012 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2014 if (rx_queue_id < dev->data->nb_rx_queues) {
2015 rxq = dev->data->rx_queues[rx_queue_id];
2018 * rx_queue_id is queue id aplication refers to, while
2019 * rxq->reg_idx is the real queue index.
2021 err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
2024 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
2028 i40e_rx_queue_release_mbufs(rxq);
2029 i40e_reset_rx_queue(rxq);
2030 dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
2037 i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
2040 struct i40e_tx_queue *txq;
2041 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2043 PMD_INIT_FUNC_TRACE();
2045 if (tx_queue_id < dev->data->nb_tx_queues) {
2046 txq = dev->data->tx_queues[tx_queue_id];
2049 * tx_queue_id is queue id aplication refers to, while
2050 * rxq->reg_idx is the real queue index.
2052 err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
2054 PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
2057 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
2064 i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
2066 struct i40e_tx_queue *txq;
2068 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2070 if (tx_queue_id < dev->data->nb_tx_queues) {
2071 txq = dev->data->tx_queues[tx_queue_id];
2074 * tx_queue_id is queue id aplication refers to, while
2075 * txq->reg_idx is the real queue index.
2077 err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
2080 PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
2085 i40e_tx_queue_release_mbufs(txq);
2086 i40e_reset_tx_queue(txq);
2087 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
2094 i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
2096 static const uint32_t ptypes[] = {
2097 /* refers to i40e_rxd_pkt_type_mapping() */
2099 RTE_PTYPE_L2_ETHER_TIMESYNC,
2100 RTE_PTYPE_L2_ETHER_LLDP,
2101 RTE_PTYPE_L2_ETHER_ARP,
2102 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2103 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2106 RTE_PTYPE_L4_NONFRAG,
2110 RTE_PTYPE_TUNNEL_GRENAT,
2111 RTE_PTYPE_TUNNEL_IP,
2112 RTE_PTYPE_INNER_L2_ETHER,
2113 RTE_PTYPE_INNER_L2_ETHER_VLAN,
2114 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2115 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2116 RTE_PTYPE_INNER_L4_FRAG,
2117 RTE_PTYPE_INNER_L4_ICMP,
2118 RTE_PTYPE_INNER_L4_NONFRAG,
2119 RTE_PTYPE_INNER_L4_SCTP,
2120 RTE_PTYPE_INNER_L4_TCP,
2121 RTE_PTYPE_INNER_L4_UDP,
2125 if (dev->rx_pkt_burst == i40e_recv_pkts ||
2126 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2127 dev->rx_pkt_burst == i40e_recv_pkts_bulk_alloc ||
2129 dev->rx_pkt_burst == i40e_recv_scattered_pkts)
2135 i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
2138 unsigned int socket_id,
2139 const struct rte_eth_rxconf *rx_conf,
2140 struct rte_mempool *mp)
2142 struct i40e_vsi *vsi;
2143 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2144 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2145 struct i40e_adapter *ad =
2146 I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2147 struct i40e_rx_queue *rxq;
2148 const struct rte_memzone *rz;
2151 uint16_t base, bsf, tc_mapping;
2152 int use_def_burst_func = 1;
2154 if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
2155 struct i40e_vf *vf =
2156 I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2159 vsi = i40e_pf_get_vsi_by_qindex(pf, queue_idx);
2162 PMD_DRV_LOG(ERR, "VSI not available or queue "
2163 "index exceeds the maximum");
2164 return I40E_ERR_PARAM;
2166 if (nb_desc % I40E_ALIGN_RING_DESC != 0 ||
2167 (nb_desc > I40E_MAX_RING_DESC) ||
2168 (nb_desc < I40E_MIN_RING_DESC)) {
2169 PMD_DRV_LOG(ERR, "Number (%u) of receive descriptors is "
2170 "invalid", nb_desc);
2171 return I40E_ERR_PARAM;
2174 /* Free memory if needed */
2175 if (dev->data->rx_queues[queue_idx]) {
2176 i40e_dev_rx_queue_release(dev->data->rx_queues[queue_idx]);
2177 dev->data->rx_queues[queue_idx] = NULL;
2180 /* Allocate the rx queue data structure */
2181 rxq = rte_zmalloc_socket("i40e rx queue",
2182 sizeof(struct i40e_rx_queue),
2183 RTE_CACHE_LINE_SIZE,
2186 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2187 "rx queue data structure");
2191 rxq->nb_rx_desc = nb_desc;
2192 rxq->rx_free_thresh = rx_conf->rx_free_thresh;
2193 rxq->queue_id = queue_idx;
2194 if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF)
2195 rxq->reg_idx = queue_idx;
2196 else /* PF device */
2197 rxq->reg_idx = vsi->base_queue +
2198 i40e_get_queue_offset_by_qindex(pf, queue_idx);
2200 rxq->port_id = dev->data->port_id;
2201 rxq->crc_len = (uint8_t) ((dev->data->dev_conf.rxmode.hw_strip_crc) ?
2203 rxq->drop_en = rx_conf->rx_drop_en;
2205 rxq->rx_deferred_start = rx_conf->rx_deferred_start;
2207 /* Allocate the maximun number of RX ring hardware descriptor. */
2208 ring_size = sizeof(union i40e_rx_desc) * I40E_MAX_RING_DESC;
2209 ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
2210 rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
2211 ring_size, I40E_RING_BASE_ALIGN, socket_id);
2213 i40e_dev_rx_queue_release(rxq);
2214 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX");
2218 /* Zero all the descriptors in the ring. */
2219 memset(rz->addr, 0, ring_size);
2221 rxq->rx_ring_phys_addr = rte_mem_phy2mch(rz->memseg_id, rz->phys_addr);
2222 rxq->rx_ring = (union i40e_rx_desc *)rz->addr;
2224 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2225 len = (uint16_t)(nb_desc + RTE_PMD_I40E_RX_MAX_BURST);
2230 /* Allocate the software ring. */
2232 rte_zmalloc_socket("i40e rx sw ring",
2233 sizeof(struct i40e_rx_entry) * len,
2234 RTE_CACHE_LINE_SIZE,
2236 if (!rxq->sw_ring) {
2237 i40e_dev_rx_queue_release(rxq);
2238 PMD_DRV_LOG(ERR, "Failed to allocate memory for SW ring");
2242 i40e_reset_rx_queue(rxq);
2244 dev->data->rx_queues[queue_idx] = rxq;
2246 use_def_burst_func = check_rx_burst_bulk_alloc_preconditions(rxq);
2248 if (!use_def_burst_func) {
2249 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2250 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
2251 "satisfied. Rx Burst Bulk Alloc function will be "
2252 "used on port=%d, queue=%d.",
2253 rxq->port_id, rxq->queue_id);
2254 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */
2256 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
2257 "not satisfied, Scattered Rx is requested, "
2258 "or RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC is "
2259 "not enabled on port=%d, queue=%d.",
2260 rxq->port_id, rxq->queue_id);
2261 ad->rx_bulk_alloc_allowed = false;
2264 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
2265 if (!(vsi->enabled_tc & (1 << i)))
2267 tc_mapping = rte_le_to_cpu_16(vsi->info.tc_mapping[i]);
2268 base = (tc_mapping & I40E_AQ_VSI_TC_QUE_OFFSET_MASK) >>
2269 I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT;
2270 bsf = (tc_mapping & I40E_AQ_VSI_TC_QUE_NUMBER_MASK) >>
2271 I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT;
2273 if (queue_idx >= base && queue_idx < (base + BIT(bsf)))
2281 i40e_dev_rx_queue_release(void *rxq)
2283 struct i40e_rx_queue *q = (struct i40e_rx_queue *)rxq;
2286 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
2290 i40e_rx_queue_release_mbufs(q);
2291 rte_free(q->sw_ring);
2296 i40e_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
2298 #define I40E_RXQ_SCAN_INTERVAL 4
2299 volatile union i40e_rx_desc *rxdp;
2300 struct i40e_rx_queue *rxq;
2303 if (unlikely(rx_queue_id >= dev->data->nb_rx_queues)) {
2304 PMD_DRV_LOG(ERR, "Invalid RX queue id %u", rx_queue_id);
2308 rxq = dev->data->rx_queues[rx_queue_id];
2309 rxdp = &(rxq->rx_ring[rxq->rx_tail]);
2310 while ((desc < rxq->nb_rx_desc) &&
2311 ((rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
2312 I40E_RXD_QW1_STATUS_MASK) >> I40E_RXD_QW1_STATUS_SHIFT) &
2313 (1 << I40E_RX_DESC_STATUS_DD_SHIFT)) {
2315 * Check the DD bit of a rx descriptor of each 4 in a group,
2316 * to avoid checking too frequently and downgrading performance
2319 desc += I40E_RXQ_SCAN_INTERVAL;
2320 rxdp += I40E_RXQ_SCAN_INTERVAL;
2321 if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
2322 rxdp = &(rxq->rx_ring[rxq->rx_tail +
2323 desc - rxq->nb_rx_desc]);
2330 i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset)
2332 volatile union i40e_rx_desc *rxdp;
2333 struct i40e_rx_queue *rxq = rx_queue;
2337 if (unlikely(offset >= rxq->nb_rx_desc)) {
2338 PMD_DRV_LOG(ERR, "Invalid RX queue id %u", offset);
2342 desc = rxq->rx_tail + offset;
2343 if (desc >= rxq->nb_rx_desc)
2344 desc -= rxq->nb_rx_desc;
2346 rxdp = &(rxq->rx_ring[desc]);
2348 ret = !!(((rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
2349 I40E_RXD_QW1_STATUS_MASK) >> I40E_RXD_QW1_STATUS_SHIFT) &
2350 (1 << I40E_RX_DESC_STATUS_DD_SHIFT));
2356 i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
2359 unsigned int socket_id,
2360 const struct rte_eth_txconf *tx_conf)
2362 struct i40e_vsi *vsi;
2363 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2364 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
2365 struct i40e_tx_queue *txq;
2366 const struct rte_memzone *tz;
2368 uint16_t tx_rs_thresh, tx_free_thresh;
2369 uint16_t i, base, bsf, tc_mapping;
2371 if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
2372 struct i40e_vf *vf =
2373 I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2376 vsi = i40e_pf_get_vsi_by_qindex(pf, queue_idx);
2379 PMD_DRV_LOG(ERR, "VSI is NULL, or queue index (%u) "
2380 "exceeds the maximum", queue_idx);
2381 return I40E_ERR_PARAM;
2384 if (nb_desc % I40E_ALIGN_RING_DESC != 0 ||
2385 (nb_desc > I40E_MAX_RING_DESC) ||
2386 (nb_desc < I40E_MIN_RING_DESC)) {
2387 PMD_DRV_LOG(ERR, "Number (%u) of transmit descriptors is "
2388 "invalid", nb_desc);
2389 return I40E_ERR_PARAM;
2393 * The following two parameters control the setting of the RS bit on
2394 * transmit descriptors. TX descriptors will have their RS bit set
2395 * after txq->tx_rs_thresh descriptors have been used. The TX
2396 * descriptor ring will be cleaned after txq->tx_free_thresh
2397 * descriptors are used or if the number of descriptors required to
2398 * transmit a packet is greater than the number of free TX descriptors.
2400 * The following constraints must be satisfied:
2401 * - tx_rs_thresh must be greater than 0.
2402 * - tx_rs_thresh must be less than the size of the ring minus 2.
2403 * - tx_rs_thresh must be less than or equal to tx_free_thresh.
2404 * - tx_rs_thresh must be a divisor of the ring size.
2405 * - tx_free_thresh must be greater than 0.
2406 * - tx_free_thresh must be less than the size of the ring minus 3.
2408 * One descriptor in the TX ring is used as a sentinel to avoid a H/W
2409 * race condition, hence the maximum threshold constraints. When set
2410 * to zero use default values.
2412 tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh) ?
2413 tx_conf->tx_rs_thresh : DEFAULT_TX_RS_THRESH);
2414 tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
2415 tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH);
2416 if (tx_rs_thresh >= (nb_desc - 2)) {
2417 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
2418 "number of TX descriptors minus 2. "
2419 "(tx_rs_thresh=%u port=%d queue=%d)",
2420 (unsigned int)tx_rs_thresh,
2421 (int)dev->data->port_id,
2423 return I40E_ERR_PARAM;
2425 if (tx_free_thresh >= (nb_desc - 3)) {
2426 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
2427 "tx_free_thresh must be less than the "
2428 "number of TX descriptors minus 3. "
2429 "(tx_free_thresh=%u port=%d queue=%d)",
2430 (unsigned int)tx_free_thresh,
2431 (int)dev->data->port_id,
2433 return I40E_ERR_PARAM;
2435 if (tx_rs_thresh > tx_free_thresh) {
2436 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or "
2437 "equal to tx_free_thresh. (tx_free_thresh=%u"
2438 " tx_rs_thresh=%u port=%d queue=%d)",
2439 (unsigned int)tx_free_thresh,
2440 (unsigned int)tx_rs_thresh,
2441 (int)dev->data->port_id,
2443 return I40E_ERR_PARAM;
2445 if ((nb_desc % tx_rs_thresh) != 0) {
2446 PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
2447 "number of TX descriptors. (tx_rs_thresh=%u"
2448 " port=%d queue=%d)",
2449 (unsigned int)tx_rs_thresh,
2450 (int)dev->data->port_id,
2452 return I40E_ERR_PARAM;
2454 if ((tx_rs_thresh > 1) && (tx_conf->tx_thresh.wthresh != 0)) {
2455 PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
2456 "tx_rs_thresh is greater than 1. "
2457 "(tx_rs_thresh=%u port=%d queue=%d)",
2458 (unsigned int)tx_rs_thresh,
2459 (int)dev->data->port_id,
2461 return I40E_ERR_PARAM;
2464 /* Free memory if needed. */
2465 if (dev->data->tx_queues[queue_idx]) {
2466 i40e_dev_tx_queue_release(dev->data->tx_queues[queue_idx]);
2467 dev->data->tx_queues[queue_idx] = NULL;
2470 /* Allocate the TX queue data structure. */
2471 txq = rte_zmalloc_socket("i40e tx queue",
2472 sizeof(struct i40e_tx_queue),
2473 RTE_CACHE_LINE_SIZE,
2476 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2477 "tx queue structure");
2481 /* Allocate TX hardware ring descriptors. */
2482 ring_size = sizeof(struct i40e_tx_desc) * I40E_MAX_RING_DESC;
2483 ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
2484 tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx,
2485 ring_size, I40E_RING_BASE_ALIGN, socket_id);
2487 i40e_dev_tx_queue_release(txq);
2488 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX");
2492 txq->nb_tx_desc = nb_desc;
2493 txq->tx_rs_thresh = tx_rs_thresh;
2494 txq->tx_free_thresh = tx_free_thresh;
2495 txq->pthresh = tx_conf->tx_thresh.pthresh;
2496 txq->hthresh = tx_conf->tx_thresh.hthresh;
2497 txq->wthresh = tx_conf->tx_thresh.wthresh;
2498 txq->queue_id = queue_idx;
2499 if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF)
2500 txq->reg_idx = queue_idx;
2501 else /* PF device */
2502 txq->reg_idx = vsi->base_queue +
2503 i40e_get_queue_offset_by_qindex(pf, queue_idx);
2505 txq->port_id = dev->data->port_id;
2506 txq->txq_flags = tx_conf->txq_flags;
2508 txq->tx_deferred_start = tx_conf->tx_deferred_start;
2510 txq->tx_ring_phys_addr = rte_mem_phy2mch(tz->memseg_id, tz->phys_addr);
2511 txq->tx_ring = (struct i40e_tx_desc *)tz->addr;
2513 /* Allocate software ring */
2515 rte_zmalloc_socket("i40e tx sw ring",
2516 sizeof(struct i40e_tx_entry) * nb_desc,
2517 RTE_CACHE_LINE_SIZE,
2519 if (!txq->sw_ring) {
2520 i40e_dev_tx_queue_release(txq);
2521 PMD_DRV_LOG(ERR, "Failed to allocate memory for SW TX ring");
2525 i40e_reset_tx_queue(txq);
2527 dev->data->tx_queues[queue_idx] = txq;
2529 /* Use a simple TX queue without offloads or multi segs if possible */
2530 i40e_set_tx_function_flag(dev, txq);
2532 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
2533 if (!(vsi->enabled_tc & (1 << i)))
2535 tc_mapping = rte_le_to_cpu_16(vsi->info.tc_mapping[i]);
2536 base = (tc_mapping & I40E_AQ_VSI_TC_QUE_OFFSET_MASK) >>
2537 I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT;
2538 bsf = (tc_mapping & I40E_AQ_VSI_TC_QUE_NUMBER_MASK) >>
2539 I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT;
2541 if (queue_idx >= base && queue_idx < (base + BIT(bsf)))
2549 i40e_dev_tx_queue_release(void *txq)
2551 struct i40e_tx_queue *q = (struct i40e_tx_queue *)txq;
2554 PMD_DRV_LOG(DEBUG, "Pointer to TX queue is NULL");
2558 i40e_tx_queue_release_mbufs(q);
2559 rte_free(q->sw_ring);
2563 const struct rte_memzone *
2564 i40e_memzone_reserve(const char *name, uint32_t len, int socket_id)
2566 const struct rte_memzone *mz;
2568 mz = rte_memzone_lookup(name);
2572 if (rte_xen_dom0_supported())
2573 mz = rte_memzone_reserve_bounded(name, len,
2574 socket_id, 0, I40E_RING_BASE_ALIGN, RTE_PGSIZE_2M);
2576 mz = rte_memzone_reserve_aligned(name, len,
2577 socket_id, 0, I40E_RING_BASE_ALIGN);
2582 i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
2586 /* SSE Vector driver has a different way of releasing mbufs. */
2587 if (rxq->rx_using_sse) {
2588 i40e_rx_queue_release_mbufs_vec(rxq);
2592 if (!rxq || !rxq->sw_ring) {
2593 PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
2597 for (i = 0; i < rxq->nb_rx_desc; i++) {
2598 if (rxq->sw_ring[i].mbuf) {
2599 rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf);
2600 rxq->sw_ring[i].mbuf = NULL;
2603 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2604 if (rxq->rx_nb_avail == 0)
2606 for (i = 0; i < rxq->rx_nb_avail; i++) {
2607 struct rte_mbuf *mbuf;
2609 mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
2610 rte_pktmbuf_free_seg(mbuf);
2612 rxq->rx_nb_avail = 0;
2613 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */
2617 i40e_reset_rx_queue(struct i40e_rx_queue *rxq)
2623 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
2627 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2628 if (check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
2629 len = (uint16_t)(rxq->nb_rx_desc + RTE_PMD_I40E_RX_MAX_BURST);
2631 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */
2632 len = rxq->nb_rx_desc;
2634 for (i = 0; i < len * sizeof(union i40e_rx_desc); i++)
2635 ((volatile char *)rxq->rx_ring)[i] = 0;
2637 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
2638 memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
2639 for (i = 0; i < RTE_PMD_I40E_RX_MAX_BURST; ++i)
2640 rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
2642 rxq->rx_nb_avail = 0;
2643 rxq->rx_next_avail = 0;
2644 rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
2645 #endif /* RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC */
2647 rxq->nb_rx_hold = 0;
2648 rxq->pkt_first_seg = NULL;
2649 rxq->pkt_last_seg = NULL;
2651 rxq->rxrearm_start = 0;
2652 rxq->rxrearm_nb = 0;
2656 i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)
2660 if (!txq || !txq->sw_ring) {
2661 PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
2665 for (i = 0; i < txq->nb_tx_desc; i++) {
2666 if (txq->sw_ring[i].mbuf) {
2667 rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
2668 txq->sw_ring[i].mbuf = NULL;
2674 i40e_reset_tx_queue(struct i40e_tx_queue *txq)
2676 struct i40e_tx_entry *txe;
2677 uint16_t i, prev, size;
2680 PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
2685 size = sizeof(struct i40e_tx_desc) * txq->nb_tx_desc;
2686 for (i = 0; i < size; i++)
2687 ((volatile char *)txq->tx_ring)[i] = 0;
2689 prev = (uint16_t)(txq->nb_tx_desc - 1);
2690 for (i = 0; i < txq->nb_tx_desc; i++) {
2691 volatile struct i40e_tx_desc *txd = &txq->tx_ring[i];
2693 txd->cmd_type_offset_bsz =
2694 rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE);
2697 txe[prev].next_id = i;
2701 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
2702 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
2705 txq->nb_tx_used = 0;
2707 txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
2708 txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
2711 /* Init the TX queue in hardware */
2713 i40e_tx_queue_init(struct i40e_tx_queue *txq)
2715 enum i40e_status_code err = I40E_SUCCESS;
2716 struct i40e_vsi *vsi = txq->vsi;
2717 struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
2718 uint16_t pf_q = txq->reg_idx;
2719 struct i40e_hmc_obj_txq tx_ctx;
2722 /* clear the context structure first */
2723 memset(&tx_ctx, 0, sizeof(tx_ctx));
2724 tx_ctx.new_context = 1;
2725 tx_ctx.base = txq->tx_ring_phys_addr / I40E_QUEUE_BASE_ADDR_UNIT;
2726 tx_ctx.qlen = txq->nb_tx_desc;
2728 #ifdef RTE_LIBRTE_IEEE1588
2729 tx_ctx.timesync_ena = 1;
2731 tx_ctx.rdylist = rte_le_to_cpu_16(vsi->info.qs_handle[txq->dcb_tc]);
2732 if (vsi->type == I40E_VSI_FDIR)
2733 tx_ctx.fd_ena = TRUE;
2735 err = i40e_clear_lan_tx_queue_context(hw, pf_q);
2736 if (err != I40E_SUCCESS) {
2737 PMD_DRV_LOG(ERR, "Failure of clean lan tx queue context");
2741 err = i40e_set_lan_tx_queue_context(hw, pf_q, &tx_ctx);
2742 if (err != I40E_SUCCESS) {
2743 PMD_DRV_LOG(ERR, "Failure of set lan tx queue context");
2747 /* Now associate this queue with this PCI function */
2748 qtx_ctl = I40E_QTX_CTL_PF_QUEUE;
2749 qtx_ctl |= ((hw->pf_id << I40E_QTX_CTL_PF_INDX_SHIFT) &
2750 I40E_QTX_CTL_PF_INDX_MASK);
2751 I40E_WRITE_REG(hw, I40E_QTX_CTL(pf_q), qtx_ctl);
2752 I40E_WRITE_FLUSH(hw);
2754 txq->qtx_tail = hw->hw_addr + I40E_QTX_TAIL(pf_q);
2760 i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq)
2762 struct i40e_rx_entry *rxe = rxq->sw_ring;
2766 for (i = 0; i < rxq->nb_rx_desc; i++) {
2767 volatile union i40e_rx_desc *rxd;
2768 struct rte_mbuf *mbuf = rte_rxmbuf_alloc(rxq->mp);
2770 if (unlikely(!mbuf)) {
2771 PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
2775 rte_mbuf_refcnt_set(mbuf, 1);
2777 mbuf->data_off = RTE_PKTMBUF_HEADROOM;
2779 mbuf->port = rxq->port_id;
2782 rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(mbuf));
2784 rxd = &rxq->rx_ring[i];
2785 rxd->read.pkt_addr = dma_addr;
2786 rxd->read.hdr_addr = 0;
2787 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
2788 rxd->read.rsvd1 = 0;
2789 rxd->read.rsvd2 = 0;
2790 #endif /* RTE_LIBRTE_I40E_16BYTE_RX_DESC */
2799 * Calculate the buffer length, and check the jumbo frame
2800 * and maximum packet length.
2803 i40e_rx_queue_config(struct i40e_rx_queue *rxq)
2805 struct i40e_pf *pf = I40E_VSI_TO_PF(rxq->vsi);
2806 struct i40e_hw *hw = I40E_VSI_TO_HW(rxq->vsi);
2807 struct rte_eth_dev_data *data = pf->dev_data;
2808 uint16_t buf_size, len;
2810 buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
2811 RTE_PKTMBUF_HEADROOM);
2813 switch (pf->flags & (I40E_FLAG_HEADER_SPLIT_DISABLED |
2814 I40E_FLAG_HEADER_SPLIT_ENABLED)) {
2815 case I40E_FLAG_HEADER_SPLIT_ENABLED: /* Not supported */
2816 rxq->rx_hdr_len = RTE_ALIGN(I40E_RXBUF_SZ_1024,
2817 (1 << I40E_RXQ_CTX_HBUFF_SHIFT));
2818 rxq->rx_buf_len = RTE_ALIGN(I40E_RXBUF_SZ_2048,
2819 (1 << I40E_RXQ_CTX_DBUFF_SHIFT));
2820 rxq->hs_mode = i40e_header_split_enabled;
2822 case I40E_FLAG_HEADER_SPLIT_DISABLED:
2824 rxq->rx_hdr_len = 0;
2825 rxq->rx_buf_len = RTE_ALIGN(buf_size,
2826 (1 << I40E_RXQ_CTX_DBUFF_SHIFT));
2827 rxq->hs_mode = i40e_header_split_none;
2831 len = hw->func_caps.rx_buf_chain_len * rxq->rx_buf_len;
2832 rxq->max_pkt_len = RTE_MIN(len, data->dev_conf.rxmode.max_rx_pkt_len);
2833 if (data->dev_conf.rxmode.jumbo_frame == 1) {
2834 if (rxq->max_pkt_len <= ETHER_MAX_LEN ||
2835 rxq->max_pkt_len > I40E_FRAME_SIZE_MAX) {
2836 PMD_DRV_LOG(ERR, "maximum packet length must "
2837 "be larger than %u and smaller than %u,"
2838 "as jumbo frame is enabled",
2839 (uint32_t)ETHER_MAX_LEN,
2840 (uint32_t)I40E_FRAME_SIZE_MAX);
2841 return I40E_ERR_CONFIG;
2844 if (rxq->max_pkt_len < ETHER_MIN_LEN ||
2845 rxq->max_pkt_len > ETHER_MAX_LEN) {
2846 PMD_DRV_LOG(ERR, "maximum packet length must be "
2847 "larger than %u and smaller than %u, "
2848 "as jumbo frame is disabled",
2849 (uint32_t)ETHER_MIN_LEN,
2850 (uint32_t)ETHER_MAX_LEN);
2851 return I40E_ERR_CONFIG;
2858 /* Init the RX queue in hardware */
2860 i40e_rx_queue_init(struct i40e_rx_queue *rxq)
2862 int err = I40E_SUCCESS;
2863 struct i40e_hw *hw = I40E_VSI_TO_HW(rxq->vsi);
2864 struct rte_eth_dev_data *dev_data = I40E_VSI_TO_DEV_DATA(rxq->vsi);
2865 uint16_t pf_q = rxq->reg_idx;
2867 struct i40e_hmc_obj_rxq rx_ctx;
2869 err = i40e_rx_queue_config(rxq);
2871 PMD_DRV_LOG(ERR, "Failed to config RX queue");
2875 /* Clear the context structure first */
2876 memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq));
2877 rx_ctx.dbuff = rxq->rx_buf_len >> I40E_RXQ_CTX_DBUFF_SHIFT;
2878 rx_ctx.hbuff = rxq->rx_hdr_len >> I40E_RXQ_CTX_HBUFF_SHIFT;
2880 rx_ctx.base = rxq->rx_ring_phys_addr / I40E_QUEUE_BASE_ADDR_UNIT;
2881 rx_ctx.qlen = rxq->nb_rx_desc;
2882 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
2885 rx_ctx.dtype = rxq->hs_mode;
2887 rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_ALL;
2889 rx_ctx.hsplit_0 = I40E_HEADER_SPLIT_NONE;
2890 rx_ctx.rxmax = rxq->max_pkt_len;
2891 rx_ctx.tphrdesc_ena = 1;
2892 rx_ctx.tphwdesc_ena = 1;
2893 rx_ctx.tphdata_ena = 1;
2894 rx_ctx.tphhead_ena = 1;
2895 rx_ctx.lrxqthresh = 2;
2896 rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
2901 err = i40e_clear_lan_rx_queue_context(hw, pf_q);
2902 if (err != I40E_SUCCESS) {
2903 PMD_DRV_LOG(ERR, "Failed to clear LAN RX queue context");
2906 err = i40e_set_lan_rx_queue_context(hw, pf_q, &rx_ctx);
2907 if (err != I40E_SUCCESS) {
2908 PMD_DRV_LOG(ERR, "Failed to set LAN RX queue context");
2912 rxq->qrx_tail = hw->hw_addr + I40E_QRX_TAIL(pf_q);
2914 buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
2915 RTE_PKTMBUF_HEADROOM);
2917 /* Check if scattered RX needs to be used. */
2918 if ((rxq->max_pkt_len + 2 * I40E_VLAN_TAG_SIZE) > buf_size) {
2919 dev_data->scattered_rx = 1;
2922 /* Init the RX tail regieter. */
2923 I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
2929 i40e_dev_clear_queues(struct rte_eth_dev *dev)
2933 PMD_INIT_FUNC_TRACE();
2935 for (i = 0; i < dev->data->nb_tx_queues; i++) {
2936 i40e_tx_queue_release_mbufs(dev->data->tx_queues[i]);
2937 i40e_reset_tx_queue(dev->data->tx_queues[i]);
2940 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2941 i40e_rx_queue_release_mbufs(dev->data->rx_queues[i]);
2942 i40e_reset_rx_queue(dev->data->rx_queues[i]);
2947 i40e_dev_free_queues(struct rte_eth_dev *dev)
2951 PMD_INIT_FUNC_TRACE();
2953 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2954 i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
2955 dev->data->rx_queues[i] = NULL;
2957 dev->data->nb_rx_queues = 0;
2959 for (i = 0; i < dev->data->nb_tx_queues; i++) {
2960 i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
2961 dev->data->tx_queues[i] = NULL;
2963 dev->data->nb_tx_queues = 0;
2966 #define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC
2967 #define I40E_FDIR_NUM_RX_DESC I40E_MIN_RING_DESC
2969 enum i40e_status_code
2970 i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
2972 struct i40e_tx_queue *txq;
2973 const struct rte_memzone *tz = NULL;
2975 struct rte_eth_dev *dev = pf->adapter->eth_dev;
2978 PMD_DRV_LOG(ERR, "PF is not available");
2979 return I40E_ERR_BAD_PTR;
2982 /* Allocate the TX queue data structure. */
2983 txq = rte_zmalloc_socket("i40e fdir tx queue",
2984 sizeof(struct i40e_tx_queue),
2985 RTE_CACHE_LINE_SIZE,
2988 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2989 "tx queue structure.");
2990 return I40E_ERR_NO_MEMORY;
2993 /* Allocate TX hardware ring descriptors. */
2994 ring_size = sizeof(struct i40e_tx_desc) * I40E_FDIR_NUM_TX_DESC;
2995 ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
2997 tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
2998 I40E_FDIR_QUEUE_ID, ring_size,
2999 I40E_RING_BASE_ALIGN, SOCKET_ID_ANY);
3001 i40e_dev_tx_queue_release(txq);
3002 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
3003 return I40E_ERR_NO_MEMORY;
3006 txq->nb_tx_desc = I40E_FDIR_NUM_TX_DESC;
3007 txq->queue_id = I40E_FDIR_QUEUE_ID;
3008 txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
3009 txq->vsi = pf->fdir.fdir_vsi;
3011 txq->tx_ring_phys_addr = rte_mem_phy2mch(tz->memseg_id, tz->phys_addr);
3012 txq->tx_ring = (struct i40e_tx_desc *)tz->addr;
3014 * don't need to allocate software ring and reset for the fdir
3015 * program queue just set the queue has been configured.
3020 return I40E_SUCCESS;
3023 enum i40e_status_code
3024 i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
3026 struct i40e_rx_queue *rxq;
3027 const struct rte_memzone *rz = NULL;
3029 struct rte_eth_dev *dev = pf->adapter->eth_dev;
3032 PMD_DRV_LOG(ERR, "PF is not available");
3033 return I40E_ERR_BAD_PTR;
3036 /* Allocate the RX queue data structure. */
3037 rxq = rte_zmalloc_socket("i40e fdir rx queue",
3038 sizeof(struct i40e_rx_queue),
3039 RTE_CACHE_LINE_SIZE,
3042 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
3043 "rx queue structure.");
3044 return I40E_ERR_NO_MEMORY;
3047 /* Allocate RX hardware ring descriptors. */
3048 ring_size = sizeof(union i40e_rx_desc) * I40E_FDIR_NUM_RX_DESC;
3049 ring_size = RTE_ALIGN(ring_size, I40E_DMA_MEM_ALIGN);
3051 rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
3052 I40E_FDIR_QUEUE_ID, ring_size,
3053 I40E_RING_BASE_ALIGN, SOCKET_ID_ANY);
3055 i40e_dev_rx_queue_release(rxq);
3056 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
3057 return I40E_ERR_NO_MEMORY;
3060 rxq->nb_rx_desc = I40E_FDIR_NUM_RX_DESC;
3061 rxq->queue_id = I40E_FDIR_QUEUE_ID;
3062 rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
3063 rxq->vsi = pf->fdir.fdir_vsi;
3065 rxq->rx_ring_phys_addr = rte_mem_phy2mch(rz->memseg_id, rz->phys_addr);
3066 rxq->rx_ring = (union i40e_rx_desc *)rz->addr;
3069 * Don't need to allocate software ring and reset for the fdir
3070 * rx queue, just set the queue has been configured.
3075 return I40E_SUCCESS;
3079 i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
3080 struct rte_eth_rxq_info *qinfo)
3082 struct i40e_rx_queue *rxq;
3084 rxq = dev->data->rx_queues[queue_id];
3086 qinfo->mp = rxq->mp;
3087 qinfo->scattered_rx = dev->data->scattered_rx;
3088 qinfo->nb_desc = rxq->nb_rx_desc;
3090 qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
3091 qinfo->conf.rx_drop_en = rxq->drop_en;
3092 qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
3096 i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
3097 struct rte_eth_txq_info *qinfo)
3099 struct i40e_tx_queue *txq;
3101 txq = dev->data->tx_queues[queue_id];
3103 qinfo->nb_desc = txq->nb_tx_desc;
3105 qinfo->conf.tx_thresh.pthresh = txq->pthresh;
3106 qinfo->conf.tx_thresh.hthresh = txq->hthresh;
3107 qinfo->conf.tx_thresh.wthresh = txq->wthresh;
3109 qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
3110 qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
3111 qinfo->conf.txq_flags = txq->txq_flags;
3112 qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
3115 void __attribute__((cold))
3116 i40e_set_rx_function(struct rte_eth_dev *dev)
3118 struct i40e_adapter *ad =
3119 I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3120 uint16_t rx_using_sse, i;
3121 /* In order to allow Vector Rx there are a few configuration
3122 * conditions to be met and Rx Bulk Allocation should be allowed.
3124 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3125 if (i40e_rx_vec_dev_conf_condition_check(dev) ||
3126 !ad->rx_bulk_alloc_allowed) {
3127 PMD_INIT_LOG(DEBUG, "Port[%d] doesn't meet"
3128 " Vector Rx preconditions",
3129 dev->data->port_id);
3131 ad->rx_vec_allowed = false;
3133 if (ad->rx_vec_allowed) {
3134 for (i = 0; i < dev->data->nb_rx_queues; i++) {
3135 struct i40e_rx_queue *rxq =
3136 dev->data->rx_queues[i];
3138 if (i40e_rxq_vec_setup(rxq)) {
3139 ad->rx_vec_allowed = false;
3146 if (dev->data->scattered_rx) {
3147 /* Set the non-LRO scattered callback: there are Vector and
3148 * single allocation versions.
3150 if (ad->rx_vec_allowed) {
3151 PMD_INIT_LOG(DEBUG, "Using Vector Scattered Rx "
3152 "callback (port=%d).",
3153 dev->data->port_id);
3155 dev->rx_pkt_burst = i40e_recv_scattered_pkts_vec;
3157 PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
3158 "allocation callback (port=%d).",
3159 dev->data->port_id);
3160 dev->rx_pkt_burst = i40e_recv_scattered_pkts;
3162 /* If parameters allow we are going to choose between the following
3166 * - Single buffer allocation (the simplest one)
3168 } else if (ad->rx_vec_allowed) {
3169 PMD_INIT_LOG(DEBUG, "Vector rx enabled, please make sure RX "
3170 "burst size no less than %d (port=%d).",
3171 RTE_I40E_DESCS_PER_LOOP,
3172 dev->data->port_id);
3174 dev->rx_pkt_burst = i40e_recv_pkts_vec;
3175 } else if (ad->rx_bulk_alloc_allowed) {
3176 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
3177 "satisfied. Rx Burst Bulk Alloc function "
3178 "will be used on port=%d.",
3179 dev->data->port_id);
3181 dev->rx_pkt_burst = i40e_recv_pkts_bulk_alloc;
3183 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are not "
3184 "satisfied, or Scattered Rx is requested "
3186 dev->data->port_id);
3188 dev->rx_pkt_burst = i40e_recv_pkts;
3191 /* Propagate information about RX function choice through all queues. */
3192 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3194 (dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
3195 dev->rx_pkt_burst == i40e_recv_pkts_vec);
3197 for (i = 0; i < dev->data->nb_rx_queues; i++) {
3198 struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
3200 rxq->rx_using_sse = rx_using_sse;
3205 void __attribute__((cold))
3206 i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
3208 struct i40e_adapter *ad =
3209 I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3211 /* Use a simple Tx queue (no offloads, no multi segs) if possible */
3212 if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
3213 && (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
3214 if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
3215 PMD_INIT_LOG(DEBUG, "Vector tx"
3216 " can be enabled on this txq.");
3219 ad->tx_vec_allowed = false;
3222 ad->tx_simple_allowed = false;
3226 void __attribute__((cold))
3227 i40e_set_tx_function(struct rte_eth_dev *dev)
3229 struct i40e_adapter *ad =
3230 I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3233 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3234 if (ad->tx_vec_allowed) {
3235 for (i = 0; i < dev->data->nb_tx_queues; i++) {
3236 struct i40e_tx_queue *txq =
3237 dev->data->tx_queues[i];
3239 if (i40e_txq_vec_setup(txq)) {
3240 ad->tx_vec_allowed = false;
3247 if (ad->tx_simple_allowed) {
3248 if (ad->tx_vec_allowed) {
3249 PMD_INIT_LOG(DEBUG, "Vector tx finally be used.");
3250 dev->tx_pkt_burst = i40e_xmit_pkts_vec;
3252 PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
3253 dev->tx_pkt_burst = i40e_xmit_pkts_simple;
3256 PMD_INIT_LOG(DEBUG, "Xmit tx finally be used.");
3257 dev->tx_pkt_burst = i40e_xmit_pkts;
3261 /* Stubs needed for linkage when CONFIG_RTE_I40E_INC_VECTOR is set to 'n' */
3262 int __attribute__((weak))
3263 i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev)
3268 uint16_t __attribute__((weak))
3270 void __rte_unused *rx_queue,
3271 struct rte_mbuf __rte_unused **rx_pkts,
3272 uint16_t __rte_unused nb_pkts)
3277 uint16_t __attribute__((weak))
3278 i40e_recv_scattered_pkts_vec(
3279 void __rte_unused *rx_queue,
3280 struct rte_mbuf __rte_unused **rx_pkts,
3281 uint16_t __rte_unused nb_pkts)
3286 int __attribute__((weak))
3287 i40e_rxq_vec_setup(struct i40e_rx_queue __rte_unused *rxq)
3292 int __attribute__((weak))
3293 i40e_txq_vec_setup(struct i40e_tx_queue __rte_unused *txq)
3298 void __attribute__((weak))
3299 i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue __rte_unused*rxq)
3304 uint16_t __attribute__((weak))
3305 i40e_xmit_pkts_vec(void __rte_unused *tx_queue,
3306 struct rte_mbuf __rte_unused **tx_pkts,
3307 uint16_t __rte_unused nb_pkts)