[16/18] examples/distributor: check status of getting link info

Message ID 1568103959-25572-17-git-send-email-arybchenko@solarflare.com
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: change link status get functions return value to int
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Sept. 10, 2019, 8:25 a.m.
From: Igor Romanov <igor.romanov@oktetlabs.ru>

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>
---
 examples/distributor/main.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Patch

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 125ee877f..49b4e611f 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);