examples/l2fwd-event: add graceful teardown
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Wed, 30 Oct 2019 16:26:50 +0000 (21:56 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 4 Nov 2019 17:09:33 +0000 (18:09 +0100)
Add graceful teardown that addresses both event mode and poll mode.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
examples/l2fwd-event/main.c

index 01eb19f..142c00e 100644 (file)
@@ -426,7 +426,7 @@ main(int argc, char **argv)
        uint16_t port_id, last_port;
        uint32_t nb_mbufs;
        uint16_t nb_ports;
-       int ret;
+       int i, ret;
 
        /* init EAL */
        ret = rte_eal_init(argc, argv);
@@ -532,16 +532,46 @@ main(int argc, char **argv)
        rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, rsrc,
                                 SKIP_MASTER);
        l2fwd_event_print_stats(rsrc);
-       rte_eal_mp_wait_lcore();
+       if (rsrc->event_mode) {
+               struct l2fwd_event_resources *evt_rsrc =
+                                                       rsrc->evt_rsrc;
+               for (i = 0; i < evt_rsrc->rx_adptr.nb_rx_adptr; i++)
+                       rte_event_eth_rx_adapter_stop(
+                               evt_rsrc->rx_adptr.rx_adptr[i]);
+               for (i = 0; i < evt_rsrc->tx_adptr.nb_tx_adptr; i++)
+                       rte_event_eth_tx_adapter_stop(
+                               evt_rsrc->tx_adptr.tx_adptr[i]);
 
-       RTE_ETH_FOREACH_DEV(port_id) {
-               if ((rsrc->enabled_port_mask &
-                                               (1 << port_id)) == 0)
-                       continue;
-               printf("Closing port %d...", port_id);
-               rte_eth_dev_stop(port_id);
-               rte_eth_dev_close(port_id);
-               printf(" Done\n");
+               RTE_ETH_FOREACH_DEV(port_id) {
+                       if ((rsrc->enabled_port_mask &
+                                                       (1 << port_id)) == 0)
+                               continue;
+                       rte_eth_dev_stop(port_id);
+               }
+
+               rte_eal_mp_wait_lcore();
+               RTE_ETH_FOREACH_DEV(port_id) {
+                       if ((rsrc->enabled_port_mask &
+                                                       (1 << port_id)) == 0)
+                               continue;
+                       rte_eth_dev_close(port_id);
+               }
+
+               rte_event_dev_stop(evt_rsrc->event_d_id);
+               rte_event_dev_close(evt_rsrc->event_d_id);
+
+       } else {
+               rte_eal_mp_wait_lcore();
+
+               RTE_ETH_FOREACH_DEV(port_id) {
+                       if ((rsrc->enabled_port_mask &
+                                                       (1 << port_id)) == 0)
+                               continue;
+                       printf("Closing port %d...", port_id);
+                       rte_eth_dev_stop(port_id);
+                       rte_eth_dev_close(port_id);
+                       printf(" Done\n");
+               }
        }
        printf("Bye...\n");