]> git.droids-corp.org - dpdk.git/commitdiff
examples: check status of getting link info
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Tue, 10 Sep 2019 08:25:50 +0000 (09:25 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:54 +0000 (15:00 +0200)
The return value of rte_eth_link_get() and rte_eth_link_get_nowait()
was changed from void to int. Update the usage of the functions
according to the new return type.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
27 files changed:
examples/bbdev_app/main.c
examples/distributor/main.c
examples/ethtool/lib/rte_ethtool.c
examples/exception_path/main.c
examples/flow_filtering/main.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/cli.c
examples/ip_pipeline/link.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-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-power/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/init.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/symmetric_mp/main.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 3d36629a1b1fb5f69009e52ed37bfbe91bf772bc..3498765896f1ce5634bb556f2042c72d68cb52ef 100644 (file)
@@ -312,6 +312,7 @@ check_port_link_status(uint16_t port_id)
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
        uint8_t count;
        struct rte_eth_link link;
+       int link_get_err = -EINVAL;
 
        printf("\nChecking link status.");
        fflush(stdout);
@@ -319,9 +320,9 @@ check_port_link_status(uint16_t port_id)
        for (count = 0; count <= MAX_CHECK_TIME &&
                        !rte_atomic16_read(&global_exit_flag); count++) {
                memset(&link, 0, sizeof(link));
-               rte_eth_link_get_nowait(port_id, &link);
+               link_get_err = rte_eth_link_get_nowait(port_id, &link);
 
-               if (link.link_status) {
+               if (link_get_err >= 0 && link.link_status) {
                        const char *dp = (link.link_duplex ==
                                ETH_LINK_FULL_DUPLEX) ?
                                "full-duplex" : "half-duplex";
@@ -334,7 +335,12 @@ check_port_link_status(uint16_t port_id)
                rte_delay_ms(CHECK_INTERVAL);
        }
 
-       printf("\nPort %d Link Down\n", port_id);
+       if (link_get_err >= 0)
+               printf("\nPort %d Link Down\n", port_id);
+       else
+               printf("\nGet link failed (port %d): %s\n", port_id,
+                      rte_strerror(-link_get_err));
+
        return 0;
 }
 
index 125ee877f3f59cdcc0f9a1c2b091654e1039f657..49b4e611f9f2b500c68260aed4837e002dbf7e6d 100644 (file)
@@ -173,12 +173,18 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                return retval;
 
        struct rte_eth_link link;
-       rte_eth_link_get_nowait(port, &link);
-       while (!link.link_status) {
+       do {
+               retval = rte_eth_link_get_nowait(port, &link);
+               if (retval < 0) {
+                       printf("Failed link get (port %u): %s\n",
+                               port, rte_strerror(-retval));
+                       return retval;
+               } else if (link.link_status)
+                       break;
+
                printf("Waiting for Link up on port %"PRIu16"\n", port);
                sleep(1);
-               rte_eth_link_get_nowait(port, &link);
-       }
+       } while (!link.link_status);
 
        if (!link.link_status) {
                printf("Link down on port %"PRIu16"\n", port);
index 43cacc05795ab630f1d3a7e332fa8df608b3036c..8393b0d609d5dfd375c550ef1ac1439b56cb7ef5 100644 (file)
@@ -124,9 +124,13 @@ int
 rte_ethtool_get_link(uint16_t port_id)
 {
        struct rte_eth_link link;
+       int ret;
 
        RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-       rte_eth_link_get(port_id, &link);
+       ret = rte_eth_link_get(port_id, &link);
+       if (ret < 0)
+               return ret;
+
        return link.link_status;
 }
 
index f3c0206b534a3f2ea4a1a6d648740765422427a6..85dbd7ec745255f6b7b8e469091777a372ad6f7e 100644 (file)
@@ -488,6 +488,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -497,7 +498,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index c40cfd098b43b5e1a1b2020c02d639d10bb76816..cc9e7e78081319c0bb529fba5391b6ef92a29125 100644 (file)
@@ -100,15 +100,19 @@ assert_link_status(void)
 {
        struct rte_eth_link link;
        uint8_t rep_cnt = MAX_REPEAT_TIMES;
+       int link_get_err = -EINVAL;
 
        memset(&link, 0, sizeof(link));
        do {
-               rte_eth_link_get(port_id, &link);
-               if (link.link_status == ETH_LINK_UP)
+               link_get_err = rte_eth_link_get(port_id, &link);
+               if (link_get_err == 0 && link.link_status == ETH_LINK_UP)
                        break;
                rte_delay_ms(CHECK_INTERVAL);
        } while (--rep_cnt);
 
+       if (link_get_err < 0)
+               rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n",
+                        rte_strerror(-link_get_err));
        if (link.link_status == ETH_LINK_DOWN)
                rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }
index 70139ee4d2fe932234e62c4f0bf26a5aaba16185..f90edc5a27a26b14621c5c582c6115091c05bc3f 100644 (file)
@@ -592,6 +592,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -601,7 +602,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index c6cf4204e2cc714aab56989b32653758679b4504..4930310cc6e548af4eedc5fef4defdc48fd87753 100644 (file)
@@ -248,12 +248,19 @@ print_link_info(struct link *link, char *out, size_t out_size)
        struct rte_ether_addr mac_addr;
        struct rte_eth_link eth_link;
        uint16_t mtu;
+       int ret;
 
        memset(&stats, 0, sizeof(stats));
        rte_eth_stats_get(link->port_id, &stats);
 
        rte_eth_macaddr_get(link->port_id, &mac_addr);
-       rte_eth_link_get(link->port_id, &eth_link);
+       ret = rte_eth_link_get(link->port_id, &eth_link);
+       if (ret < 0) {
+               snprintf(out, out_size, "\n%s: link get failed: %s",
+                        link->name, rte_strerror(-ret));
+               return;
+       }
+
        rte_eth_dev_get_mtu(link->port_id, &mtu);
 
        snprintf(out, out_size,
index 744abf394facd23e154ae5cbff46beb0c29dc784..16bcffe356bcb2a06288484168403ec4f35260c5 100644 (file)
@@ -264,7 +264,8 @@ link_is_up(const char *name)
                return 0;
 
        /* Resource */
-       rte_eth_link_get(link->port_id, &link_params);
+       if (rte_eth_link_get(link->port_id, &link_params) < 0)
+               return 0;
 
        return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1;
 }
index e810e9f3f448f4daa4eb20b7d5a2cd97ce51f835..c822c8c58a842f89c9943738eb08f0413cfdfe33 100644 (file)
@@ -711,6 +711,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -720,7 +721,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index dac0d1843fd1d5bf84f9b9cbe383f82dbb96d487..eda049bf55d015a7f9c50c71dc6a03790de54471 100644 (file)
@@ -1632,6 +1632,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -1641,7 +1642,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 1ee3b61d1aa4a817ae403f60a550d4e64c82f31b..7389beec17bc1cf5c909e5e4623a709cd7b0166f 100644 (file)
@@ -575,6 +575,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -584,7 +585,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 1069fd08bbfd9b8b311311f54828730d1c750b57..8eb5b610e88d9abd5a886a7d4615e8702f610371 100644 (file)
@@ -654,6 +654,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status\n");
        fflush(stdout);
@@ -663,7 +664,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
@@ -731,6 +739,7 @@ monitor_all_ports_link_status(void *arg)
        struct kni_port_params **p = kni_port_params_array;
        int prev;
        (void) arg;
+       int ret;
 
        while (monitor_links) {
                rte_delay_ms(500);
@@ -738,7 +747,13 @@ monitor_all_ports_link_status(void *arg)
                        if ((ports_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               RTE_LOG(ERR, APP,
+                                       "Get link failed (port %u): %s\n",
+                                       portid, rte_strerror(-ret));
+                               continue;
+                       }
                        for (i = 0; i < p[portid]->nb_kni; i++) {
                                prev = rte_kni_update_link(p[portid]->kni[i],
                                                link.link_status);
index c4ef3103128172bd04eb98c89dfa3964b8eda07a..7c84b40ff501353e08fac7b233659e48460968a8 100644 (file)
@@ -1731,6 +1731,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -1740,7 +1741,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 3dd6e45b866deae7b8c815c8279f65d8c9cae848..4f930d097798a9ad1d0c213cc7786fb078b8e198 100644 (file)
@@ -685,6 +685,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -694,7 +695,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 708f44ee0d5146ce34a8438ddf5f2d919a91c3c3..21278eed72651606c7a6433f20700ef35d59d7d8 100644 (file)
@@ -450,6 +450,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -459,7 +460,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index db070a18be16dd5b95281bd2e7fc39440deff5d7..6b9f09a4d954a95349a4387aef59234d04104cfd 100644 (file)
@@ -449,6 +449,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -462,7 +463,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index c974a357be18d85a87112076fe5517440c8253c2..0abb8cb5ec888e368b432ce291834f37d033a89b 100644 (file)
@@ -1814,6 +1814,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -1823,7 +1824,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 8ddc9ceb1eb01ee1a1b84e06b5068fa02306f43d..2e3b1d3c63c2bb6381b6033b30a1096447213d68 100644 (file)
@@ -1970,6 +1970,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint8_t count, all_ports_up, print_flag = 0;
        uint16_t portid;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -1979,7 +1980,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 9ed495ee0104acd3a11b939b6848b89578c35a6b..7253acac46a4531e8c6042b7deed3de19b67ddc9 100644 (file)
@@ -718,6 +718,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -731,7 +732,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index be57e6a98221365059b75c0e23033fad731ee598..a0b75d9f6e1cea56301892024dfb63451ef89edd 100644 (file)
@@ -117,6 +117,7 @@ print_stats(void)
 
        const char clr[] = { 27, '[', '2', 'J', '\0' };
        const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
+       int link_get_err;
 
                /* Clear screen and move to top left */
        printf("%s%s", clr, topLeft);
@@ -129,7 +130,7 @@ print_stats(void)
                        continue;
 
                memset(&link, 0, sizeof(link));
-               rte_eth_link_get_nowait(portid, &link);
+               link_get_err = rte_eth_link_get_nowait(portid, &link);
                printf("\nStatistics for port %u ------------------------------"
                           "\nLink status: %25s"
                           "\nLink speed: %26u"
@@ -138,8 +139,11 @@ print_stats(void)
                           "\nPackets received: %20"PRIu64
                           "\nPackets dropped: %21"PRIu64,
                           portid,
+                          link_get_err < 0 ? "Link get failed" :
                           (link.link_status ? "Link up" : "Link down"),
-                          (unsigned)link.link_speed,
+                          link_get_err < 0 ? 0 :
+                                       (unsigned int)link.link_speed,
+                          link_get_err < 0 ? "Link get failed" :
                           (link.link_duplex == ETH_LINK_FULL_DUPLEX ? \
                                        "full-duplex" : "half-duplex"),
                           port_statistics[portid].tx,
@@ -438,13 +442,19 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param,
                    void *ret_param)
 {
        struct rte_eth_link link;
+       int ret;
 
        RTE_SET_USED(param);
        RTE_SET_USED(ret_param);
 
        printf("\n\nIn registered callback...\n");
        printf("Event type: %s\n", type == RTE_ETH_EVENT_INTR_LSC ? "LSC interrupt" : "unknown event");
-       rte_eth_link_get_nowait(port_id, &link);
+       ret = rte_eth_link_get_nowait(port_id, &link);
+       if (ret < 0) {
+               printf("Failed link get on port %d: %s\n",
+                      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,
@@ -465,6 +475,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        uint8_t count, all_ports_up, print_flag = 0;
        uint16_t portid;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -474,7 +485,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 4d49c9514ae77afd3868810bf76fa1c5f20d461b..762226754724868722480e24968de3974eafe1c4 100644 (file)
@@ -331,6 +331,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;
+       int ret;
        uint32_t n_rx_queues, n_tx_queues;
 
        printf("\nChecking link status");
@@ -345,7 +346,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                        if ((n_rx_queues == 0) && (n_tx_queues == 0))
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index e55def84b5b95cdc00846173d532a02241e3f300..3d4a9cdfa8592b27bd5594ee37b268b806b2f25c 100644 (file)
@@ -184,6 +184,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;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -193,7 +194,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                        if ((port_mask & (1 << ports->id[portid])) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(ports->id[portid], &link);
+                       ret = rte_eth_link_get_nowait(ports->id[portid], &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 95058a5dc58fa0a9a734752b9324a8f96973207f..7f491452a729fc18a51baeb32223fc919dba9cee 100644 (file)
@@ -364,6 +364,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;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -373,7 +374,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 9e25f064ed1e8fbed634b9a2f8ae3ee197d41e05..de052192284c6ebc4128647a6d8a30e2c74ff532 100644 (file)
@@ -3432,6 +3432,7 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -3441,7 +3442,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index dbdbdefea7069afc91ca850c1604eb81d4b8cb07..32e6e1ba2dcd1a08180e99a8d5adad9c5e96cab0 100644 (file)
@@ -154,7 +154,12 @@ app_init_port(uint16_t portid, struct rte_mempool *mp)
        printf("done: ");
 
        /* get link status */
-       rte_eth_link_get(portid, &link);
+       ret = rte_eth_link_get(portid, &link);
+       if (ret < 0)
+               rte_exit(EXIT_FAILURE,
+                        "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,
@@ -295,7 +300,11 @@ app_init_sched_port(uint32_t portid, uint32_t socketid)
        uint32_t pipe, subport;
        int err;
 
-       rte_eth_link_get(portid, &link);
+       err = rte_eth_link_get(portid, &link);
+       if (err < 0)
+               rte_exit(EXIT_FAILURE,
+                        "rte_eth_link_get: err=%d, port=%u: %s\n",
+                        err, portid, rte_strerror(-err));
 
        port_params.socket = socketid;
        port_params.rate = (uint64_t) link.link_speed * 1000 * 1000 / 8;
index 335741a8fc2dfd20b2b151595a5529cc1b1ce36d..00e2e40599fea1370b43fd12c5875d6649ca6311 100644 (file)
@@ -246,6 +246,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        uint8_t count, all_ports_up, print_flag = 0;
        uint16_t portid;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -255,7 +256,14 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                        if ((port_mask & (1 << info->id[portid])) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(info->id[portid], &link);
+                       ret = rte_eth_link_get_nowait(info->id[portid], &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
index 3778b538c8173d8894ee4acac1945bfbdf434b4b..ed18177574b9bace4c10de67047441443ebe9db2 100644 (file)
@@ -237,6 +237,7 @@ check_all_ports_link_status(uint32_t port_mask)
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
        uint16_t portid, count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -250,7 +251,14 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)