ethdev: separate driver APIs
[dpdk.git] / drivers / net / i40e / i40e_rxtx.c
index a35a9d3..1217e5a 100644 (file)
@@ -17,7 +17,7 @@
 #include <rte_mbuf.h>
 #include <rte_malloc.h>
 #include <rte_ether.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_tcp.h>
 #include <rte_sctp.h>
 #include <rte_udp.h>
@@ -1685,7 +1685,9 @@ i40e_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 #endif
            dev->rx_pkt_burst == i40e_recv_scattered_pkts ||
            dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
-           dev->rx_pkt_burst == i40e_recv_pkts_vec)
+           dev->rx_pkt_burst == i40e_recv_pkts_vec ||
+           dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
+           dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2)
                return ptypes;
        return NULL;
 }
@@ -2283,7 +2285,8 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)
         *  vPMD tx will not set sw_ring's mbuf to NULL after free,
         *  so need to free remains more carefully.
         */
-       if (dev->tx_pkt_burst == i40e_xmit_pkts_vec) {
+       if (dev->tx_pkt_burst == i40e_xmit_pkts_vec_avx2 ||
+                       dev->tx_pkt_burst == i40e_xmit_pkts_vec) {
                i = txq->tx_next_dd - txq->tx_rs_thresh + 1;
                if (txq->tx_tail < i) {
                        for (; i < txq->nb_tx_desc; i++) {
@@ -2716,6 +2719,7 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
        rxq->vsi = pf->fdir.fdir_vsi;
 
        rxq->rx_ring_phys_addr = rz->iova;
+       memset(rz->addr, 0, I40E_FDIR_NUM_RX_DESC * sizeof(union i40e_rx_desc));
        rxq->rx_ring = (union i40e_rx_desc *)rz->addr;
 
        /*
@@ -2806,6 +2810,17 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
                                     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).",
@@ -2825,6 +2840,16 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
                             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) {
                PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
                                    "satisfied. Rx Burst Bulk Alloc function "
@@ -2845,7 +2870,9 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                rx_using_sse =
                        (dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec ||
-                        dev->rx_pkt_burst == i40e_recv_pkts_vec);
+                        dev->rx_pkt_burst == i40e_recv_pkts_vec ||
+                        dev->rx_pkt_burst == i40e_recv_scattered_pkts_vec_avx2 ||
+                        dev->rx_pkt_burst == i40e_recv_pkts_vec_avx2);
 
                for (i = 0; i < dev->data->nb_rx_queues; i++) {
                        struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
@@ -2902,6 +2929,16 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
                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
                } else {
                        PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
                        dev->tx_pkt_burst = i40e_xmit_pkts_simple;
@@ -3008,6 +3045,22 @@ i40e_recv_scattered_pkts_vec(
        return 0;
 }
 
+uint16_t __attribute__((weak))
+i40e_recv_pkts_vec_avx2(void __rte_unused *rx_queue,
+                       struct rte_mbuf __rte_unused **rx_pkts,
+                       uint16_t __rte_unused nb_pkts)
+{
+       return 0;
+}
+
+uint16_t __attribute__((weak))
+i40e_recv_scattered_pkts_vec_avx2(void __rte_unused *rx_queue,
+                       struct rte_mbuf __rte_unused **rx_pkts,
+                       uint16_t __rte_unused nb_pkts)
+{
+       return 0;
+}
+
 int __attribute__((weak))
 i40e_rxq_vec_setup(struct i40e_rx_queue __rte_unused *rxq)
 {
@@ -3033,3 +3086,11 @@ i40e_xmit_fixed_burst_vec(void __rte_unused * tx_queue,
 {
        return 0;
 }
+
+uint16_t __attribute__((weak))
+i40e_xmit_pkts_vec_avx2(void __rte_unused * tx_queue,
+                         struct rte_mbuf __rte_unused **tx_pkts,
+                         uint16_t __rte_unused nb_pkts)
+{
+       return 0;
+}