app/testpmd: add command to print representor info
[dpdk.git] / examples / l3fwd-graph / main.c
index d3fcf41..a0de8ca 100644 (file)
@@ -167,8 +167,8 @@ check_lcore_params(void)
                        return -1;
                }
 
-               if (lcore == rte_get_master_lcore()) {
-                       printf("Error: lcore %u is master lcore\n", lcore);
+               if (lcore == rte_get_main_lcore()) {
+                       printf("Error: lcore %u is main lcore\n", lcore);
                        return -1;
                }
                socketid = rte_lcore_to_socket_id(lcore);
@@ -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 */
@@ -696,7 +691,7 @@ print_stats(void)
        rte_graph_cluster_stats_destroy(stats);
 }
 
-/* Main processing loop */
+/* Main processing loop. 8< */
 static int
 graph_main_loop(void *conf)
 {
@@ -725,12 +720,14 @@ graph_main_loop(void *conf)
 
        return 0;
 }
+/* >8 End of main processing loop. */
 
 int
 main(int argc, char **argv)
 {
        /* Rewrite data of src and dst ether addr */
        uint8_t rewrite_data[2 * sizeof(struct rte_ether_addr)];
+       /* Graph initialization. 8< */
        static const char * const default_patterns[] = {
                "ip4*",
                "ethdev_tx-*",
@@ -787,7 +784,7 @@ main(int argc, char **argv)
        nb_ports = rte_eth_dev_count_avail();
        nb_lcores = rte_lcore_count();
 
-       /* Initialize all ports */
+       /* Initialize all ports. 8< */
        RTE_ETH_FOREACH_DEV(portid)
        {
                struct rte_eth_conf local_port_conf = port_conf;
@@ -967,6 +964,7 @@ main(int argc, char **argv)
 
        /* Ethdev node config, skip rx queue mapping */
        ret = rte_node_eth_config(ethdev_conf, nb_conf, nb_graphs);
+       /* >8 End of graph creation. */
        if (ret)
                rte_exit(EXIT_FAILURE, "rte_node_eth_config: err=%d\n", ret);
 
@@ -1042,6 +1040,7 @@ main(int argc, char **argv)
 
                qconf->graph_id = graph_id;
                qconf->graph = rte_graph_lookup(qconf->name);
+               /* >8 End of graph initialization. */
                if (!qconf->graph)
                        rte_exit(EXIT_FAILURE,
                                 "rte_graph_lookup(): graph %s not found\n",
@@ -1051,7 +1050,7 @@ main(int argc, char **argv)
        memset(&rewrite_data, 0, sizeof(rewrite_data));
        rewrite_len = sizeof(rewrite_data);
 
-       /* Add route to ip4 graph infra */
+       /* Add route to ip4 graph infra. 8< */
        for (i = 0; i < IPV4_L3FWD_LPM_NUM_ROUTES; i++) {
                char route_str[INET6_ADDRSTRLEN * 4];
                char abuf[INET6_ADDRSTRLEN];
@@ -1095,17 +1094,18 @@ main(int argc, char **argv)
                RTE_LOG(INFO, L3FWD_GRAPH, "Added route %s, next_hop %u\n",
                        route_str, i);
        }
+       /* >8 End of adding route to ip4 graph infa. */
 
-       /* Launch per-lcore init on every slave lcore */
-       rte_eal_mp_remote_launch(graph_main_loop, NULL, SKIP_MASTER);
+       /* Launch per-lcore init on every worker lcore */
+       rte_eal_mp_remote_launch(graph_main_loop, NULL, SKIP_MAIN);
 
-       /* Accumulate and print stats on master until exit */
+       /* Accumulate and print stats on main until exit */
        if (rte_graph_has_stats_feature())
                print_stats();
 
-       /* Wait for slave cores to exit */
+       /* Wait for worker cores to exit */
        ret = 0;
-       RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+       RTE_LCORE_FOREACH_WORKER(lcore_id) {
                ret = rte_eal_wait_lcore(lcore_id);
                /* Destroy graph */
                if (ret < 0 || rte_graph_destroy(
@@ -1121,10 +1121,16 @@ main(int argc, char **argv)
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
                printf("Closing port %d...", portid);
-               rte_eth_dev_stop(portid);
+               ret = rte_eth_dev_stop(portid);
+               if (ret != 0)
+                       printf("Failed to stop port %u: %s\n",
+                              portid, rte_strerror(-ret));
                rte_eth_dev_close(portid);
                printf(" Done\n");
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
        printf("Bye...\n");
 
        return ret;