New upstream version 18.08
[deb_dpdk.git] / examples / performance-thread / l3fwd-thread / main.c
index c04294c..5392fce 100644 (file)
@@ -306,7 +306,6 @@ static struct rte_eth_conf port_conf = {
                .mq_mode = ETH_MQ_RX_RSS,
                .max_rx_pkt_len = ETHER_MAX_LEN,
                .split_hdr_size = 0,
-               .ignore_offload_bitfield = 1,
                .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
                             DEV_RX_OFFLOAD_CRC_STRIP),
        },
@@ -1990,17 +1989,18 @@ cpu_load_collector(__rte_unused void *arg) {
  *
  * This loop is used to start empty scheduler on lcore.
  */
-static void
+static void *
 lthread_null(__rte_unused void *args)
 {
        int lcore_id = rte_lcore_id();
 
        RTE_LOG(INFO, L3FWD, "Starting scheduler on lcore %d.\n", lcore_id);
        lthread_exit(NULL);
+       return NULL;
 }
 
 /* main processing loop */
-static void
+static void *
 lthread_tx_per_ring(void *dummy)
 {
        int nb_rx;
@@ -2045,6 +2045,7 @@ lthread_tx_per_ring(void *dummy)
                        lthread_cond_wait(ready, 0);
 
        }
+       return NULL;
 }
 
 /*
@@ -2053,7 +2054,7 @@ lthread_tx_per_ring(void *dummy)
  * This lthread is used to spawn one new lthread per ring from producers.
  *
  */
-static void
+static void *
 lthread_tx(void *args)
 {
        struct lthread *lt;
@@ -2098,9 +2099,10 @@ lthread_tx(void *args)
                }
 
        }
+       return NULL;
 }
 
-static void
+static void *
 lthread_rx(void *dummy)
 {
        int ret;
@@ -2124,7 +2126,7 @@ lthread_rx(void *dummy)
 
        if (rx_conf->n_rx_queue == 0) {
                RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", rte_lcore_id());
-               return;
+               return NULL;
        }
 
        RTE_LOG(INFO, L3FWD, "Entering main Rx loop on lcore %u\n", rte_lcore_id());
@@ -2196,6 +2198,7 @@ lthread_rx(void *dummy)
                        lthread_yield();
                }
        }
+       return NULL;
 }
 
 /*
@@ -2204,8 +2207,9 @@ lthread_rx(void *dummy)
  * This lthread loop spawns all rx and tx lthreads on master lcore
  */
 
-static void
-lthread_spawner(__rte_unused void *arg) {
+static void *
+lthread_spawner(__rte_unused void *arg)
+{
        struct lthread *lt[MAX_THREAD];
        int i;
        int n_thread = 0;
@@ -2246,6 +2250,7 @@ lthread_spawner(__rte_unused void *arg) {
        for (i = 0; i < n_thread; i++)
                lthread_join(lt[i], NULL);
 
+       return NULL;
 }
 
 /*
@@ -2491,7 +2496,7 @@ check_lcore_params(void)
 }
 
 static int
-check_port_config(const unsigned nb_ports)
+check_port_config(void)
 {
        unsigned portid;
        uint16_t i;
@@ -2502,7 +2507,7 @@ check_port_config(const unsigned nb_ports)
                        printf("port %u is not enabled in port mask\n", portid);
                        return -1;
                }
-               if (portid >= nb_ports) {
+               if (!rte_eth_dev_is_valid_port(portid)) {
                        printf("port %u is not present on the board\n", portid);
                        return -1;
                }
@@ -3411,7 +3416,7 @@ init_mem(unsigned nb_mbuf)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -3423,7 +3428,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -3514,15 +3519,15 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "init_rx_rings failed\n");
 
-       nb_ports = rte_eth_dev_count();
+       nb_ports = rte_eth_dev_count_avail();
 
-       if (check_port_config(nb_ports) < 0)
+       if (check_port_config() < 0)
                rte_exit(EXIT_FAILURE, "check_port_config failed\n");
 
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -3545,6 +3550,18 @@ main(int argc, char **argv)
                if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                        local_port_conf.txmode.offloads |=
                                DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+               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"\n",
+                               portid,
+                               port_conf.rx_adv_conf.rss_conf.rss_hf,
+                               local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+               }
+
                ret = rte_eth_dev_configure(portid, nb_rx_queue,
                                        (uint16_t)n_tx_queue, &local_port_conf);
                if (ret < 0)
@@ -3591,7 +3608,6 @@ main(int argc, char **argv)
                        fflush(stdout);
 
                        txconf = &dev_info.default_txconf;
-                       txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
                        txconf->offloads = local_port_conf.txmode.offloads;
                        ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
                                                     socketid, txconf);
@@ -3654,7 +3670,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
 
@@ -3699,7 +3715,7 @@ main(int argc, char **argv)
                }
        }
 
-       check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        if (lthreads_on) {
                printf("Starting L-Threading Model\n");