[v3] app/pdump: add exit_with_primary option support.

Message ID 1556428025-49290-1-git-send-email-mousuanming@huawei.com (mailing list archive)
State Superseded, archived
Headers
Series [v3] app/pdump: add exit_with_primary option support. |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing fail Performance Testing issues
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Suanming.Mou April 28, 2019, 5:07 a.m. UTC
  When primary app exits, the residual running pdump will stop
the primary app to restart. Add an exit_with_primary option
to make pdump exit with primary.

Suggested-by: Varghese, Vipin <vipin.varghese@intel.com>
Suggested-by: Burakov, Anatoly <anatoly.burakov@intel.com>
Signed-off-by: Suanming.Mou <mousuanming@huawei.com>
---
 app/pdump/main.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
  

Patch

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 3d20854..b69ef4e 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -26,11 +26,14 @@ 
 #include <rte_ring.h>
 #include <rte_string_fns.h>
 #include <rte_pdump.h>
+#include <rte_alarm.h>
 
 #define CMD_LINE_OPT_PDUMP "pdump"
 #define CMD_LINE_OPT_PDUMP_NUM 256
 #define CMD_LINE_OPT_MULTI "multi"
 #define CMD_LINE_OPT_MULTI_NUM 257
+#define CMD_LINE_OPT_EXIT_WP "exit_with_primary"
+#define CMD_LINE_OPT_EXIT_WP_NUM 258
 #define PDUMP_PORT_ARG "port"
 #define PDUMP_PCI_ARG "device_id"
 #define PDUMP_QUEUE_ARG "queue"
@@ -65,6 +68,7 @@ 
 #define SIZE 256
 #define BURST_SIZE 32
 #define NUM_VDEVS 2
+#define MONITOR_INTERVEL (500 * 1000)
 
 /* true if x is a power of 2 */
 #define POWEROF2(x) ((((x)-1) & (x)) == 0)
@@ -143,12 +147,14 @@  struct parse_val {
 static struct rte_eth_conf port_conf_default;
 static volatile uint8_t quit_signal;
 static uint8_t multiple_core_capture;
+static uint8_t exit_with_primary;
 
 /**< display usage */
 static void
 pdump_usage(const char *prgname)
 {
 	printf("usage: %s [EAL options]"
+			" --["CMD_LINE_OPT_EXIT_WP"]"
 			" --["CMD_LINE_OPT_MULTI"]\n"
 			" --"CMD_LINE_OPT_PDUMP" "
 			"'(port=<port id> | device_id=<pci id or vdev name>),"
@@ -383,6 +389,7 @@  struct parse_val {
 	static struct option long_option[] = {
 		{CMD_LINE_OPT_PDUMP, 1, 0, CMD_LINE_OPT_PDUMP_NUM},
 		{CMD_LINE_OPT_MULTI, 0, 0, CMD_LINE_OPT_MULTI_NUM},
+		{CMD_LINE_OPT_EXIT_WP, 0, 0, CMD_LINE_OPT_EXIT_WP_NUM},
 		{NULL, 0, 0, 0}
 	};
 
@@ -403,6 +410,9 @@  struct parse_val {
 		case CMD_LINE_OPT_MULTI_NUM:
 			multiple_core_capture = 1;
 			break;
+		case CMD_LINE_OPT_EXIT_WP_NUM:
+			exit_with_primary = 1;
+			break;
 		default:
 			pdump_usage(prgname);
 			return -1;
@@ -864,12 +874,26 @@  struct parse_val {
 	return 0;
 }
 
+static void monitor_primary(void *arg __rte_unused)
+{
+	if (quit_signal)
+		return;
+
+	if (rte_eal_primary_proc_alive(NULL))
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+	else
+		quit_signal = 1;
+}
+
 static inline void
 dump_packets(void)
 {
 	int i;
 	uint32_t lcore_id = 0;
 
+	if (exit_with_primary)
+		rte_eal_alarm_set(MONITOR_INTERVEL, monitor_primary, NULL);
+
 	if (!multiple_core_capture) {
 		printf(" core (%u), capture for (%d) tuples\n",
 				rte_lcore_id(), num_tuples);