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_ARM
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 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1511 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1512 : :
1513 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1514 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1515 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1516 : 0 : rxq->hw_time_update = sw_cur_time;
1517 : : }
1518 : : }
1519 : :
1520 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1521 : 0 : rxdp = &rx_ring[rx_id];
1522 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1523 : :
1524 : : /* Check the DD bit first */
1525 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1526 : : break;
1527 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1528 : :
1529 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1530 [ # # ]: 0 : if (unlikely(!nmb)) {
1531 : 0 : dev = &rte_eth_devices[rxq->port_id];
1532 : 0 : dev->data->rx_mbuf_alloc_failed++;
1533 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1534 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1535 : 0 : break;
1536 : : }
1537 : :
1538 : 0 : rxd = *rxdp;
1539 : 0 : nb_hold++;
1540 : 0 : rxe = rxq->sw_ring[rx_id];
1541 : 0 : rxq->sw_ring[rx_id].mbuf = nmb;
1542 : 0 : rx_id++;
1543 [ # # ]: 0 : if (unlikely(rx_id == rxq->nb_rx_desc))
1544 : : rx_id = 0;
1545 : :
1546 : : /* Prefetch next mbuf */
1547 : 0 : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1548 : :
1549 : : /* When next RX descriptor is on a cache line boundary,
1550 : : * prefetch the next 4 RX descriptors and next 8 pointers
1551 : : * to mbufs.
1552 : : */
1553 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1554 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1555 : : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1556 : : }
1557 : : rxm = rxe.mbuf;
1558 : : dma_addr =
1559 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1560 : 0 : rxdp->read.hdr_addr = 0;
1561 : 0 : rxdp->read.pkt_addr = dma_addr;
1562 : :
1563 : 0 : rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
1564 : 0 : IAVF_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1565 : :
1566 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1567 : 0 : rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
1568 : 0 : rxm->nb_segs = 1;
1569 : 0 : rxm->next = NULL;
1570 : 0 : rxm->pkt_len = rx_packet_len;
1571 : 0 : rxm->data_len = rx_packet_len;
1572 : 0 : rxm->port = rxq->port_id;
1573 : 0 : rxm->ol_flags = 0;
1574 : 0 : rxm->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
1575 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
1576 : 0 : iavf_flex_rxd_to_vlan_tci(rxm, &rxd);
1577 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(rxm, &rxd,
1578 : 0 : &rxq->stats->ipsec_crypto);
1579 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
1580 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0);
1581 : :
1582 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0 &&
1583 [ # # ]: 0 : rxd.wb.time_stamp_low & IAVF_RX_FLX_DESC_TS_VALID) {
1584 [ # # ]: 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
1585 : : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
1586 : :
1587 : 0 : rxq->phc_time = ts_ns;
1588 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1589 : :
1590 : 0 : *RTE_MBUF_DYNFIELD(rxm,
1591 : : iavf_timestamp_dynfield_offset,
1592 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
1593 : 0 : rxm->ol_flags |= iavf_timestamp_dynflag;
1594 : : }
1595 : :
1596 : 0 : rxm->ol_flags |= pkt_flags;
1597 : :
1598 : 0 : rx_pkts[nb_rx++] = rxm;
1599 : : }
1600 : 0 : rxq->rx_tail = rx_id;
1601 : :
1602 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1603 : :
1604 : 0 : return nb_rx;
1605 : : }
1606 : :
1607 : : /* implement recv_scattered_pkts for flexible Rx descriptor */
1608 : : uint16_t
1609 : 0 : iavf_recv_scattered_pkts_flex_rxd(void *rx_queue, struct rte_mbuf **rx_pkts,
1610 : : uint16_t nb_pkts)
1611 : : {
1612 : : struct ci_rx_queue *rxq = rx_queue;
1613 : : union ci_rx_flex_desc rxd;
1614 : : struct ci_rx_entry rxe;
1615 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1616 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1617 : : struct rte_mbuf *nmb, *rxm;
1618 : 0 : uint16_t rx_id = rxq->rx_tail;
1619 : : uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
1620 : : struct rte_eth_dev *dev;
1621 : : uint16_t rx_stat_err0;
1622 : : uint64_t dma_addr;
1623 : : uint64_t pkt_flags;
1624 : : uint64_t ts_ns;
1625 : :
1626 : 0 : volatile union ci_rx_flex_desc *rx_ring = rxq->rx_flex_ring;
1627 : : volatile union ci_rx_flex_desc *rxdp;
1628 : 0 : const uint32_t *ptype_tbl = rxq->iavf_vsi->adapter->ptype_tbl;
1629 : :
1630 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1631 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1632 : :
1633 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1634 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1635 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1636 : 0 : rxq->hw_time_update = sw_cur_time;
1637 : : }
1638 : : }
1639 : :
1640 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1641 : 0 : rxdp = &rx_ring[rx_id];
1642 : 0 : rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1643 : :
1644 : : /* Check the DD bit */
1645 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1646 : : break;
1647 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1648 : :
1649 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1650 [ # # ]: 0 : if (unlikely(!nmb)) {
1651 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1652 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1653 : 0 : dev = &rte_eth_devices[rxq->port_id];
1654 : 0 : dev->data->rx_mbuf_alloc_failed++;
1655 : 0 : break;
1656 : : }
1657 : :
1658 : 0 : rxd = *rxdp;
1659 : 0 : nb_hold++;
1660 : 0 : rxe = rxq->sw_ring[rx_id];
1661 : 0 : rxq->sw_ring[rx_id].mbuf = nmb;
1662 : 0 : rx_id++;
1663 [ # # ]: 0 : if (rx_id == rxq->nb_rx_desc)
1664 : : rx_id = 0;
1665 : :
1666 : : /* Prefetch next mbuf */
1667 : 0 : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1668 : :
1669 : : /* When next RX descriptor is on a cache line boundary,
1670 : : * prefetch the next 4 RX descriptors and next 8 pointers
1671 : : * to mbufs.
1672 : : */
1673 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1674 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1675 : : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1676 : : }
1677 : :
1678 : : rxm = rxe.mbuf;
1679 : : dma_addr =
1680 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1681 : :
1682 : : /* Set data buffer address and data length of the mbuf */
1683 : 0 : rxdp->read.hdr_addr = 0;
1684 : 0 : rxdp->read.pkt_addr = dma_addr;
1685 : 0 : rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
1686 : : IAVF_RX_FLX_DESC_PKT_LEN_M;
1687 : 0 : rxm->data_len = rx_packet_len;
1688 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1689 : :
1690 : : /* If this is the first buffer of the received packet, set the
1691 : : * pointer to the first mbuf of the packet and initialize its
1692 : : * context. Otherwise, update the total length and the number
1693 : : * of segments of the current scattered packet, and update the
1694 : : * pointer to the last mbuf of the current packet.
1695 : : */
1696 [ # # ]: 0 : if (!first_seg) {
1697 : : first_seg = rxm;
1698 : 0 : first_seg->nb_segs = 1;
1699 : 0 : first_seg->pkt_len = rx_packet_len;
1700 : : } else {
1701 : 0 : first_seg->pkt_len =
1702 : 0 : (uint16_t)(first_seg->pkt_len +
1703 : : rx_packet_len);
1704 : 0 : first_seg->nb_segs++;
1705 : 0 : last_seg->next = rxm;
1706 : : }
1707 : :
1708 : : /* If this is not the last buffer of the received packet,
1709 : : * update the pointer to the last mbuf of the current scattered
1710 : : * packet and continue to parse the RX ring.
1711 : : */
1712 [ # # ]: 0 : if (!(rx_stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_EOF_S))) {
1713 : : last_seg = rxm;
1714 : 0 : continue;
1715 : : }
1716 : :
1717 : : /* This is the last buffer of the received packet. If the CRC
1718 : : * is not stripped by the hardware:
1719 : : * - Subtract the CRC length from the total packet length.
1720 : : * - If the last buffer only contains the whole CRC or a part
1721 : : * of it, free the mbuf associated to the last buffer. If part
1722 : : * of the CRC is also contained in the previous mbuf, subtract
1723 : : * the length of that CRC part from the data length of the
1724 : : * previous mbuf.
1725 : : */
1726 : 0 : rxm->next = NULL;
1727 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
1728 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
1729 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
1730 : : rte_pktmbuf_free_seg(rxm);
1731 : 0 : first_seg->nb_segs--;
1732 : 0 : last_seg->data_len =
1733 : 0 : (uint16_t)(last_seg->data_len -
1734 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
1735 : 0 : last_seg->next = NULL;
1736 : : } else {
1737 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
1738 : : RTE_ETHER_CRC_LEN);
1739 : : }
1740 : : }
1741 : :
1742 : 0 : first_seg->port = rxq->port_id;
1743 : 0 : first_seg->ol_flags = 0;
1744 : 0 : first_seg->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
1745 : 0 : rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
1746 : 0 : iavf_flex_rxd_to_vlan_tci(first_seg, &rxd);
1747 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(first_seg, &rxd,
1748 : 0 : &rxq->stats->ipsec_crypto);
1749 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd);
1750 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(rx_stat_err0);
1751 : :
1752 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0 &&
1753 [ # # ]: 0 : rxd.wb.time_stamp_low & IAVF_RX_FLX_DESC_TS_VALID) {
1754 [ # # ]: 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
1755 : : rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
1756 : :
1757 : 0 : rxq->phc_time = ts_ns;
1758 : 0 : rxq->hw_time_update = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1759 : :
1760 : 0 : *RTE_MBUF_DYNFIELD(first_seg,
1761 : : iavf_timestamp_dynfield_offset,
1762 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
1763 : 0 : first_seg->ol_flags |= iavf_timestamp_dynflag;
1764 : : }
1765 : :
1766 : 0 : first_seg->ol_flags |= pkt_flags;
1767 : :
1768 : : /* Prefetch data of first segment, if configured to do so. */
1769 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1770 : : first_seg->data_off));
1771 : 0 : rx_pkts[nb_rx++] = first_seg;
1772 : : first_seg = NULL;
1773 : : }
1774 : :
1775 : : /* Record index of the next RX descriptor to probe. */
1776 : 0 : rxq->rx_tail = rx_id;
1777 : 0 : rxq->pkt_first_seg = first_seg;
1778 : 0 : rxq->pkt_last_seg = last_seg;
1779 : :
1780 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1781 : :
1782 : 0 : return nb_rx;
1783 : : }
1784 : :
1785 : : /* implement recv_scattered_pkts */
1786 : : uint16_t
1787 : 0 : iavf_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
1788 : : uint16_t nb_pkts)
1789 : : {
1790 : : struct ci_rx_queue *rxq = rx_queue;
1791 : : union ci_rx_desc rxd;
1792 : : struct ci_rx_entry rxe;
1793 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1794 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1795 : : struct rte_mbuf *nmb, *rxm;
1796 : 0 : uint16_t rx_id = rxq->rx_tail;
1797 : : uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
1798 : : struct rte_eth_dev *dev;
1799 : : uint32_t rx_status;
1800 : : uint64_t qword1;
1801 : : uint64_t dma_addr;
1802 : : uint64_t pkt_flags;
1803 : :
1804 : 0 : volatile union ci_rx_desc *rx_ring = rxq->rx_ring;
1805 : : volatile union ci_rx_desc *rxdp;
1806 : 0 : const uint32_t *ptype_tbl = rxq->iavf_vsi->adapter->ptype_tbl;
1807 : :
1808 [ # # ]: 0 : while (nb_rx < nb_pkts) {
1809 : 0 : rxdp = &rx_ring[rx_id];
1810 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
1811 : 0 : rx_status = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
1812 : : IAVF_RXD_QW1_STATUS_SHIFT;
1813 : :
1814 : : /* Check the DD bit */
1815 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)))
1816 : : break;
1817 : : IAVF_DUMP_RX_DESC(rxq, rxdp, rx_id);
1818 : :
1819 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mp);
1820 [ # # ]: 0 : if (unlikely(!nmb)) {
1821 : : PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
1822 : : "queue_id=%u", rxq->port_id, rxq->queue_id);
1823 : 0 : dev = &rte_eth_devices[rxq->port_id];
1824 : 0 : dev->data->rx_mbuf_alloc_failed++;
1825 : 0 : break;
1826 : : }
1827 : :
1828 : 0 : rxd = *rxdp;
1829 : 0 : nb_hold++;
1830 : 0 : rxe = rxq->sw_ring[rx_id];
1831 : 0 : rxq->sw_ring[rx_id].mbuf = nmb;
1832 : 0 : rx_id++;
1833 [ # # ]: 0 : if (rx_id == rxq->nb_rx_desc)
1834 : : rx_id = 0;
1835 : :
1836 : : /* Prefetch next mbuf */
1837 : 0 : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1838 : :
1839 : : /* When next RX descriptor is on a cache line boundary,
1840 : : * prefetch the next 4 RX descriptors and next 8 pointers
1841 : : * to mbufs.
1842 : : */
1843 [ # # ]: 0 : if ((rx_id & 0x3) == 0) {
1844 : 0 : rte_prefetch0(&rx_ring[rx_id]);
1845 : : rte_prefetch0(rxq->sw_ring[rx_id].mbuf);
1846 : : }
1847 : :
1848 : : rxm = rxe.mbuf;
1849 : : dma_addr =
1850 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1851 : :
1852 : : /* Set data buffer address and data length of the mbuf */
1853 : 0 : rxdp->read.hdr_addr = 0;
1854 : 0 : rxdp->read.pkt_addr = dma_addr;
1855 : 0 : rx_packet_len = (qword1 & IAVF_RXD_QW1_LENGTH_PBUF_MASK) >>
1856 : : IAVF_RXD_QW1_LENGTH_PBUF_SHIFT;
1857 : 0 : rxm->data_len = rx_packet_len;
1858 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
1859 : :
1860 : : /* If this is the first buffer of the received packet, set the
1861 : : * pointer to the first mbuf of the packet and initialize its
1862 : : * context. Otherwise, update the total length and the number
1863 : : * of segments of the current scattered packet, and update the
1864 : : * pointer to the last mbuf of the current packet.
1865 : : */
1866 [ # # ]: 0 : if (!first_seg) {
1867 : : first_seg = rxm;
1868 : 0 : first_seg->nb_segs = 1;
1869 : 0 : first_seg->pkt_len = rx_packet_len;
1870 : : } else {
1871 : 0 : first_seg->pkt_len =
1872 : 0 : (uint16_t)(first_seg->pkt_len +
1873 : : rx_packet_len);
1874 : 0 : first_seg->nb_segs++;
1875 : 0 : last_seg->next = rxm;
1876 : : }
1877 : :
1878 : : /* If this is not the last buffer of the received packet,
1879 : : * update the pointer to the last mbuf of the current scattered
1880 : : * packet and continue to parse the RX ring.
1881 : : */
1882 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_EOF_SHIFT))) {
1883 : : last_seg = rxm;
1884 : 0 : continue;
1885 : : }
1886 : :
1887 : : /* This is the last buffer of the received packet. If the CRC
1888 : : * is not stripped by the hardware:
1889 : : * - Subtract the CRC length from the total packet length.
1890 : : * - If the last buffer only contains the whole CRC or a part
1891 : : * of it, free the mbuf associated to the last buffer. If part
1892 : : * of the CRC is also contained in the previous mbuf, subtract
1893 : : * the length of that CRC part from the data length of the
1894 : : * previous mbuf.
1895 : : */
1896 : 0 : rxm->next = NULL;
1897 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
1898 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
1899 [ # # ]: 0 : if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
1900 : : rte_pktmbuf_free_seg(rxm);
1901 : 0 : first_seg->nb_segs--;
1902 : 0 : last_seg->data_len =
1903 : 0 : (uint16_t)(last_seg->data_len -
1904 : : (RTE_ETHER_CRC_LEN - rx_packet_len));
1905 : 0 : last_seg->next = NULL;
1906 : : } else
1907 : 0 : rxm->data_len = (uint16_t)(rx_packet_len -
1908 : : RTE_ETHER_CRC_LEN);
1909 : : }
1910 : :
1911 : 0 : first_seg->port = rxq->port_id;
1912 [ # # ]: 0 : first_seg->ol_flags = 0;
1913 : : iavf_rxd_to_vlan_tci(first_seg, &rxd);
1914 : 0 : pkt_flags = iavf_rxd_to_pkt_flags(qword1);
1915 : 0 : first_seg->packet_type =
1916 : 0 : ptype_tbl[(uint8_t)((qword1 &
1917 : 0 : IAVF_RXD_QW1_PTYPE_MASK) >> IAVF_RXD_QW1_PTYPE_SHIFT)];
1918 : :
1919 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_RSS_HASH)
1920 : 0 : first_seg->hash.rss =
1921 : 0 : rte_le_to_cpu_32(rxd.wb.qword0.hi_dword.rss);
1922 : :
1923 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_FDIR)
1924 : 0 : pkt_flags |= iavf_rxd_build_fdir(&rxd, first_seg);
1925 : :
1926 : 0 : first_seg->ol_flags |= pkt_flags;
1927 : :
1928 : : /* Prefetch data of first segment, if configured to do so. */
1929 : 0 : rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1930 : : first_seg->data_off));
1931 : 0 : rx_pkts[nb_rx++] = first_seg;
1932 : : first_seg = NULL;
1933 : : }
1934 : :
1935 : : /* Record index of the next RX descriptor to probe. */
1936 : 0 : rxq->rx_tail = rx_id;
1937 : 0 : rxq->pkt_first_seg = first_seg;
1938 : 0 : rxq->pkt_last_seg = last_seg;
1939 : :
1940 : 0 : iavf_update_rx_tail(rxq, nb_hold, rx_id);
1941 : :
1942 : 0 : return nb_rx;
1943 : : }
1944 : :
1945 : : #define IAVF_LOOK_AHEAD 8
1946 : : static inline int
1947 : 0 : iavf_rx_scan_hw_ring_flex_rxd(struct ci_rx_queue *rxq,
1948 : : struct rte_mbuf **rx_pkts,
1949 : : uint16_t nb_pkts)
1950 : : {
1951 : : volatile union ci_rx_flex_desc *rxdp;
1952 : : struct ci_rx_entry *rxep;
1953 : : struct rte_mbuf *mb;
1954 : : uint16_t stat_err0;
1955 : : uint16_t pkt_len;
1956 : : int32_t s[IAVF_LOOK_AHEAD], var, nb_dd;
1957 : : int32_t i, j, nb_rx = 0;
1958 : : int32_t nb_staged = 0;
1959 : : uint64_t pkt_flags;
1960 : 0 : const uint32_t *ptype_tbl = rxq->iavf_vsi->adapter->ptype_tbl;
1961 : : uint64_t ts_ns;
1962 : :
1963 : 0 : rxdp = &rxq->rx_flex_ring[rxq->rx_tail];
1964 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
1965 : :
1966 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1967 : :
1968 : : /* Make sure there is at least 1 packet to receive */
1969 [ # # ]: 0 : if (!(stat_err0 & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S)))
1970 : : return 0;
1971 : :
1972 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1973 : 0 : uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
1974 : :
1975 [ # # ]: 0 : if (sw_cur_time - rxq->hw_time_update > 4) {
1976 [ # # ]: 0 : if (iavf_get_phc_time(rxq))
1977 : 0 : PMD_DRV_LOG(ERR, "get physical time failed");
1978 : 0 : rxq->hw_time_update = sw_cur_time;
1979 : : }
1980 : : }
1981 : :
1982 : : /* Scan LOOK_AHEAD descriptors at a time to determine which
1983 : : * descriptors reference packets that are ready to be received.
1984 : : */
1985 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i += IAVF_LOOK_AHEAD,
1986 : 0 : rxdp += IAVF_LOOK_AHEAD, rxep += IAVF_LOOK_AHEAD) {
1987 : : /* Read desc statuses backwards to avoid race condition */
1988 [ # # ]: 0 : for (j = IAVF_LOOK_AHEAD - 1; j >= 0; j--)
1989 : 0 : s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1990 : :
1991 : : /* This barrier is to order loads of different words in the descriptor */
1992 : : rte_atomic_thread_fence(rte_memory_order_acquire);
1993 : :
1994 : : /* Compute how many contiguous DD bits were set */
1995 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < IAVF_LOOK_AHEAD; j++) {
1996 : 0 : var = s[j] & (1 << IAVF_RX_FLEX_DESC_STATUS0_DD_S);
1997 : : #ifdef RTE_ARCH_ARM
1998 : : /* For Arm platforms, count only contiguous descriptors
1999 : : * whose DD bit is set to 1. On Arm platforms, reads of
2000 : : * descriptors can be reordered. Since the CPU may
2001 : : * be reading the descriptors as the NIC updates them
2002 : : * in memory, it is possbile that the DD bit for a
2003 : : * descriptor earlier in the queue is read as not set
2004 : : * while the DD bit for a descriptor later in the queue
2005 : : * is read as set.
2006 : : */
2007 : : if (var)
2008 : : nb_dd += 1;
2009 : : else
2010 : : break;
2011 : : #else
2012 : 0 : nb_dd += var;
2013 : : #endif
2014 : : }
2015 : :
2016 : : /* Translate descriptor info to mbuf parameters */
2017 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
2018 : : IAVF_DUMP_RX_DESC(rxq, &rxdp[j],
2019 : : rxq->rx_tail +
2020 : : i * IAVF_LOOK_AHEAD + j);
2021 : :
2022 : 0 : mb = rxep[j].mbuf;
2023 : 0 : pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
2024 : 0 : IAVF_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2025 : 0 : mb->data_len = pkt_len;
2026 : 0 : mb->pkt_len = pkt_len;
2027 : 0 : mb->ol_flags = 0;
2028 : :
2029 : 0 : mb->packet_type = ptype_tbl[IAVF_RX_FLEX_DESC_PTYPE_M &
2030 : 0 : rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
2031 : 0 : iavf_flex_rxd_to_vlan_tci(mb, &rxdp[j]);
2032 : 0 : iavf_flex_rxd_to_ipsec_crypto_status(mb, &rxdp[j],
2033 : 0 : &rxq->stats->ipsec_crypto);
2034 : 0 : rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);
2035 : 0 : stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
2036 : 0 : pkt_flags = iavf_flex_rxd_error_to_pkt_flags(stat_err0);
2037 : :
2038 [ # # ]: 0 : if (iavf_timestamp_dynflag > 0 &&
2039 [ # # ]: 0 : rxdp[j].wb.time_stamp_low & IAVF_RX_FLX_DESC_TS_VALID) {
2040 : 0 : ts_ns = iavf_tstamp_convert_32b_64b(rxq->phc_time,
2041 [ # # ]: 0 : rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high));
2042 : :
2043 : 0 : rxq->phc_time = ts_ns;
2044 : 0 : rxq->hw_time_update = rte_get_timer_cycles() /
2045 : 0 : (rte_get_timer_hz() / 1000);
2046 : :
2047 : 0 : *RTE_MBUF_DYNFIELD(mb,
2048 : : iavf_timestamp_dynfield_offset,
2049 : 0 : rte_mbuf_timestamp_t *) = ts_ns;
2050 : 0 : mb->ol_flags |= iavf_timestamp_dynflag;
2051 : : }
2052 : :
2053 : 0 : mb->ol_flags |= pkt_flags;
2054 : :
2055 : : /* Put up to nb_pkts directly into buffers */
2056 [ # # ]: 0 : if ((i + j) < nb_pkts) {
2057 : 0 : rx_pkts[i + j] = rxep[j].mbuf;
2058 : 0 : nb_rx++;
2059 : : } else {
2060 : : /* Stage excess pkts received */
2061 : 0 : rxq->rx_stage[nb_staged] = rxep[j].mbuf;
2062 : 0 : nb_staged++;
2063 : : }
2064 : : }
2065 : :
2066 [ # # ]: 0 : if (nb_dd != IAVF_LOOK_AHEAD)
2067 : : break;
2068 : : }
2069 : :
2070 : : /* Update rxq->rx_nb_avail to reflect number of staged pkts */
2071 : 0 : rxq->rx_nb_avail = nb_staged;
2072 : :
2073 : : /* Clear software ring entries */
2074 [ # # ]: 0 : for (i = 0; i < (nb_rx + nb_staged); i++)
2075 : 0 : rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
2076 : :
2077 : : return nb_rx;
2078 : : }
2079 : :
2080 : : static inline int
2081 : 0 : iavf_rx_scan_hw_ring(struct ci_rx_queue *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2082 : : {
2083 : : volatile union ci_rx_desc *rxdp;
2084 : : struct ci_rx_entry *rxep;
2085 : : struct rte_mbuf *mb;
2086 : : uint16_t pkt_len;
2087 : : uint64_t qword1;
2088 : : uint32_t rx_status;
2089 : : int32_t s[IAVF_LOOK_AHEAD], var, nb_dd;
2090 : : int32_t i, j, nb_rx = 0;
2091 : : int32_t nb_staged = 0;
2092 : : uint64_t pkt_flags;
2093 : 0 : const uint32_t *ptype_tbl = rxq->iavf_vsi->adapter->ptype_tbl;
2094 : :
2095 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
2096 : 0 : rxep = &rxq->sw_ring[rxq->rx_tail];
2097 : :
2098 : 0 : qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
2099 : 0 : rx_status = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
2100 : : IAVF_RXD_QW1_STATUS_SHIFT;
2101 : :
2102 : : /* Make sure there is at least 1 packet to receive */
2103 [ # # ]: 0 : if (!(rx_status & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)))
2104 : : return 0;
2105 : :
2106 : : /* Scan LOOK_AHEAD descriptors at a time to determine which
2107 : : * descriptors reference packets that are ready to be received.
2108 : : */
2109 [ # # ]: 0 : for (i = 0; i < IAVF_RX_MAX_BURST; i += IAVF_LOOK_AHEAD,
2110 : 0 : rxdp += IAVF_LOOK_AHEAD, rxep += IAVF_LOOK_AHEAD) {
2111 : : /* Read desc statuses backwards to avoid race condition */
2112 [ # # ]: 0 : for (j = IAVF_LOOK_AHEAD - 1; j >= 0; j--) {
2113 : 0 : qword1 = rte_le_to_cpu_64(
2114 : : rxdp[j].wb.qword1.status_error_len);
2115 : 0 : s[j] = (qword1 & IAVF_RXD_QW1_STATUS_MASK) >>
2116 : : IAVF_RXD_QW1_STATUS_SHIFT;
2117 : : }
2118 : :
2119 : : /* This barrier is to order loads of different words in the descriptor */
2120 : : rte_atomic_thread_fence(rte_memory_order_acquire);
2121 : :
2122 : : /* Compute how many contiguous DD bits were set */
2123 [ # # ]: 0 : for (j = 0, nb_dd = 0; j < IAVF_LOOK_AHEAD; j++) {
2124 : 0 : var = s[j] & (1 << IAVF_RX_DESC_STATUS_DD_SHIFT);
2125 : : #ifdef RTE_ARCH_ARM
2126 : : /* For Arm platforms, count only contiguous descriptors
2127 : : * whose DD bit is set to 1. On Arm platforms, reads of
2128 : : * descriptors can be reordered. Since the CPU may
2129 : : * be reading the descriptors as the NIC updates them
2130 : : * in memory, it is possbile that the DD bit for a
2131 : : * descriptor earlier in the queue is read as not set
2132 : : * while the DD bit for a descriptor later in the queue
2133 : : * is read as set.
2134 : : */
2135 : : if (var)
2136 : : nb_dd += 1;
2137 : : else
2138 : : break;
2139 : : #else
2140 : 0 : nb_dd += var;
2141 : : #endif
2142 : : }
2143 : :
2144 : : /* Translate descriptor info to mbuf parameters */
2145 [ # # ]: 0 : for (j = 0; j < nb_dd; j++) {
2146 : : IAVF_DUMP_RX_DESC(rxq, &rxdp[j],
2147 : : rxq->rx_tail + i * IAVF_LOOK_AHEAD + j);
2148 : :
2149 : 0 : mb = rxep[j].mbuf;
2150 : 0 : qword1 = rte_le_to_cpu_64
2151 : : (rxdp[j].wb.qword1.status_error_len);
2152 : 0 : pkt_len = ((qword1 & IAVF_RXD_QW1_LENGTH_PBUF_MASK) >>
2153 : 0 : IAVF_RXD_QW1_LENGTH_PBUF_SHIFT) - rxq->crc_len;
2154 : 0 : mb->data_len = pkt_len;
2155 : 0 : mb->pkt_len = pkt_len;
2156 [ # # ]: 0 : mb->ol_flags = 0;
2157 : : iavf_rxd_to_vlan_tci(mb, &rxdp[j]);
2158 : 0 : pkt_flags = iavf_rxd_to_pkt_flags(qword1);
2159 : 0 : mb->packet_type =
2160 : 0 : ptype_tbl[(uint8_t)((qword1 &
2161 : 0 : IAVF_RXD_QW1_PTYPE_MASK) >>
2162 : : IAVF_RXD_QW1_PTYPE_SHIFT)];
2163 : :
2164 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_RSS_HASH)
2165 : 0 : mb->hash.rss = rte_le_to_cpu_32(
2166 : : rxdp[j].wb.qword0.hi_dword.rss);
2167 : :
2168 [ # # ]: 0 : if (pkt_flags & RTE_MBUF_F_RX_FDIR)
2169 : 0 : pkt_flags |= iavf_rxd_build_fdir(&rxdp[j], mb);
2170 : :
2171 : 0 : mb->ol_flags |= pkt_flags;
2172 : :
2173 : : /* Put up to nb_pkts directly into buffers */
2174 [ # # ]: 0 : if ((i + j) < nb_pkts) {
2175 : 0 : rx_pkts[i + j] = rxep[j].mbuf;
2176 : 0 : nb_rx++;
2177 : : } else { /* Stage excess pkts received */
2178 : 0 : rxq->rx_stage[nb_staged] = rxep[j].mbuf;
2179 : 0 : nb_staged++;
2180 : : }
2181 : : }
2182 : :
2183 [ # # ]: 0 : if (nb_dd != IAVF_LOOK_AHEAD)
2184 : : break;
2185 : : }
2186 : :
2187 : : /* Update rxq->rx_nb_avail to reflect number of staged pkts */
2188 : 0 : rxq->rx_nb_avail = nb_staged;
2189 : :
2190 : : /* Clear software ring entries */
2191 [ # # ]: 0 : for (i = 0; i < (nb_rx + nb_staged); i++)
2192 : 0 : rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
2193 : :
2194 : : return nb_rx;
2195 : : }
2196 : :
2197 : : static inline uint16_t
2198 : : iavf_rx_fill_from_stage(struct ci_rx_queue *rxq,
2199 : : struct rte_mbuf **rx_pkts,
2200 : : uint16_t nb_pkts)
2201 : : {
2202 : : uint16_t i;
2203 : 0 : struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
2204 : :
2205 : 0 : nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
2206 : :
2207 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
2208 : 0 : rx_pkts[i] = stage[i];
2209 : :
2210 : 0 : rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
2211 : 0 : rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
2212 : :
2213 : : return nb_pkts;
2214 : : }
2215 : :
2216 : : static inline int
2217 : 0 : iavf_rx_alloc_bufs(struct ci_rx_queue *rxq)
2218 : : {
2219 : : volatile union ci_rx_desc *rxdp;
2220 : : struct ci_rx_entry *rxep;
2221 : : struct rte_mbuf *mb;
2222 : : uint16_t alloc_idx, i;
2223 : : uint64_t dma_addr;
2224 : : int diag;
2225 : :
2226 : : /* Allocate buffers in bulk */
2227 : 0 : alloc_idx = (uint16_t)(rxq->rx_free_trigger -
2228 : 0 : (rxq->rx_free_thresh - 1));
2229 : 0 : rxep = &rxq->sw_ring[alloc_idx];
2230 [ # # ]: 0 : diag = rte_mbuf_raw_alloc_bulk(rxq->mp, (void *)rxep,
2231 : : rxq->rx_free_thresh);
2232 [ # # ]: 0 : if (unlikely(diag != 0)) {
2233 : : PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
2234 : : return -ENOMEM;
2235 : : }
2236 : :
2237 : 0 : rxdp = &rxq->rx_ring[alloc_idx];
2238 [ # # ]: 0 : for (i = 0; i < rxq->rx_free_thresh; i++) {
2239 [ # # ]: 0 : if (likely(i < (rxq->rx_free_thresh - 1)))
2240 : : /* Prefetch next mbuf */
2241 : 0 : rte_prefetch0(rxep[i + 1].mbuf);
2242 : :
2243 : 0 : mb = rxep[i].mbuf;
2244 : : rte_mbuf_refcnt_set(mb, 1);
2245 : 0 : mb->next = NULL;
2246 : 0 : mb->data_off = RTE_PKTMBUF_HEADROOM;
2247 : 0 : mb->nb_segs = 1;
2248 : 0 : mb->port = rxq->port_id;
2249 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
2250 : 0 : rxdp[i].read.hdr_addr = 0;
2251 : 0 : rxdp[i].read.pkt_addr = dma_addr;
2252 : : }
2253 : :
2254 : : /* Update rx tail register */
2255 : : rte_wmb();
2256 [ # # ]: 0 : IAVF_PCI_REG_WC_WRITE_RELAXED(rxq->qrx_tail, rxq->rx_free_trigger);
2257 : :
2258 : 0 : rxq->rx_free_trigger =
2259 : 0 : (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
2260 [ # # ]: 0 : if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
2261 : 0 : rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
2262 : :
2263 : : return 0;
2264 : : }
2265 : :
2266 : : static inline uint16_t
2267 : 0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
2268 : : {
2269 : : struct ci_rx_queue *rxq = (struct ci_rx_queue *)rx_queue;
2270 : : uint16_t nb_rx = 0;
2271 : :
2272 [ # # ]: 0 : if (!nb_pkts)
2273 : : return 0;
2274 : :
2275 [ # # ]: 0 : if (rxq->rx_nb_avail)
2276 : 0 : return iavf_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
2277 : :
2278 [ # # ]: 0 : if (rxq->rxdid >= IAVF_RXDID_FLEX_NIC && rxq->rxdid <= IAVF_RXDID_LAST)
2279 : 0 : nb_rx = (uint16_t)iavf_rx_scan_hw_ring_flex_rxd(rxq, rx_pkts, nb_pkts);
2280 : : else
2281 : 0 : nb_rx = (uint16_t)iavf_rx_scan_hw_ring(rxq, rx_pkts, nb_pkts);
2282 : :
2283 : 0 : rxq->rx_next_avail = 0;
2284 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx + rxq->rx_nb_avail);
2285 : :
2286 [ # # ]: 0 : if (rxq->rx_tail > rxq->rx_free_trigger) {
2287 [ # # ]: 0 : if (iavf_rx_alloc_bufs(rxq) != 0) {
2288 : : uint16_t i, j, nb_staged;
2289 : :
2290 : : /* TODO: count rx_mbuf_alloc_failed here */
2291 : :
2292 : 0 : nb_staged = rxq->rx_nb_avail;
2293 : 0 : rxq->rx_nb_avail = 0;
2294 : :
2295 : 0 : rxq->rx_tail = (uint16_t)(rxq->rx_tail - (nb_rx + nb_staged));
2296 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++) {
2297 : 0 : rxq->sw_ring[j].mbuf = rx_pkts[i];
2298 : 0 : rx_pkts[i] = NULL;
2299 : : }
2300 [ # # ]: 0 : for (i = 0, j = rxq->rx_tail + nb_rx; i < nb_staged; i++, j++) {
2301 : 0 : rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
2302 : 0 : rx_pkts[i] = NULL;
2303 : : }
2304 : :
2305 : : return 0;
2306 : : }
2307 : : }
2308 : :
2309 [ # # ]: 0 : if (rxq->rx_tail >= rxq->nb_rx_desc)
2310 : 0 : rxq->rx_tail = 0;
2311 : :
2312 : : PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u, nb_rx=%u",
2313 : : rxq->port_id, rxq->queue_id,
2314 : : rxq->rx_tail, nb_rx);
2315 : :
2316 : : return nb_rx;
2317 : : }
2318 : :
2319 : : static uint16_t
2320 : 0 : iavf_recv_pkts_bulk_alloc(void *rx_queue,
2321 : : struct rte_mbuf **rx_pkts,
2322 : : uint16_t nb_pkts)
2323 : : {
2324 : : uint16_t nb_rx = 0, n, count;
2325 : :
2326 [ # # ]: 0 : if (unlikely(nb_pkts == 0))
2327 : : return 0;
2328 : :
2329 [ # # ]: 0 : if (likely(nb_pkts <= IAVF_RX_MAX_BURST))
2330 : 0 : return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
2331 : :
2332 [ # # ]: 0 : while (nb_pkts) {
2333 : 0 : n = RTE_MIN(nb_pkts, IAVF_RX_MAX_BURST);
2334 : 0 : count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
2335 : 0 : nb_rx = (uint16_t)(nb_rx + count);
2336 : 0 : nb_pkts = (uint16_t)(nb_pkts - count);
2337 [ # # ]: 0 : if (count < n)
2338 : : break;
2339 : : }
2340 : :
2341 : : return nb_rx;
2342 : : }
2343 : :
2344 : : /* Check if the context descriptor is needed for TX offloading */
2345 : : static inline uint16_t
2346 : : iavf_calc_context_desc(const struct rte_mbuf *mb, uint8_t vlan_flag)
2347 : : {
2348 : 0 : uint64_t flags = mb->ol_flags;
2349 : 0 : if (flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG |
2350 : : RTE_MBUF_F_TX_TUNNEL_MASK | RTE_MBUF_F_TX_OUTER_IP_CKSUM |
2351 : : RTE_MBUF_F_TX_OUTER_UDP_CKSUM | RTE_MBUF_F_TX_QINQ))
2352 : : return 1;
2353 [ # # # # ]: 0 : if (flags & RTE_MBUF_F_TX_VLAN &&
2354 : : vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
2355 : : return 1;
2356 : :
2357 [ # # # # ]: 0 : if (IAVF_CHECK_TX_LLDP(mb))
2358 : : return 1;
2359 : :
2360 : : return 0;
2361 : : }
2362 : :
2363 : : static inline void
2364 : 0 : iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, uint64_t ol_flags, const struct rte_mbuf *m)
2365 : : {
2366 : : uint64_t eip_typ = IAVF_TX_CTX_DESC_EIPT_NONE;
2367 : : uint64_t eip_len = 0;
2368 : : uint64_t eip_noinc = 0;
2369 : : /* Default - IP_ID is increment in each segment of LSO */
2370 : :
2371 [ # # # # ]: 0 : switch (ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 |
2372 : : RTE_MBUF_F_TX_OUTER_IPV6 |
2373 : : RTE_MBUF_F_TX_OUTER_IP_CKSUM)) {
2374 : 0 : case RTE_MBUF_F_TX_OUTER_IPV4:
2375 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV4_NO_CHECKSUM_OFFLOAD;
2376 : 0 : eip_len = m->outer_l3_len >> 2;
2377 : 0 : break;
2378 : 0 : case RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IP_CKSUM:
2379 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV4_CHECKSUM_OFFLOAD;
2380 : 0 : eip_len = m->outer_l3_len >> 2;
2381 : 0 : break;
2382 : 0 : case RTE_MBUF_F_TX_OUTER_IPV6:
2383 : : eip_typ = IAVF_TX_CTX_DESC_EIPT_IPV6;
2384 : 0 : eip_len = m->outer_l3_len >> 2;
2385 : 0 : break;
2386 : : }
2387 : :
2388 [ # # ]: 0 : if (!(ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
2389 : : /* L4TUNT: L4 Tunneling Type */
2390 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2391 : : case RTE_MBUF_F_TX_TUNNEL_IPIP:
2392 : : /* for non UDP / GRE tunneling, set to 00b */
2393 : : break;
2394 : 0 : case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2395 : : case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
2396 : : case RTE_MBUF_F_TX_TUNNEL_GTP:
2397 : : case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2398 : 0 : eip_typ |= IAVF_TXD_CTX_UDP_TUNNELING;
2399 : 0 : break;
2400 : 0 : case RTE_MBUF_F_TX_TUNNEL_GRE:
2401 : 0 : eip_typ |= IAVF_TXD_CTX_GRE_TUNNELING;
2402 : 0 : break;
2403 : : default:
2404 : : PMD_TX_LOG(ERR, "Tunnel type not supported");
2405 : : return;
2406 : : }
2407 : :
2408 : : /* L4TUNLEN: L4 Tunneling Length, in Words
2409 : : *
2410 : : * We depend on app to set rte_mbuf.l2_len correctly.
2411 : : * For IP in GRE it should be set to the length of the GRE
2412 : : * header;
2413 : : * For MAC in GRE or MAC in UDP it should be set to the length
2414 : : * of the GRE or UDP headers plus the inner MAC up to including
2415 : : * its last Ethertype.
2416 : : * If MPLS labels exists, it should include them as well.
2417 : : */
2418 : 0 : eip_typ |= (m->l2_len >> 1) << IAVF_TXD_CTX_QW0_NATLEN_SHIFT;
2419 : :
2420 : : /**
2421 : : * Calculate the tunneling UDP checksum.
2422 : : * Shall be set only if L4TUNT = 01b and EIPT is not zero
2423 : : */
2424 [ # # ]: 0 : if ((eip_typ & (IAVF_TX_CTX_EXT_IP_IPV6 |
2425 : : IAVF_TX_CTX_EXT_IP_IPV4 |
2426 : 0 : IAVF_TX_CTX_EXT_IP_IPV4_NO_CSUM)) &&
2427 [ # # ]: 0 : (eip_typ & IAVF_TXD_CTX_UDP_TUNNELING) &&
2428 [ # # ]: 0 : (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
2429 : 0 : eip_typ |= IAVF_TXD_CTX_QW0_L4T_CS_MASK;
2430 : : }
2431 : :
2432 : 0 : *qw0 = eip_typ << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPT_SHIFT |
2433 : 0 : eip_len << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIPLEN_SHIFT |
2434 : : eip_noinc << IAVF_TXD_CTX_QW0_TUN_PARAMS_EIP_NOINC_SHIFT;
2435 : : }
2436 : :
2437 : : static inline uint16_t
2438 : 0 : iavf_fill_ctx_desc_segmentation_field(volatile uint64_t *field, uint64_t ol_flags,
2439 : : const struct rte_mbuf *m, struct iavf_ipsec_crypto_pkt_metadata *ipsec_md)
2440 : : {
2441 : : uint64_t segmentation_field = 0;
2442 : : uint64_t total_length = 0;
2443 : :
2444 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
2445 : 0 : total_length = ipsec_md->l4_payload_len;
2446 : : } else {
2447 : 0 : total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len);
2448 : :
2449 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2450 : 0 : total_length -= m->outer_l3_len + m->outer_l2_len;
2451 : : }
2452 : :
2453 : : #ifdef RTE_ETHDEV_DEBUG_TX
2454 : : if (!m->l4_len || !m->tso_segsz)
2455 : : PMD_TX_LOG(DEBUG, "L4 length %d, LSO Segment size %d",
2456 : : m->l4_len, m->tso_segsz);
2457 : : if (m->tso_segsz < 88)
2458 : : PMD_TX_LOG(DEBUG, "LSO Segment size %d is less than minimum %d",
2459 : : m->tso_segsz, 88);
2460 : : #endif
2461 : 0 : segmentation_field =
2462 : 0 : (((uint64_t)total_length << IAVF_TXD_CTX_QW1_TSO_LEN_SHIFT) &
2463 : : IAVF_TXD_CTX_QW1_TSO_LEN_MASK) |
2464 : 0 : (((uint64_t)m->tso_segsz << IAVF_TXD_CTX_QW1_MSS_SHIFT) &
2465 : : IAVF_TXD_CTX_QW1_MSS_MASK);
2466 : :
2467 : 0 : *field |= segmentation_field;
2468 : :
2469 : 0 : return total_length;
2470 : : }
2471 : :
2472 : :
2473 : : struct iavf_tx_context_desc_qws {
2474 : : __le64 qw0;
2475 : : __le64 qw1;
2476 : : };
2477 : :
2478 : : /* IPsec callback for ci_xmit_pkts - gets IPsec descriptor information */
2479 : : static uint16_t
2480 : 0 : iavf_get_ipsec_desc(const struct rte_mbuf *mbuf, const struct ci_tx_queue *txq,
2481 : : void **ipsec_metadata, uint64_t *qw0, uint64_t *qw1)
2482 : : {
2483 : : struct iavf_ipsec_crypto_pkt_metadata *md;
2484 : :
2485 [ # # ]: 0 : if (!(mbuf->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD))
2486 : : return 0;
2487 : :
2488 : 0 : md = RTE_MBUF_DYNFIELD(mbuf, txq->ipsec_crypto_pkt_md_offset,
2489 : : struct iavf_ipsec_crypto_pkt_metadata *);
2490 [ # # ]: 0 : if (!md)
2491 : : return 0;
2492 : :
2493 : 0 : *ipsec_metadata = md;
2494 : :
2495 : : /* Fill IPsec descriptor using existing logic */
2496 : 0 : *qw0 = rte_cpu_to_le_64(((uint64_t)md->l4_payload_len <<
2497 : : IAVF_IPSEC_TX_DESC_QW0_L4PAYLEN_SHIFT) |
2498 : : ((uint64_t)md->esn << IAVF_IPSEC_TX_DESC_QW0_IPSECESN_SHIFT) |
2499 : : ((uint64_t)md->esp_trailer_len <<
2500 : : IAVF_IPSEC_TX_DESC_QW0_TRAILERLEN_SHIFT));
2501 : :
2502 : 0 : *qw1 = rte_cpu_to_le_64(((uint64_t)md->sa_idx <<
2503 : : IAVF_IPSEC_TX_DESC_QW1_IPSECSA_SHIFT) |
2504 : : ((uint64_t)md->next_proto <<
2505 : : IAVF_IPSEC_TX_DESC_QW1_IPSECNH_SHIFT) |
2506 : : ((uint64_t)(md->len_iv & 0x3) <<
2507 : : IAVF_IPSEC_TX_DESC_QW1_IVLEN_SHIFT) |
2508 : : ((uint64_t)(md->ol_flags & IAVF_IPSEC_CRYPTO_OL_FLAGS_NATT ?
2509 : : 1ULL : 0ULL) <<
2510 : : IAVF_IPSEC_TX_DESC_QW1_UDP_SHIFT) |
2511 : : ((uint64_t)IAVF_TX_DESC_DTYPE_IPSEC <<
2512 : : CI_TXD_QW1_DTYPE_S));
2513 : :
2514 : 0 : return 1; /* One IPsec descriptor needed */
2515 : : }
2516 : :
2517 : : /* IPsec callback for ci_xmit_pkts - calculates segment length for IPsec+TSO */
2518 : : static uint16_t
2519 : 0 : iavf_calc_ipsec_segment_len(const struct rte_mbuf *mb_seg, uint64_t ol_flags,
2520 : : const void *ipsec_metadata, uint16_t tlen)
2521 : : {
2522 : : const struct iavf_ipsec_crypto_pkt_metadata *ipsec_md = ipsec_metadata;
2523 : :
2524 [ # # ]: 0 : if ((ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) &&
2525 [ # # ]: 0 : (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
2526 [ # # ]: 0 : uint16_t ipseclen = ipsec_md ? (ipsec_md->esp_trailer_len +
2527 : 0 : ipsec_md->len_iv) : 0;
2528 : 0 : uint16_t slen = tlen + mb_seg->l2_len + mb_seg->l3_len +
2529 : 0 : mb_seg->outer_l3_len + ipseclen;
2530 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_L4_MASK)
2531 : 0 : slen += mb_seg->l4_len;
2532 : 0 : return slen;
2533 : : }
2534 : :
2535 : 0 : return mb_seg->data_len;
2536 : : }
2537 : :
2538 : : /* Context descriptor callback for ci_xmit_pkts */
2539 : : static uint16_t
2540 : 0 : iavf_get_context_desc(uint64_t ol_flags, const struct rte_mbuf *mbuf,
2541 : : const union ci_tx_offload *tx_offload __rte_unused,
2542 : : const struct ci_tx_queue *txq,
2543 : : uint64_t *qw0, uint64_t *qw1)
2544 : : {
2545 : : uint8_t iavf_vlan_flag;
2546 : : uint16_t cd_l2tag2 = 0;
2547 : 0 : uint64_t cd_type_cmd = IAVF_TX_DESC_DTYPE_CONTEXT;
2548 : 0 : uint64_t cd_tunneling_params = 0;
2549 : : struct iavf_ipsec_crypto_pkt_metadata *ipsec_md = NULL;
2550 : :
2551 : : /* Use IAVF-specific vlan_flag from txq */
2552 [ # # ]: 0 : iavf_vlan_flag = txq->vlan_flag;
2553 : :
2554 : : /* Check if context descriptor is needed using existing IAVF logic */
2555 : : if (!iavf_calc_context_desc(mbuf, iavf_vlan_flag))
2556 : : return 0;
2557 : :
2558 : : /* Get IPsec metadata if needed */
2559 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
2560 : 0 : ipsec_md = RTE_MBUF_DYNFIELD(mbuf, txq->ipsec_crypto_pkt_md_offset,
2561 : : struct iavf_ipsec_crypto_pkt_metadata *);
2562 : : }
2563 : :
2564 : : /* TSO command field */
2565 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
2566 : 0 : cd_type_cmd |= (uint64_t)CI_TX_CTX_DESC_TSO << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2567 : :
2568 : : /* IPsec field for TSO */
2569 [ # # # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD && ipsec_md) {
2570 : 0 : uint64_t ipsec_field = (uint64_t)ipsec_md->ctx_desc_ipsec_params <<
2571 : : IAVF_TXD_CTX_QW1_IPSEC_PARAMS_CIPHERBLK_SHIFT;
2572 : 0 : cd_type_cmd |= ipsec_field;
2573 : : }
2574 : :
2575 : : /* TSO segmentation field */
2576 : 0 : iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd, ol_flags, mbuf, ipsec_md);
2577 : : }
2578 : :
2579 : : /* VLAN field for L2TAG2 */
2580 [ # # # # ]: 0 : if ((ol_flags & RTE_MBUF_F_TX_VLAN &&
2581 : 0 : iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) ||
2582 [ # # ]: 0 : ol_flags & RTE_MBUF_F_TX_QINQ) {
2583 : 0 : cd_type_cmd |= (uint64_t)CI_TX_CTX_DESC_IL2TAG2 << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2584 : : }
2585 : :
2586 : : /* LLDP switching field */
2587 [ # # # # ]: 0 : if (IAVF_CHECK_TX_LLDP(mbuf))
2588 : 0 : cd_type_cmd |= IAVF_TX_CTX_DESC_SWTCH_UPLINK << IAVF_TXD_CTX_QW1_CMD_SHIFT;
2589 : :
2590 : : /* Tunneling field */
2591 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2592 : 0 : iavf_fill_ctx_desc_tunnelling_field(&cd_tunneling_params, ol_flags, mbuf);
2593 : :
2594 : : /* L2TAG2 field (VLAN) */
2595 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_QINQ) {
2596 [ # # ]: 0 : cd_l2tag2 = iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ?
2597 : : mbuf->vlan_tci_outer : mbuf->vlan_tci;
2598 [ # # # # ]: 0 : } else if (ol_flags & RTE_MBUF_F_TX_VLAN &&
2599 : : iavf_vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2) {
2600 : 0 : cd_l2tag2 = mbuf->vlan_tci;
2601 : : }
2602 : :
2603 : : /* Set outputs */
2604 : 0 : *qw0 = rte_cpu_to_le_64(cd_tunneling_params | ((uint64_t)cd_l2tag2 << 32));
2605 : 0 : *qw1 = rte_cpu_to_le_64(cd_type_cmd);
2606 : :
2607 : 0 : return 1; /* One context descriptor needed */
2608 : : }
2609 : :
2610 : : /* TX function */
2611 : : uint16_t
2612 : 0 : iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2613 : : {
2614 : : struct ci_tx_queue *txq = tx_queue;
2615 : :
2616 : 0 : const struct ci_ipsec_ops ipsec_ops = {
2617 : : .get_ipsec_desc = iavf_get_ipsec_desc,
2618 : : .calc_segment_len = iavf_calc_ipsec_segment_len,
2619 : : };
2620 : :
2621 : : /* IAVF does not support timestamp queues, so pass NULL for ts_fns */
2622 : 0 : return ci_xmit_pkts(txq, tx_pkts, nb_pkts,
2623 : 0 : (txq->vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1) ?
2624 : : CI_VLAN_IN_L2TAG1 : CI_VLAN_IN_L2TAG2,
2625 : : iavf_get_context_desc, &ipsec_ops, NULL);
2626 : : }
2627 : :
2628 : : /* Check if the packet with vlan user priority is transmitted in the
2629 : : * correct queue.
2630 : : */
2631 : : static int
2632 : : iavf_check_vlan_up2tc(struct ci_tx_queue *txq, struct rte_mbuf *m)
2633 : : {
2634 : : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
2635 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2636 : : uint16_t up;
2637 : :
2638 : 0 : up = m->vlan_tci >> IAVF_VLAN_TAG_PCP_OFFSET;
2639 : :
2640 [ # # ]: 0 : if (!(vf->qos_cap->cap[txq->tc].tc_prio & BIT(up))) {
2641 : : PMD_TX_LOG(ERR, "packet with vlan pcp %u cannot transmit in queue %u",
2642 : : up, txq->queue_id);
2643 : : return -1;
2644 : : } else {
2645 : : return 0;
2646 : : }
2647 : : }
2648 : :
2649 : : /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */
2650 : : static inline void
2651 : : parse_ipv4(struct rte_ipv4_hdr *ipv4_hdr, struct offload_info *info)
2652 : : {
2653 : : struct rte_tcp_hdr *tcp_hdr;
2654 : :
2655 : : info->l3_len = rte_ipv4_hdr_len(ipv4_hdr);
2656 : : info->l4_proto = ipv4_hdr->next_proto_id;
2657 : :
2658 : : /* only fill l4_len for TCP, it's useful for TSO */
2659 : : if (info->l4_proto == IPPROTO_TCP) {
2660 : : tcp_hdr = (struct rte_tcp_hdr *)
2661 : : ((char *)ipv4_hdr + info->l3_len);
2662 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
2663 : : } else if (info->l4_proto == IPPROTO_UDP) {
2664 : : info->l4_len = sizeof(struct rte_udp_hdr);
2665 : : } else {
2666 : : info->l4_len = 0;
2667 : : }
2668 : : }
2669 : :
2670 : : /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */
2671 : : static inline void
2672 : : parse_ipv6(struct rte_ipv6_hdr *ipv6_hdr, struct offload_info *info)
2673 : : {
2674 : : struct rte_tcp_hdr *tcp_hdr;
2675 : :
2676 : : info->l3_len = sizeof(struct rte_ipv6_hdr);
2677 : : info->l4_proto = ipv6_hdr->proto;
2678 : :
2679 : : /* only fill l4_len for TCP, it's useful for TSO */
2680 : : if (info->l4_proto == IPPROTO_TCP) {
2681 : : tcp_hdr = (struct rte_tcp_hdr *)
2682 : : ((char *)ipv6_hdr + info->l3_len);
2683 : : info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2;
2684 : : } else if (info->l4_proto == IPPROTO_UDP) {
2685 : : info->l4_len = sizeof(struct rte_udp_hdr);
2686 : : } else {
2687 : : info->l4_len = 0;
2688 : : }
2689 : : }
2690 : :
2691 : : /*
2692 : : * Parse an ethernet header to fill the ethertype, l2_len, l3_len and
2693 : : * ipproto. This function is able to recognize IPv4/IPv6 with optional VLAN
2694 : : * headers. The l4_len argument is only set in case of TCP (useful for TSO).
2695 : : */
2696 : : static inline void
2697 : : parse_ethernet(struct rte_ether_hdr *eth_hdr, struct offload_info *info)
2698 : : {
2699 : : struct rte_ipv4_hdr *ipv4_hdr;
2700 : : struct rte_ipv6_hdr *ipv6_hdr;
2701 : : struct rte_vlan_hdr *vlan_hdr;
2702 : :
2703 : : info->l2_len = sizeof(struct rte_ether_hdr);
2704 : : info->ethertype = eth_hdr->ether_type;
2705 : :
2706 : : while (info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN) ||
2707 : : info->ethertype == rte_cpu_to_be_16(RTE_ETHER_TYPE_QINQ)) {
2708 : : vlan_hdr = (struct rte_vlan_hdr *)
2709 : : ((char *)eth_hdr + info->l2_len);
2710 : : info->l2_len += sizeof(struct rte_vlan_hdr);
2711 : : info->ethertype = vlan_hdr->eth_proto;
2712 : : }
2713 : :
2714 : : switch (info->ethertype) {
2715 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV4):
2716 : : ipv4_hdr = (struct rte_ipv4_hdr *)
2717 : : ((char *)eth_hdr + info->l2_len);
2718 : : parse_ipv4(ipv4_hdr, info);
2719 : : break;
2720 : : case RTE_STATIC_BSWAP16(RTE_ETHER_TYPE_IPV6):
2721 : : ipv6_hdr = (struct rte_ipv6_hdr *)
2722 : : ((char *)eth_hdr + info->l2_len);
2723 : : parse_ipv6(ipv6_hdr, info);
2724 : : break;
2725 : : default:
2726 : : info->l4_len = 0;
2727 : : info->l3_len = 0;
2728 : : info->l4_proto = 0;
2729 : : break;
2730 : : }
2731 : : }
2732 : :
2733 : : /* Fill in outer layers length */
2734 : : static inline void
2735 : : update_tunnel_outer(struct offload_info *info)
2736 : : {
2737 : : info->is_tunnel = 1;
2738 : : info->outer_ethertype = info->ethertype;
2739 : : info->outer_l2_len = info->l2_len;
2740 : : info->outer_l3_len = info->l3_len;
2741 : : info->outer_l4_proto = info->l4_proto;
2742 : : }
2743 : :
2744 : : /*
2745 : : * Parse a GTP protocol header.
2746 : : * No optional fields and next extension header type.
2747 : : */
2748 : : static inline void
2749 : : parse_gtp(struct rte_udp_hdr *udp_hdr,
2750 : : struct offload_info *info)
2751 : : {
2752 : : struct rte_ipv4_hdr *ipv4_hdr;
2753 : : struct rte_ipv6_hdr *ipv6_hdr;
2754 : : struct rte_gtp_hdr *gtp_hdr;
2755 : : uint8_t gtp_len = sizeof(*gtp_hdr);
2756 : : uint8_t ip_ver;
2757 : :
2758 : : /* Check UDP destination port. */
2759 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
2760 : : udp_hdr->src_port != rte_cpu_to_be_16(RTE_GTPC_UDP_PORT) &&
2761 : : udp_hdr->dst_port != rte_cpu_to_be_16(RTE_GTPU_UDP_PORT))
2762 : : return;
2763 : :
2764 : : update_tunnel_outer(info);
2765 : : info->l2_len = 0;
2766 : :
2767 : : gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr +
2768 : : sizeof(struct rte_udp_hdr));
2769 : :
2770 : : /*
2771 : : * Check message type. If message type is 0xff, it is
2772 : : * a GTP data packet. If not, it is a GTP control packet
2773 : : */
2774 : : if (gtp_hdr->msg_type == 0xff) {
2775 : : ip_ver = *(uint8_t *)((char *)udp_hdr +
2776 : : sizeof(struct rte_udp_hdr) +
2777 : : sizeof(struct rte_gtp_hdr));
2778 : : ip_ver = (ip_ver) & 0xf0;
2779 : :
2780 : : if (ip_ver == RTE_GTP_TYPE_IPV4) {
2781 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gtp_hdr +
2782 : : gtp_len);
2783 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2784 : : parse_ipv4(ipv4_hdr, info);
2785 : : } else if (ip_ver == RTE_GTP_TYPE_IPV6) {
2786 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gtp_hdr +
2787 : : gtp_len);
2788 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2789 : : parse_ipv6(ipv6_hdr, info);
2790 : : }
2791 : : } else {
2792 : : info->ethertype = 0;
2793 : : info->l4_len = 0;
2794 : : info->l3_len = 0;
2795 : : info->l4_proto = 0;
2796 : : }
2797 : :
2798 : : info->l2_len += RTE_ETHER_GTP_HLEN;
2799 : : }
2800 : :
2801 : : /* Parse a VXLAN header */
2802 : : static inline void
2803 : : parse_vxlan(struct rte_udp_hdr *udp_hdr,
2804 : : struct offload_info *info)
2805 : : {
2806 : : struct rte_ether_hdr *eth_hdr;
2807 : :
2808 : : /* check UDP destination port, RTE_VXLAN_DEFAULT_PORT (4789) is the
2809 : : * default VXLAN port (rfc7348) or that the Rx offload flag is set
2810 : : * (i40e only currently)
2811 : : */
2812 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(RTE_VXLAN_DEFAULT_PORT))
2813 : : return;
2814 : :
2815 : : update_tunnel_outer(info);
2816 : :
2817 : : eth_hdr = (struct rte_ether_hdr *)((char *)udp_hdr +
2818 : : sizeof(struct rte_udp_hdr) +
2819 : : sizeof(struct rte_vxlan_hdr));
2820 : :
2821 : : parse_ethernet(eth_hdr, info);
2822 : : info->l2_len += RTE_ETHER_VXLAN_HLEN; /* add UDP + VXLAN */
2823 : : }
2824 : :
2825 : : /* Parse a VXLAN-GPE header */
2826 : : static inline void
2827 : : parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr,
2828 : : struct offload_info *info)
2829 : : {
2830 : : struct rte_ether_hdr *eth_hdr;
2831 : : struct rte_ipv4_hdr *ipv4_hdr;
2832 : : struct rte_ipv6_hdr *ipv6_hdr;
2833 : : struct rte_vxlan_gpe_hdr *vxlan_gpe_hdr;
2834 : : uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
2835 : :
2836 : : /* Check UDP destination port. */
2837 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(vxlan_gpe_udp_port))
2838 : : return;
2839 : :
2840 : : vxlan_gpe_hdr = (struct rte_vxlan_gpe_hdr *)((char *)udp_hdr +
2841 : : sizeof(struct rte_udp_hdr));
2842 : :
2843 : : if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
2844 : : RTE_VXLAN_GPE_TYPE_IPV4) {
2845 : : update_tunnel_outer(info);
2846 : :
2847 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)vxlan_gpe_hdr +
2848 : : vxlan_gpe_len);
2849 : :
2850 : : parse_ipv4(ipv4_hdr, info);
2851 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2852 : : info->l2_len = 0;
2853 : :
2854 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV6) {
2855 : : update_tunnel_outer(info);
2856 : :
2857 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)vxlan_gpe_hdr +
2858 : : vxlan_gpe_len);
2859 : :
2860 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2861 : : parse_ipv6(ipv6_hdr, info);
2862 : : info->l2_len = 0;
2863 : :
2864 : : } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_ETH) {
2865 : : update_tunnel_outer(info);
2866 : :
2867 : : eth_hdr = (struct rte_ether_hdr *)((char *)vxlan_gpe_hdr +
2868 : : vxlan_gpe_len);
2869 : :
2870 : : parse_ethernet(eth_hdr, info);
2871 : : } else {
2872 : : return;
2873 : : }
2874 : :
2875 : : info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN;
2876 : : }
2877 : :
2878 : : /* Parse a GENEVE header */
2879 : : static inline void
2880 : : parse_geneve(struct rte_udp_hdr *udp_hdr,
2881 : : struct offload_info *info)
2882 : : {
2883 : : struct rte_ether_hdr *eth_hdr;
2884 : : struct rte_ipv4_hdr *ipv4_hdr;
2885 : : struct rte_ipv6_hdr *ipv6_hdr;
2886 : : struct rte_geneve_hdr *geneve_hdr;
2887 : : uint16_t geneve_len;
2888 : :
2889 : : /* Check UDP destination port. */
2890 : : if (udp_hdr->dst_port != rte_cpu_to_be_16(geneve_udp_port))
2891 : : return;
2892 : :
2893 : : geneve_hdr = (struct rte_geneve_hdr *)((char *)udp_hdr +
2894 : : sizeof(struct rte_udp_hdr));
2895 : : geneve_len = sizeof(struct rte_geneve_hdr) + geneve_hdr->opt_len * 4;
2896 : : if (!geneve_hdr->proto || geneve_hdr->proto ==
2897 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
2898 : : update_tunnel_outer(info);
2899 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)geneve_hdr +
2900 : : geneve_len);
2901 : : parse_ipv4(ipv4_hdr, info);
2902 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2903 : : info->l2_len = 0;
2904 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
2905 : : update_tunnel_outer(info);
2906 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)geneve_hdr +
2907 : : geneve_len);
2908 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2909 : : parse_ipv6(ipv6_hdr, info);
2910 : : info->l2_len = 0;
2911 : :
2912 : : } else if (geneve_hdr->proto == rte_cpu_to_be_16(RTE_GENEVE_TYPE_ETH)) {
2913 : : update_tunnel_outer(info);
2914 : : eth_hdr = (struct rte_ether_hdr *)((char *)geneve_hdr +
2915 : : geneve_len);
2916 : : parse_ethernet(eth_hdr, info);
2917 : : } else {
2918 : : return;
2919 : : }
2920 : :
2921 : : info->l2_len +=
2922 : : (sizeof(struct rte_udp_hdr) + sizeof(struct rte_geneve_hdr) +
2923 : : ((struct rte_geneve_hdr *)geneve_hdr)->opt_len * 4);
2924 : : }
2925 : :
2926 : : /* Parse a GRE header */
2927 : : static inline void
2928 : : parse_gre(struct simple_gre_hdr *gre_hdr, struct offload_info *info)
2929 : : {
2930 : : struct rte_ether_hdr *eth_hdr;
2931 : : struct rte_ipv4_hdr *ipv4_hdr;
2932 : : struct rte_ipv6_hdr *ipv6_hdr;
2933 : : uint8_t gre_len = 0;
2934 : :
2935 : : gre_len += sizeof(struct simple_gre_hdr);
2936 : :
2937 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_KEY_PRESENT))
2938 : : gre_len += GRE_EXT_LEN;
2939 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_SEQUENCE_PRESENT))
2940 : : gre_len += GRE_EXT_LEN;
2941 : : if (gre_hdr->flags & rte_cpu_to_be_16(GRE_CHECKSUM_PRESENT))
2942 : : gre_len += GRE_EXT_LEN;
2943 : :
2944 : : if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
2945 : : update_tunnel_outer(info);
2946 : :
2947 : : ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gre_hdr + gre_len);
2948 : :
2949 : : parse_ipv4(ipv4_hdr, info);
2950 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2951 : : info->l2_len = 0;
2952 : :
2953 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
2954 : : update_tunnel_outer(info);
2955 : :
2956 : : ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gre_hdr + gre_len);
2957 : :
2958 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2959 : : parse_ipv6(ipv6_hdr, info);
2960 : : info->l2_len = 0;
2961 : :
2962 : : } else if (gre_hdr->proto == rte_cpu_to_be_16(RTE_ETHER_TYPE_TEB)) {
2963 : : update_tunnel_outer(info);
2964 : :
2965 : : eth_hdr = (struct rte_ether_hdr *)((char *)gre_hdr + gre_len);
2966 : :
2967 : : parse_ethernet(eth_hdr, info);
2968 : : } else {
2969 : : return;
2970 : : }
2971 : :
2972 : : info->l2_len += gre_len;
2973 : : }
2974 : :
2975 : : /* Parse an encapsulated IP or IPv6 header */
2976 : : static inline void
2977 : : parse_encap_ip(void *encap_ip, struct offload_info *info)
2978 : : {
2979 : : struct rte_ipv4_hdr *ipv4_hdr = encap_ip;
2980 : : struct rte_ipv6_hdr *ipv6_hdr = encap_ip;
2981 : : uint8_t ip_version;
2982 : :
2983 : : ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4;
2984 : :
2985 : : if (ip_version != 4 && ip_version != 6)
2986 : : return;
2987 : :
2988 : : info->is_tunnel = 1;
2989 : : info->outer_ethertype = info->ethertype;
2990 : : info->outer_l2_len = info->l2_len;
2991 : : info->outer_l3_len = info->l3_len;
2992 : :
2993 : : if (ip_version == 4) {
2994 : : parse_ipv4(ipv4_hdr, info);
2995 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
2996 : : } else {
2997 : : parse_ipv6(ipv6_hdr, info);
2998 : : info->ethertype = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
2999 : : }
3000 : : info->l2_len = 0;
3001 : : }
3002 : :
3003 : : static inline int
3004 : : check_mbuf_len(struct offload_info *info, struct rte_mbuf *m)
3005 : : {
3006 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3007 : : if (info->outer_l2_len != m->outer_l2_len) {
3008 : : PMD_TX_LOG(ERR, "outer_l2_len error in mbuf. Original "
3009 : : "length: %hu, calculated length: %u", m->outer_l2_len,
3010 : : info->outer_l2_len);
3011 : : return -1;
3012 : : }
3013 : : if (info->outer_l3_len != m->outer_l3_len) {
3014 : : PMD_TX_LOG(ERR, "outer_l3_len error in mbuf. Original "
3015 : : "length: %hu,calculated length: %u", m->outer_l3_len,
3016 : : info->outer_l3_len);
3017 : : return -1;
3018 : : }
3019 : : }
3020 : :
3021 : : if (info->l2_len != m->l2_len) {
3022 : : PMD_TX_LOG(ERR, "l2_len error in mbuf. Original "
3023 : : "length: %hu, calculated length: %u", m->l2_len,
3024 : : info->l2_len);
3025 : : return -1;
3026 : : }
3027 : : if (info->l3_len != m->l3_len) {
3028 : : PMD_TX_LOG(ERR, "l3_len error in mbuf. Original "
3029 : : "length: %hu, calculated length: %u", m->l3_len,
3030 : : info->l3_len);
3031 : : return -1;
3032 : : }
3033 : : if (info->l4_len != m->l4_len) {
3034 : : PMD_TX_LOG(ERR, "l4_len error in mbuf. Original "
3035 : : "length: %hu, calculated length: %u", m->l4_len,
3036 : : info->l4_len);
3037 : : return -1;
3038 : : }
3039 : :
3040 : : return 0;
3041 : : }
3042 : :
3043 : : static inline int
3044 : : check_ether_type(struct offload_info *info, struct rte_mbuf *m)
3045 : : {
3046 : : int ret = 0;
3047 : :
3048 : : if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
3049 : : if (info->outer_ethertype ==
3050 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3051 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)) {
3052 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, "
3053 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV4` flag.");
3054 : : ret = -1;
3055 : : }
3056 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6) {
3057 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv4, tx "
3058 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV6` flag");
3059 : : ret = -1;
3060 : : }
3061 : : } else if (info->outer_ethertype ==
3062 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3063 : : if (!(m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)) {
3064 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, "
3065 : : "tx offload missing `RTE_MBUF_F_TX_OUTER_IPV6` flag.");
3066 : : ret = -1;
3067 : : }
3068 : : if (m->ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) {
3069 : : PMD_TX_LOG(ERR, "Outer ethernet type is ipv6, tx "
3070 : : "offload contains wrong `RTE_MBUF_F_TX_OUTER_IPV4` flag");
3071 : : ret = -1;
3072 : : }
3073 : : }
3074 : : }
3075 : :
3076 : : if (info->ethertype ==
3077 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
3078 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV4)) {
3079 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx offload "
3080 : : "missing `RTE_MBUF_F_TX_IPV4` flag.");
3081 : : ret = -1;
3082 : : }
3083 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV6) {
3084 : : PMD_TX_LOG(ERR, "Ethernet type is ipv4, tx "
3085 : : "offload contains wrong `RTE_MBUF_F_TX_IPV6` flag");
3086 : : ret = -1;
3087 : : }
3088 : : } else if (info->ethertype ==
3089 : : rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)) {
3090 : : if (!(m->ol_flags & RTE_MBUF_F_TX_IPV6)) {
3091 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3092 : : "missing `RTE_MBUF_F_TX_IPV6` flag.");
3093 : : ret = -1;
3094 : : }
3095 : : if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
3096 : : PMD_TX_LOG(ERR, "Ethernet type is ipv6, tx offload "
3097 : : "contains wrong `RTE_MBUF_F_TX_IPV4` flag");
3098 : : ret = -1;
3099 : : }
3100 : : }
3101 : :
3102 : : return ret;
3103 : : }
3104 : :
3105 : : /* Check whether the parameters of mbuf are correct. */
3106 : : __rte_unused static inline int
3107 : : iavf_check_mbuf(struct rte_mbuf *m)
3108 : : {
3109 : : struct rte_ether_hdr *eth_hdr;
3110 : : void *l3_hdr = NULL; /* can be IPv4 or IPv6 */
3111 : : struct offload_info info = {0};
3112 : : uint64_t ol_flags = m->ol_flags;
3113 : : uint64_t tunnel_type = ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK;
3114 : :
3115 : : eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
3116 : : parse_ethernet(eth_hdr, &info);
3117 : : l3_hdr = (char *)eth_hdr + info.l2_len;
3118 : : if (info.l4_proto == IPPROTO_UDP) {
3119 : : struct rte_udp_hdr *udp_hdr;
3120 : :
3121 : : udp_hdr = (struct rte_udp_hdr *)
3122 : : ((char *)l3_hdr + info.l3_len);
3123 : : parse_gtp(udp_hdr, &info);
3124 : : if (info.is_tunnel) {
3125 : : if (!tunnel_type) {
3126 : : PMD_TX_LOG(ERR, "gtp tunnel packet missing tx "
3127 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GTP` flag.");
3128 : : return -1;
3129 : : }
3130 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GTP) {
3131 : : PMD_TX_LOG(ERR, "gtp tunnel packet, tx offload has wrong "
3132 : : "`%s` flag, correct is `RTE_MBUF_F_TX_TUNNEL_GTP` flag",
3133 : : rte_get_tx_ol_flag_name(tunnel_type));
3134 : : return -1;
3135 : : }
3136 : : goto check_len;
3137 : : }
3138 : : parse_vxlan_gpe(udp_hdr, &info);
3139 : : if (info.is_tunnel) {
3140 : : if (!tunnel_type) {
3141 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet missing tx "
3142 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag.");
3143 : : return -1;
3144 : : }
3145 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE) {
3146 : : PMD_TX_LOG(ERR, "vxlan gpe tunnel packet, tx offload has "
3147 : : "wrong `%s` flag, correct is "
3148 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE` flag",
3149 : : rte_get_tx_ol_flag_name(tunnel_type));
3150 : : return -1;
3151 : : }
3152 : : goto check_len;
3153 : : }
3154 : : parse_vxlan(udp_hdr, &info);
3155 : : if (info.is_tunnel) {
3156 : : if (!tunnel_type) {
3157 : : PMD_TX_LOG(ERR, "vxlan tunnel packet missing tx "
3158 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_VXLAN` flag.");
3159 : : return -1;
3160 : : }
3161 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_VXLAN) {
3162 : : PMD_TX_LOG(ERR, "vxlan tunnel packet, tx offload has "
3163 : : "wrong `%s` flag, correct is "
3164 : : "`RTE_MBUF_F_TX_TUNNEL_VXLAN` flag",
3165 : : rte_get_tx_ol_flag_name(tunnel_type));
3166 : : return -1;
3167 : : }
3168 : : goto check_len;
3169 : : }
3170 : : parse_geneve(udp_hdr, &info);
3171 : : if (info.is_tunnel) {
3172 : : if (!tunnel_type) {
3173 : : PMD_TX_LOG(ERR, "geneve tunnel packet missing tx "
3174 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GENEVE` flag.");
3175 : : return -1;
3176 : : }
3177 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GENEVE) {
3178 : : PMD_TX_LOG(ERR, "geneve tunnel packet, tx offload has "
3179 : : "wrong `%s` flag, correct is "
3180 : : "`RTE_MBUF_F_TX_TUNNEL_GENEVE` flag",
3181 : : rte_get_tx_ol_flag_name(tunnel_type));
3182 : : return -1;
3183 : : }
3184 : : goto check_len;
3185 : : }
3186 : : /* Always keep last. */
3187 : : if (unlikely(RTE_ETH_IS_TUNNEL_PKT(m->packet_type)
3188 : : != 0)) {
3189 : : PMD_TX_LOG(ERR, "Unknown tunnel packet. UDP dst port: %hu",
3190 : : udp_hdr->dst_port);
3191 : : return -1;
3192 : : }
3193 : : } else if (info.l4_proto == IPPROTO_GRE) {
3194 : : struct simple_gre_hdr *gre_hdr;
3195 : :
3196 : : gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr +
3197 : : info.l3_len);
3198 : : parse_gre(gre_hdr, &info);
3199 : : if (info.is_tunnel) {
3200 : : if (!tunnel_type) {
3201 : : PMD_TX_LOG(ERR, "gre tunnel packet missing tx "
3202 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_GRE` flag.");
3203 : : return -1;
3204 : : }
3205 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_GRE) {
3206 : : PMD_TX_LOG(ERR, "gre tunnel packet, tx offload has "
3207 : : "wrong `%s` flag, correct is "
3208 : : "`RTE_MBUF_F_TX_TUNNEL_GRE` flag",
3209 : : rte_get_tx_ol_flag_name(tunnel_type));
3210 : : return -1;
3211 : : }
3212 : : goto check_len;
3213 : : }
3214 : : } else if (info.l4_proto == IPPROTO_IPIP) {
3215 : : void *encap_ip_hdr;
3216 : :
3217 : : encap_ip_hdr = (char *)l3_hdr + info.l3_len;
3218 : : parse_encap_ip(encap_ip_hdr, &info);
3219 : : if (info.is_tunnel) {
3220 : : if (!tunnel_type) {
3221 : : PMD_TX_LOG(ERR, "Ipip tunnel packet missing tx "
3222 : : "offload missing `RTE_MBUF_F_TX_TUNNEL_IPIP` flag.");
3223 : : return -1;
3224 : : }
3225 : : if (tunnel_type != RTE_MBUF_F_TX_TUNNEL_IPIP) {
3226 : : PMD_TX_LOG(ERR, "Ipip tunnel packet, tx offload has "
3227 : : "wrong `%s` flag, correct is "
3228 : : "`RTE_MBUF_F_TX_TUNNEL_IPIP` flag",
3229 : : rte_get_tx_ol_flag_name(tunnel_type));
3230 : : return -1;
3231 : : }
3232 : : goto check_len;
3233 : : }
3234 : : }
3235 : :
3236 : : check_len:
3237 : : if (check_mbuf_len(&info, m) != 0)
3238 : : return -1;
3239 : :
3240 : : return check_ether_type(&info, m);
3241 : : }
3242 : :
3243 : : /* TX prep functions */
3244 : : uint16_t
3245 : 0 : iavf_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
3246 : : uint16_t nb_pkts)
3247 : : {
3248 : : int i, ret;
3249 : : uint64_t ol_flags;
3250 : : struct rte_mbuf *m;
3251 : : struct ci_tx_queue *txq = tx_queue;
3252 : 0 : struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
3253 : 0 : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3254 : : struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3255 : :
3256 [ # # ]: 0 : if (adapter->closed)
3257 : : return 0;
3258 : :
3259 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
3260 : 0 : m = tx_pkts[i];
3261 : 0 : ol_flags = m->ol_flags;
3262 : :
3263 : : /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. */
3264 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3265 [ # # ]: 0 : if (m->nb_segs > IAVF_TX_MAX_MTU_SEG) {
3266 : 0 : rte_errno = EINVAL;
3267 : 0 : return i;
3268 : : }
3269 [ # # ]: 0 : } else if ((m->tso_segsz < IAVF_MIN_TSO_MSS) ||
3270 : 0 : (m->tso_segsz > IAVF_MAX_TSO_MSS) ||
3271 [ # # ]: 0 : (m->nb_segs > txq->nb_tx_desc)) {
3272 : : /* MSS outside the range are considered malicious */
3273 : 0 : rte_errno = EINVAL;
3274 : 0 : return i;
3275 : : }
3276 : :
3277 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3278 : 0 : rte_errno = ENOTSUP;
3279 : 0 : return i;
3280 : : }
3281 : :
3282 : : /* valid packets are greater than min size, and single-buffer pkts
3283 : : * must have data_len == pkt_len
3284 : : */
3285 [ # # ]: 0 : if (m->pkt_len < IAVF_TX_MIN_PKT_LEN ||
3286 [ # # # # ]: 0 : (m->nb_segs == 1 && m->data_len != m->pkt_len)) {
3287 : 0 : rte_errno = EINVAL;
3288 : 0 : return i;
3289 : : }
3290 : :
3291 : : #ifdef RTE_ETHDEV_DEBUG_TX
3292 : : ret = rte_validate_tx_offload(m);
3293 : : if (ret != 0) {
3294 : : rte_errno = -ret;
3295 : : return i;
3296 : : }
3297 : : #endif
3298 : : ret = rte_net_intel_cksum_prepare(m);
3299 [ # # ]: 0 : if (ret != 0) {
3300 : 0 : rte_errno = -ret;
3301 : 0 : return i;
3302 : : }
3303 : :
3304 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
3305 [ # # ]: 0 : ol_flags & (RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN)) {
3306 : : ret = iavf_check_vlan_up2tc(txq, m);
3307 : : if (ret != 0) {
3308 : 0 : rte_errno = -ret;
3309 : 0 : return i;
3310 : : }
3311 : : }
3312 : :
3313 : : #ifdef RTE_ETHDEV_DEBUG_TX
3314 : : ret = iavf_check_mbuf(m);
3315 : : if (ret != 0) {
3316 : : rte_errno = EINVAL;
3317 : : return i;
3318 : : }
3319 : : #endif
3320 : : }
3321 : :
3322 : 0 : return i;
3323 : : }
3324 : :
3325 : : static uint16_t
3326 : : iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
3327 : : uint16_t nb_pkts);
3328 : : static uint16_t
3329 : : iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
3330 : : uint16_t nb_pkts);
3331 : :
3332 : : static const struct ci_rx_path_info iavf_rx_path_infos[] = {
3333 : : [IAVF_RX_DISABLED] = {
3334 : : .pkt_burst = iavf_recv_pkts_no_poll,
3335 : : .info = "Disabled",
3336 : : .features = {
3337 : : .disabled = true
3338 : : }
3339 : : },
3340 : : [IAVF_RX_DEFAULT] = {
3341 : : .pkt_burst = iavf_recv_pkts,
3342 : : .info = "Scalar",
3343 : : .features = {
3344 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS
3345 : : }
3346 : : },
3347 : : [IAVF_RX_SCATTERED] = {
3348 : : .pkt_burst = iavf_recv_scattered_pkts,
3349 : : .info = "Scalar Scattered",
3350 : : .features = {
3351 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3352 : : .scattered = true
3353 : : }
3354 : : },
3355 : : [IAVF_RX_FLEX_RXD] = {
3356 : : .pkt_burst = iavf_recv_pkts_flex_rxd,
3357 : : .info = "Scalar Flex",
3358 : : .features = {
3359 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS,
3360 : : .flex_desc = true
3361 : : }
3362 : : },
3363 : : [IAVF_RX_SCATTERED_FLEX_RXD] = {
3364 : : .pkt_burst = iavf_recv_scattered_pkts_flex_rxd,
3365 : : .info = "Scalar Scattered Flex",
3366 : : .features = {
3367 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3368 : : .scattered = true,
3369 : : .flex_desc = true
3370 : : }
3371 : : },
3372 : : [IAVF_RX_BULK_ALLOC] = {
3373 : : .pkt_burst = iavf_recv_pkts_bulk_alloc,
3374 : : .info = "Scalar Bulk Alloc",
3375 : : .features = {
3376 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS,
3377 : : .bulk_alloc = true
3378 : : }
3379 : : },
3380 : : [IAVF_RX_BULK_ALLOC_FLEX_RXD] = {
3381 : : .pkt_burst = iavf_recv_pkts_bulk_alloc,
3382 : : .info = "Scalar Bulk Alloc Flex",
3383 : : .features = {
3384 : : .rx_offloads = IAVF_RX_SCALAR_FLEX_OFFLOADS,
3385 : : .flex_desc = true,
3386 : : .bulk_alloc = true
3387 : : }
3388 : : },
3389 : : #ifdef RTE_ARCH_X86
3390 : : [IAVF_RX_AVX2] = {
3391 : : .pkt_burst = iavf_recv_pkts_vec_avx2,
3392 : : .info = "Vector AVX2",
3393 : : .features = {
3394 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS,
3395 : : .simd_width = RTE_VECT_SIMD_256,
3396 : : .bulk_alloc = true
3397 : : }
3398 : : },
3399 : : [IAVF_RX_AVX2_SCATTERED] = {
3400 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2,
3401 : : .info = "Vector Scattered AVX2",
3402 : : .features = {
3403 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3404 : : .simd_width = RTE_VECT_SIMD_256,
3405 : : .scattered = true,
3406 : : .bulk_alloc = true
3407 : : }
3408 : : },
3409 : : [IAVF_RX_AVX2_OFFLOAD] = {
3410 : : .pkt_burst = iavf_recv_pkts_vec_avx2_offload,
3411 : : .info = "Vector AVX2 Offload",
3412 : : .features = {
3413 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS,
3414 : : .simd_width = RTE_VECT_SIMD_256,
3415 : : .bulk_alloc = true
3416 : : }
3417 : : },
3418 : : [IAVF_RX_AVX2_SCATTERED_OFFLOAD] = {
3419 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_offload,
3420 : : .info = "Vector Scattered AVX2 Offload",
3421 : : .features = {
3422 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3423 : : .simd_width = RTE_VECT_SIMD_256,
3424 : : .scattered = true,
3425 : : .bulk_alloc = true
3426 : : }
3427 : : },
3428 : : [IAVF_RX_AVX2_FLEX_RXD] = {
3429 : : .pkt_burst = iavf_recv_pkts_vec_avx2_flex_rxd,
3430 : : .info = "Vector AVX2 Flex",
3431 : : .features = {
3432 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS,
3433 : : .simd_width = RTE_VECT_SIMD_256,
3434 : : .flex_desc = true,
3435 : : .bulk_alloc = true
3436 : : }
3437 : : },
3438 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD] = {
3439 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_flex_rxd,
3440 : : .info = "Vector Scattered AVX2 Flex",
3441 : : .features = {
3442 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3443 : : .simd_width = RTE_VECT_SIMD_256,
3444 : : .scattered = true,
3445 : : .flex_desc = true,
3446 : : .bulk_alloc = true
3447 : : }
3448 : : },
3449 : : [IAVF_RX_AVX2_FLEX_RXD_OFFLOAD] = {
3450 : : .pkt_burst = iavf_recv_pkts_vec_avx2_flex_rxd_offload,
3451 : : .info = "Vector AVX2 Flex Offload",
3452 : : .features = {
3453 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS,
3454 : : .simd_width = RTE_VECT_SIMD_256,
3455 : : .flex_desc = true,
3456 : : .bulk_alloc = true
3457 : : }
3458 : : },
3459 : : [IAVF_RX_AVX2_SCATTERED_FLEX_RXD_OFFLOAD] = {
3460 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx2_flex_rxd_offload,
3461 : : .info = "Vector Scattered AVX2 Flex Offload",
3462 : : .features = {
3463 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS |
3464 : : RTE_ETH_RX_OFFLOAD_SCATTER,
3465 : : .simd_width = RTE_VECT_SIMD_256,
3466 : : .scattered = true,
3467 : : .flex_desc = true,
3468 : : .bulk_alloc = true
3469 : : }
3470 : : },
3471 : : #ifdef CC_AVX512_SUPPORT
3472 : : [IAVF_RX_AVX512] = {
3473 : : .pkt_burst = iavf_recv_pkts_vec_avx512,
3474 : : .info = "Vector AVX512",
3475 : : .features = {
3476 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS,
3477 : : .simd_width = RTE_VECT_SIMD_512,
3478 : : .bulk_alloc = true
3479 : : }
3480 : : },
3481 : : [IAVF_RX_AVX512_SCATTERED] = {
3482 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512,
3483 : : .info = "Vector Scattered AVX512",
3484 : : .features = {
3485 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3486 : : .simd_width = RTE_VECT_SIMD_512,
3487 : : .scattered = true,
3488 : : .bulk_alloc = true
3489 : : }
3490 : : },
3491 : : [IAVF_RX_AVX512_OFFLOAD] = {
3492 : : .pkt_burst = iavf_recv_pkts_vec_avx512_offload,
3493 : : .info = "Vector AVX512 Offload",
3494 : : .features = {
3495 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS,
3496 : : .simd_width = RTE_VECT_SIMD_512,
3497 : : .bulk_alloc = true
3498 : : }
3499 : : },
3500 : : [IAVF_RX_AVX512_SCATTERED_OFFLOAD] = {
3501 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_offload,
3502 : : .info = "Vector Scattered AVX512 Offload",
3503 : : .features = {
3504 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3505 : : .simd_width = RTE_VECT_SIMD_512,
3506 : : .scattered = true,
3507 : : .bulk_alloc = true
3508 : : }
3509 : : },
3510 : : [IAVF_RX_AVX512_FLEX_RXD] = {
3511 : : .pkt_burst = iavf_recv_pkts_vec_avx512_flex_rxd,
3512 : : .info = "Vector AVX512 Flex",
3513 : : .features = {
3514 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS,
3515 : : .simd_width = RTE_VECT_SIMD_512,
3516 : : .flex_desc = true,
3517 : : .bulk_alloc = true
3518 : : }
3519 : : },
3520 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD] = {
3521 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_flex_rxd,
3522 : : .info = "Vector Scattered AVX512 Flex",
3523 : : .features = {
3524 : : .rx_offloads = IAVF_RX_VECTOR_FLEX_OFFLOADS | RTE_ETH_RX_OFFLOAD_SCATTER,
3525 : : .simd_width = RTE_VECT_SIMD_512,
3526 : : .scattered = true,
3527 : : .flex_desc = true,
3528 : : .bulk_alloc = true
3529 : : }
3530 : : },
3531 : : [IAVF_RX_AVX512_FLEX_RXD_OFFLOAD] = {
3532 : : .pkt_burst = iavf_recv_pkts_vec_avx512_flex_rxd_offload,
3533 : : .info = "Vector AVX512 Flex Offload",
3534 : : .features = {
3535 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS,
3536 : : .simd_width = RTE_VECT_SIMD_512,
3537 : : .flex_desc = true,
3538 : : .bulk_alloc = true
3539 : : }
3540 : : },
3541 : : [IAVF_RX_AVX512_SCATTERED_FLEX_RXD_OFFLOAD] = {
3542 : : .pkt_burst = iavf_recv_scattered_pkts_vec_avx512_flex_rxd_offload,
3543 : : .info = "Vector Scattered AVX512 Flex Offload",
3544 : : .features = {
3545 : : .rx_offloads = IAVF_RX_VECTOR_OFFLOAD_FLEX_OFFLOADS |
3546 : : RTE_ETH_RX_OFFLOAD_SCATTER,
3547 : : .simd_width = RTE_VECT_SIMD_512,
3548 : : .scattered = true,
3549 : : .flex_desc = true,
3550 : : .bulk_alloc = true
3551 : : }
3552 : : },
3553 : : #endif
3554 : : #elif defined RTE_ARCH_ARM
3555 : : [IAVF_RX_NEON] = {
3556 : : .pkt_burst = iavf_recv_pkts_vec,
3557 : : .info = "Vector Neon",
3558 : : .features = {
3559 : : .rx_offloads = IAVF_RX_SCALAR_OFFLOADS,
3560 : : .simd_width = RTE_VECT_SIMD_128,
3561 : : .bulk_alloc = true
3562 : : }
3563 : : },
3564 : : #endif
3565 : : };
3566 : :
3567 : : int
3568 : 0 : iavf_rx_burst_mode_get(struct rte_eth_dev *dev,
3569 : : __rte_unused uint16_t queue_id,
3570 : : struct rte_eth_burst_mode *mode)
3571 : : {
3572 : 0 : eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
3573 : : size_t i;
3574 : :
3575 [ # # ]: 0 : for (i = 0; i < RTE_DIM(iavf_rx_path_infos); i++) {
3576 [ # # ]: 0 : if (pkt_burst == iavf_rx_path_infos[i].pkt_burst) {
3577 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3578 : 0 : iavf_rx_path_infos[i].info);
3579 : 0 : return 0;
3580 : : }
3581 : : }
3582 : :
3583 : : return -EINVAL;
3584 : : }
3585 : :
3586 : : static const struct ci_tx_path_info iavf_tx_path_infos[] = {
3587 : : [IAVF_TX_DISABLED] = {
3588 : : .pkt_burst = iavf_xmit_pkts_no_poll,
3589 : : .info = "Disabled",
3590 : : .features = {
3591 : : .disabled = true
3592 : : }
3593 : : },
3594 : : [IAVF_TX_DEFAULT] = {
3595 : : .pkt_burst = iavf_xmit_pkts,
3596 : : .info = "Scalar",
3597 : : .features = {
3598 : : .tx_offloads = IAVF_TX_SCALAR_OFFLOADS,
3599 : : .ctx_desc = true
3600 : : }
3601 : : },
3602 : : #ifdef RTE_ARCH_X86
3603 : : [IAVF_TX_AVX2] = {
3604 : : .pkt_burst = iavf_xmit_pkts_vec_avx2,
3605 : : .info = "Vector AVX2",
3606 : : .features = {
3607 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3608 : : .simd_width = RTE_VECT_SIMD_256
3609 : : }
3610 : : },
3611 : : [IAVF_TX_AVX2_OFFLOAD] = {
3612 : : .pkt_burst = iavf_xmit_pkts_vec_avx2_offload,
3613 : : .info = "Vector AVX2 Offload",
3614 : : .features = {
3615 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOAD_OFFLOADS,
3616 : : .simd_width = RTE_VECT_SIMD_256
3617 : : }
3618 : : },
3619 : : #ifdef CC_AVX512_SUPPORT
3620 : : [IAVF_TX_AVX512] = {
3621 : : .pkt_burst = iavf_xmit_pkts_vec_avx512,
3622 : : .info = "Vector AVX512",
3623 : : .features = {
3624 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3625 : : .simd_width = RTE_VECT_SIMD_512
3626 : : }
3627 : : },
3628 : : [IAVF_TX_AVX512_OFFLOAD] = {
3629 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_offload,
3630 : : .info = "Vector AVX512 Offload",
3631 : : .features = {
3632 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOAD_OFFLOADS,
3633 : : .simd_width = RTE_VECT_SIMD_512
3634 : : }
3635 : : },
3636 : : [IAVF_TX_AVX512_CTX] = {
3637 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_ctx,
3638 : : .info = "Vector AVX512 Ctx",
3639 : : .features = {
3640 : : .tx_offloads = IAVF_TX_VECTOR_OFFLOADS,
3641 : : .simd_width = RTE_VECT_SIMD_512,
3642 : : .ctx_desc = true
3643 : : }
3644 : : },
3645 : : [IAVF_TX_AVX512_CTX_OFFLOAD] = {
3646 : : .pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload,
3647 : : .info = "Vector AVX512 Ctx Offload",
3648 : : .features = {
3649 : : .tx_offloads = IAVF_TX_VECTOR_CTX_OFFLOAD_OFFLOADS,
3650 : : .simd_width = RTE_VECT_SIMD_512,
3651 : : .ctx_desc = true
3652 : : }
3653 : : },
3654 : : #endif
3655 : : #endif
3656 : : };
3657 : :
3658 : : int
3659 : 0 : iavf_tx_burst_mode_get(struct rte_eth_dev *dev,
3660 : : __rte_unused uint16_t queue_id,
3661 : : struct rte_eth_burst_mode *mode)
3662 : : {
3663 : 0 : eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
3664 : : size_t i;
3665 : :
3666 [ # # ]: 0 : for (i = 0; i < RTE_DIM(iavf_tx_path_infos); i++) {
3667 [ # # ]: 0 : if (pkt_burst == iavf_tx_path_infos[i].pkt_burst) {
3668 : 0 : snprintf(mode->info, sizeof(mode->info), "%s",
3669 : 0 : iavf_tx_path_infos[i].info);
3670 : 0 : return 0;
3671 : : }
3672 : : }
3673 : :
3674 : : return -EINVAL;
3675 : : }
3676 : :
3677 : : static uint16_t
3678 : 0 : iavf_recv_pkts_no_poll(void *rx_queue, struct rte_mbuf **rx_pkts,
3679 : : uint16_t nb_pkts)
3680 : : {
3681 : : struct ci_rx_queue *rxq = rx_queue;
3682 : : enum iavf_rx_func_type rx_func_type;
3683 : :
3684 [ # # # # ]: 0 : if (!rxq->iavf_vsi || rxq->iavf_vsi->adapter->no_poll)
3685 : : return 0;
3686 : :
3687 : 0 : rx_func_type = rxq->iavf_vsi->adapter->rx_func_type;
3688 : :
3689 : 0 : return iavf_rx_path_infos[rx_func_type].pkt_burst(rx_queue,
3690 : : rx_pkts, nb_pkts);
3691 : : }
3692 : :
3693 : : static uint16_t
3694 : 0 : iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
3695 : : uint16_t nb_pkts)
3696 : : {
3697 : : struct ci_tx_queue *txq = tx_queue;
3698 : : enum iavf_tx_func_type tx_func_type;
3699 : :
3700 [ # # # # ]: 0 : if (!txq->iavf_vsi || txq->iavf_vsi->adapter->no_poll)
3701 : : return 0;
3702 : :
3703 : 0 : tx_func_type = txq->iavf_vsi->adapter->tx_func_type;
3704 : :
3705 : 0 : return iavf_tx_path_infos[tx_func_type].pkt_burst(tx_queue,
3706 : : tx_pkts, nb_pkts);
3707 : : }
3708 : :
3709 : : /* Tx mbuf check */
3710 : : static uint16_t
3711 : 0 : iavf_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts,
3712 : : uint16_t nb_pkts)
3713 : : {
3714 : : uint16_t idx;
3715 : : uint64_t ol_flags;
3716 : : struct rte_mbuf *mb;
3717 : : uint16_t good_pkts = nb_pkts;
3718 : 0 : const char *reason = NULL;
3719 : : bool pkt_error = false;
3720 : : struct ci_tx_queue *txq = tx_queue;
3721 : 0 : struct iavf_adapter *adapter = txq->iavf_vsi->adapter;
3722 : 0 : enum iavf_tx_func_type tx_func_type =
3723 : : txq->iavf_vsi->adapter->tx_func_type;
3724 : :
3725 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
3726 : 0 : mb = tx_pkts[idx];
3727 : 0 : ol_flags = mb->ol_flags;
3728 : :
3729 [ # # # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_MBUF) &&
3730 : 0 : (rte_mbuf_check(mb, 1, &reason) != 0)) {
3731 : : PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
3732 : : pkt_error = true;
3733 : : break;
3734 : : }
3735 : :
3736 [ # # ]: 0 : if ((adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SIZE) &&
3737 [ # # ]: 0 : (mb->data_len < IAVF_TX_MIN_PKT_LEN ||
3738 [ # # ]: 0 : mb->data_len > adapter->vf.max_pkt_len)) {
3739 : : PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %u)",
3740 : : mb->data_len, IAVF_TX_MIN_PKT_LEN, adapter->vf.max_pkt_len);
3741 : : pkt_error = true;
3742 : : break;
3743 : : }
3744 : :
3745 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_SEGMENT) {
3746 : : /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. */
3747 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))) {
3748 [ # # ]: 0 : if (mb->nb_segs > IAVF_TX_MAX_MTU_SEG) {
3749 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
3750 : : mb->nb_segs, IAVF_TX_MAX_MTU_SEG);
3751 : : pkt_error = true;
3752 : : break;
3753 : : }
3754 [ # # ]: 0 : } else if ((mb->tso_segsz < IAVF_MIN_TSO_MSS) ||
3755 : : (mb->tso_segsz > IAVF_MAX_TSO_MSS)) {
3756 : : /* MSS outside the range are considered malicious */
3757 : : PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
3758 : : mb->tso_segsz, IAVF_MIN_TSO_MSS, IAVF_MAX_TSO_MSS);
3759 : : pkt_error = true;
3760 : : break;
3761 [ # # ]: 0 : } else if (mb->nb_segs > txq->nb_tx_desc) {
3762 : : PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
3763 : : pkt_error = true;
3764 : : break;
3765 : : }
3766 : : }
3767 : :
3768 [ # # ]: 0 : if (adapter->devargs.mbuf_check & IAVF_MBUF_CHECK_F_TX_OFFLOAD) {
3769 [ # # ]: 0 : if (ol_flags & IAVF_TX_OFFLOAD_NOTSUP_MASK) {
3770 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
3771 : : pkt_error = true;
3772 : : break;
3773 : : }
3774 : :
3775 [ # # ]: 0 : if (!rte_validate_tx_offload(mb)) {
3776 : : PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
3777 : : pkt_error = true;
3778 : : break;
3779 : : }
3780 : : }
3781 : : }
3782 : :
3783 [ # # ]: 0 : if (pkt_error) {
3784 : 0 : txq->mbuf_errors++;
3785 : : good_pkts = idx;
3786 [ # # ]: 0 : if (good_pkts == 0)
3787 : : return 0;
3788 : : }
3789 : :
3790 : 0 : return iavf_tx_path_infos[tx_func_type].pkt_burst(tx_queue, tx_pkts, good_pkts);
3791 : : }
3792 : :
3793 : : #ifdef RTE_ARCH_X86
3794 : : enum rte_vect_max_simd
3795 : 0 : iavf_get_max_simd_bitwidth(void)
3796 : : {
3797 : 0 : return ci_get_x86_max_simd_bitwidth();
3798 : : }
3799 : : #endif
3800 : :
3801 : : /* choose rx function*/
3802 : : void
3803 : 0 : iavf_set_rx_function(struct rte_eth_dev *dev)
3804 : : {
3805 : 0 : struct iavf_adapter *adapter =
3806 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3807 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
3808 : : enum iavf_rx_func_type default_path = IAVF_RX_DEFAULT;
3809 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
3810 : : int i;
3811 : : struct ci_rx_queue *rxq;
3812 : : bool use_flex = true;
3813 : 0 : struct ci_rx_path_features req_features = {
3814 : 0 : .rx_offloads = dev->data->dev_conf.rxmode.offloads,
3815 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3816 : : };
3817 : :
3818 : : /* If the device has started the function has already been selected. */
3819 [ # # ]: 0 : if (dev->data->dev_started)
3820 : 0 : goto out;
3821 : :
3822 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
3823 : 0 : rxq = dev->data->rx_queues[i];
3824 [ # # ]: 0 : if (rxq->rxdid <= IAVF_RXDID_LEGACY_1) {
3825 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is legacy, "
3826 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3827 : : use_flex = false;
3828 [ # # ]: 0 : } else if (!(vf->supported_rxdid & RTE_BIT64(rxq->rxdid))) {
3829 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d] is not supported, "
3830 : : "set rx_pkt_burst as legacy for all queues", rxq->rxdid, i);
3831 : : use_flex = false;
3832 : : }
3833 : : }
3834 : :
3835 [ # # ]: 0 : if (use_flex)
3836 : 0 : req_features.flex_desc = true;
3837 [ # # ]: 0 : if (dev->data->scattered_rx)
3838 : 0 : req_features.scattered = true;
3839 [ # # ]: 0 : if (adapter->rx_bulk_alloc_allowed) {
3840 : 0 : req_features.bulk_alloc = true;
3841 : : default_path = IAVF_RX_BULK_ALLOC;
3842 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM)
3843 [ # # ]: 0 : if (iavf_rx_vec_dev_check(dev) != -1)
3844 : 0 : req_features.simd_width = iavf_get_max_simd_bitwidth();
3845 : : #endif
3846 : : }
3847 : :
3848 : 0 : adapter->rx_func_type = ci_rx_path_select(&req_features,
3849 : : &iavf_rx_path_infos[0],
3850 : : RTE_DIM(iavf_rx_path_infos),
3851 : : default_path);
3852 : :
3853 : 0 : out:
3854 [ # # ]: 0 : if (no_poll_on_link_down)
3855 : 0 : dev->rx_pkt_burst = iavf_recv_pkts_no_poll;
3856 : : else
3857 : 0 : dev->rx_pkt_burst = iavf_rx_path_infos[adapter->rx_func_type].pkt_burst;
3858 : :
3859 : 0 : PMD_DRV_LOG(NOTICE, "Using %s (port %d).",
3860 : : iavf_rx_path_infos[adapter->rx_func_type].info, dev->data->port_id);
3861 : 0 : }
3862 : :
3863 : : /* choose tx function*/
3864 : : void
3865 : 0 : iavf_set_tx_function(struct rte_eth_dev *dev)
3866 : : {
3867 : 0 : struct iavf_adapter *adapter =
3868 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3869 : 0 : int mbuf_check = adapter->devargs.mbuf_check;
3870 : 0 : int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
3871 : : #ifdef RTE_ARCH_X86
3872 : : struct ci_tx_queue *txq;
3873 : : int i;
3874 : : const struct ci_tx_path_features *selected_features;
3875 : : #endif
3876 : 0 : struct ci_tx_path_features req_features = {
3877 : 0 : .tx_offloads = dev->data->dev_conf.txmode.offloads,
3878 : : .simd_width = RTE_VECT_SIMD_DISABLED,
3879 : : };
3880 : :
3881 : : /* If the device has started the function has already been selected. */
3882 [ # # ]: 0 : if (dev->data->dev_started)
3883 : 0 : goto out;
3884 : :
3885 : : #ifdef RTE_ARCH_X86
3886 [ # # ]: 0 : if (iavf_tx_vec_dev_check(dev) != -1)
3887 : 0 : req_features.simd_width = iavf_get_max_simd_bitwidth();
3888 : :
3889 [ # # ]: 0 : if (rte_pmd_iavf_tx_lldp_dynfield_offset > 0)
3890 : 0 : req_features.ctx_desc = true;
3891 : :
3892 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3893 : 0 : txq = dev->data->tx_queues[i];
3894 [ # # ]: 0 : if (!txq)
3895 : 0 : continue;
3896 [ # # ]: 0 : if (txq->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT &&
3897 [ # # ]: 0 : txq->vlan_flag == IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)
3898 : 0 : req_features.ctx_desc = true;
3899 : : }
3900 : : #endif
3901 : :
3902 : 0 : adapter->tx_func_type = ci_tx_path_select(&req_features,
3903 : : &iavf_tx_path_infos[0],
3904 : : RTE_DIM(iavf_tx_path_infos),
3905 : : IAVF_TX_DEFAULT);
3906 : :
3907 : 0 : out:
3908 : : #ifdef RTE_ARCH_X86
3909 : 0 : selected_features = &iavf_tx_path_infos[adapter->tx_func_type].features;
3910 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
3911 : 0 : txq = dev->data->tx_queues[i];
3912 [ # # ]: 0 : if (!txq)
3913 : 0 : continue;
3914 : 0 : txq->use_ctx = selected_features->ctx_desc;
3915 : 0 : txq->use_vec_entry = selected_features->simd_width >= RTE_VECT_SIMD_128;
3916 : : }
3917 : : #endif
3918 : :
3919 [ # # ]: 0 : if (no_poll_on_link_down)
3920 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
3921 [ # # ]: 0 : else if (mbuf_check)
3922 : 0 : dev->tx_pkt_burst = iavf_xmit_pkts_check;
3923 : : else
3924 : 0 : dev->tx_pkt_burst = iavf_tx_path_infos[adapter->tx_func_type].pkt_burst;
3925 : :
3926 : 0 : PMD_DRV_LOG(NOTICE, "Using %s (port %d).",
3927 : : iavf_tx_path_infos[adapter->tx_func_type].info, dev->data->port_id);
3928 : 0 : }
3929 : :
3930 : : static int
3931 : 0 : iavf_tx_done_cleanup_full(struct ci_tx_queue *txq,
3932 : : uint32_t free_cnt)
3933 : : {
3934 : 0 : struct ci_tx_entry *swr_ring = txq->sw_ring;
3935 : : uint16_t tx_last, tx_id;
3936 : : uint16_t nb_tx_free_last;
3937 : : uint16_t nb_tx_to_clean;
3938 : : uint32_t pkt_cnt = 0;
3939 : :
3940 : : /* Start free mbuf from tx_tail */
3941 : 0 : tx_id = txq->tx_tail;
3942 : : tx_last = tx_id;
3943 : :
3944 [ # # ]: 0 : if (txq->nb_tx_free == 0 && ci_tx_xmit_cleanup(txq))
3945 : : return 0;
3946 : :
3947 : 0 : nb_tx_to_clean = txq->nb_tx_free;
3948 : : nb_tx_free_last = txq->nb_tx_free;
3949 [ # # ]: 0 : if (!free_cnt)
3950 : 0 : free_cnt = txq->nb_tx_desc;
3951 : :
3952 : : /* Loop through swr_ring to count the amount of
3953 : : * freeable mubfs and packets.
3954 : : */
3955 [ # # ]: 0 : while (pkt_cnt < free_cnt) {
3956 : : do {
3957 [ # # ]: 0 : if (swr_ring[tx_id].mbuf != NULL) {
3958 : : /*
3959 : : * last segment in the packet,
3960 : : * increment packet count
3961 : : */
3962 [ # # ]: 0 : pkt_cnt += (swr_ring[tx_id].mbuf->next == NULL) ? 1 : 0;
3963 : : rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
3964 : 0 : swr_ring[tx_id].mbuf = NULL;
3965 : :
3966 : : }
3967 : :
3968 : 0 : tx_id = swr_ring[tx_id].next_id;
3969 [ # # # # ]: 0 : } while (--nb_tx_to_clean && pkt_cnt < free_cnt && tx_id != tx_last);
3970 : :
3971 : 0 : if (txq->tx_rs_thresh > txq->nb_tx_desc -
3972 [ # # # # ]: 0 : txq->nb_tx_free || tx_id == tx_last)
3973 : : break;
3974 : :
3975 [ # # ]: 0 : if (pkt_cnt < free_cnt) {
3976 : : if (ci_tx_xmit_cleanup(txq))
3977 : : break;
3978 : :
3979 : 0 : nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
3980 : : nb_tx_free_last = txq->nb_tx_free;
3981 : : }
3982 : : }
3983 : :
3984 : 0 : return (int)pkt_cnt;
3985 : : }
3986 : :
3987 : : int
3988 : 0 : iavf_dev_tx_done_cleanup(void *txq, uint32_t free_cnt)
3989 : : {
3990 : : struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
3991 : :
3992 : 0 : return iavf_tx_done_cleanup_full(q, free_cnt);
3993 : : }
3994 : :
3995 : : void
3996 : 0 : iavf_dev_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
3997 : : struct rte_eth_rxq_info *qinfo)
3998 : : {
3999 : : struct ci_rx_queue *rxq;
4000 : :
4001 : 0 : rxq = dev->data->rx_queues[queue_id];
4002 : :
4003 : 0 : qinfo->mp = rxq->mp;
4004 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
4005 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
4006 : :
4007 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
4008 : 0 : qinfo->conf.rx_drop_en = true;
4009 : 0 : qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
4010 : 0 : }
4011 : :
4012 : : void
4013 : 0 : iavf_dev_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
4014 : : struct rte_eth_txq_info *qinfo)
4015 : : {
4016 : : struct ci_tx_queue *txq;
4017 : :
4018 : 0 : txq = dev->data->tx_queues[queue_id];
4019 : :
4020 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
4021 : :
4022 : 0 : qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
4023 : 0 : qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
4024 : 0 : qinfo->conf.offloads = txq->offloads;
4025 : 0 : qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
4026 : 0 : }
4027 : :
4028 : : /* Get the number of used descriptors of a rx queue */
4029 : : int
4030 : 0 : iavf_dev_rxq_count(void *rx_queue)
4031 : : {
4032 : : #define IAVF_RXQ_SCAN_INTERVAL 4
4033 : : volatile union ci_rx_desc *rxdp;
4034 : : struct ci_rx_queue *rxq;
4035 : : uint16_t desc = 0;
4036 : :
4037 : : rxq = rx_queue;
4038 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
4039 : :
4040 [ # # ]: 0 : while ((desc < rxq->nb_rx_desc) &&
4041 : 0 : ((rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len) &
4042 [ # # ]: 0 : IAVF_RXD_QW1_STATUS_MASK) >> IAVF_RXD_QW1_STATUS_SHIFT) &
4043 : : (1 << IAVF_RX_DESC_STATUS_DD_SHIFT)) {
4044 : : /* Check the DD bit of a rx descriptor of each 4 in a group,
4045 : : * to avoid checking too frequently and downgrading performance
4046 : : * too much.
4047 : : */
4048 : 0 : desc += IAVF_RXQ_SCAN_INTERVAL;
4049 : 0 : rxdp += IAVF_RXQ_SCAN_INTERVAL;
4050 [ # # ]: 0 : if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
4051 : 0 : rxdp = &(rxq->rx_ring[rxq->rx_tail +
4052 : 0 : desc - rxq->nb_rx_desc]);
4053 : : }
4054 : :
4055 : 0 : return desc;
4056 : : }
4057 : :
4058 : : int
4059 : 0 : iavf_dev_rx_desc_status(void *rx_queue, uint16_t offset)
4060 : : {
4061 : : struct ci_rx_queue *rxq = rx_queue;
4062 : : volatile uint64_t *status;
4063 : : uint64_t mask;
4064 : : uint32_t desc;
4065 : :
4066 [ # # ]: 0 : if (unlikely(offset >= rxq->nb_rx_desc))
4067 : : return -EINVAL;
4068 : :
4069 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
4070 : : return RTE_ETH_RX_DESC_UNAVAIL;
4071 : :
4072 : 0 : desc = rxq->rx_tail + offset;
4073 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
4074 : 0 : desc -= rxq->nb_rx_desc;
4075 : :
4076 : 0 : status = &rxq->rx_ring[desc].wb.qword1.status_error_len;
4077 : : mask = rte_le_to_cpu_64((1ULL << IAVF_RX_DESC_STATUS_DD_SHIFT)
4078 : : << IAVF_RXD_QW1_STATUS_SHIFT);
4079 [ # # ]: 0 : if (*status & mask)
4080 : 0 : return RTE_ETH_RX_DESC_DONE;
4081 : :
4082 : : return RTE_ETH_RX_DESC_AVAIL;
4083 : : }
4084 : :
4085 : : int
4086 : 0 : iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset)
4087 : : {
4088 : : struct ci_tx_queue *txq = tx_queue;
4089 : : volatile uint64_t *status;
4090 : : uint64_t mask, expect;
4091 : : uint32_t desc;
4092 : :
4093 [ # # ]: 0 : if (unlikely(offset >= txq->nb_tx_desc))
4094 : : return -EINVAL;
4095 : :
4096 : 0 : desc = txq->tx_tail + offset;
4097 : : /* go to next desc that has the RS bit */
4098 : 0 : desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
4099 : : txq->tx_rs_thresh;
4100 [ # # ]: 0 : if (desc >= txq->nb_tx_desc) {
4101 : 0 : desc -= txq->nb_tx_desc;
4102 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
4103 : 0 : desc -= txq->nb_tx_desc;
4104 : : }
4105 : :
4106 : 0 : status = &txq->ci_tx_ring[desc].cmd_type_offset_bsz;
4107 : : mask = rte_le_to_cpu_64(CI_TXD_QW1_DTYPE_M);
4108 : : expect = rte_cpu_to_le_64(CI_TX_DESC_DTYPE_DESC_DONE << CI_TXD_QW1_DTYPE_S);
4109 [ # # ]: 0 : if ((*status & mask) == expect)
4110 : 0 : return RTE_ETH_TX_DESC_DONE;
4111 : :
4112 : : return RTE_ETH_TX_DESC_FULL;
4113 : : }
4114 : :
4115 : : static inline uint32_t
4116 : : iavf_get_default_ptype(uint16_t ptype)
4117 : : {
4118 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] = {
4119 : : /* L2 types */
4120 : : /* [0] reserved */
4121 : : [1] = RTE_PTYPE_L2_ETHER,
4122 : : [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
4123 : : /* [3] - [5] reserved */
4124 : : [6] = RTE_PTYPE_L2_ETHER_LLDP,
4125 : : /* [7] - [10] reserved */
4126 : : [11] = RTE_PTYPE_L2_ETHER_ARP,
4127 : : /* [12] - [21] reserved */
4128 : :
4129 : : /* Non tunneled IPv4 */
4130 : : [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4131 : : RTE_PTYPE_L4_FRAG,
4132 : : [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4133 : : RTE_PTYPE_L4_NONFRAG,
4134 : : [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4135 : : RTE_PTYPE_L4_UDP,
4136 : : /* [25] reserved */
4137 : : [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4138 : : RTE_PTYPE_L4_TCP,
4139 : : [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4140 : : RTE_PTYPE_L4_SCTP,
4141 : : [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4142 : : RTE_PTYPE_L4_ICMP,
4143 : :
4144 : : /* IPv4 --> IPv4 */
4145 : : [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4146 : : RTE_PTYPE_TUNNEL_IP |
4147 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4148 : : RTE_PTYPE_INNER_L4_FRAG,
4149 : : [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4150 : : RTE_PTYPE_TUNNEL_IP |
4151 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4152 : : RTE_PTYPE_INNER_L4_NONFRAG,
4153 : : [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4154 : : RTE_PTYPE_TUNNEL_IP |
4155 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4156 : : RTE_PTYPE_INNER_L4_UDP,
4157 : : /* [32] reserved */
4158 : : [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4159 : : RTE_PTYPE_TUNNEL_IP |
4160 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4161 : : RTE_PTYPE_INNER_L4_TCP,
4162 : : [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4163 : : RTE_PTYPE_TUNNEL_IP |
4164 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4165 : : RTE_PTYPE_INNER_L4_SCTP,
4166 : : [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4167 : : RTE_PTYPE_TUNNEL_IP |
4168 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4169 : : RTE_PTYPE_INNER_L4_ICMP,
4170 : :
4171 : : /* IPv4 --> IPv6 */
4172 : : [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4173 : : RTE_PTYPE_TUNNEL_IP |
4174 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4175 : : RTE_PTYPE_INNER_L4_FRAG,
4176 : : [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4177 : : RTE_PTYPE_TUNNEL_IP |
4178 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4179 : : RTE_PTYPE_INNER_L4_NONFRAG,
4180 : : [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4181 : : RTE_PTYPE_TUNNEL_IP |
4182 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4183 : : RTE_PTYPE_INNER_L4_UDP,
4184 : : /* [39] reserved */
4185 : : [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4186 : : RTE_PTYPE_TUNNEL_IP |
4187 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4188 : : RTE_PTYPE_INNER_L4_TCP,
4189 : : [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4190 : : RTE_PTYPE_TUNNEL_IP |
4191 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4192 : : RTE_PTYPE_INNER_L4_SCTP,
4193 : : [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4194 : : RTE_PTYPE_TUNNEL_IP |
4195 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4196 : : RTE_PTYPE_INNER_L4_ICMP,
4197 : :
4198 : : /* IPv4 --> GRE/Teredo/VXLAN */
4199 : : [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4200 : : RTE_PTYPE_TUNNEL_GRENAT,
4201 : :
4202 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
4203 : : [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4204 : : RTE_PTYPE_TUNNEL_GRENAT |
4205 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4206 : : RTE_PTYPE_INNER_L4_FRAG,
4207 : : [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4208 : : RTE_PTYPE_TUNNEL_GRENAT |
4209 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4210 : : RTE_PTYPE_INNER_L4_NONFRAG,
4211 : : [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4212 : : RTE_PTYPE_TUNNEL_GRENAT |
4213 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4214 : : RTE_PTYPE_INNER_L4_UDP,
4215 : : /* [47] reserved */
4216 : : [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4217 : : RTE_PTYPE_TUNNEL_GRENAT |
4218 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4219 : : RTE_PTYPE_INNER_L4_TCP,
4220 : : [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4221 : : RTE_PTYPE_TUNNEL_GRENAT |
4222 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4223 : : RTE_PTYPE_INNER_L4_SCTP,
4224 : : [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4225 : : RTE_PTYPE_TUNNEL_GRENAT |
4226 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4227 : : RTE_PTYPE_INNER_L4_ICMP,
4228 : :
4229 : : /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
4230 : : [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4231 : : RTE_PTYPE_TUNNEL_GRENAT |
4232 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4233 : : RTE_PTYPE_INNER_L4_FRAG,
4234 : : [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4235 : : RTE_PTYPE_TUNNEL_GRENAT |
4236 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4237 : : RTE_PTYPE_INNER_L4_NONFRAG,
4238 : : [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4239 : : RTE_PTYPE_TUNNEL_GRENAT |
4240 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4241 : : RTE_PTYPE_INNER_L4_UDP,
4242 : : /* [54] reserved */
4243 : : [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4244 : : RTE_PTYPE_TUNNEL_GRENAT |
4245 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4246 : : RTE_PTYPE_INNER_L4_TCP,
4247 : : [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4248 : : RTE_PTYPE_TUNNEL_GRENAT |
4249 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4250 : : RTE_PTYPE_INNER_L4_SCTP,
4251 : : [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4252 : : RTE_PTYPE_TUNNEL_GRENAT |
4253 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4254 : : RTE_PTYPE_INNER_L4_ICMP,
4255 : :
4256 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
4257 : : [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4258 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4259 : :
4260 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4261 : : [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4262 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4263 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4264 : : RTE_PTYPE_INNER_L4_FRAG,
4265 : : [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4266 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4267 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4268 : : RTE_PTYPE_INNER_L4_NONFRAG,
4269 : : [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4270 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4271 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4272 : : RTE_PTYPE_INNER_L4_UDP,
4273 : : /* [62] reserved */
4274 : : [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4275 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4276 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4277 : : RTE_PTYPE_INNER_L4_TCP,
4278 : : [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4279 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4280 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4281 : : RTE_PTYPE_INNER_L4_SCTP,
4282 : : [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4283 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4284 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4285 : : RTE_PTYPE_INNER_L4_ICMP,
4286 : :
4287 : : /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4288 : : [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4289 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4290 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4291 : : RTE_PTYPE_INNER_L4_FRAG,
4292 : : [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4293 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4294 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4295 : : RTE_PTYPE_INNER_L4_NONFRAG,
4296 : : [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4297 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4298 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4299 : : RTE_PTYPE_INNER_L4_UDP,
4300 : : /* [69] reserved */
4301 : : [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4302 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4303 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4304 : : RTE_PTYPE_INNER_L4_TCP,
4305 : : [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4306 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4307 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4308 : : RTE_PTYPE_INNER_L4_SCTP,
4309 : : [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4310 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4311 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4312 : : RTE_PTYPE_INNER_L4_ICMP,
4313 : : /* [73] - [87] reserved */
4314 : :
4315 : : /* Non tunneled IPv6 */
4316 : : [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4317 : : RTE_PTYPE_L4_FRAG,
4318 : : [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4319 : : RTE_PTYPE_L4_NONFRAG,
4320 : : [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4321 : : RTE_PTYPE_L4_UDP,
4322 : : /* [91] reserved */
4323 : : [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4324 : : RTE_PTYPE_L4_TCP,
4325 : : [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4326 : : RTE_PTYPE_L4_SCTP,
4327 : : [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4328 : : RTE_PTYPE_L4_ICMP,
4329 : :
4330 : : /* IPv6 --> IPv4 */
4331 : : [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4332 : : RTE_PTYPE_TUNNEL_IP |
4333 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4334 : : RTE_PTYPE_INNER_L4_FRAG,
4335 : : [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4336 : : RTE_PTYPE_TUNNEL_IP |
4337 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4338 : : RTE_PTYPE_INNER_L4_NONFRAG,
4339 : : [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4340 : : RTE_PTYPE_TUNNEL_IP |
4341 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4342 : : RTE_PTYPE_INNER_L4_UDP,
4343 : : /* [98] reserved */
4344 : : [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4345 : : RTE_PTYPE_TUNNEL_IP |
4346 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4347 : : RTE_PTYPE_INNER_L4_TCP,
4348 : : [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4349 : : RTE_PTYPE_TUNNEL_IP |
4350 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4351 : : RTE_PTYPE_INNER_L4_SCTP,
4352 : : [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4353 : : RTE_PTYPE_TUNNEL_IP |
4354 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4355 : : RTE_PTYPE_INNER_L4_ICMP,
4356 : :
4357 : : /* IPv6 --> IPv6 */
4358 : : [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4359 : : RTE_PTYPE_TUNNEL_IP |
4360 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4361 : : RTE_PTYPE_INNER_L4_FRAG,
4362 : : [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4363 : : RTE_PTYPE_TUNNEL_IP |
4364 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4365 : : RTE_PTYPE_INNER_L4_NONFRAG,
4366 : : [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4367 : : RTE_PTYPE_TUNNEL_IP |
4368 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4369 : : RTE_PTYPE_INNER_L4_UDP,
4370 : : /* [105] reserved */
4371 : : [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4372 : : RTE_PTYPE_TUNNEL_IP |
4373 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4374 : : RTE_PTYPE_INNER_L4_TCP,
4375 : : [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4376 : : RTE_PTYPE_TUNNEL_IP |
4377 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4378 : : RTE_PTYPE_INNER_L4_SCTP,
4379 : : [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4380 : : RTE_PTYPE_TUNNEL_IP |
4381 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4382 : : RTE_PTYPE_INNER_L4_ICMP,
4383 : :
4384 : : /* IPv6 --> GRE/Teredo/VXLAN */
4385 : : [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4386 : : RTE_PTYPE_TUNNEL_GRENAT,
4387 : :
4388 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
4389 : : [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4390 : : RTE_PTYPE_TUNNEL_GRENAT |
4391 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4392 : : RTE_PTYPE_INNER_L4_FRAG,
4393 : : [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4394 : : RTE_PTYPE_TUNNEL_GRENAT |
4395 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4396 : : RTE_PTYPE_INNER_L4_NONFRAG,
4397 : : [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4398 : : RTE_PTYPE_TUNNEL_GRENAT |
4399 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4400 : : RTE_PTYPE_INNER_L4_UDP,
4401 : : /* [113] reserved */
4402 : : [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4403 : : RTE_PTYPE_TUNNEL_GRENAT |
4404 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4405 : : RTE_PTYPE_INNER_L4_TCP,
4406 : : [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4407 : : RTE_PTYPE_TUNNEL_GRENAT |
4408 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4409 : : RTE_PTYPE_INNER_L4_SCTP,
4410 : : [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4411 : : RTE_PTYPE_TUNNEL_GRENAT |
4412 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4413 : : RTE_PTYPE_INNER_L4_ICMP,
4414 : :
4415 : : /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
4416 : : [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4417 : : RTE_PTYPE_TUNNEL_GRENAT |
4418 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4419 : : RTE_PTYPE_INNER_L4_FRAG,
4420 : : [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4421 : : RTE_PTYPE_TUNNEL_GRENAT |
4422 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4423 : : RTE_PTYPE_INNER_L4_NONFRAG,
4424 : : [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4425 : : RTE_PTYPE_TUNNEL_GRENAT |
4426 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4427 : : RTE_PTYPE_INNER_L4_UDP,
4428 : : /* [120] reserved */
4429 : : [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4430 : : RTE_PTYPE_TUNNEL_GRENAT |
4431 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4432 : : RTE_PTYPE_INNER_L4_TCP,
4433 : : [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4434 : : RTE_PTYPE_TUNNEL_GRENAT |
4435 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4436 : : RTE_PTYPE_INNER_L4_SCTP,
4437 : : [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4438 : : RTE_PTYPE_TUNNEL_GRENAT |
4439 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4440 : : RTE_PTYPE_INNER_L4_ICMP,
4441 : :
4442 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
4443 : : [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4444 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
4445 : :
4446 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
4447 : : [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4448 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4449 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4450 : : RTE_PTYPE_INNER_L4_FRAG,
4451 : : [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4452 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4453 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4454 : : RTE_PTYPE_INNER_L4_NONFRAG,
4455 : : [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4456 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4457 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4458 : : RTE_PTYPE_INNER_L4_UDP,
4459 : : /* [128] reserved */
4460 : : [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4461 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4462 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4463 : : RTE_PTYPE_INNER_L4_TCP,
4464 : : [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4465 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4466 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4467 : : RTE_PTYPE_INNER_L4_SCTP,
4468 : : [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4469 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4470 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4471 : : RTE_PTYPE_INNER_L4_ICMP,
4472 : :
4473 : : /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
4474 : : [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4475 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4476 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4477 : : RTE_PTYPE_INNER_L4_FRAG,
4478 : : [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4479 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4480 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4481 : : RTE_PTYPE_INNER_L4_NONFRAG,
4482 : : [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4483 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4484 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4485 : : RTE_PTYPE_INNER_L4_UDP,
4486 : : /* [135] reserved */
4487 : : [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4488 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4489 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4490 : : RTE_PTYPE_INNER_L4_TCP,
4491 : : [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4492 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4493 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4494 : : RTE_PTYPE_INNER_L4_SCTP,
4495 : : [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4496 : : RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4497 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4498 : : RTE_PTYPE_INNER_L4_ICMP,
4499 : : /* [139] - [299] reserved */
4500 : :
4501 : : /* PPPoE */
4502 : : [300] = RTE_PTYPE_L2_ETHER_PPPOE,
4503 : : [301] = RTE_PTYPE_L2_ETHER_PPPOE,
4504 : :
4505 : : /* PPPoE --> IPv4 */
4506 : : [302] = RTE_PTYPE_L2_ETHER_PPPOE |
4507 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4508 : : RTE_PTYPE_L4_FRAG,
4509 : : [303] = RTE_PTYPE_L2_ETHER_PPPOE |
4510 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4511 : : RTE_PTYPE_L4_NONFRAG,
4512 : : [304] = RTE_PTYPE_L2_ETHER_PPPOE |
4513 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4514 : : RTE_PTYPE_L4_UDP,
4515 : : [305] = RTE_PTYPE_L2_ETHER_PPPOE |
4516 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4517 : : RTE_PTYPE_L4_TCP,
4518 : : [306] = RTE_PTYPE_L2_ETHER_PPPOE |
4519 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4520 : : RTE_PTYPE_L4_SCTP,
4521 : : [307] = RTE_PTYPE_L2_ETHER_PPPOE |
4522 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4523 : : RTE_PTYPE_L4_ICMP,
4524 : :
4525 : : /* PPPoE --> IPv6 */
4526 : : [308] = RTE_PTYPE_L2_ETHER_PPPOE |
4527 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4528 : : RTE_PTYPE_L4_FRAG,
4529 : : [309] = RTE_PTYPE_L2_ETHER_PPPOE |
4530 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4531 : : RTE_PTYPE_L4_NONFRAG,
4532 : : [310] = RTE_PTYPE_L2_ETHER_PPPOE |
4533 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4534 : : RTE_PTYPE_L4_UDP,
4535 : : [311] = RTE_PTYPE_L2_ETHER_PPPOE |
4536 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4537 : : RTE_PTYPE_L4_TCP,
4538 : : [312] = RTE_PTYPE_L2_ETHER_PPPOE |
4539 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4540 : : RTE_PTYPE_L4_SCTP,
4541 : : [313] = RTE_PTYPE_L2_ETHER_PPPOE |
4542 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4543 : : RTE_PTYPE_L4_ICMP,
4544 : : /* [314] - [324] reserved */
4545 : :
4546 : : /* IPv4/IPv6 --> GTPC/GTPU */
4547 : : [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4548 : : RTE_PTYPE_TUNNEL_GTPC,
4549 : : [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4550 : : RTE_PTYPE_TUNNEL_GTPC,
4551 : : [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4552 : : RTE_PTYPE_TUNNEL_GTPC,
4553 : : [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4554 : : RTE_PTYPE_TUNNEL_GTPC,
4555 : : [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4556 : : RTE_PTYPE_TUNNEL_GTPU,
4557 : : [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4558 : : RTE_PTYPE_TUNNEL_GTPU,
4559 : :
4560 : : /* IPv4 --> GTPU --> IPv4 */
4561 : : [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4562 : : RTE_PTYPE_TUNNEL_GTPU |
4563 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4564 : : RTE_PTYPE_INNER_L4_FRAG,
4565 : : [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4566 : : RTE_PTYPE_TUNNEL_GTPU |
4567 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4568 : : RTE_PTYPE_INNER_L4_NONFRAG,
4569 : : [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4570 : : RTE_PTYPE_TUNNEL_GTPU |
4571 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4572 : : RTE_PTYPE_INNER_L4_UDP,
4573 : : [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4574 : : RTE_PTYPE_TUNNEL_GTPU |
4575 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4576 : : RTE_PTYPE_INNER_L4_TCP,
4577 : : [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4578 : : RTE_PTYPE_TUNNEL_GTPU |
4579 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4580 : : RTE_PTYPE_INNER_L4_ICMP,
4581 : :
4582 : : /* IPv6 --> GTPU --> IPv4 */
4583 : : [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4584 : : RTE_PTYPE_TUNNEL_GTPU |
4585 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4586 : : RTE_PTYPE_INNER_L4_FRAG,
4587 : : [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4588 : : RTE_PTYPE_TUNNEL_GTPU |
4589 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4590 : : RTE_PTYPE_INNER_L4_NONFRAG,
4591 : : [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4592 : : RTE_PTYPE_TUNNEL_GTPU |
4593 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4594 : : RTE_PTYPE_INNER_L4_UDP,
4595 : : [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4596 : : RTE_PTYPE_TUNNEL_GTPU |
4597 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4598 : : RTE_PTYPE_INNER_L4_TCP,
4599 : : [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4600 : : RTE_PTYPE_TUNNEL_GTPU |
4601 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4602 : : RTE_PTYPE_INNER_L4_ICMP,
4603 : :
4604 : : /* IPv4 --> GTPU --> IPv6 */
4605 : : [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4606 : : RTE_PTYPE_TUNNEL_GTPU |
4607 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4608 : : RTE_PTYPE_INNER_L4_FRAG,
4609 : : [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4610 : : RTE_PTYPE_TUNNEL_GTPU |
4611 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4612 : : RTE_PTYPE_INNER_L4_NONFRAG,
4613 : : [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4614 : : RTE_PTYPE_TUNNEL_GTPU |
4615 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4616 : : RTE_PTYPE_INNER_L4_UDP,
4617 : : [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4618 : : RTE_PTYPE_TUNNEL_GTPU |
4619 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4620 : : RTE_PTYPE_INNER_L4_TCP,
4621 : : [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4622 : : RTE_PTYPE_TUNNEL_GTPU |
4623 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4624 : : RTE_PTYPE_INNER_L4_ICMP,
4625 : :
4626 : : /* IPv6 --> GTPU --> IPv6 */
4627 : : [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4628 : : RTE_PTYPE_TUNNEL_GTPU |
4629 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4630 : : RTE_PTYPE_INNER_L4_FRAG,
4631 : : [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4632 : : RTE_PTYPE_TUNNEL_GTPU |
4633 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4634 : : RTE_PTYPE_INNER_L4_NONFRAG,
4635 : : [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4636 : : RTE_PTYPE_TUNNEL_GTPU |
4637 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4638 : : RTE_PTYPE_INNER_L4_UDP,
4639 : : [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4640 : : RTE_PTYPE_TUNNEL_GTPU |
4641 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4642 : : RTE_PTYPE_INNER_L4_TCP,
4643 : : [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4644 : : RTE_PTYPE_TUNNEL_GTPU |
4645 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4646 : : RTE_PTYPE_INNER_L4_ICMP,
4647 : :
4648 : : /* IPv4 --> UDP ECPRI */
4649 : : [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4650 : : RTE_PTYPE_L4_UDP,
4651 : : [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4652 : : RTE_PTYPE_L4_UDP,
4653 : : [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4654 : : RTE_PTYPE_L4_UDP,
4655 : : [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4656 : : RTE_PTYPE_L4_UDP,
4657 : : [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4658 : : RTE_PTYPE_L4_UDP,
4659 : : [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4660 : : RTE_PTYPE_L4_UDP,
4661 : : [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4662 : : RTE_PTYPE_L4_UDP,
4663 : : [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4664 : : RTE_PTYPE_L4_UDP,
4665 : : [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4666 : : RTE_PTYPE_L4_UDP,
4667 : : [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4668 : : RTE_PTYPE_L4_UDP,
4669 : :
4670 : : /* IPV6 --> UDP ECPRI */
4671 : : [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4672 : : RTE_PTYPE_L4_UDP,
4673 : : [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4674 : : RTE_PTYPE_L4_UDP,
4675 : : [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4676 : : RTE_PTYPE_L4_UDP,
4677 : : [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4678 : : RTE_PTYPE_L4_UDP,
4679 : : [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4680 : : RTE_PTYPE_L4_UDP,
4681 : : [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4682 : : RTE_PTYPE_L4_UDP,
4683 : : [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4684 : : RTE_PTYPE_L4_UDP,
4685 : : [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4686 : : RTE_PTYPE_L4_UDP,
4687 : : [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4688 : : RTE_PTYPE_L4_UDP,
4689 : : [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4690 : : RTE_PTYPE_L4_UDP,
4691 : : /* All others reserved */
4692 : : };
4693 : :
4694 : 0 : return ptype_tbl[ptype];
4695 : : }
4696 : :
4697 : : void __rte_cold
4698 : 0 : iavf_set_default_ptype_table(struct rte_eth_dev *dev)
4699 : : {
4700 : 0 : struct iavf_adapter *ad =
4701 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4702 : : int i;
4703 : :
4704 [ # # ]: 0 : for (i = 0; i < IAVF_MAX_PKT_TYPE; i++)
4705 : 0 : ad->ptype_tbl[i] = iavf_get_default_ptype(i);
4706 : 0 : }
|