Add usage of rte_eth_link_prepare_text function to example applications Signed-off-by: Ivan Dyukov <i.dyu...@samsung.com> --- app/proc-info/main.c | 15 +++++++++------ app/test-pipeline/init.c | 11 ++++++----- app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 10 ++++++---- app/test/test_pmd_perf.c | 10 ++++++---- 5 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/app/proc-info/main.c b/app/proc-info/main.c index abeca4aab..d8506cbb2 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -669,6 +669,7 @@ show_port(void) RTE_ETH_FOREACH_DEV(i) { uint16_t mtu = 0; struct rte_eth_link link; + struct rte_eth_link_text link_text; struct rte_eth_dev_info dev_info; struct rte_eth_rxq_info queue_info; struct rte_eth_rss_conf rss_conf; @@ -685,12 +686,14 @@ show_port(void) printf("Link get failed (port %u): %s\n", i, rte_strerror(-ret)); } else { - printf("\t -- link speed %d duplex %d," - " auto neg %d status %d\n", - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); + rte_eth_link_prepare_text(&link, + ETH_SPEED_UNIT_MBPS, &link_text); + printf("\t -- link speed: %s, duplex: %s," + " auto neg: %s, status: %s\n", + link_text.link_speed, + link_text.link_duplex, + link_text.link_autoneg, + link_text.link_status); } printf("\t -- promiscuous (%d)\n", rte_eth_promiscuous_get(i)); diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c index 67d54ae05..920023825 100644 --- a/app/test-pipeline/init.c +++ b/app/test-pipeline/init.c @@ -160,6 +160,7 @@ app_ports_check_link(void) for (i = 0; i < app.n_ports; i++) { struct rte_eth_link link; + struct rte_eth_link_text link_text; uint16_t port; int ret; @@ -173,12 +174,12 @@ app_ports_check_link(void) all_ports_up = 0; continue; } - - RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n", + rte_eth_link_prepare_text(&link, + ETH_SPEED_UNIT_GBPS, &link_text); + RTE_LOG(INFO, USER1, "Port %u (%s Gbps) %s\n", port, - link.link_speed / 1000, - link.link_status ? "UP" : "DOWN"); - + link_text.link_speed, + link_text.link_status); if (link.link_status == ETH_LINK_DOWN) all_ports_up = 0; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5381207cc..722f57c12 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -552,6 +552,7 @@ port_infos_display(portid_t port_id) struct rte_port *port; struct rte_ether_addr mac_addr; struct rte_eth_link link; + struct rte_eth_link_text link_text; struct rte_eth_dev_info dev_info; int vlan_offload; struct rte_mempool * mp; @@ -600,10 +601,10 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); + rte_eth_link_prepare_text(&link, ETH_SPEED_UNIT_MBPS, &link_text); + printf("\nLink status: %s\n", link_text.link_status); + printf("Link speed: %s Mbps\n", link_text.link_speed); + printf("Link duplex: %s\n", link_text.link_duplex); if (!rte_eth_dev_get_mtu(port_id, &mtu)) printf("MTU: %u\n", mtu); @@ -724,6 +725,7 @@ port_summary_display(portid_t port_id) { struct rte_ether_addr mac_addr; struct rte_eth_link link; + struct rte_eth_link_text link_text; struct rte_eth_dev_info dev_info; char name[RTE_ETH_NAME_MAX_LEN]; int ret; @@ -746,12 +748,14 @@ port_summary_display(portid_t port_id) if (ret != 0) return; - printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n", + rte_eth_link_prepare_text(&link, ETH_SPEED_UNIT_GBPS, + &link_text); + printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n", port_id, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3], mac_addr.addr_bytes[4], mac_addr.addr_bytes[5], name, - dev_info.driver_name, (link.link_status) ? ("up") : ("down"), - (unsigned int) link.link_speed); + dev_info.driver_name, link_text.link_status, + link_text.link_speed); } void @@ -3897,7 +3901,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret = eth_link_get_nowait_print_err(port_id, &link); if (ret < 0) return 1; - if (rate > link.link_speed) { + if (link.link_speed != UINT32_MAX && rate > link.link_speed) { printf("Invalid rate value:%u bigger than link speed: %u\n", rate, link.link_speed); return 1; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9cbe6e9f6..fd78e1cea 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2987,6 +2987,7 @@ check_all_ports_link_status(uint32_t port_mask) portid_t portid; uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; + struct rte_eth_link_text link_text; int ret; printf("Checking link statuses...\n"); @@ -3007,12 +3008,13 @@ check_all_ports_link_status(uint32_t port_mask) } /* print link status if flag set */ if (print_flag == 1) { + rte_eth_link_prepare_text(&link, + ETH_SPEED_UNIT_MBPS, &link_text); if (link.link_status) printf( - "Port%d Link Up. speed %u Mbps- %s\n", - portid, link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); + "Port%d Link Up. speed %s Mbps- %s\n", + portid, link_text.link_speed, + link_text.link_duplex); else printf("Port %d Link Down\n", portid); continue; diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 352cd4715..9a275287b 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -125,6 +125,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; + struct rte_eth_link_text link_text; int ret; printf("Checking link statuses...\n"); @@ -147,11 +148,12 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) /* print link status if flag set */ if (print_flag == 1) { if (link.link_status) { + rte_eth_link_prepare_text(&link, + ETH_SPEED_UNIT_MBPS, &link_text); printf( - "Port%d Link Up. Speed %u Mbps - %s\n", - portid, link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); + "Port%d Link Up. Speed %s Mbps - %s\n", + portid, link_text.link_speed, + link_text.link_duplex); if (link_mbps == 0) link_mbps = link.link_speed; } else -- 2.17.1