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_ipsec_crypto.h"
36 : : #include "rte_pmd_iavf.h"
37 : :
38 : : #ifdef RTE_ARCH_X86
39 : : #include "../common/rx_vec_x86.h"
40 : : #endif
41 : :
42 : : #define GRE_CHECKSUM_PRESENT 0x8000
43 : : #define GRE_KEY_PRESENT 0x2000
44 : : #define GRE_SEQUENCE_PRESENT 0x1000
45 : : #define GRE_EXT_LEN 4
46 : : #define GRE_SUPPORTED_FIELDS (GRE_CHECKSUM_PRESENT | GRE_KEY_PRESENT |\
47 : : GRE_SEQUENCE_PRESENT)
48 : :
49 : : #ifndef IPPROTO_IPIP
50 : : #define IPPROTO_IPIP 4
51 : : #endif
52 : : #ifndef IPPROTO_GRE
53 : : #define IPPROTO_GRE 47
54 : : #endif
55 : :
56 : : static uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT;
57 : : static uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
58 : :
59 : : struct simple_gre_hdr {
60 : : uint16_t flags;
61 : : uint16_t proto;
62 : : };
63 : :
64 : : /* structure that caches offload info for the current packet */
65 : : struct offload_info {
66 : : uint16_t ethertype;
67 : : uint8_t gso_enable;
68 : : uint16_t l2_len;
69 : : uint16_t l3_len;
70 : : uint16_t l4_len;
71 : : uint8_t l4_proto;
72 : : uint8_t is_tunnel;
73 : : uint16_t outer_ethertype;
74 : : uint16_t outer_l2_len;
75 : : uint16_t outer_l3_len;
76 : : uint8_t outer_l4_proto;
77 : : uint16_t tso_segsz;
78 : : uint16_t tunnel_tso_segsz;
79 : : uint32_t pkt_len;
80 : : };
81 : :
82 : : /* Offset of mbuf dynamic field for protocol extraction's metadata */
83 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynfield_proto_xtr_metadata_offs, 20.11)
84 : : int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs = -1;
85 : :
86 : : /* Mask of mbuf dynamic flags for protocol extraction's type */
87 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_vlan_mask, 20.11)
88 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_vlan_mask;
89 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask, 20.11)
90 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask;
91 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask, 20.11)
92 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask;
93 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask, 20.11)
94 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask;
95 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_tcp_mask, 20.11)
96 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
97 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask, 20.11)
98 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
99 : : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask, 21.11)
100 : : uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
101 : :
102 : : uint8_t
103 : 0 : iavf_proto_xtr_type_to_rxdid(uint8_t flex_type)
104 : : {
105 : : static uint8_t rxdid_map[] = {
106 : : [IAVF_PROTO_XTR_NONE] = IAVF_RXDID_COMMS_OVS_1,
107 : : [IAVF_PROTO_XTR_VLAN] = IAVF_RXDID_COMMS_AUX_VLAN,
108 : : [IAVF_PROTO_XTR_IPV4] = IAVF_RXDID_COMMS_AUX_IPV4,
109 : : [IAVF_PROTO_XTR_IPV6] = IAVF_RXDID_COMMS_AUX_IPV6,
110 : : [IAVF_PROTO_XTR_IPV6_FLOW] = IAVF_RXDID_COMMS_AUX_IPV6_FLOW,
111 : : [IAVF_PROTO_XTR_TCP] = IAVF_RXDID_COMMS_AUX_TCP,
112 : : [IAVF_PROTO_XTR_IP_OFFSET] = IAVF_RXDID_COMMS_AUX_IP_OFFSET,
113 : : [IAVF_PROTO_XTR_IPSEC_CRYPTO_SAID] =
114 : : IAVF_RXDID_COMMS_IPSEC_CRYPTO,
115 : : };
116 : :
117 : : return flex_type < RTE_DIM(rxdid_map) ?
118 [ # # ]: 0 : rxdid_map[flex_type] : IAVF_RXDID_COMMS_OVS_1;
119 : : }
120 : :
121 : : static int
122 : 0 : iavf_monitor_callback(const uint64_t value,
123 : : const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
124 : : {
125 : : const uint64_t m = rte_cpu_to_le_64(1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
126 : : /*
127 : : * we expect the DD bit to be set to 1 if this descriptor was already
128 : : * written to.
129 : : */
130 [ # # ]: 0 : return (value & m) == m ? -1 : 0;
131 : : }
132 : :
133 : : int
134 : 0 : iavf_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
135 : : {
136 : : struct ci_rx_queue *rxq = rx_queue;
137 : : volatile union ci_rx_desc *rxdp;
138 : : uint16_t desc;
139 : :
140 : 0 : desc = rxq->rx_tail;
141 : 0 : rxdp = &rxq->rx_ring[desc];
142 : : /* watch for changes in status bit */
143 : 0 : pmc->addr = &rxdp->wb.qword1.status_error_len;
144 : :
145 : : /* comparison callback */
146 : 0 : pmc->fn = iavf_monitor_callback;
147 : :
148 : : /* registers are 64-bit */
149 : 0 : pmc->size = sizeof(uint64_t);
150 : :
151 : 0 : return 0;
152 : : }
153 : :
154 : : static inline int
155 : 0 : check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
156 : : uint16_t tx_free_thresh)
157 : : {
158 : : /* TX descriptors will have their RS bit set after tx_rs_thresh
159 : : * descriptors have been used. The TX descriptor ring will be cleaned
160 : : * after tx_free_thresh descriptors are used or if the number of
161 : : * descriptors required to transmit a packet is greater than the
162 : : * number of free TX descriptors.
163 : : *
164 : : * The following constraints must be satisfied:
165 : : * - tx_rs_thresh must be less than the size of the ring minus 2.
166 : : * - tx_free_thresh must be less than the size of the ring minus 3.
167 : : * - tx_rs_thresh must be less than or equal to tx_free_thresh.
168 : : * - tx_rs_thresh must be a divisor of the ring size.
169 : : *
170 : : * One descriptor in the TX ring is used as a sentinel to avoid a H/W
171 : : * race condition, hence the maximum threshold constraints. When set
172 : : * to zero use default values.
173 : : */
174 [ # # ]: 0 : if (tx_rs_thresh >= (nb_desc - 2)) {
175 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be less than the "
176 : : "number of TX descriptors (%u) minus 2",
177 : : tx_rs_thresh, nb_desc);
178 : 0 : return -EINVAL;
179 : : }
180 [ # # ]: 0 : if (tx_free_thresh >= (nb_desc - 3)) {
181 : 0 : PMD_INIT_LOG(ERR, "tx_free_thresh (%u) must be less than the "
182 : : "number of TX descriptors (%u) minus 3.",
183 : : tx_free_thresh, nb_desc);
184 : 0 : return -EINVAL;
185 : : }
186 [ # # ]: 0 : if (tx_rs_thresh > tx_free_thresh) {
187 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be less than or "
188 : : "equal to tx_free_thresh (%u).",
189 : : tx_rs_thresh, tx_free_thresh);
190 : 0 : return -EINVAL;
191 : : }
192 [ # # ]: 0 : if ((nb_desc % tx_rs_thresh) != 0) {
193 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh (%u) must be a divisor of the "
194 : : "number of TX descriptors (%u).",
195 : : tx_rs_thresh, nb_desc);
196 : 0 : return -EINVAL;
197 : : }
198 [ # # ]: 0 : if (!rte_is_power_of_2(tx_rs_thresh)) {
199 : 0 : PMD_INIT_LOG(ERR, "tx_rs_thresh must be a power of 2. (tx_rs_thresh=%u)",
200 : : tx_rs_thresh);
201 : 0 : return -EINVAL;
202 : : }
203 : :
204 : : return 0;
205 : : }
206 : :
207 : : static inline bool
208 : 0 : check_rx_bulk_allow(struct ci_rx_queue *rxq)
209 : : {
210 : : int ret = true;
211 : :
212 [ # # ]: 0 : if (!(rxq->rx_free_thresh >= IAVF_RX_MAX_BURST)) {
213 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
214 : : "rxq->rx_free_thresh=%d, "
215 : : "IAVF_RX_MAX_BURST=%d",
216 : : rxq->rx_free_thresh, IAVF_RX_MAX_BURST);
217 : : ret = false;
218 [ # # ]: 0 : } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
219 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
220 : : "rxq->nb_rx_desc=%d, "
221 : : "rxq->rx_free_thresh=%d",
222 : : rxq->nb_rx_desc, rxq->rx_free_thresh);
223 : : ret = false;
224 : : }
225 : 0 : return ret;
226 : : }
227 : :
228 : : static inline void
229 : 0 : reset_rx_queue(struct ci_rx_queue *rxq)
230 : : {
231 : : uint16_t len;
232 : : uint32_t i;
233 : :
234 [ # # ]: 0 : if (!rxq)
235 : : return;
236 : :
237 : 0 : len = rxq->nb_rx_desc + IAVF_RX_MAX_BURST;
238 : :
239 [ # # ]: 0 : for (i = 0; i < len * sizeof(union ci_rx_desc); i++)
240 : 0 : ((volatile char *)rxq->rx_ring)[i] = 0;
241 : :
242 : 0 : memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
243 : :
244 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i++)
245 : 0 : rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
246 : :
247 : : /* for rx bulk */
248 : 0 : rxq->rx_nb_avail = 0;
249 : 0 : rxq->rx_next_avail = 0;
250 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
251 : :
252 : 0 : rxq->rx_tail = 0;
253 : 0 : rxq->nb_rx_hold = 0;
254 : :
255 : 0 : rte_pktmbuf_free(rxq->pkt_first_seg);
256 : :
257 : 0 : rxq->pkt_first_seg = NULL;
258 : 0 : rxq->pkt_last_seg = NULL;
259 : 0 : rxq->rxrearm_nb = 0;
260 : 0 : rxq->rxrearm_start = 0;
261 : : }
262 : :
263 : : static inline void
264 : 0 : reset_tx_queue(struct ci_tx_queue *txq)
265 : : {
266 : : struct ci_tx_entry *txe;
267 : : uint32_t i, size;
268 : : uint16_t prev;
269 : :
270 [ # # ]: 0 : if (!txq) {
271 : 0 : PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
272 : 0 : return;
273 : : }
274 : :
275 : 0 : txe = txq->sw_ring;
276 : 0 : size = sizeof(struct ci_tx_desc) * txq->nb_tx_desc;
277 [ # # ]: 0 : for (i = 0; i < size; i++)
278 : 0 : ((volatile char *)txq->ci_tx_ring)[i] = 0;
279 : :
280 : 0 : prev = (uint16_t)(txq->nb_tx_desc - 1);
281 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
282 : 0 : txq->ci_tx_ring[i].cmd_type_offset_bsz =
283 : : rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE);
284 : 0 : txe[i].mbuf = NULL;
285 : 0 : txe[prev].next_id = i;
286 : : prev = i;
287 : : }
288 : :
289 : 0 : txq->tx_tail = 0;
290 : :
291 : 0 : txq->last_desc_cleaned = txq->nb_tx_desc - 1;
292 : 0 : txq->nb_tx_free = txq->nb_tx_desc - 1;
293 : :
294 : 0 : txq->tx_next_dd = txq->tx_rs_thresh - 1;
295 : 0 : txq->tx_next_rs = txq->tx_rs_thresh - 1;
296 : : }
297 : :
298 : : static int
299 : 0 : alloc_rxq_mbufs(struct ci_rx_queue *rxq)
300 : : {
301 : : volatile union ci_rx_desc *rxd;
302 : : struct rte_mbuf *mbuf = NULL;
303 : : uint64_t dma_addr;
304 : : uint16_t i, j;
305 : :
306 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
307 : 0 : mbuf = rte_mbuf_raw_alloc(rxq->mp);
308 [ # # ]: 0 : if (unlikely(!mbuf)) {
309 [ # # ]: 0 : for (j = 0; j < i; j++) {
310 [ # # ]: 0 : rte_pktmbuf_free_seg(rxq->sw_ring[j].mbuf);
311 : 0 : rxq->sw_ring[j].mbuf = NULL;
312 : : }
313 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
314 : 0 : return -ENOMEM;
315 : : }
316 : :
317 : : rte_mbuf_refcnt_set(mbuf, 1);
318 : 0 : mbuf->next = NULL;
319 : 0 : mbuf->data_off = RTE_PKTMBUF_HEADROOM;
320 : 0 : mbuf->nb_segs = 1;
321 : 0 : mbuf->port = rxq->port_id;
322 : :
323 : : dma_addr =
324 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
325 : :
326 : 0 : rxd = &rxq->rx_ring[i];
327 : 0 : rxd->read.pkt_addr = dma_addr;
328 : 0 : rxd->read.hdr_addr = 0;
329 : 0 : rxd->read.rsvd1 = 0;
330 : 0 : rxd->read.rsvd2 = 0;
331 : :
332 : 0 : rxq->sw_ring[i].mbuf = mbuf;
333 : : }
334 : :
335 : : return 0;
336 : : }
337 : :
338 : : static inline void
339 : 0 : release_rxq_mbufs(struct ci_rx_queue *rxq)
340 : : {
341 : : uint16_t i;
342 : :
343 [ # # ]: 0 : if (!rxq->sw_ring)
344 : : return;
345 : :
346 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
347 [ # # ]: 0 : if (rxq->sw_ring[i].mbuf) {
348 : : rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf);
349 : 0 : rxq->sw_ring[i].mbuf = NULL;
350 : : }
351 : : }
352 : :
353 : : /* for rx bulk */
354 [ # # ]: 0 : if (rxq->rx_nb_avail == 0)
355 : : return;
356 [ # # ]: 0 : for (i = 0; i < rxq->rx_nb_avail; i++) {
357 : : struct rte_mbuf *mbuf;
358 : :
359 : 0 : mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
360 : : rte_pktmbuf_free_seg(mbuf);
361 : : }
362 : 0 : rxq->rx_nb_avail = 0;
363 : : }
364 : :
365 : : static const
366 : : struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = {
367 : : [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_rxq_mbufs,
368 : : #ifdef RTE_ARCH_X86
369 : : [IAVF_REL_MBUFS_VEC].release_mbufs = iavf_rx_queue_release_mbufs_vec,
370 : : #endif
371 : : #ifdef RTE_ARCH_ARM64
372 : : [IAVF_REL_MBUFS_NEON_VEC].release_mbufs = iavf_rx_queue_release_mbufs_neon,
373 : : #endif
374 : : };
375 : :
376 : : static inline void
377 : 0 : iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct ci_rx_queue *rxq,
378 : : struct rte_mbuf *mb,
379 : : volatile union ci_rx_flex_desc *rxdp)
380 : : {
381 : : volatile struct iavf_32b_rx_flex_desc_comms_ovs *desc =
382 : : (volatile struct iavf_32b_rx_flex_desc_comms_ovs *)rxdp;
383 : : uint16_t stat_err;
384 : :
385 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
386 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
387 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
388 : : }
389 : :
390 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
391 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
392 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
393 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
394 : : }
395 : 0 : }
396 : :
397 : : static inline void
398 : 0 : iavf_rxd_to_pkt_fields_by_comms_aux_v1(struct ci_rx_queue *rxq,
399 : : struct rte_mbuf *mb,
400 : : volatile union ci_rx_flex_desc *rxdp)
401 : : {
402 : : volatile struct iavf_32b_rx_flex_desc_comms *desc =
403 : : (volatile struct iavf_32b_rx_flex_desc_comms *)rxdp;
404 : : uint16_t stat_err;
405 : :
406 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
407 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
408 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
409 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
410 : : }
411 : :
412 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
413 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
414 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
415 : : }
416 : :
417 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
418 : : uint32_t metadata = 0;
419 : :
420 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error1);
421 : :
422 [ # # ]: 0 : if (stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
423 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
424 : :
425 [ # # ]: 0 : if (stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
426 : 0 : metadata |=
427 : 0 : rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
428 : :
429 [ # # ]: 0 : if (metadata) {
430 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
431 : :
432 : 0 : *RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(mb) = metadata;
433 : : }
434 : : }
435 : 0 : }
436 : :
437 : : static inline void
438 : 0 : iavf_rxd_to_pkt_fields_by_comms_aux_v2(struct ci_rx_queue *rxq,
439 : : struct rte_mbuf *mb,
440 : : volatile union ci_rx_flex_desc *rxdp)
441 : : {
442 : : volatile struct iavf_32b_rx_flex_desc_comms *desc =
443 : : (volatile struct iavf_32b_rx_flex_desc_comms *)rxdp;
444 : : uint16_t stat_err;
445 : :
446 : 0 : stat_err = rte_le_to_cpu_16(desc->status_error0);
447 [ # # ]: 0 : if (likely(stat_err & (1 << IAVF_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
448 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
449 : 0 : mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
450 : : }
451 : :
452 [ # # ]: 0 : if (desc->flow_id != 0xFFFFFFFF) {
453 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
454 : 0 : mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
455 : : }
456 : :
457 [ # # ]: 0 : if (rxq->xtr_ol_flag) {
458 : : uint32_t metadata = 0;
459 : :
460 [ # # ]: 0 : if (desc->flex_ts.flex.aux0 != 0xFFFF)
461 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
462 [ # # ]: 0 : else if (desc->flex_ts.flex.aux1 != 0xFFFF)
463 : 0 : metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
464 : :
465 [ # # ]: 0 : if (metadata) {
466 : 0 : mb->ol_flags |= rxq->xtr_ol_flag;
467 : :
468 : 0 : *RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(mb) = metadata;
469 : : }
470 : : }
471 : 0 : }
472 : :
473 : : static const
474 : : iavf_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[IAVF_RXDID_LAST + 1] = {
475 : : [IAVF_RXDID_LEGACY_0] = iavf_rxd_to_pkt_fields_by_comms_ovs,
476 : : [IAVF_RXDID_LEGACY_1] = iavf_rxd_to_pkt_fields_by_comms_ovs,
477 : : [IAVF_RXDID_COMMS_AUX_VLAN] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
478 : : [IAVF_RXDID_COMMS_AUX_IPV4] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
479 : : [IAVF_RXDID_COMMS_AUX_IPV6] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
480 : : [IAVF_RXDID_COMMS_AUX_IPV6_FLOW] =
481 : : iavf_rxd_to_pkt_fields_by_comms_aux_v1,
482 : : [IAVF_RXDID_COMMS_AUX_TCP] = iavf_rxd_to_pkt_fields_by_comms_aux_v1,
483 : : [IAVF_RXDID_COMMS_AUX_IP_OFFSET] =
484 : : iavf_rxd_to_pkt_fields_by_comms_aux_v2,
485 : : [IAVF_RXDID_COMMS_IPSEC_CRYPTO] =
486 : : iavf_rxd_to_pkt_fields_by_comms_aux_v2,
487 : : [IAVF_RXDID_COMMS_OVS_1] = iavf_rxd_to_pkt_fields_by_comms_ovs,
488 : : };
489 : :
490 : : static void
491 : 0 : iavf_select_rxd_to_pkt_fields_handler(struct ci_rx_queue *rxq, uint32_t rxdid)
492 : : {
493 : 0 : rxq->rxdid = rxdid;
494 : :
495 [ # # # # : 0 : switch (rxdid) {
# # # #
# ]
496 : 0 : case IAVF_RXDID_COMMS_AUX_VLAN:
497 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_vlan_mask;
498 : 0 : break;
499 : 0 : case IAVF_RXDID_COMMS_AUX_IPV4:
500 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask;
501 : 0 : break;
502 : 0 : case IAVF_RXDID_COMMS_AUX_IPV6:
503 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask;
504 : 0 : break;
505 : 0 : case IAVF_RXDID_COMMS_AUX_IPV6_FLOW:
506 : 0 : rxq->xtr_ol_flag =
507 : : rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask;
508 : 0 : break;
509 : 0 : case IAVF_RXDID_COMMS_AUX_TCP:
510 : 0 : rxq->xtr_ol_flag = rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
511 : 0 : break;
512 : 0 : case IAVF_RXDID_COMMS_AUX_IP_OFFSET:
513 : 0 : rxq->xtr_ol_flag =
514 : : rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
515 : 0 : break;
516 : 0 : case IAVF_RXDID_COMMS_IPSEC_CRYPTO:
517 : 0 : rxq->xtr_ol_flag =
518 : : rte_pmd_ifd_dynflag_proto_xtr_ipsec_crypto_said_mask;
519 : 0 : break;
520 : : case IAVF_RXDID_COMMS_OVS_1:
521 : : case IAVF_RXDID_LEGACY_0:
522 : : case IAVF_RXDID_LEGACY_1:
523 : : break;
524 : 0 : default:
525 : : /* update this according to the RXDID for FLEX_DESC_NONE */
526 : 0 : rxq->rxdid = IAVF_RXDID_COMMS_OVS_1;
527 : 0 : break;
528 : : }
529 : :
530 [ # # ]: 0 : if (!rte_pmd_ifd_dynf_proto_xtr_metadata_avail())
531 : 0 : rxq->xtr_ol_flag = 0;
532 : 0 : }
533 : :
534 : : int
535 : 0 : iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
536 : : uint16_t nb_desc, unsigned int socket_id,
537 : : const struct rte_eth_rxconf *rx_conf,
538 : : struct rte_mempool *mp)
539 : : {
540 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
541 : : struct iavf_adapter *ad =
542 : : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
543 : : struct iavf_info *vf =
544 : : IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
545 : 0 : struct iavf_vsi *vsi = &vf->vsi;
546 : : struct ci_rx_queue *rxq;
547 : : const struct rte_memzone *mz;
548 : : uint32_t ring_size;
549 : : uint8_t proto_xtr;
550 : : uint16_t len;
551 : : uint16_t rx_free_thresh;
552 : : uint64_t offloads;
553 : :
554 : 0 : PMD_INIT_FUNC_TRACE();
555 : :
556 [ # # ]: 0 : if (ad->closed)
557 : : return -EIO;
558 : :
559 : 0 : offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
560 : :
561 [ # # ]: 0 : if (nb_desc % IAVF_ALIGN_RING_DESC != 0 ||
562 [ # # ]: 0 : nb_desc > IAVF_MAX_RING_DESC ||
563 : : nb_desc < IAVF_MIN_RING_DESC) {
564 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
565 : : "invalid", nb_desc);
566 : 0 : return -EINVAL;
567 : : }
568 : :
569 : : /* Check free threshold */
570 [ # # ]: 0 : rx_free_thresh = (rx_conf->rx_free_thresh == 0) ?
571 : : IAVF_DEFAULT_RX_FREE_THRESH :
572 : : rx_conf->rx_free_thresh;
573 : : /* Check that ring size is > 2 * rx_free_thresh */
574 [ # # ]: 0 : if (nb_desc <= 2 * rx_free_thresh) {
575 : 0 : PMD_INIT_LOG(ERR, "rx ring size (%u) must be > 2 * rx_free_thresh (%u)",
576 : : nb_desc, rx_free_thresh);
577 [ # # ]: 0 : if (nb_desc == IAVF_MIN_RING_DESC)
578 : 0 : PMD_INIT_LOG(ERR, "To use the minimum ring size (%u), reduce rx_free_thresh to a lower value (recommended %u)",
579 : : IAVF_MIN_RING_DESC, IAVF_MIN_RING_DESC / 4);
580 : 0 : return -EINVAL;
581 : : }
582 : :
583 : : /* Free memory if needed */
584 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx]) {
585 : 0 : iavf_dev_rx_queue_release(dev, queue_idx);
586 : 0 : dev->data->rx_queues[queue_idx] = NULL;
587 : : }
588 : :
589 : : /* Allocate the rx queue data structure */
590 : 0 : rxq = rte_zmalloc_socket("iavf rxq",
591 : : sizeof(struct ci_rx_queue),
592 : : RTE_CACHE_LINE_SIZE,
593 : : socket_id);
594 [ # # ]: 0 : if (!rxq) {
595 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
596 : : "rx queue data structure");
597 : 0 : return -ENOMEM;
598 : : }
599 : :
600 : : /* Allocate stats */
601 : 0 : rxq->stats = rte_zmalloc_socket("iavf rxq stats",
602 : : sizeof(struct iavf_rx_queue_stats),
603 : : RTE_CACHE_LINE_SIZE,
604 : : socket_id);
605 [ # # ]: 0 : if (!rxq->stats) {
606 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
607 : : "rx queue stats");
608 : 0 : rte_free(rxq);
609 : 0 : return -ENOMEM;
610 : : }
611 : :
612 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
613 [ # # ]: 0 : proto_xtr = vf->proto_xtr ? vf->proto_xtr[queue_idx] :
614 : : IAVF_PROTO_XTR_NONE;
615 : 0 : rxq->rxdid = iavf_proto_xtr_type_to_rxdid(proto_xtr);
616 : 0 : rxq->proto_xtr = proto_xtr;
617 : : } else {
618 : 0 : rxq->rxdid = IAVF_RXDID_LEGACY_1;
619 : 0 : rxq->proto_xtr = IAVF_PROTO_XTR_NONE;
620 : : }
621 : :
622 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
623 : : struct virtchnl_vlan_supported_caps *stripping_support =
624 : : &vf->vlan_v2_caps.offloads.stripping_support;
625 : : uint32_t stripping_cap;
626 : :
627 [ # # ]: 0 : if (stripping_support->outer)
628 : : stripping_cap = stripping_support->outer;
629 : : else
630 : 0 : stripping_cap = stripping_support->inner;
631 : :
632 [ # # ]: 0 : if (stripping_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1)
633 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1;
634 [ # # ]: 0 : else if (stripping_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2_2)
635 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG2_2;
636 : : } else {
637 : 0 : rxq->rx_flags = IAVF_RX_FLAGS_VLAN_TAG_LOC_L2TAG1;
638 : : }
639 : :
640 : 0 : iavf_select_rxd_to_pkt_fields_handler(rxq, rxq->rxdid);
641 : :
642 : 0 : rxq->mp = mp;
643 : 0 : rxq->nb_rx_desc = nb_desc;
644 : 0 : rxq->rx_free_thresh = rx_free_thresh;
645 : 0 : rxq->queue_id = queue_idx;
646 : 0 : rxq->port_id = dev->data->port_id;
647 : 0 : rxq->rx_deferred_start = rx_conf->rx_deferred_start;
648 : 0 : rxq->rx_hdr_len = 0;
649 : 0 : rxq->iavf_vsi = vsi;
650 : 0 : rxq->offloads = offloads;
651 : :
652 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
653 : 0 : rxq->crc_len = RTE_ETHER_CRC_LEN;
654 : : else
655 : 0 : rxq->crc_len = 0;
656 : :
657 : 0 : len = rte_pktmbuf_data_room_size(rxq->mp) - RTE_PKTMBUF_HEADROOM;
658 : 0 : rxq->rx_buf_len = RTE_ALIGN_FLOOR(len, (1 << IAVF_RXQ_CTX_DBUFF_SHIFT));
659 : 0 : rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, IAVF_RX_MAX_DATA_BUF_SIZE);
660 : :
661 : : /* Allocate the software ring. */
662 : 0 : len = nb_desc + IAVF_RX_MAX_BURST;
663 : 0 : rxq->sw_ring =
664 : 0 : rte_zmalloc_socket("iavf rx sw ring",
665 : : sizeof(struct rte_mbuf *) * len,
666 : : RTE_CACHE_LINE_SIZE,
667 : : socket_id);
668 [ # # ]: 0 : if (!rxq->sw_ring) {
669 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
670 : 0 : rte_free(rxq->stats);
671 : 0 : rte_free(rxq);
672 : 0 : return -ENOMEM;
673 : : }
674 : :
675 : : /* Allocate the maximum number of RX ring hardware descriptor with
676 : : * a little more to support bulk allocate.
677 : : */
678 : : len = IAVF_MAX_RING_DESC + IAVF_RX_MAX_BURST;
679 : : ring_size = RTE_ALIGN(len * sizeof(union ci_rx_desc),
680 : : IAVF_DMA_MEM_ALIGN);
681 : 0 : mz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
682 : : ring_size, IAVF_RING_BASE_ALIGN,
683 : : socket_id);
684 [ # # ]: 0 : if (!mz) {
685 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
686 : 0 : rte_free(rxq->sw_ring);
687 : 0 : rte_free(rxq->stats);
688 : 0 : rte_free(rxq);
689 : 0 : return -ENOMEM;
690 : : }
691 : : /* Zero all the descriptors in the ring. */
692 : 0 : memset(mz->addr, 0, ring_size);
693 : 0 : rxq->rx_ring_phys_addr = mz->iova;
694 : 0 : rxq->rx_ring = (union ci_rx_desc *)mz->addr;
695 : :
696 : 0 : rxq->mz = mz;
697 : 0 : reset_rx_queue(rxq);
698 : 0 : rxq->q_set = true;
699 : 0 : dev->data->rx_queues[queue_idx] = rxq;
700 : 0 : rxq->qrx_tail = hw->hw_addr + IAVF_QRX_TAIL1(rxq->queue_id);
701 : 0 : rxq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT;
702 : :
703 [ # # ]: 0 : if (check_rx_bulk_allow(rxq) == true) {
704 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
705 : : "satisfied. Rx Burst Bulk Alloc function will be "
706 : : "used on port=%d, queue=%d.",
707 : : rxq->port_id, rxq->queue_id);
708 : : } else {
709 : 0 : PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
710 : : "not satisfied, Scattered Rx is requested "
711 : : "on port=%d, queue=%d.",
712 : : rxq->port_id, rxq->queue_id);
713 : 0 : ad->rx_bulk_alloc_allowed = false;
714 : : }
715 : :
716 : : #if defined RTE_ARCH_X86 || defined RTE_ARCH_ARM64
717 : : /* check vector conflict */
718 [ # # # # ]: 0 : if (ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh) &&
719 : 0 : iavf_rxq_vec_setup(rxq)) {
720 : 0 : PMD_DRV_LOG(ERR, "Failed vector rx setup.");
721 : 0 : return -EINVAL;
722 : : }
723 : : #endif
724 : : return 0;
725 : : }
726 : :
727 : : int
728 : 0 : iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
729 : : uint16_t queue_idx,
730 : : uint16_t nb_desc,
731 : : unsigned int socket_id,
732 : : const struct rte_eth_txconf *tx_conf)
733 : : {
734 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
735 : : struct iavf_adapter *adapter =
736 : : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
737 : : struct iavf_info *vf =
738 : : IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
739 : 0 : struct iavf_vsi *vsi = &vf->vsi;
740 : : struct ci_tx_queue *txq;
741 : : const struct rte_memzone *mz;
742 : : uint32_t ring_size;
743 : : uint16_t tx_rs_thresh, tx_free_thresh;
744 : : uint64_t offloads;
745 : :
746 : 0 : PMD_INIT_FUNC_TRACE();
747 : :
748 [ # # ]: 0 : if (adapter->closed)
749 : : return -EIO;
750 : :
751 : 0 : offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
752 : :
753 [ # # ]: 0 : if (nb_desc % IAVF_ALIGN_RING_DESC != 0 ||
754 [ # # ]: 0 : nb_desc > IAVF_MAX_RING_DESC ||
755 : : nb_desc < IAVF_MIN_RING_DESC) {
756 : 0 : PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
757 : : "invalid", nb_desc);
758 : 0 : return -EINVAL;
759 : : }
760 : :
761 [ # # ]: 0 : tx_rs_thresh = (uint16_t)((tx_conf->tx_rs_thresh) ?
762 : : tx_conf->tx_rs_thresh : DEFAULT_TX_RS_THRESH);
763 [ # # ]: 0 : tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
764 : : tx_conf->tx_free_thresh : DEFAULT_TX_FREE_THRESH);
765 [ # # ]: 0 : if (check_tx_thresh(nb_desc, tx_rs_thresh, tx_free_thresh) != 0)
766 : : return -EINVAL;
767 : :
768 : : /* Free memory if needed. */
769 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx]) {
770 : 0 : iavf_dev_tx_queue_release(dev, queue_idx);
771 : 0 : dev->data->tx_queues[queue_idx] = NULL;
772 : : }
773 : :
774 : : /* Allocate the TX queue data structure. */
775 : 0 : txq = rte_zmalloc_socket("iavf txq",
776 : : sizeof(struct ci_tx_queue),
777 : : RTE_CACHE_LINE_SIZE,
778 : : socket_id);
779 [ # # ]: 0 : if (!txq) {
780 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for "
781 : : "tx queue structure");
782 : 0 : return -ENOMEM;
783 : : }
784 : :
785 [ # # ]: 0 : if (adapter->vf.vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2) {
786 : : struct virtchnl_vlan_supported_caps *insertion_support =
787 : : &adapter->vf.vlan_v2_caps.offloads.insertion_support;
788 : : uint32_t insertion_cap;
789 : :
790 [ # # ]: 0 : if (insertion_support->outer)
791 : : insertion_cap = insertion_support->outer;
792 : : else
793 : 0 : insertion_cap = insertion_support->inner;
794 : :
795 [ # # ]: 0 : if (insertion_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1) {
796 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1;
797 : 0 : PMD_INIT_LOG(DEBUG, "VLAN insertion_cap: L2TAG1");
798 [ # # ]: 0 : } else if (insertion_cap & VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2) {
799 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2;
800 : 0 : PMD_INIT_LOG(DEBUG, "VLAN insertion_cap: L2TAG2");
801 : : }
802 : : } else {
803 : 0 : txq->vlan_flag = IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1;
804 : : }
805 : :
806 : 0 : txq->nb_tx_desc = nb_desc;
807 : 0 : txq->tx_rs_thresh = tx_rs_thresh;
808 [ # # ]: 0 : txq->log2_rs_thresh = rte_log2_u32(tx_rs_thresh);
809 : 0 : txq->tx_free_thresh = tx_free_thresh;
810 : 0 : txq->queue_id = queue_idx;
811 : 0 : txq->port_id = dev->data->port_id;
812 : 0 : txq->fast_free_mp = offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE ?
813 [ # # ]: 0 : (void *)UINTPTR_MAX : NULL;
814 : 0 : txq->offloads = offloads;
815 : 0 : txq->tx_deferred_start = tx_conf->tx_deferred_start;
816 : 0 : txq->iavf_vsi = vsi;
817 : :
818 [ # # ]: 0 : if (iavf_ipsec_crypto_supported(adapter))
819 : 0 : txq->ipsec_crypto_pkt_md_offset =
820 : 0 : iavf_security_get_pkt_md_offset(adapter);
821 : :
822 : : /* Allocate software ring */
823 : 0 : txq->sw_ring =
824 : 0 : rte_zmalloc_socket("iavf tx sw ring",
825 : : sizeof(struct ci_tx_entry) * nb_desc,
826 : : RTE_CACHE_LINE_SIZE,
827 : : socket_id);
828 [ # # ]: 0 : if (!txq->sw_ring) {
829 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
830 : 0 : rte_free(txq);
831 : 0 : return -ENOMEM;
832 : : }
833 : :
834 : : /* Allocate RS last_id tracking array */
835 : 0 : uint16_t num_rs_buckets = nb_desc / tx_rs_thresh;
836 : 0 : txq->rs_last_id = rte_zmalloc_socket(NULL, sizeof(txq->rs_last_id[0]) * num_rs_buckets,
837 : : RTE_CACHE_LINE_SIZE, socket_id);
838 [ # # ]: 0 : if (txq->rs_last_id == NULL) {
839 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate memory for RS last_id array");
840 : 0 : rte_free(txq->sw_ring);
841 : 0 : rte_free(txq);
842 : 0 : return -ENOMEM;
843 : : }
844 : :
845 : : /* Allocate TX hardware ring descriptors. */
846 : : ring_size = sizeof(struct ci_tx_desc) * IAVF_MAX_RING_DESC;
847 : : ring_size = RTE_ALIGN(ring_size, IAVF_DMA_MEM_ALIGN);
848 : 0 : mz = rte_eth_dma_zone_reserve(dev, "ci_tx_ring", queue_idx,
849 : : ring_size, IAVF_RING_BASE_ALIGN,
850 : : socket_id);
851 [ # # ]: 0 : if (!mz) {
852 : 0 : PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
853 : 0 : rte_free(txq->sw_ring);
854 : 0 : rte_free(txq);
855 : 0 : return -ENOMEM;
856 : : }
857 : 0 : txq->tx_ring_dma = mz->iova;
858 : 0 : txq->ci_tx_ring = (struct ci_tx_desc *)mz->addr;
859 : :
860 : 0 : txq->mz = mz;
861 : 0 : reset_tx_queue(txq);
862 : 0 : txq->q_set = true;
863 : 0 : dev->data->tx_queues[queue_idx] = txq;
864 : 0 : txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx);
865 : :
866 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
867 [ # # ]: 0 : vf->tm_conf.committed) {
868 : : int tc;
869 [ # # ]: 0 : for (tc = 0; tc < vf->qos_cap->num_elem; tc++) {
870 [ # # ]: 0 : if (txq->queue_id >= vf->qtc_map[tc].start_queue_id &&
871 : 0 : txq->queue_id < (vf->qtc_map[tc].start_queue_id +
872 [ # # ]: 0 : vf->qtc_map[tc].queue_count))
873 : : break;
874 : : }
875 [ # # ]: 0 : if (tc >= vf->qos_cap->num_elem) {
876 : 0 : PMD_INIT_LOG(ERR, "Queue TC mapping is not correct");
877 : 0 : return -EINVAL;
878 : : }
879 : 0 : txq->tc = tc;
880 : : }
881 : :
882 : : return 0;
883 : : }
884 : :
885 : : int
886 : 0 : iavf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
887 : : {
888 : 0 : struct iavf_adapter *adapter =
889 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
890 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
891 : : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
892 : : struct ci_rx_queue *rxq;
893 : : int err = 0;
894 : :
895 : 0 : PMD_DRV_FUNC_TRACE();
896 : :
897 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues)
898 : : return -EINVAL;
899 : :
900 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
901 : :
902 : 0 : err = alloc_rxq_mbufs(rxq);
903 [ # # ]: 0 : if (err) {
904 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
905 : 0 : return err;
906 : : }
907 : :
908 : : rte_wmb();
909 : :
910 : : /* Init the RX tail register. */
911 : 0 : IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
912 : 0 : IAVF_WRITE_FLUSH(hw);
913 : :
914 : : /* Ready to switch the queue on */
915 [ # # ]: 0 : if (!vf->lv_enabled)
916 : 0 : err = iavf_switch_queue(adapter, rx_queue_id, true, true);
917 : : else
918 : 0 : err = iavf_switch_queue_lv(adapter, rx_queue_id, true, true);
919 : :
920 [ # # ]: 0 : if (err) {
921 : 0 : release_rxq_mbufs(rxq);
922 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
923 : : rx_queue_id);
924 : : } else {
925 : 0 : dev->data->rx_queue_state[rx_queue_id] =
926 : : RTE_ETH_QUEUE_STATE_STARTED;
927 : : }
928 : :
929 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.offloads &
930 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
931 [ # # ]: 0 : if (iavf_get_phc_time(rxq)) {
932 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
933 : 0 : return err;
934 : : }
935 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
936 : : }
937 : :
938 : : return err;
939 : : }
940 : :
941 : : int
942 : 0 : iavf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
943 : : {
944 : 0 : struct iavf_adapter *adapter =
945 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
946 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
947 : : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
948 : : struct ci_tx_queue *txq;
949 : : int err = 0;
950 : :
951 : 0 : PMD_DRV_FUNC_TRACE();
952 : :
953 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues)
954 : : return -EINVAL;
955 : :
956 : 0 : txq = dev->data->tx_queues[tx_queue_id];
957 : :
958 : : /* Init the RX tail register. */
959 : 0 : IAVF_PCI_REG_WRITE(txq->qtx_tail, 0);
960 : 0 : IAVF_WRITE_FLUSH(hw);
961 : :
962 : : /* Ready to switch the queue on */
963 [ # # ]: 0 : if (!vf->lv_enabled)
964 : 0 : err = iavf_switch_queue(adapter, tx_queue_id, false, true);
965 : : else
966 : 0 : err = iavf_switch_queue_lv(adapter, tx_queue_id, false, true);
967 : :
968 [ # # ]: 0 : if (err)
969 : 0 : PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
970 : : tx_queue_id);
971 : : else
972 : 0 : dev->data->tx_queue_state[tx_queue_id] =
973 : : RTE_ETH_QUEUE_STATE_STARTED;
974 : :
975 : : return err;
976 : : }
977 : :
978 : : int
979 : 0 : iavf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
980 : : {
981 : 0 : struct iavf_adapter *adapter =
982 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
983 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
984 : : struct ci_rx_queue *rxq;
985 : : int err;
986 : :
987 : 0 : PMD_DRV_FUNC_TRACE();
988 : :
989 [ # # ]: 0 : if (rx_queue_id >= dev->data->nb_rx_queues)
990 : : return -EINVAL;
991 : :
992 [ # # ]: 0 : if (!vf->lv_enabled)
993 : 0 : err = iavf_switch_queue(adapter, rx_queue_id, true, false);
994 : : else
995 : 0 : err = iavf_switch_queue_lv(adapter, rx_queue_id, true, false);
996 : :
997 [ # # ]: 0 : if (err) {
998 : 0 : PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
999 : : rx_queue_id);
1000 : 0 : return err;
1001 : : }
1002 : :
1003 : 0 : rxq = dev->data->rx_queues[rx_queue_id];
1004 : 0 : iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
1005 : 0 : reset_rx_queue(rxq);
1006 : 0 : dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
1007 : :
1008 : 0 : return 0;
1009 : : }
1010 : :
1011 : : int
1012 : 0 : iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1013 : : {
1014 : 0 : struct iavf_adapter *adapter =
1015 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1016 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
1017 : : struct ci_tx_queue *txq;
1018 : : int err;
1019 : :
1020 : 0 : PMD_DRV_FUNC_TRACE();
1021 : :
1022 [ # # ]: 0 : if (tx_queue_id >= dev->data->nb_tx_queues)
1023 : : return -EINVAL;
1024 : :
1025 [ # # ]: 0 : if (!vf->lv_enabled)
1026 : 0 : err = iavf_switch_queue(adapter, tx_queue_id, false, false);
1027 : : else
1028 : 0 : err = iavf_switch_queue_lv(adapter, tx_queue_id, false, false);
1029 : :
1030 [ # # ]: 0 : if (err) {
1031 : 0 : PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
1032 : : tx_queue_id);
1033 : 0 : return err;
1034 : : }
1035 : :
1036 : 0 : txq = dev->data->tx_queues[tx_queue_id];
1037 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1038 : 0 : reset_tx_queue(txq);
1039 : 0 : dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
1040 : :
1041 : 0 : return 0;
1042 : : }
1043 : :
1044 : : void
1045 : 0 : iavf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1046 : : {
1047 : 0 : struct ci_rx_queue *q = dev->data->rx_queues[qid];
1048 : :
1049 [ # # ]: 0 : if (!q)
1050 : : return;
1051 : :
1052 : 0 : iavf_rxq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q);
1053 : 0 : rte_free(q->sw_ring);
1054 : 0 : rte_memzone_free(q->mz);
1055 : 0 : rte_free(q->stats);
1056 : 0 : rte_free(q);
1057 : : }
1058 : :
1059 : : void
1060 : 0 : iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1061 : : {
1062 : 0 : struct ci_tx_queue *q = dev->data->tx_queues[qid];
1063 : :
1064 [ # # ]: 0 : if (!q)
1065 : : return;
1066 : :
1067 : 0 : ci_txq_release_all_mbufs(q, q->use_ctx);
1068 : 0 : rte_free(q->sw_ring);
1069 : 0 : rte_free(q->rs_last_id);
1070 : 0 : rte_memzone_free(q->mz);
1071 : 0 : rte_free(q);
1072 : : }
1073 : :
1074 : : static void
1075 : 0 : iavf_reset_queues(struct rte_eth_dev *dev)
1076 : : {
1077 : : struct ci_rx_queue *rxq;
1078 : : struct ci_tx_queue *txq;
1079 : : int i;
1080 : :
1081 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
1082 : 0 : txq = dev->data->tx_queues[i];
1083 [ # # ]: 0 : if (!txq)
1084 : 0 : continue;
1085 : 0 : ci_txq_release_all_mbufs(txq, txq->use_ctx);
1086 : 0 : reset_tx_queue(txq);
1087 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1088 : : }
1089 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1090 : 0 : rxq = dev->data->rx_queues[i];
1091 [ # # ]: 0 : if (!rxq)
1092 : 0 : continue;
1093 : 0 : iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq);
1094 : 0 : reset_rx_queue(rxq);
1095 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1096 : : }
1097 : 0 : }
1098 : :
1099 : : void
1100 : 0 : iavf_stop_queues(struct rte_eth_dev *dev)
1101 : : {
1102 : 0 : struct iavf_adapter *adapter =
1103 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1104 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
1105 : : int ret;
1106 : :
1107 : : /* adminq will be disabled when vf is resetting. */
1108 [ # # ]: 0 : if (vf->in_reset_recovery) {
1109 : 0 : iavf_reset_queues(dev);
1110 : 0 : return;
1111 : : }
1112 : :
1113 : : /* Stop All queues */
1114 [ # # ]: 0 : if (!vf->lv_enabled) {
1115 : 0 : ret = iavf_disable_queues(adapter);
1116 [ # # ]: 0 : if (ret)
1117 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues");
1118 : : } else {
1119 : 0 : ret = iavf_disable_queues_lv(adapter);
1120 [ # # ]: 0 : if (ret)
1121 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues for large VF");
1122 : : }
1123 : :
1124 [ # # ]: 0 : if (ret)
1125 : 0 : PMD_DRV_LOG(WARNING, "Fail to stop queues");
1126 : :
1127 : 0 : iavf_reset_queues(dev);
1128 : : }
1129 : :
1130 : : #define IAVF_RX_FLEX_ERR0_BITS \
1131 : : ((1 << IAVF_RX_FLEX_DESC_STATUS0_HBO_S) | \
1132 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1133 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1134 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1135 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1136 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_RXE_S))
1137 : :
1138 : : static inline void
1139 : : iavf_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ci_rx_desc *rxdp)
1140 : : {
1141 : 0 : if (rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
1142 : : (1 << IAVF_RX_DESC_STATUS_L2TAG1P_SHIFT)) {
1143 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1144 : 0 : mb->vlan_tci =
1145 : 0 : rte_le_to_cpu_16(rxdp->wb.qword0.lo_dword.l2tag1);
1146 : : } else {
1147 : 0 : mb->vlan_tci = 0;
1148 : : }
1149 : : }
1150 : :
1151 : : static inline void
1152 : 0 : iavf_flex_rxd_to_vlan_tci(struct rte_mbuf *mb,
1153 : : volatile union ci_rx_flex_desc *rxdp)
1154 : : {
1155 [ # # ]: 0 : if (rte_le_to_cpu_64(rxdp->wb.status_error0) &
1156 : : (1 << IAVF_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
1157 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN |
1158 : : RTE_MBUF_F_RX_VLAN_STRIPPED;
1159 : 0 : mb->vlan_tci =
1160 : 0 : rte_le_to_cpu_16(rxdp->wb.l2tag1);
1161 : : } else {
1162 : 0 : mb->vlan_tci = 0;
1163 : : }
1164 : :
1165 [ # # ]: 0 : if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
1166 : : (1 << IAVF_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
1167 [ # # ]: 0 : if ((mb->ol_flags & RTE_MBUF_F_RX_VLAN_STRIPPED) == 0) {
1168 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1169 : : } else {
1170 : : /* if two tags, move Tag1 to outer tag field */
1171 : 0 : mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED | RTE_MBUF_F_RX_QINQ;
1172 : 0 : mb->vlan_tci_outer = mb->vlan_tci;
1173 : : }
1174 : 0 : mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
1175 : : PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
1176 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
1177 : : rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
1178 : : } else {
1179 : 0 : mb->vlan_tci_outer = 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);
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);
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]);
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 : 0 : iavf_calc_context_desc(const struct rte_mbuf *mb, uint8_t vlan_flag, uint8_t lldp_mode)
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_mode))
# # # # #
# ]
2340 : 0 : 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 = IAVF_TX_CTX_DESC_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 = IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD;
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 = IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD;
2362 : 0 : eip_len = m->outer_l3_len >> 2;
2363 : 0 : break;
2364 : 0 : case RTE_MBUF_F_TX_OUTER_IPV6:
2365 : : eip_typ = IAVF_TX_CTX_DESC_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 |= IAVF_TXD_CTX_UDP_TUNNELING;
2381 : 0 : break;
2382 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2383 : 0 : eip_typ |= IAVF_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) << IAVF_TXD_CTX_QW0_NATLEN_SHIFT;
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 & (IAVF_TX_CTX_EXT_IP_IPV6 |
2407 : : IAVF_TX_CTX_EXT_IP_IPV4 |
2408 : 0 : IAVF_TX_CTX_EXT_IP_IPV4_NO_CSUM)) &&
2409 [ # # ]: 0 : (eip_typ & IAVF_TXD_CTX_UDP_TUNNELING) &&
2410 [ # # ]: 0 : (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2411 : 0 : eip_typ |= IAVF_TXD_CTX_QW0_L4T_CS_MASK;
2412 : : }
2413 : :
2414 : 0 : *qw0 = eip_typ << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT |
2415 : 0 : eip_len << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT |
2416 : : eip_noinc << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT;
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, lldp_mode;
2528 : : uint16_t cd_l2tag2 = 0;
2529 : 0 : uint64_t cd_type_cmd = IAVF_TX_DESC_DTYPE_CONTEXT;
2530 : 0 : uint64_t cd_tunneling_params = 0;
2531 : : struct iavf_ipsec_crypto_pkt_metadata *ipsec_md = NULL;
2532 : :
2533 : : /* Use IAVF-specific flags from txq */
2534 : 0 : iavf_vlan_flag = txq->vlan_flag;
2535 : 0 : lldp_mode = txq->lldp_mode;
2536 : :
2537 : : /* Check if context descriptor is needed using existing IAVF logic */
2538 [ # # ]: 0 : if (!iavf_calc_context_desc(mbuf, iavf_vlan_flag, lldp_mode))
2539 : : return 0;
2540 : :
2541 : : /* Get IPsec metadata if needed */
2542 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
2543 : 0 : ipsec_md = RTE_MBUF_DYNFIELD(mbuf, txq->ipsec_crypto_pkt_md_offset,
2544 : : struct iavf_ipsec_crypto_pkt_metadata *);
2545 : : }
2546 : :
2547 : : /* TSO command field */
2548 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
2549 : 0 : cd_type_cmd |= (uint64_t)CI_TX_CTX_DESC_TSO << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2550 : :
2551 : : /* IPsec field for TSO */
2552 [ # # # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD && ipsec_md) {
2553 : 0 : uint64_t ipsec_field = (uint64_t)ipsec_md->ctx_desc_ipsec_params <<
2554 : : IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT;
2555 : 0 : cd_type_cmd |= ipsec_field;
2556 : : }
2557 : :
2558 : : /* TSO segmentation field */
2559 : 0 : iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd, ol_flags, mbuf, ipsec_md);
2560 : : }
2561 : :
2562 : : /* VLAN field for L2TAG2 */
2563 [ # # # # ]: 0 : if ((ol_flags & RTE_MBUF_F_TX_VLAN &&
2564 : 0 : iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) ||
2565 [ # # ]: 0 : ol_flags & RTE_MBUF_F_TX_QINQ) {
2566 : 0 : cd_type_cmd |= (uint64_t)CI_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2567 : : }
2568 : :
2569 : : /* LLDP switching field */
2570 [ # # # # : 0 : if (IAVF_CHECK_TX_LLDP(mbuf, lldp_mode))
# # # # #
# ]
2571 : 0 : cd_type_cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2572 : :
2573 : : /* Tunneling field */
2574 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2575 : 0 : iavf_fill_ctx_desc_tunnelling_field(&cd_tunneling_params, ol_flags, mbuf);
2576 : :
2577 : : /* L2TAG2 field (VLAN) */
2578 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_QINQ) {
2579 [ # # ]: 0 : cd_l2tag2 = iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ?
2580 : : mbuf->vlan_tci_outer : mbuf->vlan_tci;
2581 [ # # # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_VLAN &&
2582 : : iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2583 : 0 : cd_l2tag2 = mbuf->vlan_tci;
2584 : : }
2585 : :
2586 : : /* Set outputs */
2587 : 0 : *qw0 = rte_cpu_to_le_64(cd_tunneling_params | ((uint64_t)cd_l2tag2 << 32));
2588 : 0 : *qw1 = rte_cpu_to_le_64(cd_type_cmd);
2589 : :
2590 : 0 : return 1; /* One context descriptor needed */
2591 : : }
2592 : :
2593 : : /* TX function */
2594 : : uint16_t
2595 : 0 : iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2596 : : {
2597 : : struct ci_tx_queue *txq = tx_queue;
2598 : :
2599 : 0 : const struct ci_ipsec_ops ipsec_ops = {
2600 : : .get_ipsec_desc = iavf_get_ipsec_desc,
2601 : : .calc_segment_len = iavf_calc_ipsec_segment_len,
2602 : : };
2603 : :
2604 : : /* IAVF does not support timestamp queues, so pass NULL for ts_fns */
2605 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts,
2606 : 0 : (txq->vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) ?
2607 : : CI_VLAN_IN_L2TAG1 : CI_VLAN_IN_L2TAG2,
2608 : : iavf_get_context_desc, &ipsec_ops, NULL);
2609 : : }
2610 : :
2611 : : /* Check if the packet with vlan user priority is transmitted in the
2612 : : * correct queue.
2613 : : */
2614 : : static int
2615 : : iavf_check_vlan_up2tc(struct ci_tx_queue *txq, struct rte_mbuf *m)
2616 : : {
2617 : : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
2618 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2619 : : uint16_t up;
2620 : :
2621 : 0 : up = m->vlan_tci >> IAVF_VLAN_TAG_PCP_OFFSET;
2622 : :
2623 [ # # ]: 0 : if (!(vf->qos_cap->cap[txq->tc].tc_prio & BIT(up))) {
2624 : : PMD_TX_LOG(ERR, "packet with vlan pcp %u cannot transmit in queue %u",
2625 : : up, txq->queue_id);
2626 : : return -1;
2627 : : } else {
2628 : : return 0;
2629 : : }
2630 : : }
2631 : :
2632 : : /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
2633 : : static inline void
2634 : : parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
2635 : : {
2636 : : struct rte_tcp_hdr *tcp_hdr;
2637 : :
2638 : : info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
2639 : : info->l4_proto = ipv4_hdr->next_proto_id;
2640 : :
2641 : : /* only fill l4_len for TCP, it's useful for TSO */
2642 : : if (info->l4_proto == IPPROTO_TCP) {
2643 : : tcp_hdr = (struct rte_tcp_hdr *)
2644 : : ((char *)ipv4_hdr + info->l3_len);
2645 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
2646 : : } else if (info->l4_proto == IPPROTO_UDP) {
2647 : : info->l4_len = sizeof(struct rte_udp_hdr);
2648 : : } else {
2649 : : info->l4_len = 0;
2650 : : }
2651 : : }
2652 : :
2653 : : /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
2654 : : static inline void
2655 : : parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
2656 : : {
2657 : : struct rte_tcp_hdr *tcp_hdr;
2658 : :
2659 : : info->l3_len = sizeof(struct rte_ipv6_hdr);
2660 : : info->l4_proto = ipv6_hdr->proto;
2661 : :
2662 : : /* only fill l4_len for TCP, it's useful for TSO */
2663 : : if (info->l4_proto == IPPROTO_TCP) {
2664 : : tcp_hdr = (struct rte_tcp_hdr *)
2665 : : ((char *)ipv6_hdr + info->l3_len);
2666 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
2667 : : } else if (info->l4_proto == IPPROTO_UDP) {
2668 : : info->l4_len = sizeof(struct rte_udp_hdr);
2669 : : } else {
2670 : : info->l4_len = 0;
2671 : : }
2672 : : }
2673 : :
2674 : : /*
2675 : : * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
2676 : : * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
2677 : : * headers. The l4_len argument is only set in case of TCP (useful for TSO).
2678 : : */
2679 : : static inline void
2680 : : parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
2681 : : {
2682 : : struct rte_ipv4_hdr *ipv4_hdr;
2683 : : struct rte_ipv6_hdr *ipv6_hdr;
2684 : : struct rte_vlan_hdr *vlan_hdr;
2685 : :
2686 : : info->l2_len = sizeof(struct rte_ether_hdr);
2687 : : info->ethertype = eth_hdr->ether_type;
2688 : :
2689 : : while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
2690 : : info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
2691 : : vlan_hdr = (struct rte_vlan_hdr *)
2692 : : ((char *)eth_hdr + info->l2_len);
2693 : : info->l2_len += sizeof(struct rte_vlan_hdr);
2694 : : info->ethertype = vlan_hdr->eth_proto;
2695 : : }
2696 : :
2697 : : switch (info->ethertype) {
2698 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV4):
2699 : : ipv4_hdr = (struct rte_ipv4_hdr *)
2700 : : ((char *)eth_hdr + info->l2_len);
2701 : : parse_ipv4(ipv4_hdr, info);
2702 : : break;
2703 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV6):
2704 : : ipv6_hdr = (struct rte_ipv6_hdr *)
2705 : : ((char *)eth_hdr + info->l2_len);
2706 : : parse_ipv6(ipv6_hdr, info);
2707 : : break;
2708 : : default:
2709 : : info->l4_len = 0;
2710 : : info->l3_len = 0;
2711 : : info->l4_proto = 0;
2712 : : break;
2713 : : }
2714 : : }
2715 : :
2716 : : /* Fill in outer layers length */
2717 : : static inline void
2718 : : update_tunnel_outer(struct offload_info *info)
2719 : : {
2720 : : info->is_tunnel = 1;
2721 : : info->outer_ethertype = info->ethertype;
2722 : : info->outer_l2_len = info->l2_len;
2723 : : info->outer_l3_len = info->l3_len;
2724 : : info->outer_l4_proto = info->l4_proto;
2725 : : }
2726 : :
2727 : : /*
2728 : : * Parse a GTP protocol header.
2729 : : * No optional fields and next extension header type.
2730 : : */
2731 : : static inline void
2732 : : parse_gtp(struct rte_udp_hdr *udp_hdr,
2733 : : struct offload_info *info)
2734 : : {
2735 : : struct rte_ipv4_hdr *ipv4_hdr;
2736 : : struct rte_ipv6_hdr *ipv6_hdr;
2737 : : struct rte_gtp_hdr *gtp_hdr;
2738 : : uint8_t gtp_len = sizeof(*gtp_hdr);
2739 : : uint8_t ip_ver;
2740 : :
2741 : : /* Check UDP destination port. */
2742 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
2743 : : udp_hdr->src_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
2744 : : udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPU_UDP_PORT))
2745 : : return;
2746 : :
2747 : : update_tunnel_outer(info);
2748 : : info->l2_len = 0;
2749 : :
2750 : : gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr +
2751 : : sizeof(struct rte_udp_hdr));
2752 : :
2753 : : /*
2754 : : * Check message type. If message type is 0xff, it is
2755 : : * a GTP data packet. If not, it is a GTP control packet
2756 : : */
2757 : : if (gtp_hdr->msg_type == 0xff) {
2758 : : ip_ver = *(uint8_t *)((char *)udp_hdr +
2759 : : sizeof(struct rte_udp_hdr) +
2760 : : sizeof(struct rte_gtp_hdr));
2761 : : ip_ver = (ip_ver) & 0xf0;
2762 : :
2763 : : if (ip_ver == RTE_GTP_TYPE_IPV4) {
2764 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gtp_hdr +
2765 : : gtp_len);
2766 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2767 : : parse_ipv4(ipv4_hdr, info);
2768 : : } else if (ip_ver == RTE_GTP_TYPE_IPV6) {
2769 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gtp_hdr +
2770 : : gtp_len);
2771 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2772 : : parse_ipv6(ipv6_hdr, info);
2773 : : }
2774 : : } else {
2775 : : info->ethertype = 0;
2776 : : info->l4_len = 0;
2777 : : info->l3_len = 0;
2778 : : info->l4_proto = 0;
2779 : : }
2780 : :
2781 : : info->l2_len += RTE_ETHER_GTP_HLEN;
2782 : : }
2783 : :
2784 : : /* Parse a VXLAN header */
2785 : : static inline void
2786 : : parse_vxlan(struct rte_udp_hdr *udp_hdr,
2787 : : struct offload_info *info)
2788 : : {
2789 : : struct rte_ether_hdr *eth_hdr;
2790 : :
2791 : : /* check UDP destination port, RTE_VXLAN_DEFAULT_PORT (4789) is the
2792 : : * default VXLAN port (rfc7348) or that the Rx offload flag is set
2793 : : * (i40e only currently)
2794 : : */
2795 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT))
2796 : : return;
2797 : :
2798 : : update_tunnel_outer(info);
2799 : :
2800 : : eth_hdr = (struct rte_ether_hdr *)((char *)udp_hdr +
2801 : : sizeof(struct rte_udp_hdr) +
2802 : : sizeof(struct rte_vxlan_hdr));
2803 : :
2804 : : parse_ethernet(eth_hdr, info);
2805 : : info->l2_len += RTE_ETHER_VXLAN_HLEN; /* add UDP + VXLAN */
2806 : : }
2807 : :
2808 : : /* Parse a VXLAN-GPE header */
2809 : : static inline void
2810 : : parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr,
2811 : : struct offload_info *info)
2812 : : {
2813 : : struct rte_ether_hdr *eth_hdr;
2814 : : struct rte_ipv4_hdr *ipv4_hdr;
2815 : : struct rte_ipv6_hdr *ipv6_hdr;
2816 : : struct rte_vxlan_gpe_hdr *vxlan_gpe_hdr;
2817 : : uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
2818 : :
2819 : : /* Check UDP destination port. */
2820 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(vxlan_gpe_udp_port))
2821 : : return;
2822 : :
2823 : : vxlan_gpe_hdr = (struct rte_vxlan_gpe_hdr *)((char *)udp_hdr +
2824 : : sizeof(struct rte_udp_hdr));
2825 : :
2826 : : if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
2827 : : RTE_VXLAN_GPE_TYPE_IPV4) {
2828 : : update_tunnel_outer(info);
2829 : :
2830 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)vxlan_gpe_hdr +
2831 : : vxlan_gpe_len);
2832 : :
2833 : : parse_ipv4(ipv4_hdr, info);
2834 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2835 : : info->l2_len = 0;
2836 : :
2837 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV6) {
2838 : : update_tunnel_outer(info);
2839 : :
2840 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)vxlan_gpe_hdr +
2841 : : vxlan_gpe_len);
2842 : :
2843 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2844 : : parse_ipv6(ipv6_hdr, info);
2845 : : info->l2_len = 0;
2846 : :
2847 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_ETH) {
2848 : : update_tunnel_outer(info);
2849 : :
2850 : : eth_hdr = (struct rte_ether_hdr *)((char *)vxlan_gpe_hdr +
2851 : : vxlan_gpe_len);
2852 : :
2853 : : parse_ethernet(eth_hdr, info);
2854 : : } else {
2855 : : return;
2856 : : }
2857 : :
2858 : : info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN;
2859 : : }
2860 : :
2861 : : /* Parse a GENEVE header */
2862 : : static inline void
2863 : : parse_geneve(struct rte_udp_hdr *udp_hdr,
2864 : : struct offload_info *info)
2865 : : {
2866 : : struct rte_ether_hdr *eth_hdr;
2867 : : struct rte_ipv4_hdr *ipv4_hdr;
2868 : : struct rte_ipv6_hdr *ipv6_hdr;
2869 : : struct rte_geneve_hdr *geneve_hdr;
2870 : : uint16_t geneve_len;
2871 : :
2872 : : /* Check UDP destination port. */
2873 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(geneve_udp_port))
2874 : : return;
2875 : :
2876 : : geneve_hdr = (struct rte_geneve_hdr *)((char *)udp_hdr +
2877 : : sizeof(struct rte_udp_hdr));
2878 : : geneve_len = sizeof(struct rte_geneve_hdr) + geneve_hdr->opt_len * 4;
2879 : : if (!geneve_hdr->proto || geneve_hdr->proto ==
2880 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
2881 : : update_tunnel_outer(info);
2882 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)geneve_hdr +
2883 : : geneve_len);
2884 : : parse_ipv4(ipv4_hdr, info);
2885 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2886 : : info->l2_len = 0;
2887 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
2888 : : update_tunnel_outer(info);
2889 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)geneve_hdr +
2890 : : geneve_len);
2891 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2892 : : parse_ipv6(ipv6_hdr, info);
2893 : : info->l2_len = 0;
2894 : :
2895 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_GENEVE_TYPE_ETH)) {
2896 : : update_tunnel_outer(info);
2897 : : eth_hdr = (struct rte_ether_hdr *)((char *)geneve_hdr +
2898 : : geneve_len);
2899 : : parse_ethernet(eth_hdr, info);
2900 : : } else {
2901 : : return;
2902 : : }
2903 : :
2904 : : info->l2_len +=
2905 : : (sizeof(struct rte_udp_hdr) + sizeof(struct rte_geneve_hdr) +
2906 : : ((struct rte_geneve_hdr *)geneve_hdr)->opt_len * 4);
2907 : : }
2908 : :
2909 : : /* Parse a GRE header */
2910 : : static inline void
2911 : : parse_gre(struct simple_gre_hdr *gre_hdr, struct offload_info *info)
2912 : : {
2913 : : struct rte_ether_hdr *eth_hdr;
2914 : : struct rte_ipv4_hdr *ipv4_hdr;
2915 : : struct rte_ipv6_hdr *ipv6_hdr;
2916 : : uint8_t gre_len = 0;
2917 : :
2918 : : gre_len += sizeof(struct simple_gre_hdr);
2919 : :
2920 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_KEY_PRESENT))
2921 : : gre_len += GRE_EXT_LEN;
2922 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_SEQUENCE_PRESENT))
2923 : : gre_len += GRE_EXT_LEN;
2924 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_CHECKSUM_PRESENT))
2925 : : gre_len += GRE_EXT_LEN;
2926 : :
2927 : : if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
2928 : : update_tunnel_outer(info);
2929 : :
2930 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gre_hdr + gre_len);
2931 : :
2932 : : parse_ipv4(ipv4_hdr, info);
2933 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2934 : : info->l2_len = 0;
2935 : :
2936 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
2937 : : update_tunnel_outer(info);
2938 : :
2939 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gre_hdr + gre_len);
2940 : :
2941 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2942 : : parse_ipv6(ipv6_hdr, info);
2943 : : info->l2_len = 0;
2944 : :
2945 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_TEB)) {
2946 : : update_tunnel_outer(info);
2947 : :
2948 : : eth_hdr = (struct rte_ether_hdr *)((char *)gre_hdr + gre_len);
2949 : :
2950 : : parse_ethernet(eth_hdr, info);
2951 : : } else {
2952 : : return;
2953 : : }
2954 : :
2955 : : info->l2_len += gre_len;
2956 : : }
2957 : :
2958 : : /* Parse an encapsulated IP or IPv6 header */
2959 : : static inline void
2960 : : parse_encap_ip(void *encap_ip, struct offload_info *info)
2961 : : {
2962 : : struct rte_ipv4_hdr *ipv4_hdr = encap_ip;
2963 : : struct rte_ipv6_hdr *ipv6_hdr = encap_ip;
2964 : : uint8_t ip_version;
2965 : :
2966 : : ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4;
2967 : :
2968 : : if (ip_version != 4 && ip_version != 6)
2969 : : return;
2970 : :
2971 : : info->is_tunnel = 1;
2972 : : info->outer_ethertype = info->ethertype;
2973 : : info->outer_l2_len = info->l2_len;
2974 : : info->outer_l3_len = info->l3_len;
2975 : :
2976 : : if (ip_version == 4) {
2977 : : parse_ipv4(ipv4_hdr, info);
2978 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2979 : : } else {
2980 : : parse_ipv6(ipv6_hdr, info);
2981 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2982 : : }
2983 : : info->l2_len = 0;
2984 : : }
2985 : :
2986 : : static inline int
2987 : : check_mbuf_len(struct offload_info *info, struct rte_mbuf *m)
2988 : : {
2989 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2990 : : if (info->outer_l2_len != m->outer_l2_len) {
2991 : : PMD_TX_LOG(ERR, "outer_l2_len error in mbuf. Original "
2992 : : "length: %hu, calculated length: %u", m->outer_l2_len,
2993 : : info->outer_l2_len);
2994 : : return -1;
2995 : : }
2996 : : if (info->outer_l3_len != m->outer_l3_len) {
2997 : : PMD_TX_LOG(ERR, "outer_l3_len error in mbuf. Original "
2998 : : "length: %hu,calculated length: %u", m->outer_l3_len,
2999 : : info->outer_l3_len);
3000 : : return -1;
3001 : : }
3002 : : }
3003 : :
3004 : : if (info->l2_len != m->l2_len) {
3005 : : PMD_TX_LOG(ERR, "l2_len error in mbuf. Original "
3006 : : "length: %hu, calculated length: %u", m->l2_len,
3007 : : info->l2_len);
3008 : : return -1;
3009 : : }
3010 : : if (info->l3_len != m->l3_len) {
3011 : : PMD_TX_LOG(ERR, "l3_len error in mbuf. Original "
3012 : : "length: %hu, calculated length: %u", m->l3_len,
3013 : : info->l3_len);
3014 : : return -1;
3015 : : }
3016 : : if (info->l4_len != m->l4_len) {
3017 : : PMD_TX_LOG(ERR, "l4_len error in mbuf. Original "
3018 : : "length: %hu, calculated length: %u", m->l4_len,
3019 : : info->l4_len);
3020 : : return -1;
3021 : : }
3022 : :
3023 : : return 0;
3024 : : }
3025 : :
3026 : : static inline int
3027 : : check_ether_type(struct offload_info *info, struct rte_mbuf *m)
3028 : : {
3029 : : int ret = 0;
3030 : :
3031 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3032 : : if (info->outer_ethertype ==
3033 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3034 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)) {
3035 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, "
3036 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV4` flag.");
3037 : : ret = -1;
3038 : : }
3039 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6) {
3040 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, tx "
3041 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV6` flag");
3042 : : ret = -1;
3043 : : }
3044 : : } else if (info->outer_ethertype ==
3045 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3046 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)) {
3047 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, "
3048 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV6` flag.");
3049 : : ret = -1;
3050 : : }
3051 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) {
3052 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, tx "
3053 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV4` flag");
3054 : : ret = -1;
3055 : : }
3056 : : }
3057 : : }
3058 : :
3059 : : if (info->ethertype ==
3060 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3061 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV4)) {
3062 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx offload "
3063 : : "missing `RTE_MBUF_F_TX_IPV4` flag.");
3064 : : ret = -1;
3065 : : }
3066 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV6) {
3067 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx "
3068 : : "offload contains wrong `RTE_MBUF_F_TX_IPV6` flag");
3069 : : ret = -1;
3070 : : }
3071 : : } else if (info->ethertype ==
3072 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3073 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV6)) {
3074 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3075 : : "missing `RTE_MBUF_F_TX_IPV6` flag.");
3076 : : ret = -1;
3077 : : }
3078 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
3079 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3080 : : "contains wrong `RTE_MBUF_F_TX_IPV4` flag");
3081 : : ret = -1;
3082 : : }
3083 : : }
3084 : :
3085 : : return ret;
3086 : : }
3087 : :
3088 : : /* Check whether the parameters of mbuf are correct. */
3089 : : __rte_unused static inline int
3090 : : iavf_check_mbuf(struct rte_mbuf *m)
3091 : : {
3092 : : struct rte_ether_hdr *eth_hdr;
3093 : : void *l3_hdr = NULL; /* can be IPv4 or IPv6 */
3094 : : struct offload_info info = {0};
3095 : : uint64_t ol_flags = m->ol_flags;
3096 : : uint64_t tunnel_type = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK;
3097 : :
3098 : : eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
3099 : : parse_ethernet(eth_hdr, &info);
3100 : : l3_hdr = (char *)eth_hdr + info.l2_len;
3101 : : if (info.l4_proto == IPPROTO_UDP) {
3102 : : struct rte_udp_hdr *udp_hdr;
3103 : :
3104 : : udp_hdr = (struct rte_udp_hdr *)
3105 : : ((char *)l3_hdr + info.l3_len);
3106 : : parse_gtp(udp_hdr, &info);
3107 : : if (info.is_tunnel) {
3108 : : if (!tunnel_type) {
3109 : : PMD_TX_LOG(ERR, "gtp tunnel packet missing tx "
3110 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GTP` flag.");
3111 : : return -1;
3112 : : }
3113 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GTP) {
3114 : : PMD_TX_LOG(ERR, "gtp tunnel packet, tx offload has wrong "
3115 : : "`%s` flag, correct is `RTE_MBUF_F_TX_TUNNEL_GTP` flag",
3116 : : rte_get_tx_ol_flag_name(tunnel_type));
3117 : : return -1;
3118 : : }
3119 : : goto check_len;
3120 : : }
3121 : : parse_vxlan_gpe(udp_hdr, &info);
3122 : : if (info.is_tunnel) {
3123 : : if (!tunnel_type) {
3124 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet missing tx "
3125 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag.");
3126 : : return -1;
3127 : : }
3128 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE) {
3129 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet, tx offload has "
3130 : : "wrong `%s` flag, correct is "
3131 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag",
3132 : : rte_get_tx_ol_flag_name(tunnel_type));
3133 : : return -1;
3134 : : }
3135 : : goto check_len;
3136 : : }
3137 : : parse_vxlan(udp_hdr, &info);
3138 : : if (info.is_tunnel) {
3139 : : if (!tunnel_type) {
3140 : : PMD_TX_LOG(ERR, "vxlan tunnel packet missing tx "
3141 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN` flag.");
3142 : : return -1;
3143 : : }
3144 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN) {
3145 : : PMD_TX_LOG(ERR, "vxlan tunnel packet, tx offload has "
3146 : : "wrong `%s` flag, correct is "
3147 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN` flag",
3148 : : rte_get_tx_ol_flag_name(tunnel_type));
3149 : : return -1;
3150 : : }
3151 : : goto check_len;
3152 : : }
3153 : : parse_geneve(udp_hdr, &info);
3154 : : if (info.is_tunnel) {
3155 : : if (!tunnel_type) {
3156 : : PMD_TX_LOG(ERR, "geneve tunnel packet missing tx "
3157 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GENEVE` flag.");
3158 : : return -1;
3159 : : }
3160 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GENEVE) {
3161 : : PMD_TX_LOG(ERR, "geneve tunnel packet, tx offload has "
3162 : : "wrong `%s` flag, correct is "
3163 : : "`RTE_MBUF_F_TX_TUNNEL_GENEVE` flag",
3164 : : rte_get_tx_ol_flag_name(tunnel_type));
3165 : : return -1;
3166 : : }
3167 : : goto check_len;
3168 : : }
3169 : : /* Always keep last. */
3170 : : if (unlikely(RTE_ETH_IS_TUNNEL_PKT(m->packet_type)
3171 : : != 0)) {
3172 : : PMD_TX_LOG(ERR, "Unknown tunnel packet. UDP dst port: %hu",
3173 : : udp_hdr->dst_port);
3174 : : return -1;
3175 : : }
3176 : : } else if (info.l4_proto == IPPROTO_GRE) {
3177 : : struct simple_gre_hdr *gre_hdr;
3178 : :
3179 : : gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr +
3180 : : info.l3_len);
3181 : : parse_gre(gre_hdr, &info);
3182 : : if (info.is_tunnel) {
3183 : : if (!tunnel_type) {
3184 : : PMD_TX_LOG(ERR, "gre tunnel packet missing tx "
3185 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GRE` flag.");
3186 : : return -1;
3187 : : }
3188 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GRE) {
3189 : : PMD_TX_LOG(ERR, "gre tunnel packet, tx offload has "
3190 : : "wrong `%s` flag, correct is "
3191 : : "`RTE_MBUF_F_TX_TUNNEL_GRE` flag",
3192 : : rte_get_tx_ol_flag_name(tunnel_type));
3193 : : return -1;
3194 : : }
3195 : : goto check_len;
3196 : : }
3197 : : } else if (info.l4_proto == IPPROTO_IPIP) {
3198 : : void *encap_ip_hdr;
3199 : :
3200 : : encap_ip_hdr = (char *)l3_hdr + info.l3_len;
3201 : : parse_encap_ip(encap_ip_hdr, &info);
3202 : : if (info.is_tunnel) {
3203 : : if (!tunnel_type) {
3204 : : PMD_TX_LOG(ERR, "Ipip tunnel packet missing tx "
3205 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_IPIP` flag.");
3206 : : return -1;
3207 : : }
3208 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_IPIP) {
3209 : : PMD_TX_LOG(ERR, "Ipip tunnel packet, tx offload has "
3210 : : "wrong `%s` flag, correct is "
3211 : : "`RTE_MBUF_F_TX_TUNNEL_IPIP` flag",
3212 : : rte_get_tx_ol_flag_name(tunnel_type));
3213 : : return -1;
3214 : : }
3215 : : goto check_len;
3216 : : }
3217 : : }
3218 : :
3219 : : check_len:
3220 : : if (check_mbuf_len(&info, m) != 0)
3221 : : return -1;
3222 : :
3223 : : return check_ether_type(&info, m);
3224 : : }
3225 : :
3226 : : /* TX prep functions */
3227 : : uint16_t
3228 : 0 : iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
3229 : : uint16_t nb_pkts)
3230 : : {
3231 : : int i, ret;
3232 : : uint64_t ol_flags;
3233 : : struct rte_mbuf *m;
3234 : : struct ci_tx_queue *txq = tx_queue;
3235 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
3236 : 0 : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3237 : : struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3238 : :
3239 [ # # ]: 0 : if (adapter->closed)
3240 : : return 0;
3241 : :
3242 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3243 : 0 : m = tx_pkts[i];
3244 : 0 : ol_flags = m->ol_flags;
3245 : :
3246 : : /* Validate segment count and packet length. */
3247 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3248 [ # # # # ]: 0 : if (m->nb_segs > IAVF_TX_MAX_MTU_SEG || m->pkt_len > IAVF_FRAME_SIZE_MAX) {
3249 : 0 : rte_errno = EINVAL;
3250 : 0 : return i;
3251 : : }
3252 [ # # ]: 0 : } else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
3253 : 0 : (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
3254 [ # # ]: 0 : (m->nb_segs > txq->nb_tx_desc)) {
3255 : : /* MSS outside the range are considered malicious */
3256 : 0 : rte_errno = EINVAL;
3257 : 0 : return i;
3258 : : }
3259 : :
3260 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3261 : 0 : rte_errno = ENOTSUP;
3262 : 0 : return i;
3263 : : }
3264 : :
3265 : : /* valid packets are greater than min size, and single-buffer pkts
3266 : : * must have data_len == pkt_len
3267 : : */
3268 [ # # ]: 0 : if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
3269 [ # # # # ]: 0 : (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
3270 : 0 : rte_errno = EINVAL;
3271 : 0 : return i;
3272 : : }
3273 : :
3274 : : #ifdef RTE_ETHDEV_DEBUG_TX
3275 : : ret = rte_validate_tx_offload(m);
3276 : : if (ret != 0) {
3277 : : rte_errno = -ret;
3278 : : return i;
3279 : : }
3280 : : #endif
3281 : : ret = rte_net_intel_cksum_prepare(m);
3282 [ # # ]: 0 : if (ret != 0) {
3283 : 0 : rte_errno = -ret;
3284 : 0 : return i;
3285 : : }
3286 : :
3287 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
3288 [ # # ]: 0 : ol_flags & (RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN)) {
3289 : : ret = iavf_check_vlan_up2tc(txq, m);
3290 : : if (ret != 0) {
3291 : 0 : rte_errno = -ret;
3292 : 0 : return i;
3293 : : }
3294 : : }
3295 : :
3296 : : #ifdef RTE_ETHDEV_DEBUG_TX
3297 : : ret = iavf_check_mbuf(m);
3298 : : if (ret != 0) {
3299 : : rte_errno = EINVAL;
3300 : : return i;
3301 : : }
3302 : : #endif
3303 : : }
3304 : :
3305 : 0 : return i;
3306 : : }
3307 : :
3308 : : static uint16_t
3309 : : iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
3310 : : uint16_t nb_pkts);
3311 : : static uint16_t
3312 : : iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
3313 : : uint16_t nb_pkts);
3314 : :
3315 : : static const struct ci_rx_path_info iavf_rx_path_infos[] = {
3316 : : [IAVF_RX_DISABLED] = {
3317 : : .pkt_burst = iavf_recv_pkts_no_poll,
3318 : : .info = "Disabled",
3319 : : .features = {
3320 : : .disabled = true
3321 : : }
3322 : : },
3323 : : [IAVF_RX_DEFAULT] = {
3324 : : .pkt_burst = iavf_recv_pkts,
3325 : : .info = "Scalar",
3326 : : .features = {
3327 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS
3328 : : }
3329 : : },
3330 : : [IAVF_RX_SCATTERED] = {
3331 : : .pkt_burst = iavf_recv_scattered_pkts,
3332 : : .info = "Scalar Scattered",
3333 : : .features = {
3334 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3335 : : .scattered = true
3336 : : }
3337 : : },
3338 : : [IAVF_RX_FLEX_RXD] = {
3339 : : .pkt_burst = iavf_recv_pkts_flex_rxd,
3340 : : .info = "Scalar Flex",
3341 : : .features = {
3342 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS,
3343 : : .flex_desc = true
3344 : : }
3345 : : },
3346 : : [IAVF_RX_SCATTERED_FLEX_RXD] = {
3347 : : .pkt_burst = iavf_recv_scattered_pkts_flex_rxd,
3348 : : .info = "Scalar Scattered Flex",
3349 : : .features = {
3350 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3351 : : .scattered = true,
3352 : : .flex_desc = true
3353 : : }
3354 : : },
3355 : : [IAVF_RX_BULK_ALLOC] = {
3356 : : .pkt_burst = iavf_recv_pkts_bulk_alloc,
3357 : : .info = "Scalar Bulk Alloc",
3358 : : .features = {
3359 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS,
3360 : : .bulk_alloc = true
3361 : : }
3362 : : },
3363 : : [IAVF_RX_BULK_ALLOC_FLEX_RXD] = {
3364 : : .pkt_burst = iavf_recv_pkts_bulk_alloc,
3365 : : .info = "Scalar Bulk Alloc Flex",
3366 : : .features = {
3367 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS,
3368 : : .flex_desc = true,
3369 : : .bulk_alloc = true
3370 : : }
3371 : : },
3372 : : #ifdef RTE_ARCH_X86
3373 : : [IAVF_RX_AVX2] = {
3374 : : .pkt_burst = iavf_recv_pkts_vec_avx2,
3375 : : .info = "Vector AVX2",
3376 : : .features = {
3377 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS,
3378 : : .simd_width = RTE_VECT_SIMD_256,
3379 : : .bulk_alloc = true
3380 : : }
3381 : : },
3382 : : [IAVF_RX_AVX2_SCATTERED] = {
3383 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2,
3384 : : .info = "Vector Scattered AVX2",
3385 : : .features = {
3386 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3387 : : .simd_width = RTE_VECT_SIMD_256,
3388 : : .scattered = true,
3389 : : .bulk_alloc = true
3390 : : }
3391 : : },
3392 : : [IAVF_RX_AVX2_OFFLOAD] = {
3393 : : .pkt_burst = iavf_recv_pkts_vec_avx2_offload,
3394 : : .info = "Vector AVX2 Offload",
3395 : : .features = {
3396 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS,
3397 : : .simd_width = RTE_VECT_SIMD_256,
3398 : : .bulk_alloc = true
3399 : : }
3400 : : },
3401 : : [IAVF_RX_AVX2_SCATTERED_OFFLOAD] = {
3402 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_offload,
3403 : : .info = "Vector Scattered AVX2 Offload",
3404 : : .features = {
3405 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3406 : : .simd_width = RTE_VECT_SIMD_256,
3407 : : .scattered = true,
3408 : : .bulk_alloc = true
3409 : : }
3410 : : },
3411 : : [IAVF_RX_AVX2_FLEX_RXD] = {
3412 : : .pkt_burst = iavf_recv_pkts_vec_avx2_flex_rxd,
3413 : : .info = "Vector AVX2 Flex",
3414 : : .features = {
3415 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS,
3416 : : .simd_width = RTE_VECT_SIMD_256,
3417 : : .flex_desc = true,
3418 : : .bulk_alloc = true
3419 : : }
3420 : : },
3421 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD] = {
3422 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
3423 : : .info = "Vector Scattered AVX2 Flex",
3424 : : .features = {
3425 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3426 : : .simd_width = RTE_VECT_SIMD_256,
3427 : : .scattered = true,
3428 : : .flex_desc = true,
3429 : : .bulk_alloc = true
3430 : : }
3431 : : },
3432 : : [IAVF_RX_AVX2_FLEX_RXD_OFFLOAD] = {
3433 : : .pkt_burst = iavf_recv_pkts_vec_avx2_flex_rxd_offload,
3434 : : .info = "Vector AVX2 Flex Offload",
3435 : : .features = {
3436 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS,
3437 : : .simd_width = RTE_VECT_SIMD_256,
3438 : : .flex_desc = true,
3439 : : .bulk_alloc = true
3440 : : }
3441 : : },
3442 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD] = {
3443 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
3444 : : .info = "Vector Scattered AVX2 Flex Offload",
3445 : : .features = {
3446 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS |
3447 : : RTE_ETH_RX_OFFLOAD_SCATTER,
3448 : : .simd_width = RTE_VECT_SIMD_256,
3449 : : .scattered = true,
3450 : : .flex_desc = true,
3451 : : .bulk_alloc = true
3452 : : }
3453 : : },
3454 : : #ifdef CC_AVX512_SUPPORT
3455 : : [IAVF_RX_AVX512] = {
3456 : : .pkt_burst = iavf_recv_pkts_vec_avx512,
3457 : : .info = "Vector AVX512",
3458 : : .features = {
3459 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS,
3460 : : .simd_width = RTE_VECT_SIMD_512,
3461 : : .bulk_alloc = true
3462 : : }
3463 : : },
3464 : : [IAVF_RX_AVX512_SCATTERED] = {
3465 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512,
3466 : : .info = "Vector Scattered AVX512",
3467 : : .features = {
3468 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3469 : : .simd_width = RTE_VECT_SIMD_512,
3470 : : .scattered = true,
3471 : : .bulk_alloc = true
3472 : : }
3473 : : },
3474 : : [IAVF_RX_AVX512_OFFLOAD] = {
3475 : : .pkt_burst = iavf_recv_pkts_vec_avx512_offload,
3476 : : .info = "Vector AVX512 Offload",
3477 : : .features = {
3478 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS,
3479 : : .simd_width = RTE_VECT_SIMD_512,
3480 : : .bulk_alloc = true
3481 : : }
3482 : : },
3483 : : [IAVF_RX_AVX512_SCATTERED_OFFLOAD] = {
3484 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_offload,
3485 : : .info = "Vector Scattered AVX512 Offload",
3486 : : .features = {
3487 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3488 : : .simd_width = RTE_VECT_SIMD_512,
3489 : : .scattered = true,
3490 : : .bulk_alloc = true
3491 : : }
3492 : : },
3493 : : [IAVF_RX_AVX512_FLEX_RXD] = {
3494 : : .pkt_burst = iavf_recv_pkts_vec_avx512_flex_rxd,
3495 : : .info = "Vector AVX512 Flex",
3496 : : .features = {
3497 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS,
3498 : : .simd_width = RTE_VECT_SIMD_512,
3499 : : .flex_desc = true,
3500 : : .bulk_alloc = true
3501 : : }
3502 : : },
3503 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD] = {
3504 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
3505 : : .info = "Vector Scattered AVX512 Flex",
3506 : : .features = {
3507 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3508 : : .simd_width = RTE_VECT_SIMD_512,
3509 : : .scattered = true,
3510 : : .flex_desc = true,
3511 : : .bulk_alloc = true
3512 : : }
3513 : : },
3514 : : [IAVF_RX_AVX512_FLEX_RXD_OFFLOAD] = {
3515 : : .pkt_burst = iavf_recv_pkts_vec_avx512_flex_rxd_offload,
3516 : : .info = "Vector AVX512 Flex Offload",
3517 : : .features = {
3518 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS,
3519 : : .simd_width = RTE_VECT_SIMD_512,
3520 : : .flex_desc = true,
3521 : : .bulk_alloc = true
3522 : : }
3523 : : },
3524 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD] = {
3525 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
3526 : : .info = "Vector Scattered AVX512 Flex Offload",
3527 : : .features = {
3528 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS |
3529 : : RTE_ETH_RX_OFFLOAD_SCATTER,
3530 : : .simd_width = RTE_VECT_SIMD_512,
3531 : : .scattered = true,
3532 : : .flex_desc = true,
3533 : : .bulk_alloc = true
3534 : : }
3535 : : },
3536 : : #endif
3537 : : #elif defined(RTE_ARCH_ARM64)
3538 : : [IAVF_RX_NEON] = {
3539 : : .pkt_burst = iavf_recv_pkts_vec,
3540 : : .info = "Vector Neon",
3541 : : .features = {
3542 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS,
3543 : : .simd_width = RTE_VECT_SIMD_128,
3544 : : .bulk_alloc = true
3545 : : }
3546 : : },
3547 : : [IAVF_RX_NEON_SCATTERED] = {
3548 : : .pkt_burst = iavf_recv_scattered_pkts_vec,
3549 : : .info = "Vector Scattered Neon",
3550 : : .features = {
3551 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3552 : : .simd_width = RTE_VECT_SIMD_128,
3553 : : .scattered = true,
3554 : : .bulk_alloc = true
3555 : : }
3556 : : },
3557 : : [IAVF_RX_NEON_FLEX_RXD] = {
3558 : : .pkt_burst = iavf_recv_pkts_vec_flex_rxd,
3559 : : .info = "Vector Neon Flex",
3560 : : .features = {
3561 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS,
3562 : : .simd_width = RTE_VECT_SIMD_128,
3563 : : .flex_desc = true,
3564 : : .bulk_alloc = true
3565 : : }
3566 : : },
3567 : : [IAVF_RX_NEON_SCATTERED_FLEX_RXD] = {
3568 : : .pkt_burst = iavf_recv_scattered_pkts_vec_flex_rxd,
3569 : : .info = "Vector Scattered Neon Flex",
3570 : : .features = {
3571 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3572 : : .simd_width = RTE_VECT_SIMD_128,
3573 : : .scattered = true,
3574 : : .flex_desc = true,
3575 : : .bulk_alloc = true
3576 : : }
3577 : : },
3578 : : #endif
3579 : : };
3580 : :
3581 : : int
3582 : 0 : iavf_rx_burst_mode_get(struct rte_eth_dev *dev,
3583 : : __rte_unused uint16_t queue_id,
3584 : : struct rte_eth_burst_mode *mode)
3585 : : {
3586 : 0 : struct iavf_adapter *adapter =
3587 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3588 : 0 : enum iavf_rx_func_type rx_func_type = adapter->rx_func_type;
3589 : :
3590 [ # # ]: 0 : if ((size_t)rx_func_type >= RTE_DIM(iavf_rx_path_infos) ||
3591 [ # # ]: 0 : iavf_rx_path_infos[rx_func_type].info == NULL)
3592 : : return -EINVAL;
3593 : :
3594 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3595 : : iavf_rx_path_infos[rx_func_type].info);
3596 : :
3597 : 0 : return 0;
3598 : : }
3599 : :
3600 : : static const struct ci_tx_path_info iavf_tx_path_infos[] = {
3601 : : [IAVF_TX_DISABLED] = {
3602 : : .pkt_burst = iavf_xmit_pkts_no_poll,
3603 : : .info = "Disabled",
3604 : : .features = {
3605 : : .disabled = true
3606 : : }
3607 : : },
3608 : : [IAVF_TX_DEFAULT] = {
3609 : : .pkt_burst = iavf_xmit_pkts,
3610 : : .info = "Scalar",
3611 : : .features = {
3612 : : .tx_offloads = IAVF_TX_SCALAR_OFFLOADS,
3613 : : .ctx_desc = true
3614 : : }
3615 : : },
3616 : : #ifdef RTE_ARCH_X86
3617 : : [IAVF_TX_AVX2] = {
3618 : : .pkt_burst = iavf_xmit_pkts_vec_avx2,
3619 : : .info = "Vector AVX2",
3620 : : .features = {
3621 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3622 : : .simd_width = RTE_VECT_SIMD_256
3623 : : }
3624 : : },
3625 : : [IAVF_TX_AVX2_OFFLOAD] = {
3626 : : .pkt_burst = iavf_xmit_pkts_vec_avx2_offload,
3627 : : .info = "Vector AVX2 Offload",
3628 : : .features = {
3629 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOAD_OFFLOADS,
3630 : : .simd_width = RTE_VECT_SIMD_256
3631 : : }
3632 : : },
3633 : : [IAVF_TX_AVX2_CTX] = {
3634 : : .pkt_burst = iavf_xmit_pkts_vec_avx2_ctx,
3635 : : .info = "Vector AVX2 Ctx",
3636 : : .features = {
3637 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3638 : : .simd_width = RTE_VECT_SIMD_256,
3639 : : .ctx_desc = true
3640 : : }
3641 : : },
3642 : : [IAVF_TX_AVX2_CTX_OFFLOAD] = {
3643 : : .pkt_burst = iavf_xmit_pkts_vec_avx2_ctx_offload,
3644 : : .info = "Vector AVX2 Ctx Offload",
3645 : : .features = {
3646 : : .tx_offloads = IAVF_TX_VECTOR_CTX_OFFLOAD_OFFLOADS,
3647 : : .simd_width = RTE_VECT_SIMD_256,
3648 : : .ctx_desc = true
3649 : : }
3650 : : },
3651 : : #ifdef CC_AVX512_SUPPORT
3652 : : [IAVF_TX_AVX512] = {
3653 : : .pkt_burst = iavf_xmit_pkts_vec_avx512,
3654 : : .info = "Vector AVX512",
3655 : : .features = {
3656 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3657 : : .simd_width = RTE_VECT_SIMD_512
3658 : : }
3659 : : },
3660 : : [IAVF_TX_AVX512_OFFLOAD] = {
3661 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_offload,
3662 : : .info = "Vector AVX512 Offload",
3663 : : .features = {
3664 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOAD_OFFLOADS,
3665 : : .simd_width = RTE_VECT_SIMD_512
3666 : : }
3667 : : },
3668 : : [IAVF_TX_AVX512_CTX] = {
3669 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_ctx,
3670 : : .info = "Vector AVX512 Ctx",
3671 : : .features = {
3672 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3673 : : .simd_width = RTE_VECT_SIMD_512,
3674 : : .ctx_desc = true
3675 : : }
3676 : : },
3677 : : [IAVF_TX_AVX512_CTX_OFFLOAD] = {
3678 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload,
3679 : : .info = "Vector AVX512 Ctx Offload",
3680 : : .features = {
3681 : : .tx_offloads = IAVF_TX_VECTOR_CTX_OFFLOAD_OFFLOADS,
3682 : : .simd_width = RTE_VECT_SIMD_512,
3683 : : .ctx_desc = true
3684 : : }
3685 : : },
3686 : : #endif
3687 : : #elif defined(RTE_ARCH_ARM64)
3688 : : [IAVF_TX_NEON] = {
3689 : : .pkt_burst = iavf_xmit_pkts_vec,
3690 : : .info = "Vector Neon",
3691 : : .features = {
3692 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3693 : : .simd_width = RTE_VECT_SIMD_128
3694 : : }
3695 : : },
3696 : : #endif
3697 : : };
3698 : :
3699 : : int
3700 : 0 : iavf_tx_burst_mode_get(struct rte_eth_dev *dev,
3701 : : __rte_unused uint16_t queue_id,
3702 : : struct rte_eth_burst_mode *mode)
3703 : : {
3704 : 0 : struct iavf_adapter *adapter =
3705 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3706 : 0 : enum iavf_tx_func_type tx_func_type = adapter->tx_func_type;
3707 : :
3708 [ # # ]: 0 : if ((size_t)tx_func_type >= RTE_DIM(iavf_tx_path_infos) ||
3709 [ # # ]: 0 : iavf_tx_path_infos[tx_func_type].info == NULL)
3710 : : return -EINVAL;
3711 : :
3712 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3713 : : iavf_tx_path_infos[tx_func_type].info);
3714 : :
3715 : 0 : return 0;
3716 : : }
3717 : :
3718 : : static uint16_t
3719 : 0 : iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
3720 : : uint16_t nb_pkts)
3721 : : {
3722 : : struct ci_rx_queue *rxq = rx_queue;
3723 : : enum iavf_rx_func_type rx_func_type;
3724 : :
3725 [ # # # # ]: 0 : if (!rxq->iavf_vsi || rxq->iavf_vsi->adapter->no_poll)
3726 : : return 0;
3727 : :
3728 : 0 : rx_func_type = rxq->iavf_vsi->adapter->rx_func_type;
3729 : :
3730 : 0 : return iavf_rx_path_infos[rx_func_type].pkt_burst(rx_queue,
3731 : : rx_pkts, nb_pkts);
3732 : : }
3733 : :
3734 : : static uint16_t
3735 : 0 : iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
3736 : : uint16_t nb_pkts)
3737 : : {
3738 : : struct ci_tx_queue *txq = tx_queue;
3739 : : enum iavf_tx_func_type tx_func_type;
3740 : :
3741 [ # # # # ]: 0 : if (!txq->iavf_vsi || txq->iavf_vsi->adapter->no_poll)
3742 : : return 0;
3743 : :
3744 : 0 : tx_func_type = txq->iavf_vsi->adapter->tx_func_type;
3745 : :
3746 : 0 : return iavf_tx_path_infos[tx_func_type].pkt_burst(tx_queue,
3747 : : tx_pkts, nb_pkts);
3748 : : }
3749 : :
3750 : : /* Tx mbuf check */
3751 : : static uint16_t
3752 : 0 : iavf_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts,
3753 : : uint16_t nb_pkts)
3754 : : {
3755 : : uint16_t idx;
3756 : : uint64_t ol_flags;
3757 : : struct rte_mbuf *mb;
3758 : : uint16_t good_pkts = nb_pkts;
3759 : 0 : const char *reason = NULL;
3760 : : bool pkt_error = false;
3761 : : struct ci_tx_queue *txq = tx_queue;
3762 : 0 : struct iavf_adapter *adapter = txq->iavf_vsi->adapter;
3763 : 0 : enum iavf_tx_func_type tx_func_type =
3764 : : txq->iavf_vsi->adapter->tx_func_type;
3765 : :
3766 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
3767 : 0 : mb = tx_pkts[idx];
3768 : 0 : ol_flags = mb->ol_flags;
3769 : :
3770 [ # # # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_MBUF) &&
3771 : 0 : (rte_mbuf_check(mb, 1, &reason) != 0)) {
3772 : : PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
3773 : : pkt_error = true;
3774 : : break;
3775 : : }
3776 : :
3777 [ # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SIZE) &&
3778 [ # # ]: 0 : (mb->data_len < IAVF_TX_MIN_PKT_LEN ||
3779 [ # # ]: 0 : mb->data_len > adapter->vf.max_pkt_len)) {
3780 : : PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %u)",
3781 : : mb->data_len, IAVF_TX_MIN_PKT_LEN, adapter->vf.max_pkt_len);
3782 : : pkt_error = true;
3783 : : break;
3784 : : }
3785 : :
3786 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SEGMENT) {
3787 : : /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. */
3788 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3789 [ # # ]: 0 : if (mb->nb_segs > IAVF_TX_MAX_MTU_SEG) {
3790 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
3791 : : mb->nb_segs, IAVF_TX_MAX_MTU_SEG);
3792 : : pkt_error = true;
3793 : : break;
3794 : : }
3795 [ # # ]: 0 : } else if ((mb->tso_segsz < IAVF_MIN_TSO_MSS) ||
3796 : : (mb->tso_segsz > IAVF_MAX_TSO_MSS)) {
3797 : : /* MSS outside the range are considered malicious */
3798 : : PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
3799 : : mb->tso_segsz, IAVF_MIN_TSO_MSS, IAVF_MAX_TSO_MSS);
3800 : : pkt_error = true;
3801 : : break;
3802 [ # # ]: 0 : } else if (mb->nb_segs > txq->nb_tx_desc) {
3803 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
3804 : : pkt_error = true;
3805 : : break;
3806 : : }
3807 : : }
3808 : :
3809 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_OFFLOAD) {
3810 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3811 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
3812 : : pkt_error = true;
3813 : : break;
3814 : : }
3815 : :
3816 [ # # ]: 0 : if (!rte_validate_tx_offload(mb)) {
3817 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
3818 : : pkt_error = true;
3819 : : break;
3820 : : }
3821 : : }
3822 : : }
3823 : :
3824 [ # # ]: 0 : if (pkt_error) {
3825 : 0 : txq->mbuf_errors++;
3826 : : good_pkts = idx;
3827 [ # # ]: 0 : if (good_pkts == 0)
3828 : : return 0;
3829 : : }
3830 : :
3831 : 0 : return iavf_tx_path_infos[tx_func_type].pkt_burst(tx_queue, tx_pkts, good_pkts);
3832 : : }
3833 : :
3834 : : #ifdef RTE_ARCH_X86
3835 : : enum rte_vect_max_simd
3836 : 0 : iavf_get_max_simd_bitwidth(void)
3837 : : {
3838 : 0 : return ci_get_x86_max_simd_bitwidth();
3839 : : }
3840 : : #endif
3841 : :
3842 : : /* choose rx function*/
3843 : : void
3844 : 0 : iavf_set_rx_function(struct rte_eth_dev *dev)
3845 : : {
3846 : 0 : struct iavf_adapter *adapter =
3847 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3848 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3849 : : enum iavf_rx_func_type default_path = IAVF_RX_DEFAULT;
3850 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
3851 : : int i;
3852 : : struct ci_rx_queue *rxq;
3853 : : bool use_flex = true;
3854 : 0 : struct ci_rx_path_features req_features = {
3855 : 0 : .rx_offloads = dev->data->dev_conf.rxmode.offloads,
3856 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3857 : : };
3858 : :
3859 : : /* If the device has started the function has already been selected. */
3860 [ # # ]: 0 : if (dev->data->dev_started)
3861 : 0 : goto out;
3862 : :
3863 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3864 : 0 : rxq = dev->data->rx_queues[i];
3865 [ # # ]: 0 : if (rxq->rxdid <= IAVF_RXDID_LEGACY_1) {
3866 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is legacy, "
3867 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3868 : : use_flex = false;
3869 [ # # ]: 0 : } else if (!(vf->supported_rxdid & RTE_BIT64(rxq->rxdid))) {
3870 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is not supported, "
3871 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3872 : : use_flex = false;
3873 : : }
3874 : : }
3875 : :
3876 [ # # ]: 0 : if (use_flex)
3877 : 0 : req_features.flex_desc = true;
3878 [ # # ]: 0 : if (dev->data->scattered_rx)
3879 : 0 : req_features.scattered = true;
3880 [ # # ]: 0 : if (adapter->rx_bulk_alloc_allowed) {
3881 : 0 : req_features.bulk_alloc = true;
3882 : : default_path = IAVF_RX_BULK_ALLOC;
3883 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3884 [ # # ]: 0 : if (iavf_rx_vec_dev_check(dev) != -1)
3885 : 0 : req_features.simd_width = iavf_get_max_simd_bitwidth();
3886 : : #endif
3887 : : }
3888 : :
3889 : 0 : adapter->rx_func_type = ci_rx_path_select(&req_features,
3890 : : &iavf_rx_path_infos[0],
3891 : : RTE_DIM(iavf_rx_path_infos),
3892 : : default_path);
3893 : :
3894 : 0 : out:
3895 [ # # ]: 0 : if (no_poll_on_link_down)
3896 : 0 : dev->rx_pkt_burst = iavf_recv_pkts_no_poll;
3897 : : else
3898 : 0 : dev->rx_pkt_burst = iavf_rx_path_infos[adapter->rx_func_type].pkt_burst;
3899 : :
3900 : 0 : PMD_DRV_LOG(DEBUG, "Using %s (port %d).",
3901 : : iavf_rx_path_infos[adapter->rx_func_type].info, dev->data->port_id);
3902 : 0 : }
3903 : :
3904 : : /* choose tx function*/
3905 : : void
3906 : 0 : iavf_set_tx_function(struct rte_eth_dev *dev)
3907 : : {
3908 : 0 : struct iavf_adapter *adapter =
3909 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3910 : 0 : int mbuf_check = adapter->devargs.mbuf_check;
3911 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
3912 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3913 : : struct ci_tx_queue *txq;
3914 : : int i;
3915 : : const struct ci_tx_path_features *selected_features;
3916 : : #endif
3917 : 0 : struct ci_tx_path_features req_features = {
3918 : 0 : .tx_offloads = dev->data->dev_conf.txmode.offloads,
3919 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3920 : : };
3921 : :
3922 : : /* If the device has started the function has already been selected. */
3923 [ # # ]: 0 : if (dev->data->dev_started)
3924 : 0 : goto out;
3925 : :
3926 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3927 [ # # ]: 0 : if (iavf_tx_vec_dev_check(dev) != -1)
3928 : 0 : req_features.simd_width = iavf_get_max_simd_bitwidth();
3929 : :
3930 [ # # # # ]: 0 : if (adapter->devargs.enable_ptype_lldp || rte_pmd_iavf_tx_lldp_dynfield_offset > 0)
3931 : 0 : req_features.ctx_desc = true;
3932 : :
3933 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3934 : 0 : txq = dev->data->tx_queues[i];
3935 [ # # ]: 0 : if (!txq)
3936 : 0 : continue;
3937 [ # # ]: 0 : if (txq->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT &&
3938 [ # # ]: 0 : txq->vlan_flag == IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
3939 : 0 : req_features.ctx_desc = true;
3940 : : }
3941 : : #endif
3942 : :
3943 : 0 : adapter->tx_func_type = ci_tx_path_select(&req_features,
3944 : : &iavf_tx_path_infos[0],
3945 : : RTE_DIM(iavf_tx_path_infos),
3946 : : IAVF_TX_DEFAULT);
3947 : :
3948 : 0 : out:
3949 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
3950 : 0 : selected_features = &iavf_tx_path_infos[adapter->tx_func_type].features;
3951 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3952 : 0 : txq = dev->data->tx_queues[i];
3953 [ # # ]: 0 : if (!txq)
3954 : 0 : continue;
3955 : 0 : txq->use_ctx = selected_features->ctx_desc;
3956 : 0 : txq->use_vec_entry = selected_features->simd_width >= RTE_VECT_SIMD_128;
3957 : : }
3958 : : #endif
3959 : :
3960 [ # # ]: 0 : if (no_poll_on_link_down)
3961 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
3962 [ # # ]: 0 : else if (mbuf_check)
3963 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_check;
3964 : : else
3965 : 0 : dev->tx_pkt_burst = iavf_tx_path_infos[adapter->tx_func_type].pkt_burst;
3966 : :
3967 : 0 : PMD_DRV_LOG(DEBUG, "Using %s (port %d).",
3968 : : iavf_tx_path_infos[adapter->tx_func_type].info, dev->data->port_id);
3969 : 0 : }
3970 : :
3971 : : static int
3972 : 0 : iavf_tx_done_cleanup_full(struct ci_tx_queue *txq,
3973 : : uint32_t free_cnt)
3974 : : {
3975 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
3976 : : uint16_t tx_last, tx_id;
3977 : : uint16_t nb_tx_free_last;
3978 : : uint16_t nb_tx_to_clean;
3979 : : uint32_t pkt_cnt = 0;
3980 : :
3981 : : /* Start free mbuf from tx_tail */
3982 : 0 : tx_id = txq->tx_tail;
3983 : : tx_last = tx_id;
3984 : :
3985 [ # # ]: 0 : if (txq->nb_tx_free == 0 && ci_tx_xmit_cleanup(txq))
3986 : : return 0;
3987 : :
3988 : 0 : nb_tx_to_clean = txq->nb_tx_free;
3989 : : nb_tx_free_last = txq->nb_tx_free;
3990 [ # # ]: 0 : if (!free_cnt)
3991 : 0 : free_cnt = txq->nb_tx_desc;
3992 : :
3993 : : /* Loop through swr_ring to count the amount of
3994 : : * freeable mubfs and packets.
3995 : : */
3996 [ # # ]: 0 : while (pkt_cnt < free_cnt) {
3997 : : do {
3998 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
3999 : : /*
4000 : : * last segment in the packet,
4001 : : * increment packet count
4002 : : */
4003 [ # # ]: 0 : pkt_cnt += (swr_ring[tx_id].mbuf->next == NULL) ? 1 : 0;
4004 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
4005 : 0 : swr_ring[tx_id].mbuf = NULL;
4006 : :
4007 : : }
4008 : :
4009 : 0 : tx_id = swr_ring[tx_id].next_id;
4010 [ # # # # ]: 0 : } while (--nb_tx_to_clean && pkt_cnt < free_cnt && tx_id != tx_last);
4011 : :
4012 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
4013 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
4014 : : break;
4015 : :
4016 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
4017 : : if (ci_tx_xmit_cleanup(txq))
4018 : : break;
4019 : :
4020 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
4021 : : nb_tx_free_last = txq->nb_tx_free;
4022 : : }
4023 : : }
4024 : :
4025 : 0 : return (int)pkt_cnt;
4026 : : }
4027 : :
4028 : : int
4029 : 0 : iavf_dev_tx_done_cleanup(void *txq, uint32_t free_cnt)
4030 : : {
4031 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
4032 : :
4033 : 0 : return iavf_tx_done_cleanup_full(q, free_cnt);
4034 : : }
4035 : :
4036 : : void
4037 : 0 : iavf_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
4038 : : struct rte_eth_rxq_info *qinfo)
4039 : : {
4040 : : struct ci_rx_queue *rxq;
4041 : :
4042 : 0 : rxq = dev->data->rx_queues[queue_id];
4043 : :
4044 : 0 : qinfo->mp = rxq->mp;
4045 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
4046 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
4047 : :
4048 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
4049 : 0 : qinfo->conf.rx_drop_en = true;
4050 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
4051 : 0 : }
4052 : :
4053 : : void
4054 : 0 : iavf_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
4055 : : struct rte_eth_txq_info *qinfo)
4056 : : {
4057 : : struct ci_tx_queue *txq;
4058 : :
4059 : 0 : txq = dev->data->tx_queues[queue_id];
4060 : :
4061 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
4062 : :
4063 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
4064 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
4065 : 0 : qinfo->conf.offloads = txq->offloads;
4066 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
4067 : 0 : }
4068 : :
4069 : : /* Get the number of used descriptors of a rx queue */
4070 : : int
4071 : 0 : iavf_dev_rxq_count(void *rx_queue)
4072 : : {
4073 : : #define IAVF_RXQ_SCAN_INTERVAL 4
4074 : : volatile union ci_rx_desc *rxdp;
4075 : : struct ci_rx_queue *rxq;
4076 : : uint16_t desc = 0;
4077 : :
4078 : : rxq = rx_queue;
4079 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
4080 : :
4081 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
4082 : 0 : ((rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
4083 [ # # ]: 0 : IAVF_RXD_QW1_STATUS_MASK) >> IAVF_RXD_QW1_STATUS_SHIFT) &
4084 : : (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)) {
4085 : : /* Check the DD bit of a rx descriptor of each 4 in a group,
4086 : : * to avoid checking too frequently and downgrading performance
4087 : : * too much.
4088 : : */
4089 : 0 : desc += IAVF_RXQ_SCAN_INTERVAL;
4090 : 0 : rxdp += IAVF_RXQ_SCAN_INTERVAL;
4091 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
4092 : 0 : rxdp = &(rxq->rx_ring[rxq->rx_tail +
4093 : 0 : desc - rxq->nb_rx_desc]);
4094 : : }
4095 : :
4096 : 0 : return desc;
4097 : : }
4098 : :
4099 : : int
4100 : 0 : iavf_dev_rx_desc_status(void *rx_queue, uint16_t offset)
4101 : : {
4102 : : struct ci_rx_queue *rxq = rx_queue;
4103 : : volatile uint64_t *status;
4104 : : uint64_t mask;
4105 : : uint32_t desc;
4106 : :
4107 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
4108 : : return -EINVAL;
4109 : :
4110 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
4111 : : return RTE_ETH_RX_DESC_UNAVAIL;
4112 : :
4113 : 0 : desc = rxq->rx_tail + offset;
4114 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
4115 : 0 : desc -= rxq->nb_rx_desc;
4116 : :
4117 : 0 : status = &rxq->rx_ring[desc].wb.qword1.status_error_len;
4118 : : mask = rte_le_to_cpu_64((1ULL << IAVF_RX_DESC_STATUS_DD_SHIFT)
4119 : : << IAVF_RXD_QW1_STATUS_SHIFT);
4120 [ # # ]: 0 : if (*status & mask)
4121 : 0 : return RTE_ETH_RX_DESC_DONE;
4122 : :
4123 : : return RTE_ETH_RX_DESC_AVAIL;
4124 : : }
4125 : :
4126 : : int
4127 : 0 : iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset)
4128 : : {
4129 : : struct ci_tx_queue *txq = tx_queue;
4130 : : volatile uint64_t *status;
4131 : : uint64_t mask, expect;
4132 : : uint32_t desc;
4133 : :
4134 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
4135 : : return -EINVAL;
4136 : :
4137 : 0 : desc = txq->tx_tail + offset;
4138 : : /* go to next desc that has the RS bit */
4139 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
4140 : : txq->tx_rs_thresh;
4141 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
4142 : 0 : desc -= txq->nb_tx_desc;
4143 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
4144 : 0 : desc -= txq->nb_tx_desc;
4145 : : }
4146 : :
4147 : 0 : status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
4148 : : mask = rte_le_to_cpu_64(CI_TXD_QW1_DTYPE_M);
4149 : : expect = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE << CI_TXD_QW1_DTYPE_S);
4150 [ # # ]: 0 : if ((*status & mask) == expect)
4151 : 0 : return RTE_ETH_TX_DESC_DONE;
4152 : :
4153 : : return RTE_ETH_TX_DESC_FULL;
4154 : : }
4155 : :
4156 : : static inline uint32_t
4157 : : iavf_get_default_ptype(uint16_t ptype)
4158 : : {
4159 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] = {
4160 : : /* L2 types */
4161 : : /* [0] reserved */
4162 : : [1] = RTE_PTYPE_L2_ETHER,
4163 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
4164 : : /* [3] - [5] reserved */
4165 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
4166 : : /* [7] - [10] reserved */
4167 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
4168 : : /* [12] - [21] reserved */
4169 : :
4170 : : /* Non tunneled IPv4 */
4171 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4172 : : RTE_PTYPE_L4_FRAG,
4173 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4174 : : RTE_PTYPE_L4_NONFRAG,
4175 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4176 : : RTE_PTYPE_L4_UDP,
4177 : : /* [25] reserved */
4178 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4179 : : RTE_PTYPE_L4_TCP,
4180 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4181 : : RTE_PTYPE_L4_SCTP,
4182 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4183 : : RTE_PTYPE_L4_ICMP,
4184 : :
4185 : : /* IPv4 --> IPv4 */
4186 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4187 : : RTE_PTYPE_TUNNEL_IP |
4188 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4189 : : RTE_PTYPE_INNER_L4_FRAG,
4190 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4191 : : RTE_PTYPE_TUNNEL_IP |
4192 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4193 : : RTE_PTYPE_INNER_L4_NONFRAG,
4194 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4195 : : RTE_PTYPE_TUNNEL_IP |
4196 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4197 : : RTE_PTYPE_INNER_L4_UDP,
4198 : : /* [32] reserved */
4199 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4200 : : RTE_PTYPE_TUNNEL_IP |
4201 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4202 : : RTE_PTYPE_INNER_L4_TCP,
4203 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4204 : : RTE_PTYPE_TUNNEL_IP |
4205 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4206 : : RTE_PTYPE_INNER_L4_SCTP,
4207 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4208 : : RTE_PTYPE_TUNNEL_IP |
4209 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4210 : : RTE_PTYPE_INNER_L4_ICMP,
4211 : :
4212 : : /* IPv4 --> IPv6 */
4213 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4214 : : RTE_PTYPE_TUNNEL_IP |
4215 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4216 : : RTE_PTYPE_INNER_L4_FRAG,
4217 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4218 : : RTE_PTYPE_TUNNEL_IP |
4219 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4220 : : RTE_PTYPE_INNER_L4_NONFRAG,
4221 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4222 : : RTE_PTYPE_TUNNEL_IP |
4223 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4224 : : RTE_PTYPE_INNER_L4_UDP,
4225 : : /* [39] reserved */
4226 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4227 : : RTE_PTYPE_TUNNEL_IP |
4228 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4229 : : RTE_PTYPE_INNER_L4_TCP,
4230 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4231 : : RTE_PTYPE_TUNNEL_IP |
4232 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4233 : : RTE_PTYPE_INNER_L4_SCTP,
4234 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4235 : : RTE_PTYPE_TUNNEL_IP |
4236 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4237 : : RTE_PTYPE_INNER_L4_ICMP,
4238 : :
4239 : : /* IPv4 --> GRE/Teredo/VXLAN */
4240 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4241 : : RTE_PTYPE_TUNNEL_GRENAT,
4242 : :
4243 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
4244 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4245 : : RTE_PTYPE_TUNNEL_GRENAT |
4246 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4247 : : RTE_PTYPE_INNER_L4_FRAG,
4248 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4249 : : RTE_PTYPE_TUNNEL_GRENAT |
4250 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4251 : : RTE_PTYPE_INNER_L4_NONFRAG,
4252 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4253 : : RTE_PTYPE_TUNNEL_GRENAT |
4254 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4255 : : RTE_PTYPE_INNER_L4_UDP,
4256 : : /* [47] reserved */
4257 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4258 : : RTE_PTYPE_TUNNEL_GRENAT |
4259 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4260 : : RTE_PTYPE_INNER_L4_TCP,
4261 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4262 : : RTE_PTYPE_TUNNEL_GRENAT |
4263 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4264 : : RTE_PTYPE_INNER_L4_SCTP,
4265 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4266 : : RTE_PTYPE_TUNNEL_GRENAT |
4267 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4268 : : RTE_PTYPE_INNER_L4_ICMP,
4269 : :
4270 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
4271 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4272 : : RTE_PTYPE_TUNNEL_GRENAT |
4273 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4274 : : RTE_PTYPE_INNER_L4_FRAG,
4275 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4276 : : RTE_PTYPE_TUNNEL_GRENAT |
4277 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4278 : : RTE_PTYPE_INNER_L4_NONFRAG,
4279 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4280 : : RTE_PTYPE_TUNNEL_GRENAT |
4281 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4282 : : RTE_PTYPE_INNER_L4_UDP,
4283 : : /* [54] reserved */
4284 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4285 : : RTE_PTYPE_TUNNEL_GRENAT |
4286 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4287 : : RTE_PTYPE_INNER_L4_TCP,
4288 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4289 : : RTE_PTYPE_TUNNEL_GRENAT |
4290 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4291 : : RTE_PTYPE_INNER_L4_SCTP,
4292 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4293 : : RTE_PTYPE_TUNNEL_GRENAT |
4294 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4295 : : RTE_PTYPE_INNER_L4_ICMP,
4296 : :
4297 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
4298 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4299 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4300 : :
4301 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4302 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4303 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4304 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4305 : : RTE_PTYPE_INNER_L4_FRAG,
4306 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4307 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4308 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4309 : : RTE_PTYPE_INNER_L4_NONFRAG,
4310 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4311 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4312 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4313 : : RTE_PTYPE_INNER_L4_UDP,
4314 : : /* [62] reserved */
4315 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4316 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4317 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4318 : : RTE_PTYPE_INNER_L4_TCP,
4319 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4320 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4321 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4322 : : RTE_PTYPE_INNER_L4_SCTP,
4323 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4324 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4325 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4326 : : RTE_PTYPE_INNER_L4_ICMP,
4327 : :
4328 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4329 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4330 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4331 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4332 : : RTE_PTYPE_INNER_L4_FRAG,
4333 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4334 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4335 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4336 : : RTE_PTYPE_INNER_L4_NONFRAG,
4337 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4338 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4339 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4340 : : RTE_PTYPE_INNER_L4_UDP,
4341 : : /* [69] reserved */
4342 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4343 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4344 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4345 : : RTE_PTYPE_INNER_L4_TCP,
4346 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4347 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4348 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4349 : : RTE_PTYPE_INNER_L4_SCTP,
4350 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4351 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4352 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4353 : : RTE_PTYPE_INNER_L4_ICMP,
4354 : : /* [73] - [87] reserved */
4355 : :
4356 : : /* Non tunneled IPv6 */
4357 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4358 : : RTE_PTYPE_L4_FRAG,
4359 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4360 : : RTE_PTYPE_L4_NONFRAG,
4361 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4362 : : RTE_PTYPE_L4_UDP,
4363 : : /* [91] reserved */
4364 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4365 : : RTE_PTYPE_L4_TCP,
4366 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4367 : : RTE_PTYPE_L4_SCTP,
4368 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4369 : : RTE_PTYPE_L4_ICMP,
4370 : :
4371 : : /* IPv6 --> IPv4 */
4372 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4373 : : RTE_PTYPE_TUNNEL_IP |
4374 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4375 : : RTE_PTYPE_INNER_L4_FRAG,
4376 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4377 : : RTE_PTYPE_TUNNEL_IP |
4378 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4379 : : RTE_PTYPE_INNER_L4_NONFRAG,
4380 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4381 : : RTE_PTYPE_TUNNEL_IP |
4382 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4383 : : RTE_PTYPE_INNER_L4_UDP,
4384 : : /* [98] reserved */
4385 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4386 : : RTE_PTYPE_TUNNEL_IP |
4387 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4388 : : RTE_PTYPE_INNER_L4_TCP,
4389 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4390 : : RTE_PTYPE_TUNNEL_IP |
4391 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4392 : : RTE_PTYPE_INNER_L4_SCTP,
4393 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4394 : : RTE_PTYPE_TUNNEL_IP |
4395 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4396 : : RTE_PTYPE_INNER_L4_ICMP,
4397 : :
4398 : : /* IPv6 --> IPv6 */
4399 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4400 : : RTE_PTYPE_TUNNEL_IP |
4401 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4402 : : RTE_PTYPE_INNER_L4_FRAG,
4403 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4404 : : RTE_PTYPE_TUNNEL_IP |
4405 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4406 : : RTE_PTYPE_INNER_L4_NONFRAG,
4407 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4408 : : RTE_PTYPE_TUNNEL_IP |
4409 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4410 : : RTE_PTYPE_INNER_L4_UDP,
4411 : : /* [105] reserved */
4412 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4413 : : RTE_PTYPE_TUNNEL_IP |
4414 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4415 : : RTE_PTYPE_INNER_L4_TCP,
4416 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4417 : : RTE_PTYPE_TUNNEL_IP |
4418 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4419 : : RTE_PTYPE_INNER_L4_SCTP,
4420 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4421 : : RTE_PTYPE_TUNNEL_IP |
4422 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4423 : : RTE_PTYPE_INNER_L4_ICMP,
4424 : :
4425 : : /* IPv6 --> GRE/Teredo/VXLAN */
4426 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4427 : : RTE_PTYPE_TUNNEL_GRENAT,
4428 : :
4429 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4430 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4431 : : RTE_PTYPE_TUNNEL_GRENAT |
4432 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4433 : : RTE_PTYPE_INNER_L4_FRAG,
4434 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4435 : : RTE_PTYPE_TUNNEL_GRENAT |
4436 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4437 : : RTE_PTYPE_INNER_L4_NONFRAG,
4438 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4439 : : RTE_PTYPE_TUNNEL_GRENAT |
4440 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4441 : : RTE_PTYPE_INNER_L4_UDP,
4442 : : /* [113] reserved */
4443 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4444 : : RTE_PTYPE_TUNNEL_GRENAT |
4445 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4446 : : RTE_PTYPE_INNER_L4_TCP,
4447 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4448 : : RTE_PTYPE_TUNNEL_GRENAT |
4449 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4450 : : RTE_PTYPE_INNER_L4_SCTP,
4451 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4452 : : RTE_PTYPE_TUNNEL_GRENAT |
4453 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4454 : : RTE_PTYPE_INNER_L4_ICMP,
4455 : :
4456 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4457 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4458 : : RTE_PTYPE_TUNNEL_GRENAT |
4459 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4460 : : RTE_PTYPE_INNER_L4_FRAG,
4461 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4462 : : RTE_PTYPE_TUNNEL_GRENAT |
4463 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4464 : : RTE_PTYPE_INNER_L4_NONFRAG,
4465 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4466 : : RTE_PTYPE_TUNNEL_GRENAT |
4467 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4468 : : RTE_PTYPE_INNER_L4_UDP,
4469 : : /* [120] reserved */
4470 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4471 : : RTE_PTYPE_TUNNEL_GRENAT |
4472 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4473 : : RTE_PTYPE_INNER_L4_TCP,
4474 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4475 : : RTE_PTYPE_TUNNEL_GRENAT |
4476 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4477 : : RTE_PTYPE_INNER_L4_SCTP,
4478 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4479 : : RTE_PTYPE_TUNNEL_GRENAT |
4480 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4481 : : RTE_PTYPE_INNER_L4_ICMP,
4482 : :
4483 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4484 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4485 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4486 : :
4487 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4488 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4489 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4490 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4491 : : RTE_PTYPE_INNER_L4_FRAG,
4492 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4493 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4494 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4495 : : RTE_PTYPE_INNER_L4_NONFRAG,
4496 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4497 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4498 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4499 : : RTE_PTYPE_INNER_L4_UDP,
4500 : : /* [128] reserved */
4501 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4502 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4503 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4504 : : RTE_PTYPE_INNER_L4_TCP,
4505 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4506 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4507 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4508 : : RTE_PTYPE_INNER_L4_SCTP,
4509 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4510 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4511 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4512 : : RTE_PTYPE_INNER_L4_ICMP,
4513 : :
4514 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4515 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4516 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4517 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4518 : : RTE_PTYPE_INNER_L4_FRAG,
4519 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4520 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4521 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4522 : : RTE_PTYPE_INNER_L4_NONFRAG,
4523 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4524 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4525 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4526 : : RTE_PTYPE_INNER_L4_UDP,
4527 : : /* [135] reserved */
4528 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4529 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4530 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4531 : : RTE_PTYPE_INNER_L4_TCP,
4532 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4533 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4534 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4535 : : RTE_PTYPE_INNER_L4_SCTP,
4536 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4537 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4538 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4539 : : RTE_PTYPE_INNER_L4_ICMP,
4540 : : /* [139] - [299] reserved */
4541 : :
4542 : : /* PPPoE */
4543 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4544 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4545 : :
4546 : : /* PPPoE --> IPv4 */
4547 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4548 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4549 : : RTE_PTYPE_L4_FRAG,
4550 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4551 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4552 : : RTE_PTYPE_L4_NONFRAG,
4553 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4554 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4555 : : RTE_PTYPE_L4_UDP,
4556 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4557 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4558 : : RTE_PTYPE_L4_TCP,
4559 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4560 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4561 : : RTE_PTYPE_L4_SCTP,
4562 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4563 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4564 : : RTE_PTYPE_L4_ICMP,
4565 : :
4566 : : /* PPPoE --> IPv6 */
4567 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4568 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4569 : : RTE_PTYPE_L4_FRAG,
4570 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4571 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4572 : : RTE_PTYPE_L4_NONFRAG,
4573 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4574 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4575 : : RTE_PTYPE_L4_UDP,
4576 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4577 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4578 : : RTE_PTYPE_L4_TCP,
4579 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4580 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4581 : : RTE_PTYPE_L4_SCTP,
4582 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4583 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4584 : : RTE_PTYPE_L4_ICMP,
4585 : : /* [314] - [324] reserved */
4586 : :
4587 : : /* IPv4/IPv6 --> GTPC/GTPU */
4588 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4589 : : RTE_PTYPE_TUNNEL_GTPC,
4590 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4591 : : RTE_PTYPE_TUNNEL_GTPC,
4592 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4593 : : RTE_PTYPE_TUNNEL_GTPC,
4594 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4595 : : RTE_PTYPE_TUNNEL_GTPC,
4596 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4597 : : RTE_PTYPE_TUNNEL_GTPU,
4598 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4599 : : RTE_PTYPE_TUNNEL_GTPU,
4600 : :
4601 : : /* IPv4 --> GTPU --> IPv4 */
4602 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4603 : : RTE_PTYPE_TUNNEL_GTPU |
4604 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4605 : : RTE_PTYPE_INNER_L4_FRAG,
4606 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4607 : : RTE_PTYPE_TUNNEL_GTPU |
4608 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4609 : : RTE_PTYPE_INNER_L4_NONFRAG,
4610 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4611 : : RTE_PTYPE_TUNNEL_GTPU |
4612 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4613 : : RTE_PTYPE_INNER_L4_UDP,
4614 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4615 : : RTE_PTYPE_TUNNEL_GTPU |
4616 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4617 : : RTE_PTYPE_INNER_L4_TCP,
4618 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4619 : : RTE_PTYPE_TUNNEL_GTPU |
4620 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4621 : : RTE_PTYPE_INNER_L4_ICMP,
4622 : :
4623 : : /* IPv6 --> GTPU --> IPv4 */
4624 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4625 : : RTE_PTYPE_TUNNEL_GTPU |
4626 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4627 : : RTE_PTYPE_INNER_L4_FRAG,
4628 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4629 : : RTE_PTYPE_TUNNEL_GTPU |
4630 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4631 : : RTE_PTYPE_INNER_L4_NONFRAG,
4632 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4633 : : RTE_PTYPE_TUNNEL_GTPU |
4634 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4635 : : RTE_PTYPE_INNER_L4_UDP,
4636 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4637 : : RTE_PTYPE_TUNNEL_GTPU |
4638 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4639 : : RTE_PTYPE_INNER_L4_TCP,
4640 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4641 : : RTE_PTYPE_TUNNEL_GTPU |
4642 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4643 : : RTE_PTYPE_INNER_L4_ICMP,
4644 : :
4645 : : /* IPv4 --> GTPU --> IPv6 */
4646 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4647 : : RTE_PTYPE_TUNNEL_GTPU |
4648 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4649 : : RTE_PTYPE_INNER_L4_FRAG,
4650 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4651 : : RTE_PTYPE_TUNNEL_GTPU |
4652 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4653 : : RTE_PTYPE_INNER_L4_NONFRAG,
4654 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4655 : : RTE_PTYPE_TUNNEL_GTPU |
4656 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4657 : : RTE_PTYPE_INNER_L4_UDP,
4658 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4659 : : RTE_PTYPE_TUNNEL_GTPU |
4660 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4661 : : RTE_PTYPE_INNER_L4_TCP,
4662 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4663 : : RTE_PTYPE_TUNNEL_GTPU |
4664 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4665 : : RTE_PTYPE_INNER_L4_ICMP,
4666 : :
4667 : : /* IPv6 --> GTPU --> IPv6 */
4668 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4669 : : RTE_PTYPE_TUNNEL_GTPU |
4670 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4671 : : RTE_PTYPE_INNER_L4_FRAG,
4672 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4673 : : RTE_PTYPE_TUNNEL_GTPU |
4674 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4675 : : RTE_PTYPE_INNER_L4_NONFRAG,
4676 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4677 : : RTE_PTYPE_TUNNEL_GTPU |
4678 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4679 : : RTE_PTYPE_INNER_L4_UDP,
4680 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4681 : : RTE_PTYPE_TUNNEL_GTPU |
4682 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4683 : : RTE_PTYPE_INNER_L4_TCP,
4684 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4685 : : RTE_PTYPE_TUNNEL_GTPU |
4686 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4687 : : RTE_PTYPE_INNER_L4_ICMP,
4688 : :
4689 : : /* IPv4 --> UDP ECPRI */
4690 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4691 : : RTE_PTYPE_L4_UDP,
4692 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4693 : : RTE_PTYPE_L4_UDP,
4694 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4695 : : RTE_PTYPE_L4_UDP,
4696 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4697 : : RTE_PTYPE_L4_UDP,
4698 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4699 : : RTE_PTYPE_L4_UDP,
4700 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4701 : : RTE_PTYPE_L4_UDP,
4702 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4703 : : RTE_PTYPE_L4_UDP,
4704 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4705 : : RTE_PTYPE_L4_UDP,
4706 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4707 : : RTE_PTYPE_L4_UDP,
4708 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4709 : : RTE_PTYPE_L4_UDP,
4710 : :
4711 : : /* IPV6 --> UDP ECPRI */
4712 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4713 : : RTE_PTYPE_L4_UDP,
4714 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4715 : : RTE_PTYPE_L4_UDP,
4716 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4717 : : RTE_PTYPE_L4_UDP,
4718 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4719 : : RTE_PTYPE_L4_UDP,
4720 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4721 : : RTE_PTYPE_L4_UDP,
4722 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4723 : : RTE_PTYPE_L4_UDP,
4724 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4725 : : RTE_PTYPE_L4_UDP,
4726 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4727 : : RTE_PTYPE_L4_UDP,
4728 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4729 : : RTE_PTYPE_L4_UDP,
4730 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4731 : : RTE_PTYPE_L4_UDP,
4732 : : /* All others reserved */
4733 : : };
4734 : :
4735 : 0 : return ptype_tbl[ptype];
4736 : : }
4737 : :
4738 : : void __rte_cold
4739 : 0 : iavf_set_default_ptype_table(struct rte_eth_dev *dev)
4740 : : {
4741 : 0 : struct iavf_adapter *ad =
4742 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4743 : : int i;
4744 : :
4745 [ # # ]: 0 : for (i = 0; i < IAVF_MAX_PKT_TYPE; i++)
4746 : 0 : ad->ptype_tbl[i] = iavf_get_default_ptype(i);
4747 : 0 : }
|