app/procinfo: add --show-mempool
[dpdk.git] / drivers / net / i40e / i40e_rxtx.c
index ec1ce54..8f727fa 100644 (file)
@@ -40,9 +40,6 @@
 /* Base address of the HW descriptor ring should be 128B aligned. */
 #define I40E_RING_BASE_ALIGN   128
 
-#define I40E_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
-                                       ETH_TXQ_FLAGS_NOOFFLOADS)
-
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
 #ifdef RTE_LIBRTE_IEEE1588
                PKT_TX_OUTER_IP_CKSUM)
 
 #define I40E_TX_OFFLOAD_MASK (  \
+               PKT_TX_OUTER_IPV4 |     \
+               PKT_TX_OUTER_IPV6 |     \
+               PKT_TX_IPV4 |           \
+               PKT_TX_IPV6 |           \
                PKT_TX_IP_CKSUM |       \
                PKT_TX_L4_MASK |        \
                PKT_TX_OUTER_IP_CKSUM | \
@@ -86,7 +87,8 @@ i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
 #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
        if (rte_le_to_cpu_16(rxdp->wb.qword2.ext_status) &
                (1 << I40E_RX_DESC_EXT_STATUS_L2TAG2P_SHIFT)) {
-               mb->ol_flags |= PKT_RX_QINQ_STRIPPED;
+               mb->ol_flags |= PKT_RX_QINQ_STRIPPED | PKT_RX_QINQ |
+                       PKT_RX_VLAN_STRIPPED | PKT_RX_VLAN;
                mb->vlan_tci_outer = mb->vlan_tci;
                mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.qword2.l2tag2_2);
                PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
@@ -1240,7 +1242,7 @@ i40e_tx_free_bufs(struct i40e_tx_queue *txq)
        for (i = 0; i < txq->tx_rs_thresh; i++)
                rte_prefetch0((txep + i)->mbuf);
 
-       if (txq->txq_flags & (uint32_t)ETH_TXQ_FLAGS_NOREFCOUNT) {
+       if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE) {
                for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
                        rte_mempool_put(txep->mbuf->pool, txep->mbuf);
                        txep->mbuf = NULL;
@@ -1442,13 +1444,15 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 
                /* Check for m->nb_segs to not exceed the limits. */
                if (!(ol_flags & PKT_TX_TCP_SEG)) {
-                       if (m->nb_segs > I40E_TX_MAX_SEG ||
-                           m->nb_segs > I40E_TX_MAX_MTU_SEG) {
+                       if (m->nb_segs > I40E_TX_MAX_MTU_SEG ||
+                           m->pkt_len > I40E_FRAME_SIZE_MAX) {
                                rte_errno = -EINVAL;
                                return i;
                        }
-               } else if ((m->tso_segsz < I40E_MIN_TSO_MSS) ||
-                               (m->tso_segsz > I40E_MAX_TSO_MSS)) {
+               } else if (m->nb_segs > I40E_TX_MAX_SEG ||
+                          m->tso_segsz < I40E_MIN_TSO_MSS ||
+                          m->tso_segsz > I40E_MAX_TSO_MSS ||
+                          m->pkt_len > I40E_TSO_FRAME_SIZE_MAX) {
                        /* MSS outside the range (256B - 9674B) are considered
                         * malicious
                         */
@@ -1461,6 +1465,12 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
                        return i;
                }
 
+               /* check the size of packet */
+               if (m->pkt_len < I40E_TX_MIN_PKT_LEN) {
+                       rte_errno = -EINVAL;
+                       return i;
+               }
+
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
                ret = rte_validate_tx_offload(m);
                if (ret != 0) {
@@ -1527,38 +1537,36 @@ int
 i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
        struct i40e_rx_queue *rxq;
-       int err = -1;
+       int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        PMD_INIT_FUNC_TRACE();
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
-
-               err = i40e_alloc_rx_queue_mbufs(rxq);
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
-                       return err;
-               }
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               rte_wmb();
+       err = i40e_alloc_rx_queue_mbufs(rxq);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+               return err;
+       }
 
-               /* Init the RX tail regieter. */
-               I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+       rte_wmb();
 
-               err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE);
+       /* Init the RX tail regieter. */
+       I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
 
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
-                                   rx_queue_id);
+       err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
+                           rx_queue_id);
 
-                       i40e_rx_queue_release_mbufs(rxq);
-                       i40e_reset_rx_queue(rxq);
-               } else
-                       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+               i40e_rx_queue_release_mbufs(rxq);
+               i40e_reset_rx_queue(rxq);
+               return err;
        }
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 int
@@ -1568,24 +1576,21 @@ i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
-
-               /*
-               * rx_queue_id is queue id application refers to, while
-               * rxq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
-                                   rx_queue_id);
-                       return err;
-               }
-               i40e_rx_queue_release_mbufs(rxq);
-               i40e_reset_rx_queue(rxq);
-               dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       /*
+        * rx_queue_id is queue id application refers to, while
+        * rxq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
+                           rx_queue_id);
+               return err;
        }
+       i40e_rx_queue_release_mbufs(rxq);
+       i40e_reset_rx_queue(rxq);
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
 
        return 0;
 }
@@ -1593,28 +1598,27 @@ i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 int
 i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
-       int err = -1;
+       int err;
        struct i40e_tx_queue *txq;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        PMD_INIT_FUNC_TRACE();
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-               txq = dev->data->tx_queues[tx_queue_id];
-
-               /*
-               * tx_queue_id is queue id application refers to, while
-               * rxq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
-               if (err)
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
-                                   tx_queue_id);
-               else
-                       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+       txq = dev->data->tx_queues[tx_queue_id];
+
+       /*
+        * tx_queue_id is queue id application refers to, while
+        * rxq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
+                           tx_queue_id);
+               return err;
        }
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 int
@@ -1624,26 +1628,23 @@ i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
        int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-               txq = dev->data->tx_queues[tx_queue_id];
+       txq = dev->data->tx_queues[tx_queue_id];
 
-               /*
-               * tx_queue_id is queue id application refers to, while
-               * txq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
-
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
-                                   tx_queue_id);
-                       return err;
-               }
-
-               i40e_tx_queue_release_mbufs(txq);
-               i40e_reset_tx_queue(txq);
-               dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       /*
+        * tx_queue_id is queue id application refers to, while
+        * txq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
+                           tx_queue_id);
+               return err;
        }
 
+       i40e_tx_queue_release_mbufs(txq);
+       i40e_reset_tx_queue(txq);
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
        return 0;
 }
 
@@ -1692,20 +1693,6 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
        return NULL;
 }
 
-static int
-i40e_check_rx_queue_offloads(struct rte_eth_dev *dev, uint64_t requested)
-{
-       struct rte_eth_dev_info dev_info;
-       uint64_t mandatory = dev->data->dev_conf.rxmode.offloads;
-       uint64_t supported; /* All per port offloads */
-
-       dev->dev_ops->dev_infos_get(dev, &dev_info);
-       supported = dev_info.rx_offload_capa ^ dev_info.rx_queue_offload_capa;
-       if ((requested & dev_info.rx_offload_capa) != requested)
-               return 0; /* requested range check */
-       return !((mandatory ^ requested) & supported);
-}
-
 static int
 i40e_dev_first_queue(uint16_t idx, void **queues, int num)
 {
@@ -1754,6 +1741,11 @@ i40e_dev_rx_queue_setup_runtime(struct rte_eth_dev *dev,
                        ad->rx_bulk_alloc_allowed = false;
                i40e_set_rx_function(dev);
                return 0;
+       } else if (ad->rx_vec_allowed && !rte_is_power_of_2(rxq->nb_rx_desc)) {
+               PMD_DRV_LOG(ERR, "Vector mode is allowed, but descriptor"
+                           " number %d of queue %d isn't power of 2",
+                           rxq->nb_rx_desc, rxq->queue_id);
+               return -EINVAL;
        }
 
        /* check bulk alloc conflict */
@@ -1795,18 +1787,9 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
        uint16_t len, i;
        uint16_t reg_idx, base, bsf, tc_mapping;
        int q_offset, use_def_burst_func = 1;
-       struct rte_eth_dev_info dev_info;
+       uint64_t offloads;
 
-       if (!i40e_check_rx_queue_offloads(dev, rx_conf->offloads)) {
-               dev->dev_ops->dev_infos_get(dev, &dev_info);
-               PMD_INIT_LOG(ERR, "%p: Rx queue offloads 0x%" PRIx64
-                       " don't match port  offloads 0x%" PRIx64
-                       " or supported offloads 0x%" PRIx64,
-                       (void *)dev, rx_conf->offloads,
-                       dev->data->dev_conf.rxmode.offloads,
-                       dev_info.rx_offload_capa);
-               return -ENOTSUP;
-       }
+       offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 
        if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
                vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -1855,11 +1838,14 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
        rxq->queue_id = queue_idx;
        rxq->reg_idx = reg_idx;
        rxq->port_id = dev->data->port_id;
-       rxq->crc_len = (uint8_t)((dev->data->dev_conf.rxmode.offloads &
-                       DEV_RX_OFFLOAD_CRC_STRIP) ? 0 : ETHER_CRC_LEN);
+       if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC)
+               rxq->crc_len = ETHER_CRC_LEN;
+       else
+               rxq->crc_len = 0;
        rxq->drop_en = rx_conf->rx_drop_en;
        rxq->vsi = vsi;
        rxq->rx_deferred_start = rx_conf->rx_deferred_start;
+       rxq->offloads = offloads;
 
        /* Allocate the maximun number of RX ring hardware descriptor. */
        len = I40E_MAX_RING_DESC;
@@ -2076,20 +2062,6 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
        return RTE_ETH_TX_DESC_FULL;
 }
 
-static int
-i40e_check_tx_queue_offloads(struct rte_eth_dev *dev, uint64_t requested)
-{
-       struct rte_eth_dev_info dev_info;
-       uint64_t mandatory = dev->data->dev_conf.txmode.offloads;
-       uint64_t supported; /* All per port offloads */
-
-       dev->dev_ops->dev_infos_get(dev, &dev_info);
-       supported = dev_info.tx_offload_capa ^ dev_info.tx_queue_offload_capa;
-       if ((requested & dev_info.tx_offload_capa) != requested)
-               return 0; /* requested range check */
-       return !((mandatory ^ requested) & supported);
-}
-
 static int
 i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
                                struct i40e_tx_queue *txq)
@@ -2108,11 +2080,9 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
                                 dev->data->nb_tx_queues)) {
                /**
                 * If it is the first queue to setup,
-                * set all flags to default and call
+                * set all flags and call
                 * i40e_set_tx_function.
                 */
-               ad->tx_simple_allowed = true;
-               ad->tx_vec_allowed = true;
                i40e_set_tx_function_flag(dev, txq);
                i40e_set_tx_function(dev);
                return 0;
@@ -2128,9 +2098,8 @@ i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev,
        }
        /* check simple tx conflict */
        if (ad->tx_simple_allowed) {
-               if (((txq->txq_flags & I40E_SIMPLE_FLAGS) !=
-                    I40E_SIMPLE_FLAGS) ||
-                   txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
+               if ((txq->offloads & ~DEV_TX_OFFLOAD_MBUF_FAST_FREE) != 0 ||
+                               txq->tx_rs_thresh < RTE_PMD_I40E_TX_MAX_BURST) {
                        PMD_DRV_LOG(ERR, "No-simple tx is required.");
                        return -EINVAL;
                }
@@ -2156,18 +2125,9 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
        uint16_t tx_rs_thresh, tx_free_thresh;
        uint16_t reg_idx, i, base, bsf, tc_mapping;
        int q_offset;
-       struct rte_eth_dev_info dev_info;
+       uint64_t offloads;
 
-       if (!i40e_check_tx_queue_offloads(dev, tx_conf->offloads)) {
-               dev->dev_ops->dev_infos_get(dev, &dev_info);
-               PMD_INIT_LOG(ERR, "%p: Tx queue offloads 0x%" PRIx64
-                       " don't match port  offloads 0x%" PRIx64
-                       " or supported offloads 0x%" PRIx64,
-                       (void *)dev, tx_conf->offloads,
-                       dev->data->dev_conf.txmode.offloads,
-                       dev_info.tx_offload_capa);
-                       return -ENOTSUP;
-       }
+       offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
 
        if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
                vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
@@ -2302,7 +2262,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
        txq->queue_id = queue_idx;
        txq->reg_idx = reg_idx;
        txq->port_id = dev->data->port_id;
-       txq->txq_flags = tx_conf->txq_flags;
+       txq->offloads = offloads;
        txq->vsi = vsi;
        txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
@@ -2793,7 +2753,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
                i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
                dev->data->rx_queues[i] = NULL;
        }
-       dev->data->nb_rx_queues = 0;
 
        for (i = 0; i < dev->data->nb_tx_queues; i++) {
                if (!dev->data->tx_queues[i])
@@ -2801,7 +2760,6 @@ i40e_dev_free_queues(struct rte_eth_dev *dev)
                i40e_dev_tx_queue_release(dev->data->tx_queues[i]);
                dev->data->tx_queues[i] = NULL;
        }
-       dev->data->nb_tx_queues = 0;
 }
 
 #define I40E_FDIR_NUM_TX_DESC  I40E_MIN_RING_DESC
@@ -2955,8 +2913,37 @@ i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 
        qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
        qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
-       qinfo->conf.txq_flags = txq->txq_flags;
        qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
+       qinfo->conf.offloads = txq->offloads;
+}
+
+static eth_rx_burst_t
+i40e_get_latest_rx_vec(bool scatter)
+{
+#ifdef RTE_ARCH_X86
+       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+               return scatter ? i40e_recv_scattered_pkts_vec_avx2 :
+                                i40e_recv_pkts_vec_avx2;
+#endif
+       return scatter ? i40e_recv_scattered_pkts_vec :
+                        i40e_recv_pkts_vec;
+}
+
+static eth_rx_burst_t
+i40e_get_recommend_rx_vec(bool scatter)
+{
+#ifdef RTE_ARCH_X86
+       /*
+        * since AVX frequency can be different to base frequency, limit
+        * use of AVX2 version to later plaforms, not all those that could
+        * theoretically run it.
+        */
+       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+               return scatter ? i40e_recv_scattered_pkts_vec_avx2 :
+                                i40e_recv_pkts_vec_avx2;
+#endif
+       return scatter ? i40e_recv_scattered_pkts_vec :
+                        i40e_recv_pkts_vec;
 }
 
 void __attribute__((cold))
@@ -2990,57 +2977,17 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
                }
        }
 
-       if (dev->data->scattered_rx) {
-               /* Set the non-LRO scattered callback: there are Vector and
-                * single allocation versions.
-                */
-               if (ad->rx_vec_allowed) {
-                       PMD_INIT_LOG(DEBUG, "Using Vector Scattered Rx "
-                                           "callback (port=%d).",
-                                    dev->data->port_id);
-
-                       dev->rx_pkt_burst = i40e_recv_scattered_pkts_vec;
-#ifdef RTE_ARCH_X86
-                       /*
-                        * since AVX frequency can be different to base
-                        * frequency, limit use of AVX2 version to later
-                        * plaforms, not all those that could theoretically
-                        * run it.
-                        */
-                       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
-                               dev->rx_pkt_burst =
-                                       i40e_recv_scattered_pkts_vec_avx2;
-#endif
-               } else {
-                       PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
-                                          "allocation callback (port=%d).",
-                                    dev->data->port_id);
-                       dev->rx_pkt_burst = i40e_recv_scattered_pkts;
-               }
-       /* If parameters allow we are going to choose between the following
-        * callbacks:
-        *    - Vector
-        *    - Bulk Allocation
-        *    - Single buffer allocation (the simplest one)
-        */
-       } else if (ad->rx_vec_allowed) {
-               PMD_INIT_LOG(DEBUG, "Vector rx enabled, please make sure RX "
-                                   "burst size no less than %d (port=%d).",
-                            RTE_I40E_DESCS_PER_LOOP,
-                            dev->data->port_id);
-
-               dev->rx_pkt_burst = i40e_recv_pkts_vec;
-#ifdef RTE_ARCH_X86
-               /*
-                * since AVX frequency can be different to base
-                * frequency, limit use of AVX2 version to later
-                * plaforms, not all those that could theoretically
-                * run it.
-                */
-               if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
-                       dev->rx_pkt_burst = i40e_recv_pkts_vec_avx2;
-#endif
-       } else if (ad->rx_bulk_alloc_allowed) {
+       if (ad->rx_vec_allowed) {
+               /* Vec Rx path */
+               PMD_INIT_LOG(DEBUG, "Vector Rx path will be used on port=%d.",
+                               dev->data->port_id);
+               if (ad->use_latest_vec)
+                       dev->rx_pkt_burst =
+                       i40e_get_latest_rx_vec(dev->data->scattered_rx);
+               else
+                       dev->rx_pkt_burst =
+                       i40e_get_recommend_rx_vec(dev->data->scattered_rx);
+       } else if (!dev->data->scattered_rx && ad->rx_bulk_alloc_allowed) {
                PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
                                    "satisfied. Rx Burst Bulk Alloc function "
                                    "will be used on port=%d.",
@@ -3048,12 +2995,12 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 
                dev->rx_pkt_burst = i40e_recv_pkts_bulk_alloc;
        } else {
-               PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are not "
-                                   "satisfied, or Scattered Rx is requested "
-                                   "(port=%d).",
+               /* Simple Rx Path. */
+               PMD_INIT_LOG(DEBUG, "Simple Rx path will be used on port=%d.",
                             dev->data->port_id);
-
-               dev->rx_pkt_burst = i40e_recv_pkts;
+               dev->rx_pkt_burst = dev->data->scattered_rx ?
+                                       i40e_recv_scattered_pkts :
+                                       i40e_recv_pkts;
        }
 
        /* Propagate information about RX function choice through all queues. */
@@ -3079,19 +3026,49 @@ i40e_set_tx_function_flag(struct rte_eth_dev *dev, struct i40e_tx_queue *txq)
        struct i40e_adapter *ad =
                I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
-       /* Use a simple Tx queue (no offloads, no multi segs) if possible */
-       if (((txq->txq_flags & I40E_SIMPLE_FLAGS) == I40E_SIMPLE_FLAGS)
-                       && (txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST)) {
-               if (txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ) {
-                       PMD_INIT_LOG(DEBUG, "Vector tx"
-                                    " can be enabled on this txq.");
+       /* Use a simple Tx queue if possible (only fast free is allowed) */
+       ad->tx_simple_allowed =
+               (txq->offloads ==
+                (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE) &&
+                txq->tx_rs_thresh >= RTE_PMD_I40E_TX_MAX_BURST);
+       ad->tx_vec_allowed = (ad->tx_simple_allowed &&
+                       txq->tx_rs_thresh <= RTE_I40E_TX_MAX_FREE_BUF_SZ);
+
+       if (ad->tx_vec_allowed)
+               PMD_INIT_LOG(DEBUG, "Vector Tx can be enabled on Tx queue %u.",
+                               txq->queue_id);
+       else if (ad->tx_simple_allowed)
+               PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
+                               txq->queue_id);
+       else
+               PMD_INIT_LOG(DEBUG,
+                               "Neither simple nor vector Tx enabled on Tx queue %u\n",
+                               txq->queue_id);
+}
 
-               } else {
-                       ad->tx_vec_allowed = false;
-               }
-       } else {
-               ad->tx_simple_allowed = false;
-       }
+static eth_tx_burst_t
+i40e_get_latest_tx_vec(void)
+{
+#ifdef RTE_ARCH_X86
+       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+               return i40e_xmit_pkts_vec_avx2;
+#endif
+       return i40e_xmit_pkts_vec;
+}
+
+static eth_tx_burst_t
+i40e_get_recommend_tx_vec(void)
+{
+#ifdef RTE_ARCH_X86
+       /*
+        * since AVX frequency can be different to base frequency, limit
+        * use of AVX2 version to later plaforms, not all those that could
+        * theoretically run it.
+        */
+       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
+               return i40e_xmit_pkts_vec_avx2;
+#endif
+       return i40e_xmit_pkts_vec;
 }
 
 void __attribute__((cold))
@@ -3118,17 +3095,12 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
        if (ad->tx_simple_allowed) {
                if (ad->tx_vec_allowed) {
                        PMD_INIT_LOG(DEBUG, "Vector tx finally be used.");
-                       dev->tx_pkt_burst = i40e_xmit_pkts_vec;
-#ifdef RTE_ARCH_X86
-                       /*
-                        * since AVX frequency can be different to base
-                        * frequency, limit use of AVX2 version to later
-                        * plaforms, not all those that could theoretically
-                        * run it.
-                        */
-                       if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
-                               dev->tx_pkt_burst = i40e_xmit_pkts_vec_avx2;
-#endif
+                       if (ad->use_latest_vec)
+                               dev->tx_pkt_burst =
+                                       i40e_get_latest_tx_vec();
+                       else
+                               dev->tx_pkt_burst =
+                                       i40e_get_recommend_tx_vec();
                } else {
                        PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
                        dev->tx_pkt_burst = i40e_xmit_pkts_simple;
@@ -3210,14 +3182,14 @@ i40e_set_default_pctype_table(struct rte_eth_dev *dev)
        }
 }
 
-/* Stubs needed for linkage when CONFIG_RTE_I40E_INC_VECTOR is set to 'n' */
-int __attribute__((weak))
+/* Stubs needed for linkage when CONFIG_RTE_LIBRTE_I40E_INC_VECTOR is set to 'n' */
+__rte_weak int
 i40e_rx_vec_dev_conf_condition_check(struct rte_eth_dev __rte_unused *dev)
 {
        return -1;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_recv_pkts_vec(
        void __rte_unused *rx_queue,
        struct rte_mbuf __rte_unused **rx_pkts,
@@ -3226,7 +3198,7 @@ i40e_recv_pkts_vec(
        return 0;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_recv_scattered_pkts_vec(
        void __rte_unused *rx_queue,
        struct rte_mbuf __rte_unused **rx_pkts,
@@ -3235,7 +3207,7 @@ i40e_recv_scattered_pkts_vec(
        return 0;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_recv_pkts_vec_avx2(void __rte_unused *rx_queue,
                        struct rte_mbuf __rte_unused **rx_pkts,
                        uint16_t __rte_unused nb_pkts)
@@ -3243,7 +3215,7 @@ i40e_recv_pkts_vec_avx2(void __rte_unused *rx_queue,
        return 0;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_recv_scattered_pkts_vec_avx2(void __rte_unused *rx_queue,
                        struct rte_mbuf __rte_unused **rx_pkts,
                        uint16_t __rte_unused nb_pkts)
@@ -3251,25 +3223,25 @@ i40e_recv_scattered_pkts_vec_avx2(void __rte_unused *rx_queue,
        return 0;
 }
 
-int __attribute__((weak))
+__rte_weak int
 i40e_rxq_vec_setup(struct i40e_rx_queue __rte_unused *rxq)
 {
        return -1;
 }
 
-int __attribute__((weak))
+__rte_weak int
 i40e_txq_vec_setup(struct i40e_tx_queue __rte_unused *txq)
 {
        return -1;
 }
 
-void __attribute__((weak))
+__rte_weak void
 i40e_rx_queue_release_mbufs_vec(struct i40e_rx_queue __rte_unused*rxq)
 {
        return;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_xmit_fixed_burst_vec(void __rte_unused * tx_queue,
                          struct rte_mbuf __rte_unused **tx_pkts,
                          uint16_t __rte_unused nb_pkts)
@@ -3277,7 +3249,7 @@ i40e_xmit_fixed_burst_vec(void __rte_unused * tx_queue,
        return 0;
 }
 
-uint16_t __attribute__((weak))
+__rte_weak uint16_t
 i40e_xmit_pkts_vec_avx2(void __rte_unused * tx_queue,
                          struct rte_mbuf __rte_unused **tx_pkts,
                          uint16_t __rte_unused nb_pkts)