From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 (+0000) Subject: examples/l2fwd: if no port configured, exit X-Git-Tag: spdx-start~11188 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f56d08158ffcc29a6b77fa66048cae48d3194ff8;p=dpdk.git examples/l2fwd: if no port configured, exit Signed-off-by: Intel --- diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e420b7b0c2..851d767b61 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -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 */