From 089e5ed727a15da2729cfee9b63533dd120bd04c Mon Sep 17 00:00:00 2001 From: Ivan Ilchenko Date: Thu, 12 Sep 2019 17:42:29 +0100 Subject: [PATCH] examples: 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 examples according to its new return type. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Ferruh Yigit --- examples/bond/main.c | 14 +++++++++-- examples/distributor/main.c | 8 +++++- examples/ethtool/ethtool-app/main.c | 8 +++++- examples/ethtool/lib/rte_ethtool.c | 19 +++++++++++--- examples/eventdev_pipeline/main.c | 8 +++++- examples/exception_path/main.c | 7 +++++- examples/ip_fragmentation/main.c | 14 +++++++++-- examples/ip_pipeline/kni.c | 5 +++- examples/ip_pipeline/link.c | 3 ++- examples/ip_reassembly/main.c | 7 +++++- examples/ipv4_multicast/main.c | 7 +++++- examples/kni/main.c | 25 ++++++++++++++++--- examples/l2fwd-crypto/main.c | 9 ++++++- examples/l2fwd-jobstats/main.c | 8 +++++- examples/l2fwd-keepalive/main.c | 8 +++++- examples/l2fwd/main.c | 8 +++++- examples/l3fwd-acl/main.c | 22 +++++++++++++--- examples/l3fwd-power/main.c | 22 +++++++++++++--- examples/l3fwd/main.c | 14 +++++++++-- examples/link_status_interrupt/main.c | 8 +++++- examples/load_balancer/init.c | 7 +++++- examples/multi_process/symmetric_mp/main.c | 8 +++++- examples/netmap_compat/lib/compat_netmap.c | 9 ++++++- examples/packet_ordering/main.c | 8 +++++- .../performance-thread/l3fwd-thread/main.c | 15 +++++++++-- examples/ptpclient/ptpclient.c | 9 ++++++- examples/qos_meter/main.c | 16 ++++++++++-- examples/rxtx_callbacks/main.c | 9 ++++++- examples/server_node_efd/server/init.c | 5 +++- examples/skeleton/basicfwd.c | 8 +++++- examples/tep_termination/vxlan_setup.c | 6 ++++- examples/vm_power_manager/main.c | 8 +++++- examples/vmdq/main.c | 16 ++++++++++-- examples/vmdq_dcb/main.c | 18 +++++++++++-- 34 files changed, 317 insertions(+), 49 deletions(-) diff --git a/examples/bond/main.c b/examples/bond/main.c index 1c0df9d467..be62c1713a 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -148,7 +148,12 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(portid)) rte_exit(EXIT_FAILURE, "Invalid port\n"); - rte_eth_dev_info_get(portid, &dev_info); + retval = rte_eth_dev_info_get(portid, &dev_info); + if (retval != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-retval)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -230,7 +235,12 @@ bond_port_init(struct rte_mempool *mbuf_pool) BOND_PORT = retval; - rte_eth_dev_info_get(BOND_PORT, &dev_info); + retval = rte_eth_dev_info_get(BOND_PORT, &dev_info); + if (retval != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + BOND_PORT, strerror(-retval)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/distributor/main.c b/examples/distributor/main.c index 81d7ca61d1..8942f3607c 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -120,7 +120,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c index 3d2a70d524..774df7eb10 100644 --- a/examples/ethtool/ethtool-app/main.c +++ b/examples/ethtool/ethtool-app/main.c @@ -95,6 +95,7 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) char str_name[16]; uint16_t nb_rxd = PORT_RX_QUEUE_SIZE; uint16_t nb_txd = PORT_TX_QUEUE_SIZE; + int ret; memset(&cfg_port, 0, sizeof(cfg_port)); cfg_port.txmode.mq_mode = ETH_MQ_TX_NONE; @@ -102,7 +103,12 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) for (idx_port = 0; idx_port < cnt_ports; idx_port++) { struct app_port *ptr_port = &app_cfg->ports[idx_port]; - rte_eth_dev_info_get(idx_port, &dev_info); + ret = rte_eth_dev_info_get(idx_port, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + idx_port, strerror(-ret)); + size_pktpool = dev_info.rx_desc_lim.nb_max + dev_info.tx_desc_lim.nb_max + PKTPOOL_EXTRA_SIZE; diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index fd1692daae..43cacc0579 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -41,7 +41,13 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo) printf("Insufficient fw version buffer size, " "the minimum size should be %d\n", ret); - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + + return ret; + } strlcpy(drvinfo->driver, dev_info.driver_name, sizeof(drvinfo->driver)); @@ -370,8 +376,12 @@ rte_ethtool_net_set_rx_mode(uint16_t port_id) uint16_t num_vfs; struct rte_eth_dev_info dev_info; uint16_t vf; + int ret; + + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + return ret; - rte_eth_dev_info_get(port_id, &dev_info); num_vfs = dev_info.max_vfs; /* Set VF vf_rx_mode, VF unsupport status is discard */ @@ -397,11 +407,14 @@ rte_ethtool_get_ringparam(uint16_t port_id, struct rte_eth_rxq_info rx_qinfo; struct rte_eth_txq_info tx_qinfo; int stat; + int ret; if (ring_param == NULL) return -EINVAL; - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + return ret; stat = rte_eth_rx_queue_info_get(port_id, 0, &rx_qinfo); if (stat != 0) diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c index f4e57f5412..3789fbfd7b 100644 --- a/examples/eventdev_pipeline/main.c +++ b/examples/eventdev_pipeline/main.c @@ -274,7 +274,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 0d79e5a24b..d7f3598afb 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -432,7 +432,12 @@ init_port(uint16_t port) /* Initialise device and RX/TX queues */ PRINT_INFO("Initialising port %u ...", port); fflush(stdout); - rte_eth_dev_info_get(port, &dev_info); + + ret = rte_eth_dev_info_get(port, &dev_info); + if (ret != 0) + FATAL_ERROR("Error during getting device (port %u) info: %s\n", + port, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 324d60773f..6b832445aa 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -903,7 +903,12 @@ main(int argc, char **argv) qconf = &lcore_queue_conf[rx_lcore_id]; /* limit the frame size to the maximum supported by NIC */ - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + local_port_conf.rxmode.max_rx_pkt_len = RTE_MIN( dev_info.max_rx_pktlen, local_port_conf.rxmode.max_rx_pkt_len); @@ -984,7 +989,12 @@ main(int argc, char **argv) printf("\n"); /* init one TX queue per couple (lcore,port) */ - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + queueid = 0; for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { if (rte_lcore_is_enabled(lcore_id) == 0) diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index e9262e0790..4519685932 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -109,6 +109,7 @@ kni_create(const char *name, struct kni_params *params) struct rte_kni *k; const struct rte_pci_device *pci_dev; const struct rte_bus *bus = NULL; + int ret; /* Check input params */ if ((name == NULL) || @@ -123,7 +124,9 @@ kni_create(const char *name, struct kni_params *params) return NULL; /* Resource create */ - rte_eth_dev_info_get(link->port_id, &dev_info); + ret = rte_eth_dev_info_get(link->port_id, &dev_info); + if (ret != 0) + return NULL; memset(&kni_conf, 0, sizeof(kni_conf)); strlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE); diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c index 787eb866ab..4e3a40b5a8 100644 --- a/examples/ip_pipeline/link.c +++ b/examples/ip_pipeline/link.c @@ -129,7 +129,8 @@ link_create(const char *name, struct link_params *params) if (!rte_eth_dev_is_valid_port(port_id)) return NULL; - rte_eth_dev_info_get(port_id, &port_info); + if (rte_eth_dev_info_get(port_id, &port_info) != 0) + return NULL; mempool = mempool_find(params->rx.mempool_name); if (mempool == NULL) diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index 38b39be6b8..87d4b5c01f 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -1038,7 +1038,12 @@ main(int argc, char **argv) qconf = &lcore_queue_conf[rx_lcore_id]; /* limit the frame size to the maximum supported by NIC */ - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + local_port_conf.rxmode.max_rx_pkt_len = RTE_MIN( dev_info.max_rx_pktlen, local_port_conf.rxmode.max_rx_pkt_len); diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 72eaadc519..1ee3b61d1a 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -686,7 +686,12 @@ main(int argc, char **argv) qconf = &lcore_queue_conf[rx_lcore_id]; /* limit the frame size to the maximum supported by NIC */ - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + local_port_conf.rxmode.max_rx_pkt_len = RTE_MIN( dev_info.max_rx_pktlen, local_port_conf.rxmode.max_rx_pkt_len); diff --git a/examples/kni/main.c b/examples/kni/main.c index 17f695ea99..e43f174479 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -595,7 +595,13 @@ init_port(uint16_t port) /* Initialise device and RX/TX queues */ RTE_LOG(INFO, APP, "Initialising port %u ...\n", (unsigned)port); fflush(stdout); - rte_eth_dev_info_get(port, &dev_info); + + ret = rte_eth_dev_info_get(port, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + port, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -780,7 +786,15 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) "for port%u (%d)\n", (unsigned int)port_id, ret); - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) { + RTE_LOG(ERR, APP, + "Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + + return ret; + } + rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, @@ -869,6 +883,7 @@ kni_alloc(uint16_t port_id) struct rte_kni *kni; struct rte_kni_conf conf; struct kni_port_params **params = kni_port_params_array; + int ret; if (port_id >= RTE_MAX_ETHPORTS || !params[port_id]) return -1; @@ -898,7 +913,11 @@ kni_alloc(uint16_t port_id) struct rte_kni_ops ops; struct rte_eth_dev_info dev_info; - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); /* Get the interface default mac address */ rte_eth_macaddr_get(port_id, diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 3fe2ba7253..9a370f2dea 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -2513,7 +2513,14 @@ initialize_ports(struct l2fwd_crypto_options *options) /* init port */ printf("Initializing port %u... ", portid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + + retval = rte_eth_dev_info_get(portid, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + portid, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index 77e44dc825..5fcba5c88c 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -842,7 +842,13 @@ main(int argc, char **argv) /* init port */ printf("Initializing port %u... ", portid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 9831a43237..a051390688 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -634,7 +634,13 @@ main(int argc, char **argv) /* init port */ printf("Initializing port %u... ", portid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 1e2b142976..8d4c539810 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -635,7 +635,13 @@ main(int argc, char **argv) /* init port */ printf("Initializing port %u... ", portid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index 0c44df767e..60531ce0ec 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1924,7 +1924,13 @@ main(int argc, char **argv) n_tx_queue = MAX_TX_QUEUE_PER_PORT; printf("Creating queues: nb_rxq=%d nb_txq=%u... ", nb_rx_queue, (unsigned)n_tx_queue); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -1994,7 +2000,12 @@ main(int argc, char **argv) printf("txq=%u,%d,%d ", lcore_id, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + txconf = &dev_info.default_txconf; txconf->offloads = local_port_conf.txmode.offloads; ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd, @@ -2036,7 +2047,12 @@ main(int argc, char **argv) printf("rxq=%d,%d,%d ", portid, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd, diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index fd8d9528fa..bfcaa46c58 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -2257,7 +2257,12 @@ main(int argc, char **argv) printf("Initializing port %d ... ", portid ); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + dev_rxq_num = dev_info.max_rx_queues; dev_txq_num = dev_info.max_tx_queues; @@ -2275,7 +2280,13 @@ main(int argc, char **argv) /* If number of Rx queue is 0, no need to enable Rx interrupt */ if (nb_rx_queue == 0) local_port_conf.intr_conf.rxq = 0; - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -2398,7 +2409,12 @@ main(int argc, char **argv) printf("rxq=%d,%d,%d ", portid, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd, diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 3800bad196..3294ac2dab 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -874,7 +874,12 @@ main(int argc, char **argv) printf("Creating queues: nb_rxq=%d nb_txq=%u... ", nb_rx_queue, (unsigned)n_tx_queue ); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -985,7 +990,12 @@ main(int argc, char **argv) printf("rxq=%d,%d,%d ", portid, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; if (!per_port_pool) diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index 9cd4dc7a69..0c3dfc6912 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -609,7 +609,13 @@ main(int argc, char **argv) /* init port */ printf("Initializing port %u... ", (unsigned) portid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index 3ab7d0211c..660f5a8edd 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -411,7 +411,12 @@ app_init_nics(void) /* Init port */ printf("Initializing NIC port %u ...\n", port); - rte_eth_dev_info_get(port, &dev_info); + + ret = rte_eth_dev_info_get(port, &dev_info); + if (ret != 0) + rte_panic("Error during getting device (port %u) info: %s\n", + port, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index 62771e036c..9ae8efb0ba 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -209,7 +209,13 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool, printf("# Initialising port %u... ", port); fflush(stdout); - rte_eth_dev_info_get(port, &info); + retval = rte_eth_dev_info_get(port, &info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + info.default_rxconf.rx_drop_en = 1; if (info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) diff --git a/examples/netmap_compat/lib/compat_netmap.c b/examples/netmap_compat/lib/compat_netmap.c index 10a4379438..c25cc093d0 100644 --- a/examples/netmap_compat/lib/compat_netmap.c +++ b/examples/netmap_compat/lib/compat_netmap.c @@ -684,7 +684,14 @@ rte_netmap_init_port(uint16_t portid, const struct rte_netmap_port_conf *conf) return -EINVAL; } - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) { + RTE_LOG(ERR, USER1, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + return ret; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) conf->eth_conf->txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index 030e922996..a99961f821 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -283,7 +283,13 @@ configure_eth_port(uint16_t port_id) if (!rte_eth_dev_is_valid_port(port_id)) return -1; - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) { + printf("Error during getting device (port %u) info: %s\n", + port_id, strerror(-ret)); + return ret; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 49d9424070..00f535053c 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -3559,7 +3559,13 @@ main(int argc, char **argv) n_tx_queue = MAX_TX_QUEUE_PER_PORT; printf("Creating queues: nb_rxq=%d nb_txq=%u... ", nb_rx_queue, (unsigned)n_tx_queue); - rte_eth_dev_info_get(portid, &dev_info); + + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -3663,7 +3669,12 @@ main(int argc, char **argv) printf("rxq=%d,%d,%d ", portid, queueid, socketid); fflush(stdout); - rte_eth_dev_info_get(portid, &dev_info); + ret = rte_eth_dev_info_get(portid, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + portid, strerror(-ret)); + rxq_conf = dev_info.default_rxconf; rxq_conf.offloads = port_conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd, diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c index 31778fd956..bc427a526c 100644 --- a/examples/ptpclient/ptpclient.c +++ b/examples/ptpclient/ptpclient.c @@ -189,7 +189,14 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c index da7afe8be2..13c85e9406 100644 --- a/examples/qos_meter/main.c +++ b/examples/qos_meter/main.c @@ -329,7 +329,13 @@ main(int argc, char **argv) /* NIC init */ conf = port_conf; - rte_eth_dev_info_get(port_rx, &dev_info); + + ret = rte_eth_dev_info_get(port_rx, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + port_rx, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; @@ -369,7 +375,13 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Port %d TX queue setup error (%d)\n", port_rx, ret); conf = port_conf; - rte_eth_dev_info_get(port_tx, &dev_info); + + ret = rte_eth_dev_info_get(port_tx, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + port_tx, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index dbcd9f4fc7..9fd4b8efd5 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -112,7 +112,14 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/server_node_efd/server/init.c b/examples/server_node_efd/server/init.c index af5a18e285..773780b4d2 100644 --- a/examples/server_node_efd/server/init.c +++ b/examples/server_node_efd/server/init.c @@ -111,7 +111,10 @@ init_port(uint16_t port_num) printf("Port %u init ... ", port_num); fflush(stdout); - rte_eth_dev_info_get(port_num, &dev_info); + retval = rte_eth_dev_info_get(port_num, &dev_info); + if (retval != 0) + return retval; + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c index a8a8e98f07..171ebde7bd 100644 --- a/examples/skeleton/basicfwd.c +++ b/examples/skeleton/basicfwd.c @@ -44,7 +44,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c index 9a0880002a..8d6514dd85 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -119,7 +119,11 @@ vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool) pconf->dst_port = udp_port; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); if (dev_info.max_rx_queues > MAX_QUEUES) { rte_exit(EXIT_FAILURE, diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 54c704610b..0f48ae926c 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -71,7 +71,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (!rte_eth_dev_is_valid_port(port)) return -1; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c index 7281ffd7fb..91f9a99042 100644 --- a/examples/vmdq/main.c +++ b/examples/vmdq/main.c @@ -169,7 +169,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) * The max pool number from dev_info will be used to validate the pool * number specified in cmd line */ - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + max_nb_pools = (uint32_t)dev_info.max_vmdq_pools; /* * We allow to process part of VMDQ pools specified by num_pools in @@ -214,7 +220,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) rxRings = (uint16_t)dev_info.max_rx_queues; txRings = (uint16_t)dev_info.max_tx_queues; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c index 3890003276..2122e41f5e 100644 --- a/examples/vmdq_dcb/main.c +++ b/examples/vmdq_dcb/main.c @@ -202,7 +202,14 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) * The max pool number from dev_info will be used to validate the pool * number specified in cmd line */ - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + + return retval; + } + max_nb_pools = (uint32_t)dev_info.max_vmdq_pools; /* * We allow to process part of VMDQ pools specified by num_pools in @@ -253,7 +260,14 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) if (retval < 0) return retval; - rte_eth_dev_info_get(port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + printf("Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + + return retval; + } + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;