DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples/ptpclient: add signal handler for cleanup
@ 2022-08-31  6:49 Rahul Bhansali
  2022-11-02 16:51 ` Rahul Bhansali
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Rahul Bhansali @ 2022-08-31  6:49 UTC (permalink / raw)
  To: dev, Kirill Rybalchenko; +Cc: Rahul Bhansali

This adds the signal handler for SIGINT, SIGTERM.
Also, this will come out from infinite loop and do cleanup once it receives
any of the registered signal.

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
---
 examples/ptpclient/ptpclient.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 1f1c9c9c52..8b69716be1 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -19,6 +19,9 @@
 #include <limits.h>
 #include <sys/time.h>
 #include <getopt.h>
+#include <signal.h>
+
+static volatile bool force_quit;
 
 #define RX_RING_SIZE 1024
 #define TX_RING_SIZE 1024
@@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
  * The lcore main. This is the main thread that does the work, reading from an
  * input port and writing to an output port.
  */
-static __rte_noreturn void
+static void
 lcore_main(void)
 {
 	uint16_t portid;
@@ -621,7 +624,7 @@ lcore_main(void)
 
 	/* Run until the application is quit or killed. */
 
-	while (1) {
+	while (!force_quit) {
 		/* Read packet from RX queues. 8< */
 		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
 
@@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
 	return 0;
 }
 
+static void
+signal_handler(int signum)
+{
+	if (signum == SIGINT || signum == SIGTERM)
+		force_quit = true;
+}
+
 /*
  * The main function, which does initialization and calls the per-lcore
  * functions.
@@ -758,6 +768,10 @@ main(int argc, char *argv[])
 	argc -= ret;
 	argv += ret;
 
+	force_quit = false;
+	signal(SIGINT, signal_handler);
+	signal(SIGTERM, signal_handler);
+
 	ret = ptp_parse_args(argc, argv);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n");
@@ -802,6 +816,20 @@ main(int argc, char *argv[])
 	/* Call lcore_main on the main core only. */
 	lcore_main();
 
+	RTE_ETH_FOREACH_DEV(portid) {
+		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
+			continue;
+
+		/* Disable timesync timestamping for the Ethernet device */
+		rte_eth_timesync_disable(portid);
+
+		ret = rte_eth_dev_stop(portid);
+		if (ret != 0)
+			printf("rte_eth_dev_stop: err=%d, port=%d\n", ret, portid);
+
+		rte_eth_dev_close(portid);
+	}
+
 	/* clean up the EAL */
 	rte_eal_cleanup();
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2022-08-31  6:49 [PATCH] examples/ptpclient: add signal handler for cleanup Rahul Bhansali
@ 2022-11-02 16:51 ` Rahul Bhansali
  2023-01-20  5:56   ` Rahul Bhansali
  2024-03-07  9:17 ` Thomas Monjalon
  2024-03-07 16:48 ` Stephen Hemminger
  2 siblings, 1 reply; 9+ messages in thread
From: Rahul Bhansali @ 2022-11-02 16:51 UTC (permalink / raw)
  To: dev, Kirill Rybalchenko

Ping.

> -----Original Message-----
> From: Rahul Bhansali <rbhansali@marvell.com>
> Sent: Wednesday, August 31, 2022 12:19 PM
> To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> Cc: Rahul Bhansali <rbhansali@marvell.com>
> Subject: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> This adds the signal handler for SIGINT, SIGTERM.
> Also, this will come out from infinite loop and do cleanup once it receives any of
> the registered signal.
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> ---
>  examples/ptpclient/ptpclient.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
> index 1f1c9c9c52..8b69716be1 100644
> --- a/examples/ptpclient/ptpclient.c
> +++ b/examples/ptpclient/ptpclient.c
> @@ -19,6 +19,9 @@
>  #include <limits.h>
>  #include <sys/time.h>
>  #include <getopt.h>
> +#include <signal.h>
> +
> +static volatile bool force_quit;
> 
>  #define RX_RING_SIZE 1024
>  #define TX_RING_SIZE 1024
> @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m)
> {
>   * The lcore main. This is the main thread that does the work, reading from an
>   * input port and writing to an output port.
>   */
> -static __rte_noreturn void
> +static void
>  lcore_main(void)
>  {
>  	uint16_t portid;
> @@ -621,7 +624,7 @@ lcore_main(void)
> 
>  	/* Run until the application is quit or killed. */
> 
> -	while (1) {
> +	while (!force_quit) {
>  		/* Read packet from RX queues. 8< */
>  		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
> 
> @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
>  	return 0;
>  }
> 
> +static void
> +signal_handler(int signum)
> +{
> +	if (signum == SIGINT || signum == SIGTERM)
> +		force_quit = true;
> +}
> +
>  /*
>   * The main function, which does initialization and calls the per-lcore
>   * functions.
> @@ -758,6 +768,10 @@ main(int argc, char *argv[])
>  	argc -= ret;
>  	argv += ret;
> 
> +	force_quit = false;
> +	signal(SIGINT, signal_handler);
> +	signal(SIGTERM, signal_handler);
> +
>  	ret = ptp_parse_args(argc, argv);
>  	if (ret < 0)
>  		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@ -
> 802,6 +816,20 @@ main(int argc, char *argv[])
>  	/* Call lcore_main on the main core only. */
>  	lcore_main();
> 
> +	RTE_ETH_FOREACH_DEV(portid) {
> +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> +			continue;
> +
> +		/* Disable timesync timestamping for the Ethernet device */
> +		rte_eth_timesync_disable(portid);
> +
> +		ret = rte_eth_dev_stop(portid);
> +		if (ret != 0)
> +			printf("rte_eth_dev_stop: err=%d, port=%d\n", ret,
> portid);
> +
> +		rte_eth_dev_close(portid);
> +	}
> +
>  	/* clean up the EAL */
>  	rte_eal_cleanup();
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2022-11-02 16:51 ` Rahul Bhansali
@ 2023-01-20  5:56   ` Rahul Bhansali
  2023-05-15 10:59     ` Rahul Bhansali
  0 siblings, 1 reply; 9+ messages in thread
From: Rahul Bhansali @ 2023-01-20  5:56 UTC (permalink / raw)
  To: dev, Kirill Rybalchenko

Ping.

> -----Original Message-----
> From: Rahul Bhansali
> Sent: Wednesday, November 2, 2022 10:21 PM
> To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> Ping.
> 
> > -----Original Message-----
> > From: Rahul Bhansali <rbhansali@marvell.com>
> > Sent: Wednesday, August 31, 2022 12:19 PM
> > To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > Cc: Rahul Bhansali <rbhansali@marvell.com>
> > Subject: [PATCH] examples/ptpclient: add signal handler for cleanup
> >
> > This adds the signal handler for SIGINT, SIGTERM.
> > Also, this will come out from infinite loop and do cleanup once it
> > receives any of the registered signal.
> >
> > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> > ---
> >  examples/ptpclient/ptpclient.c | 32 ++++++++++++++++++++++++++++++--
> >  1 file changed, 30 insertions(+), 2 deletions(-)
> >
> > diff --git a/examples/ptpclient/ptpclient.c
> > b/examples/ptpclient/ptpclient.c index 1f1c9c9c52..8b69716be1 100644
> > --- a/examples/ptpclient/ptpclient.c
> > +++ b/examples/ptpclient/ptpclient.c
> > @@ -19,6 +19,9 @@
> >  #include <limits.h>
> >  #include <sys/time.h>
> >  #include <getopt.h>
> > +#include <signal.h>
> > +
> > +static volatile bool force_quit;
> >
> >  #define RX_RING_SIZE 1024
> >  #define TX_RING_SIZE 1024
> > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf
> > *m) {
> >   * The lcore main. This is the main thread that does the work, reading from an
> >   * input port and writing to an output port.
> >   */
> > -static __rte_noreturn void
> > +static void
> >  lcore_main(void)
> >  {
> >  	uint16_t portid;
> > @@ -621,7 +624,7 @@ lcore_main(void)
> >
> >  	/* Run until the application is quit or killed. */
> >
> > -	while (1) {
> > +	while (!force_quit) {
> >  		/* Read packet from RX queues. 8< */
> >  		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
> >
> > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
> >  	return 0;
> >  }
> >
> > +static void
> > +signal_handler(int signum)
> > +{
> > +	if (signum == SIGINT || signum == SIGTERM)
> > +		force_quit = true;
> > +}
> > +
> >  /*
> >   * The main function, which does initialization and calls the per-lcore
> >   * functions.
> > @@ -758,6 +768,10 @@ main(int argc, char *argv[])
> >  	argc -= ret;
> >  	argv += ret;
> >
> > +	force_quit = false;
> > +	signal(SIGINT, signal_handler);
> > +	signal(SIGTERM, signal_handler);
> > +
> >  	ret = ptp_parse_args(argc, argv);
> >  	if (ret < 0)
> >  		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@ -
> > 802,6 +816,20 @@ main(int argc, char *argv[])
> >  	/* Call lcore_main on the main core only. */
> >  	lcore_main();
> >
> > +	RTE_ETH_FOREACH_DEV(portid) {
> > +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> > +			continue;
> > +
> > +		/* Disable timesync timestamping for the Ethernet device */
> > +		rte_eth_timesync_disable(portid);
> > +
> > +		ret = rte_eth_dev_stop(portid);
> > +		if (ret != 0)
> > +			printf("rte_eth_dev_stop: err=%d, port=%d\n", ret,
> > portid);
> > +
> > +		rte_eth_dev_close(portid);
> > +	}
> > +
> >  	/* clean up the EAL */
> >  	rte_eal_cleanup();
> >
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2023-01-20  5:56   ` Rahul Bhansali
@ 2023-05-15 10:59     ` Rahul Bhansali
  2023-05-30  9:00       ` Rahul Bhansali
  0 siblings, 1 reply; 9+ messages in thread
From: Rahul Bhansali @ 2023-05-15 10:59 UTC (permalink / raw)
  To: Kirill Rybalchenko, Thomas Monjalon; +Cc: dev

Ping.

> -----Original Message-----
> From: Rahul Bhansali
> Sent: Friday, January 20, 2023 11:26 AM
> To: 'dev@dpdk.org' <dev@dpdk.org>; 'Kirill Rybalchenko'
> <kirill.rybalchenko@intel.com>
> Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> Ping.
> 
> > -----Original Message-----
> > From: Rahul Bhansali
> > Sent: Wednesday, November 2, 2022 10:21 PM
> > To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > cleanup
> >
> > Ping.
> >
> > > -----Original Message-----
> > > From: Rahul Bhansali <rbhansali@marvell.com>
> > > Sent: Wednesday, August 31, 2022 12:19 PM
> > > To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > > Cc: Rahul Bhansali <rbhansali@marvell.com>
> > > Subject: [PATCH] examples/ptpclient: add signal handler for cleanup
> > >
> > > This adds the signal handler for SIGINT, SIGTERM.
> > > Also, this will come out from infinite loop and do cleanup once it
> > > receives any of the registered signal.
> > >
> > > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> > > ---
> > >  examples/ptpclient/ptpclient.c | 32
> > > ++++++++++++++++++++++++++++++--
> > >  1 file changed, 30 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/examples/ptpclient/ptpclient.c
> > > b/examples/ptpclient/ptpclient.c index 1f1c9c9c52..8b69716be1 100644
> > > --- a/examples/ptpclient/ptpclient.c
> > > +++ b/examples/ptpclient/ptpclient.c
> > > @@ -19,6 +19,9 @@
> > >  #include <limits.h>
> > >  #include <sys/time.h>
> > >  #include <getopt.h>
> > > +#include <signal.h>
> > > +
> > > +static volatile bool force_quit;
> > >
> > >  #define RX_RING_SIZE 1024
> > >  #define TX_RING_SIZE 1024
> > > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct
> > > rte_mbuf
> > > *m) {
> > >   * The lcore main. This is the main thread that does the work, reading from
> an
> > >   * input port and writing to an output port.
> > >   */
> > > -static __rte_noreturn void
> > > +static void
> > >  lcore_main(void)
> > >  {
> > >  	uint16_t portid;
> > > @@ -621,7 +624,7 @@ lcore_main(void)
> > >
> > >  	/* Run until the application is quit or killed. */
> > >
> > > -	while (1) {
> > > +	while (!force_quit) {
> > >  		/* Read packet from RX queues. 8< */
> > >  		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
> > >
> > > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
> > >  	return 0;
> > >  }
> > >
> > > +static void
> > > +signal_handler(int signum)
> > > +{
> > > +	if (signum == SIGINT || signum == SIGTERM)
> > > +		force_quit = true;
> > > +}
> > > +
> > >  /*
> > >   * The main function, which does initialization and calls the per-lcore
> > >   * functions.
> > > @@ -758,6 +768,10 @@ main(int argc, char *argv[])
> > >  	argc -= ret;
> > >  	argv += ret;
> > >
> > > +	force_quit = false;
> > > +	signal(SIGINT, signal_handler);
> > > +	signal(SIGTERM, signal_handler);
> > > +
> > >  	ret = ptp_parse_args(argc, argv);
> > >  	if (ret < 0)
> > >  		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@ -
> > > 802,6 +816,20 @@ main(int argc, char *argv[])
> > >  	/* Call lcore_main on the main core only. */
> > >  	lcore_main();
> > >
> > > +	RTE_ETH_FOREACH_DEV(portid) {
> > > +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> > > +			continue;
> > > +
> > > +		/* Disable timesync timestamping for the Ethernet device */
> > > +		rte_eth_timesync_disable(portid);
> > > +
> > > +		ret = rte_eth_dev_stop(portid);
> > > +		if (ret != 0)
> > > +			printf("rte_eth_dev_stop: err=%d, port=%d\n", ret,
> > > portid);
> > > +
> > > +		rte_eth_dev_close(portid);
> > > +	}
> > > +
> > >  	/* clean up the EAL */
> > >  	rte_eal_cleanup();
> > >
> > > --
> > > 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2023-05-15 10:59     ` Rahul Bhansali
@ 2023-05-30  9:00       ` Rahul Bhansali
  2023-06-16  4:58         ` Rahul Bhansali
  0 siblings, 1 reply; 9+ messages in thread
From: Rahul Bhansali @ 2023-05-30  9:00 UTC (permalink / raw)
  To: Kirill Rybalchenko, Thomas Monjalon; +Cc: dev

Hi Kirill,

This patch is pending for review from long time.
Please do let me know if any comments on this patch, else will request to merge it.

Regards,
Rahul

> -----Original Message-----
> From: Rahul Bhansali
> Sent: Monday, May 15, 2023 4:29 PM
> To: 'Kirill Rybalchenko' <kirill.rybalchenko@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>
> Cc: 'dev@dpdk.org' <dev@dpdk.org>
> Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> Ping.
> 
> > -----Original Message-----
> > From: Rahul Bhansali
> > Sent: Friday, January 20, 2023 11:26 AM
> > To: 'dev@dpdk.org' <dev@dpdk.org>; 'Kirill Rybalchenko'
> > <kirill.rybalchenko@intel.com>
> > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > cleanup
> >
> > Ping.
> >
> > > -----Original Message-----
> > > From: Rahul Bhansali
> > > Sent: Wednesday, November 2, 2022 10:21 PM
> > > To: dev@dpdk.org; Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > cleanup
> > >
> > > Ping.
> > >
> > > > -----Original Message-----
> > > > From: Rahul Bhansali <rbhansali@marvell.com>
> > > > Sent: Wednesday, August 31, 2022 12:19 PM
> > > > To: dev@dpdk.org; Kirill Rybalchenko
> > > > <kirill.rybalchenko@intel.com>
> > > > Cc: Rahul Bhansali <rbhansali@marvell.com>
> > > > Subject: [PATCH] examples/ptpclient: add signal handler for
> > > > cleanup
> > > >
> > > > This adds the signal handler for SIGINT, SIGTERM.
> > > > Also, this will come out from infinite loop and do cleanup once it
> > > > receives any of the registered signal.
> > > >
> > > > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> > > > ---
> > > >  examples/ptpclient/ptpclient.c | 32
> > > > ++++++++++++++++++++++++++++++--
> > > >  1 file changed, 30 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/examples/ptpclient/ptpclient.c
> > > > b/examples/ptpclient/ptpclient.c index 1f1c9c9c52..8b69716be1
> > > > 100644
> > > > --- a/examples/ptpclient/ptpclient.c
> > > > +++ b/examples/ptpclient/ptpclient.c
> > > > @@ -19,6 +19,9 @@
> > > >  #include <limits.h>
> > > >  #include <sys/time.h>
> > > >  #include <getopt.h>
> > > > +#include <signal.h>
> > > > +
> > > > +static volatile bool force_quit;
> > > >
> > > >  #define RX_RING_SIZE 1024
> > > >  #define TX_RING_SIZE 1024
> > > > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct
> > > > rte_mbuf
> > > > *m) {
> > > >   * The lcore main. This is the main thread that does the work,
> > > > reading from
> > an
> > > >   * input port and writing to an output port.
> > > >   */
> > > > -static __rte_noreturn void
> > > > +static void
> > > >  lcore_main(void)
> > > >  {
> > > >  	uint16_t portid;
> > > > @@ -621,7 +624,7 @@ lcore_main(void)
> > > >
> > > >  	/* Run until the application is quit or killed. */
> > > >
> > > > -	while (1) {
> > > > +	while (!force_quit) {
> > > >  		/* Read packet from RX queues. 8< */
> > > >  		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
> > > >
> > > > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
> > > >  	return 0;
> > > >  }
> > > >
> > > > +static void
> > > > +signal_handler(int signum)
> > > > +{
> > > > +	if (signum == SIGINT || signum == SIGTERM)
> > > > +		force_quit = true;
> > > > +}
> > > > +
> > > >  /*
> > > >   * The main function, which does initialization and calls the per-lcore
> > > >   * functions.
> > > > @@ -758,6 +768,10 @@ main(int argc, char *argv[])
> > > >  	argc -= ret;
> > > >  	argv += ret;
> > > >
> > > > +	force_quit = false;
> > > > +	signal(SIGINT, signal_handler);
> > > > +	signal(SIGTERM, signal_handler);
> > > > +
> > > >  	ret = ptp_parse_args(argc, argv);
> > > >  	if (ret < 0)
> > > >  		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@ -
> > > > 802,6 +816,20 @@ main(int argc, char *argv[])
> > > >  	/* Call lcore_main on the main core only. */
> > > >  	lcore_main();
> > > >
> > > > +	RTE_ETH_FOREACH_DEV(portid) {
> > > > +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> > > > +			continue;
> > > > +
> > > > +		/* Disable timesync timestamping for the Ethernet device */
> > > > +		rte_eth_timesync_disable(portid);
> > > > +
> > > > +		ret = rte_eth_dev_stop(portid);
> > > > +		if (ret != 0)
> > > > +			printf("rte_eth_dev_stop: err=%d, port=%d\n", ret,
> > > > portid);
> > > > +
> > > > +		rte_eth_dev_close(portid);
> > > > +	}
> > > > +
> > > >  	/* clean up the EAL */
> > > >  	rte_eal_cleanup();
> > > >
> > > > --
> > > > 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2023-05-30  9:00       ` Rahul Bhansali
@ 2023-06-16  4:58         ` Rahul Bhansali
  2023-09-21 14:08           ` Rahul Bhansali
  0 siblings, 1 reply; 9+ messages in thread
From: Rahul Bhansali @ 2023-06-16  4:58 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Kirill Rybalchenko

Hi Thomas,

This is pending from long time and no comments so far. Can you please check and accept this ?
Let me know if you have any review comments.

Regard,
Rahul

> -----Original Message-----
> From: Rahul Bhansali
> Sent: Tuesday, May 30, 2023 2:30 PM
> To: 'Kirill Rybalchenko' <kirill.rybalchenko@intel.com>; 'Thomas Monjalon'
> <thomas@monjalon.net>
> Cc: 'dev@dpdk.org' <dev@dpdk.org>
> Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> Hi Kirill,
> 
> This patch is pending for review from long time.
> Please do let me know if any comments on this patch, else will request to merge
> it.
> 
> Regards,
> Rahul
> 
> > -----Original Message-----
> > From: Rahul Bhansali
> > Sent: Monday, May 15, 2023 4:29 PM
> > To: 'Kirill Rybalchenko' <kirill.rybalchenko@intel.com>; Thomas
> > Monjalon <thomas@monjalon.net>
> > Cc: 'dev@dpdk.org' <dev@dpdk.org>
> > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > cleanup
> >
> > Ping.
> >
> > > -----Original Message-----
> > > From: Rahul Bhansali
> > > Sent: Friday, January 20, 2023 11:26 AM
> > > To: 'dev@dpdk.org' <dev@dpdk.org>; 'Kirill Rybalchenko'
> > > <kirill.rybalchenko@intel.com>
> > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > cleanup
> > >
> > > Ping.
> > >
> > > > -----Original Message-----
> > > > From: Rahul Bhansali
> > > > Sent: Wednesday, November 2, 2022 10:21 PM
> > > > To: dev@dpdk.org; Kirill Rybalchenko
> > > > <kirill.rybalchenko@intel.com>
> > > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > > cleanup
> > > >
> > > > Ping.
> > > >
> > > > > -----Original Message-----
> > > > > From: Rahul Bhansali <rbhansali@marvell.com>
> > > > > Sent: Wednesday, August 31, 2022 12:19 PM
> > > > > To: dev@dpdk.org; Kirill Rybalchenko
> > > > > <kirill.rybalchenko@intel.com>
> > > > > Cc: Rahul Bhansali <rbhansali@marvell.com>
> > > > > Subject: [PATCH] examples/ptpclient: add signal handler for
> > > > > cleanup
> > > > >
> > > > > This adds the signal handler for SIGINT, SIGTERM.
> > > > > Also, this will come out from infinite loop and do cleanup once
> > > > > it receives any of the registered signal.
> > > > >
> > > > > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> > > > > ---
> > > > >  examples/ptpclient/ptpclient.c | 32
> > > > > ++++++++++++++++++++++++++++++--
> > > > >  1 file changed, 30 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/examples/ptpclient/ptpclient.c
> > > > > b/examples/ptpclient/ptpclient.c index 1f1c9c9c52..8b69716be1
> > > > > 100644
> > > > > --- a/examples/ptpclient/ptpclient.c
> > > > > +++ b/examples/ptpclient/ptpclient.c
> > > > > @@ -19,6 +19,9 @@
> > > > >  #include <limits.h>
> > > > >  #include <sys/time.h>
> > > > >  #include <getopt.h>
> > > > > +#include <signal.h>
> > > > > +
> > > > > +static volatile bool force_quit;
> > > > >
> > > > >  #define RX_RING_SIZE 1024
> > > > >  #define TX_RING_SIZE 1024
> > > > > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct
> > > > > rte_mbuf
> > > > > *m) {
> > > > >   * The lcore main. This is the main thread that does the work,
> > > > > reading from
> > > an
> > > > >   * input port and writing to an output port.
> > > > >   */
> > > > > -static __rte_noreturn void
> > > > > +static void
> > > > >  lcore_main(void)
> > > > >  {
> > > > >  	uint16_t portid;
> > > > > @@ -621,7 +624,7 @@ lcore_main(void)
> > > > >
> > > > >  	/* Run until the application is quit or killed. */
> > > > >
> > > > > -	while (1) {
> > > > > +	while (!force_quit) {
> > > > >  		/* Read packet from RX queues. 8< */
> > > > >  		for (portid = 0; portid < ptp_enabled_port_nb; portid++) {
> > > > >
> > > > > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
> > > > >  	return 0;
> > > > >  }
> > > > >
> > > > > +static void
> > > > > +signal_handler(int signum)
> > > > > +{
> > > > > +	if (signum == SIGINT || signum == SIGTERM)
> > > > > +		force_quit = true;
> > > > > +}
> > > > > +
> > > > >  /*
> > > > >   * The main function, which does initialization and calls the per-lcore
> > > > >   * functions.
> > > > > @@ -758,6 +768,10 @@ main(int argc, char *argv[])
> > > > >  	argc -= ret;
> > > > >  	argv += ret;
> > > > >
> > > > > +	force_quit = false;
> > > > > +	signal(SIGINT, signal_handler);
> > > > > +	signal(SIGTERM, signal_handler);
> > > > > +
> > > > >  	ret = ptp_parse_args(argc, argv);
> > > > >  	if (ret < 0)
> > > > >  		rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@
> > > > > -
> > > > > 802,6 +816,20 @@ main(int argc, char *argv[])
> > > > >  	/* Call lcore_main on the main core only. */
> > > > >  	lcore_main();
> > > > >
> > > > > +	RTE_ETH_FOREACH_DEV(portid) {
> > > > > +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> > > > > +			continue;
> > > > > +
> > > > > +		/* Disable timesync timestamping for the Ethernet
> device */
> > > > > +		rte_eth_timesync_disable(portid);
> > > > > +
> > > > > +		ret = rte_eth_dev_stop(portid);
> > > > > +		if (ret != 0)
> > > > > +			printf("rte_eth_dev_stop: err=%d, port=%d\n",
> ret,
> > > > > portid);
> > > > > +
> > > > > +		rte_eth_dev_close(portid);
> > > > > +	}
> > > > > +
> > > > >  	/* clean up the EAL */
> > > > >  	rte_eal_cleanup();
> > > > >
> > > > > --
> > > > > 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] examples/ptpclient: add signal handler for cleanup
  2023-06-16  4:58         ` Rahul Bhansali
@ 2023-09-21 14:08           ` Rahul Bhansali
  0 siblings, 0 replies; 9+ messages in thread
From: Rahul Bhansali @ 2023-09-21 14:08 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Kirill Rybalchenko

Hi Thomas,

Can you please check this and merge if no comments as this is waiting from long time ?

Regards,
Rahul

> -----Original Message-----
> From: Rahul Bhansali
> Sent: Friday, June 16, 2023 10:28 AM
> To: 'Thomas Monjalon' <thomas@monjalon.net>
> Cc: 'dev@dpdk.org' <dev@dpdk.org>; 'Kirill Rybalchenko'
> <kirill.rybalchenko@intel.com>
> Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup
> 
> Hi Thomas,
> 
> This is pending from long time and no comments so far. Can you please check
> and accept this ?
> Let me know if you have any review comments.
> 
> Regard,
> Rahul
> 
> > -----Original Message-----
> > From: Rahul Bhansali
> > Sent: Tuesday, May 30, 2023 2:30 PM
> > To: 'Kirill Rybalchenko' <kirill.rybalchenko@intel.com>; 'Thomas Monjalon'
> > <thomas@monjalon.net>
> > Cc: 'dev@dpdk.org' <dev@dpdk.org>
> > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > cleanup
> >
> > Hi Kirill,
> >
> > This patch is pending for review from long time.
> > Please do let me know if any comments on this patch, else will request
> > to merge it.
> >
> > Regards,
> > Rahul
> >
> > > -----Original Message-----
> > > From: Rahul Bhansali
> > > Sent: Monday, May 15, 2023 4:29 PM
> > > To: 'Kirill Rybalchenko' <kirill.rybalchenko@intel.com>; Thomas
> > > Monjalon <thomas@monjalon.net>
> > > Cc: 'dev@dpdk.org' <dev@dpdk.org>
> > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > cleanup
> > >
> > > Ping.
> > >
> > > > -----Original Message-----
> > > > From: Rahul Bhansali
> > > > Sent: Friday, January 20, 2023 11:26 AM
> > > > To: 'dev@dpdk.org' <dev@dpdk.org>; 'Kirill Rybalchenko'
> > > > <kirill.rybalchenko@intel.com>
> > > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > > cleanup
> > > >
> > > > Ping.
> > > >
> > > > > -----Original Message-----
> > > > > From: Rahul Bhansali
> > > > > Sent: Wednesday, November 2, 2022 10:21 PM
> > > > > To: dev@dpdk.org; Kirill Rybalchenko
> > > > > <kirill.rybalchenko@intel.com>
> > > > > Subject: RE: [PATCH] examples/ptpclient: add signal handler for
> > > > > cleanup
> > > > >
> > > > > Ping.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Rahul Bhansali <rbhansali@marvell.com>
> > > > > > Sent: Wednesday, August 31, 2022 12:19 PM
> > > > > > To: dev@dpdk.org; Kirill Rybalchenko
> > > > > > <kirill.rybalchenko@intel.com>
> > > > > > Cc: Rahul Bhansali <rbhansali@marvell.com>
> > > > > > Subject: [PATCH] examples/ptpclient: add signal handler for
> > > > > > cleanup
> > > > > >
> > > > > > This adds the signal handler for SIGINT, SIGTERM.
> > > > > > Also, this will come out from infinite loop and do cleanup
> > > > > > once it receives any of the registered signal.
> > > > > >
> > > > > > Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> > > > > > ---
> > > > > >  examples/ptpclient/ptpclient.c | 32
> > > > > > ++++++++++++++++++++++++++++++--
> > > > > >  1 file changed, 30 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/examples/ptpclient/ptpclient.c
> > > > > > b/examples/ptpclient/ptpclient.c index 1f1c9c9c52..8b69716be1
> > > > > > 100644
> > > > > > --- a/examples/ptpclient/ptpclient.c
> > > > > > +++ b/examples/ptpclient/ptpclient.c
> > > > > > @@ -19,6 +19,9 @@
> > > > > >  #include <limits.h>
> > > > > >  #include <sys/time.h>
> > > > > >  #include <getopt.h>
> > > > > > +#include <signal.h>
> > > > > > +
> > > > > > +static volatile bool force_quit;
> > > > > >
> > > > > >  #define RX_RING_SIZE 1024
> > > > > >  #define TX_RING_SIZE 1024
> > > > > > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct
> > > > > > rte_mbuf
> > > > > > *m) {
> > > > > >   * The lcore main. This is the main thread that does the
> > > > > > work, reading from
> > > > an
> > > > > >   * input port and writing to an output port.
> > > > > >   */
> > > > > > -static __rte_noreturn void
> > > > > > +static void
> > > > > >  lcore_main(void)
> > > > > >  {
> > > > > >  	uint16_t portid;
> > > > > > @@ -621,7 +624,7 @@ lcore_main(void)
> > > > > >
> > > > > >  	/* Run until the application is quit or killed. */
> > > > > >
> > > > > > -	while (1) {
> > > > > > +	while (!force_quit) {
> > > > > >  		/* Read packet from RX queues. 8< */
> > > > > >  		for (portid = 0; portid < ptp_enabled_port_nb; portid++)
> {
> > > > > >
> > > > > > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv)
> > > > > >  	return 0;
> > > > > >  }
> > > > > >
> > > > > > +static void
> > > > > > +signal_handler(int signum)
> > > > > > +{
> > > > > > +	if (signum == SIGINT || signum == SIGTERM)
> > > > > > +		force_quit = true;
> > > > > > +}
> > > > > > +
> > > > > >  /*
> > > > > >   * The main function, which does initialization and calls the per-lcore
> > > > > >   * functions.
> > > > > > @@ -758,6 +768,10 @@ main(int argc, char *argv[])
> > > > > >  	argc -= ret;
> > > > > >  	argv += ret;
> > > > > >
> > > > > > +	force_quit = false;
> > > > > > +	signal(SIGINT, signal_handler);
> > > > > > +	signal(SIGTERM, signal_handler);
> > > > > > +
> > > > > >  	ret = ptp_parse_args(argc, argv);
> > > > > >  	if (ret < 0)
> > > > > >  		rte_exit(EXIT_FAILURE, "Error with PTP
> initialization\n");
> > > > > > @@
> > > > > > -
> > > > > > 802,6 +816,20 @@ main(int argc, char *argv[])
> > > > > >  	/* Call lcore_main on the main core only. */
> > > > > >  	lcore_main();
> > > > > >
> > > > > > +	RTE_ETH_FOREACH_DEV(portid) {
> > > > > > +		if ((ptp_enabled_port_mask & (1 << portid)) == 0)
> > > > > > +			continue;
> > > > > > +
> > > > > > +		/* Disable timesync timestamping for the Ethernet
> > device */
> > > > > > +		rte_eth_timesync_disable(portid);
> > > > > > +
> > > > > > +		ret = rte_eth_dev_stop(portid);
> > > > > > +		if (ret != 0)
> > > > > > +			printf("rte_eth_dev_stop: err=%d, port=%d\n",
> > ret,
> > > > > > portid);
> > > > > > +
> > > > > > +		rte_eth_dev_close(portid);
> > > > > > +	}
> > > > > > +
> > > > > >  	/* clean up the EAL */
> > > > > >  	rte_eal_cleanup();
> > > > > >
> > > > > > --
> > > > > > 2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] examples/ptpclient: add signal handler for cleanup
  2022-08-31  6:49 [PATCH] examples/ptpclient: add signal handler for cleanup Rahul Bhansali
  2022-11-02 16:51 ` Rahul Bhansali
@ 2024-03-07  9:17 ` Thomas Monjalon
  2024-03-07 16:48 ` Stephen Hemminger
  2 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2024-03-07  9:17 UTC (permalink / raw)
  To: Rahul Bhansali; +Cc: dev, Kirill Rybalchenko

31/08/2022 08:49, Rahul Bhansali:
> This adds the signal handler for SIGINT, SIGTERM.
> Also, this will come out from infinite loop and do cleanup once it receives
> any of the registered signal.
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>

Was waiting for review for a very long time.

Applied, thanks.

I suppose Kirill is not maintaining this example.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] examples/ptpclient: add signal handler for cleanup
  2022-08-31  6:49 [PATCH] examples/ptpclient: add signal handler for cleanup Rahul Bhansali
  2022-11-02 16:51 ` Rahul Bhansali
  2024-03-07  9:17 ` Thomas Monjalon
@ 2024-03-07 16:48 ` Stephen Hemminger
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-07 16:48 UTC (permalink / raw)
  To: Rahul Bhansali; +Cc: dev, Kirill Rybalchenko

On Wed, 31 Aug 2022 12:19:24 +0530
Rahul Bhansali <rbhansali@marvell.com> wrote:

> This adds the signal handler for SIGINT, SIGTERM.
> Also, this will come out from infinite loop and do cleanup once it receives
> any of the registered signal.
> 
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-07 16:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31  6:49 [PATCH] examples/ptpclient: add signal handler for cleanup Rahul Bhansali
2022-11-02 16:51 ` Rahul Bhansali
2023-01-20  5:56   ` Rahul Bhansali
2023-05-15 10:59     ` Rahul Bhansali
2023-05-30  9:00       ` Rahul Bhansali
2023-06-16  4:58         ` Rahul Bhansali
2023-09-21 14:08           ` Rahul Bhansali
2024-03-07  9:17 ` Thomas Monjalon
2024-03-07 16:48 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).