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