From 22e5c73bd181ddae758189295146154542b63360 Mon Sep 17 00:00:00 2001 From: Igor Romanov Date: Tue, 10 Sep 2019 09:25:50 +0100 Subject: [PATCH] examples: check status of getting link info The return value of rte_eth_link_get() and rte_eth_link_get_nowait() was changed from void to int. Update the usage of the functions according to the new return type. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- examples/bbdev_app/main.c | 12 ++++++--- examples/distributor/main.c | 14 +++++++--- examples/ethtool/lib/rte_ethtool.c | 6 ++++- examples/exception_path/main.c | 10 ++++++- examples/flow_filtering/main.c | 8 ++++-- examples/ip_fragmentation/main.c | 10 ++++++- examples/ip_pipeline/cli.c | 9 ++++++- examples/ip_pipeline/link.c | 3 ++- examples/ip_reassembly/main.c | 10 ++++++- examples/ipsec-secgw/ipsec-secgw.c | 10 ++++++- examples/ipv4_multicast/main.c | 10 ++++++- examples/kni/main.c | 19 ++++++++++++-- examples/l2fwd-crypto/main.c | 10 ++++++- examples/l2fwd-jobstats/main.c | 10 ++++++- examples/l2fwd-keepalive/main.c | 10 ++++++- examples/l2fwd/main.c | 10 ++++++- examples/l3fwd-acl/main.c | 10 ++++++- examples/l3fwd-power/main.c | 10 ++++++- examples/l3fwd/main.c | 10 ++++++- examples/link_status_interrupt/main.c | 26 ++++++++++++++++--- examples/load_balancer/init.c | 10 ++++++- .../client_server_mp/mp_server/init.c | 10 ++++++- examples/multi_process/symmetric_mp/main.c | 10 ++++++- .../performance-thread/l3fwd-thread/main.c | 10 ++++++- examples/qos_sched/init.c | 13 ++++++++-- examples/server_node_efd/server/init.c | 10 ++++++- examples/vm_power_manager/main.c | 10 ++++++- 27 files changed, 252 insertions(+), 38 deletions(-) diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c index 3d36629a1b..3498765896 100644 --- a/examples/bbdev_app/main.c +++ b/examples/bbdev_app/main.c @@ -312,6 +312,7 @@ check_port_link_status(uint16_t port_id) #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ uint8_t count; struct rte_eth_link link; + int link_get_err = -EINVAL; printf("\nChecking link status."); fflush(stdout); @@ -319,9 +320,9 @@ check_port_link_status(uint16_t port_id) for (count = 0; count <= MAX_CHECK_TIME && !rte_atomic16_read(&global_exit_flag); count++) { memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(port_id, &link); + link_get_err = rte_eth_link_get_nowait(port_id, &link); - if (link.link_status) { + if (link_get_err >= 0 && link.link_status) { const char *dp = (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? "full-duplex" : "half-duplex"; @@ -334,7 +335,12 @@ check_port_link_status(uint16_t port_id) rte_delay_ms(CHECK_INTERVAL); } - printf("\nPort %d Link Down\n", port_id); + if (link_get_err >= 0) + printf("\nPort %d Link Down\n", port_id); + else + printf("\nGet link failed (port %d): %s\n", port_id, + rte_strerror(-link_get_err)); + return 0; } diff --git a/examples/distributor/main.c b/examples/distributor/main.c index 125ee877f3..49b4e611f9 100644 --- a/examples/distributor/main.c +++ b/examples/distributor/main.c @@ -173,12 +173,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool) return retval; struct rte_eth_link link; - rte_eth_link_get_nowait(port, &link); - while (!link.link_status) { + do { + retval = rte_eth_link_get_nowait(port, &link); + if (retval < 0) { + printf("Failed link get (port %u): %s\n", + port, rte_strerror(-retval)); + return retval; + } else if (link.link_status) + break; + printf("Waiting for Link up on port %"PRIu16"\n", port); sleep(1); - rte_eth_link_get_nowait(port, &link); - } + } while (!link.link_status); if (!link.link_status) { printf("Link down on port %"PRIu16"\n", port); diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index 43cacc0579..8393b0d609 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -124,9 +124,13 @@ int rte_ethtool_get_link(uint16_t port_id) { struct rte_eth_link link; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - rte_eth_link_get(port_id, &link); + ret = rte_eth_link_get(port_id, &link); + if (ret < 0) + return ret; + return link.link_status; } diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index f3c0206b53..85dbd7ec74 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -488,6 +488,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -497,7 +498,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c index c40cfd098b..cc9e7e7808 100644 --- a/examples/flow_filtering/main.c +++ b/examples/flow_filtering/main.c @@ -100,15 +100,19 @@ assert_link_status(void) { struct rte_eth_link link; uint8_t rep_cnt = MAX_REPEAT_TIMES; + int link_get_err = -EINVAL; memset(&link, 0, sizeof(link)); do { - rte_eth_link_get(port_id, &link); - if (link.link_status == ETH_LINK_UP) + link_get_err = rte_eth_link_get(port_id, &link); + if (link_get_err == 0 && link.link_status == ETH_LINK_UP) break; rte_delay_ms(CHECK_INTERVAL); } while (--rep_cnt); + if (link_get_err < 0) + rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n", + rte_strerror(-link_get_err)); if (link.link_status == ETH_LINK_DOWN) rte_exit(EXIT_FAILURE, ":: error: link is still down\n"); } diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 70139ee4d2..f90edc5a27 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -592,6 +592,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -601,7 +602,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index c6cf4204e2..4930310cc6 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -248,12 +248,19 @@ print_link_info(struct link *link, char *out, size_t out_size) struct rte_ether_addr mac_addr; struct rte_eth_link eth_link; uint16_t mtu; + int ret; memset(&stats, 0, sizeof(stats)); rte_eth_stats_get(link->port_id, &stats); rte_eth_macaddr_get(link->port_id, &mac_addr); - rte_eth_link_get(link->port_id, ð_link); + ret = rte_eth_link_get(link->port_id, ð_link); + if (ret < 0) { + snprintf(out, out_size, "\n%s: link get failed: %s", + link->name, rte_strerror(-ret)); + return; + } + rte_eth_dev_get_mtu(link->port_id, &mtu); snprintf(out, out_size, diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c index 744abf394f..16bcffe356 100644 --- a/examples/ip_pipeline/link.c +++ b/examples/ip_pipeline/link.c @@ -264,7 +264,8 @@ link_is_up(const char *name) return 0; /* Resource */ - rte_eth_link_get(link->port_id, &link_params); + if (rte_eth_link_get(link->port_id, &link_params) < 0) + return 0; return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1; } diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index e810e9f3f4..c822c8c58a 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -711,6 +711,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -720,7 +721,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index dac0d1843f..eda049bf55 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1632,6 +1632,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -1641,7 +1642,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 1ee3b61d1a..7389beec17 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -575,6 +575,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -584,7 +585,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/kni/main.c b/examples/kni/main.c index 1069fd08bb..8eb5b610e8 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -654,6 +654,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status\n"); fflush(stdout); @@ -663,7 +664,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) @@ -731,6 +739,7 @@ monitor_all_ports_link_status(void *arg) struct kni_port_params **p = kni_port_params_array; int prev; (void) arg; + int ret; while (monitor_links) { rte_delay_ms(500); @@ -738,7 +747,13 @@ monitor_all_ports_link_status(void *arg) if ((ports_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + RTE_LOG(ERR, APP, + "Get link failed (port %u): %s\n", + portid, rte_strerror(-ret)); + continue; + } for (i = 0; i < p[portid]->nb_kni; i++) { prev = rte_kni_update_link(p[portid]->kni[i], link.link_status); diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index c4ef310312..7c84b40ff5 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1731,6 +1731,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -1740,7 +1741,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index 3dd6e45b86..4f930d0977 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -685,6 +685,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -694,7 +695,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 708f44ee0d..21278eed72 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -450,6 +450,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -459,7 +460,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index db070a18be..6b9f09a4d9 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -449,6 +449,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -462,7 +463,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index c974a357be..0abb8cb5ec 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1814,6 +1814,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -1823,7 +1824,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 8ddc9ceb1e..2e3b1d3c63 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1970,6 +1970,7 @@ check_all_ports_link_status(uint32_t port_mask) uint8_t count, all_ports_up, print_flag = 0; uint16_t portid; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -1979,7 +1980,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 9ed495ee01..7253acac46 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -718,6 +718,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -731,7 +732,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index be57e6a982..a0b75d9f6e 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -117,6 +117,7 @@ print_stats(void) const char clr[] = { 27, '[', '2', 'J', '\0' }; const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' }; + int link_get_err; /* Clear screen and move to top left */ printf("%s%s", clr, topLeft); @@ -129,7 +130,7 @@ print_stats(void) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + link_get_err = rte_eth_link_get_nowait(portid, &link); printf("\nStatistics for port %u ------------------------------" "\nLink status: %25s" "\nLink speed: %26u" @@ -138,8 +139,11 @@ print_stats(void) "\nPackets received: %20"PRIu64 "\nPackets dropped: %21"PRIu64, portid, + link_get_err < 0 ? "Link get failed" : (link.link_status ? "Link up" : "Link down"), - (unsigned)link.link_speed, + link_get_err < 0 ? 0 : + (unsigned int)link.link_speed, + link_get_err < 0 ? "Link get failed" : (link.link_duplex == ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"), port_statistics[portid].tx, @@ -438,13 +442,19 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, void *ret_param) { struct rte_eth_link link; + int ret; RTE_SET_USED(param); RTE_SET_USED(ret_param); printf("\n\nIn registered callback...\n"); printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event"); - rte_eth_link_get_nowait(port_id, &link); + ret = rte_eth_link_get_nowait(port_id, &link); + if (ret < 0) { + printf("Failed link get on port %d: %s\n", + port_id, rte_strerror(-ret)); + return ret; + } if (link.link_status) { printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, @@ -465,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint8_t count, all_ports_up, print_flag = 0; uint16_t portid; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -474,7 +485,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index 4d49c9514a..7622267547 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -331,6 +331,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; uint32_t n_rx_queues, n_tx_queues; printf("\nChecking link status"); @@ -345,7 +346,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) if ((n_rx_queues == 0) && (n_tx_queues == 0)) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c index e55def84b5..3d4a9cdfa8 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -184,6 +184,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -193,7 +194,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) if ((port_mask & (1 << ports->id[portid])) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(ports->id[portid], &link); + ret = rte_eth_link_get_nowait(ports->id[portid], &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index 95058a5dc5..7f491452a7 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -364,6 +364,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -373,7 +374,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 9e25f064ed..de05219228 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -3432,6 +3432,7 @@ check_all_ports_link_status(uint32_t port_mask) uint16_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -3441,7 +3442,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c index dbdbdefea7..32e6e1ba2d 100644 --- a/examples/qos_sched/init.c +++ b/examples/qos_sched/init.c @@ -154,7 +154,12 @@ app_init_port(uint16_t portid, struct rte_mempool *mp) printf("done: "); /* get link status */ - rte_eth_link_get(portid, &link); + ret = rte_eth_link_get(portid, &link); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_link_get: err=%d, port=%u: %s\n", + ret, portid, rte_strerror(-ret)); + if (link.link_status) { printf(" Link Up - speed %u Mbps - %s\n", (uint32_t) link.link_speed, @@ -295,7 +300,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid) uint32_t pipe, subport; int err; - rte_eth_link_get(portid, &link); + err = rte_eth_link_get(portid, &link); + if (err < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_link_get: err=%d, port=%u: %s\n", + err, portid, rte_strerror(-err)); port_params.socket = socketid; port_params.rate = (uint64_t) link.link_speed * 1000 * 1000 / 8; diff --git a/examples/server_node_efd/server/init.c b/examples/server_node_efd/server/init.c index 335741a8fc..00e2e40599 100644 --- a/examples/server_node_efd/server/init.c +++ b/examples/server_node_efd/server/init.c @@ -246,6 +246,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint8_t count, all_ports_up, print_flag = 0; uint16_t portid; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -255,7 +256,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) if ((port_mask & (1 << info->id[portid])) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(info->id[portid], &link); + ret = rte_eth_link_get_nowait(info->id[portid], &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 3778b538c8..ed18177574 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -237,6 +237,7 @@ check_all_ports_link_status(uint32_t port_mask) #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ uint16_t portid, count, all_ports_up, print_flag = 0; struct rte_eth_link link; + int ret; printf("\nChecking link status"); fflush(stdout); @@ -250,7 +251,14 @@ check_all_ports_link_status(uint32_t port_mask) if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get_nowait(portid, &link); + ret = rte_eth_link_get_nowait(portid, &link); + if (ret < 0) { + all_ports_up = 0; + if (print_flag == 1) + printf("Port %u link get failed: %s\n", + portid, rte_strerror(-ret)); + continue; + } /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) -- 2.20.1