[v6,09/10] examples/l2fwd-event: add graceful teardown

Message ID 20191014182247.961-10-pbhagavatula@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series example/l2fwd-event: introduce l2fwd-event example |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Pavan Nikhilesh Bhagavatula Oct. 14, 2019, 6:22 p.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Add graceful teardown that addresses both event mode and poll mode.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 examples/l2fwd-event/main.c | 50 +++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 10 deletions(-)
  

Comments

Varghese, Vipin Oct. 21, 2019, 3:12 a.m. UTC | #1
Hi Pavan,

snipped
> 
> Add graceful teardown that addresses both event mode and poll mode.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
snipped
> +	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]);
Question from my end, for a graceful tear down first we stop the RX adapter then ensure after all events from worker are either dropped or transmit. Then we continue to TX adapter is stop. Is this right way?
> +		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]);
Should we call `rte_cleanup` to clean up the service core usage?

>  	}
>  	printf("Bye...\n");
> 
> --
> 2.17.1
  
Pavan Nikhilesh Bhagavatula Oct. 21, 2019, 4:56 p.m. UTC | #2
>Hi Pavan,
>
>snipped
>>
>> Add graceful teardown that addresses both event mode and poll
>mode.
>>
>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> ---
>snipped
>> +	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]);
>Question from my end, for a graceful tear down first we stop the RX
>adapter then ensure after all events from worker are either dropped or
>transmit. Then we continue to TX adapter is stop. Is this right way?

The general rule of thumb is to stop producers before consumers.

>> +		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]);
>Should we call `rte_cleanup` to clean up the service core usage?

Since we are exiting from here I don't think we explicitly need to do a 
cleanup of service config.

>
>>  	}
>>  	printf("Bye...\n");
>>
>> --
>> 2.17.1
  
Varghese, Vipin Oct. 22, 2019, 2:48 a.m. UTC | #3
Hi Pavan,

snipped
> >> Add graceful teardown that addresses both event mode and poll
> >mode.
> >>
> >> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >> ---
> >snipped
> >> +	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]);
> >Question from my end, for a graceful tear down first we stop the RX
> >adapter then ensure after all events from worker are either dropped or
> >transmit. Then we continue to TX adapter is stop. Is this right way?
> 
> The general rule of thumb is to stop producers before consumers.
> 
> >> +		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]);
> >Should we call `rte_cleanup` to clean up the service core usage?
> 
> Since we are exiting from here I don't think we explicitly need to do a cleanup of
> service config.

As I recollect in dpdk 18.11, there was a bug and fix done for service core cleanup with `rte_cleanup`. If this taken care implicity 19.11, then yes you are right there is no need of `rte_celanup` when service cores are in use.
> 
> >
> >>  	}
> >>  	printf("Bye...\n");
> >>
> >> --
> >> 2.17.1
  

Patch

diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c
index c11b057aa..6d4215890 100644
--- a/examples/l2fwd-event/main.c
+++ b/examples/l2fwd-event/main.c
@@ -304,7 +304,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);
@@ -409,16 +409,46 @@  main(int argc, char **argv)
 	/* launch per-lcore init on every lcore */
 	rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, rsrc,
 				 CALL_MASTER);
-	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");