cryptodev: rename function to check device validity
[dpdk.git] / examples / l2fwd-keepalive / main.c
index b274263..4e1a17c 100644 (file)
@@ -227,7 +227,7 @@ l2fwd_main_loop(void)
        uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz();
 
        while (!terminate_signal_received) {
-               /* Keepalive heartbeat */
+               /* Keepalive heartbeat. 8< */
                rte_keepalive_mark_alive(rte_global_keepalive_info);
 
                cur_tsc = rte_rdtsc();
@@ -238,6 +238,7 @@ l2fwd_main_loop(void)
                 */
                if (check_period > 0 && cur_tsc - tsc_initial > tsc_lifetime)
                        break;
+               /* >8 End of keepalive heartbeat. */
 
                /*
                 * TX burst queue drain
@@ -307,10 +308,7 @@ l2fwd_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;
 }
@@ -453,6 +451,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);
@@ -472,14 +471,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 */
@@ -766,10 +761,12 @@ main(int argc, char **argv)
                if (ka_shm == NULL)
                        rte_exit(EXIT_FAILURE,
                                "rte_keepalive_shm_create() failed");
+               /* Initialize keepalive functionality. 8< */
                rte_global_keepalive_info =
                        rte_keepalive_create(&dead_core, ka_shm);
                if (rte_global_keepalive_info == NULL)
                        rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+               /* >8 End of initializing keepalive functionality. */
                rte_keepalive_register_relay_callback(rte_global_keepalive_info,
                        relay_core_state, ka_shm);
                rte_timer_init(&hb_timer);
@@ -784,6 +781,7 @@ main(int argc, char **argv)
                        rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
        }
        if (timer_period > 0) {
+               /* Issues the pings keepalive_dispatch_pings(). 8< */
                if (rte_timer_reset(&stats_timer,
                                (timer_period * rte_get_timer_hz()) / 1000,
                                PERIODICAL,
@@ -791,9 +789,10 @@ main(int argc, char **argv)
                                &print_stats, NULL
                                ) != 0 )
                        rte_exit(EXIT_FAILURE, "Stats setup failure.\n");
+               /* >8 End of issuing the pings keepalive_dispatch_pings(). */
        }
-       /* launch per-lcore init on every slave lcore */
-       RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+       /* launch per-lcore init on every worker lcore */
+       RTE_LCORE_FOREACH_WORKER(lcore_id) {
                struct lcore_queue_conf *qconf = &lcore_queue_conf[lcore_id];
 
                if (qconf->n_rx_port == 0)
@@ -816,12 +815,16 @@ main(int argc, char **argv)
                rte_delay_ms(5);
                }
 
-       RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+       RTE_LCORE_FOREACH_WORKER(lcore_id) {
                if (rte_eal_wait_lcore(lcore_id) < 0)
                        return -1;
        }
 
        if (ka_shm != NULL)
                rte_keepalive_shm_cleanup(ka_shm);
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }