DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: "Wu, Jingjing" <jingjing.wu@intel.com>,
	"Lu, Wenzhuo" <wenzhuo.lu@intel.com>
Subject: [dpdk-dev] [PATCH] app/testpmd: configure event display
Date: Fri, 28 Apr 2017 12:10:26 +0200	[thread overview]
Message-ID: <1493374226-24245-1-git-send-email-gaetan.rivet@6wind.com> (raw)

Add two parameters to testpmd:

  --print-event <event name>
  --mask-event <event name>

To enable or disable to printing of events. This display is configured
on a per-event basis. By default, all except VF_MBOX are displayed.

Fixes: 76ad4a2d82d4 ("app/testpmd: add generic event handler")
Cc: "Lu, Wenzhuo" <wenzhuo.lu@intel.com>

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
Additionally, I'm thinking about runtime commands for events, in the form

event show <name|all>
event print <name|all>
event mask <name|all>

where show could display the state of the masking for this event as well
as statistics for the event. print and mask would do the same as the two
parameters introduced by this patch.

But this is a little heavier and I wanted to propose this fix as soon as
possible.
---
 app/test-pmd/parameters.c             | 46 +++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c                | 13 +++++++++-
 app/test-pmd/testpmd.h                |  2 ++
 doc/guides/testpmd_app_ug/run_app.rst |  8 ++++++
 4 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 3f4d3a2..3ee1ace 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -202,6 +202,10 @@ usage(char* progname)
 	       "starting/stopping ports.\n");
 	printf("  --no-lsc-interrupt: disable link status change interrupt.\n");
 	printf("  --no-rmv-interrupt: disable device removal interrupt.");
+	printf("  --print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv>: "
+	       "enable print of designated event");
+	printf("  --mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv>: "
+	       "disable print of designated event");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -499,6 +503,36 @@ parse_ringnuma_config(const char *q_arg)
 	return 0;
 }
 
+static int
+parse_event_printing_config(const char *optarg, int enable)
+{
+	uint32_t mask = 0;
+
+	if (!strcmp(optarg, "unknown"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN;
+	else if (!strcmp(optarg, "intr_lsc"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC;
+	else if (!strcmp(optarg, "queue_state"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE;
+	else if (!strcmp(optarg, "intr_reset"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET;
+	else if (!strcmp(optarg, "vf_mbox"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_VF_MBOX;
+	else if (!strcmp(optarg, "macsec"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_MACSEC;
+	else if (!strcmp(optarg, "intr_rmv"))
+		mask = UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV;
+	else {
+		fprintf(stderr, "Invalid event: %s\n", optarg);
+		return -1;
+	}
+	if (enable)
+		event_print_mask |= mask;
+	else
+		event_print_mask &= ~mask;
+	return 0;
+}
+
 void
 launch_args_parse(int argc, char** argv)
 {
@@ -573,6 +607,8 @@ launch_args_parse(int argc, char** argv)
 		{ "disable-link-check",		0, 0, 0 },
 		{ "no-lsc-interrupt",		0, 0, 0 },
 		{ "no-rmv-interrupt",		0, 0, 0 },
+		{ "print-event",		1, 0, 0 },
+		{ "mask-event",			1, 0, 0 },
 		{ 0, 0, 0, 0 },
 	};
 
@@ -1009,6 +1045,16 @@ launch_args_parse(int argc, char** argv)
 				lsc_interrupt = 0;
 			if (!strcmp(lgopts[opt_idx].name, "no-rmv-interrupt"))
 				rmv_interrupt = 0;
+			if (!strcmp(lgopts[opt_idx].name, "print-event"))
+				if (parse_event_printing_config(optarg, 1)) {
+					rte_exit(EXIT_FAILURE,
+						 "invalid print-event argument\n");
+				}
+			if (!strcmp(lgopts[opt_idx].name, "mask-event"))
+				if (parse_event_printing_config(optarg, 0)) {
+					rte_exit(EXIT_FAILURE,
+						 "invalid mask-event argument\n");
+				}
 
 			break;
 		case 'h':
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 3a57348..755f73b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -281,6 +281,17 @@ uint8_t lsc_interrupt = 1; /* enabled by default */
 uint8_t rmv_interrupt = 1; /* enabled by default */
 
 /*
+ * Display or mask ether events
+ * Default to all events except VF_MBOX
+ */
+uint32_t event_print_mask = (UINT32_C(1) << RTE_ETH_EVENT_UNKNOWN) |
+			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_LSC) |
+			    (UINT32_C(1) << RTE_ETH_EVENT_QUEUE_STATE) |
+			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RESET) |
+			    (UINT32_C(1) << RTE_ETH_EVENT_MACSEC) |
+			    (UINT32_C(1) << RTE_ETH_EVENT_INTR_RMV);
+
+/*
  * NIC bypass mode configuration options.
  */
 #ifdef RTE_NIC_BYPASS
@@ -1806,7 +1817,7 @@ eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param)
 		fprintf(stderr, "\nPort %" PRIu8 ": %s called upon invalid event %d\n",
 			port_id, __func__, type);
 		fflush(stderr);
-	} else {
+	} else if (event_print_mask & (UINT32_C(1) << type)) {
 		printf("\nPort %" PRIu8 ": %s event\n", port_id,
 			event_desc[type]);
 		fflush(stdout);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a9ff07e..30b2472 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -307,6 +307,8 @@ extern uint8_t no_link_check; /**<set by "--disable-link-check" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
+extern uint32_t event_print_mask;
+/**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
 
 #ifdef RTE_NIC_BYPASS
 extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index a72c7e3..31ee5ff 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -473,3 +473,11 @@ The commandline options are:
 *  ``--no-rmv-interrupt``
 
   Disable RMV interrupts for all ports, even those supporting it.
+
+*  ``--print-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv>``
+
+  Enable printing the occurence of the designated event.
+
+*  ``--mask-event <unknown|intr_lsc|queue_state|intr_reset|vf_mbox|macsec|intr_rmv>``
+
+  Disable printing the occurence of the designated event.
-- 
2.1.4

             reply	other threads:[~2017-04-28 10:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 10:10 Gaetan Rivet [this message]
2017-05-02  7:03 ` [dpdk-dev] [PATCH v2] " Gaetan Rivet
2017-05-02  9:40   ` Thomas Monjalon
2017-05-02  9:54   ` [dpdk-dev] [PATCH v3] " Gaetan Rivet
2017-05-06  0:57     ` Wu, Jingjing
2017-05-06  8:44       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1493374226-24245-1-git-send-email-gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).