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