]> git.droids-corp.org - dpdk.git/blobdiff - examples/vmdq/main.c
fix ethdev port id validation
[dpdk.git] / examples / vmdq / main.c
index 72845241ef0e1ba0cea3e3b8b7eee0f0b6be7f56..2f3eb74f50aed4a17400a0fc80e59744c842746f 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--;
                }