On 9/15/2020 8:07 PM, Ivan Dyukov wrote:
Add usage of rte_eth_link_to_str function to example
applications:
* ipv4_multicast
* l2fwd-jobstats
* l2fwd-keepalive
* l3fwd
* link_status_interrupt
Signed-off-by: Ivan Dyukov <i.dyu...@samsung.com>
<...>
@@ -457,13 +458,9 @@ lsi_event_callback(uint16_t port_id, enum
rte_eth_event_type type, void *param,
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,
- (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex"));
- } else
- printf("Port %d Link Down\n\n", port_id);
+ rte_eth_link_to_str(link_status_text, sizeof(link_status_text),
+ NULL, &link);
There is additional parameter, should be removed.
+ printf("Port %d %s\n\n", port_id, link_status_text);
return 0;
}
@@ -478,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t
port_mask)
uint16_t portid;
struct rte_eth_link link;
int ret;
+ char link_status_text[ETH_LINK_MAX_STR_LEN];
printf("\nChecking link status");
fflush(stdout);
@@ -497,14 +495,10 @@ 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)
- 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"));
- else
- printf("Port %d Link Down\n", portid);
+ rte_eth_link_to_str(link_status_text,
+ sizeof(link_status_text), NULL, &link);
ditto.
+ printf("Port %d %s", portid,
+ link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */