X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=examples%2Fvmdq%2Fmain.c;h=52596dd5e776ac0aae8a298ec4ea4bb738987ed7;hb=15dedf321036ae67c61f35a3ab55de767b07801f;hp=d94a18314ca860853ae93316d166f5dffc440116;hpb=9f3a8cb4cfe59ea63e267f69700fb0fde13d7dd3;p=deb_dpdk.git diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c index d94a1831..52596dd5 100644 --- a/examples/vmdq/main.c +++ b/examples/vmdq/main.c @@ -201,7 +201,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) num_pf_queues, num_pools, queues_per_pool); printf("vmdq queue base: %d pool base %d\n", vmdq_queue_base, vmdq_pool_base); - if (port >= rte_eth_dev_count()) + if (!rte_eth_dev_is_valid_port(port)) return -1; /* @@ -539,9 +539,9 @@ static unsigned check_ports_num(unsigned nb_ports) } for (portid = 0; portid < num_ports; portid++) { - if (ports[portid] >= nb_ports) { - printf("\nSpecified port ID(%u) exceeds max system port ID(%u)\n", - ports[portid], (nb_ports - 1)); + if (!rte_eth_dev_is_valid_port(ports[portid])) { + printf("\nSpecified port ID(%u) is not valid\n", + ports[portid]); ports[portid] = INVALID_PORT_ID; valid_num_ports--; } @@ -580,7 +580,7 @@ main(int argc, char *argv[]) if (rte_lcore_count() > RTE_MAX_LCORE) rte_exit(EXIT_FAILURE, "Not enough cores\n"); - nb_ports = rte_eth_dev_count(); + nb_ports = rte_eth_dev_count_avail(); /* * Update the global var NUM_PORTS and global array PORTS @@ -600,7 +600,7 @@ main(int argc, char *argv[]) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); /* initialize all ports */ - for (portid = 0; portid < nb_ports; portid++) { + RTE_ETH_FOREACH_DEV(portid) { /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << portid)) == 0) { printf("\nSkipping disabled port %d\n", portid);