From: Pavan Nikhilesh Date: Wed, 30 Oct 2019 16:26:50 +0000 (+0530) Subject: examples/l2fwd-event: add graceful teardown X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3dd1f9fb32ea81aed8df3f75390f50f3c8715590;p=dpdk.git examples/l2fwd-event: add graceful teardown Add graceful teardown that addresses both event mode and poll mode. Signed-off-by: Pavan Nikhilesh Acked-by: Nipun Gupta Acked-by: Jerin Jacob --- diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c index 01eb19f3e8..142c00e8f5 100644 --- a/examples/l2fwd-event/main.c +++ b/examples/l2fwd-event/main.c @@ -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");