From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: Yogesh Jangra <yogesh.jangra@intel.com>
Subject: [PATCH 3/3] examples/pipeline: support packet mirroring
Date: Fri, 4 Mar 2022 18:06:23 +0000 [thread overview]
Message-ID: <20220304180623.74893-3-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <20220304180623.74893-1-cristian.dumitrescu@intel.com>
Add CLI commands for packet mirroring.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
examples/pipeline/cli.c | 154 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index edae63dae6..e983cdd21d 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2697,6 +2697,131 @@ cmd_pipeline_stats(char **tokens,
}
}
+static const char cmd_pipeline_mirror_help[] =
+"pipeline <pipeline_name> mirror slots <n_slots> sessions <n_sessions>\n";
+
+static void
+cmd_pipeline_mirror(char **tokens,
+ uint32_t n_tokens,
+ char *out,
+ size_t out_size,
+ void *obj)
+{
+ struct rte_swx_pipeline_mirroring_params params;
+ struct pipeline *p;
+ int status;
+
+ if (n_tokens != 7) {
+ snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+ return;
+ }
+
+ if (strcmp(tokens[0], "pipeline")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+ return;
+ }
+
+ p = pipeline_find(obj, tokens[1]);
+ if (!p) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name");
+ return;
+ }
+
+ if (strcmp(tokens[2], "mirror")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mirror");
+ return;
+ }
+
+ if (strcmp(tokens[3], "slots")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "slots");
+ return;
+ }
+
+ if (parser_read_uint32(¶ms.n_slots, tokens[4])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "n_slots");
+ return;
+ }
+
+ if (strcmp(tokens[5], "sessions")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "sessions");
+ return;
+ }
+
+ if (parser_read_uint32(¶ms.n_sessions, tokens[6])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "n_sessions");
+ return;
+ }
+
+ status = rte_swx_pipeline_mirroring_config(p->p, ¶ms);
+ if (status) {
+ snprintf(out, out_size, "Command failed!\n");
+ return;
+ }
+}
+
+static const char cmd_pipeline_mirror_session_help[] =
+"pipeline <pipeline_name> mirror session <session_id> port <port_id>\n";
+
+static void
+cmd_pipeline_mirror_session(char **tokens,
+ uint32_t n_tokens,
+ char *out,
+ size_t out_size,
+ void *obj)
+{
+ struct rte_swx_pipeline_mirroring_session_params params;
+ struct pipeline *p;
+ uint32_t session_id;
+ int status;
+
+ if (n_tokens != 7) {
+ snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+ return;
+ }
+
+ if (strcmp(tokens[0], "pipeline")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+ return;
+ }
+
+ p = pipeline_find(obj, tokens[1]);
+ if (!p || !p->ctl) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name");
+ return;
+ }
+
+ if (strcmp(tokens[2], "mirror")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mirror");
+ return;
+ }
+
+ if (strcmp(tokens[3], "session")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "session");
+ return;
+ }
+
+ if (parser_read_uint32(&session_id, tokens[4])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "session_id");
+ return;
+ }
+
+ if (strcmp(tokens[5], "port")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+ return;
+ }
+
+ if (parser_read_uint32(¶ms.port_id, tokens[6])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+ return;
+ }
+
+ status = rte_swx_ctl_pipeline_mirroring_session_set(p->p, session_id, ¶ms);
+ if (status) {
+ snprintf(out, out_size, "Command failed!\n");
+ return;
+ }
+}
+
static const char cmd_thread_pipeline_enable_help[] =
"thread <thread_id> pipeline <pipeline_name> enable\n";
@@ -2837,6 +2962,8 @@ cmd_help(char **tokens,
"\tpipeline meter set\n"
"\tpipeline meter stats\n"
"\tpipeline stats\n"
+ "\tpipeline mirror\n"
+ "\tpipeline mirror session\n"
"\tthread pipeline enable\n"
"\tthread pipeline disable\n\n");
return;
@@ -3056,6 +3183,19 @@ cmd_help(char **tokens,
return;
}
+ if (!strcmp(tokens[0], "pipeline") &&
+ (n_tokens == 2) && !strcmp(tokens[1], "mirror")) {
+ snprintf(out, out_size, "\n%s\n", cmd_pipeline_mirror_help);
+ return;
+ }
+
+ if (!strcmp(tokens[0], "pipeline") &&
+ (n_tokens == 3) && !strcmp(tokens[1], "mirror")
+ && !strcmp(tokens[2], "session")) {
+ snprintf(out, out_size, "\n%s\n", cmd_pipeline_mirror_session_help);
+ return;
+ }
+
if ((n_tokens == 3) &&
(strcmp(tokens[0], "thread") == 0) &&
(strcmp(tokens[1], "pipeline") == 0)) {
@@ -3310,6 +3450,20 @@ cli_process(char *in, char *out, size_t out_size, void *obj)
obj);
return;
}
+
+ if ((n_tokens >= 4) &&
+ (strcmp(tokens[2], "mirror") == 0) &&
+ (strcmp(tokens[3], "slots") == 0)) {
+ cmd_pipeline_mirror(tokens, n_tokens, out, out_size, obj);
+ return;
+ }
+
+ if ((n_tokens >= 4) &&
+ (strcmp(tokens[2], "mirror") == 0) &&
+ (strcmp(tokens[3], "session") == 0)) {
+ cmd_pipeline_mirror_session(tokens, n_tokens, out, out_size, obj);
+ return;
+ }
}
if (strcmp(tokens[0], "thread") == 0) {
--
2.17.1
next prev parent reply other threads:[~2022-03-04 18:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 18:06 [PATCH 1/3] port: " Cristian Dumitrescu
2022-03-04 18:06 ` [PATCH 2/3] pipeline: " Cristian Dumitrescu
2022-03-04 18:06 ` Cristian Dumitrescu [this message]
2022-04-05 12:30 ` [PATCH V2 1/3] port: " Cristian Dumitrescu
2022-04-05 12:30 ` [PATCH V2 2/3] pipeline: " Cristian Dumitrescu
2022-04-05 12:30 ` [PATCH V2 3/3] examples/pipeline: " Cristian Dumitrescu
2022-04-05 21:36 ` [PATCH V3 1/4] port: " Cristian Dumitrescu
2022-04-05 21:36 ` [PATCH V3 2/4] pipeline: " Cristian Dumitrescu
2022-04-05 21:36 ` [PATCH V3 3/4] examples/pipeline: " Cristian Dumitrescu
2022-04-05 21:36 ` [PATCH V3 4/4] pipeline: support packet recirculation Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 1/6] port: support packet mirroring Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 2/6] pipeline: " Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 3/6] examples/pipeline: " Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 4/6] examples/pipeline: add packet mirroring example Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 5/6] pipeline: support packet recirculation Cristian Dumitrescu
2022-04-06 18:48 ` [PATCH V4 6/6] examples/pipeline: add packet recirculation example Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 1/6] port: support packet mirroring Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 2/6] pipeline: " Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 3/6] examples/pipeline: " Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 4/6] examples/pipeline: add packet mirroring example Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 5/6] pipeline: support packet recirculation Cristian Dumitrescu
2022-04-06 18:55 ` [PATCH V5 6/6] examples/pipeline: add packet recirculation example Cristian Dumitrescu
2022-06-01 12:44 ` [PATCH V5 1/6] port: support packet mirroring Thomas Monjalon
2022-06-01 13:01 ` 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=20220304180623.74893-3-cristian.dumitrescu@intel.com \
--to=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=yogesh.jangra@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).