fix ethdev port id validation
[dpdk.git] / examples / vmdq / main.c
index 7284524..2f3eb74 100644 (file)
@@ -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--;
                }