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