Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <stdlib.h>
7 : : #include <string.h>
8 : : #include <errno.h>
9 : : #include <stdint.h>
10 : : #include <stdarg.h>
11 : : #include <unistd.h>
12 : : #include <inttypes.h>
13 : : #include <sys/queue.h>
14 : :
15 : : #include <rte_string_fns.h>
16 : : #include <rte_memzone.h>
17 : : #include <rte_mbuf.h>
18 : : #include <rte_malloc.h>
19 : : #include <rte_ether.h>
20 : : #include <ethdev_driver.h>
21 : : #include <rte_tcp.h>
22 : : #include <rte_sctp.h>
23 : : #include <rte_udp.h>
24 : : #include <rte_ip.h>
25 : : #include <rte_net.h>
26 : : #include <rte_vect.h>
27 : : #include <rte_vxlan.h>
28 : : #include <rte_gtp.h>
29 : : #include <rte_geneve.h>
30 : :
31 : : #include "iavf.h"
32 : : #include "iavf_rxtx.h"
33 : : #include "iavf_ipsec_crypto.h"
34 : : #include "rte_pmd_iavf.h"
35 : :
36 : : #define GRE_CHECKSUM_PRESENT 0x8000
37 : : #define GRE_KEY_PRESENT 0x2000
38 : : #define GRE_SEQUENCE_PRESENT 0x1000
39 : : #define GRE_EXT_LEN 4
40 : : #define GRE_SUPPORTED_FIELDS (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
41 : : GRE_SEQUENCE_PRESENT)
42 : :
43 : : #ifndef IPPROTO_IPIP
44 : : #define IPPROTO_IPIP 4
45 : : #endif
46 : : #ifndef IPPROTO_GRE
47 : : #define IPPROTO_GRE 47
48 : : #endif
49 : :
50 : : static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
51 : : static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
52 : :
53 : : struct simple_gre_hdr {
54 : : uint16_t flags;
55 : : uint16_t proto;
56 : : };
57 : :
58 : : /* structure that caches offload info for the current packet */
59 : : struct offload_info {
60 : : uint16_t ethertype;
61 : : uint8_t gso_enable;
62 : : uint16_t l2_len;
63 : : uint16_t l3_len;
64 : : uint16_t l4_len;
65 : : uint8_t l4_proto;
66 : : uint8_t is_tunnel;
67 : : uint16_t outer_ethertype;
68 : : uint16_t outer_l2_len;
69 : : uint16_t outer_l3_len;
70 : : uint8_t outer_l4_proto;
71 : : uint16_t tso_segsz;
72 : : uint16_t tunnel_tso_segsz;
73 : : uint32_t pkt_len;
74 : : };
75 : :
76 : : /* Offset of mbuf dynamic field for protocol extraction's metadata */
77 : : int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
78 : :
79 : : /* Mask of mbuf dynamic flags for protocol extraction's type */
80 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_vlan_mask;
81 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask;
82 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask;
83 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask;
84 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
85 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
86 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
87 : :
88 : : uint8_t
89 : 0 : iavf_proto_xtr_type_to_rxdid(uint8_t flex_type)
90 : : {
91 : : static uint8_t rxdid_map[] = {
92 : : [IAVF_PROTO_XTR_NONE] = IAVF_RXDID_COMMS_OVS_1,
93 : : [IAVF_PROTO_XTR_VLAN] = IAVF_RXDID_COMMS_AUX_VLAN,
94 : : [IAVF_PROTO_XTR_IPV4] = IAVF_RXDID_COMMS_AUX_IPV4,
95 : : [IAVF_PROTO_XTR_IPV6] = IAVF_RXDID_COMMS_AUX_IPV6,
96 : : [IAVF_PROTO_XTR_IPV6_FLOW] = IAVF_RXDID_COMMS_AUX_IPV6_FLOW,
97 : : [IAVF_PROTO_XTR_TCP] = IAVF_RXDID_COMMS_AUX_TCP,
98 : : [IAVF_PROTO_XTR_IP_OFFSET] = IAVF_RXDID_COMMS_AUX_IP_OFFSET,
99 : : [IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID] =
100 : : IAVF_RXDID_COMMS_IPSEC_CRYPTO,
101 : : };
102 : :
103 : : return flex_type < RTE_DIM(rxdid_map) ?
104 [ # # ]: 0 : rxdid_map[flex_type] : IAVF_RXDID_COMMS_OVS_1;
105 : : }
106 : :
107 : : static int
108 : 0 : iavf_monitor_callback(const uint64_t value,
109 : : const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
110 : : {
111 : : const uint64_t m = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
112 : : /*
113 : : * we expect the DD bit to be set to 1 if this descriptor was already
114 : : * written to.
115 : : */
116 [ # # ]: 0 : return (value & m) == m ? -1 : 0;
117 : : }
118 : :
119 : : int
120 : 0 : iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
121 : : {
122 : : struct iavf_rx_queue *rxq = rx_queue;
123 : : volatile union iavf_rx_desc *rxdp;
124 : : uint16_t desc;
125 : :
126 : 0 : desc = rxq->rx_tail;
127 : 0 : rxdp = &rxq->rx_ring[desc];
128 : : /* watch for changes in status bit */
129 : 0 : pmc->addr = &rxdp->wb.qword1.status_error_len;
130 : :
131 : : /* comparison callback */
132 : 0 : pmc->fn = iavf_monitor_callback;
133 : :
134 : : /* registers are 64-bit */
135 : 0 : pmc->size = sizeof(uint64_t);
136 : :
137 : 0 : return 0;
138 : : }
139 : :
140 : : static inline int
141 : : check_rx_thresh(uint16_t nb_desc, uint16_t thresh)
142 : : {
143 : : /* The following constraints must be satisfied:
144 : : * thresh < rxq->nb_rx_desc
145 : : */
146 : 0 : if (thresh >= nb_desc) {
147 : 0 : PMD_INIT_LOG(ERR, "rx_free_thresh (%u) must be less than %u",
148 : : thresh, nb_desc);
149 : : return -EINVAL;
150 : : }
151 : : return 0;
152 : : }
153 : :
154 : : static inline int
155 : 0 : check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
156 : : uint16_t tx_free_thresh)
157 : : {
158 : : /* TX descriptors will have their RS bit set after tx_rs_thresh
159 : : * descriptors have been used. The TX descriptor ring will be cleaned
160 : : * after tx_free_thresh descriptors are used or if the number of
161 : : * descriptors required to transmit a packet is greater than the
162 : : * number of free TX descriptors.
163 : : *
164 : : * The following constraints must be satisfied:
165 : : * - tx_rs_thresh must be less than the size of the ring minus 2.
166 : : * - tx_free_thresh must be less than the size of the ring minus 3.
167 : : * - tx_rs_thresh must be less than or equal to tx_free_thresh.
168 : : * - tx_rs_thresh must be a divisor of the ring size.
169 : : *
170 : : * One descriptor in the TX ring is used as a sentinel to avoid a H/W
171 : : * race condition, hence the maximum threshold constraints. When set
172 : : * to zero use default values.
173 : : */
174 [ # # ]: 0 : if (tx_rs_thresh >= (nb_desc - 2)) {
175 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be less than the "
176 : : "number of TX descriptors (%u) minus 2",
177 : : tx_rs_thresh, nb_desc);
178 : 0 : return -EINVAL;
179 : : }
180 [ # # ]: 0 : if (tx_free_thresh >= (nb_desc - 3)) {
181 : 0 : PMD_INIT_LOG(ERR, "tx_free_thresh (%u) must be less than the "
182 : : "number of TX descriptors (%u) minus 3.",
183 : : tx_free_thresh, nb_desc);
184 : 0 : return -EINVAL;
185 : : }
186 [ # # ]: 0 : if (tx_rs_thresh > tx_free_thresh) {
187 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be less than or "
188 : : "equal to tx_free_thresh (%u).",
189 : : tx_rs_thresh, tx_free_thresh);
190 : 0 : return -EINVAL;
191 : : }
192 [ # # ]: 0 : if ((nb_desc % tx_rs_thresh) != 0) {
193 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be a divisor of the "
194 : : "number of TX descriptors (%u).",
195 : : tx_rs_thresh, nb_desc);
196 : 0 : return -EINVAL;
197 : : }
198 : :
199 : : return 0;
200 : : }
201 : :
202 : : static inline bool
203 : 0 : check_tx_vec_allow(struct ci_tx_queue *txq)
204 : : {
205 [ # # ]: 0 : if (!(txq->offloads & IAVF_TX_NO_VECTOR_FLAGS) &&
206 [ # # # # ]: 0 : txq->tx_rs_thresh >= IAVF_VPMD_TX_MAX_BURST &&
207 : : txq->tx_rs_thresh <= IAVF_VPMD_TX_MAX_FREE_BUF) {
208 : 0 : PMD_INIT_LOG(DEBUG, "Vector tx can be enabled on this txq.");
209 : 0 : return true;
210 : : }
211 : 0 : PMD_INIT_LOG(DEBUG, "Vector Tx cannot be enabled on this txq.");
212 : 0 : return false;
213 : : }
214 : :
215 : : static inline bool
216 : 0 : check_rx_bulk_allow(struct iavf_rx_queue *rxq)
217 : : {
218 : : int ret = true;
219 : :
220 [ # # ]: 0 : if (!(rxq->rx_free_thresh >= IAVF_RX_MAX_BURST)) {
221 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
222 : : "rxq->rx_free_thresh=%d, "
223 : : "IAVF_RX_MAX_BURST=%d",
224 : : rxq->rx_free_thresh, IAVF_RX_MAX_BURST);
225 : : ret = false;
226 [ # # ]: 0 : } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
227 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
228 : : "rxq->nb_rx_desc=%d, "
229 : : "rxq->rx_free_thresh=%d",
230 : : rxq->nb_rx_desc, rxq->rx_free_thresh);
231 : : ret = false;
232 : : }
233 : 0 : return ret;
234 : : }
235 : :
236 : : static inline void
237 : 0 : reset_rx_queue(struct iavf_rx_queue *rxq)
238 : : {
239 : : uint16_t len;
240 : : uint32_t i;
241 : :
242 [ # # ]: 0 : if (!rxq)
243 : : return;
244 : :
245 : 0 : len = rxq->nb_rx_desc + IAVF_RX_MAX_BURST;
246 : :
247 [ # # ]: 0 : for (i = 0; i < len * sizeof(union iavf_rx_desc); i++)
248 : 0 : ((volatile char *)rxq->rx_ring)[i] = 0;
249 : :
250 : 0 : memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
251 : :
252 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i++)
253 : 0 : rxq->sw_ring[rxq->nb_rx_desc + i] = &rxq->fake_mbuf;
254 : :
255 : : /* for rx bulk */
256 : 0 : rxq->rx_nb_avail = 0;
257 : 0 : rxq->rx_next_avail = 0;
258 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
259 : :
260 : 0 : rxq->rx_tail = 0;
261 : 0 : rxq->nb_rx_hold = 0;
262 : :
263 : 0 : rte_pktmbuf_free(rxq->pkt_first_seg);
264 : :
265 : 0 : rxq->pkt_first_seg = NULL;
266 : 0 : rxq->pkt_last_seg = NULL;
267 : 0 : rxq->rxrearm_nb = 0;
268 : 0 : rxq->rxrearm_start = 0;
269 : : }
270 : :
271 : : static inline void
272 : 0 : reset_tx_queue(struct ci_tx_queue *txq)
273 : : {
274 : : struct ci_tx_entry *txe;
275 : : uint32_t i, size;
276 : : uint16_t prev;
277 : :
278 [ # # ]: 0 : if (!txq) {
279 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
280 : 0 : return;
281 : : }
282 : :
283 : 0 : txe = txq->sw_ring;
284 : 0 : size = sizeof(struct iavf_tx_desc) * txq->nb_tx_desc;
285 [ # # ]: 0 : for (i = 0; i < size; i++)
286 : 0 : ((volatile char *)txq->iavf_tx_ring)[i] = 0;
287 : :
288 : 0 : prev = (uint16_t)(txq->nb_tx_desc - 1);
289 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
290 : 0 : txq->iavf_tx_ring[i].cmd_type_offset_bsz =
291 : : rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
292 : 0 : txe[i].mbuf = NULL;
293 : 0 : txe[i].last_id = i;
294 : 0 : txe[prev].next_id = i;
295 : : prev = i;
296 : : }
297 : :
298 : 0 : txq->tx_tail = 0;
299 : 0 : txq->nb_tx_used = 0;
300 : :
301 : 0 : txq->last_desc_cleaned = txq->nb_tx_desc - 1;
302 : 0 : txq->nb_tx_free = txq->nb_tx_desc - 1;
303 : :
304 : 0 : txq->tx_next_dd = txq->tx_rs_thresh - 1;
305 : 0 : txq->tx_next_rs = txq->tx_rs_thresh - 1;
306 : : }
307 : :
308 : : static int
309 : 0 : alloc_rxq_mbufs(struct iavf_rx_queue *rxq)
310 : : {
311 : : volatile union iavf_rx_desc *rxd;
312 : : struct rte_mbuf *mbuf = NULL;
313 : : uint64_t dma_addr;
314 : : uint16_t i, j;
315 : :
316 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
317 : 0 : mbuf = rte_mbuf_raw_alloc(rxq->mp);
318 [ # # ]: 0 : if (unlikely(!mbuf)) {
319 [ # # ]: 0 : for (j = 0; j < i; j++) {
320 [ # # ]: 0 : rte_pktmbuf_free_seg(rxq->sw_ring[j]);
321 : 0 : rxq->sw_ring[j] = NULL;
322 : : }
323 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
324 : 0 : return -ENOMEM;
325 : : }
326 : :
327 : : rte_mbuf_refcnt_set(mbuf, 1);
328 : 0 : mbuf->next = NULL;
329 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
330 : 0 : mbuf->nb_segs = 1;
331 : 0 : mbuf->port = rxq->port_id;
332 : :
333 : : dma_addr =
334 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
335 : :
336 : 0 : rxd = &rxq->rx_ring[i];
337 : 0 : rxd->read.pkt_addr = dma_addr;
338 : 0 : rxd->read.hdr_addr = 0;
339 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
340 : 0 : rxd->read.rsvd1 = 0;
341 : 0 : rxd->read.rsvd2 = 0;
342 : : #endif
343 : :
344 : 0 : rxq->sw_ring[i] = mbuf;
345 : : }
346 : :
347 : : return 0;
348 : : }
349 : :
350 : : static inline void
351 : 0 : release_rxq_mbufs(struct iavf_rx_queue *rxq)
352 : : {
353 : : uint16_t i;
354 : :
355 [ # # ]: 0 : if (!rxq->sw_ring)
356 : : return;
357 : :
358 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
359 [ # # ]: 0 : if (rxq->sw_ring[i]) {
360 : : rte_pktmbuf_free_seg(rxq->sw_ring[i]);
361 : 0 : rxq->sw_ring[i] = NULL;
362 : : }
363 : : }
364 : :
365 : : /* for rx bulk */
366 [ # # ]: 0 : if (rxq->rx_nb_avail == 0)
367 : : return;
368 [ # # ]: 0 : for (i = 0; i < rxq->rx_nb_avail; i++) {
369 : : struct rte_mbuf *mbuf;
370 : :
371 : 0 : mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
372 : : rte_pktmbuf_free_seg(mbuf);
373 : : }
374 : 0 : rxq->rx_nb_avail = 0;
375 : : }
376 : :
377 : : static const
378 : : struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = {
379 : : [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_rxq_mbufs,
380 : : #ifdef RTE_ARCH_X86
381 : : [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_rx_queue_release_mbufs_sse,
382 : : #endif
383 : : };
384 : :
385 : : static inline void
386 : 0 : iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct iavf_rx_queue *rxq,
387 : : struct rte_mbuf *mb,
388 : : volatile union iavf_rx_flex_desc *rxdp)
389 : : {
390 : : volatile struct iavf_32b_rx_flex_desc_comms_ovs *desc =
391 : : (volatile struct iavf_32b_rx_flex_desc_comms_ovs *)rxdp;
392 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
393 : : uint16_t stat_err;
394 : : #endif
395 : :
396 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
397 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
398 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
399 : : }
400 : :
401 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
402 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
403 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
404 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
405 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
406 : : }
407 : : #endif
408 : 0 : }
409 : :
410 : : static inline void
411 : 0 : iavf_rxd_to_pkt_fields_by_comms_aux_v1(struct iavf_rx_queue *rxq,
412 : : struct rte_mbuf *mb,
413 : : volatile union iavf_rx_flex_desc *rxdp)
414 : : {
415 : : volatile struct iavf_32b_rx_flex_desc_comms *desc =
416 : : (volatile struct iavf_32b_rx_flex_desc_comms *)rxdp;
417 : : uint16_t stat_err;
418 : :
419 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
420 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
421 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
422 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
423 : : }
424 : :
425 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
426 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
427 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
428 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
429 : : }
430 : :
431 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
432 : : uint32_t metadata = 0;
433 : :
434 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error1);
435 : :
436 [ # # ]: 0 : if (stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
437 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
438 : :
439 [ # # ]: 0 : if (stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
440 : 0 : metadata |=
441 : 0 : rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
442 : :
443 [ # # ]: 0 : if (metadata) {
444 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
445 : :
446 : 0 : *RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(mb) = metadata;
447 : : }
448 : : }
449 : : #endif
450 : 0 : }
451 : :
452 : : static inline void
453 : 0 : iavf_rxd_to_pkt_fields_by_comms_aux_v2(struct iavf_rx_queue *rxq,
454 : : struct rte_mbuf *mb,
455 : : volatile union iavf_rx_flex_desc *rxdp)
456 : : {
457 : : volatile struct iavf_32b_rx_flex_desc_comms *desc =
458 : : (volatile struct iavf_32b_rx_flex_desc_comms *)rxdp;
459 : : uint16_t stat_err;
460 : :
461 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
462 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
463 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
464 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
465 : : }
466 : :
467 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
468 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
469 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
470 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
471 : : }
472 : :
473 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
474 : : uint32_t metadata = 0;
475 : :
476 [ # # ]: 0 : if (desc->flex_ts.flex.aux0 != 0xFFFF)
477 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
478 [ # # ]: 0 : else if (desc->flex_ts.flex.aux1 != 0xFFFF)
479 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
480 : :
481 [ # # ]: 0 : if (metadata) {
482 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
483 : :
484 : 0 : *RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(mb) = metadata;
485 : : }
486 : : }
487 : : #endif
488 : 0 : }
489 : :
490 : : static const
491 : : iavf_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[IAVF_RXDID_LAST + 1] = {
492 : : [IAVF_RXDID_LEGACY_0] = iavf_rxd_to_pkt_fields_by_comms_ovs,
493 : : [IAVF_RXDID_LEGACY_1] = iavf_rxd_to_pkt_fields_by_comms_ovs,
494 : : [IAVF_RXDID_COMMS_AUX_VLAN] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
495 : : [IAVF_RXDID_COMMS_AUX_IPV4] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
496 : : [IAVF_RXDID_COMMS_AUX_IPV6] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
497 : : [IAVF_RXDID_COMMS_AUX_IPV6_FLOW] =
498 : : iavf_rxd_to_pkt_fields_by_comms_aux_v1,
499 : : [IAVF_RXDID_COMMS_AUX_TCP] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
500 : : [IAVF_RXDID_COMMS_AUX_IP_OFFSET] =
501 : : iavf_rxd_to_pkt_fields_by_comms_aux_v2,
502 : : [IAVF_RXDID_COMMS_IPSEC_CRYPTO] =
503 : : iavf_rxd_to_pkt_fields_by_comms_aux_v2,
504 : : [IAVF_RXDID_COMMS_OVS_1] = iavf_rxd_to_pkt_fields_by_comms_ovs,
505 : : };
506 : :
507 : : static void
508 : 0 : iavf_select_rxd_to_pkt_fields_handler(struct iavf_rx_queue *rxq, uint32_t rxdid)
509 : : {
510 : 0 : rxq->rxdid = rxdid;
511 : :
512 [ # # # # : 0 : switch (rxdid) {
# # # #
# ]
513 : 0 : case IAVF_RXDID_COMMS_AUX_VLAN:
514 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_vlan_mask;
515 : 0 : break;
516 : 0 : case IAVF_RXDID_COMMS_AUX_IPV4:
517 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask;
518 : 0 : break;
519 : 0 : case IAVF_RXDID_COMMS_AUX_IPV6:
520 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask;
521 : 0 : break;
522 : 0 : case IAVF_RXDID_COMMS_AUX_IPV6_FLOW:
523 : 0 : rxq->xtr_ol_flag =
524 : : rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask;
525 : 0 : break;
526 : 0 : case IAVF_RXDID_COMMS_AUX_TCP:
527 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
528 : 0 : break;
529 : 0 : case IAVF_RXDID_COMMS_AUX_IP_OFFSET:
530 : 0 : rxq->xtr_ol_flag =
531 : : rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
532 : 0 : break;
533 : 0 : case IAVF_RXDID_COMMS_IPSEC_CRYPTO:
534 : 0 : rxq->xtr_ol_flag =
535 : : rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
536 : 0 : break;
537 : : case IAVF_RXDID_COMMS_OVS_1:
538 : : case IAVF_RXDID_LEGACY_0:
539 : : case IAVF_RXDID_LEGACY_1:
540 : : break;
541 : 0 : default:
542 : : /* update this according to the RXDID for FLEX_DESC_NONE */
543 : 0 : rxq->rxdid = IAVF_RXDID_COMMS_OVS_1;
544 : 0 : break;
545 : : }
546 : :
547 [ # # ]: 0 : if (!rte_pmd_ifd_dynf_proto_xtr_metadata_avail())
548 : 0 : rxq->xtr_ol_flag = 0;
549 : 0 : }
550 : :
551 : : int
552 : 0 : iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
553 : : uint16_t nb_desc, unsigned int socket_id,
554 : : const struct rte_eth_rxconf *rx_conf,
555 : : struct rte_mempool *mp)
556 : : {
557 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
558 : : struct iavf_adapter *ad =
559 : : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
560 : : struct iavf_info *vf =
561 : : IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
562 : 0 : struct iavf_vsi *vsi = &vf->vsi;
563 : : struct iavf_rx_queue *rxq;
564 : : const struct rte_memzone *mz;
565 : : uint32_t ring_size;
566 : : uint8_t proto_xtr;
567 : : uint16_t len;
568 : : uint16_t rx_free_thresh;
569 : : uint64_t offloads;
570 : :
571 : 0 : PMD_INIT_FUNC_TRACE();
572 : :
573 [ # # ]: 0 : if (ad->closed)
574 : : return -EIO;
575 : :
576 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
577 : :
578 [ # # ]: 0 : if (nb_desc % IAVF_ALIGN_RING_DESC != 0 ||
579 [ # # ]: 0 : nb_desc > IAVF_MAX_RING_DESC ||
580 : : nb_desc < IAVF_MIN_RING_DESC) {
581 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
582 : : "invalid", nb_desc);
583 : 0 : return -EINVAL;
584 : : }
585 : :
586 : : /* Check free threshold */
587 [ # # ]: 0 : rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
588 : : IAVF_DEFAULT_RX_FREE_THRESH :
589 : : rx_conf->rx_free_thresh;
590 [ # # ]: 0 : if (check_rx_thresh(nb_desc, rx_free_thresh) != 0)
591 : 0 : return -EINVAL;
592 : :
593 : : /* Free memory if needed */
594 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx]) {
595 : 0 : iavf_dev_rx_queue_release(dev, queue_idx);
596 : 0 : dev->data->rx_queues[queue_idx] = NULL;
597 : : }
598 : :
599 : : /* Allocate the rx queue data structure */
600 : 0 : rxq = rte_zmalloc_socket("iavf rxq",
601 : : sizeof(struct iavf_rx_queue),
602 : : RTE_CACHE_LINE_SIZE,
603 : : socket_id);
604 [ # # ]: 0 : if (!rxq) {
605 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
606 : : "rx queue data structure");
607 : 0 : return -ENOMEM;
608 : : }
609 : :
610 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
611 [ # # ]: 0 : proto_xtr = vf->proto_xtr ? vf->proto_xtr[queue_idx] :
612 : : IAVF_PROTO_XTR_NONE;
613 : 0 : rxq->rxdid = iavf_proto_xtr_type_to_rxdid(proto_xtr);
614 : 0 : rxq->proto_xtr = proto_xtr;
615 : : } else {
616 : 0 : rxq->rxdid = IAVF_RXDID_LEGACY_1;
617 : 0 : rxq->proto_xtr = IAVF_PROTO_XTR_NONE;
618 : : }
619 : :
620 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
621 : : struct virtchnl_vlan_supported_caps *stripping_support =
622 : : &vf->vlan_v2_caps.offloads.stripping_support;
623 : : uint32_t stripping_cap;
624 : :
625 [ # # ]: 0 : if (stripping_support->outer)
626 : : stripping_cap = stripping_support->outer;
627 : : else
628 : 0 : stripping_cap = stripping_support->inner;
629 : :
630 [ # # ]: 0 : if (stripping_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1)
631 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1;
632 [ # # ]: 0 : else if (stripping_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2)
633 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2;
634 : : } else {
635 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1;
636 : : }
637 : :
638 : 0 : iavf_select_rxd_to_pkt_fields_handler(rxq, rxq->rxdid);
639 : :
640 : 0 : rxq->mp = mp;
641 : 0 : rxq->nb_rx_desc = nb_desc;
642 : 0 : rxq->rx_free_thresh = rx_free_thresh;
643 : 0 : rxq->queue_id = queue_idx;
644 : 0 : rxq->port_id = dev->data->port_id;
645 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
646 : 0 : rxq->rx_hdr_len = 0;
647 : 0 : rxq->vsi = vsi;
648 : 0 : rxq->offloads = offloads;
649 : :
650 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
651 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
652 : : else
653 : 0 : rxq->crc_len = 0;
654 : :
655 : 0 : len = rte_pktmbuf_data_room_size(rxq->mp) - RTE_PKTMBUF_HEADROOM;
656 : 0 : rxq->rx_buf_len = RTE_ALIGN_FLOOR(len, (1 << IAVF_RXQ_CTX_DBUFF_SHIFT));
657 : 0 : rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, IAVF_RX_MAX_DATA_BUF_SIZE);
658 : :
659 : : /* Allocate the software ring. */
660 : 0 : len = nb_desc + IAVF_RX_MAX_BURST;
661 : 0 : rxq->sw_ring =
662 : 0 : rte_zmalloc_socket("iavf rx sw ring",
663 : : sizeof(struct rte_mbuf *) * len,
664 : : RTE_CACHE_LINE_SIZE,
665 : : socket_id);
666 [ # # ]: 0 : if (!rxq->sw_ring) {
667 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
668 : 0 : rte_free(rxq);
669 : 0 : return -ENOMEM;
670 : : }
671 : :
672 : : /* Allocate the maximum number of RX ring hardware descriptor with
673 : : * a little more to support bulk allocate.
674 : : */
675 : : len = IAVF_MAX_RING_DESC + IAVF_RX_MAX_BURST;
676 : : ring_size = RTE_ALIGN(len * sizeof(union iavf_rx_desc),
677 : : IAVF_DMA_MEM_ALIGN);
678 : 0 : mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
679 : : ring_size, IAVF_RING_BASE_ALIGN,
680 : : socket_id);
681 [ # # ]: 0 : if (!mz) {
682 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
683 : 0 : rte_free(rxq->sw_ring);
684 : 0 : rte_free(rxq);
685 : 0 : return -ENOMEM;
686 : : }
687 : : /* Zero all the descriptors in the ring. */
688 : 0 : memset(mz->addr, 0, ring_size);
689 : 0 : rxq->rx_ring_phys_addr = mz->iova;
690 : 0 : rxq->rx_ring = (union iavf_rx_desc *)mz->addr;
691 : :
692 : 0 : rxq->mz = mz;
693 : 0 : reset_rx_queue(rxq);
694 : 0 : rxq->q_set = true;
695 : 0 : dev->data->rx_queues[queue_idx] = rxq;
696 : 0 : rxq->qrx_tail = hw->hw_addr + IAVF_QRX_TAIL1(rxq->queue_id);
697 : 0 : rxq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT;
698 : :
699 [ # # ]: 0 : if (check_rx_bulk_allow(rxq) == true) {
700 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
701 : : "satisfied. Rx Burst Bulk Alloc function will be "
702 : : "used on port=%d, queue=%d.",
703 : : rxq->port_id, rxq->queue_id);
704 : : } else {
705 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
706 : : "not satisfied, Scattered Rx is requested "
707 : : "on port=%d, queue=%d.",
708 : : rxq->port_id, rxq->queue_id);
709 : 0 : ad->rx_bulk_alloc_allowed = false;
710 : : }
711 : :
712 [ # # ]: 0 : if (!ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh, rxq->offloads))
713 : 0 : ad->rx_vec_allowed = false;
714 : :
715 : : #if defined RTE_ARCH_X86 || defined RTE_ARCH_ARM
716 : : /* check vector conflict */
717 [ # # # # ]: 0 : if (ad->rx_vec_allowed && iavf_rxq_vec_setup(rxq)) {
718 : 0 : PMD_DRV_LOG(ERR, "Failed vector rx setup.");
719 : 0 : return -EINVAL;
720 : : }
721 : : #endif
722 : : return 0;
723 : : }
724 : :
725 : : int
726 : 0 : iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
727 : : uint16_t queue_idx,
728 : : uint16_t nb_desc,
729 : : unsigned int socket_id,
730 : : const struct rte_eth_txconf *tx_conf)
731 : : {
732 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
733 : : struct iavf_adapter *adapter =
734 : : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
735 : : struct iavf_info *vf =
736 : : IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
737 : 0 : struct iavf_vsi *vsi = &vf->vsi;
738 : : struct ci_tx_queue *txq;
739 : : const struct rte_memzone *mz;
740 : : uint32_t ring_size;
741 : : uint16_t tx_rs_thresh, tx_free_thresh;
742 : : uint64_t offloads;
743 : :
744 : 0 : PMD_INIT_FUNC_TRACE();
745 : :
746 [ # # ]: 0 : if (adapter->closed)
747 : : return -EIO;
748 : :
749 : 0 : offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
750 : :
751 [ # # ]: 0 : if (nb_desc % IAVF_ALIGN_RING_DESC != 0 ||
752 [ # # ]: 0 : nb_desc > IAVF_MAX_RING_DESC ||
753 : : nb_desc < IAVF_MIN_RING_DESC) {
754 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
755 : : "invalid", nb_desc);
756 : 0 : return -EINVAL;
757 : : }
758 : :
759 [ # # ]: 0 : tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh) ?
760 : : tx_conf->tx_rs_thresh : DEFAULT_TX_RS_THRESH);
761 [ # # ]: 0 : tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
762 : : tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH);
763 [ # # ]: 0 : if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
764 : : return -EINVAL;
765 : :
766 : : /* Free memory if needed. */
767 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx]) {
768 : 0 : iavf_dev_tx_queue_release(dev, queue_idx);
769 : 0 : dev->data->tx_queues[queue_idx] = NULL;
770 : : }
771 : :
772 : : /* Allocate the TX queue data structure. */
773 : 0 : txq = rte_zmalloc_socket("iavf txq",
774 : : sizeof(struct ci_tx_queue),
775 : : RTE_CACHE_LINE_SIZE,
776 : : socket_id);
777 [ # # ]: 0 : if (!txq) {
778 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
779 : : "tx queue structure");
780 : 0 : return -ENOMEM;
781 : : }
782 : :
783 [ # # ]: 0 : if (adapter->vf.vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
784 : : struct virtchnl_vlan_supported_caps *insertion_support =
785 : : &adapter->vf.vlan_v2_caps.offloads.insertion_support;
786 : : uint32_t insertion_cap;
787 : :
788 [ # # ]: 0 : if (insertion_support->outer)
789 : : insertion_cap = insertion_support->outer;
790 : : else
791 : 0 : insertion_cap = insertion_support->inner;
792 : :
793 [ # # ]: 0 : if (insertion_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1) {
794 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1;
795 : 0 : PMD_INIT_LOG(DEBUG, "VLAN insertion_cap: L2TAG1");
796 [ # # ]: 0 : } else if (insertion_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2) {
797 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2;
798 : 0 : PMD_INIT_LOG(DEBUG, "VLAN insertion_cap: L2TAG2");
799 : : }
800 : : } else {
801 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1;
802 : : }
803 : :
804 : 0 : txq->nb_tx_desc = nb_desc;
805 : 0 : txq->tx_rs_thresh = tx_rs_thresh;
806 : 0 : txq->tx_free_thresh = tx_free_thresh;
807 : 0 : txq->queue_id = queue_idx;
808 : 0 : txq->port_id = dev->data->port_id;
809 : 0 : txq->offloads = offloads;
810 : 0 : txq->tx_deferred_start = tx_conf->tx_deferred_start;
811 : 0 : txq->iavf_vsi = vsi;
812 : :
813 [ # # ]: 0 : if (iavf_ipsec_crypto_supported(adapter))
814 : 0 : txq->ipsec_crypto_pkt_md_offset =
815 : 0 : iavf_security_get_pkt_md_offset(adapter);
816 : :
817 : : /* Allocate software ring */
818 : 0 : txq->sw_ring =
819 : 0 : rte_zmalloc_socket("iavf tx sw ring",
820 : : sizeof(struct ci_tx_entry) * nb_desc,
821 : : RTE_CACHE_LINE_SIZE,
822 : : socket_id);
823 [ # # ]: 0 : if (!txq->sw_ring) {
824 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
825 : 0 : rte_free(txq);
826 : 0 : return -ENOMEM;
827 : : }
828 : :
829 : : /* Allocate TX hardware ring descriptors. */
830 : : ring_size = sizeof(struct iavf_tx_desc) * IAVF_MAX_RING_DESC;
831 : : ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
832 : 0 : mz = rte_eth_dma_zone_reserve(dev, "iavf_tx_ring", queue_idx,
833 : : ring_size, IAVF_RING_BASE_ALIGN,
834 : : socket_id);
835 [ # # ]: 0 : if (!mz) {
836 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
837 : 0 : rte_free(txq->sw_ring);
838 : 0 : rte_free(txq);
839 : 0 : return -ENOMEM;
840 : : }
841 : 0 : txq->tx_ring_dma = mz->iova;
842 : 0 : txq->iavf_tx_ring = (struct iavf_tx_desc *)mz->addr;
843 : :
844 : 0 : txq->mz = mz;
845 : 0 : reset_tx_queue(txq);
846 : 0 : txq->q_set = true;
847 : 0 : dev->data->tx_queues[queue_idx] = txq;
848 : 0 : txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx);
849 : :
850 [ # # ]: 0 : if (check_tx_vec_allow(txq) == false) {
851 : 0 : struct iavf_adapter *ad =
852 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
853 : 0 : ad->tx_vec_allowed = false;
854 : : }
855 : :
856 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
857 [ # # ]: 0 : vf->tm_conf.committed) {
858 : : int tc;
859 [ # # ]: 0 : for (tc = 0; tc < vf->qos_cap->num_elem; tc++) {
860 [ # # ]: 0 : if (txq->queue_id >= vf->qtc_map[tc].start_queue_id &&
861 : 0 : txq->queue_id < (vf->qtc_map[tc].start_queue_id +
862 [ # # ]: 0 : vf->qtc_map[tc].queue_count))
863 : : break;
864 : : }
865 [ # # ]: 0 : if (tc >= vf->qos_cap->num_elem) {
866 : 0 : PMD_INIT_LOG(ERR, "Queue TC mapping is not correct");
867 : 0 : return -EINVAL;
868 : : }
869 : 0 : txq->tc = tc;
870 : : }
871 : :
872 : : return 0;
873 : : }
874 : :
875 : : int
876 : 0 : iavf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
877 : : {
878 : 0 : struct iavf_adapter *adapter =
879 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
880 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
881 : : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
882 : : struct iavf_rx_queue *rxq;
883 : : int err = 0;
884 : :
885 : 0 : PMD_DRV_FUNC_TRACE();
886 : :
887 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues)
888 : : return -EINVAL;
889 : :
890 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
891 : :
892 : 0 : err = alloc_rxq_mbufs(rxq);
893 [ # # ]: 0 : if (err) {
894 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
895 : 0 : return err;
896 : : }
897 : :
898 : : rte_wmb();
899 : :
900 : : /* Init the RX tail register. */
901 : 0 : IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
902 : 0 : IAVF_WRITE_FLUSH(hw);
903 : :
904 : : /* Ready to switch the queue on */
905 [ # # ]: 0 : if (!vf->lv_enabled)
906 : 0 : err = iavf_switch_queue(adapter, rx_queue_id, true, true);
907 : : else
908 : 0 : err = iavf_switch_queue_lv(adapter, rx_queue_id, true, true);
909 : :
910 [ # # ]: 0 : if (err) {
911 : 0 : release_rxq_mbufs(rxq);
912 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
913 : : rx_queue_id);
914 : : } else {
915 : 0 : dev->data->rx_queue_state[rx_queue_id] =
916 : : RTE_ETH_QUEUE_STATE_STARTED;
917 : : }
918 : :
919 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads &
920 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
921 [ # # ]: 0 : if (iavf_get_phc_time(rxq)) {
922 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
923 : 0 : return err;
924 : : }
925 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
926 : : }
927 : :
928 : : return err;
929 : : }
930 : :
931 : : int
932 : 0 : iavf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
933 : : {
934 : 0 : struct iavf_adapter *adapter =
935 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
936 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
937 : : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
938 : : struct ci_tx_queue *txq;
939 : : int err = 0;
940 : :
941 : 0 : PMD_DRV_FUNC_TRACE();
942 : :
943 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues)
944 : : return -EINVAL;
945 : :
946 : 0 : txq = dev->data->tx_queues[tx_queue_id];
947 : :
948 : : /* Init the RX tail register. */
949 : 0 : IAVF_PCI_REG_WRITE(txq->qtx_tail, 0);
950 : 0 : IAVF_WRITE_FLUSH(hw);
951 : :
952 : : /* Ready to switch the queue on */
953 [ # # ]: 0 : if (!vf->lv_enabled)
954 : 0 : err = iavf_switch_queue(adapter, tx_queue_id, false, true);
955 : : else
956 : 0 : err = iavf_switch_queue_lv(adapter, tx_queue_id, false, true);
957 : :
958 [ # # ]: 0 : if (err)
959 : 0 : PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
960 : : tx_queue_id);
961 : : else
962 : 0 : dev->data->tx_queue_state[tx_queue_id] =
963 : : RTE_ETH_QUEUE_STATE_STARTED;
964 : :
965 : : return err;
966 : : }
967 : :
968 : : int
969 : 0 : iavf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
970 : : {
971 : 0 : struct iavf_adapter *adapter =
972 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
973 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
974 : : struct iavf_rx_queue *rxq;
975 : : int err;
976 : :
977 : 0 : PMD_DRV_FUNC_TRACE();
978 : :
979 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues)
980 : : return -EINVAL;
981 : :
982 [ # # ]: 0 : if (!vf->lv_enabled)
983 : 0 : err = iavf_switch_queue(adapter, rx_queue_id, true, false);
984 : : else
985 : 0 : err = iavf_switch_queue_lv(adapter, rx_queue_id, true, false);
986 : :
987 [ # # ]: 0 : if (err) {
988 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
989 : : rx_queue_id);
990 : 0 : return err;
991 : : }
992 : :
993 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
994 : 0 : iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
995 : 0 : reset_rx_queue(rxq);
996 : 0 : dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
997 : :
998 : 0 : return 0;
999 : : }
1000 : :
1001 : : int
1002 : 0 : iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1003 : : {
1004 : 0 : struct iavf_adapter *adapter =
1005 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1006 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
1007 : : struct ci_tx_queue *txq;
1008 : : int err;
1009 : :
1010 : 0 : PMD_DRV_FUNC_TRACE();
1011 : :
1012 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues)
1013 : : return -EINVAL;
1014 : :
1015 [ # # ]: 0 : if (!vf->lv_enabled)
1016 : 0 : err = iavf_switch_queue(adapter, tx_queue_id, false, false);
1017 : : else
1018 : 0 : err = iavf_switch_queue_lv(adapter, tx_queue_id, false, false);
1019 : :
1020 [ # # ]: 0 : if (err) {
1021 : 0 : PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
1022 : : tx_queue_id);
1023 : 0 : return err;
1024 : : }
1025 : :
1026 : 0 : txq = dev->data->tx_queues[tx_queue_id];
1027 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1028 : 0 : reset_tx_queue(txq);
1029 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
1030 : :
1031 : 0 : return 0;
1032 : : }
1033 : :
1034 : : void
1035 : 0 : iavf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1036 : : {
1037 : 0 : struct iavf_rx_queue *q = dev->data->rx_queues[qid];
1038 : :
1039 [ # # ]: 0 : if (!q)
1040 : : return;
1041 : :
1042 : 0 : iavf_rxq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q);
1043 : 0 : rte_free(q->sw_ring);
1044 : 0 : rte_memzone_free(q->mz);
1045 : 0 : rte_free(q);
1046 : : }
1047 : :
1048 : : void
1049 : 0 : iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1050 : : {
1051 : 0 : struct ci_tx_queue *q = dev->data->tx_queues[qid];
1052 : :
1053 [ # # ]: 0 : if (!q)
1054 : : return;
1055 : :
1056 : 0 : ci_txq_release_all_mbufs(q, q->use_ctx);
1057 : 0 : rte_free(q->sw_ring);
1058 : 0 : rte_memzone_free(q->mz);
1059 : 0 : rte_free(q);
1060 : : }
1061 : :
1062 : : static void
1063 : 0 : iavf_reset_queues(struct rte_eth_dev *dev)
1064 : : {
1065 : : struct iavf_rx_queue *rxq;
1066 : : struct ci_tx_queue *txq;
1067 : : int i;
1068 : :
1069 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
1070 : 0 : txq = dev->data->tx_queues[i];
1071 [ # # ]: 0 : if (!txq)
1072 : 0 : continue;
1073 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1074 : 0 : reset_tx_queue(txq);
1075 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1076 : : }
1077 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1078 : 0 : rxq = dev->data->rx_queues[i];
1079 [ # # ]: 0 : if (!rxq)
1080 : 0 : continue;
1081 : 0 : iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
1082 : 0 : reset_rx_queue(rxq);
1083 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1084 : : }
1085 : 0 : }
1086 : :
1087 : : void
1088 : 0 : iavf_stop_queues(struct rte_eth_dev *dev)
1089 : : {
1090 : 0 : struct iavf_adapter *adapter =
1091 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1092 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
1093 : : int ret;
1094 : :
1095 : : /* adminq will be disabled when vf is resetting. */
1096 [ # # ]: 0 : if (vf->in_reset_recovery) {
1097 : 0 : iavf_reset_queues(dev);
1098 : 0 : return;
1099 : : }
1100 : :
1101 : : /* Stop All queues */
1102 [ # # ]: 0 : if (!vf->lv_enabled) {
1103 : 0 : ret = iavf_disable_queues(adapter);
1104 [ # # ]: 0 : if (ret)
1105 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues");
1106 : : } else {
1107 : 0 : ret = iavf_disable_queues_lv(adapter);
1108 [ # # ]: 0 : if (ret)
1109 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues for large VF");
1110 : : }
1111 : :
1112 [ # # ]: 0 : if (ret)
1113 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues");
1114 : :
1115 : 0 : iavf_reset_queues(dev);
1116 : : }
1117 : :
1118 : : #define IAVF_RX_FLEX_ERR0_BITS \
1119 : : ((1 << IAVF_RX_FLEX_DESC_STATUS0_HBO_S) | \
1120 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1121 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1122 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1123 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1124 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_RXE_S))
1125 : :
1126 : : static inline void
1127 : : iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union iavf_rx_desc *rxdp)
1128 : : {
1129 : 0 : if (rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
1130 : : (1 << IAVF_RX_DESC_STATUS_L2TAG1P_SHIFT)) {
1131 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1132 : 0 : mb->vlan_tci =
1133 : 0 : rte_le_to_cpu_16(rxdp->wb.qword0.lo_dword.l2tag1);
1134 : : } else {
1135 : 0 : mb->vlan_tci = 0;
1136 : : }
1137 : : }
1138 : :
1139 : : static inline void
1140 : : iavf_flex_rxd_to_vlan_tci(struct rte_mbuf *mb,
1141 : : volatile union iavf_rx_flex_desc *rxdp)
1142 : : {
1143 : 0 : if (rte_le_to_cpu_64(rxdp->wb.status_error0) &
1144 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
1145 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN |
1146 : : RTE_MBUF_F_RX_VLAN_STRIPPED;
1147 : 0 : mb->vlan_tci =
1148 : 0 : rte_le_to_cpu_16(rxdp->wb.l2tag1);
1149 : : } else {
1150 : 0 : mb->vlan_tci = 0;
1151 : : }
1152 : :
1153 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
1154 [ # # # # : 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
# # ]
1155 : : (1 << IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
1156 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED |
1157 : : RTE_MBUF_F_RX_QINQ |
1158 : : RTE_MBUF_F_RX_VLAN_STRIPPED |
1159 : : RTE_MBUF_F_RX_VLAN;
1160 : 0 : mb->vlan_tci_outer = mb->vlan_tci;
1161 : 0 : mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
1162 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
1163 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
1164 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
1165 : : } else {
1166 : 0 : mb->vlan_tci_outer = 0;
1167 : : }
1168 : : #endif
1169 : : }
1170 : :
1171 : : static inline void
1172 : : iavf_flex_rxd_to_ipsec_crypto_said_get(struct rte_mbuf *mb,
1173 : : volatile union iavf_rx_flex_desc *rxdp)
1174 : : {
1175 : : volatile struct iavf_32b_rx_flex_desc_comms_ipsec *desc =
1176 : : (volatile struct iavf_32b_rx_flex_desc_comms_ipsec *)rxdp;
1177 : :
1178 : 0 : mb->dynfield1[0] = desc->ipsec_said &
1179 : : IAVF_RX_FLEX_DESC_IPSEC_CRYPTO_SAID_MASK;
1180 : 0 : }
1181 : :
1182 : : static inline void
1183 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(struct rte_mbuf *mb,
1184 : : volatile union iavf_rx_flex_desc *rxdp,
1185 : : struct iavf_ipsec_crypto_stats *stats)
1186 : : {
1187 : 0 : uint16_t status1 = rte_le_to_cpu_64(rxdp->wb.status_error1);
1188 : :
1189 [ # # ]: 0 : if (status1 & BIT(IAVF_RX_FLEX_DESC_STATUS1_IPSEC_CRYPTO_PROCESSED)) {
1190 : : uint16_t ipsec_status;
1191 : :
1192 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD;
1193 : :
1194 : 0 : ipsec_status = status1 &
1195 : : IAVF_RX_FLEX_DESC_IPSEC_CRYPTO_STATUS_MASK;
1196 : :
1197 : :
1198 [ # # ]: 0 : if (unlikely(ipsec_status !=
1199 : : IAVF_IPSEC_CRYPTO_STATUS_SUCCESS)) {
1200 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1201 : :
1202 [ # # # # : 0 : switch (ipsec_status) {
# # ]
1203 : 0 : case IAVF_IPSEC_CRYPTO_STATUS_SAD_MISS:
1204 : 0 : stats->ierrors.sad_miss++;
1205 : 0 : break;
1206 : 0 : case IAVF_IPSEC_CRYPTO_STATUS_NOT_PROCESSED:
1207 : 0 : stats->ierrors.not_processed++;
1208 : 0 : break;
1209 : 0 : case IAVF_IPSEC_CRYPTO_STATUS_ICV_CHECK_FAIL:
1210 : 0 : stats->ierrors.icv_check++;
1211 : 0 : break;
1212 : 0 : case IAVF_IPSEC_CRYPTO_STATUS_LENGTH_ERR:
1213 : 0 : stats->ierrors.ipsec_length++;
1214 : 0 : break;
1215 : 0 : case IAVF_IPSEC_CRYPTO_STATUS_MISC_ERR:
1216 : 0 : stats->ierrors.misc++;
1217 : 0 : break;
1218 : : }
1219 : :
1220 : 0 : stats->ierrors.count++;
1221 : 0 : return;
1222 : : }
1223 : :
1224 : 0 : stats->icount++;
1225 : 0 : stats->ibytes += rxdp->wb.pkt_len & 0x3FFF;
1226 : :
1227 [ # # # # ]: 0 : if (rxdp->wb.rxdid == IAVF_RXDID_COMMS_IPSEC_CRYPTO &&
1228 : : ipsec_status !=
1229 : : IAVF_IPSEC_CRYPTO_STATUS_SAD_MISS)
1230 : : iavf_flex_rxd_to_ipsec_crypto_said_get(mb, rxdp);
1231 : : }
1232 : : }
1233 : :
1234 : :
1235 : : /* Translate the rx descriptor status and error fields to pkt flags */
1236 : : static inline uint64_t
1237 : 0 : iavf_rxd_to_pkt_flags(uint64_t qword)
1238 : : {
1239 : : uint64_t flags;
1240 : 0 : uint64_t error_bits = (qword >> IAVF_RXD_QW1_ERROR_SHIFT);
1241 : :
1242 : : #define IAVF_RX_ERR_BITS 0x3f
1243 : :
1244 : : /* Check if RSS_HASH */
1245 : 0 : flags = (((qword >> IAVF_RX_DESC_STATUS_FLTSTAT_SHIFT) &
1246 : : IAVF_RX_DESC_FLTSTAT_RSS_HASH) ==
1247 [ # # ]: 0 : IAVF_RX_DESC_FLTSTAT_RSS_HASH) ? RTE_MBUF_F_RX_RSS_HASH : 0;
1248 : :
1249 : : /* Check if FDIR Match */
1250 : 0 : flags |= (qword & (1 << IAVF_RX_DESC_STATUS_FLM_SHIFT) ?
1251 : 0 : RTE_MBUF_F_RX_FDIR : 0);
1252 : :
1253 [ # # ]: 0 : if (likely((error_bits & IAVF_RX_ERR_BITS) == 0)) {
1254 : 0 : flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD);
1255 : 0 : return flags;
1256 : : }
1257 : :
1258 [ # # ]: 0 : if (unlikely(error_bits & (1 << IAVF_RX_DESC_ERROR_IPE_SHIFT)))
1259 : 0 : flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
1260 : : else
1261 : 0 : flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
1262 : :
1263 [ # # ]: 0 : if (unlikely(error_bits & (1 << IAVF_RX_DESC_ERROR_L4E_SHIFT)))
1264 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
1265 : : else
1266 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
1267 : :
1268 : : /* TODO: Oversize error bit is not processed here */
1269 : :
1270 : : return flags;
1271 : : }
1272 : :
1273 : : static inline uint64_t
1274 : : iavf_rxd_build_fdir(volatile union iavf_rx_desc *rxdp, struct rte_mbuf *mb)
1275 : : {
1276 : : uint64_t flags = 0;
1277 : : #ifndef RTE_LIBRTE_IAVF_16BYTE_RX_DESC
1278 : : uint16_t flexbh;
1279 : :
1280 : 0 : flexbh = (rte_le_to_cpu_32(rxdp->wb.qword2.ext_status) >>
1281 : 0 : IAVF_RX_DESC_EXT_STATUS_FLEXBH_SHIFT) &
1282 : : IAVF_RX_DESC_EXT_STATUS_FLEXBH_MASK;
1283 : :
1284 [ # # # # : 0 : if (flexbh == IAVF_RX_DESC_EXT_STATUS_FLEXBH_FD_ID) {
# # ]
1285 : 0 : mb->hash.fdir.hi =
1286 : 0 : rte_le_to_cpu_32(rxdp->wb.qword3.hi_dword.fd_id);
1287 : : flags |= RTE_MBUF_F_RX_FDIR_ID;
1288 : : }
1289 : : #else
1290 : : mb->hash.fdir.hi =
1291 : : rte_le_to_cpu_32(rxdp->wb.qword0.hi_dword.fd_id);
1292 : : flags |= RTE_MBUF_F_RX_FDIR_ID;
1293 : : #endif
1294 : : return flags;
1295 : : }
1296 : :
1297 : : #define IAVF_RX_FLEX_ERR0_BITS \
1298 : : ((1 << IAVF_RX_FLEX_DESC_STATUS0_HBO_S) | \
1299 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1300 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1301 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1302 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1303 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_RXE_S))
1304 : :
1305 : : /* Rx L3/L4 checksum */
1306 : : static inline uint64_t
1307 : 0 : iavf_flex_rxd_error_to_pkt_flags(uint16_t stat_err0)
1308 : : {
1309 : : uint64_t flags = 0;
1310 : :
1311 : : /* check if HW has decoded the packet and checksum */
1312 [ # # ]: 0 : if (unlikely(!(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_L3L4P_S))))
1313 : : return 0;
1314 : :
1315 [ # # ]: 0 : if (likely(!(stat_err0 & IAVF_RX_FLEX_ERR0_BITS))) {
1316 : : flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1317 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD |
1318 : : RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
1319 : : return flags;
1320 : : }
1321 : :
1322 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
1323 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
1324 : : else
1325 : : flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
1326 : :
1327 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
1328 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
1329 : : else
1330 : 0 : flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
1331 : :
1332 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
1333 : 0 : flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
1334 : :
1335 [ # # ]: 0 : if (unlikely(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
1336 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
1337 : : else
1338 : 0 : flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
1339 : :
1340 : : return flags;
1341 : : }
1342 : :
1343 : : /* If the number of free RX descriptors is greater than the RX free
1344 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
1345 : : * register. Update the RDT with the value of the last processed RX
1346 : : * descriptor minus 1, to guarantee that the RDT register is never
1347 : : * equal to the RDH register, which creates a "full" ring situation
1348 : : * from the hardware point of view.
1349 : : */
1350 : : static inline void
1351 : 0 : iavf_update_rx_tail(struct iavf_rx_queue *rxq, uint16_t nb_hold, uint16_t rx_id)
1352 : : {
1353 : 0 : nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
1354 : :
1355 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
1356 : : PMD_RX_LOG(DEBUG,
1357 : : "port_id=%u queue_id=%u rx_tail=%u nb_hold=%u",
1358 : : rxq->port_id, rxq->queue_id, rx_id, nb_hold);
1359 [ # # ]: 0 : rx_id = (uint16_t)((rx_id == 0) ?
1360 : 0 : (rxq->nb_rx_desc - 1) : (rx_id - 1));
1361 : 0 : IAVF_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
1362 : : nb_hold = 0;
1363 : : }
1364 : 0 : rxq->nb_rx_hold = nb_hold;
1365 : 0 : }
1366 : :
1367 : : /* implement recv_pkts */
1368 : : uint16_t
1369 : 0 : iavf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1370 : : {
1371 : : volatile union iavf_rx_desc *rx_ring;
1372 : : volatile union iavf_rx_desc *rxdp;
1373 : : struct iavf_rx_queue *rxq;
1374 : : union iavf_rx_desc rxd;
1375 : : struct rte_mbuf *rxe;
1376 : : struct rte_eth_dev *dev;
1377 : : struct rte_mbuf *rxm;
1378 : : struct rte_mbuf *nmb;
1379 : : uint16_t nb_rx;
1380 : : uint32_t rx_status;
1381 : : uint64_t qword1;
1382 : : uint16_t rx_packet_len;
1383 : : uint16_t rx_id, nb_hold;
1384 : : uint64_t dma_addr;
1385 : : uint64_t pkt_flags;
1386 : : const uint32_t *ptype_tbl;
1387 : :
1388 : : nb_rx = 0;
1389 : : nb_hold = 0;
1390 : : rxq = rx_queue;
1391 : 0 : rx_id = rxq->rx_tail;
1392 : 0 : rx_ring = rxq->rx_ring;
1393 : 0 : ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1394 : :
1395 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1396 : 0 : rxdp = &rx_ring[rx_id];
1397 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
1398 : 0 : rx_status = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
1399 : : IAVF_RXD_QW1_STATUS_SHIFT;
1400 : :
1401 : : /* Check the DD bit first */
1402 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)))
1403 : : break;
1404 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1405 : :
1406 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1407 [ # # ]: 0 : if (unlikely(!nmb)) {
1408 : 0 : dev = &rte_eth_devices[rxq->port_id];
1409 : 0 : dev->data->rx_mbuf_alloc_failed++;
1410 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1411 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1412 : 0 : break;
1413 : : }
1414 : :
1415 : 0 : rxd = *rxdp;
1416 : 0 : nb_hold++;
1417 : 0 : rxe = rxq->sw_ring[rx_id];
1418 : 0 : rxq->sw_ring[rx_id] = nmb;
1419 : 0 : rx_id++;
1420 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
1421 : : rx_id = 0;
1422 : :
1423 : : /* Prefetch next mbuf */
1424 : 0 : rte_prefetch0(rxq->sw_ring[rx_id]);
1425 : :
1426 : : /* When next RX descriptor is on a cache line boundary,
1427 : : * prefetch the next 4 RX descriptors and next 8 pointers
1428 : : * to mbufs.
1429 : : */
1430 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1431 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1432 : : rte_prefetch0(rxq->sw_ring[rx_id]);
1433 : : }
1434 : : rxm = rxe;
1435 : : dma_addr =
1436 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1437 : 0 : rxdp->read.hdr_addr = 0;
1438 : 0 : rxdp->read.pkt_addr = dma_addr;
1439 : :
1440 : 0 : rx_packet_len = ((qword1 & IAVF_RXD_QW1_LENGTH_PBUF_MASK) >>
1441 : 0 : IAVF_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;
1442 : :
1443 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1444 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
1445 : 0 : rxm->nb_segs = 1;
1446 : 0 : rxm->next = NULL;
1447 : 0 : rxm->pkt_len = rx_packet_len;
1448 : 0 : rxm->data_len = rx_packet_len;
1449 : 0 : rxm->port = rxq->port_id;
1450 [ # # ]: 0 : rxm->ol_flags = 0;
1451 : : iavf_rxd_to_vlan_tci(rxm, &rxd);
1452 : 0 : pkt_flags = iavf_rxd_to_pkt_flags(qword1);
1453 : 0 : rxm->packet_type =
1454 : 0 : ptype_tbl[(uint8_t)((qword1 &
1455 : 0 : IAVF_RXD_QW1_PTYPE_MASK) >> IAVF_RXD_QW1_PTYPE_SHIFT)];
1456 : :
1457 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_RSS_HASH)
1458 : 0 : rxm->hash.rss =
1459 : 0 : rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
1460 : :
1461 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_FDIR)
1462 : 0 : pkt_flags |= iavf_rxd_build_fdir(&rxd, rxm);
1463 : :
1464 : 0 : rxm->ol_flags |= pkt_flags;
1465 : :
1466 : 0 : rx_pkts[nb_rx++] = rxm;
1467 : : }
1468 : 0 : rxq->rx_tail = rx_id;
1469 : :
1470 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1471 : :
1472 : 0 : return nb_rx;
1473 : : }
1474 : :
1475 : : /* implement recv_pkts for flexible Rx descriptor */
1476 : : uint16_t
1477 : 0 : iavf_recv_pkts_flex_rxd(void *rx_queue,
1478 : : struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1479 : : {
1480 : : volatile union iavf_rx_desc *rx_ring;
1481 : : volatile union iavf_rx_flex_desc *rxdp;
1482 : : struct iavf_rx_queue *rxq;
1483 : : union iavf_rx_flex_desc rxd;
1484 : : struct rte_mbuf *rxe;
1485 : : struct rte_eth_dev *dev;
1486 : : struct rte_mbuf *rxm;
1487 : : struct rte_mbuf *nmb;
1488 : : uint16_t nb_rx;
1489 : : uint16_t rx_stat_err0;
1490 : : uint16_t rx_packet_len;
1491 : : uint16_t rx_id, nb_hold;
1492 : : uint64_t dma_addr;
1493 : : uint64_t pkt_flags;
1494 : : const uint32_t *ptype_tbl;
1495 : : uint64_t ts_ns;
1496 : :
1497 : : nb_rx = 0;
1498 : : nb_hold = 0;
1499 : : rxq = rx_queue;
1500 : 0 : rx_id = rxq->rx_tail;
1501 : 0 : rx_ring = rxq->rx_ring;
1502 : 0 : ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1503 : :
1504 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1505 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1506 : :
1507 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1508 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1509 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1510 : 0 : rxq->hw_time_update = sw_cur_time;
1511 : : }
1512 : : }
1513 : :
1514 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1515 : 0 : rxdp = (volatile union iavf_rx_flex_desc *)&rx_ring[rx_id];
1516 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1517 : :
1518 : : /* Check the DD bit first */
1519 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1520 : : break;
1521 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1522 : :
1523 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1524 [ # # ]: 0 : if (unlikely(!nmb)) {
1525 : 0 : dev = &rte_eth_devices[rxq->port_id];
1526 : 0 : dev->data->rx_mbuf_alloc_failed++;
1527 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1528 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1529 : 0 : break;
1530 : : }
1531 : :
1532 : 0 : rxd = *rxdp;
1533 : 0 : nb_hold++;
1534 : 0 : rxe = rxq->sw_ring[rx_id];
1535 : 0 : rxq->sw_ring[rx_id] = nmb;
1536 : 0 : rx_id++;
1537 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
1538 : : rx_id = 0;
1539 : :
1540 : : /* Prefetch next mbuf */
1541 : 0 : rte_prefetch0(rxq->sw_ring[rx_id]);
1542 : :
1543 : : /* When next RX descriptor is on a cache line boundary,
1544 : : * prefetch the next 4 RX descriptors and next 8 pointers
1545 : : * to mbufs.
1546 : : */
1547 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1548 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1549 : : rte_prefetch0(rxq->sw_ring[rx_id]);
1550 : : }
1551 : : rxm = rxe;
1552 : : dma_addr =
1553 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1554 : 0 : rxdp->read.hdr_addr = 0;
1555 : 0 : rxdp->read.pkt_addr = dma_addr;
1556 : :
1557 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
1558 : 0 : IAVF_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1559 : :
1560 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1561 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
1562 : 0 : rxm->nb_segs = 1;
1563 : 0 : rxm->next = NULL;
1564 : 0 : rxm->pkt_len = rx_packet_len;
1565 : 0 : rxm->data_len = rx_packet_len;
1566 : 0 : rxm->port = rxq->port_id;
1567 : 0 : rxm->ol_flags = 0;
1568 : 0 : rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
1569 [ # # ]: 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
1570 : : iavf_flex_rxd_to_vlan_tci(rxm, &rxd);
1571 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(rxm, &rxd,
1572 : : &rxq->stats.ipsec_crypto);
1573 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
1574 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0);
1575 : :
1576 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0) {
1577 [ # # ]: 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
1578 : : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
1579 : :
1580 : 0 : rxq->phc_time = ts_ns;
1581 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1582 : :
1583 : 0 : *RTE_MBUF_DYNFIELD(rxm,
1584 : : iavf_timestamp_dynfield_offset,
1585 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
1586 : 0 : rxm->ol_flags |= iavf_timestamp_dynflag;
1587 : : }
1588 : :
1589 : 0 : rxm->ol_flags |= pkt_flags;
1590 : :
1591 : 0 : rx_pkts[nb_rx++] = rxm;
1592 : : }
1593 : 0 : rxq->rx_tail = rx_id;
1594 : :
1595 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1596 : :
1597 : 0 : return nb_rx;
1598 : : }
1599 : :
1600 : : /* implement recv_scattered_pkts for flexible Rx descriptor */
1601 : : uint16_t
1602 : 0 : iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts,
1603 : : uint16_t nb_pkts)
1604 : : {
1605 : : struct iavf_rx_queue *rxq = rx_queue;
1606 : : union iavf_rx_flex_desc rxd;
1607 : : struct rte_mbuf *rxe;
1608 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1609 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1610 : : struct rte_mbuf *nmb, *rxm;
1611 : 0 : uint16_t rx_id = rxq->rx_tail;
1612 : : uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
1613 : : struct rte_eth_dev *dev;
1614 : : uint16_t rx_stat_err0;
1615 : : uint64_t dma_addr;
1616 : : uint64_t pkt_flags;
1617 : : uint64_t ts_ns;
1618 : :
1619 : 0 : volatile union iavf_rx_desc *rx_ring = rxq->rx_ring;
1620 : : volatile union iavf_rx_flex_desc *rxdp;
1621 : 0 : const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1622 : :
1623 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1624 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1625 : :
1626 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1627 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1628 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1629 : 0 : rxq->hw_time_update = sw_cur_time;
1630 : : }
1631 : : }
1632 : :
1633 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1634 : 0 : rxdp = (volatile union iavf_rx_flex_desc *)&rx_ring[rx_id];
1635 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1636 : :
1637 : : /* Check the DD bit */
1638 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1639 : : break;
1640 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1641 : :
1642 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1643 [ # # ]: 0 : if (unlikely(!nmb)) {
1644 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1645 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1646 : 0 : dev = &rte_eth_devices[rxq->port_id];
1647 : 0 : dev->data->rx_mbuf_alloc_failed++;
1648 : 0 : break;
1649 : : }
1650 : :
1651 : 0 : rxd = *rxdp;
1652 : 0 : nb_hold++;
1653 : 0 : rxe = rxq->sw_ring[rx_id];
1654 : 0 : rxq->sw_ring[rx_id] = nmb;
1655 : 0 : rx_id++;
1656 [ # # ]: 0 : if (rx_id == rxq->nb_rx_desc)
1657 : : rx_id = 0;
1658 : :
1659 : : /* Prefetch next mbuf */
1660 : 0 : rte_prefetch0(rxq->sw_ring[rx_id]);
1661 : :
1662 : : /* When next RX descriptor is on a cache line boundary,
1663 : : * prefetch the next 4 RX descriptors and next 8 pointers
1664 : : * to mbufs.
1665 : : */
1666 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1667 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1668 : : rte_prefetch0(rxq->sw_ring[rx_id]);
1669 : : }
1670 : :
1671 : : rxm = rxe;
1672 : : dma_addr =
1673 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1674 : :
1675 : : /* Set data buffer address and data length of the mbuf */
1676 : 0 : rxdp->read.hdr_addr = 0;
1677 : 0 : rxdp->read.pkt_addr = dma_addr;
1678 : 0 : rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
1679 : : IAVF_RX_FLX_DESC_PKT_LEN_M;
1680 : 0 : rxm->data_len = rx_packet_len;
1681 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1682 : :
1683 : : /* If this is the first buffer of the received packet, set the
1684 : : * pointer to the first mbuf of the packet and initialize its
1685 : : * context. Otherwise, update the total length and the number
1686 : : * of segments of the current scattered packet, and update the
1687 : : * pointer to the last mbuf of the current packet.
1688 : : */
1689 [ # # ]: 0 : if (!first_seg) {
1690 : : first_seg = rxm;
1691 : 0 : first_seg->nb_segs = 1;
1692 : 0 : first_seg->pkt_len = rx_packet_len;
1693 : : } else {
1694 : 0 : first_seg->pkt_len =
1695 : 0 : (uint16_t)(first_seg->pkt_len +
1696 : : rx_packet_len);
1697 : 0 : first_seg->nb_segs++;
1698 : 0 : last_seg->next = rxm;
1699 : : }
1700 : :
1701 : : /* If this is not the last buffer of the received packet,
1702 : : * update the pointer to the last mbuf of the current scattered
1703 : : * packet and continue to parse the RX ring.
1704 : : */
1705 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_EOF_S))) {
1706 : : last_seg = rxm;
1707 : 0 : continue;
1708 : : }
1709 : :
1710 : : /* This is the last buffer of the received packet. If the CRC
1711 : : * is not stripped by the hardware:
1712 : : * - Subtract the CRC length from the total packet length.
1713 : : * - If the last buffer only contains the whole CRC or a part
1714 : : * of it, free the mbuf associated to the last buffer. If part
1715 : : * of the CRC is also contained in the previous mbuf, subtract
1716 : : * the length of that CRC part from the data length of the
1717 : : * previous mbuf.
1718 : : */
1719 : 0 : rxm->next = NULL;
1720 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
1721 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
1722 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
1723 : : rte_pktmbuf_free_seg(rxm);
1724 : 0 : first_seg->nb_segs--;
1725 : 0 : last_seg->data_len =
1726 : 0 : (uint16_t)(last_seg->data_len -
1727 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
1728 : 0 : last_seg->next = NULL;
1729 : : } else {
1730 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
1731 : : RTE_ETHER_CRC_LEN);
1732 : : }
1733 : : }
1734 : :
1735 : 0 : first_seg->port = rxq->port_id;
1736 : 0 : first_seg->ol_flags = 0;
1737 : 0 : first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
1738 [ # # ]: 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
1739 : : iavf_flex_rxd_to_vlan_tci(first_seg, &rxd);
1740 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(first_seg, &rxd,
1741 : : &rxq->stats.ipsec_crypto);
1742 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd);
1743 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0);
1744 : :
1745 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0) {
1746 [ # # ]: 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
1747 : : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
1748 : :
1749 : 0 : rxq->phc_time = ts_ns;
1750 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1751 : :
1752 : 0 : *RTE_MBUF_DYNFIELD(first_seg,
1753 : : iavf_timestamp_dynfield_offset,
1754 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
1755 : 0 : first_seg->ol_flags |= iavf_timestamp_dynflag;
1756 : : }
1757 : :
1758 : 0 : first_seg->ol_flags |= pkt_flags;
1759 : :
1760 : : /* Prefetch data of first segment, if configured to do so. */
1761 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1762 : : first_seg->data_off));
1763 : 0 : rx_pkts[nb_rx++] = first_seg;
1764 : : first_seg = NULL;
1765 : : }
1766 : :
1767 : : /* Record index of the next RX descriptor to probe. */
1768 : 0 : rxq->rx_tail = rx_id;
1769 : 0 : rxq->pkt_first_seg = first_seg;
1770 : 0 : rxq->pkt_last_seg = last_seg;
1771 : :
1772 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1773 : :
1774 : 0 : return nb_rx;
1775 : : }
1776 : :
1777 : : /* implement recv_scattered_pkts */
1778 : : uint16_t
1779 : 0 : iavf_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
1780 : : uint16_t nb_pkts)
1781 : : {
1782 : : struct iavf_rx_queue *rxq = rx_queue;
1783 : : union iavf_rx_desc rxd;
1784 : : struct rte_mbuf *rxe;
1785 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1786 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1787 : : struct rte_mbuf *nmb, *rxm;
1788 : 0 : uint16_t rx_id = rxq->rx_tail;
1789 : : uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
1790 : : struct rte_eth_dev *dev;
1791 : : uint32_t rx_status;
1792 : : uint64_t qword1;
1793 : : uint64_t dma_addr;
1794 : : uint64_t pkt_flags;
1795 : :
1796 : 0 : volatile union iavf_rx_desc *rx_ring = rxq->rx_ring;
1797 : : volatile union iavf_rx_desc *rxdp;
1798 : 0 : const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1799 : :
1800 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1801 : 0 : rxdp = &rx_ring[rx_id];
1802 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
1803 : 0 : rx_status = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
1804 : : IAVF_RXD_QW1_STATUS_SHIFT;
1805 : :
1806 : : /* Check the DD bit */
1807 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)))
1808 : : break;
1809 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1810 : :
1811 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1812 [ # # ]: 0 : if (unlikely(!nmb)) {
1813 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1814 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1815 : 0 : dev = &rte_eth_devices[rxq->port_id];
1816 : 0 : dev->data->rx_mbuf_alloc_failed++;
1817 : 0 : break;
1818 : : }
1819 : :
1820 : 0 : rxd = *rxdp;
1821 : 0 : nb_hold++;
1822 : 0 : rxe = rxq->sw_ring[rx_id];
1823 : 0 : rxq->sw_ring[rx_id] = nmb;
1824 : 0 : rx_id++;
1825 [ # # ]: 0 : if (rx_id == rxq->nb_rx_desc)
1826 : : rx_id = 0;
1827 : :
1828 : : /* Prefetch next mbuf */
1829 : 0 : rte_prefetch0(rxq->sw_ring[rx_id]);
1830 : :
1831 : : /* When next RX descriptor is on a cache line boundary,
1832 : : * prefetch the next 4 RX descriptors and next 8 pointers
1833 : : * to mbufs.
1834 : : */
1835 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1836 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1837 : : rte_prefetch0(rxq->sw_ring[rx_id]);
1838 : : }
1839 : :
1840 : : rxm = rxe;
1841 : : dma_addr =
1842 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1843 : :
1844 : : /* Set data buffer address and data length of the mbuf */
1845 : 0 : rxdp->read.hdr_addr = 0;
1846 : 0 : rxdp->read.pkt_addr = dma_addr;
1847 : 0 : rx_packet_len = (qword1 & IAVF_RXD_QW1_LENGTH_PBUF_MASK) >>
1848 : : IAVF_RXD_QW1_LENGTH_PBUF_SHIFT;
1849 : 0 : rxm->data_len = rx_packet_len;
1850 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1851 : :
1852 : : /* If this is the first buffer of the received packet, set the
1853 : : * pointer to the first mbuf of the packet and initialize its
1854 : : * context. Otherwise, update the total length and the number
1855 : : * of segments of the current scattered packet, and update the
1856 : : * pointer to the last mbuf of the current packet.
1857 : : */
1858 [ # # ]: 0 : if (!first_seg) {
1859 : : first_seg = rxm;
1860 : 0 : first_seg->nb_segs = 1;
1861 : 0 : first_seg->pkt_len = rx_packet_len;
1862 : : } else {
1863 : 0 : first_seg->pkt_len =
1864 : 0 : (uint16_t)(first_seg->pkt_len +
1865 : : rx_packet_len);
1866 : 0 : first_seg->nb_segs++;
1867 : 0 : last_seg->next = rxm;
1868 : : }
1869 : :
1870 : : /* If this is not the last buffer of the received packet,
1871 : : * update the pointer to the last mbuf of the current scattered
1872 : : * packet and continue to parse the RX ring.
1873 : : */
1874 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_EOF_SHIFT))) {
1875 : : last_seg = rxm;
1876 : 0 : continue;
1877 : : }
1878 : :
1879 : : /* This is the last buffer of the received packet. If the CRC
1880 : : * is not stripped by the hardware:
1881 : : * - Subtract the CRC length from the total packet length.
1882 : : * - If the last buffer only contains the whole CRC or a part
1883 : : * of it, free the mbuf associated to the last buffer. If part
1884 : : * of the CRC is also contained in the previous mbuf, subtract
1885 : : * the length of that CRC part from the data length of the
1886 : : * previous mbuf.
1887 : : */
1888 : 0 : rxm->next = NULL;
1889 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
1890 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
1891 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
1892 : : rte_pktmbuf_free_seg(rxm);
1893 : 0 : first_seg->nb_segs--;
1894 : 0 : last_seg->data_len =
1895 : 0 : (uint16_t)(last_seg->data_len -
1896 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
1897 : 0 : last_seg->next = NULL;
1898 : : } else
1899 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
1900 : : RTE_ETHER_CRC_LEN);
1901 : : }
1902 : :
1903 : 0 : first_seg->port = rxq->port_id;
1904 [ # # ]: 0 : first_seg->ol_flags = 0;
1905 : : iavf_rxd_to_vlan_tci(first_seg, &rxd);
1906 : 0 : pkt_flags = iavf_rxd_to_pkt_flags(qword1);
1907 : 0 : first_seg->packet_type =
1908 : 0 : ptype_tbl[(uint8_t)((qword1 &
1909 : 0 : IAVF_RXD_QW1_PTYPE_MASK) >> IAVF_RXD_QW1_PTYPE_SHIFT)];
1910 : :
1911 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_RSS_HASH)
1912 : 0 : first_seg->hash.rss =
1913 : 0 : rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
1914 : :
1915 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_FDIR)
1916 : 0 : pkt_flags |= iavf_rxd_build_fdir(&rxd, first_seg);
1917 : :
1918 : 0 : first_seg->ol_flags |= pkt_flags;
1919 : :
1920 : : /* Prefetch data of first segment, if configured to do so. */
1921 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1922 : : first_seg->data_off));
1923 : 0 : rx_pkts[nb_rx++] = first_seg;
1924 : : first_seg = NULL;
1925 : : }
1926 : :
1927 : : /* Record index of the next RX descriptor to probe. */
1928 : 0 : rxq->rx_tail = rx_id;
1929 : 0 : rxq->pkt_first_seg = first_seg;
1930 : 0 : rxq->pkt_last_seg = last_seg;
1931 : :
1932 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1933 : :
1934 : 0 : return nb_rx;
1935 : : }
1936 : :
1937 : : #define IAVF_LOOK_AHEAD 8
1938 : : static inline int
1939 : 0 : iavf_rx_scan_hw_ring_flex_rxd(struct iavf_rx_queue *rxq,
1940 : : struct rte_mbuf **rx_pkts,
1941 : : uint16_t nb_pkts)
1942 : : {
1943 : : volatile union iavf_rx_flex_desc *rxdp;
1944 : : struct rte_mbuf **rxep;
1945 : : struct rte_mbuf *mb;
1946 : : uint16_t stat_err0;
1947 : : uint16_t pkt_len;
1948 : : int32_t s[IAVF_LOOK_AHEAD], var, nb_dd;
1949 : : int32_t i, j, nb_rx = 0;
1950 : : int32_t nb_staged = 0;
1951 : : uint64_t pkt_flags;
1952 : 0 : const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1953 : : uint64_t ts_ns;
1954 : :
1955 : 0 : rxdp = (volatile union iavf_rx_flex_desc *)&rxq->rx_ring[rxq->rx_tail];
1956 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
1957 : :
1958 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1959 : :
1960 : : /* Make sure there is at least 1 packet to receive */
1961 [ # # ]: 0 : if (!(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1962 : : return 0;
1963 : :
1964 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1965 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1966 : :
1967 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1968 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1969 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1970 : 0 : rxq->hw_time_update = sw_cur_time;
1971 : : }
1972 : : }
1973 : :
1974 : : /* Scan LOOK_AHEAD descriptors at a time to determine which
1975 : : * descriptors reference packets that are ready to be received.
1976 : : */
1977 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i += IAVF_LOOK_AHEAD,
1978 : 0 : rxdp += IAVF_LOOK_AHEAD, rxep += IAVF_LOOK_AHEAD) {
1979 : : /* Read desc statuses backwards to avoid race condition */
1980 [ # # ]: 0 : for (j = IAVF_LOOK_AHEAD - 1; j >= 0; j--)
1981 : 0 : s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1982 : :
1983 : : /* This barrier is to order loads of different words in the descriptor */
1984 : : rte_atomic_thread_fence(rte_memory_order_acquire);
1985 : :
1986 : : /* Compute how many contiguous DD bits were set */
1987 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < IAVF_LOOK_AHEAD; j++) {
1988 : 0 : var = s[j] & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S);
1989 : : #ifdef RTE_ARCH_ARM
1990 : : /* For Arm platforms, count only contiguous descriptors
1991 : : * whose DD bit is set to 1. On Arm platforms, reads of
1992 : : * descriptors can be reordered. Since the CPU may
1993 : : * be reading the descriptors as the NIC updates them
1994 : : * in memory, it is possbile that the DD bit for a
1995 : : * descriptor earlier in the queue is read as not set
1996 : : * while the DD bit for a descriptor later in the queue
1997 : : * is read as set.
1998 : : */
1999 : : if (var)
2000 : : nb_dd += 1;
2001 : : else
2002 : : break;
2003 : : #else
2004 : 0 : nb_dd += var;
2005 : : #endif
2006 : : }
2007 : :
2008 : : /* Translate descriptor info to mbuf parameters */
2009 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
2010 : : IAVF_DUMP_RX_DESC(rxq, &rxdp[j],
2011 : : rxq->rx_tail +
2012 : : i * IAVF_LOOK_AHEAD + j);
2013 : :
2014 : 0 : mb = rxep[j];
2015 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
2016 : 0 : IAVF_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2017 : 0 : mb->data_len = pkt_len;
2018 : 0 : mb->pkt_len = pkt_len;
2019 : 0 : mb->ol_flags = 0;
2020 : :
2021 : 0 : mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
2022 [ # # ]: 0 : rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
2023 : : iavf_flex_rxd_to_vlan_tci(mb, &rxdp[j]);
2024 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(mb, &rxdp[j],
2025 : : &rxq->stats.ipsec_crypto);
2026 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);
2027 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
2028 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(stat_err0);
2029 : :
2030 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0) {
2031 : 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
2032 [ # # ]: 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high));
2033 : :
2034 : 0 : rxq->phc_time = ts_ns;
2035 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2036 : 0 : (rte_get_timer_hz() / 1000);
2037 : :
2038 : 0 : *RTE_MBUF_DYNFIELD(mb,
2039 : : iavf_timestamp_dynfield_offset,
2040 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2041 : 0 : mb->ol_flags |= iavf_timestamp_dynflag;
2042 : : }
2043 : :
2044 : 0 : mb->ol_flags |= pkt_flags;
2045 : :
2046 : : /* Put up to nb_pkts directly into buffers */
2047 [ # # ]: 0 : if ((i + j) < nb_pkts) {
2048 : 0 : rx_pkts[i + j] = rxep[j];
2049 : 0 : nb_rx++;
2050 : : } else {
2051 : : /* Stage excess pkts received */
2052 : 0 : rxq->rx_stage[nb_staged] = rxep[j];
2053 : 0 : nb_staged++;
2054 : : }
2055 : : }
2056 : :
2057 [ # # ]: 0 : if (nb_dd != IAVF_LOOK_AHEAD)
2058 : : break;
2059 : : }
2060 : :
2061 : : /* Update rxq->rx_nb_avail to reflect number of staged pkts */
2062 : 0 : rxq->rx_nb_avail = nb_staged;
2063 : :
2064 : : /* Clear software ring entries */
2065 [ # # ]: 0 : for (i = 0; i < (nb_rx + nb_staged); i++)
2066 : 0 : rxq->sw_ring[rxq->rx_tail + i] = NULL;
2067 : :
2068 : : return nb_rx;
2069 : : }
2070 : :
2071 : : static inline int
2072 : 0 : iavf_rx_scan_hw_ring(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2073 : : {
2074 : : volatile union iavf_rx_desc *rxdp;
2075 : : struct rte_mbuf **rxep;
2076 : : struct rte_mbuf *mb;
2077 : : uint16_t pkt_len;
2078 : : uint64_t qword1;
2079 : : uint32_t rx_status;
2080 : : int32_t s[IAVF_LOOK_AHEAD], var, nb_dd;
2081 : : int32_t i, j, nb_rx = 0;
2082 : : int32_t nb_staged = 0;
2083 : : uint64_t pkt_flags;
2084 : 0 : const uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
2085 : :
2086 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
2087 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
2088 : :
2089 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
2090 : 0 : rx_status = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
2091 : : IAVF_RXD_QW1_STATUS_SHIFT;
2092 : :
2093 : : /* Make sure there is at least 1 packet to receive */
2094 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)))
2095 : : return 0;
2096 : :
2097 : : /* Scan LOOK_AHEAD descriptors at a time to determine which
2098 : : * descriptors reference packets that are ready to be received.
2099 : : */
2100 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i += IAVF_LOOK_AHEAD,
2101 : 0 : rxdp += IAVF_LOOK_AHEAD, rxep += IAVF_LOOK_AHEAD) {
2102 : : /* Read desc statuses backwards to avoid race condition */
2103 [ # # ]: 0 : for (j = IAVF_LOOK_AHEAD - 1; j >= 0; j--) {
2104 : 0 : qword1 = rte_le_to_cpu_64(
2105 : : rxdp[j].wb.qword1.status_error_len);
2106 : 0 : s[j] = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
2107 : : IAVF_RXD_QW1_STATUS_SHIFT;
2108 : : }
2109 : :
2110 : : /* This barrier is to order loads of different words in the descriptor */
2111 : : rte_atomic_thread_fence(rte_memory_order_acquire);
2112 : :
2113 : : /* Compute how many contiguous DD bits were set */
2114 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < IAVF_LOOK_AHEAD; j++) {
2115 : 0 : var = s[j] & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
2116 : : #ifdef RTE_ARCH_ARM
2117 : : /* For Arm platforms, count only contiguous descriptors
2118 : : * whose DD bit is set to 1. On Arm platforms, reads of
2119 : : * descriptors can be reordered. Since the CPU may
2120 : : * be reading the descriptors as the NIC updates them
2121 : : * in memory, it is possbile that the DD bit for a
2122 : : * descriptor earlier in the queue is read as not set
2123 : : * while the DD bit for a descriptor later in the queue
2124 : : * is read as set.
2125 : : */
2126 : : if (var)
2127 : : nb_dd += 1;
2128 : : else
2129 : : break;
2130 : : #else
2131 : 0 : nb_dd += var;
2132 : : #endif
2133 : : }
2134 : :
2135 : : /* Translate descriptor info to mbuf parameters */
2136 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
2137 : : IAVF_DUMP_RX_DESC(rxq, &rxdp[j],
2138 : : rxq->rx_tail + i * IAVF_LOOK_AHEAD + j);
2139 : :
2140 : 0 : mb = rxep[j];
2141 : 0 : qword1 = rte_le_to_cpu_64
2142 : : (rxdp[j].wb.qword1.status_error_len);
2143 : 0 : pkt_len = ((qword1 & IAVF_RXD_QW1_LENGTH_PBUF_MASK) >>
2144 : 0 : IAVF_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;
2145 : 0 : mb->data_len = pkt_len;
2146 : 0 : mb->pkt_len = pkt_len;
2147 [ # # ]: 0 : mb->ol_flags = 0;
2148 : : iavf_rxd_to_vlan_tci(mb, &rxdp[j]);
2149 : 0 : pkt_flags = iavf_rxd_to_pkt_flags(qword1);
2150 : 0 : mb->packet_type =
2151 : 0 : ptype_tbl[(uint8_t)((qword1 &
2152 : 0 : IAVF_RXD_QW1_PTYPE_MASK) >>
2153 : : IAVF_RXD_QW1_PTYPE_SHIFT)];
2154 : :
2155 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_RSS_HASH)
2156 : 0 : mb->hash.rss = rte_le_to_cpu_32(
2157 : : rxdp[j].wb.qword0.hi_dword.rss);
2158 : :
2159 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_FDIR)
2160 : 0 : pkt_flags |= iavf_rxd_build_fdir(&rxdp[j], mb);
2161 : :
2162 : 0 : mb->ol_flags |= pkt_flags;
2163 : :
2164 : : /* Put up to nb_pkts directly into buffers */
2165 [ # # ]: 0 : if ((i + j) < nb_pkts) {
2166 : 0 : rx_pkts[i + j] = rxep[j];
2167 : 0 : nb_rx++;
2168 : : } else { /* Stage excess pkts received */
2169 : 0 : rxq->rx_stage[nb_staged] = rxep[j];
2170 : 0 : nb_staged++;
2171 : : }
2172 : : }
2173 : :
2174 [ # # ]: 0 : if (nb_dd != IAVF_LOOK_AHEAD)
2175 : : break;
2176 : : }
2177 : :
2178 : : /* Update rxq->rx_nb_avail to reflect number of staged pkts */
2179 : 0 : rxq->rx_nb_avail = nb_staged;
2180 : :
2181 : : /* Clear software ring entries */
2182 [ # # ]: 0 : for (i = 0; i < (nb_rx + nb_staged); i++)
2183 : 0 : rxq->sw_ring[rxq->rx_tail + i] = NULL;
2184 : :
2185 : : return nb_rx;
2186 : : }
2187 : :
2188 : : static inline uint16_t
2189 : : iavf_rx_fill_from_stage(struct iavf_rx_queue *rxq,
2190 : : struct rte_mbuf **rx_pkts,
2191 : : uint16_t nb_pkts)
2192 : : {
2193 : : uint16_t i;
2194 : 0 : struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
2195 : :
2196 : 0 : nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
2197 : :
2198 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
2199 : 0 : rx_pkts[i] = stage[i];
2200 : :
2201 : 0 : rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
2202 : 0 : rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
2203 : :
2204 : : return nb_pkts;
2205 : : }
2206 : :
2207 : : static inline int
2208 : 0 : iavf_rx_alloc_bufs(struct iavf_rx_queue *rxq)
2209 : : {
2210 : : volatile union iavf_rx_desc *rxdp;
2211 : : struct rte_mbuf **rxep;
2212 : : struct rte_mbuf *mb;
2213 : : uint16_t alloc_idx, i;
2214 : : uint64_t dma_addr;
2215 : : int diag;
2216 : :
2217 : : /* Allocate buffers in bulk */
2218 : 0 : alloc_idx = (uint16_t)(rxq->rx_free_trigger -
2219 : 0 : (rxq->rx_free_thresh - 1));
2220 : 0 : rxep = &rxq->sw_ring[alloc_idx];
2221 [ # # ]: 0 : diag = rte_mempool_get_bulk(rxq->mp, (void *)rxep,
2222 : : rxq->rx_free_thresh);
2223 [ # # ]: 0 : if (unlikely(diag != 0)) {
2224 : : PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
2225 : : return -ENOMEM;
2226 : : }
2227 : :
2228 : 0 : rxdp = &rxq->rx_ring[alloc_idx];
2229 [ # # ]: 0 : for (i = 0; i < rxq->rx_free_thresh; i++) {
2230 [ # # ]: 0 : if (likely(i < (rxq->rx_free_thresh - 1)))
2231 : : /* Prefetch next mbuf */
2232 : 0 : rte_prefetch0(rxep[i + 1]);
2233 : :
2234 : 0 : mb = rxep[i];
2235 : : rte_mbuf_refcnt_set(mb, 1);
2236 : 0 : mb->next = NULL;
2237 : 0 : mb->data_off = RTE_PKTMBUF_HEADROOM;
2238 : 0 : mb->nb_segs = 1;
2239 : 0 : mb->port = rxq->port_id;
2240 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
2241 : 0 : rxdp[i].read.hdr_addr = 0;
2242 : 0 : rxdp[i].read.pkt_addr = dma_addr;
2243 : : }
2244 : :
2245 : : /* Update rx tail register */
2246 : : rte_wmb();
2247 [ # # ]: 0 : IAVF_PCI_REG_WC_WRITE_RELAXED(rxq->qrx_tail, rxq->rx_free_trigger);
2248 : :
2249 : 0 : rxq->rx_free_trigger =
2250 : 0 : (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
2251 [ # # ]: 0 : if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
2252 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
2253 : :
2254 : : return 0;
2255 : : }
2256 : :
2257 : : static inline uint16_t
2258 : 0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2259 : : {
2260 : : struct iavf_rx_queue *rxq = (struct iavf_rx_queue *)rx_queue;
2261 : : uint16_t nb_rx = 0;
2262 : :
2263 [ # # ]: 0 : if (!nb_pkts)
2264 : : return 0;
2265 : :
2266 [ # # ]: 0 : if (rxq->rx_nb_avail)
2267 : 0 : return iavf_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2268 : :
2269 [ # # ]: 0 : if (rxq->rxdid >= IAVF_RXDID_FLEX_NIC && rxq->rxdid <= IAVF_RXDID_LAST)
2270 : 0 : nb_rx = (uint16_t)iavf_rx_scan_hw_ring_flex_rxd(rxq, rx_pkts, nb_pkts);
2271 : : else
2272 : 0 : nb_rx = (uint16_t)iavf_rx_scan_hw_ring(rxq, rx_pkts, nb_pkts);
2273 : :
2274 : 0 : rxq->rx_next_avail = 0;
2275 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx + rxq->rx_nb_avail);
2276 : :
2277 [ # # ]: 0 : if (rxq->rx_tail > rxq->rx_free_trigger) {
2278 [ # # ]: 0 : if (iavf_rx_alloc_bufs(rxq) != 0) {
2279 : : uint16_t i, j, nb_staged;
2280 : :
2281 : : /* TODO: count rx_mbuf_alloc_failed here */
2282 : :
2283 : 0 : nb_staged = rxq->rx_nb_avail;
2284 : 0 : rxq->rx_nb_avail = 0;
2285 : :
2286 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail - (nb_rx + nb_staged));
2287 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++) {
2288 : 0 : rxq->sw_ring[j] = rx_pkts[i];
2289 : 0 : rx_pkts[i] = NULL;
2290 : : }
2291 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail + nb_rx; i < nb_staged; i++, j++) {
2292 : 0 : rxq->sw_ring[j] = rxq->rx_stage[i];
2293 : 0 : rx_pkts[i] = NULL;
2294 : : }
2295 : :
2296 : : return 0;
2297 : : }
2298 : : }
2299 : :
2300 [ # # ]: 0 : if (rxq->rx_tail >= rxq->nb_rx_desc)
2301 : 0 : rxq->rx_tail = 0;
2302 : :
2303 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u, nb_rx=%u",
2304 : : rxq->port_id, rxq->queue_id,
2305 : : rxq->rx_tail, nb_rx);
2306 : :
2307 : : return nb_rx;
2308 : : }
2309 : :
2310 : : static uint16_t
2311 : 0 : iavf_recv_pkts_bulk_alloc(void *rx_queue,
2312 : : struct rte_mbuf **rx_pkts,
2313 : : uint16_t nb_pkts)
2314 : : {
2315 : : uint16_t nb_rx = 0, n, count;
2316 : :
2317 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
2318 : : return 0;
2319 : :
2320 [ # # ]: 0 : if (likely(nb_pkts <= IAVF_RX_MAX_BURST))
2321 : 0 : return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
2322 : :
2323 [ # # ]: 0 : while (nb_pkts) {
2324 : 0 : n = RTE_MIN(nb_pkts, IAVF_RX_MAX_BURST);
2325 : 0 : count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
2326 : 0 : nb_rx = (uint16_t)(nb_rx + count);
2327 : 0 : nb_pkts = (uint16_t)(nb_pkts - count);
2328 [ # # ]: 0 : if (count < n)
2329 : : break;
2330 : : }
2331 : :
2332 : : return nb_rx;
2333 : : }
2334 : :
2335 : : static inline int
2336 : 0 : iavf_xmit_cleanup(struct ci_tx_queue *txq)
2337 : : {
2338 : 0 : struct ci_tx_entry *sw_ring = txq->sw_ring;
2339 : 0 : uint16_t last_desc_cleaned = txq->last_desc_cleaned;
2340 : 0 : uint16_t nb_tx_desc = txq->nb_tx_desc;
2341 : : uint16_t desc_to_clean_to;
2342 : : uint16_t nb_tx_to_clean;
2343 : :
2344 : 0 : volatile struct iavf_tx_desc *txd = txq->iavf_tx_ring;
2345 : :
2346 : 0 : desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
2347 [ # # ]: 0 : if (desc_to_clean_to >= nb_tx_desc)
2348 : 0 : desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
2349 : :
2350 : 0 : desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
2351 [ # # ]: 0 : if ((txd[desc_to_clean_to].cmd_type_offset_bsz &
2352 : : rte_cpu_to_le_64(IAVF_TXD_QW1_DTYPE_MASK)) !=
2353 : : rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE)) {
2354 : : PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
2355 : : "(port=%d queue=%d)", desc_to_clean_to,
2356 : : txq->port_id, txq->queue_id);
2357 : : return -1;
2358 : : }
2359 : :
2360 [ # # ]: 0 : if (last_desc_cleaned > desc_to_clean_to)
2361 : 0 : nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
2362 : : desc_to_clean_to);
2363 : : else
2364 : 0 : nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
2365 : : last_desc_cleaned);
2366 : :
2367 : 0 : txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
2368 : :
2369 : 0 : txq->last_desc_cleaned = desc_to_clean_to;
2370 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
2371 : :
2372 : 0 : return 0;
2373 : : }
2374 : :
2375 : : /* Check if the context descriptor is needed for TX offloading */
2376 : : static inline uint16_t
2377 : : iavf_calc_context_desc(struct rte_mbuf *mb, uint8_t vlan_flag)
2378 : : {
2379 : : uint64_t flags = mb->ol_flags;
2380 : 0 : if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
2381 : : RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
2382 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2383 : : return 1;
2384 [ # # # # ]: 0 : if (flags & RTE_MBUF_F_TX_VLAN &&
2385 : : vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
2386 : : return 1;
2387 : :
2388 [ # # # # ]: 0 : if (IAVF_CHECK_TX_LLDP(mb))
2389 : 0 : return 1;
2390 : :
2391 : : return 0;
2392 : : }
2393 : :
2394 : : static inline void
2395 : 0 : iavf_fill_ctx_desc_cmd_field(volatile uint64_t *field, struct rte_mbuf *m,
2396 : : uint8_t vlan_flag)
2397 : : {
2398 : : uint64_t cmd = 0;
2399 : :
2400 : : /* TSO enabled */
2401 [ # # ]: 0 : if (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
2402 : : cmd = IAVF_TX_CTX_DESC_TSO << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2403 : :
2404 [ # # # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_VLAN &&
2405 : : vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2406 : 0 : cmd |= IAVF_TX_CTX_DESC_IL2TAG2
2407 : : << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2408 : : }
2409 : :
2410 [ # # # # ]: 0 : if (IAVF_CHECK_TX_LLDP(m))
2411 : 0 : cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK
2412 : : << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2413 : :
2414 : 0 : *field |= cmd;
2415 : 0 : }
2416 : :
2417 : : static inline void
2418 : : iavf_fill_ctx_desc_ipsec_field(volatile uint64_t *field,
2419 : : struct iavf_ipsec_crypto_pkt_metadata *ipsec_md)
2420 : : {
2421 : 0 : uint64_t ipsec_field =
2422 : 0 : (uint64_t)ipsec_md->ctx_desc_ipsec_params <<
2423 : : IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT;
2424 : :
2425 : 0 : *field |= ipsec_field;
2426 : 0 : }
2427 : :
2428 : :
2429 : : static inline void
2430 : 0 : iavf_fill_ctx_desc_tunnelling_field(volatile uint64_t *qw0,
2431 : : const struct rte_mbuf *m)
2432 : : {
2433 : : uint64_t eip_typ = IAVF_TX_CTX_DESC_EIPT_NONE;
2434 : : uint64_t eip_len = 0;
2435 : : uint64_t eip_noinc = 0;
2436 : : /* Default - IP_ID is increment in each segment of LSO */
2437 : :
2438 [ # # # # ]: 0 : switch (m->ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 |
2439 : : RTE_MBUF_F_TX_OUTER_IPV6 |
2440 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM)) {
2441 : 0 : case RTE_MBUF_F_TX_OUTER_IPV4:
2442 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD;
2443 : 0 : eip_len = m->outer_l3_len >> 2;
2444 : 0 : break;
2445 : 0 : case RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IP_CKSUM:
2446 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD;
2447 : 0 : eip_len = m->outer_l3_len >> 2;
2448 : 0 : break;
2449 : 0 : case RTE_MBUF_F_TX_OUTER_IPV6:
2450 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV6;
2451 : 0 : eip_len = m->outer_l3_len >> 2;
2452 : 0 : break;
2453 : : }
2454 : :
2455 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
2456 : : /* L4TUNT: L4 Tunneling Type */
2457 [ # # # # ]: 0 : switch (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2458 : : case RTE_MBUF_F_TX_TUNNEL_IPIP:
2459 : : /* for non UDP / GRE tunneling, set to 00b */
2460 : : break;
2461 : 0 : case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2462 : : case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
2463 : : case RTE_MBUF_F_TX_TUNNEL_GTP:
2464 : : case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2465 : 0 : eip_typ |= IAVF_TXD_CTX_UDP_TUNNELING;
2466 : 0 : break;
2467 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2468 : 0 : eip_typ |= IAVF_TXD_CTX_GRE_TUNNELING;
2469 : 0 : break;
2470 : : default:
2471 : : PMD_TX_LOG(ERR, "Tunnel type not supported");
2472 : : return;
2473 : : }
2474 : :
2475 : : /* L4TUNLEN: L4 Tunneling Length, in Words
2476 : : *
2477 : : * We depend on app to set rte_mbuf.l2_len correctly.
2478 : : * For IP in GRE it should be set to the length of the GRE
2479 : : * header;
2480 : : * For MAC in GRE or MAC in UDP it should be set to the length
2481 : : * of the GRE or UDP headers plus the inner MAC up to including
2482 : : * its last Ethertype.
2483 : : * If MPLS labels exists, it should include them as well.
2484 : : */
2485 : 0 : eip_typ |= (m->l2_len >> 1) << IAVF_TXD_CTX_QW0_NATLEN_SHIFT;
2486 : :
2487 : : /**
2488 : : * Calculate the tunneling UDP checksum.
2489 : : * Shall be set only if L4TUNT = 01b and EIPT is not zero
2490 : : */
2491 [ # # ]: 0 : if ((eip_typ & (IAVF_TX_CTX_EXT_IP_IPV6 |
2492 : : IAVF_TX_CTX_EXT_IP_IPV4 |
2493 : 0 : IAVF_TX_CTX_EXT_IP_IPV4_NO_CSUM)) &&
2494 [ # # ]: 0 : (eip_typ & IAVF_TXD_CTX_UDP_TUNNELING) &&
2495 [ # # ]: 0 : (m->ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2496 : 0 : eip_typ |= IAVF_TXD_CTX_QW0_L4T_CS_MASK;
2497 : : }
2498 : :
2499 : 0 : *qw0 = eip_typ << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT |
2500 : 0 : eip_len << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT |
2501 : : eip_noinc << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT;
2502 : : }
2503 : :
2504 : : static inline uint16_t
2505 : 0 : iavf_fill_ctx_desc_segmentation_field(volatile uint64_t *field,
2506 : : struct rte_mbuf *m, struct iavf_ipsec_crypto_pkt_metadata *ipsec_md)
2507 : : {
2508 : : uint64_t segmentation_field = 0;
2509 : : uint64_t total_length = 0;
2510 : :
2511 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
2512 : 0 : total_length = ipsec_md->l4_payload_len;
2513 : : } else {
2514 : 0 : total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len);
2515 : :
2516 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2517 : 0 : total_length -= m->outer_l3_len + m->outer_l2_len;
2518 : : }
2519 : :
2520 : : #ifdef RTE_ETHDEV_DEBUG_TX
2521 : : if (!m->l4_len || !m->tso_segsz)
2522 : : PMD_TX_LOG(DEBUG, "L4 length %d, LSO Segment size %d",
2523 : : m->l4_len, m->tso_segsz);
2524 : : if (m->tso_segsz < 88)
2525 : : PMD_TX_LOG(DEBUG, "LSO Segment size %d is less than minimum %d",
2526 : : m->tso_segsz, 88);
2527 : : #endif
2528 : 0 : segmentation_field =
2529 : 0 : (((uint64_t)total_length << IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT) &
2530 : : IAVF_TXD_CTX_QW1_TSO_LEN_MASK) |
2531 : 0 : (((uint64_t)m->tso_segsz << IAVF_TXD_CTX_QW1_MSS_SHIFT) &
2532 : : IAVF_TXD_CTX_QW1_MSS_MASK);
2533 : :
2534 : 0 : *field |= segmentation_field;
2535 : :
2536 : 0 : return total_length;
2537 : : }
2538 : :
2539 : :
2540 : : struct iavf_tx_context_desc_qws {
2541 : : __le64 qw0;
2542 : : __le64 qw1;
2543 : : };
2544 : :
2545 : : static inline void
2546 : 0 : iavf_fill_context_desc(volatile struct iavf_tx_context_desc *desc,
2547 : : struct rte_mbuf *m, struct iavf_ipsec_crypto_pkt_metadata *ipsec_md,
2548 : : uint16_t *tlen, uint8_t vlan_flag)
2549 : : {
2550 : : volatile struct iavf_tx_context_desc_qws *desc_qws =
2551 : : (volatile struct iavf_tx_context_desc_qws *)desc;
2552 : : /* fill descriptor type field */
2553 : 0 : desc_qws->qw1 = IAVF_TX_DESC_DTYPE_CONTEXT;
2554 : :
2555 : : /* fill command field */
2556 : 0 : iavf_fill_ctx_desc_cmd_field(&desc_qws->qw1, m, vlan_flag);
2557 : :
2558 : : /* fill segmentation field */
2559 [ # # ]: 0 : if (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
2560 : : /* fill IPsec field */
2561 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)
2562 : : iavf_fill_ctx_desc_ipsec_field(&desc_qws->qw1,
2563 : : ipsec_md);
2564 : :
2565 : 0 : *tlen = iavf_fill_ctx_desc_segmentation_field(&desc_qws->qw1,
2566 : : m, ipsec_md);
2567 : : }
2568 : :
2569 : : /* fill tunnelling field */
2570 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2571 : 0 : iavf_fill_ctx_desc_tunnelling_field(&desc_qws->qw0, m);
2572 : : else
2573 : 0 : desc_qws->qw0 = 0;
2574 : :
2575 : 0 : desc_qws->qw0 = rte_cpu_to_le_64(desc_qws->qw0);
2576 : 0 : desc_qws->qw1 = rte_cpu_to_le_64(desc_qws->qw1);
2577 : :
2578 [ # # ]: 0 : if (vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
2579 : 0 : desc->l2tag2 = m->vlan_tci;
2580 : 0 : }
2581 : :
2582 : :
2583 : : static inline void
2584 : 0 : iavf_fill_ipsec_desc(volatile struct iavf_tx_ipsec_desc *desc,
2585 : : const struct iavf_ipsec_crypto_pkt_metadata *md, uint16_t *ipsec_len)
2586 : : {
2587 : 0 : desc->qw0 = rte_cpu_to_le_64(((uint64_t)md->l4_payload_len <<
2588 : : IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) |
2589 : : ((uint64_t)md->esn << IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) |
2590 : : ((uint64_t)md->esp_trailer_len <<
2591 : : IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT));
2592 : :
2593 : 0 : desc->qw1 = rte_cpu_to_le_64(((uint64_t)md->sa_idx <<
2594 : : IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) |
2595 : : ((uint64_t)md->next_proto <<
2596 : : IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) |
2597 : : ((uint64_t)(md->len_iv & 0x3) <<
2598 : : IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) |
2599 : : ((uint64_t)(md->ol_flags & IAVF_IPSEC_CRYPTO_OL_FLAGS_NATT ?
2600 : : 1ULL : 0ULL) <<
2601 : : IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) |
2602 : : (uint64_t)IAVF_TX_DESC_DTYPE_IPSEC);
2603 : :
2604 : : /**
2605 : : * TODO: Pre-calculate this in the Session initialization
2606 : : *
2607 : : * Calculate IPsec length required in data descriptor func when TSO
2608 : : * offload is enabled
2609 : : */
2610 : 0 : *ipsec_len = sizeof(struct rte_esp_hdr) + (md->len_iv >> 2) +
2611 : : (md->ol_flags & IAVF_IPSEC_CRYPTO_OL_FLAGS_NATT ?
2612 : 0 : sizeof(struct rte_udp_hdr) : 0);
2613 : 0 : }
2614 : :
2615 : : static inline void
2616 : 0 : iavf_build_data_desc_cmd_offset_fields(volatile uint64_t *qw1,
2617 : : struct rte_mbuf *m, uint8_t vlan_flag)
2618 : : {
2619 : : uint64_t command = 0;
2620 : : uint64_t offset = 0;
2621 : : uint64_t l2tag1 = 0;
2622 : :
2623 : 0 : *qw1 = IAVF_TX_DESC_DTYPE_DATA;
2624 : :
2625 : : command = (uint64_t)IAVF_TX_DESC_CMD_ICRC;
2626 : :
2627 : : /* Descriptor based VLAN insertion */
2628 [ # # ]: 0 : if ((vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) &&
2629 [ # # ]: 0 : m->ol_flags & RTE_MBUF_F_TX_VLAN) {
2630 : : command |= (uint64_t)IAVF_TX_DESC_CMD_IL2TAG1;
2631 : 0 : l2tag1 |= m->vlan_tci;
2632 : : }
2633 : :
2634 [ # # ]: 0 : if ((m->ol_flags &
2635 : : (IAVF_TX_CKSUM_OFFLOAD_MASK | RTE_MBUF_F_TX_SEC_OFFLOAD)) == 0)
2636 : 0 : goto skip_cksum;
2637 : :
2638 : : /* Set MACLEN */
2639 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK &&
2640 [ # # ]: 0 : !(m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD))
2641 : 0 : offset |= (m->outer_l2_len >> 1)
2642 : 0 : << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT;
2643 : : else
2644 : 0 : offset |= (m->l2_len >> 1)
2645 : 0 : << IAVF_TX_DESC_LENGTH_MACLEN_SHIFT;
2646 : :
2647 : : /* Enable L3 checksum offloading inner */
2648 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
2649 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
2650 : 0 : command |= IAVF_TX_DESC_CMD_IIPT_IPV4_CSUM;
2651 : 0 : offset |= (m->l3_len >> 2) << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
2652 : : }
2653 [ # # ]: 0 : } else if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
2654 : 0 : command |= IAVF_TX_DESC_CMD_IIPT_IPV4;
2655 : 0 : offset |= (m->l3_len >> 2) << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
2656 [ # # ]: 0 : } else if (m->ol_flags & RTE_MBUF_F_TX_IPV6) {
2657 : 0 : command |= IAVF_TX_DESC_CMD_IIPT_IPV6;
2658 : 0 : offset |= (m->l3_len >> 2) << IAVF_TX_DESC_LENGTH_IPLEN_SHIFT;
2659 : : }
2660 : :
2661 [ # # ]: 0 : if (m->ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
2662 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_TCP_SEG)
2663 : 0 : command |= IAVF_TX_DESC_CMD_L4T_EOFT_TCP;
2664 : : else
2665 : 0 : command |= IAVF_TX_DESC_CMD_L4T_EOFT_UDP;
2666 : 0 : offset |= (m->l4_len >> 2) <<
2667 : : IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
2668 : :
2669 : 0 : *qw1 = rte_cpu_to_le_64((((uint64_t)command <<
2670 : : IAVF_TXD_DATA_QW1_CMD_SHIFT) & IAVF_TXD_DATA_QW1_CMD_MASK) |
2671 : : (((uint64_t)offset << IAVF_TXD_DATA_QW1_OFFSET_SHIFT) &
2672 : : IAVF_TXD_DATA_QW1_OFFSET_MASK) |
2673 : : ((uint64_t)l2tag1 << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT));
2674 : :
2675 : 0 : return;
2676 : : }
2677 : :
2678 : : /* Enable L4 checksum offloads */
2679 [ # # # # ]: 0 : switch (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) {
2680 : 0 : case RTE_MBUF_F_TX_TCP_CKSUM:
2681 : 0 : command |= IAVF_TX_DESC_CMD_L4T_EOFT_TCP;
2682 : 0 : offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
2683 : : IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
2684 : 0 : break;
2685 : 0 : case RTE_MBUF_F_TX_SCTP_CKSUM:
2686 : 0 : command |= IAVF_TX_DESC_CMD_L4T_EOFT_SCTP;
2687 : 0 : offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
2688 : : IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
2689 : 0 : break;
2690 : 0 : case RTE_MBUF_F_TX_UDP_CKSUM:
2691 : 0 : command |= IAVF_TX_DESC_CMD_L4T_EOFT_UDP;
2692 : 0 : offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
2693 : : IAVF_TX_DESC_LENGTH_L4_FC_LEN_SHIFT;
2694 : 0 : break;
2695 : : }
2696 : :
2697 : 0 : skip_cksum:
2698 : 0 : *qw1 = rte_cpu_to_le_64((((uint64_t)command <<
2699 : : IAVF_TXD_DATA_QW1_CMD_SHIFT) & IAVF_TXD_DATA_QW1_CMD_MASK) |
2700 : : (((uint64_t)offset << IAVF_TXD_DATA_QW1_OFFSET_SHIFT) &
2701 : : IAVF_TXD_DATA_QW1_OFFSET_MASK) |
2702 : : ((uint64_t)l2tag1 << IAVF_TXD_DATA_QW1_L2TAG1_SHIFT));
2703 : : }
2704 : :
2705 : : /* Calculate the number of TX descriptors needed for each pkt */
2706 : : static inline uint16_t
2707 : : iavf_calc_pkt_desc(struct rte_mbuf *tx_pkt)
2708 : : {
2709 : : struct rte_mbuf *txd = tx_pkt;
2710 : : uint16_t count = 0;
2711 : :
2712 [ # # ]: 0 : while (txd != NULL) {
2713 : 0 : count += (txd->data_len + IAVF_MAX_DATA_PER_TXD - 1) /
2714 : : IAVF_MAX_DATA_PER_TXD;
2715 : 0 : txd = txd->next;
2716 : : }
2717 : :
2718 : : return count;
2719 : : }
2720 : :
2721 : : static inline void
2722 : : iavf_fill_data_desc(volatile struct iavf_tx_desc *desc,
2723 : : uint64_t desc_template, uint16_t buffsz,
2724 : : uint64_t buffer_addr)
2725 : : {
2726 : : /* fill data descriptor qw1 from template */
2727 : 0 : desc->cmd_type_offset_bsz = desc_template;
2728 : :
2729 : : /* set data buffer size */
2730 : 0 : desc->cmd_type_offset_bsz |=
2731 : 0 : (((uint64_t)buffsz << IAVF_TXD_DATA_QW1_TX_BUF_SZ_SHIFT) &
2732 : : IAVF_TXD_DATA_QW1_TX_BUF_SZ_MASK);
2733 : :
2734 : 0 : desc->buffer_addr = rte_cpu_to_le_64(buffer_addr);
2735 : 0 : desc->cmd_type_offset_bsz = rte_cpu_to_le_64(desc->cmd_type_offset_bsz);
2736 : : }
2737 : :
2738 : :
2739 : : static struct iavf_ipsec_crypto_pkt_metadata *
2740 : : iavf_ipsec_crypto_get_pkt_metadata(const struct ci_tx_queue *txq,
2741 : : struct rte_mbuf *m)
2742 : : {
2743 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)
2744 : 0 : return RTE_MBUF_DYNFIELD(m, txq->ipsec_crypto_pkt_md_offset,
2745 : : struct iavf_ipsec_crypto_pkt_metadata *);
2746 : :
2747 : : return NULL;
2748 : : }
2749 : :
2750 : : /* TX function */
2751 : : uint16_t
2752 : 0 : iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2753 : : {
2754 : : struct ci_tx_queue *txq = tx_queue;
2755 : 0 : volatile struct iavf_tx_desc *txr = txq->iavf_tx_ring;
2756 : 0 : struct ci_tx_entry *txe_ring = txq->sw_ring;
2757 : : struct ci_tx_entry *txe, *txn;
2758 : : struct rte_mbuf *mb, *mb_seg;
2759 : : uint64_t buf_dma_addr;
2760 : : uint16_t desc_idx, desc_idx_last;
2761 : : uint16_t idx;
2762 : : uint16_t slen;
2763 : :
2764 : :
2765 : : /* Check if the descriptor ring needs to be cleaned. */
2766 [ # # ]: 0 : if (txq->nb_tx_free < txq->tx_free_thresh)
2767 : 0 : iavf_xmit_cleanup(txq);
2768 : :
2769 : 0 : desc_idx = txq->tx_tail;
2770 : 0 : txe = &txe_ring[desc_idx];
2771 : :
2772 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
2773 : : volatile struct iavf_tx_desc *ddesc;
2774 : : struct iavf_ipsec_crypto_pkt_metadata *ipsec_md;
2775 : :
2776 : : uint16_t nb_desc_ctx, nb_desc_ipsec;
2777 : : uint16_t nb_desc_data, nb_desc_required;
2778 : 0 : uint16_t tlen = 0, ipseclen = 0;
2779 : 0 : uint64_t ddesc_template = 0;
2780 : : uint64_t ddesc_cmd = 0;
2781 : :
2782 : 0 : mb = tx_pkts[idx];
2783 : :
2784 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
2785 : :
2786 : : /**
2787 : : * Get metadata for ipsec crypto from mbuf dynamic fields if
2788 : : * security offload is specified.
2789 : : */
2790 : : ipsec_md = iavf_ipsec_crypto_get_pkt_metadata(txq, mb);
2791 : :
2792 : 0 : nb_desc_data = mb->nb_segs;
2793 : : nb_desc_ctx =
2794 [ # # ]: 0 : iavf_calc_context_desc(mb, txq->vlan_flag);
2795 : 0 : nb_desc_ipsec = !!(mb->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
2796 : :
2797 : : /**
2798 : : * The number of descriptors that must be allocated for
2799 : : * a packet equals to the number of the segments of that
2800 : : * packet plus the context and ipsec descriptors if needed.
2801 : : * Recalculate the needed tx descs when TSO enabled in case
2802 : : * the mbuf data size exceeds max data size that hw allows
2803 : : * per tx desc.
2804 : : */
2805 [ # # ]: 0 : if (mb->ol_flags & RTE_MBUF_F_TX_TCP_SEG)
2806 : 0 : nb_desc_required = iavf_calc_pkt_desc(mb) + nb_desc_ctx + nb_desc_ipsec;
2807 : : else
2808 : 0 : nb_desc_required = nb_desc_data + nb_desc_ctx + nb_desc_ipsec;
2809 : :
2810 : 0 : desc_idx_last = (uint16_t)(desc_idx + nb_desc_required - 1);
2811 : :
2812 : : /* wrap descriptor ring */
2813 [ # # ]: 0 : if (desc_idx_last >= txq->nb_tx_desc)
2814 : 0 : desc_idx_last =
2815 : : (uint16_t)(desc_idx_last - txq->nb_tx_desc);
2816 : :
2817 : : PMD_TX_LOG(DEBUG,
2818 : : "port_id=%u queue_id=%u tx_first=%u tx_last=%u",
2819 : : txq->port_id, txq->queue_id, desc_idx, desc_idx_last);
2820 : :
2821 [ # # ]: 0 : if (nb_desc_required > txq->nb_tx_free) {
2822 [ # # ]: 0 : if (iavf_xmit_cleanup(txq)) {
2823 [ # # ]: 0 : if (idx == 0)
2824 : 0 : return 0;
2825 : 0 : goto end_of_tx;
2826 : : }
2827 [ # # ]: 0 : if (unlikely(nb_desc_required > txq->tx_rs_thresh)) {
2828 [ # # ]: 0 : while (nb_desc_required > txq->nb_tx_free) {
2829 [ # # ]: 0 : if (iavf_xmit_cleanup(txq)) {
2830 [ # # ]: 0 : if (idx == 0)
2831 : : return 0;
2832 : 0 : goto end_of_tx;
2833 : : }
2834 : : }
2835 : : }
2836 : : }
2837 : :
2838 : 0 : iavf_build_data_desc_cmd_offset_fields(&ddesc_template, mb,
2839 : : txq->vlan_flag);
2840 : :
2841 : : /* Setup TX context descriptor if required */
2842 [ # # ]: 0 : if (nb_desc_ctx) {
2843 : 0 : volatile struct iavf_tx_context_desc *ctx_desc =
2844 : : (volatile struct iavf_tx_context_desc *)
2845 : 0 : &txr[desc_idx];
2846 : :
2847 : : /* clear QW0 or the previous writeback value
2848 : : * may impact next write
2849 : : */
2850 : 0 : *(volatile uint64_t *)ctx_desc = 0;
2851 : :
2852 : 0 : txn = &txe_ring[txe->next_id];
2853 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
2854 : :
2855 [ # # ]: 0 : if (txe->mbuf) {
2856 : : rte_pktmbuf_free_seg(txe->mbuf);
2857 : 0 : txe->mbuf = NULL;
2858 : : }
2859 : :
2860 : 0 : iavf_fill_context_desc(ctx_desc, mb, ipsec_md, &tlen,
2861 : 0 : txq->vlan_flag);
2862 : : IAVF_DUMP_TX_DESC(txq, ctx_desc, desc_idx);
2863 : :
2864 : 0 : txe->last_id = desc_idx_last;
2865 : 0 : desc_idx = txe->next_id;
2866 : : txe = txn;
2867 : : }
2868 : :
2869 [ # # ]: 0 : if (nb_desc_ipsec) {
2870 : 0 : volatile struct iavf_tx_ipsec_desc *ipsec_desc =
2871 : : (volatile struct iavf_tx_ipsec_desc *)
2872 : 0 : &txr[desc_idx];
2873 : :
2874 : 0 : txn = &txe_ring[txe->next_id];
2875 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
2876 : :
2877 [ # # ]: 0 : if (txe->mbuf) {
2878 : : rte_pktmbuf_free_seg(txe->mbuf);
2879 : 0 : txe->mbuf = NULL;
2880 : : }
2881 : :
2882 : 0 : iavf_fill_ipsec_desc(ipsec_desc, ipsec_md, &ipseclen);
2883 : :
2884 : : IAVF_DUMP_TX_DESC(txq, ipsec_desc, desc_idx);
2885 : :
2886 : 0 : txe->last_id = desc_idx_last;
2887 : 0 : desc_idx = txe->next_id;
2888 : : txe = txn;
2889 : : }
2890 : :
2891 : : mb_seg = mb;
2892 : :
2893 : : do {
2894 : 0 : ddesc = (volatile struct iavf_tx_desc *)
2895 : 0 : &txr[desc_idx];
2896 : :
2897 : 0 : txn = &txe_ring[txe->next_id];
2898 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
2899 : :
2900 [ # # ]: 0 : if (txe->mbuf)
2901 : : rte_pktmbuf_free_seg(txe->mbuf);
2902 : :
2903 : 0 : txe->mbuf = mb_seg;
2904 : :
2905 [ # # ]: 0 : if ((mb_seg->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) &&
2906 [ # # ]: 0 : (mb_seg->ol_flags &
2907 : : (RTE_MBUF_F_TX_TCP_SEG |
2908 : : RTE_MBUF_F_TX_UDP_SEG))) {
2909 : 0 : slen = tlen + mb_seg->l2_len + mb_seg->l3_len +
2910 : 0 : mb_seg->outer_l3_len + ipseclen;
2911 [ # # ]: 0 : if (mb_seg->ol_flags & RTE_MBUF_F_TX_L4_MASK)
2912 : 0 : slen += mb_seg->l4_len;
2913 : : } else {
2914 : 0 : slen = mb_seg->data_len;
2915 : : }
2916 : :
2917 : : buf_dma_addr = rte_mbuf_data_iova(mb_seg);
2918 : 0 : while ((mb_seg->ol_flags & (RTE_MBUF_F_TX_TCP_SEG |
2919 [ # # ]: 0 : RTE_MBUF_F_TX_UDP_SEG)) &&
2920 [ # # ]: 0 : unlikely(slen > IAVF_MAX_DATA_PER_TXD)) {
2921 : 0 : iavf_fill_data_desc(ddesc, ddesc_template,
2922 : : IAVF_MAX_DATA_PER_TXD, buf_dma_addr);
2923 : :
2924 : : IAVF_DUMP_TX_DESC(txq, ddesc, desc_idx);
2925 : :
2926 : 0 : buf_dma_addr += IAVF_MAX_DATA_PER_TXD;
2927 : 0 : slen -= IAVF_MAX_DATA_PER_TXD;
2928 : :
2929 : 0 : txe->last_id = desc_idx_last;
2930 : 0 : desc_idx = txe->next_id;
2931 : : txe = txn;
2932 : 0 : ddesc = &txr[desc_idx];
2933 : 0 : txn = &txe_ring[txe->next_id];
2934 : : }
2935 : :
2936 : 0 : iavf_fill_data_desc(ddesc, ddesc_template,
2937 : : slen, buf_dma_addr);
2938 : :
2939 : : IAVF_DUMP_TX_DESC(txq, ddesc, desc_idx);
2940 : :
2941 : 0 : txe->last_id = desc_idx_last;
2942 : 0 : desc_idx = txe->next_id;
2943 : : txe = txn;
2944 : 0 : mb_seg = mb_seg->next;
2945 [ # # ]: 0 : } while (mb_seg);
2946 : :
2947 : : /* The last packet data descriptor needs End Of Packet (EOP) */
2948 : : ddesc_cmd = IAVF_TX_DESC_CMD_EOP;
2949 : :
2950 : 0 : txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_desc_required);
2951 : 0 : txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_desc_required);
2952 : :
2953 [ # # ]: 0 : if (txq->nb_tx_used >= txq->tx_rs_thresh) {
2954 : : PMD_TX_LOG(DEBUG, "Setting RS bit on TXD id="
2955 : : "%4u (port=%d queue=%d)",
2956 : : desc_idx_last, txq->port_id, txq->queue_id);
2957 : :
2958 : : ddesc_cmd |= IAVF_TX_DESC_CMD_RS;
2959 : :
2960 : : /* Update txq RS bit counters */
2961 : 0 : txq->nb_tx_used = 0;
2962 : : }
2963 : :
2964 : 0 : ddesc->cmd_type_offset_bsz |= rte_cpu_to_le_64(ddesc_cmd <<
2965 : : IAVF_TXD_DATA_QW1_CMD_SHIFT);
2966 : :
2967 : : IAVF_DUMP_TX_DESC(txq, ddesc, desc_idx - 1);
2968 : : }
2969 : :
2970 : 0 : end_of_tx:
2971 : : rte_wmb();
2972 : :
2973 : : PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
2974 : : txq->port_id, txq->queue_id, desc_idx, idx);
2975 : :
2976 : 0 : IAVF_PCI_REG_WRITE_RELAXED(txq->qtx_tail, desc_idx);
2977 : 0 : txq->tx_tail = desc_idx;
2978 : :
2979 : 0 : return idx;
2980 : : }
2981 : :
2982 : : /* Check if the packet with vlan user priority is transmitted in the
2983 : : * correct queue.
2984 : : */
2985 : : static int
2986 : : iavf_check_vlan_up2tc(struct ci_tx_queue *txq, struct rte_mbuf *m)
2987 : : {
2988 : : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
2989 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2990 : : uint16_t up;
2991 : :
2992 : 0 : up = m->vlan_tci >> IAVF_VLAN_TAG_PCP_OFFSET;
2993 : :
2994 [ # # ]: 0 : if (!(vf->qos_cap->cap[txq->tc].tc_prio & BIT(up))) {
2995 : : PMD_TX_LOG(ERR, "packet with vlan pcp %u cannot transmit in queue %u",
2996 : : up, txq->queue_id);
2997 : : return -1;
2998 : : } else {
2999 : : return 0;
3000 : : }
3001 : : }
3002 : :
3003 : : /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
3004 : : static inline void
3005 : : parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
3006 : : {
3007 : : struct rte_tcp_hdr *tcp_hdr;
3008 : :
3009 : : info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
3010 : : info->l4_proto = ipv4_hdr->next_proto_id;
3011 : :
3012 : : /* only fill l4_len for TCP, it's useful for TSO */
3013 : : if (info->l4_proto == IPPROTO_TCP) {
3014 : : tcp_hdr = (struct rte_tcp_hdr *)
3015 : : ((char *)ipv4_hdr + info->l3_len);
3016 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
3017 : : } else if (info->l4_proto == IPPROTO_UDP) {
3018 : : info->l4_len = sizeof(struct rte_udp_hdr);
3019 : : } else {
3020 : : info->l4_len = 0;
3021 : : }
3022 : : }
3023 : :
3024 : : /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
3025 : : static inline void
3026 : : parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
3027 : : {
3028 : : struct rte_tcp_hdr *tcp_hdr;
3029 : :
3030 : : info->l3_len = sizeof(struct rte_ipv6_hdr);
3031 : : info->l4_proto = ipv6_hdr->proto;
3032 : :
3033 : : /* only fill l4_len for TCP, it's useful for TSO */
3034 : : if (info->l4_proto == IPPROTO_TCP) {
3035 : : tcp_hdr = (struct rte_tcp_hdr *)
3036 : : ((char *)ipv6_hdr + info->l3_len);
3037 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
3038 : : } else if (info->l4_proto == IPPROTO_UDP) {
3039 : : info->l4_len = sizeof(struct rte_udp_hdr);
3040 : : } else {
3041 : : info->l4_len = 0;
3042 : : }
3043 : : }
3044 : :
3045 : : /*
3046 : : * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
3047 : : * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
3048 : : * headers. The l4_len argument is only set in case of TCP (useful for TSO).
3049 : : */
3050 : : static inline void
3051 : : parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
3052 : : {
3053 : : struct rte_ipv4_hdr *ipv4_hdr;
3054 : : struct rte_ipv6_hdr *ipv6_hdr;
3055 : : struct rte_vlan_hdr *vlan_hdr;
3056 : :
3057 : : info->l2_len = sizeof(struct rte_ether_hdr);
3058 : : info->ethertype = eth_hdr->ether_type;
3059 : :
3060 : : while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
3061 : : info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
3062 : : vlan_hdr = (struct rte_vlan_hdr *)
3063 : : ((char *)eth_hdr + info->l2_len);
3064 : : info->l2_len += sizeof(struct rte_vlan_hdr);
3065 : : info->ethertype = vlan_hdr->eth_proto;
3066 : : }
3067 : :
3068 : : switch (info->ethertype) {
3069 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV4):
3070 : : ipv4_hdr = (struct rte_ipv4_hdr *)
3071 : : ((char *)eth_hdr + info->l2_len);
3072 : : parse_ipv4(ipv4_hdr, info);
3073 : : break;
3074 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV6):
3075 : : ipv6_hdr = (struct rte_ipv6_hdr *)
3076 : : ((char *)eth_hdr + info->l2_len);
3077 : : parse_ipv6(ipv6_hdr, info);
3078 : : break;
3079 : : default:
3080 : : info->l4_len = 0;
3081 : : info->l3_len = 0;
3082 : : info->l4_proto = 0;
3083 : : break;
3084 : : }
3085 : : }
3086 : :
3087 : : /* Fill in outer layers length */
3088 : : static inline void
3089 : : update_tunnel_outer(struct offload_info *info)
3090 : : {
3091 : : info->is_tunnel = 1;
3092 : : info->outer_ethertype = info->ethertype;
3093 : : info->outer_l2_len = info->l2_len;
3094 : : info->outer_l3_len = info->l3_len;
3095 : : info->outer_l4_proto = info->l4_proto;
3096 : : }
3097 : :
3098 : : /*
3099 : : * Parse a GTP protocol header.
3100 : : * No optional fields and next extension header type.
3101 : : */
3102 : : static inline void
3103 : : parse_gtp(struct rte_udp_hdr *udp_hdr,
3104 : : struct offload_info *info)
3105 : : {
3106 : : struct rte_ipv4_hdr *ipv4_hdr;
3107 : : struct rte_ipv6_hdr *ipv6_hdr;
3108 : : struct rte_gtp_hdr *gtp_hdr;
3109 : : uint8_t gtp_len = sizeof(*gtp_hdr);
3110 : : uint8_t ip_ver;
3111 : :
3112 : : /* Check UDP destination port. */
3113 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
3114 : : udp_hdr->src_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
3115 : : udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPU_UDP_PORT))
3116 : : return;
3117 : :
3118 : : update_tunnel_outer(info);
3119 : : info->l2_len = 0;
3120 : :
3121 : : gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr +
3122 : : sizeof(struct rte_udp_hdr));
3123 : :
3124 : : /*
3125 : : * Check message type. If message type is 0xff, it is
3126 : : * a GTP data packet. If not, it is a GTP control packet
3127 : : */
3128 : : if (gtp_hdr->msg_type == 0xff) {
3129 : : ip_ver = *(uint8_t *)((char *)udp_hdr +
3130 : : sizeof(struct rte_udp_hdr) +
3131 : : sizeof(struct rte_gtp_hdr));
3132 : : ip_ver = (ip_ver) & 0xf0;
3133 : :
3134 : : if (ip_ver == RTE_GTP_TYPE_IPV4) {
3135 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gtp_hdr +
3136 : : gtp_len);
3137 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
3138 : : parse_ipv4(ipv4_hdr, info);
3139 : : } else if (ip_ver == RTE_GTP_TYPE_IPV6) {
3140 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gtp_hdr +
3141 : : gtp_len);
3142 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
3143 : : parse_ipv6(ipv6_hdr, info);
3144 : : }
3145 : : } else {
3146 : : info->ethertype = 0;
3147 : : info->l4_len = 0;
3148 : : info->l3_len = 0;
3149 : : info->l4_proto = 0;
3150 : : }
3151 : :
3152 : : info->l2_len += RTE_ETHER_GTP_HLEN;
3153 : : }
3154 : :
3155 : : /* Parse a VXLAN header */
3156 : : static inline void
3157 : : parse_vxlan(struct rte_udp_hdr *udp_hdr,
3158 : : struct offload_info *info)
3159 : : {
3160 : : struct rte_ether_hdr *eth_hdr;
3161 : :
3162 : : /* check UDP destination port, RTE_VXLAN_DEFAULT_PORT (4789) is the
3163 : : * default VXLAN port (rfc7348) or that the Rx offload flag is set
3164 : : * (i40e only currently)
3165 : : */
3166 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT))
3167 : : return;
3168 : :
3169 : : update_tunnel_outer(info);
3170 : :
3171 : : eth_hdr = (struct rte_ether_hdr *)((char *)udp_hdr +
3172 : : sizeof(struct rte_udp_hdr) +
3173 : : sizeof(struct rte_vxlan_hdr));
3174 : :
3175 : : parse_ethernet(eth_hdr, info);
3176 : : info->l2_len += RTE_ETHER_VXLAN_HLEN; /* add UDP + VXLAN */
3177 : : }
3178 : :
3179 : : /* Parse a VXLAN-GPE header */
3180 : : static inline void
3181 : : parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr,
3182 : : struct offload_info *info)
3183 : : {
3184 : : struct rte_ether_hdr *eth_hdr;
3185 : : struct rte_ipv4_hdr *ipv4_hdr;
3186 : : struct rte_ipv6_hdr *ipv6_hdr;
3187 : : struct rte_vxlan_gpe_hdr *vxlan_gpe_hdr;
3188 : : uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
3189 : :
3190 : : /* Check UDP destination port. */
3191 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(vxlan_gpe_udp_port))
3192 : : return;
3193 : :
3194 : : vxlan_gpe_hdr = (struct rte_vxlan_gpe_hdr *)((char *)udp_hdr +
3195 : : sizeof(struct rte_udp_hdr));
3196 : :
3197 : : if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
3198 : : RTE_VXLAN_GPE_TYPE_IPV4) {
3199 : : update_tunnel_outer(info);
3200 : :
3201 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)vxlan_gpe_hdr +
3202 : : vxlan_gpe_len);
3203 : :
3204 : : parse_ipv4(ipv4_hdr, info);
3205 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
3206 : : info->l2_len = 0;
3207 : :
3208 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV6) {
3209 : : update_tunnel_outer(info);
3210 : :
3211 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)vxlan_gpe_hdr +
3212 : : vxlan_gpe_len);
3213 : :
3214 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
3215 : : parse_ipv6(ipv6_hdr, info);
3216 : : info->l2_len = 0;
3217 : :
3218 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_ETH) {
3219 : : update_tunnel_outer(info);
3220 : :
3221 : : eth_hdr = (struct rte_ether_hdr *)((char *)vxlan_gpe_hdr +
3222 : : vxlan_gpe_len);
3223 : :
3224 : : parse_ethernet(eth_hdr, info);
3225 : : } else {
3226 : : return;
3227 : : }
3228 : :
3229 : : info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN;
3230 : : }
3231 : :
3232 : : /* Parse a GENEVE header */
3233 : : static inline void
3234 : : parse_geneve(struct rte_udp_hdr *udp_hdr,
3235 : : struct offload_info *info)
3236 : : {
3237 : : struct rte_ether_hdr *eth_hdr;
3238 : : struct rte_ipv4_hdr *ipv4_hdr;
3239 : : struct rte_ipv6_hdr *ipv6_hdr;
3240 : : struct rte_geneve_hdr *geneve_hdr;
3241 : : uint16_t geneve_len;
3242 : :
3243 : : /* Check UDP destination port. */
3244 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(geneve_udp_port))
3245 : : return;
3246 : :
3247 : : geneve_hdr = (struct rte_geneve_hdr *)((char *)udp_hdr +
3248 : : sizeof(struct rte_udp_hdr));
3249 : : geneve_len = sizeof(struct rte_geneve_hdr) + geneve_hdr->opt_len * 4;
3250 : : if (!geneve_hdr->proto || geneve_hdr->proto ==
3251 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3252 : : update_tunnel_outer(info);
3253 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)geneve_hdr +
3254 : : geneve_len);
3255 : : parse_ipv4(ipv4_hdr, info);
3256 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
3257 : : info->l2_len = 0;
3258 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3259 : : update_tunnel_outer(info);
3260 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)geneve_hdr +
3261 : : geneve_len);
3262 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
3263 : : parse_ipv6(ipv6_hdr, info);
3264 : : info->l2_len = 0;
3265 : :
3266 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_GENEVE_TYPE_ETH)) {
3267 : : update_tunnel_outer(info);
3268 : : eth_hdr = (struct rte_ether_hdr *)((char *)geneve_hdr +
3269 : : geneve_len);
3270 : : parse_ethernet(eth_hdr, info);
3271 : : } else {
3272 : : return;
3273 : : }
3274 : :
3275 : : info->l2_len +=
3276 : : (sizeof(struct rte_udp_hdr) + sizeof(struct rte_geneve_hdr) +
3277 : : ((struct rte_geneve_hdr *)geneve_hdr)->opt_len * 4);
3278 : : }
3279 : :
3280 : : /* Parse a GRE header */
3281 : : static inline void
3282 : : parse_gre(struct simple_gre_hdr *gre_hdr, struct offload_info *info)
3283 : : {
3284 : : struct rte_ether_hdr *eth_hdr;
3285 : : struct rte_ipv4_hdr *ipv4_hdr;
3286 : : struct rte_ipv6_hdr *ipv6_hdr;
3287 : : uint8_t gre_len = 0;
3288 : :
3289 : : gre_len += sizeof(struct simple_gre_hdr);
3290 : :
3291 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_KEY_PRESENT))
3292 : : gre_len += GRE_EXT_LEN;
3293 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_SEQUENCE_PRESENT))
3294 : : gre_len += GRE_EXT_LEN;
3295 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_CHECKSUM_PRESENT))
3296 : : gre_len += GRE_EXT_LEN;
3297 : :
3298 : : if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3299 : : update_tunnel_outer(info);
3300 : :
3301 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gre_hdr + gre_len);
3302 : :
3303 : : parse_ipv4(ipv4_hdr, info);
3304 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
3305 : : info->l2_len = 0;
3306 : :
3307 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3308 : : update_tunnel_outer(info);
3309 : :
3310 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gre_hdr + gre_len);
3311 : :
3312 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
3313 : : parse_ipv6(ipv6_hdr, info);
3314 : : info->l2_len = 0;
3315 : :
3316 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_TEB)) {
3317 : : update_tunnel_outer(info);
3318 : :
3319 : : eth_hdr = (struct rte_ether_hdr *)((char *)gre_hdr + gre_len);
3320 : :
3321 : : parse_ethernet(eth_hdr, info);
3322 : : } else {
3323 : : return;
3324 : : }
3325 : :
3326 : : info->l2_len += gre_len;
3327 : : }
3328 : :
3329 : : /* Parse an encapsulated IP or IPv6 header */
3330 : : static inline void
3331 : : parse_encap_ip(void *encap_ip, struct offload_info *info)
3332 : : {
3333 : : struct rte_ipv4_hdr *ipv4_hdr = encap_ip;
3334 : : struct rte_ipv6_hdr *ipv6_hdr = encap_ip;
3335 : : uint8_t ip_version;
3336 : :
3337 : : ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4;
3338 : :
3339 : : if (ip_version != 4 && ip_version != 6)
3340 : : return;
3341 : :
3342 : : info->is_tunnel = 1;
3343 : : info->outer_ethertype = info->ethertype;
3344 : : info->outer_l2_len = info->l2_len;
3345 : : info->outer_l3_len = info->l3_len;
3346 : :
3347 : : if (ip_version == 4) {
3348 : : parse_ipv4(ipv4_hdr, info);
3349 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
3350 : : } else {
3351 : : parse_ipv6(ipv6_hdr, info);
3352 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
3353 : : }
3354 : : info->l2_len = 0;
3355 : : }
3356 : :
3357 : : static inline int
3358 : : check_mbuf_len(struct offload_info *info, struct rte_mbuf *m)
3359 : : {
3360 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3361 : : if (info->outer_l2_len != m->outer_l2_len) {
3362 : : PMD_TX_LOG(ERR, "outer_l2_len error in mbuf. Original "
3363 : : "length: %hu, calculated length: %u", m->outer_l2_len,
3364 : : info->outer_l2_len);
3365 : : return -1;
3366 : : }
3367 : : if (info->outer_l3_len != m->outer_l3_len) {
3368 : : PMD_TX_LOG(ERR, "outer_l3_len error in mbuf. Original "
3369 : : "length: %hu,calculated length: %u", m->outer_l3_len,
3370 : : info->outer_l3_len);
3371 : : return -1;
3372 : : }
3373 : : }
3374 : :
3375 : : if (info->l2_len != m->l2_len) {
3376 : : PMD_TX_LOG(ERR, "l2_len error in mbuf. Original "
3377 : : "length: %hu, calculated length: %u", m->l2_len,
3378 : : info->l2_len);
3379 : : return -1;
3380 : : }
3381 : : if (info->l3_len != m->l3_len) {
3382 : : PMD_TX_LOG(ERR, "l3_len error in mbuf. Original "
3383 : : "length: %hu, calculated length: %u", m->l3_len,
3384 : : info->l3_len);
3385 : : return -1;
3386 : : }
3387 : : if (info->l4_len != m->l4_len) {
3388 : : PMD_TX_LOG(ERR, "l4_len error in mbuf. Original "
3389 : : "length: %hu, calculated length: %u", m->l4_len,
3390 : : info->l4_len);
3391 : : return -1;
3392 : : }
3393 : :
3394 : : return 0;
3395 : : }
3396 : :
3397 : : static inline int
3398 : : check_ether_type(struct offload_info *info, struct rte_mbuf *m)
3399 : : {
3400 : : int ret = 0;
3401 : :
3402 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3403 : : if (info->outer_ethertype ==
3404 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3405 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)) {
3406 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, "
3407 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV4` flag.");
3408 : : ret = -1;
3409 : : }
3410 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6) {
3411 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, tx "
3412 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV6` flag");
3413 : : ret = -1;
3414 : : }
3415 : : } else if (info->outer_ethertype ==
3416 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3417 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)) {
3418 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, "
3419 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV6` flag.");
3420 : : ret = -1;
3421 : : }
3422 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) {
3423 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, tx "
3424 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV4` flag");
3425 : : ret = -1;
3426 : : }
3427 : : }
3428 : : }
3429 : :
3430 : : if (info->ethertype ==
3431 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3432 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV4)) {
3433 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx offload "
3434 : : "missing `RTE_MBUF_F_TX_IPV4` flag.");
3435 : : ret = -1;
3436 : : }
3437 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV6) {
3438 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx "
3439 : : "offload contains wrong `RTE_MBUF_F_TX_IPV6` flag");
3440 : : ret = -1;
3441 : : }
3442 : : } else if (info->ethertype ==
3443 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3444 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV6)) {
3445 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3446 : : "missing `RTE_MBUF_F_TX_IPV6` flag.");
3447 : : ret = -1;
3448 : : }
3449 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
3450 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3451 : : "contains wrong `RTE_MBUF_F_TX_IPV4` flag");
3452 : : ret = -1;
3453 : : }
3454 : : }
3455 : :
3456 : : return ret;
3457 : : }
3458 : :
3459 : : /* Check whether the parameters of mbuf are correct. */
3460 : : __rte_unused static inline int
3461 : : iavf_check_mbuf(struct rte_mbuf *m)
3462 : : {
3463 : : struct rte_ether_hdr *eth_hdr;
3464 : : void *l3_hdr = NULL; /* can be IPv4 or IPv6 */
3465 : : struct offload_info info = {0};
3466 : : uint64_t ol_flags = m->ol_flags;
3467 : : uint64_t tunnel_type = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK;
3468 : :
3469 : : eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
3470 : : parse_ethernet(eth_hdr, &info);
3471 : : l3_hdr = (char *)eth_hdr + info.l2_len;
3472 : : if (info.l4_proto == IPPROTO_UDP) {
3473 : : struct rte_udp_hdr *udp_hdr;
3474 : :
3475 : : udp_hdr = (struct rte_udp_hdr *)
3476 : : ((char *)l3_hdr + info.l3_len);
3477 : : parse_gtp(udp_hdr, &info);
3478 : : if (info.is_tunnel) {
3479 : : if (!tunnel_type) {
3480 : : PMD_TX_LOG(ERR, "gtp tunnel packet missing tx "
3481 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GTP` flag.");
3482 : : return -1;
3483 : : }
3484 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GTP) {
3485 : : PMD_TX_LOG(ERR, "gtp tunnel packet, tx offload has wrong "
3486 : : "`%s` flag, correct is `RTE_MBUF_F_TX_TUNNEL_GTP` flag",
3487 : : rte_get_tx_ol_flag_name(tunnel_type));
3488 : : return -1;
3489 : : }
3490 : : goto check_len;
3491 : : }
3492 : : parse_vxlan_gpe(udp_hdr, &info);
3493 : : if (info.is_tunnel) {
3494 : : if (!tunnel_type) {
3495 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet missing tx "
3496 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag.");
3497 : : return -1;
3498 : : }
3499 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE) {
3500 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet, tx offload has "
3501 : : "wrong `%s` flag, correct is "
3502 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag",
3503 : : rte_get_tx_ol_flag_name(tunnel_type));
3504 : : return -1;
3505 : : }
3506 : : goto check_len;
3507 : : }
3508 : : parse_vxlan(udp_hdr, &info);
3509 : : if (info.is_tunnel) {
3510 : : if (!tunnel_type) {
3511 : : PMD_TX_LOG(ERR, "vxlan tunnel packet missing tx "
3512 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN` flag.");
3513 : : return -1;
3514 : : }
3515 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN) {
3516 : : PMD_TX_LOG(ERR, "vxlan tunnel packet, tx offload has "
3517 : : "wrong `%s` flag, correct is "
3518 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN` flag",
3519 : : rte_get_tx_ol_flag_name(tunnel_type));
3520 : : return -1;
3521 : : }
3522 : : goto check_len;
3523 : : }
3524 : : parse_geneve(udp_hdr, &info);
3525 : : if (info.is_tunnel) {
3526 : : if (!tunnel_type) {
3527 : : PMD_TX_LOG(ERR, "geneve tunnel packet missing tx "
3528 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GENEVE` flag.");
3529 : : return -1;
3530 : : }
3531 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GENEVE) {
3532 : : PMD_TX_LOG(ERR, "geneve tunnel packet, tx offload has "
3533 : : "wrong `%s` flag, correct is "
3534 : : "`RTE_MBUF_F_TX_TUNNEL_GENEVE` flag",
3535 : : rte_get_tx_ol_flag_name(tunnel_type));
3536 : : return -1;
3537 : : }
3538 : : goto check_len;
3539 : : }
3540 : : /* Always keep last. */
3541 : : if (unlikely(RTE_ETH_IS_TUNNEL_PKT(m->packet_type)
3542 : : != 0)) {
3543 : : PMD_TX_LOG(ERR, "Unknown tunnel packet. UDP dst port: %hu",
3544 : : udp_hdr->dst_port);
3545 : : return -1;
3546 : : }
3547 : : } else if (info.l4_proto == IPPROTO_GRE) {
3548 : : struct simple_gre_hdr *gre_hdr;
3549 : :
3550 : : gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr +
3551 : : info.l3_len);
3552 : : parse_gre(gre_hdr, &info);
3553 : : if (info.is_tunnel) {
3554 : : if (!tunnel_type) {
3555 : : PMD_TX_LOG(ERR, "gre tunnel packet missing tx "
3556 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GRE` flag.");
3557 : : return -1;
3558 : : }
3559 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GRE) {
3560 : : PMD_TX_LOG(ERR, "gre tunnel packet, tx offload has "
3561 : : "wrong `%s` flag, correct is "
3562 : : "`RTE_MBUF_F_TX_TUNNEL_GRE` flag",
3563 : : rte_get_tx_ol_flag_name(tunnel_type));
3564 : : return -1;
3565 : : }
3566 : : goto check_len;
3567 : : }
3568 : : } else if (info.l4_proto == IPPROTO_IPIP) {
3569 : : void *encap_ip_hdr;
3570 : :
3571 : : encap_ip_hdr = (char *)l3_hdr + info.l3_len;
3572 : : parse_encap_ip(encap_ip_hdr, &info);
3573 : : if (info.is_tunnel) {
3574 : : if (!tunnel_type) {
3575 : : PMD_TX_LOG(ERR, "Ipip tunnel packet missing tx "
3576 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_IPIP` flag.");
3577 : : return -1;
3578 : : }
3579 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_IPIP) {
3580 : : PMD_TX_LOG(ERR, "Ipip tunnel packet, tx offload has "
3581 : : "wrong `%s` flag, correct is "
3582 : : "`RTE_MBUF_F_TX_TUNNEL_IPIP` flag",
3583 : : rte_get_tx_ol_flag_name(tunnel_type));
3584 : : return -1;
3585 : : }
3586 : : goto check_len;
3587 : : }
3588 : : }
3589 : :
3590 : : check_len:
3591 : : if (check_mbuf_len(&info, m) != 0)
3592 : : return -1;
3593 : :
3594 : : return check_ether_type(&info, m);
3595 : : }
3596 : :
3597 : : /* TX prep functions */
3598 : : uint16_t
3599 : 0 : iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
3600 : : uint16_t nb_pkts)
3601 : : {
3602 : : int i, ret;
3603 : : uint64_t ol_flags;
3604 : : struct rte_mbuf *m;
3605 : : struct ci_tx_queue *txq = tx_queue;
3606 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
3607 : 0 : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3608 : : struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3609 : :
3610 [ # # ]: 0 : if (adapter->closed)
3611 : : return 0;
3612 : :
3613 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3614 : 0 : m = tx_pkts[i];
3615 : 0 : ol_flags = m->ol_flags;
3616 : :
3617 : : /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. */
3618 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3619 [ # # ]: 0 : if (m->nb_segs > IAVF_TX_MAX_MTU_SEG) {
3620 : 0 : rte_errno = EINVAL;
3621 : 0 : return i;
3622 : : }
3623 [ # # ]: 0 : } else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
3624 : 0 : (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
3625 [ # # ]: 0 : (m->nb_segs > txq->nb_tx_desc)) {
3626 : : /* MSS outside the range are considered malicious */
3627 : 0 : rte_errno = EINVAL;
3628 : 0 : return i;
3629 : : }
3630 : :
3631 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3632 : 0 : rte_errno = ENOTSUP;
3633 : 0 : return i;
3634 : : }
3635 : :
3636 : : /* valid packets are greater than min size, and single-buffer pkts
3637 : : * must have data_len == pkt_len
3638 : : */
3639 [ # # ]: 0 : if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
3640 [ # # # # ]: 0 : (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
3641 : 0 : rte_errno = EINVAL;
3642 : 0 : return i;
3643 : : }
3644 : :
3645 : : #ifdef RTE_ETHDEV_DEBUG_TX
3646 : : ret = rte_validate_tx_offload(m);
3647 : : if (ret != 0) {
3648 : : rte_errno = -ret;
3649 : : return i;
3650 : : }
3651 : : #endif
3652 : : ret = rte_net_intel_cksum_prepare(m);
3653 [ # # ]: 0 : if (ret != 0) {
3654 : 0 : rte_errno = -ret;
3655 : 0 : return i;
3656 : : }
3657 : :
3658 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
3659 [ # # ]: 0 : ol_flags & (RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN)) {
3660 : : ret = iavf_check_vlan_up2tc(txq, m);
3661 : : if (ret != 0) {
3662 : 0 : rte_errno = -ret;
3663 : 0 : return i;
3664 : : }
3665 : : }
3666 : :
3667 : : #ifdef RTE_ETHDEV_DEBUG_TX
3668 : : ret = iavf_check_mbuf(m);
3669 : : if (ret != 0) {
3670 : : rte_errno = EINVAL;
3671 : : return i;
3672 : : }
3673 : : #endif
3674 : : }
3675 : :
3676 : 0 : return i;
3677 : : }
3678 : :
3679 : : static
3680 : : const eth_rx_burst_t iavf_rx_pkt_burst_ops[] = {
3681 : : [IAVF_RX_DEFAULT] = iavf_recv_pkts,
3682 : : [IAVF_RX_FLEX_RXD] = iavf_recv_pkts_flex_rxd,
3683 : : [IAVF_RX_BULK_ALLOC] = iavf_recv_pkts_bulk_alloc,
3684 : : [IAVF_RX_SCATTERED] = iavf_recv_scattered_pkts,
3685 : : [IAVF_RX_SCATTERED_FLEX_RXD] = iavf_recv_scattered_pkts_flex_rxd,
3686 : : #ifdef RTE_ARCH_X86
3687 : : [IAVF_RX_SSE] = iavf_recv_pkts_vec,
3688 : : [IAVF_RX_AVX2] = iavf_recv_pkts_vec_avx2,
3689 : : [IAVF_RX_AVX2_OFFLOAD] = iavf_recv_pkts_vec_avx2_offload,
3690 : : [IAVF_RX_SSE_FLEX_RXD] = iavf_recv_pkts_vec_flex_rxd,
3691 : : [IAVF_RX_AVX2_FLEX_RXD] = iavf_recv_pkts_vec_avx2_flex_rxd,
3692 : : [IAVF_RX_AVX2_FLEX_RXD_OFFLOAD] =
3693 : : iavf_recv_pkts_vec_avx2_flex_rxd_offload,
3694 : : [IAVF_RX_SSE_SCATTERED] = iavf_recv_scattered_pkts_vec,
3695 : : [IAVF_RX_AVX2_SCATTERED] = iavf_recv_scattered_pkts_vec_avx2,
3696 : : [IAVF_RX_AVX2_SCATTERED_OFFLOAD] =
3697 : : iavf_recv_scattered_pkts_vec_avx2_offload,
3698 : : [IAVF_RX_SSE_SCATTERED_FLEX_RXD] =
3699 : : iavf_recv_scattered_pkts_vec_flex_rxd,
3700 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD] =
3701 : : iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
3702 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD] =
3703 : : iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
3704 : : #ifdef CC_AVX512_SUPPORT
3705 : : [IAVF_RX_AVX512] = iavf_recv_pkts_vec_avx512,
3706 : : [IAVF_RX_AVX512_OFFLOAD] = iavf_recv_pkts_vec_avx512_offload,
3707 : : [IAVF_RX_AVX512_FLEX_RXD] = iavf_recv_pkts_vec_avx512_flex_rxd,
3708 : : [IAVF_RX_AVX512_FLEX_RXD_OFFLOAD] =
3709 : : iavf_recv_pkts_vec_avx512_flex_rxd_offload,
3710 : : [IAVF_RX_AVX512_SCATTERED] = iavf_recv_scattered_pkts_vec_avx512,
3711 : : [IAVF_RX_AVX512_SCATTERED_OFFLOAD] =
3712 : : iavf_recv_scattered_pkts_vec_avx512_offload,
3713 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD] =
3714 : : iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
3715 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD] =
3716 : : iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
3717 : : #endif
3718 : : #elif defined RTE_ARCH_ARM
3719 : : [IAVF_RX_SSE] = iavf_recv_pkts_vec,
3720 : : #endif
3721 : : };
3722 : :
3723 : : static
3724 : : const eth_tx_burst_t iavf_tx_pkt_burst_ops[] = {
3725 : : [IAVF_TX_DEFAULT] = iavf_xmit_pkts,
3726 : : #ifdef RTE_ARCH_X86
3727 : : [IAVF_TX_SSE] = iavf_xmit_pkts_vec,
3728 : : [IAVF_TX_AVX2] = iavf_xmit_pkts_vec_avx2,
3729 : : [IAVF_TX_AVX2_OFFLOAD] = iavf_xmit_pkts_vec_avx2_offload,
3730 : : #ifdef CC_AVX512_SUPPORT
3731 : : [IAVF_TX_AVX512] = iavf_xmit_pkts_vec_avx512,
3732 : : [IAVF_TX_AVX512_OFFLOAD] = iavf_xmit_pkts_vec_avx512_offload,
3733 : : [IAVF_TX_AVX512_CTX] = iavf_xmit_pkts_vec_avx512_ctx,
3734 : : [IAVF_TX_AVX512_CTX_OFFLOAD] = iavf_xmit_pkts_vec_avx512_ctx_offload,
3735 : : #endif
3736 : : #endif
3737 : : };
3738 : :
3739 : : static uint16_t
3740 : 0 : iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
3741 : : uint16_t nb_pkts)
3742 : : {
3743 : : struct iavf_rx_queue *rxq = rx_queue;
3744 : : enum iavf_rx_burst_type rx_burst_type;
3745 : :
3746 [ # # # # ]: 0 : if (!rxq->vsi || rxq->vsi->adapter->no_poll)
3747 : : return 0;
3748 : :
3749 : 0 : rx_burst_type = rxq->vsi->adapter->rx_burst_type;
3750 : :
3751 : 0 : return iavf_rx_pkt_burst_ops[rx_burst_type](rx_queue,
3752 : : rx_pkts, nb_pkts);
3753 : : }
3754 : :
3755 : : static uint16_t
3756 : 0 : iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
3757 : : uint16_t nb_pkts)
3758 : : {
3759 : : struct ci_tx_queue *txq = tx_queue;
3760 : : enum iavf_tx_burst_type tx_burst_type;
3761 : :
3762 [ # # # # ]: 0 : if (!txq->iavf_vsi || txq->iavf_vsi->adapter->no_poll)
3763 : : return 0;
3764 : :
3765 : 0 : tx_burst_type = txq->iavf_vsi->adapter->tx_burst_type;
3766 : :
3767 : 0 : return iavf_tx_pkt_burst_ops[tx_burst_type](tx_queue,
3768 : : tx_pkts, nb_pkts);
3769 : : }
3770 : :
3771 : : /* Tx mbuf check */
3772 : : static uint16_t
3773 : 0 : iavf_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts,
3774 : : uint16_t nb_pkts)
3775 : : {
3776 : : uint16_t idx;
3777 : : uint64_t ol_flags;
3778 : : struct rte_mbuf *mb;
3779 : : uint16_t good_pkts = nb_pkts;
3780 : 0 : const char *reason = NULL;
3781 : : bool pkt_error = false;
3782 : : struct ci_tx_queue *txq = tx_queue;
3783 : 0 : struct iavf_adapter *adapter = txq->iavf_vsi->adapter;
3784 : 0 : enum iavf_tx_burst_type tx_burst_type =
3785 : : txq->iavf_vsi->adapter->tx_burst_type;
3786 : :
3787 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
3788 : 0 : mb = tx_pkts[idx];
3789 : 0 : ol_flags = mb->ol_flags;
3790 : :
3791 [ # # # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_MBUF) &&
3792 : 0 : (rte_mbuf_check(mb, 1, &reason) != 0)) {
3793 : : PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
3794 : : pkt_error = true;
3795 : : break;
3796 : : }
3797 : :
3798 [ # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SIZE) &&
3799 [ # # ]: 0 : (mb->data_len < IAVF_TX_MIN_PKT_LEN ||
3800 [ # # ]: 0 : mb->data_len > adapter->vf.max_pkt_len)) {
3801 : : PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %u)",
3802 : : mb->data_len, IAVF_TX_MIN_PKT_LEN, adapter->vf.max_pkt_len);
3803 : : pkt_error = true;
3804 : : break;
3805 : : }
3806 : :
3807 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SEGMENT) {
3808 : : /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. */
3809 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3810 [ # # ]: 0 : if (mb->nb_segs > IAVF_TX_MAX_MTU_SEG) {
3811 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
3812 : : mb->nb_segs, IAVF_TX_MAX_MTU_SEG);
3813 : : pkt_error = true;
3814 : : break;
3815 : : }
3816 [ # # ]: 0 : } else if ((mb->tso_segsz < IAVF_MIN_TSO_MSS) ||
3817 : : (mb->tso_segsz > IAVF_MAX_TSO_MSS)) {
3818 : : /* MSS outside the range are considered malicious */
3819 : : PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
3820 : : mb->tso_segsz, IAVF_MIN_TSO_MSS, IAVF_MAX_TSO_MSS);
3821 : : pkt_error = true;
3822 : : break;
3823 [ # # ]: 0 : } else if (mb->nb_segs > txq->nb_tx_desc) {
3824 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
3825 : : pkt_error = true;
3826 : : break;
3827 : : }
3828 : : }
3829 : :
3830 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_OFFLOAD) {
3831 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3832 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
3833 : : pkt_error = true;
3834 : : break;
3835 : : }
3836 : :
3837 [ # # ]: 0 : if (!rte_validate_tx_offload(mb)) {
3838 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
3839 : : pkt_error = true;
3840 : : break;
3841 : : }
3842 : : }
3843 : : }
3844 : :
3845 [ # # ]: 0 : if (pkt_error) {
3846 : 0 : txq->mbuf_errors++;
3847 : : good_pkts = idx;
3848 [ # # ]: 0 : if (good_pkts == 0)
3849 : : return 0;
3850 : : }
3851 : :
3852 : 0 : return iavf_tx_pkt_burst_ops[tx_burst_type](tx_queue, tx_pkts, good_pkts);
3853 : : }
3854 : :
3855 : : /* choose rx function*/
3856 : : void
3857 : 0 : iavf_set_rx_function(struct rte_eth_dev *dev)
3858 : : {
3859 : 0 : struct iavf_adapter *adapter =
3860 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3861 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3862 : : enum iavf_rx_burst_type rx_burst_type;
3863 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
3864 : : int i;
3865 : : struct iavf_rx_queue *rxq;
3866 : : bool use_flex = true;
3867 : :
3868 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3869 : 0 : rxq = dev->data->rx_queues[i];
3870 [ # # ]: 0 : if (rxq->rxdid <= IAVF_RXDID_LEGACY_1) {
3871 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is legacy, "
3872 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3873 : : use_flex = false;
3874 [ # # ]: 0 : } else if (!(vf->supported_rxdid & BIT(rxq->rxdid))) {
3875 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is not supported, "
3876 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3877 : : use_flex = false;
3878 : : }
3879 : : }
3880 : :
3881 : : #ifdef RTE_ARCH_X86
3882 : : int check_ret;
3883 : : bool use_avx2 = false;
3884 : : bool use_avx512 = false;
3885 : :
3886 : 0 : check_ret = iavf_rx_vec_dev_check(dev);
3887 [ # # # # ]: 0 : if (check_ret >= 0 &&
3888 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
3889 [ # # # # ]: 0 : if ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
3890 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
3891 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
3892 : : use_avx2 = true;
3893 : :
3894 : : #ifdef CC_AVX512_SUPPORT
3895 [ # # # # ]: 0 : if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
3896 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1 &&
3897 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
3898 : : use_avx512 = true;
3899 : : #endif
3900 : :
3901 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3902 : 0 : rxq = dev->data->rx_queues[i];
3903 : 0 : (void)iavf_rxq_vec_setup(rxq);
3904 : : }
3905 : :
3906 [ # # ]: 0 : if (dev->data->scattered_rx) {
3907 [ # # ]: 0 : if (!use_avx2 && !use_avx512) {
3908 : 0 : PMD_DRV_LOG(DEBUG,
3909 : : "Using Vector Scattered Rx (port %d).",
3910 : : dev->data->port_id);
3911 : : } else {
3912 [ # # ]: 0 : if (use_avx2) {
3913 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3914 : 0 : PMD_DRV_LOG(DEBUG,
3915 : : "Using AVX2 Vector Scattered Rx (port %d).",
3916 : : dev->data->port_id);
3917 : : else
3918 : 0 : PMD_DRV_LOG(DEBUG,
3919 : : "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).",
3920 : : dev->data->port_id);
3921 : : } else {
3922 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3923 : 0 : PMD_DRV_LOG(DEBUG,
3924 : : "Using AVX512 Vector Scattered Rx (port %d).",
3925 : : dev->data->port_id);
3926 : : else
3927 : 0 : PMD_DRV_LOG(DEBUG,
3928 : : "Using AVX512 OFFLOAD Vector Scattered Rx (port %d).",
3929 : : dev->data->port_id);
3930 : : }
3931 : : }
3932 [ # # ]: 0 : if (use_flex) {
3933 : : rx_burst_type = IAVF_RX_SSE_SCATTERED_FLEX_RXD;
3934 [ # # ]: 0 : if (use_avx2) {
3935 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3936 : : rx_burst_type =
3937 : : IAVF_RX_AVX2_SCATTERED_FLEX_RXD;
3938 : : else
3939 : : rx_burst_type =
3940 : : IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD;
3941 : : }
3942 : : #ifdef CC_AVX512_SUPPORT
3943 [ # # ]: 0 : if (use_avx512) {
3944 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3945 : : rx_burst_type =
3946 : : IAVF_RX_AVX512_SCATTERED_FLEX_RXD;
3947 : : else
3948 : : rx_burst_type =
3949 : : IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD;
3950 : : }
3951 : : #endif
3952 : : } else {
3953 : : rx_burst_type = IAVF_RX_SSE_SCATTERED;
3954 [ # # ]: 0 : if (use_avx2) {
3955 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3956 : : rx_burst_type =
3957 : : IAVF_RX_AVX2_SCATTERED;
3958 : : else
3959 : : rx_burst_type =
3960 : : IAVF_RX_AVX2_SCATTERED_OFFLOAD;
3961 : : }
3962 : : #ifdef CC_AVX512_SUPPORT
3963 [ # # ]: 0 : if (use_avx512) {
3964 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3965 : : rx_burst_type =
3966 : : IAVF_RX_AVX512_SCATTERED;
3967 : : else
3968 : : rx_burst_type =
3969 : : IAVF_RX_AVX512_SCATTERED_OFFLOAD;
3970 : : }
3971 : : #endif
3972 : : }
3973 : : } else {
3974 [ # # ]: 0 : if (!use_avx2 && !use_avx512) {
3975 : 0 : PMD_DRV_LOG(DEBUG, "Using Vector Rx (port %d).",
3976 : : dev->data->port_id);
3977 : : } else {
3978 [ # # ]: 0 : if (use_avx2) {
3979 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3980 : 0 : PMD_DRV_LOG(DEBUG,
3981 : : "Using AVX2 Vector Rx (port %d).",
3982 : : dev->data->port_id);
3983 : : else
3984 : 0 : PMD_DRV_LOG(DEBUG,
3985 : : "Using AVX2 OFFLOAD Vector Rx (port %d).",
3986 : : dev->data->port_id);
3987 : : } else {
3988 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
3989 : 0 : PMD_DRV_LOG(DEBUG,
3990 : : "Using AVX512 Vector Rx (port %d).",
3991 : : dev->data->port_id);
3992 : : else
3993 : 0 : PMD_DRV_LOG(DEBUG,
3994 : : "Using AVX512 OFFLOAD Vector Rx (port %d).",
3995 : : dev->data->port_id);
3996 : : }
3997 : : }
3998 [ # # ]: 0 : if (use_flex) {
3999 : : rx_burst_type = IAVF_RX_SSE_FLEX_RXD;
4000 [ # # ]: 0 : if (use_avx2) {
4001 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
4002 : : rx_burst_type = IAVF_RX_AVX2_FLEX_RXD;
4003 : : else
4004 : : rx_burst_type = IAVF_RX_AVX2_FLEX_RXD_OFFLOAD;
4005 : : }
4006 : : #ifdef CC_AVX512_SUPPORT
4007 [ # # ]: 0 : if (use_avx512) {
4008 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
4009 : : rx_burst_type = IAVF_RX_AVX512_FLEX_RXD;
4010 : : else
4011 : : rx_burst_type =
4012 : : IAVF_RX_AVX512_FLEX_RXD_OFFLOAD;
4013 : : }
4014 : : #endif
4015 : : } else {
4016 : : rx_burst_type = IAVF_RX_SSE;
4017 [ # # ]: 0 : if (use_avx2) {
4018 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
4019 : : rx_burst_type = IAVF_RX_AVX2;
4020 : : else
4021 : : rx_burst_type = IAVF_RX_AVX2_OFFLOAD;
4022 : : }
4023 : : #ifdef CC_AVX512_SUPPORT
4024 [ # # ]: 0 : if (use_avx512) {
4025 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH)
4026 : : rx_burst_type = IAVF_RX_AVX512;
4027 : : else
4028 : : rx_burst_type = IAVF_RX_AVX512_OFFLOAD;
4029 : : }
4030 : : #endif
4031 : : }
4032 : : }
4033 : :
4034 [ # # ]: 0 : if (no_poll_on_link_down) {
4035 : 0 : adapter->rx_burst_type = rx_burst_type;
4036 : 0 : dev->rx_pkt_burst = iavf_recv_pkts_no_poll;
4037 : : } else {
4038 : 0 : dev->rx_pkt_burst = iavf_rx_pkt_burst_ops[rx_burst_type];
4039 : : }
4040 : 0 : return;
4041 : : }
4042 : : #elif defined RTE_ARCH_ARM
4043 : : int check_ret;
4044 : :
4045 : : check_ret = iavf_rx_vec_dev_check(dev);
4046 : : if (check_ret >= 0 &&
4047 : : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
4048 : : PMD_DRV_LOG(DEBUG, "Using a Vector Rx callback (port=%d).",
4049 : : dev->data->port_id);
4050 : : for (i = 0; i < dev->data->nb_rx_queues; i++) {
4051 : : rxq = dev->data->rx_queues[i];
4052 : : (void)iavf_rxq_vec_setup(rxq);
4053 : : }
4054 : : rx_burst_type = IAVF_RX_SSE;
4055 : :
4056 : : if (no_poll_on_link_down) {
4057 : : adapter->rx_burst_type = rx_burst_type;
4058 : : dev->rx_pkt_burst = iavf_recv_pkts_no_poll;
4059 : : } else {
4060 : : dev->rx_pkt_burst = iavf_rx_pkt_burst_ops[rx_burst_type];
4061 : : }
4062 : : return;
4063 : : }
4064 : : #endif
4065 [ # # ]: 0 : if (dev->data->scattered_rx) {
4066 : 0 : PMD_DRV_LOG(DEBUG, "Using a Scattered Rx callback (port=%d).",
4067 : : dev->data->port_id);
4068 [ # # ]: 0 : if (use_flex)
4069 : : rx_burst_type = IAVF_RX_SCATTERED_FLEX_RXD;
4070 : : else
4071 : : rx_burst_type = IAVF_RX_SCATTERED;
4072 [ # # ]: 0 : } else if (adapter->rx_bulk_alloc_allowed) {
4073 : 0 : PMD_DRV_LOG(DEBUG, "Using bulk Rx callback (port=%d).",
4074 : : dev->data->port_id);
4075 : : rx_burst_type = IAVF_RX_BULK_ALLOC;
4076 : : } else {
4077 : 0 : PMD_DRV_LOG(DEBUG, "Using Basic Rx callback (port=%d).",
4078 : : dev->data->port_id);
4079 [ # # ]: 0 : if (use_flex)
4080 : : rx_burst_type = IAVF_RX_FLEX_RXD;
4081 : : else
4082 : : rx_burst_type = IAVF_RX_DEFAULT;
4083 : : }
4084 : :
4085 [ # # ]: 0 : if (no_poll_on_link_down) {
4086 : 0 : adapter->rx_burst_type = rx_burst_type;
4087 : 0 : dev->rx_pkt_burst = iavf_recv_pkts_no_poll;
4088 : : } else {
4089 : 0 : dev->rx_pkt_burst = iavf_rx_pkt_burst_ops[rx_burst_type];
4090 : : }
4091 : : }
4092 : :
4093 : : /* choose tx function*/
4094 : : void
4095 : 0 : iavf_set_tx_function(struct rte_eth_dev *dev)
4096 : : {
4097 : 0 : struct iavf_adapter *adapter =
4098 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4099 : : enum iavf_tx_burst_type tx_burst_type;
4100 : 0 : int mbuf_check = adapter->devargs.mbuf_check;
4101 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
4102 : : #ifdef RTE_ARCH_X86
4103 : : struct ci_tx_queue *txq;
4104 : : int i;
4105 : : int check_ret;
4106 : : bool use_sse = false;
4107 : : bool use_avx2 = false;
4108 : : bool use_avx512 = false;
4109 : :
4110 : 0 : check_ret = iavf_tx_vec_dev_check(dev);
4111 : :
4112 [ # # # # ]: 0 : if (check_ret >= 0 &&
4113 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
4114 : : /* SSE not support offload path yet. */
4115 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH) {
4116 : : use_sse = true;
4117 : : }
4118 [ # # # # ]: 0 : if ((rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
4119 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
4120 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
4121 : : use_avx2 = true;
4122 : : #ifdef CC_AVX512_SUPPORT
4123 [ # # # # ]: 0 : if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
4124 [ # # ]: 0 : rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1 &&
4125 : 0 : rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)
4126 : : use_avx512 = true;
4127 : : #endif
4128 : :
4129 [ # # # # ]: 0 : if (!use_sse && !use_avx2 && !use_avx512)
4130 : 0 : goto normal;
4131 : :
4132 [ # # ]: 0 : if (use_sse) {
4133 : 0 : PMD_DRV_LOG(DEBUG, "Using Vector Tx (port %d).",
4134 : : dev->data->port_id);
4135 : : tx_burst_type = IAVF_TX_SSE;
4136 : : }
4137 [ # # ]: 0 : if (use_avx2) {
4138 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH) {
4139 : : tx_burst_type = IAVF_TX_AVX2;
4140 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX2 Vector Tx (port %d).",
4141 : : dev->data->port_id);
4142 [ # # ]: 0 : } else if (check_ret == IAVF_VECTOR_CTX_OFFLOAD_PATH) {
4143 : 0 : PMD_DRV_LOG(DEBUG,
4144 : : "AVX2 does not support outer checksum offload.");
4145 : 0 : goto normal;
4146 : : } else {
4147 : : tx_burst_type = IAVF_TX_AVX2_OFFLOAD;
4148 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX2 OFFLOAD Vector Tx (port %d).",
4149 : : dev->data->port_id);
4150 : : }
4151 : : }
4152 : : #ifdef CC_AVX512_SUPPORT
4153 [ # # ]: 0 : if (use_avx512) {
4154 [ # # ]: 0 : if (check_ret == IAVF_VECTOR_PATH) {
4155 : : tx_burst_type = IAVF_TX_AVX512;
4156 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX512 Vector Tx (port %d).",
4157 : : dev->data->port_id);
4158 [ # # ]: 0 : } else if (check_ret == IAVF_VECTOR_OFFLOAD_PATH) {
4159 : : tx_burst_type = IAVF_TX_AVX512_OFFLOAD;
4160 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
4161 : : dev->data->port_id);
4162 [ # # ]: 0 : } else if (check_ret == IAVF_VECTOR_CTX_PATH) {
4163 : : tx_burst_type = IAVF_TX_AVX512_CTX;
4164 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT Vector Tx (port %d).",
4165 : : dev->data->port_id);
4166 : : } else {
4167 : : tx_burst_type = IAVF_TX_AVX512_CTX_OFFLOAD;
4168 : 0 : PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT OFFLOAD Vector Tx (port %d).",
4169 : : dev->data->port_id);
4170 : : }
4171 : : }
4172 : : #endif
4173 : :
4174 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
4175 : 0 : txq = dev->data->tx_queues[i];
4176 [ # # ]: 0 : if (!txq)
4177 : 0 : continue;
4178 : 0 : iavf_txq_vec_setup(txq);
4179 : : }
4180 : :
4181 [ # # ]: 0 : if (no_poll_on_link_down) {
4182 : 0 : adapter->tx_burst_type = tx_burst_type;
4183 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
4184 [ # # ]: 0 : } else if (mbuf_check) {
4185 : 0 : adapter->tx_burst_type = tx_burst_type;
4186 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_check;
4187 : : } else {
4188 : 0 : dev->tx_pkt_burst = iavf_tx_pkt_burst_ops[tx_burst_type];
4189 : : }
4190 : 0 : return;
4191 : : }
4192 : :
4193 : 0 : normal:
4194 : : #endif
4195 : 0 : PMD_DRV_LOG(DEBUG, "Using Basic Tx callback (port=%d).",
4196 : : dev->data->port_id);
4197 : : tx_burst_type = IAVF_TX_DEFAULT;
4198 : :
4199 [ # # ]: 0 : if (no_poll_on_link_down) {
4200 : 0 : adapter->tx_burst_type = tx_burst_type;
4201 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
4202 [ # # ]: 0 : } else if (mbuf_check) {
4203 : 0 : adapter->tx_burst_type = tx_burst_type;
4204 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_check;
4205 : : } else {
4206 : 0 : dev->tx_pkt_burst = iavf_tx_pkt_burst_ops[tx_burst_type];
4207 : : }
4208 : : }
4209 : :
4210 : : static int
4211 : 0 : iavf_tx_done_cleanup_full(struct ci_tx_queue *txq,
4212 : : uint32_t free_cnt)
4213 : : {
4214 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
4215 : : uint16_t tx_last, tx_id;
4216 : : uint16_t nb_tx_free_last;
4217 : : uint16_t nb_tx_to_clean;
4218 : : uint32_t pkt_cnt = 0;
4219 : :
4220 : : /* Start free mbuf from tx_tail */
4221 : 0 : tx_id = txq->tx_tail;
4222 : : tx_last = tx_id;
4223 : :
4224 [ # # # # ]: 0 : if (txq->nb_tx_free == 0 && iavf_xmit_cleanup(txq))
4225 : : return 0;
4226 : :
4227 : 0 : nb_tx_to_clean = txq->nb_tx_free;
4228 : : nb_tx_free_last = txq->nb_tx_free;
4229 [ # # ]: 0 : if (!free_cnt)
4230 : 0 : free_cnt = txq->nb_tx_desc;
4231 : :
4232 : : /* Loop through swr_ring to count the amount of
4233 : : * freeable mubfs and packets.
4234 : : */
4235 [ # # ]: 0 : while (pkt_cnt < free_cnt) {
4236 : : do {
4237 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
4238 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
4239 : 0 : swr_ring[tx_id].mbuf = NULL;
4240 : :
4241 : : /*
4242 : : * last segment in the packet,
4243 : : * increment packet count
4244 : : */
4245 : 0 : pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
4246 : : }
4247 : :
4248 : 0 : tx_id = swr_ring[tx_id].next_id;
4249 [ # # # # ]: 0 : } while (--nb_tx_to_clean && pkt_cnt < free_cnt && tx_id != tx_last);
4250 : :
4251 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
4252 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
4253 : : break;
4254 : :
4255 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
4256 [ # # ]: 0 : if (iavf_xmit_cleanup(txq))
4257 : : break;
4258 : :
4259 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
4260 : : nb_tx_free_last = txq->nb_tx_free;
4261 : : }
4262 : : }
4263 : :
4264 : 0 : return (int)pkt_cnt;
4265 : : }
4266 : :
4267 : : int
4268 : 0 : iavf_dev_tx_done_cleanup(void *txq, uint32_t free_cnt)
4269 : : {
4270 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
4271 : :
4272 : 0 : return iavf_tx_done_cleanup_full(q, free_cnt);
4273 : : }
4274 : :
4275 : : void
4276 : 0 : iavf_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
4277 : : struct rte_eth_rxq_info *qinfo)
4278 : : {
4279 : : struct iavf_rx_queue *rxq;
4280 : :
4281 : 0 : rxq = dev->data->rx_queues[queue_id];
4282 : :
4283 : 0 : qinfo->mp = rxq->mp;
4284 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
4285 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
4286 : :
4287 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
4288 : 0 : qinfo->conf.rx_drop_en = true;
4289 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
4290 : 0 : }
4291 : :
4292 : : void
4293 : 0 : iavf_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
4294 : : struct rte_eth_txq_info *qinfo)
4295 : : {
4296 : : struct ci_tx_queue *txq;
4297 : :
4298 : 0 : txq = dev->data->tx_queues[queue_id];
4299 : :
4300 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
4301 : :
4302 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
4303 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
4304 : 0 : qinfo->conf.offloads = txq->offloads;
4305 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
4306 : 0 : }
4307 : :
4308 : : /* Get the number of used descriptors of a rx queue */
4309 : : uint32_t
4310 : 0 : iavf_dev_rxq_count(void *rx_queue)
4311 : : {
4312 : : #define IAVF_RXQ_SCAN_INTERVAL 4
4313 : : volatile union iavf_rx_desc *rxdp;
4314 : : struct iavf_rx_queue *rxq;
4315 : : uint16_t desc = 0;
4316 : :
4317 : : rxq = rx_queue;
4318 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
4319 : :
4320 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
4321 : 0 : ((rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
4322 [ # # ]: 0 : IAVF_RXD_QW1_STATUS_MASK) >> IAVF_RXD_QW1_STATUS_SHIFT) &
4323 : : (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)) {
4324 : : /* Check the DD bit of a rx descriptor of each 4 in a group,
4325 : : * to avoid checking too frequently and downgrading performance
4326 : : * too much.
4327 : : */
4328 : 0 : desc += IAVF_RXQ_SCAN_INTERVAL;
4329 : 0 : rxdp += IAVF_RXQ_SCAN_INTERVAL;
4330 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
4331 : 0 : rxdp = &(rxq->rx_ring[rxq->rx_tail +
4332 : 0 : desc - rxq->nb_rx_desc]);
4333 : : }
4334 : :
4335 : 0 : return desc;
4336 : : }
4337 : :
4338 : : int
4339 : 0 : iavf_dev_rx_desc_status(void *rx_queue, uint16_t offset)
4340 : : {
4341 : : struct iavf_rx_queue *rxq = rx_queue;
4342 : : volatile uint64_t *status;
4343 : : uint64_t mask;
4344 : : uint32_t desc;
4345 : :
4346 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
4347 : : return -EINVAL;
4348 : :
4349 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
4350 : : return RTE_ETH_RX_DESC_UNAVAIL;
4351 : :
4352 : 0 : desc = rxq->rx_tail + offset;
4353 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
4354 : 0 : desc -= rxq->nb_rx_desc;
4355 : :
4356 : 0 : status = &rxq->rx_ring[desc].wb.qword1.status_error_len;
4357 : : mask = rte_le_to_cpu_64((1ULL << IAVF_RX_DESC_STATUS_DD_SHIFT)
4358 : : << IAVF_RXD_QW1_STATUS_SHIFT);
4359 [ # # ]: 0 : if (*status & mask)
4360 : 0 : return RTE_ETH_RX_DESC_DONE;
4361 : :
4362 : : return RTE_ETH_RX_DESC_AVAIL;
4363 : : }
4364 : :
4365 : : int
4366 : 0 : iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset)
4367 : : {
4368 : : struct ci_tx_queue *txq = tx_queue;
4369 : : volatile uint64_t *status;
4370 : : uint64_t mask, expect;
4371 : : uint32_t desc;
4372 : :
4373 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
4374 : : return -EINVAL;
4375 : :
4376 : 0 : desc = txq->tx_tail + offset;
4377 : : /* go to next desc that has the RS bit */
4378 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
4379 : : txq->tx_rs_thresh;
4380 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
4381 : 0 : desc -= txq->nb_tx_desc;
4382 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
4383 : 0 : desc -= txq->nb_tx_desc;
4384 : : }
4385 : :
4386 : 0 : status = &txq->iavf_tx_ring[desc].cmd_type_offset_bsz;
4387 : : mask = rte_le_to_cpu_64(IAVF_TXD_QW1_DTYPE_MASK);
4388 : : expect = rte_cpu_to_le_64(
4389 : : IAVF_TX_DESC_DTYPE_DESC_DONE << IAVF_TXD_QW1_DTYPE_SHIFT);
4390 [ # # ]: 0 : if ((*status & mask) == expect)
4391 : 0 : return RTE_ETH_TX_DESC_DONE;
4392 : :
4393 : : return RTE_ETH_TX_DESC_FULL;
4394 : : }
4395 : :
4396 : : static inline uint32_t
4397 : : iavf_get_default_ptype(uint16_t ptype)
4398 : : {
4399 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] = {
4400 : : /* L2 types */
4401 : : /* [0] reserved */
4402 : : [1] = RTE_PTYPE_L2_ETHER,
4403 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
4404 : : /* [3] - [5] reserved */
4405 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
4406 : : /* [7] - [10] reserved */
4407 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
4408 : : /* [12] - [21] reserved */
4409 : :
4410 : : /* Non tunneled IPv4 */
4411 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4412 : : RTE_PTYPE_L4_FRAG,
4413 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4414 : : RTE_PTYPE_L4_NONFRAG,
4415 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4416 : : RTE_PTYPE_L4_UDP,
4417 : : /* [25] reserved */
4418 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4419 : : RTE_PTYPE_L4_TCP,
4420 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4421 : : RTE_PTYPE_L4_SCTP,
4422 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4423 : : RTE_PTYPE_L4_ICMP,
4424 : :
4425 : : /* IPv4 --> IPv4 */
4426 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4427 : : RTE_PTYPE_TUNNEL_IP |
4428 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4429 : : RTE_PTYPE_INNER_L4_FRAG,
4430 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4431 : : RTE_PTYPE_TUNNEL_IP |
4432 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4433 : : RTE_PTYPE_INNER_L4_NONFRAG,
4434 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4435 : : RTE_PTYPE_TUNNEL_IP |
4436 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4437 : : RTE_PTYPE_INNER_L4_UDP,
4438 : : /* [32] reserved */
4439 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4440 : : RTE_PTYPE_TUNNEL_IP |
4441 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4442 : : RTE_PTYPE_INNER_L4_TCP,
4443 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4444 : : RTE_PTYPE_TUNNEL_IP |
4445 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4446 : : RTE_PTYPE_INNER_L4_SCTP,
4447 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4448 : : RTE_PTYPE_TUNNEL_IP |
4449 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4450 : : RTE_PTYPE_INNER_L4_ICMP,
4451 : :
4452 : : /* IPv4 --> IPv6 */
4453 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4454 : : RTE_PTYPE_TUNNEL_IP |
4455 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4456 : : RTE_PTYPE_INNER_L4_FRAG,
4457 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4458 : : RTE_PTYPE_TUNNEL_IP |
4459 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4460 : : RTE_PTYPE_INNER_L4_NONFRAG,
4461 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4462 : : RTE_PTYPE_TUNNEL_IP |
4463 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4464 : : RTE_PTYPE_INNER_L4_UDP,
4465 : : /* [39] reserved */
4466 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4467 : : RTE_PTYPE_TUNNEL_IP |
4468 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4469 : : RTE_PTYPE_INNER_L4_TCP,
4470 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4471 : : RTE_PTYPE_TUNNEL_IP |
4472 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4473 : : RTE_PTYPE_INNER_L4_SCTP,
4474 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4475 : : RTE_PTYPE_TUNNEL_IP |
4476 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4477 : : RTE_PTYPE_INNER_L4_ICMP,
4478 : :
4479 : : /* IPv4 --> GRE/Teredo/VXLAN */
4480 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4481 : : RTE_PTYPE_TUNNEL_GRENAT,
4482 : :
4483 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
4484 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4485 : : RTE_PTYPE_TUNNEL_GRENAT |
4486 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4487 : : RTE_PTYPE_INNER_L4_FRAG,
4488 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4489 : : RTE_PTYPE_TUNNEL_GRENAT |
4490 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4491 : : RTE_PTYPE_INNER_L4_NONFRAG,
4492 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4493 : : RTE_PTYPE_TUNNEL_GRENAT |
4494 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4495 : : RTE_PTYPE_INNER_L4_UDP,
4496 : : /* [47] reserved */
4497 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4498 : : RTE_PTYPE_TUNNEL_GRENAT |
4499 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4500 : : RTE_PTYPE_INNER_L4_TCP,
4501 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4502 : : RTE_PTYPE_TUNNEL_GRENAT |
4503 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4504 : : RTE_PTYPE_INNER_L4_SCTP,
4505 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4506 : : RTE_PTYPE_TUNNEL_GRENAT |
4507 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4508 : : RTE_PTYPE_INNER_L4_ICMP,
4509 : :
4510 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
4511 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4512 : : RTE_PTYPE_TUNNEL_GRENAT |
4513 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4514 : : RTE_PTYPE_INNER_L4_FRAG,
4515 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4516 : : RTE_PTYPE_TUNNEL_GRENAT |
4517 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4518 : : RTE_PTYPE_INNER_L4_NONFRAG,
4519 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4520 : : RTE_PTYPE_TUNNEL_GRENAT |
4521 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4522 : : RTE_PTYPE_INNER_L4_UDP,
4523 : : /* [54] reserved */
4524 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4525 : : RTE_PTYPE_TUNNEL_GRENAT |
4526 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4527 : : RTE_PTYPE_INNER_L4_TCP,
4528 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4529 : : RTE_PTYPE_TUNNEL_GRENAT |
4530 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4531 : : RTE_PTYPE_INNER_L4_SCTP,
4532 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4533 : : RTE_PTYPE_TUNNEL_GRENAT |
4534 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4535 : : RTE_PTYPE_INNER_L4_ICMP,
4536 : :
4537 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
4538 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4539 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4540 : :
4541 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4542 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4543 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4544 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4545 : : RTE_PTYPE_INNER_L4_FRAG,
4546 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4547 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4548 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4549 : : RTE_PTYPE_INNER_L4_NONFRAG,
4550 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4551 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4552 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4553 : : RTE_PTYPE_INNER_L4_UDP,
4554 : : /* [62] reserved */
4555 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4556 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4557 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4558 : : RTE_PTYPE_INNER_L4_TCP,
4559 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4560 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4561 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4562 : : RTE_PTYPE_INNER_L4_SCTP,
4563 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4564 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4565 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4566 : : RTE_PTYPE_INNER_L4_ICMP,
4567 : :
4568 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4569 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4570 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4571 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4572 : : RTE_PTYPE_INNER_L4_FRAG,
4573 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4574 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4575 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4576 : : RTE_PTYPE_INNER_L4_NONFRAG,
4577 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4578 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4579 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4580 : : RTE_PTYPE_INNER_L4_UDP,
4581 : : /* [69] reserved */
4582 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4583 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4584 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4585 : : RTE_PTYPE_INNER_L4_TCP,
4586 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4587 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4588 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4589 : : RTE_PTYPE_INNER_L4_SCTP,
4590 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4591 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4592 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4593 : : RTE_PTYPE_INNER_L4_ICMP,
4594 : : /* [73] - [87] reserved */
4595 : :
4596 : : /* Non tunneled IPv6 */
4597 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4598 : : RTE_PTYPE_L4_FRAG,
4599 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4600 : : RTE_PTYPE_L4_NONFRAG,
4601 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4602 : : RTE_PTYPE_L4_UDP,
4603 : : /* [91] reserved */
4604 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4605 : : RTE_PTYPE_L4_TCP,
4606 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4607 : : RTE_PTYPE_L4_SCTP,
4608 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4609 : : RTE_PTYPE_L4_ICMP,
4610 : :
4611 : : /* IPv6 --> IPv4 */
4612 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4613 : : RTE_PTYPE_TUNNEL_IP |
4614 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4615 : : RTE_PTYPE_INNER_L4_FRAG,
4616 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4617 : : RTE_PTYPE_TUNNEL_IP |
4618 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4619 : : RTE_PTYPE_INNER_L4_NONFRAG,
4620 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4621 : : RTE_PTYPE_TUNNEL_IP |
4622 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4623 : : RTE_PTYPE_INNER_L4_UDP,
4624 : : /* [98] reserved */
4625 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4626 : : RTE_PTYPE_TUNNEL_IP |
4627 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4628 : : RTE_PTYPE_INNER_L4_TCP,
4629 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4630 : : RTE_PTYPE_TUNNEL_IP |
4631 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4632 : : RTE_PTYPE_INNER_L4_SCTP,
4633 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4634 : : RTE_PTYPE_TUNNEL_IP |
4635 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4636 : : RTE_PTYPE_INNER_L4_ICMP,
4637 : :
4638 : : /* IPv6 --> IPv6 */
4639 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4640 : : RTE_PTYPE_TUNNEL_IP |
4641 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4642 : : RTE_PTYPE_INNER_L4_FRAG,
4643 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4644 : : RTE_PTYPE_TUNNEL_IP |
4645 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4646 : : RTE_PTYPE_INNER_L4_NONFRAG,
4647 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4648 : : RTE_PTYPE_TUNNEL_IP |
4649 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4650 : : RTE_PTYPE_INNER_L4_UDP,
4651 : : /* [105] reserved */
4652 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4653 : : RTE_PTYPE_TUNNEL_IP |
4654 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4655 : : RTE_PTYPE_INNER_L4_TCP,
4656 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4657 : : RTE_PTYPE_TUNNEL_IP |
4658 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4659 : : RTE_PTYPE_INNER_L4_SCTP,
4660 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4661 : : RTE_PTYPE_TUNNEL_IP |
4662 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4663 : : RTE_PTYPE_INNER_L4_ICMP,
4664 : :
4665 : : /* IPv6 --> GRE/Teredo/VXLAN */
4666 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4667 : : RTE_PTYPE_TUNNEL_GRENAT,
4668 : :
4669 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4670 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4671 : : RTE_PTYPE_TUNNEL_GRENAT |
4672 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4673 : : RTE_PTYPE_INNER_L4_FRAG,
4674 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4675 : : RTE_PTYPE_TUNNEL_GRENAT |
4676 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4677 : : RTE_PTYPE_INNER_L4_NONFRAG,
4678 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4679 : : RTE_PTYPE_TUNNEL_GRENAT |
4680 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4681 : : RTE_PTYPE_INNER_L4_UDP,
4682 : : /* [113] reserved */
4683 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4684 : : RTE_PTYPE_TUNNEL_GRENAT |
4685 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4686 : : RTE_PTYPE_INNER_L4_TCP,
4687 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4688 : : RTE_PTYPE_TUNNEL_GRENAT |
4689 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4690 : : RTE_PTYPE_INNER_L4_SCTP,
4691 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4692 : : RTE_PTYPE_TUNNEL_GRENAT |
4693 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4694 : : RTE_PTYPE_INNER_L4_ICMP,
4695 : :
4696 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4697 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4698 : : RTE_PTYPE_TUNNEL_GRENAT |
4699 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4700 : : RTE_PTYPE_INNER_L4_FRAG,
4701 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4702 : : RTE_PTYPE_TUNNEL_GRENAT |
4703 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4704 : : RTE_PTYPE_INNER_L4_NONFRAG,
4705 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4706 : : RTE_PTYPE_TUNNEL_GRENAT |
4707 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4708 : : RTE_PTYPE_INNER_L4_UDP,
4709 : : /* [120] reserved */
4710 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4711 : : RTE_PTYPE_TUNNEL_GRENAT |
4712 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4713 : : RTE_PTYPE_INNER_L4_TCP,
4714 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4715 : : RTE_PTYPE_TUNNEL_GRENAT |
4716 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4717 : : RTE_PTYPE_INNER_L4_SCTP,
4718 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4719 : : RTE_PTYPE_TUNNEL_GRENAT |
4720 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4721 : : RTE_PTYPE_INNER_L4_ICMP,
4722 : :
4723 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4724 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4725 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4726 : :
4727 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4728 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4729 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4730 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4731 : : RTE_PTYPE_INNER_L4_FRAG,
4732 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4733 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4734 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4735 : : RTE_PTYPE_INNER_L4_NONFRAG,
4736 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4737 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4738 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4739 : : RTE_PTYPE_INNER_L4_UDP,
4740 : : /* [128] reserved */
4741 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4742 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4743 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4744 : : RTE_PTYPE_INNER_L4_TCP,
4745 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4746 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4747 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4748 : : RTE_PTYPE_INNER_L4_SCTP,
4749 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4750 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4751 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4752 : : RTE_PTYPE_INNER_L4_ICMP,
4753 : :
4754 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4755 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4756 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4757 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4758 : : RTE_PTYPE_INNER_L4_FRAG,
4759 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4760 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4761 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4762 : : RTE_PTYPE_INNER_L4_NONFRAG,
4763 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4764 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4765 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4766 : : RTE_PTYPE_INNER_L4_UDP,
4767 : : /* [135] reserved */
4768 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4769 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4770 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4771 : : RTE_PTYPE_INNER_L4_TCP,
4772 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4773 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4774 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4775 : : RTE_PTYPE_INNER_L4_SCTP,
4776 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4777 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4778 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4779 : : RTE_PTYPE_INNER_L4_ICMP,
4780 : : /* [139] - [299] reserved */
4781 : :
4782 : : /* PPPoE */
4783 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4784 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4785 : :
4786 : : /* PPPoE --> IPv4 */
4787 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4788 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4789 : : RTE_PTYPE_L4_FRAG,
4790 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4791 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4792 : : RTE_PTYPE_L4_NONFRAG,
4793 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4794 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4795 : : RTE_PTYPE_L4_UDP,
4796 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4797 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4798 : : RTE_PTYPE_L4_TCP,
4799 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4800 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4801 : : RTE_PTYPE_L4_SCTP,
4802 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4803 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4804 : : RTE_PTYPE_L4_ICMP,
4805 : :
4806 : : /* PPPoE --> IPv6 */
4807 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4808 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4809 : : RTE_PTYPE_L4_FRAG,
4810 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4811 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4812 : : RTE_PTYPE_L4_NONFRAG,
4813 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4814 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4815 : : RTE_PTYPE_L4_UDP,
4816 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4817 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4818 : : RTE_PTYPE_L4_TCP,
4819 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4820 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4821 : : RTE_PTYPE_L4_SCTP,
4822 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4823 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4824 : : RTE_PTYPE_L4_ICMP,
4825 : : /* [314] - [324] reserved */
4826 : :
4827 : : /* IPv4/IPv6 --> GTPC/GTPU */
4828 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4829 : : RTE_PTYPE_TUNNEL_GTPC,
4830 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4831 : : RTE_PTYPE_TUNNEL_GTPC,
4832 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4833 : : RTE_PTYPE_TUNNEL_GTPC,
4834 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4835 : : RTE_PTYPE_TUNNEL_GTPC,
4836 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4837 : : RTE_PTYPE_TUNNEL_GTPU,
4838 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4839 : : RTE_PTYPE_TUNNEL_GTPU,
4840 : :
4841 : : /* IPv4 --> GTPU --> IPv4 */
4842 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4843 : : RTE_PTYPE_TUNNEL_GTPU |
4844 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4845 : : RTE_PTYPE_INNER_L4_FRAG,
4846 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4847 : : RTE_PTYPE_TUNNEL_GTPU |
4848 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4849 : : RTE_PTYPE_INNER_L4_NONFRAG,
4850 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4851 : : RTE_PTYPE_TUNNEL_GTPU |
4852 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4853 : : RTE_PTYPE_INNER_L4_UDP,
4854 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4855 : : RTE_PTYPE_TUNNEL_GTPU |
4856 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4857 : : RTE_PTYPE_INNER_L4_TCP,
4858 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4859 : : RTE_PTYPE_TUNNEL_GTPU |
4860 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4861 : : RTE_PTYPE_INNER_L4_ICMP,
4862 : :
4863 : : /* IPv6 --> GTPU --> IPv4 */
4864 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4865 : : RTE_PTYPE_TUNNEL_GTPU |
4866 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4867 : : RTE_PTYPE_INNER_L4_FRAG,
4868 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4869 : : RTE_PTYPE_TUNNEL_GTPU |
4870 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4871 : : RTE_PTYPE_INNER_L4_NONFRAG,
4872 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4873 : : RTE_PTYPE_TUNNEL_GTPU |
4874 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4875 : : RTE_PTYPE_INNER_L4_UDP,
4876 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4877 : : RTE_PTYPE_TUNNEL_GTPU |
4878 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4879 : : RTE_PTYPE_INNER_L4_TCP,
4880 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4881 : : RTE_PTYPE_TUNNEL_GTPU |
4882 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4883 : : RTE_PTYPE_INNER_L4_ICMP,
4884 : :
4885 : : /* IPv4 --> GTPU --> IPv6 */
4886 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4887 : : RTE_PTYPE_TUNNEL_GTPU |
4888 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4889 : : RTE_PTYPE_INNER_L4_FRAG,
4890 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4891 : : RTE_PTYPE_TUNNEL_GTPU |
4892 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4893 : : RTE_PTYPE_INNER_L4_NONFRAG,
4894 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4895 : : RTE_PTYPE_TUNNEL_GTPU |
4896 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4897 : : RTE_PTYPE_INNER_L4_UDP,
4898 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4899 : : RTE_PTYPE_TUNNEL_GTPU |
4900 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4901 : : RTE_PTYPE_INNER_L4_TCP,
4902 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4903 : : RTE_PTYPE_TUNNEL_GTPU |
4904 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4905 : : RTE_PTYPE_INNER_L4_ICMP,
4906 : :
4907 : : /* IPv6 --> GTPU --> IPv6 */
4908 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4909 : : RTE_PTYPE_TUNNEL_GTPU |
4910 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4911 : : RTE_PTYPE_INNER_L4_FRAG,
4912 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4913 : : RTE_PTYPE_TUNNEL_GTPU |
4914 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4915 : : RTE_PTYPE_INNER_L4_NONFRAG,
4916 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4917 : : RTE_PTYPE_TUNNEL_GTPU |
4918 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4919 : : RTE_PTYPE_INNER_L4_UDP,
4920 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4921 : : RTE_PTYPE_TUNNEL_GTPU |
4922 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4923 : : RTE_PTYPE_INNER_L4_TCP,
4924 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4925 : : RTE_PTYPE_TUNNEL_GTPU |
4926 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4927 : : RTE_PTYPE_INNER_L4_ICMP,
4928 : :
4929 : : /* IPv4 --> UDP ECPRI */
4930 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4931 : : RTE_PTYPE_L4_UDP,
4932 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4933 : : RTE_PTYPE_L4_UDP,
4934 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4935 : : RTE_PTYPE_L4_UDP,
4936 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4937 : : RTE_PTYPE_L4_UDP,
4938 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4939 : : RTE_PTYPE_L4_UDP,
4940 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4941 : : RTE_PTYPE_L4_UDP,
4942 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4943 : : RTE_PTYPE_L4_UDP,
4944 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4945 : : RTE_PTYPE_L4_UDP,
4946 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4947 : : RTE_PTYPE_L4_UDP,
4948 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4949 : : RTE_PTYPE_L4_UDP,
4950 : :
4951 : : /* IPV6 --> UDP ECPRI */
4952 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4953 : : RTE_PTYPE_L4_UDP,
4954 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4955 : : RTE_PTYPE_L4_UDP,
4956 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4957 : : RTE_PTYPE_L4_UDP,
4958 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4959 : : RTE_PTYPE_L4_UDP,
4960 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4961 : : RTE_PTYPE_L4_UDP,
4962 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4963 : : RTE_PTYPE_L4_UDP,
4964 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4965 : : RTE_PTYPE_L4_UDP,
4966 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4967 : : RTE_PTYPE_L4_UDP,
4968 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4969 : : RTE_PTYPE_L4_UDP,
4970 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4971 : : RTE_PTYPE_L4_UDP,
4972 : : /* All others reserved */
4973 : : };
4974 : :
4975 : 0 : return ptype_tbl[ptype];
4976 : : }
4977 : :
4978 : : void __rte_cold
4979 : 0 : iavf_set_default_ptype_table(struct rte_eth_dev *dev)
4980 : : {
4981 : 0 : struct iavf_adapter *ad =
4982 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4983 : : int i;
4984 : :
4985 [ # # ]: 0 : for (i = 0; i < IAVF_MAX_PKT_TYPE; i++)
4986 : 0 : ad->ptype_tbl[i] = iavf_get_default_ptype(i);
4987 : 0 : }
|