aboutsummaryrefslogtreecommitdiffstats
path: root/examples/multi_process/l2fwd_fork/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multi_process/l2fwd_fork/main.c')
-rw-r--r--examples/multi_process/l2fwd_fork/main.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index bc9ceb5c..94318ab6 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -838,7 +838,7 @@ l2fwd_parse_args(int argc, char **argv)
/* 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 */
@@ -850,7 +850,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));
@@ -897,7 +897,7 @@ main(int argc, char **argv)
struct lcore_queue_conf *qconf;
int ret;
uint16_t nb_ports;
- uint16_t nb_ports_available;
+ uint16_t nb_ports_available = 0;
uint16_t portid, last_port;
unsigned rx_lcore_id;
unsigned nb_ports_in_mask = 0;
@@ -941,12 +941,12 @@ main(int argc, char **argv)
for (i = 0; i < RTE_MAX_LCORE; i++)
lcore_resource[i].lcore_id = i;
- nb_ports = rte_eth_dev_count();
+ nb_ports = rte_eth_dev_count_avail();
if (nb_ports == 0)
rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
/* create the mbuf pool */
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
continue;
@@ -969,7 +969,7 @@ main(int argc, char **argv)
/*
* Each logical core is assigned a dedicated TX queue on each port.
*/
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
continue;
@@ -992,7 +992,7 @@ main(int argc, char **argv)
qconf = NULL;
/* Initialize the port/queue configuration of each logical core */
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
struct lcore_resource_struct *res;
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
@@ -1025,10 +1025,8 @@ 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++) {
+ RTE_ETH_FOREACH_DEV(portid) {
struct rte_eth_rxconf rxq_conf;
struct rte_eth_txconf txq_conf;
struct rte_eth_conf local_port_conf = port_conf;
@@ -1036,9 +1034,9 @@ main(int argc, char **argv)
/* 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;
}
+ nb_ports_available++;
/* init port */
printf("Initializing port %u... ", (unsigned) portid);
fflush(stdout);
@@ -1129,7 +1127,7 @@ main(int argc, char **argv)
"All available ports are disabled. Please set portmask.\n");
}
- check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+ check_all_ports_link_status(l2fwd_enabled_port_mask);
/* Record pair lcore */
/**
@@ -1140,7 +1138,7 @@ main(int argc, char **argv)
* procedure completed. So, record the pair relationship for those lcores working
* on ports.
**/
- for (portid = 0; portid < nb_ports; portid++) {
+ RTE_ETH_FOREACH_DEV(portid) {
uint32_t pair_port;
unsigned lcore = 0, pair_lcore = 0;
unsigned j, find_lcore, find_pair_lcore;