X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Flink_status_interrupt%2Fmain.c;h=d8ff5f133b3d0b3046d1ce66e198cfdf79a57ce0;hb=24d9c5d59d5d17804ce78fb700475251239ffba5;hp=38422f6ac5b8437203e1f45946125d747f73973f;hpb=f2fc83b40f06da6a6b2476005279ba52d4ce3c44;p=dpdk.git diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index 38422f6ac5..d8ff5f133b 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -133,7 +132,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 +140,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"), @@ -162,6 +161,8 @@ print_stats(void) total_packets_rx, total_packets_dropped); printf("\n====================================================\n"); + + fflush(stdout); } static void @@ -253,8 +254,8 @@ lsi_main_loop(void) /* if timer has reached its timeout */ if (unlikely(timer_tsc >= (uint64_t) timer_period)) { - /* do this only on master core */ - if (lcore_id == rte_get_master_lcore()) { + /* do this only on main core */ + if (lcore_id == rte_get_main_lcore()) { print_stats(); /* reset the timer */ timer_tsc = 0; @@ -312,10 +313,7 @@ lsi_parse_portmask(const char *portmask) /* parse hexadecimal string */ pm = strtoul(portmask, &end, 16); if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) - return -1; - - if (pm == 0) - return -1; + return 0; return pm; } @@ -443,6 +441,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); @@ -455,13 +454,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; } @@ -476,6 +470,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); @@ -495,14 +490,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\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", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ @@ -733,11 +724,14 @@ main(int argc, char **argv) check_all_ports_link_status(nb_ports, lsi_enabled_port_mask); /* launch per-lcore init on every lcore */ - rte_eal_mp_remote_launch(lsi_launch_one_lcore, NULL, CALL_MASTER); - RTE_LCORE_FOREACH_SLAVE(lcore_id) { + rte_eal_mp_remote_launch(lsi_launch_one_lcore, NULL, CALL_MAIN); + RTE_LCORE_FOREACH_WORKER(lcore_id) { if (rte_eal_wait_lcore(lcore_id) < 0) return -1; } + /* clean up the EAL */ + rte_eal_cleanup(); + return 0; }