1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #include <ethdev_driver.h>
9 #include "rte_pmd_ice.h"
11 #include "ice_rxtx_vec_common.h"
13 #define ICE_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM | \
14 RTE_MBUF_F_TX_L4_MASK | \
15 RTE_MBUF_F_TX_TCP_SEG | \
16 RTE_MBUF_F_TX_OUTER_IP_CKSUM)
18 /* Offset of mbuf dynamic field for protocol extraction data */
19 int rte_net_ice_dynfield_proto_xtr_metadata_offs = -1;
21 /* Mask of mbuf dynamic flags for protocol extraction type */
22 uint64_t rte_net_ice_dynflag_proto_xtr_vlan_mask;
23 uint64_t rte_net_ice_dynflag_proto_xtr_ipv4_mask;
24 uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_mask;
25 uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
26 uint64_t rte_net_ice_dynflag_proto_xtr_tcp_mask;
27 uint64_t rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
30 ice_monitor_callback(const uint64_t value,
31 const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
33 const uint64_t m = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
35 * we expect the DD bit to be set to 1 if this descriptor was already
38 return (value & m) == m ? -1 : 0;
42 ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
44 volatile union ice_rx_flex_desc *rxdp;
45 struct ice_rx_queue *rxq = rx_queue;
49 rxdp = &rxq->rx_ring[desc];
50 /* watch for changes in status bit */
51 pmc->addr = &rxdp->wb.status_error0;
53 /* comparison callback */
54 pmc->fn = ice_monitor_callback;
56 /* register is 16-bit */
57 pmc->size = sizeof(uint16_t);
64 ice_proto_xtr_type_to_rxdid(uint8_t xtr_type)
66 static uint8_t rxdid_map[] = {
67 [PROTO_XTR_NONE] = ICE_RXDID_COMMS_OVS,
68 [PROTO_XTR_VLAN] = ICE_RXDID_COMMS_AUX_VLAN,
69 [PROTO_XTR_IPV4] = ICE_RXDID_COMMS_AUX_IPV4,
70 [PROTO_XTR_IPV6] = ICE_RXDID_COMMS_AUX_IPV6,
71 [PROTO_XTR_IPV6_FLOW] = ICE_RXDID_COMMS_AUX_IPV6_FLOW,
72 [PROTO_XTR_TCP] = ICE_RXDID_COMMS_AUX_TCP,
73 [PROTO_XTR_IP_OFFSET] = ICE_RXDID_COMMS_AUX_IP_OFFSET,
76 return xtr_type < RTE_DIM(rxdid_map) ?
77 rxdid_map[xtr_type] : ICE_RXDID_COMMS_OVS;
81 ice_rxd_to_pkt_fields_by_comms_generic(__rte_unused struct ice_rx_queue *rxq,
83 volatile union ice_rx_flex_desc *rxdp)
85 volatile struct ice_32b_rx_flex_desc_comms *desc =
86 (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
87 uint16_t stat_err = rte_le_to_cpu_16(desc->status_error0);
89 if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
90 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
91 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
94 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
95 if (desc->flow_id != 0xFFFFFFFF) {
96 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
97 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
103 ice_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct ice_rx_queue *rxq,
105 volatile union ice_rx_flex_desc *rxdp)
107 volatile struct ice_32b_rx_flex_desc_comms_ovs *desc =
108 (volatile struct ice_32b_rx_flex_desc_comms_ovs *)rxdp;
109 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
113 if (desc->flow_id != 0xFFFFFFFF) {
114 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
115 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
118 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
119 stat_err = rte_le_to_cpu_16(desc->status_error0);
120 if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
121 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
122 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
128 ice_rxd_to_pkt_fields_by_comms_aux_v1(struct ice_rx_queue *rxq,
130 volatile union ice_rx_flex_desc *rxdp)
132 volatile struct ice_32b_rx_flex_desc_comms *desc =
133 (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
136 stat_err = rte_le_to_cpu_16(desc->status_error0);
137 if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
138 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
139 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
142 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
143 if (desc->flow_id != 0xFFFFFFFF) {
144 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
145 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
148 if (rxq->xtr_ol_flag) {
149 uint32_t metadata = 0;
151 stat_err = rte_le_to_cpu_16(desc->status_error1);
153 if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
154 metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
156 if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
158 rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
161 mb->ol_flags |= rxq->xtr_ol_flag;
163 *RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(mb) = metadata;
170 ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,
172 volatile union ice_rx_flex_desc *rxdp)
174 volatile struct ice_32b_rx_flex_desc_comms *desc =
175 (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
178 stat_err = rte_le_to_cpu_16(desc->status_error0);
179 if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
180 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
181 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
184 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
185 if (desc->flow_id != 0xFFFFFFFF) {
186 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
187 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
190 if (rxq->xtr_ol_flag) {
191 uint32_t metadata = 0;
193 if (desc->flex_ts.flex.aux0 != 0xFFFF)
194 metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
195 else if (desc->flex_ts.flex.aux1 != 0xFFFF)
196 metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
199 mb->ol_flags |= rxq->xtr_ol_flag;
201 *RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(mb) = metadata;
208 ice_select_rxd_to_pkt_fields_handler(struct ice_rx_queue *rxq, uint32_t rxdid)
211 case ICE_RXDID_COMMS_AUX_VLAN:
212 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_vlan_mask;
213 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;
216 case ICE_RXDID_COMMS_AUX_IPV4:
217 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv4_mask;
218 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;
221 case ICE_RXDID_COMMS_AUX_IPV6:
222 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_mask;
223 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;
226 case ICE_RXDID_COMMS_AUX_IPV6_FLOW:
227 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
228 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;
231 case ICE_RXDID_COMMS_AUX_TCP:
232 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_tcp_mask;
233 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v1;
236 case ICE_RXDID_COMMS_AUX_IP_OFFSET:
237 rxq->xtr_ol_flag = rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
238 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_aux_v2;
241 case ICE_RXDID_COMMS_GENERIC:
242 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_generic;
245 case ICE_RXDID_COMMS_OVS:
246 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;
250 /* update this according to the RXDID for PROTO_XTR_NONE */
251 rxq->rxd_to_pkt_fields = ice_rxd_to_pkt_fields_by_comms_ovs;
255 if (!rte_net_ice_dynf_proto_xtr_metadata_avail())
256 rxq->xtr_ol_flag = 0;
259 static enum ice_status
260 ice_program_hw_rx_queue(struct ice_rx_queue *rxq)
262 struct ice_vsi *vsi = rxq->vsi;
263 struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
264 struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
265 struct rte_eth_dev_data *dev_data = rxq->vsi->adapter->pf.dev_data;
266 struct ice_rlan_ctx rx_ctx;
269 uint32_t rxdid = ICE_RXDID_COMMS_OVS;
271 struct ice_adapter *ad = rxq->vsi->adapter;
272 uint32_t frame_size = dev_data->mtu + ICE_ETH_OVERHEAD;
274 /* Set buffer size as the head split is disabled. */
275 buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
276 RTE_PKTMBUF_HEADROOM);
278 rxq->rx_buf_len = RTE_ALIGN(buf_size, (1 << ICE_RLAN_CTX_DBUF_S));
280 RTE_MIN((uint32_t)ICE_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
283 if (rxq->max_pkt_len <= RTE_ETHER_MIN_LEN ||
284 rxq->max_pkt_len > ICE_FRAME_SIZE_MAX) {
285 PMD_DRV_LOG(ERR, "maximum packet length must "
286 "be larger than %u and smaller than %u",
287 (uint32_t)RTE_ETHER_MIN_LEN,
288 (uint32_t)ICE_FRAME_SIZE_MAX);
292 if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
293 /* Register mbuf field and flag for Rx timestamp */
294 err = rte_mbuf_dyn_rx_timestamp_register(
295 &ice_timestamp_dynfield_offset,
296 &ice_timestamp_dynflag);
299 "Cannot register mbuf field/flag for timestamp");
304 memset(&rx_ctx, 0, sizeof(rx_ctx));
306 rx_ctx.base = rxq->rx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
307 rx_ctx.qlen = rxq->nb_rx_desc;
308 rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
309 rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
310 rx_ctx.dtype = 0; /* No Header Split mode */
311 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
312 rx_ctx.dsize = 1; /* 32B descriptors */
314 rx_ctx.rxmax = rxq->max_pkt_len;
315 /* TPH: Transaction Layer Packet (TLP) processing hints */
316 rx_ctx.tphrdesc_ena = 1;
317 rx_ctx.tphwdesc_ena = 1;
318 rx_ctx.tphdata_ena = 1;
319 rx_ctx.tphhead_ena = 1;
320 /* Low Receive Queue Threshold defined in 64 descriptors units.
321 * When the number of free descriptors goes below the lrxqthresh,
322 * an immediate interrupt is triggered.
324 rx_ctx.lrxqthresh = 2;
325 /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
328 rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
330 rxdid = ice_proto_xtr_type_to_rxdid(rxq->proto_xtr);
332 PMD_DRV_LOG(DEBUG, "Port (%u) - Rx queue (%u) is set with RXDID : %u",
333 rxq->port_id, rxq->queue_id, rxdid);
335 if (!(pf->supported_rxdid & BIT(rxdid))) {
336 PMD_DRV_LOG(ERR, "currently package doesn't support RXDID (%u)",
341 ice_select_rxd_to_pkt_fields_handler(rxq, rxdid);
343 /* Enable Flexible Descriptors in the queue context which
344 * allows this driver to select a specific receive descriptor format
346 regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
347 QRXFLXP_CNTXT_RXDID_IDX_M;
349 /* increasing context priority to pick up profile ID;
350 * default is 0x01; setting to 0x03 to ensure profile
351 * is programming if prev context is of same priority
353 regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
354 QRXFLXP_CNTXT_RXDID_PRIO_M;
356 if (ad->ptp_ena || rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
357 regval |= QRXFLXP_CNTXT_TS_M;
359 ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
361 err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
363 PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
367 err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
369 PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
374 /* Check if scattered RX needs to be used. */
375 if (frame_size > buf_size)
376 dev_data->scattered_rx = 1;
378 rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
380 /* Init the Rx tail register*/
381 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
386 /* Allocate mbufs for all descriptors in rx queue */
388 ice_alloc_rx_queue_mbufs(struct ice_rx_queue *rxq)
390 struct ice_rx_entry *rxe = rxq->sw_ring;
394 for (i = 0; i < rxq->nb_rx_desc; i++) {
395 volatile union ice_rx_flex_desc *rxd;
396 struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mp);
398 if (unlikely(!mbuf)) {
399 PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
403 rte_mbuf_refcnt_set(mbuf, 1);
405 mbuf->data_off = RTE_PKTMBUF_HEADROOM;
407 mbuf->port = rxq->port_id;
410 rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
412 rxd = &rxq->rx_ring[i];
413 rxd->read.pkt_addr = dma_addr;
414 rxd->read.hdr_addr = 0;
415 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
425 /* Free all mbufs for descriptors in rx queue */
427 _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
431 if (!rxq || !rxq->sw_ring) {
432 PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
436 for (i = 0; i < rxq->nb_rx_desc; i++) {
437 if (rxq->sw_ring[i].mbuf) {
438 rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf);
439 rxq->sw_ring[i].mbuf = NULL;
442 if (rxq->rx_nb_avail == 0)
444 for (i = 0; i < rxq->rx_nb_avail; i++)
445 rte_pktmbuf_free_seg(rxq->rx_stage[rxq->rx_next_avail + i]);
447 rxq->rx_nb_avail = 0;
450 /* turn on or off rx queue
451 * @q_idx: queue index in pf scope
452 * @on: turn on or off the queue
455 ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
460 /* QRX_CTRL = QRX_ENA */
461 reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
464 if (reg & QRX_CTRL_QENA_STAT_M)
465 return 0; /* Already on, skip */
466 reg |= QRX_CTRL_QENA_REQ_M;
468 if (!(reg & QRX_CTRL_QENA_STAT_M))
469 return 0; /* Already off, skip */
470 reg &= ~QRX_CTRL_QENA_REQ_M;
473 /* Write the register */
474 ICE_WRITE_REG(hw, QRX_CTRL(q_idx), reg);
475 /* Check the result. It is said that QENA_STAT
476 * follows the QENA_REQ not more than 10 use.
477 * TODO: need to change the wait counter later
479 for (j = 0; j < ICE_CHK_Q_ENA_COUNT; j++) {
480 rte_delay_us(ICE_CHK_Q_ENA_INTERVAL_US);
481 reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
483 if ((reg & QRX_CTRL_QENA_REQ_M) &&
484 (reg & QRX_CTRL_QENA_STAT_M))
487 if (!(reg & QRX_CTRL_QENA_REQ_M) &&
488 !(reg & QRX_CTRL_QENA_STAT_M))
493 /* Check if it is timeout */
494 if (j >= ICE_CHK_Q_ENA_COUNT) {
495 PMD_DRV_LOG(ERR, "Failed to %s rx queue[%u]",
496 (on ? "enable" : "disable"), q_idx);
504 ice_check_rx_burst_bulk_alloc_preconditions(struct ice_rx_queue *rxq)
508 if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
509 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
510 "rxq->rx_free_thresh=%d, "
511 "ICE_RX_MAX_BURST=%d",
512 rxq->rx_free_thresh, ICE_RX_MAX_BURST);
514 } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
515 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
516 "rxq->rx_free_thresh=%d, "
517 "rxq->nb_rx_desc=%d",
518 rxq->rx_free_thresh, rxq->nb_rx_desc);
520 } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
521 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
522 "rxq->nb_rx_desc=%d, "
523 "rxq->rx_free_thresh=%d",
524 rxq->nb_rx_desc, rxq->rx_free_thresh);
531 /* reset fields in ice_rx_queue back to default */
533 ice_reset_rx_queue(struct ice_rx_queue *rxq)
539 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
543 len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
545 for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
546 ((volatile char *)rxq->rx_ring)[i] = 0;
548 memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
549 for (i = 0; i < ICE_RX_MAX_BURST; ++i)
550 rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
552 rxq->rx_nb_avail = 0;
553 rxq->rx_next_avail = 0;
554 rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
558 rxq->pkt_first_seg = NULL;
559 rxq->pkt_last_seg = NULL;
561 rxq->rxrearm_start = 0;
566 ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
568 struct ice_rx_queue *rxq;
570 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
572 PMD_INIT_FUNC_TRACE();
574 if (rx_queue_id >= dev->data->nb_rx_queues) {
575 PMD_DRV_LOG(ERR, "RX queue %u is out of range %u",
576 rx_queue_id, dev->data->nb_rx_queues);
580 rxq = dev->data->rx_queues[rx_queue_id];
581 if (!rxq || !rxq->q_set) {
582 PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
587 err = ice_program_hw_rx_queue(rxq);
589 PMD_DRV_LOG(ERR, "fail to program RX queue %u",
594 err = ice_alloc_rx_queue_mbufs(rxq);
596 PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
600 /* Init the RX tail register. */
601 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
603 err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
605 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
608 rxq->rx_rel_mbufs(rxq);
609 ice_reset_rx_queue(rxq);
613 dev->data->rx_queue_state[rx_queue_id] =
614 RTE_ETH_QUEUE_STATE_STARTED;
620 ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
622 struct ice_rx_queue *rxq;
624 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
626 if (rx_queue_id < dev->data->nb_rx_queues) {
627 rxq = dev->data->rx_queues[rx_queue_id];
629 err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
631 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
635 rxq->rx_rel_mbufs(rxq);
636 ice_reset_rx_queue(rxq);
637 dev->data->rx_queue_state[rx_queue_id] =
638 RTE_ETH_QUEUE_STATE_STOPPED;
645 ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
647 struct ice_tx_queue *txq;
651 struct ice_aqc_add_tx_qgrp *txq_elem;
652 struct ice_tlan_ctx tx_ctx;
655 PMD_INIT_FUNC_TRACE();
657 if (tx_queue_id >= dev->data->nb_tx_queues) {
658 PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
659 tx_queue_id, dev->data->nb_tx_queues);
663 txq = dev->data->tx_queues[tx_queue_id];
664 if (!txq || !txq->q_set) {
665 PMD_DRV_LOG(ERR, "TX queue %u is not available or setup",
670 buf_len = ice_struct_size(txq_elem, txqs, 1);
671 txq_elem = ice_malloc(hw, buf_len);
676 hw = ICE_VSI_TO_HW(vsi);
678 memset(&tx_ctx, 0, sizeof(tx_ctx));
679 txq_elem->num_txqs = 1;
680 txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
682 tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
683 tx_ctx.qlen = txq->nb_tx_desc;
684 tx_ctx.pf_num = hw->pf_id;
685 tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
686 tx_ctx.src_vsi = vsi->vsi_id;
687 tx_ctx.port_num = hw->port_info->lport;
688 tx_ctx.tso_ena = 1; /* tso enable */
689 tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
690 tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
693 ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
696 txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
698 /* Init the Tx tail register*/
699 ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
701 /* Fix me, we assume TC always 0 here */
702 err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
703 txq_elem, buf_len, NULL);
705 PMD_DRV_LOG(ERR, "Failed to add lan txq");
709 /* store the schedule node id */
710 txq->q_teid = txq_elem->txqs[0].q_teid;
712 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
718 static enum ice_status
719 ice_fdir_program_hw_rx_queue(struct ice_rx_queue *rxq)
721 struct ice_vsi *vsi = rxq->vsi;
722 struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
723 uint32_t rxdid = ICE_RXDID_LEGACY_1;
724 struct ice_rlan_ctx rx_ctx;
729 rxq->rx_buf_len = 1024;
731 memset(&rx_ctx, 0, sizeof(rx_ctx));
733 rx_ctx.base = rxq->rx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
734 rx_ctx.qlen = rxq->nb_rx_desc;
735 rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
736 rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
737 rx_ctx.dtype = 0; /* No Header Split mode */
738 rx_ctx.dsize = 1; /* 32B descriptors */
739 rx_ctx.rxmax = ICE_ETH_MAX_LEN;
740 /* TPH: Transaction Layer Packet (TLP) processing hints */
741 rx_ctx.tphrdesc_ena = 1;
742 rx_ctx.tphwdesc_ena = 1;
743 rx_ctx.tphdata_ena = 1;
744 rx_ctx.tphhead_ena = 1;
745 /* Low Receive Queue Threshold defined in 64 descriptors units.
746 * When the number of free descriptors goes below the lrxqthresh,
747 * an immediate interrupt is triggered.
749 rx_ctx.lrxqthresh = 2;
750 /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
753 rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
755 /* Enable Flexible Descriptors in the queue context which
756 * allows this driver to select a specific receive descriptor format
758 regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
759 QRXFLXP_CNTXT_RXDID_IDX_M;
761 /* increasing context priority to pick up profile ID;
762 * default is 0x01; setting to 0x03 to ensure profile
763 * is programming if prev context is of same priority
765 regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
766 QRXFLXP_CNTXT_RXDID_PRIO_M;
768 ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
770 err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
772 PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
776 err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
778 PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
783 rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
785 /* Init the Rx tail register*/
786 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
792 ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
794 struct ice_rx_queue *rxq;
796 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
797 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
799 PMD_INIT_FUNC_TRACE();
802 if (!rxq || !rxq->q_set) {
803 PMD_DRV_LOG(ERR, "FDIR RX queue %u not available or setup",
808 err = ice_fdir_program_hw_rx_queue(rxq);
810 PMD_DRV_LOG(ERR, "fail to program FDIR RX queue %u",
815 /* Init the RX tail register. */
816 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
818 err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
820 PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u on",
823 ice_reset_rx_queue(rxq);
831 ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
833 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
834 struct ice_tx_queue *txq;
838 struct ice_aqc_add_tx_qgrp *txq_elem;
839 struct ice_tlan_ctx tx_ctx;
842 PMD_INIT_FUNC_TRACE();
845 if (!txq || !txq->q_set) {
846 PMD_DRV_LOG(ERR, "FDIR TX queue %u is not available or setup",
851 buf_len = ice_struct_size(txq_elem, txqs, 1);
852 txq_elem = ice_malloc(hw, buf_len);
857 hw = ICE_VSI_TO_HW(vsi);
859 memset(&tx_ctx, 0, sizeof(tx_ctx));
860 txq_elem->num_txqs = 1;
861 txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
863 tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
864 tx_ctx.qlen = txq->nb_tx_desc;
865 tx_ctx.pf_num = hw->pf_id;
866 tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
867 tx_ctx.src_vsi = vsi->vsi_id;
868 tx_ctx.port_num = hw->port_info->lport;
869 tx_ctx.tso_ena = 1; /* tso enable */
870 tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
871 tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
873 ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
876 txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
878 /* Init the Tx tail register*/
879 ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
881 /* Fix me, we assume TC always 0 here */
882 err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
883 txq_elem, buf_len, NULL);
885 PMD_DRV_LOG(ERR, "Failed to add FDIR txq");
889 /* store the schedule node id */
890 txq->q_teid = txq_elem->txqs[0].q_teid;
896 /* Free all mbufs for descriptors in tx queue */
898 _ice_tx_queue_release_mbufs(struct ice_tx_queue *txq)
902 if (!txq || !txq->sw_ring) {
903 PMD_DRV_LOG(DEBUG, "Pointer to txq or sw_ring is NULL");
907 for (i = 0; i < txq->nb_tx_desc; i++) {
908 if (txq->sw_ring[i].mbuf) {
909 rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
910 txq->sw_ring[i].mbuf = NULL;
916 ice_reset_tx_queue(struct ice_tx_queue *txq)
918 struct ice_tx_entry *txe;
919 uint16_t i, prev, size;
922 PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
927 size = sizeof(struct ice_tx_desc) * txq->nb_tx_desc;
928 for (i = 0; i < size; i++)
929 ((volatile char *)txq->tx_ring)[i] = 0;
931 prev = (uint16_t)(txq->nb_tx_desc - 1);
932 for (i = 0; i < txq->nb_tx_desc; i++) {
933 volatile struct ice_tx_desc *txd = &txq->tx_ring[i];
935 txd->cmd_type_offset_bsz =
936 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE);
939 txe[prev].next_id = i;
943 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
944 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
949 txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
950 txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
954 ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
956 struct ice_tx_queue *txq;
957 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
958 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
959 struct ice_vsi *vsi = pf->main_vsi;
960 enum ice_status status;
963 uint16_t q_handle = tx_queue_id;
965 if (tx_queue_id >= dev->data->nb_tx_queues) {
966 PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
967 tx_queue_id, dev->data->nb_tx_queues);
971 txq = dev->data->tx_queues[tx_queue_id];
973 PMD_DRV_LOG(ERR, "TX queue %u is not available",
978 q_ids[0] = txq->reg_idx;
979 q_teids[0] = txq->q_teid;
981 /* Fix me, we assume TC always 0 here */
982 status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
983 q_ids, q_teids, ICE_NO_RESET, 0, NULL);
984 if (status != ICE_SUCCESS) {
985 PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
989 txq->tx_rel_mbufs(txq);
990 ice_reset_tx_queue(txq);
991 dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
997 ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
999 struct ice_rx_queue *rxq;
1001 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1002 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1006 err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
1008 PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u off",
1012 rxq->rx_rel_mbufs(rxq);
1018 ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
1020 struct ice_tx_queue *txq;
1021 struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1022 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1023 struct ice_vsi *vsi = pf->main_vsi;
1024 enum ice_status status;
1026 uint32_t q_teids[1];
1027 uint16_t q_handle = tx_queue_id;
1031 PMD_DRV_LOG(ERR, "TX queue %u is not available",
1037 q_ids[0] = txq->reg_idx;
1038 q_teids[0] = txq->q_teid;
1040 /* Fix me, we assume TC always 0 here */
1041 status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
1042 q_ids, q_teids, ICE_NO_RESET, 0, NULL);
1043 if (status != ICE_SUCCESS) {
1044 PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
1048 txq->tx_rel_mbufs(txq);
1054 ice_rx_queue_setup(struct rte_eth_dev *dev,
1057 unsigned int socket_id,
1058 const struct rte_eth_rxconf *rx_conf,
1059 struct rte_mempool *mp)
1061 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1062 struct ice_adapter *ad =
1063 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1064 struct ice_vsi *vsi = pf->main_vsi;
1065 struct ice_rx_queue *rxq;
1066 const struct rte_memzone *rz;
1069 int use_def_burst_func = 1;
1072 if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1073 nb_desc > ICE_MAX_RING_DESC ||
1074 nb_desc < ICE_MIN_RING_DESC) {
1075 PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
1076 "invalid", nb_desc);
1080 offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
1082 /* Free memory if needed */
1083 if (dev->data->rx_queues[queue_idx]) {
1084 ice_rx_queue_release(dev->data->rx_queues[queue_idx]);
1085 dev->data->rx_queues[queue_idx] = NULL;
1088 /* Allocate the rx queue data structure */
1089 rxq = rte_zmalloc_socket(NULL,
1090 sizeof(struct ice_rx_queue),
1091 RTE_CACHE_LINE_SIZE,
1094 PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1095 "rx queue data structure");
1099 rxq->nb_rx_desc = nb_desc;
1100 rxq->rx_free_thresh = rx_conf->rx_free_thresh;
1101 rxq->queue_id = queue_idx;
1102 rxq->offloads = offloads;
1104 rxq->reg_idx = vsi->base_queue + queue_idx;
1105 rxq->port_id = dev->data->port_id;
1106 if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
1107 rxq->crc_len = RTE_ETHER_CRC_LEN;
1111 rxq->drop_en = rx_conf->rx_drop_en;
1113 rxq->rx_deferred_start = rx_conf->rx_deferred_start;
1114 rxq->proto_xtr = pf->proto_xtr != NULL ?
1115 pf->proto_xtr[queue_idx] : PROTO_XTR_NONE;
1117 /* Allocate the maximun number of RX ring hardware descriptor. */
1118 len = ICE_MAX_RING_DESC;
1121 * Allocating a little more memory because vectorized/bulk_alloc Rx
1122 * functions doesn't check boundaries each time.
1124 len += ICE_RX_MAX_BURST;
1126 /* Allocate the maximum number of RX ring hardware descriptor. */
1127 ring_size = sizeof(union ice_rx_flex_desc) * len;
1128 ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1129 rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
1130 ring_size, ICE_RING_BASE_ALIGN,
1133 ice_rx_queue_release(rxq);
1134 PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
1139 /* Zero all the descriptors in the ring. */
1140 memset(rz->addr, 0, ring_size);
1142 rxq->rx_ring_dma = rz->iova;
1143 rxq->rx_ring = rz->addr;
1145 /* always reserve more for bulk alloc */
1146 len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
1148 /* Allocate the software ring. */
1149 rxq->sw_ring = rte_zmalloc_socket(NULL,
1150 sizeof(struct ice_rx_entry) * len,
1151 RTE_CACHE_LINE_SIZE,
1153 if (!rxq->sw_ring) {
1154 ice_rx_queue_release(rxq);
1155 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
1159 ice_reset_rx_queue(rxq);
1161 dev->data->rx_queues[queue_idx] = rxq;
1162 rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
1164 use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
1166 if (!use_def_burst_func) {
1167 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1168 "satisfied. Rx Burst Bulk Alloc function will be "
1169 "used on port=%d, queue=%d.",
1170 rxq->port_id, rxq->queue_id);
1172 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
1173 "not satisfied, Scattered Rx is requested. "
1174 "on port=%d, queue=%d.",
1175 rxq->port_id, rxq->queue_id);
1176 ad->rx_bulk_alloc_allowed = false;
1183 ice_rx_queue_release(void *rxq)
1185 struct ice_rx_queue *q = (struct ice_rx_queue *)rxq;
1188 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
1193 rte_free(q->sw_ring);
1194 rte_memzone_free(q->mz);
1199 ice_tx_queue_setup(struct rte_eth_dev *dev,
1202 unsigned int socket_id,
1203 const struct rte_eth_txconf *tx_conf)
1205 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
1206 struct ice_vsi *vsi = pf->main_vsi;
1207 struct ice_tx_queue *txq;
1208 const struct rte_memzone *tz;
1210 uint16_t tx_rs_thresh, tx_free_thresh;
1213 offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
1215 if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
1216 nb_desc > ICE_MAX_RING_DESC ||
1217 nb_desc < ICE_MIN_RING_DESC) {
1218 PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
1219 "invalid", nb_desc);
1224 * The following two parameters control the setting of the RS bit on
1225 * transmit descriptors. TX descriptors will have their RS bit set
1226 * after txq->tx_rs_thresh descriptors have been used. The TX
1227 * descriptor ring will be cleaned after txq->tx_free_thresh
1228 * descriptors are used or if the number of descriptors required to
1229 * transmit a packet is greater than the number of free TX descriptors.
1231 * The following constraints must be satisfied:
1232 * - tx_rs_thresh must be greater than 0.
1233 * - tx_rs_thresh must be less than the size of the ring minus 2.
1234 * - tx_rs_thresh must be less than or equal to tx_free_thresh.
1235 * - tx_rs_thresh must be a divisor of the ring size.
1236 * - tx_free_thresh must be greater than 0.
1237 * - tx_free_thresh must be less than the size of the ring minus 3.
1238 * - tx_free_thresh + tx_rs_thresh must not exceed nb_desc.
1240 * One descriptor in the TX ring is used as a sentinel to avoid a H/W
1241 * race condition, hence the maximum threshold constraints. When set
1242 * to zero use default values.
1244 tx_free_thresh = (uint16_t)(tx_conf->tx_free_thresh ?
1245 tx_conf->tx_free_thresh :
1246 ICE_DEFAULT_TX_FREE_THRESH);
1247 /* force tx_rs_thresh to adapt an aggresive tx_free_thresh */
1249 (ICE_DEFAULT_TX_RSBIT_THRESH + tx_free_thresh > nb_desc) ?
1250 nb_desc - tx_free_thresh : ICE_DEFAULT_TX_RSBIT_THRESH;
1251 if (tx_conf->tx_rs_thresh)
1252 tx_rs_thresh = tx_conf->tx_rs_thresh;
1253 if (tx_rs_thresh + tx_free_thresh > nb_desc) {
1254 PMD_INIT_LOG(ERR, "tx_rs_thresh + tx_free_thresh must not "
1255 "exceed nb_desc. (tx_rs_thresh=%u "
1256 "tx_free_thresh=%u nb_desc=%u port = %d queue=%d)",
1257 (unsigned int)tx_rs_thresh,
1258 (unsigned int)tx_free_thresh,
1259 (unsigned int)nb_desc,
1260 (int)dev->data->port_id,
1264 if (tx_rs_thresh >= (nb_desc - 2)) {
1265 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1266 "number of TX descriptors minus 2. "
1267 "(tx_rs_thresh=%u port=%d queue=%d)",
1268 (unsigned int)tx_rs_thresh,
1269 (int)dev->data->port_id,
1273 if (tx_free_thresh >= (nb_desc - 3)) {
1274 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
1275 "tx_free_thresh must be less than the "
1276 "number of TX descriptors minus 3. "
1277 "(tx_free_thresh=%u port=%d queue=%d)",
1278 (unsigned int)tx_free_thresh,
1279 (int)dev->data->port_id,
1283 if (tx_rs_thresh > tx_free_thresh) {
1284 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or "
1285 "equal to tx_free_thresh. (tx_free_thresh=%u"
1286 " tx_rs_thresh=%u port=%d queue=%d)",
1287 (unsigned int)tx_free_thresh,
1288 (unsigned int)tx_rs_thresh,
1289 (int)dev->data->port_id,
1293 if ((nb_desc % tx_rs_thresh) != 0) {
1294 PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
1295 "number of TX descriptors. (tx_rs_thresh=%u"
1296 " port=%d queue=%d)",
1297 (unsigned int)tx_rs_thresh,
1298 (int)dev->data->port_id,
1302 if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
1303 PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
1304 "tx_rs_thresh is greater than 1. "
1305 "(tx_rs_thresh=%u port=%d queue=%d)",
1306 (unsigned int)tx_rs_thresh,
1307 (int)dev->data->port_id,
1312 /* Free memory if needed. */
1313 if (dev->data->tx_queues[queue_idx]) {
1314 ice_tx_queue_release(dev->data->tx_queues[queue_idx]);
1315 dev->data->tx_queues[queue_idx] = NULL;
1318 /* Allocate the TX queue data structure. */
1319 txq = rte_zmalloc_socket(NULL,
1320 sizeof(struct ice_tx_queue),
1321 RTE_CACHE_LINE_SIZE,
1324 PMD_INIT_LOG(ERR, "Failed to allocate memory for "
1325 "tx queue structure");
1329 /* Allocate TX hardware ring descriptors. */
1330 ring_size = sizeof(struct ice_tx_desc) * ICE_MAX_RING_DESC;
1331 ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
1332 tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx,
1333 ring_size, ICE_RING_BASE_ALIGN,
1336 ice_tx_queue_release(txq);
1337 PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
1342 txq->nb_tx_desc = nb_desc;
1343 txq->tx_rs_thresh = tx_rs_thresh;
1344 txq->tx_free_thresh = tx_free_thresh;
1345 txq->pthresh = tx_conf->tx_thresh.pthresh;
1346 txq->hthresh = tx_conf->tx_thresh.hthresh;
1347 txq->wthresh = tx_conf->tx_thresh.wthresh;
1348 txq->queue_id = queue_idx;
1350 txq->reg_idx = vsi->base_queue + queue_idx;
1351 txq->port_id = dev->data->port_id;
1352 txq->offloads = offloads;
1354 txq->tx_deferred_start = tx_conf->tx_deferred_start;
1356 txq->tx_ring_dma = tz->iova;
1357 txq->tx_ring = tz->addr;
1359 /* Allocate software ring */
1361 rte_zmalloc_socket(NULL,
1362 sizeof(struct ice_tx_entry) * nb_desc,
1363 RTE_CACHE_LINE_SIZE,
1365 if (!txq->sw_ring) {
1366 ice_tx_queue_release(txq);
1367 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
1371 ice_reset_tx_queue(txq);
1373 dev->data->tx_queues[queue_idx] = txq;
1374 txq->tx_rel_mbufs = _ice_tx_queue_release_mbufs;
1375 ice_set_tx_function_flag(dev, txq);
1381 ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1383 ice_rx_queue_release(dev->data->rx_queues[qid]);
1387 ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1389 ice_tx_queue_release(dev->data->tx_queues[qid]);
1393 ice_tx_queue_release(void *txq)
1395 struct ice_tx_queue *q = (struct ice_tx_queue *)txq;
1398 PMD_DRV_LOG(DEBUG, "Pointer to TX queue is NULL");
1403 rte_free(q->sw_ring);
1404 rte_memzone_free(q->mz);
1409 ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1410 struct rte_eth_rxq_info *qinfo)
1412 struct ice_rx_queue *rxq;
1414 rxq = dev->data->rx_queues[queue_id];
1416 qinfo->mp = rxq->mp;
1417 qinfo->scattered_rx = dev->data->scattered_rx;
1418 qinfo->nb_desc = rxq->nb_rx_desc;
1420 qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
1421 qinfo->conf.rx_drop_en = rxq->drop_en;
1422 qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
1426 ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1427 struct rte_eth_txq_info *qinfo)
1429 struct ice_tx_queue *txq;
1431 txq = dev->data->tx_queues[queue_id];
1433 qinfo->nb_desc = txq->nb_tx_desc;
1435 qinfo->conf.tx_thresh.pthresh = txq->pthresh;
1436 qinfo->conf.tx_thresh.hthresh = txq->hthresh;
1437 qinfo->conf.tx_thresh.wthresh = txq->wthresh;
1439 qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
1440 qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
1441 qinfo->conf.offloads = txq->offloads;
1442 qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
1446 ice_rx_queue_count(void *rx_queue)
1448 #define ICE_RXQ_SCAN_INTERVAL 4
1449 volatile union ice_rx_flex_desc *rxdp;
1450 struct ice_rx_queue *rxq;
1454 rxdp = &rxq->rx_ring[rxq->rx_tail];
1455 while ((desc < rxq->nb_rx_desc) &&
1456 rte_le_to_cpu_16(rxdp->wb.status_error0) &
1457 (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)) {
1459 * Check the DD bit of a rx descriptor of each 4 in a group,
1460 * to avoid checking too frequently and downgrading performance
1463 desc += ICE_RXQ_SCAN_INTERVAL;
1464 rxdp += ICE_RXQ_SCAN_INTERVAL;
1465 if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
1466 rxdp = &(rxq->rx_ring[rxq->rx_tail +
1467 desc - rxq->nb_rx_desc]);
1473 #define ICE_RX_FLEX_ERR0_BITS \
1474 ((1 << ICE_RX_FLEX_DESC_STATUS0_HBO_S) | \
1475 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \
1476 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) | \
1477 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) | \
1478 (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) | \
1479 (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
1481 /* Rx L3/L4 checksum */
1482 static inline uint64_t
1483 ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
1487 /* check if HW has decoded the packet and checksum */
1488 if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S))))
1491 if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
1492 flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD);
1496 if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
1497 flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
1499 flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
1501 if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
1502 flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
1504 flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
1506 if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
1507 flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
1509 if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
1510 flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
1512 flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
1518 ice_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ice_rx_flex_desc *rxdp)
1520 if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
1521 (1 << ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
1522 mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1524 rte_le_to_cpu_16(rxdp->wb.l2tag1);
1525 PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
1526 rte_le_to_cpu_16(rxdp->wb.l2tag1));
1531 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
1532 if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
1533 (1 << ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
1534 mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED | RTE_MBUF_F_RX_QINQ |
1535 RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN;
1536 mb->vlan_tci_outer = mb->vlan_tci;
1537 mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
1538 PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
1539 rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
1540 rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
1542 mb->vlan_tci_outer = 0;
1545 PMD_RX_LOG(DEBUG, "Mbuf vlan_tci: %u, vlan_tci_outer: %u",
1546 mb->vlan_tci, mb->vlan_tci_outer);
1549 #define ICE_LOOK_AHEAD 8
1550 #if (ICE_LOOK_AHEAD != 8)
1551 #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
1554 ice_rx_scan_hw_ring(struct ice_rx_queue *rxq)
1556 volatile union ice_rx_flex_desc *rxdp;
1557 struct ice_rx_entry *rxep;
1558 struct rte_mbuf *mb;
1561 int32_t s[ICE_LOOK_AHEAD], nb_dd;
1562 int32_t i, j, nb_rx = 0;
1563 uint64_t pkt_flags = 0;
1564 uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1565 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
1566 struct ice_vsi *vsi = rxq->vsi;
1567 struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1569 struct ice_adapter *ad = rxq->vsi->adapter;
1571 rxdp = &rxq->rx_ring[rxq->rx_tail];
1572 rxep = &rxq->sw_ring[rxq->rx_tail];
1574 stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1576 /* Make sure there is at least 1 packet to receive */
1577 if (!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
1581 * Scan LOOK_AHEAD descriptors at a time to determine which
1582 * descriptors reference packets that are ready to be received.
1584 for (i = 0; i < ICE_RX_MAX_BURST; i += ICE_LOOK_AHEAD,
1585 rxdp += ICE_LOOK_AHEAD, rxep += ICE_LOOK_AHEAD) {
1586 /* Read desc statuses backwards to avoid race condition */
1587 for (j = ICE_LOOK_AHEAD - 1; j >= 0; j--)
1588 s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1592 /* Compute how many status bits were set */
1593 for (j = 0, nb_dd = 0; j < ICE_LOOK_AHEAD; j++)
1594 nb_dd += s[j] & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
1598 /* Translate descriptor info to mbuf parameters */
1599 for (j = 0; j < nb_dd; j++) {
1601 pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
1602 ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
1603 mb->data_len = pkt_len;
1604 mb->pkt_len = pkt_len;
1606 stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
1607 pkt_flags = ice_rxd_error_to_pkt_flags(stat_err0);
1608 mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
1609 rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
1610 ice_rxd_to_vlan_tci(mb, &rxdp[j]);
1611 rxq->rxd_to_pkt_fields(rxq, mb, &rxdp[j]);
1612 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
1613 if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1614 ts_ns = ice_tstamp_convert_32b_64b(hw,
1615 rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high));
1616 if (ice_timestamp_dynflag > 0) {
1617 *RTE_MBUF_DYNFIELD(mb,
1618 ice_timestamp_dynfield_offset,
1619 rte_mbuf_timestamp_t *) = ts_ns;
1620 mb->ol_flags |= ice_timestamp_dynflag;
1624 if (ad->ptp_ena && ((mb->packet_type &
1625 RTE_PTYPE_L2_MASK) == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
1627 rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
1628 mb->timesync = rxq->queue_id;
1629 pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
1632 mb->ol_flags |= pkt_flags;
1635 for (j = 0; j < ICE_LOOK_AHEAD; j++)
1636 rxq->rx_stage[i + j] = rxep[j].mbuf;
1638 if (nb_dd != ICE_LOOK_AHEAD)
1642 /* Clear software ring entries */
1643 for (i = 0; i < nb_rx; i++)
1644 rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
1646 PMD_RX_LOG(DEBUG, "ice_rx_scan_hw_ring: "
1647 "port_id=%u, queue_id=%u, nb_rx=%d",
1648 rxq->port_id, rxq->queue_id, nb_rx);
1653 static inline uint16_t
1654 ice_rx_fill_from_stage(struct ice_rx_queue *rxq,
1655 struct rte_mbuf **rx_pkts,
1659 struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
1661 nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
1663 for (i = 0; i < nb_pkts; i++)
1664 rx_pkts[i] = stage[i];
1666 rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
1667 rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
1673 ice_rx_alloc_bufs(struct ice_rx_queue *rxq)
1675 volatile union ice_rx_flex_desc *rxdp;
1676 struct ice_rx_entry *rxep;
1677 struct rte_mbuf *mb;
1678 uint16_t alloc_idx, i;
1682 /* Allocate buffers in bulk */
1683 alloc_idx = (uint16_t)(rxq->rx_free_trigger -
1684 (rxq->rx_free_thresh - 1));
1685 rxep = &rxq->sw_ring[alloc_idx];
1686 diag = rte_mempool_get_bulk(rxq->mp, (void *)rxep,
1687 rxq->rx_free_thresh);
1688 if (unlikely(diag != 0)) {
1689 PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
1693 rxdp = &rxq->rx_ring[alloc_idx];
1694 for (i = 0; i < rxq->rx_free_thresh; i++) {
1695 if (likely(i < (rxq->rx_free_thresh - 1)))
1696 /* Prefetch next mbuf */
1697 rte_prefetch0(rxep[i + 1].mbuf);
1700 rte_mbuf_refcnt_set(mb, 1);
1702 mb->data_off = RTE_PKTMBUF_HEADROOM;
1704 mb->port = rxq->port_id;
1705 dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
1706 rxdp[i].read.hdr_addr = 0;
1707 rxdp[i].read.pkt_addr = dma_addr;
1710 /* Update rx tail regsiter */
1711 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
1713 rxq->rx_free_trigger =
1714 (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
1715 if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
1716 rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
1721 static inline uint16_t
1722 rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
1724 struct ice_rx_queue *rxq = (struct ice_rx_queue *)rx_queue;
1730 if (rxq->rx_nb_avail)
1731 return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1733 nb_rx = (uint16_t)ice_rx_scan_hw_ring(rxq);
1734 rxq->rx_next_avail = 0;
1735 rxq->rx_nb_avail = nb_rx;
1736 rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
1738 if (rxq->rx_tail > rxq->rx_free_trigger) {
1739 if (ice_rx_alloc_bufs(rxq) != 0) {
1742 rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed +=
1743 rxq->rx_free_thresh;
1744 PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
1745 "port_id=%u, queue_id=%u",
1746 rxq->port_id, rxq->queue_id);
1747 rxq->rx_nb_avail = 0;
1748 rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
1749 for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
1750 rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
1756 if (rxq->rx_tail >= rxq->nb_rx_desc)
1759 if (rxq->rx_nb_avail)
1760 return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
1766 ice_recv_pkts_bulk_alloc(void *rx_queue,
1767 struct rte_mbuf **rx_pkts,
1774 if (unlikely(nb_pkts == 0))
1777 if (likely(nb_pkts <= ICE_RX_MAX_BURST))
1778 return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
1781 n = RTE_MIN(nb_pkts, ICE_RX_MAX_BURST);
1782 count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
1783 nb_rx = (uint16_t)(nb_rx + count);
1784 nb_pkts = (uint16_t)(nb_pkts - count);
1793 ice_recv_scattered_pkts(void *rx_queue,
1794 struct rte_mbuf **rx_pkts,
1797 struct ice_rx_queue *rxq = rx_queue;
1798 volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
1799 volatile union ice_rx_flex_desc *rxdp;
1800 union ice_rx_flex_desc rxd;
1801 struct ice_rx_entry *sw_ring = rxq->sw_ring;
1802 struct ice_rx_entry *rxe;
1803 struct rte_mbuf *first_seg = rxq->pkt_first_seg;
1804 struct rte_mbuf *last_seg = rxq->pkt_last_seg;
1805 struct rte_mbuf *nmb; /* new allocated mbuf */
1806 struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
1807 uint16_t rx_id = rxq->rx_tail;
1809 uint16_t nb_hold = 0;
1810 uint16_t rx_packet_len;
1811 uint16_t rx_stat_err0;
1814 uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
1815 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
1816 struct ice_vsi *vsi = rxq->vsi;
1817 struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
1819 struct ice_adapter *ad = rxq->vsi->adapter;
1821 while (nb_rx < nb_pkts) {
1822 rxdp = &rx_ring[rx_id];
1823 rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
1825 /* Check the DD bit first */
1826 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
1830 nmb = rte_mbuf_raw_alloc(rxq->mp);
1831 if (unlikely(!nmb)) {
1832 rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
1835 rxd = *rxdp; /* copy descriptor in ring to temp variable*/
1838 rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
1840 if (unlikely(rx_id == rxq->nb_rx_desc))
1843 /* Prefetch next mbuf */
1844 rte_prefetch0(sw_ring[rx_id].mbuf);
1847 * When next RX descriptor is on a cache line boundary,
1848 * prefetch the next 4 RX descriptors and next 8 pointers
1851 if ((rx_id & 0x3) == 0) {
1852 rte_prefetch0(&rx_ring[rx_id]);
1853 rte_prefetch0(&sw_ring[rx_id]);
1859 rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
1861 /* Set data buffer address and data length of the mbuf */
1862 rxdp->read.hdr_addr = 0;
1863 rxdp->read.pkt_addr = dma_addr;
1864 rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
1865 ICE_RX_FLX_DESC_PKT_LEN_M;
1866 rxm->data_len = rx_packet_len;
1867 rxm->data_off = RTE_PKTMBUF_HEADROOM;
1870 * If this is the first buffer of the received packet, set the
1871 * pointer to the first mbuf of the packet and initialize its
1872 * context. Otherwise, update the total length and the number
1873 * of segments of the current scattered packet, and update the
1874 * pointer to the last mbuf of the current packet.
1878 first_seg->nb_segs = 1;
1879 first_seg->pkt_len = rx_packet_len;
1881 first_seg->pkt_len =
1882 (uint16_t)(first_seg->pkt_len +
1884 first_seg->nb_segs++;
1885 last_seg->next = rxm;
1889 * If this is not the last buffer of the received packet,
1890 * update the pointer to the last mbuf of the current scattered
1891 * packet and continue to parse the RX ring.
1893 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_EOF_S))) {
1899 * This is the last buffer of the received packet. If the CRC
1900 * is not stripped by the hardware:
1901 * - Subtract the CRC length from the total packet length.
1902 * - If the last buffer only contains the whole CRC or a part
1903 * of it, free the mbuf associated to the last buffer. If part
1904 * of the CRC is also contained in the previous mbuf, subtract
1905 * the length of that CRC part from the data length of the
1909 if (unlikely(rxq->crc_len > 0)) {
1910 first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
1911 if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
1912 rte_pktmbuf_free_seg(rxm);
1913 first_seg->nb_segs--;
1914 last_seg->data_len =
1915 (uint16_t)(last_seg->data_len -
1916 (RTE_ETHER_CRC_LEN - rx_packet_len));
1917 last_seg->next = NULL;
1919 rxm->data_len = (uint16_t)(rx_packet_len -
1923 first_seg->port = rxq->port_id;
1924 first_seg->ol_flags = 0;
1925 first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
1926 rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
1927 ice_rxd_to_vlan_tci(first_seg, &rxd);
1928 rxq->rxd_to_pkt_fields(rxq, first_seg, &rxd);
1929 pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
1930 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
1931 if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
1932 ts_ns = ice_tstamp_convert_32b_64b(hw,
1933 rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
1934 if (ice_timestamp_dynflag > 0) {
1935 *RTE_MBUF_DYNFIELD(first_seg,
1936 ice_timestamp_dynfield_offset,
1937 rte_mbuf_timestamp_t *) = ts_ns;
1938 first_seg->ol_flags |= ice_timestamp_dynflag;
1942 if (ad->ptp_ena && ((first_seg->packet_type & RTE_PTYPE_L2_MASK)
1943 == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
1945 rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
1946 first_seg->timesync = rxq->queue_id;
1947 pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
1950 first_seg->ol_flags |= pkt_flags;
1951 /* Prefetch data of first segment, if configured to do so. */
1952 rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
1953 first_seg->data_off));
1954 rx_pkts[nb_rx++] = first_seg;
1958 /* Record index of the next RX descriptor to probe. */
1959 rxq->rx_tail = rx_id;
1960 rxq->pkt_first_seg = first_seg;
1961 rxq->pkt_last_seg = last_seg;
1964 * If the number of free RX descriptors is greater than the RX free
1965 * threshold of the queue, advance the Receive Descriptor Tail (RDT)
1966 * register. Update the RDT with the value of the last processed RX
1967 * descriptor minus 1, to guarantee that the RDT register is never
1968 * equal to the RDH register, which creates a "full" ring situtation
1969 * from the hardware point of view.
1971 nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
1972 if (nb_hold > rxq->rx_free_thresh) {
1973 rx_id = (uint16_t)(rx_id == 0 ?
1974 (rxq->nb_rx_desc - 1) : (rx_id - 1));
1975 /* write TAIL register */
1976 ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
1979 rxq->nb_rx_hold = nb_hold;
1981 /* return received packet in the burst */
1986 ice_dev_supported_ptypes_get(struct rte_eth_dev *dev)
1988 struct ice_adapter *ad =
1989 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
1990 const uint32_t *ptypes;
1992 static const uint32_t ptypes_os[] = {
1993 /* refers to ice_get_default_pkt_type() */
1995 RTE_PTYPE_L2_ETHER_TIMESYNC,
1996 RTE_PTYPE_L2_ETHER_LLDP,
1997 RTE_PTYPE_L2_ETHER_ARP,
1998 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
1999 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2002 RTE_PTYPE_L4_NONFRAG,
2006 RTE_PTYPE_TUNNEL_GRENAT,
2007 RTE_PTYPE_TUNNEL_IP,
2008 RTE_PTYPE_INNER_L2_ETHER,
2009 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2010 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2011 RTE_PTYPE_INNER_L4_FRAG,
2012 RTE_PTYPE_INNER_L4_ICMP,
2013 RTE_PTYPE_INNER_L4_NONFRAG,
2014 RTE_PTYPE_INNER_L4_SCTP,
2015 RTE_PTYPE_INNER_L4_TCP,
2016 RTE_PTYPE_INNER_L4_UDP,
2020 static const uint32_t ptypes_comms[] = {
2021 /* refers to ice_get_default_pkt_type() */
2023 RTE_PTYPE_L2_ETHER_TIMESYNC,
2024 RTE_PTYPE_L2_ETHER_LLDP,
2025 RTE_PTYPE_L2_ETHER_ARP,
2026 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
2027 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
2030 RTE_PTYPE_L4_NONFRAG,
2034 RTE_PTYPE_TUNNEL_GRENAT,
2035 RTE_PTYPE_TUNNEL_IP,
2036 RTE_PTYPE_INNER_L2_ETHER,
2037 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
2038 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
2039 RTE_PTYPE_INNER_L4_FRAG,
2040 RTE_PTYPE_INNER_L4_ICMP,
2041 RTE_PTYPE_INNER_L4_NONFRAG,
2042 RTE_PTYPE_INNER_L4_SCTP,
2043 RTE_PTYPE_INNER_L4_TCP,
2044 RTE_PTYPE_INNER_L4_UDP,
2045 RTE_PTYPE_TUNNEL_GTPC,
2046 RTE_PTYPE_TUNNEL_GTPU,
2047 RTE_PTYPE_L2_ETHER_PPPOE,
2051 if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
2052 ptypes = ptypes_comms;
2056 if (dev->rx_pkt_burst == ice_recv_pkts ||
2057 dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc ||
2058 dev->rx_pkt_burst == ice_recv_scattered_pkts)
2062 if (dev->rx_pkt_burst == ice_recv_pkts_vec ||
2063 dev->rx_pkt_burst == ice_recv_scattered_pkts_vec ||
2064 #ifdef CC_AVX512_SUPPORT
2065 dev->rx_pkt_burst == ice_recv_pkts_vec_avx512 ||
2066 dev->rx_pkt_burst == ice_recv_pkts_vec_avx512_offload ||
2067 dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512 ||
2068 dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload ||
2070 dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 ||
2071 dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload ||
2072 dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 ||
2073 dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload)
2081 ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
2083 volatile union ice_rx_flex_desc *rxdp;
2084 struct ice_rx_queue *rxq = rx_queue;
2087 if (unlikely(offset >= rxq->nb_rx_desc))
2090 if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
2091 return RTE_ETH_RX_DESC_UNAVAIL;
2093 desc = rxq->rx_tail + offset;
2094 if (desc >= rxq->nb_rx_desc)
2095 desc -= rxq->nb_rx_desc;
2097 rxdp = &rxq->rx_ring[desc];
2098 if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
2099 (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
2100 return RTE_ETH_RX_DESC_DONE;
2102 return RTE_ETH_RX_DESC_AVAIL;
2106 ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
2108 struct ice_tx_queue *txq = tx_queue;
2109 volatile uint64_t *status;
2110 uint64_t mask, expect;
2113 if (unlikely(offset >= txq->nb_tx_desc))
2116 desc = txq->tx_tail + offset;
2117 /* go to next desc that has the RS bit */
2118 desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
2120 if (desc >= txq->nb_tx_desc) {
2121 desc -= txq->nb_tx_desc;
2122 if (desc >= txq->nb_tx_desc)
2123 desc -= txq->nb_tx_desc;
2126 status = &txq->tx_ring[desc].cmd_type_offset_bsz;
2127 mask = rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M);
2128 expect = rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE <<
2129 ICE_TXD_QW1_DTYPE_S);
2130 if ((*status & mask) == expect)
2131 return RTE_ETH_TX_DESC_DONE;
2133 return RTE_ETH_TX_DESC_FULL;
2137 ice_free_queues(struct rte_eth_dev *dev)
2141 PMD_INIT_FUNC_TRACE();
2143 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2144 if (!dev->data->rx_queues[i])
2146 ice_rx_queue_release(dev->data->rx_queues[i]);
2147 dev->data->rx_queues[i] = NULL;
2149 dev->data->nb_rx_queues = 0;
2151 for (i = 0; i < dev->data->nb_tx_queues; i++) {
2152 if (!dev->data->tx_queues[i])
2154 ice_tx_queue_release(dev->data->tx_queues[i]);
2155 dev->data->tx_queues[i] = NULL;
2157 dev->data->nb_tx_queues = 0;
2160 #define ICE_FDIR_NUM_TX_DESC ICE_MIN_RING_DESC
2161 #define ICE_FDIR_NUM_RX_DESC ICE_MIN_RING_DESC
2164 ice_fdir_setup_tx_resources(struct ice_pf *pf)
2166 struct ice_tx_queue *txq;
2167 const struct rte_memzone *tz = NULL;
2169 struct rte_eth_dev *dev;
2172 PMD_DRV_LOG(ERR, "PF is not available");
2176 dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2178 /* Allocate the TX queue data structure. */
2179 txq = rte_zmalloc_socket("ice fdir tx queue",
2180 sizeof(struct ice_tx_queue),
2181 RTE_CACHE_LINE_SIZE,
2184 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2185 "tx queue structure.");
2189 /* Allocate TX hardware ring descriptors. */
2190 ring_size = sizeof(struct ice_tx_desc) * ICE_FDIR_NUM_TX_DESC;
2191 ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2193 tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
2194 ICE_FDIR_QUEUE_ID, ring_size,
2195 ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2197 ice_tx_queue_release(txq);
2198 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
2203 txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
2204 txq->queue_id = ICE_FDIR_QUEUE_ID;
2205 txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2206 txq->vsi = pf->fdir.fdir_vsi;
2208 txq->tx_ring_dma = tz->iova;
2209 txq->tx_ring = (struct ice_tx_desc *)tz->addr;
2211 * don't need to allocate software ring and reset for the fdir
2212 * program queue just set the queue has been configured.
2217 txq->tx_rel_mbufs = _ice_tx_queue_release_mbufs;
2223 ice_fdir_setup_rx_resources(struct ice_pf *pf)
2225 struct ice_rx_queue *rxq;
2226 const struct rte_memzone *rz = NULL;
2228 struct rte_eth_dev *dev;
2231 PMD_DRV_LOG(ERR, "PF is not available");
2235 dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
2237 /* Allocate the RX queue data structure. */
2238 rxq = rte_zmalloc_socket("ice fdir rx queue",
2239 sizeof(struct ice_rx_queue),
2240 RTE_CACHE_LINE_SIZE,
2243 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
2244 "rx queue structure.");
2248 /* Allocate RX hardware ring descriptors. */
2249 ring_size = sizeof(union ice_32byte_rx_desc) * ICE_FDIR_NUM_RX_DESC;
2250 ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
2252 rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
2253 ICE_FDIR_QUEUE_ID, ring_size,
2254 ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
2256 ice_rx_queue_release(rxq);
2257 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
2262 rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
2263 rxq->queue_id = ICE_FDIR_QUEUE_ID;
2264 rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
2265 rxq->vsi = pf->fdir.fdir_vsi;
2267 rxq->rx_ring_dma = rz->iova;
2268 memset(rz->addr, 0, ICE_FDIR_NUM_RX_DESC *
2269 sizeof(union ice_32byte_rx_desc));
2270 rxq->rx_ring = (union ice_rx_flex_desc *)rz->addr;
2273 * Don't need to allocate software ring and reset for the fdir
2274 * rx queue, just set the queue has been configured.
2279 rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
2285 ice_recv_pkts(void *rx_queue,
2286 struct rte_mbuf **rx_pkts,
2289 struct ice_rx_queue *rxq = rx_queue;
2290 volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
2291 volatile union ice_rx_flex_desc *rxdp;
2292 union ice_rx_flex_desc rxd;
2293 struct ice_rx_entry *sw_ring = rxq->sw_ring;
2294 struct ice_rx_entry *rxe;
2295 struct rte_mbuf *nmb; /* new allocated mbuf */
2296 struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
2297 uint16_t rx_id = rxq->rx_tail;
2299 uint16_t nb_hold = 0;
2300 uint16_t rx_packet_len;
2301 uint16_t rx_stat_err0;
2304 uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
2305 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
2306 struct ice_vsi *vsi = rxq->vsi;
2307 struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
2309 struct ice_adapter *ad = rxq->vsi->adapter;
2311 while (nb_rx < nb_pkts) {
2312 rxdp = &rx_ring[rx_id];
2313 rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
2315 /* Check the DD bit first */
2316 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
2320 nmb = rte_mbuf_raw_alloc(rxq->mp);
2321 if (unlikely(!nmb)) {
2322 rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
2325 rxd = *rxdp; /* copy descriptor in ring to temp variable*/
2328 rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
2330 if (unlikely(rx_id == rxq->nb_rx_desc))
2335 rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
2338 * fill the read format of descriptor with physic address in
2339 * new allocated mbuf: nmb
2341 rxdp->read.hdr_addr = 0;
2342 rxdp->read.pkt_addr = dma_addr;
2344 /* calculate rx_packet_len of the received pkt */
2345 rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
2346 ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
2348 /* fill old mbuf with received descriptor: rxd */
2349 rxm->data_off = RTE_PKTMBUF_HEADROOM;
2350 rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
2353 rxm->pkt_len = rx_packet_len;
2354 rxm->data_len = rx_packet_len;
2355 rxm->port = rxq->port_id;
2356 rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
2357 rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
2358 ice_rxd_to_vlan_tci(rxm, &rxd);
2359 rxq->rxd_to_pkt_fields(rxq, rxm, &rxd);
2360 pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
2361 #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
2362 if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
2363 ts_ns = ice_tstamp_convert_32b_64b(hw,
2364 rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high));
2365 if (ice_timestamp_dynflag > 0) {
2366 *RTE_MBUF_DYNFIELD(rxm,
2367 ice_timestamp_dynfield_offset,
2368 rte_mbuf_timestamp_t *) = ts_ns;
2369 rxm->ol_flags |= ice_timestamp_dynflag;
2373 if (ad->ptp_ena && ((rxm->packet_type & RTE_PTYPE_L2_MASK) ==
2374 RTE_PTYPE_L2_ETHER_TIMESYNC)) {
2376 rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
2377 rxm->timesync = rxq->queue_id;
2378 pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
2381 rxm->ol_flags |= pkt_flags;
2382 /* copy old mbuf to rx_pkts */
2383 rx_pkts[nb_rx++] = rxm;
2385 rxq->rx_tail = rx_id;
2387 * If the number of free RX descriptors is greater than the RX free
2388 * threshold of the queue, advance the receive tail register of queue.
2389 * Update that register with the value of the last processed RX
2390 * descriptor minus 1.
2392 nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
2393 if (nb_hold > rxq->rx_free_thresh) {
2394 rx_id = (uint16_t)(rx_id == 0 ?
2395 (rxq->nb_rx_desc - 1) : (rx_id - 1));
2396 /* write TAIL register */
2397 ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
2400 rxq->nb_rx_hold = nb_hold;
2402 /* return received packet in the burst */
2407 ice_parse_tunneling_params(uint64_t ol_flags,
2408 union ice_tx_offload tx_offload,
2409 uint32_t *cd_tunneling)
2411 /* EIPT: External (outer) IP header type */
2412 if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
2413 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4;
2414 else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)
2415 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4_NO_CSUM;
2416 else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)
2417 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV6;
2419 /* EIPLEN: External (outer) IP header length, in DWords */
2420 *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
2421 ICE_TXD_CTX_QW0_EIPLEN_S;
2423 /* L4TUNT: L4 Tunneling Type */
2424 switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
2425 case RTE_MBUF_F_TX_TUNNEL_IPIP:
2426 /* for non UDP / GRE tunneling, set to 00b */
2428 case RTE_MBUF_F_TX_TUNNEL_VXLAN:
2429 case RTE_MBUF_F_TX_TUNNEL_GTP:
2430 case RTE_MBUF_F_TX_TUNNEL_GENEVE:
2431 *cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
2433 case RTE_MBUF_F_TX_TUNNEL_GRE:
2434 *cd_tunneling |= ICE_TXD_CTX_GRE_TUNNELING;
2437 PMD_TX_LOG(ERR, "Tunnel type not supported");
2441 /* L4TUNLEN: L4 Tunneling Length, in Words
2443 * We depend on app to set rte_mbuf.l2_len correctly.
2444 * For IP in GRE it should be set to the length of the GRE
2446 * For MAC in GRE or MAC in UDP it should be set to the length
2447 * of the GRE or UDP headers plus the inner MAC up to including
2448 * its last Ethertype.
2449 * If MPLS labels exists, it should include them as well.
2451 *cd_tunneling |= (tx_offload.l2_len >> 1) <<
2452 ICE_TXD_CTX_QW0_NATLEN_S;
2455 * Calculate the tunneling UDP checksum.
2456 * Shall be set only if L4TUNT = 01b and EIPT is not zero
2458 if (!(*cd_tunneling & ICE_TX_CTX_EIPT_NONE) &&
2459 (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING))
2460 *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M;
2464 ice_txd_enable_checksum(uint64_t ol_flags,
2466 uint32_t *td_offset,
2467 union ice_tx_offload tx_offload)
2470 if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2471 *td_offset |= (tx_offload.outer_l2_len >> 1)
2472 << ICE_TX_DESC_LEN_MACLEN_S;
2474 *td_offset |= (tx_offload.l2_len >> 1)
2475 << ICE_TX_DESC_LEN_MACLEN_S;
2477 /* Enable L3 checksum offloads */
2478 if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
2479 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4_CSUM;
2480 *td_offset |= (tx_offload.l3_len >> 2) <<
2481 ICE_TX_DESC_LEN_IPLEN_S;
2482 } else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
2483 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4;
2484 *td_offset |= (tx_offload.l3_len >> 2) <<
2485 ICE_TX_DESC_LEN_IPLEN_S;
2486 } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
2487 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV6;
2488 *td_offset |= (tx_offload.l3_len >> 2) <<
2489 ICE_TX_DESC_LEN_IPLEN_S;
2492 if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
2493 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
2494 *td_offset |= (tx_offload.l4_len >> 2) <<
2495 ICE_TX_DESC_LEN_L4_LEN_S;
2499 /* Enable L4 checksum offloads */
2500 switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
2501 case RTE_MBUF_F_TX_TCP_CKSUM:
2502 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
2503 *td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
2504 ICE_TX_DESC_LEN_L4_LEN_S;
2506 case RTE_MBUF_F_TX_SCTP_CKSUM:
2507 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_SCTP;
2508 *td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
2509 ICE_TX_DESC_LEN_L4_LEN_S;
2511 case RTE_MBUF_F_TX_UDP_CKSUM:
2512 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP;
2513 *td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
2514 ICE_TX_DESC_LEN_L4_LEN_S;
2522 ice_xmit_cleanup(struct ice_tx_queue *txq)
2524 struct ice_tx_entry *sw_ring = txq->sw_ring;
2525 volatile struct ice_tx_desc *txd = txq->tx_ring;
2526 uint16_t last_desc_cleaned = txq->last_desc_cleaned;
2527 uint16_t nb_tx_desc = txq->nb_tx_desc;
2528 uint16_t desc_to_clean_to;
2529 uint16_t nb_tx_to_clean;
2531 /* Determine the last descriptor needing to be cleaned */
2532 desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
2533 if (desc_to_clean_to >= nb_tx_desc)
2534 desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
2536 /* Check to make sure the last descriptor to clean is done */
2537 desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
2538 if (!(txd[desc_to_clean_to].cmd_type_offset_bsz &
2539 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
2540 PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
2541 "(port=%d queue=%d) value=0x%"PRIx64"\n",
2543 txq->port_id, txq->queue_id,
2544 txd[desc_to_clean_to].cmd_type_offset_bsz);
2545 /* Failed to clean any descriptors */
2549 /* Figure out how many descriptors will be cleaned */
2550 if (last_desc_cleaned > desc_to_clean_to)
2551 nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
2554 nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
2557 /* The last descriptor to clean is done, so that means all the
2558 * descriptors from the last descriptor that was cleaned
2559 * up to the last descriptor with the RS bit set
2560 * are done. Only reset the threshold descriptor.
2562 txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
2564 /* Update the txq to reflect the last descriptor that was cleaned */
2565 txq->last_desc_cleaned = desc_to_clean_to;
2566 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
2571 /* Construct the tx flags */
2572 static inline uint64_t
2573 ice_build_ctob(uint32_t td_cmd,
2578 return rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
2579 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
2580 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
2581 ((uint64_t)size << ICE_TXD_QW1_TX_BUF_SZ_S) |
2582 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
2585 /* Check if the context descriptor is needed for TX offloading */
2586 static inline uint16_t
2587 ice_calc_context_desc(uint64_t flags)
2589 static uint64_t mask = RTE_MBUF_F_TX_TCP_SEG |
2590 RTE_MBUF_F_TX_QINQ |
2591 RTE_MBUF_F_TX_OUTER_IP_CKSUM |
2592 RTE_MBUF_F_TX_TUNNEL_MASK |
2593 RTE_MBUF_F_TX_IEEE1588_TMST;
2595 return (flags & mask) ? 1 : 0;
2598 /* set ice TSO context descriptor */
2599 static inline uint64_t
2600 ice_set_tso_ctx(struct rte_mbuf *mbuf, union ice_tx_offload tx_offload)
2602 uint64_t ctx_desc = 0;
2603 uint32_t cd_cmd, hdr_len, cd_tso_len;
2605 if (!tx_offload.l4_len) {
2606 PMD_TX_LOG(DEBUG, "L4 length set to 0");
2610 hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
2611 hdr_len += (mbuf->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
2612 tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
2614 cd_cmd = ICE_TX_CTX_DESC_TSO;
2615 cd_tso_len = mbuf->pkt_len - hdr_len;
2616 ctx_desc |= ((uint64_t)cd_cmd << ICE_TXD_CTX_QW1_CMD_S) |
2617 ((uint64_t)cd_tso_len << ICE_TXD_CTX_QW1_TSO_LEN_S) |
2618 ((uint64_t)mbuf->tso_segsz << ICE_TXD_CTX_QW1_MSS_S);
2623 /* HW requires that TX buffer size ranges from 1B up to (16K-1)B. */
2624 #define ICE_MAX_DATA_PER_TXD \
2625 (ICE_TXD_QW1_TX_BUF_SZ_M >> ICE_TXD_QW1_TX_BUF_SZ_S)
2626 /* Calculate the number of TX descriptors needed for each pkt */
2627 static inline uint16_t
2628 ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
2630 struct rte_mbuf *txd = tx_pkt;
2633 while (txd != NULL) {
2634 count += DIV_ROUND_UP(txd->data_len, ICE_MAX_DATA_PER_TXD);
2642 ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
2644 struct ice_tx_queue *txq;
2645 volatile struct ice_tx_desc *tx_ring;
2646 volatile struct ice_tx_desc *txd;
2647 struct ice_tx_entry *sw_ring;
2648 struct ice_tx_entry *txe, *txn;
2649 struct rte_mbuf *tx_pkt;
2650 struct rte_mbuf *m_seg;
2651 uint32_t cd_tunneling_params;
2656 uint32_t td_cmd = 0;
2657 uint32_t td_offset = 0;
2658 uint32_t td_tag = 0;
2661 uint64_t buf_dma_addr;
2663 union ice_tx_offload tx_offload = {0};
2666 sw_ring = txq->sw_ring;
2667 tx_ring = txq->tx_ring;
2668 tx_id = txq->tx_tail;
2669 txe = &sw_ring[tx_id];
2671 /* Check if the descriptor ring needs to be cleaned. */
2672 if (txq->nb_tx_free < txq->tx_free_thresh)
2673 (void)ice_xmit_cleanup(txq);
2675 for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
2676 tx_pkt = *tx_pkts++;
2681 ol_flags = tx_pkt->ol_flags;
2682 tx_offload.l2_len = tx_pkt->l2_len;
2683 tx_offload.l3_len = tx_pkt->l3_len;
2684 tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
2685 tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
2686 tx_offload.l4_len = tx_pkt->l4_len;
2687 tx_offload.tso_segsz = tx_pkt->tso_segsz;
2688 /* Calculate the number of context descriptors needed. */
2689 nb_ctx = ice_calc_context_desc(ol_flags);
2691 /* The number of descriptors that must be allocated for
2692 * a packet equals to the number of the segments of that
2693 * packet plus the number of context descriptor if needed.
2694 * Recalculate the needed tx descs when TSO enabled in case
2695 * the mbuf data size exceeds max data size that hw allows
2698 if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
2699 nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
2702 nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
2703 tx_last = (uint16_t)(tx_id + nb_used - 1);
2706 if (tx_last >= txq->nb_tx_desc)
2707 tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
2709 if (nb_used > txq->nb_tx_free) {
2710 if (ice_xmit_cleanup(txq) != 0) {
2715 if (unlikely(nb_used > txq->tx_rs_thresh)) {
2716 while (nb_used > txq->nb_tx_free) {
2717 if (ice_xmit_cleanup(txq) != 0) {
2726 /* Descriptor based VLAN insertion */
2727 if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
2728 td_cmd |= ICE_TX_DESC_CMD_IL2TAG1;
2729 td_tag = tx_pkt->vlan_tci;
2732 /* Fill in tunneling parameters if necessary */
2733 cd_tunneling_params = 0;
2734 if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
2735 ice_parse_tunneling_params(ol_flags, tx_offload,
2736 &cd_tunneling_params);
2738 /* Enable checksum offloading */
2739 if (ol_flags & ICE_TX_CKSUM_OFFLOAD_MASK)
2740 ice_txd_enable_checksum(ol_flags, &td_cmd,
2741 &td_offset, tx_offload);
2744 /* Setup TX context descriptor if required */
2745 volatile struct ice_tx_ctx_desc *ctx_txd =
2746 (volatile struct ice_tx_ctx_desc *)
2748 uint16_t cd_l2tag2 = 0;
2749 uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
2751 txn = &sw_ring[txe->next_id];
2752 RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
2754 rte_pktmbuf_free_seg(txe->mbuf);
2758 if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
2759 cd_type_cmd_tso_mss |=
2760 ice_set_tso_ctx(tx_pkt, tx_offload);
2761 else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
2762 cd_type_cmd_tso_mss |=
2763 ((uint64_t)ICE_TX_CTX_DESC_TSYN <<
2764 ICE_TXD_CTX_QW1_CMD_S);
2766 ctx_txd->tunneling_params =
2767 rte_cpu_to_le_32(cd_tunneling_params);
2769 /* TX context descriptor based double VLAN insert */
2770 if (ol_flags & RTE_MBUF_F_TX_QINQ) {
2771 cd_l2tag2 = tx_pkt->vlan_tci_outer;
2772 cd_type_cmd_tso_mss |=
2773 ((uint64_t)ICE_TX_CTX_DESC_IL2TAG2 <<
2774 ICE_TXD_CTX_QW1_CMD_S);
2776 ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
2778 rte_cpu_to_le_64(cd_type_cmd_tso_mss);
2780 txe->last_id = tx_last;
2781 tx_id = txe->next_id;
2787 txd = &tx_ring[tx_id];
2788 txn = &sw_ring[txe->next_id];
2791 rte_pktmbuf_free_seg(txe->mbuf);
2794 /* Setup TX Descriptor */
2795 slen = m_seg->data_len;
2796 buf_dma_addr = rte_mbuf_data_iova(m_seg);
2798 while ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
2799 unlikely(slen > ICE_MAX_DATA_PER_TXD)) {
2800 txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
2801 txd->cmd_type_offset_bsz =
2802 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
2803 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
2804 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
2805 ((uint64_t)ICE_MAX_DATA_PER_TXD <<
2806 ICE_TXD_QW1_TX_BUF_SZ_S) |
2807 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
2809 buf_dma_addr += ICE_MAX_DATA_PER_TXD;
2810 slen -= ICE_MAX_DATA_PER_TXD;
2812 txe->last_id = tx_last;
2813 tx_id = txe->next_id;
2815 txd = &tx_ring[tx_id];
2816 txn = &sw_ring[txe->next_id];
2819 txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
2820 txd->cmd_type_offset_bsz =
2821 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
2822 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
2823 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
2824 ((uint64_t)slen << ICE_TXD_QW1_TX_BUF_SZ_S) |
2825 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
2827 txe->last_id = tx_last;
2828 tx_id = txe->next_id;
2830 m_seg = m_seg->next;
2833 /* fill the last descriptor with End of Packet (EOP) bit */
2834 td_cmd |= ICE_TX_DESC_CMD_EOP;
2835 txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
2836 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
2838 /* set RS bit on the last descriptor of one packet */
2839 if (txq->nb_tx_used >= txq->tx_rs_thresh) {
2841 "Setting RS bit on TXD id="
2842 "%4u (port=%d queue=%d)",
2843 tx_last, txq->port_id, txq->queue_id);
2845 td_cmd |= ICE_TX_DESC_CMD_RS;
2847 /* Update txq RS bit counters */
2848 txq->nb_tx_used = 0;
2850 txd->cmd_type_offset_bsz |=
2851 rte_cpu_to_le_64(((uint64_t)td_cmd) <<
2855 /* update Tail register */
2856 ICE_PCI_REG_WRITE(txq->qtx_tail, tx_id);
2857 txq->tx_tail = tx_id;
2862 static __rte_always_inline int
2863 ice_tx_free_bufs(struct ice_tx_queue *txq)
2865 struct ice_tx_entry *txep;
2868 if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
2869 rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) !=
2870 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
2873 txep = &txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)];
2875 for (i = 0; i < txq->tx_rs_thresh; i++)
2876 rte_prefetch0((txep + i)->mbuf);
2878 if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
2879 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
2880 rte_mempool_put(txep->mbuf->pool, txep->mbuf);
2884 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
2885 rte_pktmbuf_free_seg(txep->mbuf);
2890 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
2891 txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
2892 if (txq->tx_next_dd >= txq->nb_tx_desc)
2893 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
2895 return txq->tx_rs_thresh;
2899 ice_tx_done_cleanup_full(struct ice_tx_queue *txq,
2902 struct ice_tx_entry *swr_ring = txq->sw_ring;
2903 uint16_t i, tx_last, tx_id;
2904 uint16_t nb_tx_free_last;
2905 uint16_t nb_tx_to_clean;
2908 /* Start free mbuf from the next of tx_tail */
2909 tx_last = txq->tx_tail;
2910 tx_id = swr_ring[tx_last].next_id;
2912 if (txq->nb_tx_free == 0 && ice_xmit_cleanup(txq))
2915 nb_tx_to_clean = txq->nb_tx_free;
2916 nb_tx_free_last = txq->nb_tx_free;
2918 free_cnt = txq->nb_tx_desc;
2920 /* Loop through swr_ring to count the amount of
2921 * freeable mubfs and packets.
2923 for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
2924 for (i = 0; i < nb_tx_to_clean &&
2925 pkt_cnt < free_cnt &&
2926 tx_id != tx_last; i++) {
2927 if (swr_ring[tx_id].mbuf != NULL) {
2928 rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
2929 swr_ring[tx_id].mbuf = NULL;
2932 * last segment in the packet,
2933 * increment packet count
2935 pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
2938 tx_id = swr_ring[tx_id].next_id;
2941 if (txq->tx_rs_thresh > txq->nb_tx_desc -
2942 txq->nb_tx_free || tx_id == tx_last)
2945 if (pkt_cnt < free_cnt) {
2946 if (ice_xmit_cleanup(txq))
2949 nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
2950 nb_tx_free_last = txq->nb_tx_free;
2954 return (int)pkt_cnt;
2959 ice_tx_done_cleanup_vec(struct ice_tx_queue *txq __rte_unused,
2960 uint32_t free_cnt __rte_unused)
2967 ice_tx_done_cleanup_simple(struct ice_tx_queue *txq,
2972 if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
2973 free_cnt = txq->nb_tx_desc;
2975 cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
2977 for (i = 0; i < cnt; i += n) {
2978 if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
2981 n = ice_tx_free_bufs(txq);
2991 ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
2993 struct ice_tx_queue *q = (struct ice_tx_queue *)txq;
2994 struct rte_eth_dev *dev = &rte_eth_devices[q->port_id];
2995 struct ice_adapter *ad =
2996 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2999 if (ad->tx_vec_allowed)
3000 return ice_tx_done_cleanup_vec(q, free_cnt);
3002 if (ad->tx_simple_allowed)
3003 return ice_tx_done_cleanup_simple(q, free_cnt);
3005 return ice_tx_done_cleanup_full(q, free_cnt);
3008 /* Populate 4 descriptors with data from 4 mbufs */
3010 tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
3015 for (i = 0; i < 4; i++, txdp++, pkts++) {
3016 dma_addr = rte_mbuf_data_iova(*pkts);
3017 txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
3018 txdp->cmd_type_offset_bsz =
3019 ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
3020 (*pkts)->data_len, 0);
3024 /* Populate 1 descriptor with data from 1 mbuf */
3026 tx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
3030 dma_addr = rte_mbuf_data_iova(*pkts);
3031 txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
3032 txdp->cmd_type_offset_bsz =
3033 ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
3034 (*pkts)->data_len, 0);
3038 ice_tx_fill_hw_ring(struct ice_tx_queue *txq, struct rte_mbuf **pkts,
3041 volatile struct ice_tx_desc *txdp = &txq->tx_ring[txq->tx_tail];
3042 struct ice_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
3043 const int N_PER_LOOP = 4;
3044 const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
3045 int mainpart, leftover;
3049 * Process most of the packets in chunks of N pkts. Any
3050 * leftover packets will get processed one at a time.
3052 mainpart = nb_pkts & ((uint32_t)~N_PER_LOOP_MASK);
3053 leftover = nb_pkts & ((uint32_t)N_PER_LOOP_MASK);
3054 for (i = 0; i < mainpart; i += N_PER_LOOP) {
3055 /* Copy N mbuf pointers to the S/W ring */
3056 for (j = 0; j < N_PER_LOOP; ++j)
3057 (txep + i + j)->mbuf = *(pkts + i + j);
3058 tx4(txdp + i, pkts + i);
3061 if (unlikely(leftover > 0)) {
3062 for (i = 0; i < leftover; ++i) {
3063 (txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
3064 tx1(txdp + mainpart + i, pkts + mainpart + i);
3069 static inline uint16_t
3070 tx_xmit_pkts(struct ice_tx_queue *txq,
3071 struct rte_mbuf **tx_pkts,
3074 volatile struct ice_tx_desc *txr = txq->tx_ring;
3078 * Begin scanning the H/W ring for done descriptors when the number
3079 * of available descriptors drops below tx_free_thresh. For each done
3080 * descriptor, free the associated buffer.
3082 if (txq->nb_tx_free < txq->tx_free_thresh)
3083 ice_tx_free_bufs(txq);
3085 /* Use available descriptor only */
3086 nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
3087 if (unlikely(!nb_pkts))
3090 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
3091 if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
3092 n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
3093 ice_tx_fill_hw_ring(txq, tx_pkts, n);
3094 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
3095 rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
3097 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
3101 /* Fill hardware descriptor ring with mbuf data */
3102 ice_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
3103 txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
3105 /* Determin if RS bit needs to be set */
3106 if (txq->tx_tail > txq->tx_next_rs) {
3107 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
3108 rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
3111 (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
3112 if (txq->tx_next_rs >= txq->nb_tx_desc)
3113 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
3116 if (txq->tx_tail >= txq->nb_tx_desc)
3119 /* Update the tx tail register */
3120 ICE_PCI_REG_WC_WRITE(txq->qtx_tail, txq->tx_tail);
3126 ice_xmit_pkts_simple(void *tx_queue,
3127 struct rte_mbuf **tx_pkts,
3132 if (likely(nb_pkts <= ICE_TX_MAX_BURST))
3133 return tx_xmit_pkts((struct ice_tx_queue *)tx_queue,
3137 uint16_t ret, num = (uint16_t)RTE_MIN(nb_pkts,
3140 ret = tx_xmit_pkts((struct ice_tx_queue *)tx_queue,
3141 &tx_pkts[nb_tx], num);
3142 nb_tx = (uint16_t)(nb_tx + ret);
3143 nb_pkts = (uint16_t)(nb_pkts - ret);
3152 ice_set_rx_function(struct rte_eth_dev *dev)
3154 PMD_INIT_FUNC_TRACE();
3155 struct ice_adapter *ad =
3156 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3158 struct ice_rx_queue *rxq;
3160 int rx_check_ret = -1;
3162 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3163 ad->rx_use_avx512 = false;
3164 ad->rx_use_avx2 = false;
3165 rx_check_ret = ice_rx_vec_dev_check(dev);
3168 if (rx_check_ret >= 0 && ad->rx_bulk_alloc_allowed &&
3169 rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
3170 ad->rx_vec_allowed = true;
3171 for (i = 0; i < dev->data->nb_rx_queues; i++) {
3172 rxq = dev->data->rx_queues[i];
3173 if (rxq && ice_rxq_vec_setup(rxq)) {
3174 ad->rx_vec_allowed = false;
3179 if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
3180 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
3181 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
3182 #ifdef CC_AVX512_SUPPORT
3183 ad->rx_use_avx512 = true;
3186 "AVX512 is not supported in build env");
3188 if (!ad->rx_use_avx512 &&
3189 (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
3190 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
3191 rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
3192 ad->rx_use_avx2 = true;
3195 ad->rx_vec_allowed = false;
3199 if (ad->rx_vec_allowed) {
3200 if (dev->data->scattered_rx) {
3201 if (ad->rx_use_avx512) {
3202 #ifdef CC_AVX512_SUPPORT
3203 if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3205 "Using AVX512 OFFLOAD Vector Scattered Rx (port %d).",
3206 dev->data->port_id);
3208 ice_recv_scattered_pkts_vec_avx512_offload;
3211 "Using AVX512 Vector Scattered Rx (port %d).",
3212 dev->data->port_id);
3214 ice_recv_scattered_pkts_vec_avx512;
3217 } else if (ad->rx_use_avx2) {
3218 if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3220 "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).",
3221 dev->data->port_id);
3223 ice_recv_scattered_pkts_vec_avx2_offload;
3226 "Using AVX2 Vector Scattered Rx (port %d).",
3227 dev->data->port_id);
3229 ice_recv_scattered_pkts_vec_avx2;
3233 "Using Vector Scattered Rx (port %d).",
3234 dev->data->port_id);
3235 dev->rx_pkt_burst = ice_recv_scattered_pkts_vec;
3238 if (ad->rx_use_avx512) {
3239 #ifdef CC_AVX512_SUPPORT
3240 if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3242 "Using AVX512 OFFLOAD Vector Rx (port %d).",
3243 dev->data->port_id);
3245 ice_recv_pkts_vec_avx512_offload;
3248 "Using AVX512 Vector Rx (port %d).",
3249 dev->data->port_id);
3251 ice_recv_pkts_vec_avx512;
3254 } else if (ad->rx_use_avx2) {
3255 if (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3257 "Using AVX2 OFFLOAD Vector Rx (port %d).",
3258 dev->data->port_id);
3260 ice_recv_pkts_vec_avx2_offload;
3263 "Using AVX2 Vector Rx (port %d).",
3264 dev->data->port_id);
3266 ice_recv_pkts_vec_avx2;
3270 "Using Vector Rx (port %d).",
3271 dev->data->port_id);
3272 dev->rx_pkt_burst = ice_recv_pkts_vec;
3280 if (dev->data->scattered_rx) {
3281 /* Set the non-LRO scattered function */
3283 "Using a Scattered function on port %d.",
3284 dev->data->port_id);
3285 dev->rx_pkt_burst = ice_recv_scattered_pkts;
3286 } else if (ad->rx_bulk_alloc_allowed) {
3288 "Rx Burst Bulk Alloc Preconditions are "
3289 "satisfied. Rx Burst Bulk Alloc function "
3290 "will be used on port %d.",
3291 dev->data->port_id);
3292 dev->rx_pkt_burst = ice_recv_pkts_bulk_alloc;
3295 "Rx Burst Bulk Alloc Preconditions are not "
3296 "satisfied, Normal Rx will be used on port %d.",
3297 dev->data->port_id);
3298 dev->rx_pkt_burst = ice_recv_pkts;
3302 static const struct {
3303 eth_rx_burst_t pkt_burst;
3305 } ice_rx_burst_infos[] = {
3306 { ice_recv_scattered_pkts, "Scalar Scattered" },
3307 { ice_recv_pkts_bulk_alloc, "Scalar Bulk Alloc" },
3308 { ice_recv_pkts, "Scalar" },
3310 #ifdef CC_AVX512_SUPPORT
3311 { ice_recv_scattered_pkts_vec_avx512, "Vector AVX512 Scattered" },
3312 { ice_recv_scattered_pkts_vec_avx512_offload, "Offload Vector AVX512 Scattered" },
3313 { ice_recv_pkts_vec_avx512, "Vector AVX512" },
3314 { ice_recv_pkts_vec_avx512_offload, "Offload Vector AVX512" },
3316 { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" },
3317 { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" },
3318 { ice_recv_pkts_vec_avx2, "Vector AVX2" },
3319 { ice_recv_pkts_vec_avx2_offload, "Offload Vector AVX2" },
3320 { ice_recv_scattered_pkts_vec, "Vector SSE Scattered" },
3321 { ice_recv_pkts_vec, "Vector SSE" },
3326 ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3327 struct rte_eth_burst_mode *mode)
3329 eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
3333 for (i = 0; i < RTE_DIM(ice_rx_burst_infos); ++i) {
3334 if (pkt_burst == ice_rx_burst_infos[i].pkt_burst) {
3335 snprintf(mode->info, sizeof(mode->info), "%s",
3336 ice_rx_burst_infos[i].info);
3346 ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq)
3348 struct ice_adapter *ad =
3349 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3351 /* Use a simple Tx queue if possible (only fast free is allowed) */
3352 ad->tx_simple_allowed =
3354 (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
3355 txq->tx_rs_thresh >= ICE_TX_MAX_BURST);
3357 if (ad->tx_simple_allowed)
3358 PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
3362 "Simple Tx can NOT be enabled on Tx queue %u.",
3366 /*********************************************************************
3370 **********************************************************************/
3371 /* The default values of TSO MSS */
3372 #define ICE_MIN_TSO_MSS 64
3373 #define ICE_MAX_TSO_MSS 9728
3374 #define ICE_MAX_TSO_FRAME_SIZE 262144
3376 ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
3383 for (i = 0; i < nb_pkts; i++) {
3385 ol_flags = m->ol_flags;
3387 if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
3388 (m->tso_segsz < ICE_MIN_TSO_MSS ||
3389 m->tso_segsz > ICE_MAX_TSO_MSS ||
3390 m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
3392 * MSS outside the range are considered malicious
3398 #ifdef RTE_ETHDEV_DEBUG_TX
3399 ret = rte_validate_tx_offload(m);
3405 ret = rte_net_intel_cksum_prepare(m);
3415 ice_set_tx_function(struct rte_eth_dev *dev)
3417 struct ice_adapter *ad =
3418 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
3420 struct ice_tx_queue *txq;
3422 int tx_check_ret = -1;
3424 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
3425 ad->tx_use_avx2 = false;
3426 ad->tx_use_avx512 = false;
3427 tx_check_ret = ice_tx_vec_dev_check(dev);
3428 if (tx_check_ret >= 0 &&
3429 rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
3430 ad->tx_vec_allowed = true;
3432 if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
3433 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
3434 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
3435 #ifdef CC_AVX512_SUPPORT
3436 ad->tx_use_avx512 = true;
3439 "AVX512 is not supported in build env");
3441 if (!ad->tx_use_avx512 &&
3442 (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
3443 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
3444 rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
3445 ad->tx_use_avx2 = true;
3447 if (!ad->tx_use_avx2 && !ad->tx_use_avx512 &&
3448 tx_check_ret == ICE_VECTOR_OFFLOAD_PATH)
3449 ad->tx_vec_allowed = false;
3451 if (ad->tx_vec_allowed) {
3452 for (i = 0; i < dev->data->nb_tx_queues; i++) {
3453 txq = dev->data->tx_queues[i];
3454 if (txq && ice_txq_vec_setup(txq)) {
3455 ad->tx_vec_allowed = false;
3461 ad->tx_vec_allowed = false;
3465 if (ad->tx_vec_allowed) {
3466 dev->tx_pkt_prepare = NULL;
3467 if (ad->tx_use_avx512) {
3468 #ifdef CC_AVX512_SUPPORT
3469 if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3471 "Using AVX512 OFFLOAD Vector Tx (port %d).",
3472 dev->data->port_id);
3474 ice_xmit_pkts_vec_avx512_offload;
3475 dev->tx_pkt_prepare = ice_prep_pkts;
3478 "Using AVX512 Vector Tx (port %d).",
3479 dev->data->port_id);
3480 dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512;
3484 if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
3486 "Using AVX2 OFFLOAD Vector Tx (port %d).",
3487 dev->data->port_id);
3489 ice_xmit_pkts_vec_avx2_offload;
3490 dev->tx_pkt_prepare = ice_prep_pkts;
3492 PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).",
3493 ad->tx_use_avx2 ? "avx2 " : "",
3494 dev->data->port_id);
3495 dev->tx_pkt_burst = ad->tx_use_avx2 ?
3496 ice_xmit_pkts_vec_avx2 :
3505 if (ad->tx_simple_allowed) {
3506 PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
3507 dev->tx_pkt_burst = ice_xmit_pkts_simple;
3508 dev->tx_pkt_prepare = NULL;
3510 PMD_INIT_LOG(DEBUG, "Normal tx finally be used.");
3511 dev->tx_pkt_burst = ice_xmit_pkts;
3512 dev->tx_pkt_prepare = ice_prep_pkts;
3516 static const struct {
3517 eth_tx_burst_t pkt_burst;
3519 } ice_tx_burst_infos[] = {
3520 { ice_xmit_pkts_simple, "Scalar Simple" },
3521 { ice_xmit_pkts, "Scalar" },
3523 #ifdef CC_AVX512_SUPPORT
3524 { ice_xmit_pkts_vec_avx512, "Vector AVX512" },
3525 { ice_xmit_pkts_vec_avx512_offload, "Offload Vector AVX512" },
3527 { ice_xmit_pkts_vec_avx2, "Vector AVX2" },
3528 { ice_xmit_pkts_vec, "Vector SSE" },
3533 ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
3534 struct rte_eth_burst_mode *mode)
3536 eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
3540 for (i = 0; i < RTE_DIM(ice_tx_burst_infos); ++i) {
3541 if (pkt_burst == ice_tx_burst_infos[i].pkt_burst) {
3542 snprintf(mode->info, sizeof(mode->info), "%s",
3543 ice_tx_burst_infos[i].info);
3552 /* For each value it means, datasheet of hardware can tell more details
3554 * @note: fix ice_dev_supported_ptypes_get() if any change here.
3556 static inline uint32_t
3557 ice_get_default_pkt_type(uint16_t ptype)
3559 static const uint32_t type_table[ICE_MAX_PKT_TYPE]
3560 __rte_cache_aligned = {
3563 [1] = RTE_PTYPE_L2_ETHER,
3564 [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
3565 /* [3] - [5] reserved */
3566 [6] = RTE_PTYPE_L2_ETHER_LLDP,
3567 /* [7] - [10] reserved */
3568 [11] = RTE_PTYPE_L2_ETHER_ARP,
3569 /* [12] - [21] reserved */
3571 /* Non tunneled IPv4 */
3572 [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3574 [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3575 RTE_PTYPE_L4_NONFRAG,
3576 [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3579 [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3581 [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3583 [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3587 [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3588 RTE_PTYPE_TUNNEL_IP |
3589 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3590 RTE_PTYPE_INNER_L4_FRAG,
3591 [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3592 RTE_PTYPE_TUNNEL_IP |
3593 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3594 RTE_PTYPE_INNER_L4_NONFRAG,
3595 [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3596 RTE_PTYPE_TUNNEL_IP |
3597 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3598 RTE_PTYPE_INNER_L4_UDP,
3600 [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3601 RTE_PTYPE_TUNNEL_IP |
3602 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3603 RTE_PTYPE_INNER_L4_TCP,
3604 [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3605 RTE_PTYPE_TUNNEL_IP |
3606 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3607 RTE_PTYPE_INNER_L4_SCTP,
3608 [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3609 RTE_PTYPE_TUNNEL_IP |
3610 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3611 RTE_PTYPE_INNER_L4_ICMP,
3614 [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3615 RTE_PTYPE_TUNNEL_IP |
3616 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3617 RTE_PTYPE_INNER_L4_FRAG,
3618 [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3619 RTE_PTYPE_TUNNEL_IP |
3620 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3621 RTE_PTYPE_INNER_L4_NONFRAG,
3622 [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3623 RTE_PTYPE_TUNNEL_IP |
3624 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3625 RTE_PTYPE_INNER_L4_UDP,
3627 [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3628 RTE_PTYPE_TUNNEL_IP |
3629 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3630 RTE_PTYPE_INNER_L4_TCP,
3631 [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3632 RTE_PTYPE_TUNNEL_IP |
3633 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3634 RTE_PTYPE_INNER_L4_SCTP,
3635 [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3636 RTE_PTYPE_TUNNEL_IP |
3637 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3638 RTE_PTYPE_INNER_L4_ICMP,
3640 /* IPv4 --> GRE/Teredo/VXLAN */
3641 [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3642 RTE_PTYPE_TUNNEL_GRENAT,
3644 /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
3645 [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3646 RTE_PTYPE_TUNNEL_GRENAT |
3647 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3648 RTE_PTYPE_INNER_L4_FRAG,
3649 [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3650 RTE_PTYPE_TUNNEL_GRENAT |
3651 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3652 RTE_PTYPE_INNER_L4_NONFRAG,
3653 [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3654 RTE_PTYPE_TUNNEL_GRENAT |
3655 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3656 RTE_PTYPE_INNER_L4_UDP,
3658 [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3659 RTE_PTYPE_TUNNEL_GRENAT |
3660 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3661 RTE_PTYPE_INNER_L4_TCP,
3662 [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3663 RTE_PTYPE_TUNNEL_GRENAT |
3664 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3665 RTE_PTYPE_INNER_L4_SCTP,
3666 [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3667 RTE_PTYPE_TUNNEL_GRENAT |
3668 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3669 RTE_PTYPE_INNER_L4_ICMP,
3671 /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
3672 [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3673 RTE_PTYPE_TUNNEL_GRENAT |
3674 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3675 RTE_PTYPE_INNER_L4_FRAG,
3676 [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3677 RTE_PTYPE_TUNNEL_GRENAT |
3678 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3679 RTE_PTYPE_INNER_L4_NONFRAG,
3680 [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3681 RTE_PTYPE_TUNNEL_GRENAT |
3682 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3683 RTE_PTYPE_INNER_L4_UDP,
3685 [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3686 RTE_PTYPE_TUNNEL_GRENAT |
3687 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3688 RTE_PTYPE_INNER_L4_TCP,
3689 [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3690 RTE_PTYPE_TUNNEL_GRENAT |
3691 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3692 RTE_PTYPE_INNER_L4_SCTP,
3693 [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3694 RTE_PTYPE_TUNNEL_GRENAT |
3695 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3696 RTE_PTYPE_INNER_L4_ICMP,
3698 /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
3699 [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3700 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
3702 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
3703 [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3704 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3705 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3706 RTE_PTYPE_INNER_L4_FRAG,
3707 [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3708 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3709 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3710 RTE_PTYPE_INNER_L4_NONFRAG,
3711 [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3712 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3713 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3714 RTE_PTYPE_INNER_L4_UDP,
3716 [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3717 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3718 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3719 RTE_PTYPE_INNER_L4_TCP,
3720 [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3721 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3722 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3723 RTE_PTYPE_INNER_L4_SCTP,
3724 [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3725 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3726 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3727 RTE_PTYPE_INNER_L4_ICMP,
3729 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
3730 [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3731 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3732 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3733 RTE_PTYPE_INNER_L4_FRAG,
3734 [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3735 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3736 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3737 RTE_PTYPE_INNER_L4_NONFRAG,
3738 [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3739 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3740 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3741 RTE_PTYPE_INNER_L4_UDP,
3743 [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3744 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3745 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3746 RTE_PTYPE_INNER_L4_TCP,
3747 [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3748 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3749 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3750 RTE_PTYPE_INNER_L4_SCTP,
3751 [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3752 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3753 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3754 RTE_PTYPE_INNER_L4_ICMP,
3755 /* [73] - [87] reserved */
3757 /* Non tunneled IPv6 */
3758 [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3760 [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3761 RTE_PTYPE_L4_NONFRAG,
3762 [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3765 [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3767 [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3769 [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3773 [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3774 RTE_PTYPE_TUNNEL_IP |
3775 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3776 RTE_PTYPE_INNER_L4_FRAG,
3777 [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3778 RTE_PTYPE_TUNNEL_IP |
3779 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3780 RTE_PTYPE_INNER_L4_NONFRAG,
3781 [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3782 RTE_PTYPE_TUNNEL_IP |
3783 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3784 RTE_PTYPE_INNER_L4_UDP,
3786 [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3787 RTE_PTYPE_TUNNEL_IP |
3788 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3789 RTE_PTYPE_INNER_L4_TCP,
3790 [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3791 RTE_PTYPE_TUNNEL_IP |
3792 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3793 RTE_PTYPE_INNER_L4_SCTP,
3794 [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3795 RTE_PTYPE_TUNNEL_IP |
3796 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3797 RTE_PTYPE_INNER_L4_ICMP,
3800 [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3801 RTE_PTYPE_TUNNEL_IP |
3802 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3803 RTE_PTYPE_INNER_L4_FRAG,
3804 [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3805 RTE_PTYPE_TUNNEL_IP |
3806 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3807 RTE_PTYPE_INNER_L4_NONFRAG,
3808 [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3809 RTE_PTYPE_TUNNEL_IP |
3810 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3811 RTE_PTYPE_INNER_L4_UDP,
3812 /* [105] reserved */
3813 [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3814 RTE_PTYPE_TUNNEL_IP |
3815 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3816 RTE_PTYPE_INNER_L4_TCP,
3817 [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3818 RTE_PTYPE_TUNNEL_IP |
3819 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3820 RTE_PTYPE_INNER_L4_SCTP,
3821 [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3822 RTE_PTYPE_TUNNEL_IP |
3823 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3824 RTE_PTYPE_INNER_L4_ICMP,
3826 /* IPv6 --> GRE/Teredo/VXLAN */
3827 [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3828 RTE_PTYPE_TUNNEL_GRENAT,
3830 /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
3831 [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3832 RTE_PTYPE_TUNNEL_GRENAT |
3833 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3834 RTE_PTYPE_INNER_L4_FRAG,
3835 [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3836 RTE_PTYPE_TUNNEL_GRENAT |
3837 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3838 RTE_PTYPE_INNER_L4_NONFRAG,
3839 [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3840 RTE_PTYPE_TUNNEL_GRENAT |
3841 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3842 RTE_PTYPE_INNER_L4_UDP,
3843 /* [113] reserved */
3844 [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3845 RTE_PTYPE_TUNNEL_GRENAT |
3846 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3847 RTE_PTYPE_INNER_L4_TCP,
3848 [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3849 RTE_PTYPE_TUNNEL_GRENAT |
3850 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3851 RTE_PTYPE_INNER_L4_SCTP,
3852 [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3853 RTE_PTYPE_TUNNEL_GRENAT |
3854 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3855 RTE_PTYPE_INNER_L4_ICMP,
3857 /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
3858 [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3859 RTE_PTYPE_TUNNEL_GRENAT |
3860 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3861 RTE_PTYPE_INNER_L4_FRAG,
3862 [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3863 RTE_PTYPE_TUNNEL_GRENAT |
3864 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3865 RTE_PTYPE_INNER_L4_NONFRAG,
3866 [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3867 RTE_PTYPE_TUNNEL_GRENAT |
3868 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3869 RTE_PTYPE_INNER_L4_UDP,
3870 /* [120] reserved */
3871 [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3872 RTE_PTYPE_TUNNEL_GRENAT |
3873 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3874 RTE_PTYPE_INNER_L4_TCP,
3875 [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3876 RTE_PTYPE_TUNNEL_GRENAT |
3877 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3878 RTE_PTYPE_INNER_L4_SCTP,
3879 [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3880 RTE_PTYPE_TUNNEL_GRENAT |
3881 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3882 RTE_PTYPE_INNER_L4_ICMP,
3884 /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
3885 [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3886 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
3888 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
3889 [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3890 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3891 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3892 RTE_PTYPE_INNER_L4_FRAG,
3893 [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3894 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3895 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3896 RTE_PTYPE_INNER_L4_NONFRAG,
3897 [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3898 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3899 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3900 RTE_PTYPE_INNER_L4_UDP,
3901 /* [128] reserved */
3902 [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3903 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3904 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3905 RTE_PTYPE_INNER_L4_TCP,
3906 [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3907 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3908 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3909 RTE_PTYPE_INNER_L4_SCTP,
3910 [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3911 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3912 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
3913 RTE_PTYPE_INNER_L4_ICMP,
3915 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
3916 [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3917 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3918 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3919 RTE_PTYPE_INNER_L4_FRAG,
3920 [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3921 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3922 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3923 RTE_PTYPE_INNER_L4_NONFRAG,
3924 [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3925 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3926 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3927 RTE_PTYPE_INNER_L4_UDP,
3928 /* [135] reserved */
3929 [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3930 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3931 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3932 RTE_PTYPE_INNER_L4_TCP,
3933 [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3934 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3935 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3936 RTE_PTYPE_INNER_L4_SCTP,
3937 [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3938 RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3939 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
3940 RTE_PTYPE_INNER_L4_ICMP,
3941 /* [139] - [299] reserved */
3944 [300] = RTE_PTYPE_L2_ETHER_PPPOE,
3945 [301] = RTE_PTYPE_L2_ETHER_PPPOE,
3947 /* PPPoE --> IPv4 */
3948 [302] = RTE_PTYPE_L2_ETHER_PPPOE |
3949 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3951 [303] = RTE_PTYPE_L2_ETHER_PPPOE |
3952 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3953 RTE_PTYPE_L4_NONFRAG,
3954 [304] = RTE_PTYPE_L2_ETHER_PPPOE |
3955 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3957 [305] = RTE_PTYPE_L2_ETHER_PPPOE |
3958 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3960 [306] = RTE_PTYPE_L2_ETHER_PPPOE |
3961 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3963 [307] = RTE_PTYPE_L2_ETHER_PPPOE |
3964 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3967 /* PPPoE --> IPv6 */
3968 [308] = RTE_PTYPE_L2_ETHER_PPPOE |
3969 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3971 [309] = RTE_PTYPE_L2_ETHER_PPPOE |
3972 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3973 RTE_PTYPE_L4_NONFRAG,
3974 [310] = RTE_PTYPE_L2_ETHER_PPPOE |
3975 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3977 [311] = RTE_PTYPE_L2_ETHER_PPPOE |
3978 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3980 [312] = RTE_PTYPE_L2_ETHER_PPPOE |
3981 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3983 [313] = RTE_PTYPE_L2_ETHER_PPPOE |
3984 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3986 /* [314] - [324] reserved */
3988 /* IPv4/IPv6 --> GTPC/GTPU */
3989 [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3990 RTE_PTYPE_TUNNEL_GTPC,
3991 [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3992 RTE_PTYPE_TUNNEL_GTPC,
3993 [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3994 RTE_PTYPE_TUNNEL_GTPC,
3995 [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
3996 RTE_PTYPE_TUNNEL_GTPC,
3997 [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
3998 RTE_PTYPE_TUNNEL_GTPU,
3999 [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4000 RTE_PTYPE_TUNNEL_GTPU,
4002 /* IPv4 --> GTPU --> IPv4 */
4003 [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4004 RTE_PTYPE_TUNNEL_GTPU |
4005 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4006 RTE_PTYPE_INNER_L4_FRAG,
4007 [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4008 RTE_PTYPE_TUNNEL_GTPU |
4009 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4010 RTE_PTYPE_INNER_L4_NONFRAG,
4011 [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4012 RTE_PTYPE_TUNNEL_GTPU |
4013 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4014 RTE_PTYPE_INNER_L4_UDP,
4015 [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4016 RTE_PTYPE_TUNNEL_GTPU |
4017 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4018 RTE_PTYPE_INNER_L4_TCP,
4019 [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4020 RTE_PTYPE_TUNNEL_GTPU |
4021 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4022 RTE_PTYPE_INNER_L4_ICMP,
4024 /* IPv6 --> GTPU --> IPv4 */
4025 [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4026 RTE_PTYPE_TUNNEL_GTPU |
4027 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4028 RTE_PTYPE_INNER_L4_FRAG,
4029 [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4030 RTE_PTYPE_TUNNEL_GTPU |
4031 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4032 RTE_PTYPE_INNER_L4_NONFRAG,
4033 [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4034 RTE_PTYPE_TUNNEL_GTPU |
4035 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4036 RTE_PTYPE_INNER_L4_UDP,
4037 [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4038 RTE_PTYPE_TUNNEL_GTPU |
4039 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4040 RTE_PTYPE_INNER_L4_TCP,
4041 [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4042 RTE_PTYPE_TUNNEL_GTPU |
4043 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
4044 RTE_PTYPE_INNER_L4_ICMP,
4046 /* IPv4 --> GTPU --> IPv6 */
4047 [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4048 RTE_PTYPE_TUNNEL_GTPU |
4049 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4050 RTE_PTYPE_INNER_L4_FRAG,
4051 [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4052 RTE_PTYPE_TUNNEL_GTPU |
4053 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4054 RTE_PTYPE_INNER_L4_NONFRAG,
4055 [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4056 RTE_PTYPE_TUNNEL_GTPU |
4057 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4058 RTE_PTYPE_INNER_L4_UDP,
4059 [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4060 RTE_PTYPE_TUNNEL_GTPU |
4061 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4062 RTE_PTYPE_INNER_L4_TCP,
4063 [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4064 RTE_PTYPE_TUNNEL_GTPU |
4065 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4066 RTE_PTYPE_INNER_L4_ICMP,
4068 /* IPv6 --> GTPU --> IPv6 */
4069 [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4070 RTE_PTYPE_TUNNEL_GTPU |
4071 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4072 RTE_PTYPE_INNER_L4_FRAG,
4073 [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4074 RTE_PTYPE_TUNNEL_GTPU |
4075 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4076 RTE_PTYPE_INNER_L4_NONFRAG,
4077 [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4078 RTE_PTYPE_TUNNEL_GTPU |
4079 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4080 RTE_PTYPE_INNER_L4_UDP,
4081 [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4082 RTE_PTYPE_TUNNEL_GTPU |
4083 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4084 RTE_PTYPE_INNER_L4_TCP,
4085 [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4086 RTE_PTYPE_TUNNEL_GTPU |
4087 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
4088 RTE_PTYPE_INNER_L4_ICMP,
4090 /* IPv4 --> UDP ECPRI */
4091 [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4093 [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4095 [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4097 [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4099 [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4101 [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4103 [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4105 [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4107 [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4109 [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
4112 /* IPV6 --> UDP ECPRI */
4113 [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4115 [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4117 [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4119 [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4121 [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4123 [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4125 [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4127 [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4129 [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4131 [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
4133 /* All others reserved */
4136 return type_table[ptype];
4140 ice_set_default_ptype_table(struct rte_eth_dev *dev)
4142 struct ice_adapter *ad =
4143 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
4146 for (i = 0; i < ICE_MAX_PKT_TYPE; i++)
4147 ad->ptype_tbl[i] = ice_get_default_pkt_type(i);
4150 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S 1
4151 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M \
4152 (0x3UL << ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S)
4153 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD 0
4154 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL 0x1
4156 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S 4
4157 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M \
4158 (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S)
4159 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S 5
4160 #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M \
4161 (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S)
4164 * check the programming status descriptor in rx queue.
4165 * done after Programming Flow Director is programmed on
4169 ice_check_fdir_programming_status(struct ice_rx_queue *rxq)
4171 volatile union ice_32byte_rx_desc *rxdp;
4178 rxdp = (volatile union ice_32byte_rx_desc *)
4179 (&rxq->rx_ring[rxq->rx_tail]);
4180 qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
4181 rx_status = (qword1 & ICE_RXD_QW1_STATUS_M)
4182 >> ICE_RXD_QW1_STATUS_S;
4184 if (rx_status & (1 << ICE_RX_DESC_STATUS_DD_S)) {
4186 error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M) >>
4187 ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S;
4188 id = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M) >>
4189 ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S;
4191 if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD)
4192 PMD_DRV_LOG(ERR, "Failed to add FDIR rule.");
4193 else if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL)
4194 PMD_DRV_LOG(ERR, "Failed to remove FDIR rule.");
4198 error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M) >>
4199 ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S;
4201 PMD_DRV_LOG(ERR, "Failed to create FDIR profile.");
4205 rxdp->wb.qword1.status_error_len = 0;
4207 if (unlikely(rxq->rx_tail == rxq->nb_rx_desc))
4209 if (rxq->rx_tail == 0)
4210 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
4212 ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_tail - 1);
4218 #define ICE_FDIR_MAX_WAIT_US 10000
4221 ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
4223 struct ice_tx_queue *txq = pf->fdir.txq;
4224 struct ice_rx_queue *rxq = pf->fdir.rxq;
4225 volatile struct ice_fltr_desc *fdirdp;
4226 volatile struct ice_tx_desc *txdp;
4230 fdirdp = (volatile struct ice_fltr_desc *)
4231 (&txq->tx_ring[txq->tx_tail]);
4232 fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
4233 fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
4235 txdp = &txq->tx_ring[txq->tx_tail + 1];
4236 txdp->buf_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
4237 td_cmd = ICE_TX_DESC_CMD_EOP |
4238 ICE_TX_DESC_CMD_RS |
4239 ICE_TX_DESC_CMD_DUMMY;
4241 txdp->cmd_type_offset_bsz =
4242 ice_build_ctob(td_cmd, 0, ICE_FDIR_PKT_LEN, 0);
4245 if (txq->tx_tail >= txq->nb_tx_desc)
4247 /* Update the tx tail register */
4248 ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
4249 for (i = 0; i < ICE_FDIR_MAX_WAIT_US; i++) {
4250 if ((txdp->cmd_type_offset_bsz &
4251 rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) ==
4252 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
4256 if (i >= ICE_FDIR_MAX_WAIT_US) {
4258 "Failed to program FDIR filter: time out to get DD on tx queue.");
4262 for (; i < ICE_FDIR_MAX_WAIT_US; i++) {
4265 ret = ice_check_fdir_programming_status(rxq);
4273 "Failed to program FDIR filter: programming status reported.");