From 773392553bed3223b17eab798c5098fcbdfbf409 Mon Sep 17 00:00:00 2001 From: Ivan Ilchenko Date: Thu, 12 Sep 2019 17:42:15 +0100 Subject: [PATCH] app: check status of getting ethdev info rte_eth_dev_info_get() return value was changed from void to int, so this patch modify rte_eth_dev_info_get() usage across apps according to its new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Ferruh Yigit --- app/proc-info/main.c | 15 +++++++++-- app/test-eventdev/test_perf_common.c | 8 +++++- app/test-eventdev/test_pipeline_common.c | 9 ++++++- app/test/test_event_eth_rx_adapter.c | 4 ++- app/test/test_kni.c | 27 ++++++++++++++++--- app/test/test_link_bonding_rssconf.c | 33 ++++++++++++++++++++---- app/test/test_pmd_ring.c | 9 ++++++- 7 files changed, 91 insertions(+), 14 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index a89b51bb3f..34eb7a7cc4 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -683,7 +683,12 @@ show_port(void) if (ret == 0) printf("\t -- mtu (%d)\n", mtu); - rte_eth_dev_info_get(i, &dev_info); + ret = rte_eth_dev_info_get(i, &dev_info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + i, strerror(-ret)); + return; + } printf(" - queue\n"); for (j = 0; j < dev_info.nb_rx_queues; j++) { @@ -836,7 +841,13 @@ show_tm(void) memset(&cap, 0, sizeof(cap)); memset(&error, 0, sizeof(error)); - rte_eth_dev_info_get(i, &dev_info); + ret = rte_eth_dev_info_get(i, &dev_info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + i, strerror(-ret)); + return; + } + printf(" - Generic for port (%u)\n" "\t -- driver name %s\n" "\t -- max vf (%u)\n" diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index aa925a7ef7..e75582b1a2 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -660,6 +660,7 @@ int perf_ethdev_setup(struct evt_test *test, struct evt_options *opt) { uint16_t i; + int ret; struct test_perf *t = evt_test_priv(test); struct rte_eth_conf port_conf = { .rxmode = { @@ -688,7 +689,12 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt) struct rte_eth_dev_info dev_info; struct rte_eth_conf local_port_conf = port_conf; - rte_eth_dev_info_get(i, &dev_info); + ret = rte_eth_dev_info_get(i, &dev_info); + if (ret != 0) { + evt_err("Error during getting device (port %u) info: %s\n", + i, strerror(-ret)); + return ret; + } local_port_conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads; diff --git a/app/test-eventdev/test_pipeline_common.c b/app/test-eventdev/test_pipeline_common.c index 16c49b8608..ef8ae28c93 100644 --- a/app/test-eventdev/test_pipeline_common.c +++ b/app/test-eventdev/test_pipeline_common.c @@ -159,6 +159,7 @@ int pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt) { uint16_t i; + int ret; uint8_t nb_queues = 1; struct test_pipeline *t = evt_test_priv(test); struct rte_eth_rxconf rx_conf; @@ -191,7 +192,13 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt) if (!(caps & RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT)) t->internal_port = 0; - rte_eth_dev_info_get(i, &dev_info); + ret = rte_eth_dev_info_get(i, &dev_info); + if (ret != 0) { + evt_err("Error during getting device (port %u) info: %s\n", + i, strerror(-ret)); + return ret; + } + rx_conf = dev_info.default_rxconf; rx_conf.offloads = port_conf.rxmode.offloads; diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c index 953b827456..950bc67c2f 100644 --- a/app/test/test_event_eth_rx_adapter.c +++ b/app/test/test_event_eth_rx_adapter.c @@ -45,7 +45,9 @@ port_init_common(uint16_t port, const struct rte_eth_conf *port_conf, retval = rte_eth_dev_configure(port, 0, 0, port_conf); - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) + return retval; default_params.rx_rings = RTE_MIN(dev_info.max_rx_queues, MAX_NUM_RX_QUEUE); diff --git a/app/test/test_kni.c b/app/test/test_kni.c index 7a65de179b..2c333748db 100644 --- a/app/test/test_kni.c +++ b/app/test/test_kni.c @@ -436,7 +436,13 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp) memset(&info, 0, sizeof(info)); memset(&ops, 0, sizeof(ops)); - rte_eth_dev_info_get(port_id, &info); + ret = rte_eth_dev_info_get(port_id, &info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + return -1; + } + if (info.device) bus = rte_bus_find_by_device(info.device); if (bus && !strcmp(bus->name, "pci")) { @@ -622,7 +628,14 @@ test_kni(void) memset(&info, 0, sizeof(info)); memset(&conf, 0, sizeof(conf)); memset(&ops, 0, sizeof(ops)); - rte_eth_dev_info_get(port_id, &info); + + ret = rte_eth_dev_info_get(port_id, &info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + return -1; + } + if (info.device) bus = rte_bus_find_by_device(info.device); else @@ -658,7 +671,15 @@ test_kni(void) memset(&conf, 0, sizeof(conf)); memset(&info, 0, sizeof(info)); memset(&ops, 0, sizeof(ops)); - rte_eth_dev_info_get(port_id, &info); + + ret = rte_eth_dev_info_get(port_id, &info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + ret = -1; + goto fail; + } + if (info.device) bus = rte_bus_find_by_device(info.device); else diff --git a/app/test/test_link_bonding_rssconf.c b/app/test/test_link_bonding_rssconf.c index 65de3b98d4..1a9571e5c6 100644 --- a/app/test/test_link_bonding_rssconf.c +++ b/app/test/test_link_bonding_rssconf.c @@ -329,7 +329,11 @@ test_propagate(void) uint64_t rss_hf = 0; uint64_t default_rss_hf = 0; - rte_eth_dev_info_get(test_params.bond_port_id, &test_params.bond_dev_info); + retval = rte_eth_dev_info_get(test_params.bond_port_id, + &test_params.bond_dev_info); + TEST_ASSERT((retval == 0), + "Error during getting device (port %u) info: %s\n", + test_params.bond_port_id, strerror(-retval)); /* * Test hash function propagation @@ -443,10 +447,16 @@ test_rss(void) /** * Configure bonding port in RSS mq mode */ + int ret; + TEST_ASSERT_SUCCESS(configure_ethdev(test_params.bond_port_id, &rss_pmd_conf, 0), "Failed to configure bonding device\n"); - rte_eth_dev_info_get(test_params.bond_port_id, &test_params.bond_dev_info); + ret = rte_eth_dev_info_get(test_params.bond_port_id, + &test_params.bond_dev_info); + TEST_ASSERT((ret == 0), + "Error during getting device (port %u) info: %s\n", + test_params.bond_port_id, strerror(-ret)); TEST_ASSERT_SUCCESS(bond_slaves(), "Bonding slaves failed"); @@ -468,10 +478,16 @@ test_rss(void) static int test_rss_lazy(void) { + int ret; + TEST_ASSERT_SUCCESS(configure_ethdev(test_params.bond_port_id, &default_pmd_conf, 0), "Failed to configure bonding device\n"); - rte_eth_dev_info_get(test_params.bond_port_id, &test_params.bond_dev_info); + ret = rte_eth_dev_info_get(test_params.bond_port_id, + &test_params.bond_dev_info); + TEST_ASSERT((ret == 0), + "Error during getting device (port %u) info: %s\n", + test_params.bond_port_id, strerror(-ret)); TEST_ASSERT_SUCCESS(bond_slaves(), "Bonding slaves failed"); @@ -532,6 +548,10 @@ test_setup(void) rte_eth_dev_default_mac_addr_set(port->port_id, &mac_addr); rte_eth_dev_info_get(port->port_id, &port->dev_info); + retval = rte_eth_dev_info_get(port->port_id, &port->dev_info); + TEST_ASSERT((retval == 0), + "Error during getting device (port %u) info: %s\n", + test_params.bond_port_id, strerror(-retval)); } if (test_params.bond_port_id == INVALID_PORT_ID) { @@ -545,8 +565,11 @@ test_setup(void) TEST_ASSERT_SUCCESS(configure_ethdev(test_params.bond_port_id, &default_pmd_conf, 0), "Failed to configure bonding device\n"); - rte_eth_dev_info_get(test_params.bond_port_id, - &test_params.bond_dev_info); + retval = rte_eth_dev_info_get(test_params.bond_port_id, + &test_params.bond_dev_info); + TEST_ASSERT((retval == 0), + "Error during getting device (port %u) info: %s\n", + test_params.bond_port_id, strerror(-retval)); } return TEST_SUCCESS; diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c index 6414bbd189..65ab6e7e00 100644 --- a/app/test/test_pmd_ring.c +++ b/app/test/test_pmd_ring.c @@ -490,10 +490,17 @@ static int test_command_line_ring_port(void) { int port, cmdl_port0 = -1; + int ret; + /* find a port created with the --vdev=net_ring0 command line option */ RTE_ETH_FOREACH_DEV(port) { struct rte_eth_dev_info dev_info; - rte_eth_dev_info_get(port, &dev_info); + + ret = rte_eth_dev_info_get(port, &dev_info); + TEST_ASSERT((ret == 0), + "Error during getting device (port %d) info: %s\n", + port, strerror(-ret)); + if (!strcmp(dev_info.driver_name, "Rings PMD")) { printf("found a command line ring port=%d\n", port); cmdl_port0 = port; -- 2.20.1