X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fkni%2Fmain.c;h=4b162debb144faf2ca006ceb1da02842ccb2034c;hb=3c0db1ab516498e96b42fa804a3cf14e0ccf7647;hp=d944bae6923b59463ba700b87542ff8169771eeb;hpb=8728ccf37615904cf23fb8763895b05c9a3c6b0c;p=dpdk.git diff --git a/examples/kni/main.c b/examples/kni/main.c index d944bae692..4b162debb1 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -689,7 +689,7 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) struct rte_eth_dev_info dev_info; struct rte_eth_rxconf rxq_conf; - if (port_id >= rte_eth_dev_count()) { + if (!rte_eth_dev_is_valid_port(port_id)) { RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id); return -EINVAL; } @@ -748,7 +748,7 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up) { int ret = 0; - if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) { + if (!rte_eth_dev_is_valid_port(port_id)) { RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id); return -EINVAL; } @@ -782,7 +782,7 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) { int ret = 0; - if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) { + if (!rte_eth_dev_is_valid_port(port_id)) { RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id); return -EINVAL; } @@ -926,13 +926,13 @@ main(int argc, char** argv) } /* Get number of ports found in scan */ - nb_sys_ports = rte_eth_dev_count(); + nb_sys_ports = rte_eth_dev_count_avail(); if (nb_sys_ports == 0) rte_exit(EXIT_FAILURE, "No supported Ethernet device found\n"); /* Check if the configured port ID is valid */ for (i = 0; i < RTE_MAX_ETHPORTS; i++) - if (kni_port_params_array[i] && i >= nb_sys_ports) + if (kni_port_params_array[i] && !rte_eth_dev_is_valid_port(i)) rte_exit(EXIT_FAILURE, "Configured invalid " "port ID %u\n", i);