[v6,14/25] examples/kni: new link status print format
diff mbox series

Message ID 20200706203743.29416-15-i.dyukov@samsung.com
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series
  • ethdev: allow unknown link speed
Related show

Checks

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

Commit Message

Ivan Dyukov July 6, 2020, 8:37 p.m. UTC
Add usage of rte_eth_link_strf function to example
applications

Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
---
 examples/kni/main.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

Patch
diff mbox series

diff --git a/examples/kni/main.c b/examples/kni/main.c
index f5d12a5b8..8ad7fb532 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -661,6 +661,7 @@  check_all_ports_link_status(uint32_t port_mask)
 	uint8_t count, all_ports_up, print_flag = 0;
 	struct rte_eth_link link;
 	int ret;
+	char link_status_text[60];
 
 	printf("\nChecking link status\n");
 	fflush(stdout);
@@ -680,14 +681,9 @@  check_all_ports_link_status(uint32_t port_mask)
 			}
 			/* print link status if flag set */
 			if (print_flag == 1) {
-				if (link.link_status)
-					printf(
-					"Port%d Link Up - speed %uMbps - %s\n",
-						portid, link.link_speed,
-				(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-					("full-duplex") : ("half-duplex"));
-				else
-					printf("Port %d Link Down\n", portid);
+				rte_eth_link_strf(link_status_text, 60, NULL,
+						    &link);
+				printf("Port %d %s", portid, link_status_text);
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
@@ -717,19 +713,15 @@  check_all_ports_link_status(uint32_t port_mask)
 static void
 log_link_state(struct rte_kni *kni, int prev, struct rte_eth_link *link)
 {
+	char link_status_text[60];
 	if (kni == NULL || link == NULL)
 		return;
 
-	if (prev == ETH_LINK_DOWN && link->link_status == ETH_LINK_UP) {
-		RTE_LOG(INFO, APP, "%s NIC Link is Up %d Mbps %s %s.\n",
+	rte_eth_link_strf(link_status_text, 60, NULL, link);
+	if (prev != link->link_status)
+		RTE_LOG(INFO, APP, "%s NIC %s",
 			rte_kni_get_name(kni),
-			link->link_speed,
-			link->link_autoneg ?  "(AutoNeg)" : "(Fixed)",
-			link->link_duplex ?  "Full Duplex" : "Half Duplex");
-	} else if (prev == ETH_LINK_UP && link->link_status == ETH_LINK_DOWN) {
-		RTE_LOG(INFO, APP, "%s NIC Link is Down.\n",
-			rte_kni_get_name(kni));
-	}
+			link_status_text);
 }
 
 /*