net/af_xdp: fix zero-copy Tx queue drain
[dpdk.git] / examples / l2fwd-event / l2fwd_common.c
index 0c069ec..b8c1e02 100644 (file)
@@ -1,3 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2019 Marvell International Ltd.
+ */
+
 #include "l2fwd_common.h"
 
 int
@@ -46,13 +50,26 @@ l2fwd_event_init_ports(struct l2fwd_resources *rsrc)
                if (ret != 0)
                        rte_panic("Error during getting device (port %u) info: %s\n",
                                  port_id, strerror(-ret));
+               local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
+               if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+                               port_conf.rx_adv_conf.rss_conf.rss_hf) {
+                       printf("Port %u modified RSS hash function based on hardware support,"
+                              "requested:%#"PRIx64" configured:%#"PRIx64"",
+                               port_id,
+                               port_conf.rx_adv_conf.rss_conf.rss_hf,
+                               local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+               }
+
                if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                        local_port_conf.txmode.offloads |=
                                DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+               /* Configure RX and TX queue. 8< */
                ret = rte_eth_dev_configure(port_id, 1, 1, &local_port_conf);
                if (ret < 0)
                        rte_panic("Cannot configure device: err=%d, port=%u\n",
                                  ret, port_id);
+               /* >8 End of configuration RX and TX queue. */
 
                ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd,
                                                       &nb_txd);
@@ -66,6 +83,7 @@ l2fwd_event_init_ports(struct l2fwd_resources *rsrc)
                fflush(stdout);
                rxq_conf = dev_info.default_rxconf;
                rxq_conf.offloads = local_port_conf.rxmode.offloads;
+               /* Using lcore to poll one or several ports. 8< */
                ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd,
                                             rte_eth_dev_socket_id(port_id),
                                             &rxq_conf,
@@ -74,7 +92,9 @@ l2fwd_event_init_ports(struct l2fwd_resources *rsrc)
                        rte_panic("rte_eth_rx_queue_setup:err=%d, port=%u\n",
                                  ret, port_id);
 
-               /* init one TX queue on each port */
+               /* >8 End of using lcore to poll one or several ports. */
+
+               /* Init one TX queue on each port. 8< */
                fflush(stdout);
                txq_conf = dev_info.default_txconf;
                txq_conf.offloads = local_port_conf.txmode.offloads;
@@ -84,6 +104,7 @@ l2fwd_event_init_ports(struct l2fwd_resources *rsrc)
                if (ret < 0)
                        rte_panic("rte_eth_tx_queue_setup:err=%d, port=%u\n",
                                  ret, port_id);
+               /* >8 End of init one TX queue on each port. */
 
                rte_eth_promiscuous_enable(port_id);