summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Romanov <igor.romanov@oktetlabs.ru>2019-09-10 09:25:50 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2019-10-07 15:00:54 +0200
commit22e5c73bd181ddae758189295146154542b63360 (patch)
treec549007462855672702c8b3c6abc9ee3687b4f49
parent844949eceb8e58978d6ae41eb2345d280351bbf0 (diff)
downloaddpdk-22e5c73bd181ddae758189295146154542b63360.zip
dpdk-22e5c73bd181ddae758189295146154542b63360.tar.gz
dpdk-22e5c73bd181ddae758189295146154542b63360.tar.xz
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 <igor.romanov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
-rw-r--r--examples/bbdev_app/main.c12
-rw-r--r--examples/distributor/main.c14
-rw-r--r--examples/ethtool/lib/rte_ethtool.c6
-rw-r--r--examples/exception_path/main.c10
-rw-r--r--examples/flow_filtering/main.c8
-rw-r--r--examples/ip_fragmentation/main.c10
-rw-r--r--examples/ip_pipeline/cli.c9
-rw-r--r--examples/ip_pipeline/link.c3
-rw-r--r--examples/ip_reassembly/main.c10
-rw-r--r--examples/ipsec-secgw/ipsec-secgw.c10
-rw-r--r--examples/ipv4_multicast/main.c10
-rw-r--r--examples/kni/main.c19
-rw-r--r--examples/l2fwd-crypto/main.c10
-rw-r--r--examples/l2fwd-jobstats/main.c10
-rw-r--r--examples/l2fwd-keepalive/main.c10
-rw-r--r--examples/l2fwd/main.c10
-rw-r--r--examples/l3fwd-acl/main.c10
-rw-r--r--examples/l3fwd-power/main.c10
-rw-r--r--examples/l3fwd/main.c10
-rw-r--r--examples/link_status_interrupt/main.c26
-rw-r--r--examples/load_balancer/init.c10
-rw-r--r--examples/multi_process/client_server_mp/mp_server/init.c10
-rw-r--r--examples/multi_process/symmetric_mp/main.c10
-rw-r--r--examples/performance-thread/l3fwd-thread/main.c10
-rw-r--r--examples/qos_sched/init.c13
-rw-r--r--examples/server_node_efd/server/init.c10
-rw-r--r--examples/vm_power_manager/main.c10
27 files changed, 252 insertions, 38 deletions
diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 3d36629..3498765 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 125ee87..49b4e61 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 43cacc0..8393b0d 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 f3c0206..85dbd7e 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 c40cfd0..cc9e7e7 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 70139ee..f90edc5 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 c6cf420..4930310 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, &eth_link);
+ ret = rte_eth_link_get(link->port_id, &eth_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 744abf3..16bcffe 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 e810e9f..c822c8c 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 dac0d18..eda049b 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 1ee3b61..7389bee 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 1069fd0..8eb5b61 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 c4ef310..7c84b40 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 3dd6e45..4f930d0 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 708f44e..21278ee 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 db070a1..6b9f09a 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 c974a35..0abb8cb 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 8ddc9ce..2e3b1d3 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 9ed495e..7253aca 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 be57e6a..a0b75d9 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 4d49c95..7622267 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 e55def8..3d4a9cd 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 95058a5..7f49145 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 9e25f06..de05219 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 dbdbdef..32e6e1b 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 335741a..00e2e40 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 3778b53..ed18177 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)