examples: add flush after stats printing
[dpdk.git] / examples / l2fwd-crypto / main.c
index 9a370f2..827da9b 100644 (file)
@@ -334,6 +334,8 @@ print_stats(void)
                   total_packets_dropped,
                   total_packets_errors);
        printf("\n====================================================\n");
+
+       fflush(stdout);
 }
 
 static int
@@ -1731,6 +1733,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 +1743,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)
@@ -1748,7 +1758,7 @@ check_all_ports_link_status(uint32_t port_mask)
                                        "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"));
+                                       ("full-duplex") : ("half-duplex"));
                                else
                                        printf("Port %d Link Down\n", portid);
                                continue;
@@ -2574,9 +2584,20 @@ initialize_ports(struct l2fwd_crypto_options *options)
                        return -1;
                }
 
-               rte_eth_promiscuous_enable(portid);
+               retval = rte_eth_promiscuous_enable(portid);
+               if (retval != 0) {
+                       printf("rte_eth_promiscuous_enable:err=%s, port=%u\n",
+                               rte_strerror(-retval), portid);
+                       return -1;
+               }
 
-               rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
+               retval = rte_eth_macaddr_get(portid,
+                                            &l2fwd_ports_eth_addr[portid]);
+               if (retval < 0) {
+                       printf("rte_eth_macaddr_get :err=%d, port=%u\n",
+                                       retval, portid);
+                       return -1;
+               }
 
                printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
                                portid,