examples/l2fwd: if no port configured, exit
authorIntel <intel.com>
Mon, 3 Jun 2013 00:00:00 +0000 (00:00 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Sep 2013 12:16:09 +0000 (14:16 +0200)
Signed-off-by: Intel
examples/l2fwd/main.c

index e420b7b..851d767 100644 (file)
@@ -583,6 +583,7 @@ MAIN(int argc, char **argv)
        struct rte_eth_dev_info dev_info;
        int ret;
        uint8_t nb_ports;
+       uint8_t nb_ports_available;
        uint8_t portid, last_port;
        unsigned lcore_id, rx_lcore_id;
        unsigned nb_ports_in_mask = 0;
@@ -648,7 +649,7 @@ MAIN(int argc, char **argv)
 
                rte_eth_dev_info_get(portid, &dev_info);
        }
-       if (nb_ports_in_mask < 2 || nb_ports_in_mask % 2) {
+       if (nb_ports_in_mask % 2) {
                printf("Notice: odd number of ports in portmask.\n");
                l2fwd_dst_ports[last_port] = last_port;
        }
@@ -680,11 +681,14 @@ MAIN(int argc, char **argv)
                printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid);
        }
 
+       nb_ports_available = nb_ports;
+
        /* Initialise each port */
        for (portid = 0; portid < nb_ports; portid++) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
                        printf("Skipping disabled port %u\n", (unsigned) portid);
+                       nb_ports_available--;
                        continue;
                }
                /* init port */
@@ -737,6 +741,11 @@ MAIN(int argc, char **argv)
                memset(&port_statistics, 0, sizeof(port_statistics));
        }
 
+       if (!nb_ports_available) {
+               rte_exit(EXIT_FAILURE,
+                       "All available ports are disabled. Please set portmask.\n");
+       }
+
        check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
 
        /* launch per-lcore init on every lcore */