Skip to content

Commit

Permalink
examples: use new link status print format
Browse files Browse the repository at this point in the history
Add usage of rte_eth_link_to_str function to example
applications.

Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
Ivan Dyukov authored and Ferruh Yigit committed Sep 21, 2020
1 parent ba5509a commit db4e813
Show file tree
Hide file tree
Showing 26 changed files with 137 additions and 211 deletions.
6 changes: 4 additions & 2 deletions examples/bbdev_app/main.c
Expand Up @@ -326,8 +326,10 @@ check_port_link_status(uint16_t port_id)
const char *dp = (link.link_duplex ==
ETH_LINK_FULL_DUPLEX) ?
"full-duplex" : "half-duplex";
printf("\nPort %u Link Up - speed %u Mbps - %s\n",
port_id, link.link_speed, dp);
printf("\nPort %u Link Up - speed %s - %s\n",
port_id,
rte_eth_link_speed_to_str(link.link_speed),
dp);
return 0;
}
printf(".");
Expand Down
14 changes: 6 additions & 8 deletions examples/ioat/ioatfwd.c
Expand Up @@ -700,6 +700,7 @@ check_link_status(uint32_t port_mask)
uint16_t portid;
struct rte_eth_link link;
int ret, link_status = 0;
char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status\n");
RTE_ETH_FOREACH_DEV(portid) {
Expand All @@ -715,15 +716,12 @@ check_link_status(uint32_t port_mask)
}

/* Print link status */
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"));
rte_eth_link_to_str(link_status_text,
sizeof(link_status_text), &link);
printf("Port %d %s\n", portid, link_status_text);

if (link.link_status)
link_status = 1;
} else
printf("Port %d Link Down\n", portid);
}
return link_status;
}
Expand Down
13 changes: 5 additions & 8 deletions examples/ip_fragmentation/main.c
Expand Up @@ -593,6 +593,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -612,14 +613,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
4 changes: 2 additions & 2 deletions examples/ip_pipeline/cli.c
Expand Up @@ -273,7 +273,7 @@ print_link_info(struct link *link, char *out, size_t out_size)
"\n"
"%s: flags=<%s> mtu %u\n"
"\tether %02X:%02X:%02X:%02X:%02X:%02X rxqueues %u txqueues %u\n"
"\tport# %u speed %u Mbps\n"
"\tport# %u speed %s\n"
"\tRX packets %" PRIu64" bytes %" PRIu64"\n"
"\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n"
"\tTX packets %" PRIu64" bytes %" PRIu64"\n"
Expand All @@ -287,7 +287,7 @@ print_link_info(struct link *link, char *out, size_t out_size)
link->n_rxq,
link->n_txq,
link->port_id,
eth_link.link_speed,
rte_eth_link_speed_to_str(eth_link.link_speed),
stats.ipackets,
stats.ibytes,
stats.ierrors,
Expand Down
13 changes: 5 additions & 8 deletions examples/ip_reassembly/main.c
Expand Up @@ -709,6 +709,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -728,14 +729,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/ipsec-secgw/ipsec-secgw.c
Expand Up @@ -1842,6 +1842,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -1861,14 +1862,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
14 changes: 6 additions & 8 deletions examples/ipv4_multicast/main.c
Expand Up @@ -572,6 +572,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -591,14 +592,11 @@ 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 %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),
&link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
27 changes: 10 additions & 17 deletions examples/kni/main.c
Expand Up @@ -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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status\n");
fflush(stdout);
Expand All @@ -680,14 +681,10 @@ 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_to_str(link_status_text,
sizeof(link_status_text), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down Expand Up @@ -717,19 +714,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[RTE_ETH_LINK_MAX_STR_LEN];
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_to_str(link_status_text, sizeof(link_status_text), 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);
}

/*
Expand Down
13 changes: 5 additions & 8 deletions examples/l2fwd-crypto/main.c
Expand Up @@ -1734,6 +1734,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -1753,14 +1754,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/l2fwd-event/main.c
Expand Up @@ -363,6 +363,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,
uint8_t count, all_ports_up, print_flag = 0;
struct rte_eth_link link;
int ret;
char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status...");
fflush(stdout);
Expand All @@ -386,14 +387,10 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc,
}
/* print link status if flag set */
if (print_flag == 1) {
if (link.link_status)
printf(
"Port%d Link Up. Speed %u Mbps - %s\n",
port_id, link.link_speed,
(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex"));
else
printf("Port %d Link Down\n", port_id);
rte_eth_link_to_str(link_status_text,
sizeof(link_status_text), &link);
printf("Port %d %s\n", port_id,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/l2fwd-jobstats/main.c
Expand Up @@ -686,6 +686,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -705,14 +706,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/l2fwd-keepalive/main.c
Expand Up @@ -450,6 +450,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -469,14 +470,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/l2fwd/main.c
Expand Up @@ -568,6 +568,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -591,14 +592,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down
13 changes: 5 additions & 8 deletions examples/l3fwd-acl/main.c
Expand Up @@ -1812,6 +1812,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[RTE_ETH_LINK_MAX_STR_LEN];

printf("\nChecking link status");
fflush(stdout);
Expand All @@ -1831,14 +1832,10 @@ 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 %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), &link);
printf("Port %d %s\n", portid,
link_status_text);
continue;
}
/* clear all_ports_up flag if any link down */
Expand Down

0 comments on commit db4e813

Please sign in to comment.