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