examples: use new link status print format
authorIvan Dyukov <i.dyukov@samsung.com>
Tue, 15 Sep 2020 19:07:02 +0000 (22:07 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 21 Sep 2020 16:05:38 +0000 (18:05 +0200)
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>
26 files changed:
examples/bbdev_app/main.c
examples/ioat/ioatfwd.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/cli.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/kni/main.c
examples/l2fwd-crypto/main.c
examples/l2fwd-event/main.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-graph/main.c
examples/l3fwd-power/main.c
examples/l3fwd/Makefile
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/symmetric_mp/main.c
examples/ntb/ntb_fwd.c
examples/performance-thread/l3fwd-thread/main.c
examples/qos_sched/init.c
examples/server_node_efd/server/init.c
examples/vm_power_manager/main.c

index 68a4605..6a7a03c 100644 (file)
@@ -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(".");
index 43a1984..288a75c 100644 (file)
@@ -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) {
@@ -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;
 }
index 4afb971..c7348be 100644 (file)
@@ -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);
@@ -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 */
index d79699e..dafc95a 100644 (file)
@@ -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"
@@ -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,
index 550fb53..c4c9603 100644 (file)
@@ -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);
@@ -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 */
index 8ba15d2..60132c4 100644 (file)
@@ -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);
@@ -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 */
index 7e255c3..a51b584 100644 (file)
@@ -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);
@@ -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 */
index f5d12a5..2223bd3 100644 (file)
@@ -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);
@@ -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 */
@@ -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);
 }
 
 /*
index 827da9b..820470d 100644 (file)
@@ -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);
@@ -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 */
index 6f20766..9f831b1 100644 (file)
@@ -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);
@@ -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 */
index 29d5705..1dbe066 100644 (file)
@@ -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);
@@ -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 */
index 35d10e5..d0e8bf3 100644 (file)
@@ -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);
@@ -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 */
index b5fb905..7e30787 100644 (file)
@@ -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);
@@ -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 */
index 112ec3d..4386584 100644 (file)
@@ -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);
@@ -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 */
index d3fcf41..2306ba9 100644 (file)
@@ -596,6 +596,7 @@ check_all_ports_link_status(uint32_t port_mask)
        struct rte_eth_link link;
        uint16_t portid;
        int ret;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -620,16 +621,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\n"));
-                               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 */
index afa38c1..d0e6c9b 100644 (file)
@@ -2134,6 +2134,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        struct rte_eth_link link;
        int ret;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -2153,15 +2154,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", (uint8_t)portid,
-                                               (unsigned)link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               (uint8_t)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 */
index d87eafc..7e70bbd 100644 (file)
@@ -24,6 +24,8 @@ PKGCONF ?= pkg-config
 
 PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
 CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk)
+# Added for 'rte_eth_link_to_str()'
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
 LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
 
index de6c622..80f3434 100644 (file)
@@ -807,6 +807,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);
@@ -830,14 +831,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 */
index d1ce6ab..e20a7e2 100644 (file)
@@ -133,7 +133,7 @@ print_stats(void)
                link_get_err = rte_eth_link_get_nowait(portid, &link);
                printf("\nStatistics for port %u ------------------------------"
                           "\nLink status: %25s"
-                          "\nLink speed: %26u"
+                          "\nLink speed: %26s"
                           "\nLink duplex: %25s"
                           "\nPackets sent: %24"PRIu64
                           "\nPackets received: %20"PRIu64
@@ -141,8 +141,8 @@ print_stats(void)
                           portid,
                           link_get_err < 0 ? "Link get failed" :
                           (link.link_status ? "Link up" : "Link down"),
-                          link_get_err < 0 ? 0 :
-                                       (unsigned int)link.link_speed,
+                          link_get_err < 0 ? "0" :
+                          rte_eth_link_speed_to_str(link.link_speed),
                           link_get_err < 0 ? "Link get failed" :
                           (link.link_duplex == ETH_LINK_FULL_DUPLEX ? \
                                        "full-duplex" : "half-duplex"),
@@ -442,6 +442,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param,
 {
        struct rte_eth_link link;
        int ret;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        RTE_SET_USED(param);
        RTE_SET_USED(ret_param);
@@ -454,13 +455,8 @@ 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), &link);
+       printf("Port %d %s\n\n", port_id, link_status_text);
 
        return 0;
 }
@@ -475,6 +471,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[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -494,14 +491,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), &link);
+                               printf("Port %d %s", portid,
+                                      link_status_text);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
index c2ec07a..1ad71ca 100644 (file)
@@ -185,6 +185,7 @@ check_all_ports_link_status(uint16_t port_num, 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);
@@ -204,15 +205,11 @@ 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", ports->id[portid],
-                                               (unsigned)link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               (uint8_t)ports->id[portid]);
+                               rte_eth_link_to_str(link_status_text,
+                                       sizeof(link_status_text), &link);
+                               printf("Port %d %s\n",
+                                      ports->id[portid],
+                                      link_status_text);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
index 9a16e19..33643d3 100644 (file)
@@ -365,6 +365,7 @@ check_all_ports_link_status(uint16_t port_num, 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);
@@ -384,14 +385,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), &link);
+                               printf("Port %d %s\n", portid,
+                                      link_status_text);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
index 5a8439b..139da54 100644 (file)
@@ -729,6 +729,7 @@ start_pkt_fwd(void)
        struct rte_eth_link eth_link;
        uint32_t lcore_id;
        int ret, i;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        ret = ntb_fwd_config_setup();
        if (ret < 0) {
@@ -747,11 +748,11 @@ start_pkt_fwd(void)
                                return;
                        }
                        if (eth_link.link_status) {
-                               printf("Eth%u Link Up. Speed %u Mbps - %s\n",
-                                       eth_port_id, eth_link.link_speed,
-                                       (eth_link.link_duplex ==
-                                        ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
+                               rte_eth_link_to_str(link_status_text,
+                                       sizeof(link_status_text),
+                                       &eth_link);
+                               printf("Eth%u %s\n", eth_port_id,
+                                      link_status_text);
                                break;
                        }
                }
index e32802a..818e483 100644 (file)
@@ -3430,6 +3430,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);
@@ -3449,14 +3450,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 */
index 9626c15..06328dd 100644 (file)
@@ -76,6 +76,7 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)
        uint16_t rx_size;
        uint16_t tx_size;
        struct rte_eth_conf local_port_conf = port_conf;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        /* check if port already initialized (multistream configuration) */
        if (app_inited_port_mask & (1u << portid))
@@ -160,14 +161,9 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)
                         "rte_eth_link_get: err=%d, port=%u: %s\n",
                         ret, portid, rte_strerror(-ret));
 
-       if (link.link_status) {
-               printf(" Link Up - speed %u Mbps - %s\n",
-                       (uint32_t) link.link_speed,
-                       (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                       ("full-duplex") : ("half-duplex"));
-       } else {
-               printf(" Link Down\n");
-       }
+       rte_eth_link_to_str(link_status_text, sizeof(link_status_text), &link);
+       printf("%s\n", link_status_text);
+
        ret = rte_eth_promiscuous_enable(portid);
        if (ret != 0)
                rte_exit(EXIT_FAILURE,
index 378a74f..347737c 100644 (file)
@@ -247,6 +247,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[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -266,16 +267,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",
-                                               info->id[portid],
-                                               link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               info->id[portid]);
+                               rte_eth_link_to_str(link_status_text,
+                                       sizeof(link_status_text), &link);
+                               printf("Port %d %s\n", info->id[portid],
+                                      link_status_text);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
index 3a89580..44d2508 100644 (file)
@@ -246,6 +246,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid, 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);
@@ -269,15 +270,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", (uint16_t)portid,
-                                               (unsigned int)link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex"));
-                               else
-                                       printf("Port %d Link Down\n",
-                                               (uint16_t)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 */