From: Haifei Luo <haifeil@nvidia.com>
To: dev@dpdk.org
Cc: orika@nvidia.com, viacheslavo@nvidia.com, rasland@nvidia.com,
xuemingl@nvidia.com, haifeil@nvidia.com,
ajit.khaparde@broadcom.com, Xiaoyun Li <xiaoyun.li@intel.com>
Subject: [dpdk-dev] [PATCH v6 2/2] app/testpmd: add CLIs for single flow dump feature
Date: Wed, 14 Apr 2021 13:20:00 +0300 [thread overview]
Message-ID: <1618395600-215396-3-git-send-email-haifeil@nvidia.com> (raw)
In-Reply-To: <1618395600-215396-1-git-send-email-haifeil@nvidia.com>
Add support for single flow dump.
The CLIs to dump one rule: flow dump PORT rule ID
to dump all: flow dump PORT all
Examples:
testpmd> flow dump 0 all
testpmd> flow dump 0 rule 0
Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
app/test-pmd/cmdline_flow.c | 55 +++++++++++++++++++++++++----
app/test-pmd/config.c | 38 ++++++++++++++++++--
app/test-pmd/testpmd.h | 3 +-
doc/guides/rel_notes/release_21_05.rst | 2 ++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +++-
5 files changed, 92 insertions(+), 12 deletions(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fb7a3a8..0127d9e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -108,6 +108,10 @@ enum index {
TUNNEL_SET,
TUNNEL_MATCH,
+ /* Dump arguments */
+ DUMP_ALL,
+ DUMP_ONE,
+
/* Shared action arguments */
SHARED_ACTION_CREATE,
SHARED_ACTION_UPDATE,
@@ -793,6 +797,8 @@ struct buffer {
} destroy; /**< Destroy arguments. */
struct {
char file[128];
+ bool mode;
+ uint32_t rule;
} dump; /**< Dump arguments. */
struct {
uint32_t rule;
@@ -844,6 +850,12 @@ struct parse_action_priv {
ZERO,
};
+static const enum index next_dump_subcmd[] = {
+ DUMP_ALL,
+ DUMP_ONE,
+ ZERO,
+};
+
static const enum index next_sa_subcmd[] = {
SHARED_ACTION_CREATE,
SHARED_ACTION_UPDATE,
@@ -2032,10 +2044,9 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
},
[DUMP] = {
.name = "dump",
- .help = "dump all flow rules to file",
- .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
- .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
- ARGS_ENTRY(struct buffer, port)),
+ .help = "dump single/all flow rules to file",
+ .next = NEXT(next_dump_subcmd, NEXT_ENTRY(PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
.call = parse_dump,
},
[QUERY] = {
@@ -2125,6 +2136,22 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
.args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
.call = parse_destroy,
},
+ /* Dump arguments. */
+ [DUMP_ALL] = {
+ .name = "all",
+ .help = "dump all",
+ .next = NEXT(next_dump_attr),
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
+ .call = parse_dump,
+ },
+ [DUMP_ONE] = {
+ .name = "rule",
+ .help = "dump one rule",
+ .next = NEXT(next_dump_attr, NEXT_ENTRY(RULE_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
+ ARGS_ENTRY(struct buffer, args.dump.rule)),
+ .call = parse_dump,
+ },
/* Query arguments. */
[QUERY_ACTION] = {
.name = "{action}",
@@ -6364,8 +6391,20 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
ctx->objdata = 0;
ctx->object = out;
ctx->objmask = NULL;
+ return len;
+ }
+ switch (ctx->curr) {
+ case DUMP_ALL:
+ case DUMP_ONE:
+ out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
+ out->command = ctx->curr;
+ ctx->objdata = 0;
+ ctx->object = out;
+ ctx->objmask = NULL;
+ return len;
+ default:
+ return -1;
}
- return len;
}
/** Parse tokens for query command. */
@@ -7659,8 +7698,10 @@ static int comp_set_modify_field_id(struct context *, const struct token *,
case FLUSH:
port_flow_flush(in->port);
break;
- case DUMP:
- port_flow_dump(in->port, in->args.dump.file);
+ case DUMP_ONE:
+ case DUMP_ALL:
+ port_flow_dump(in->port, in->args.dump.mode,
+ in->args.dump.rule, in->args.dump.file);
break;
case QUERY:
port_flow_query(in->port, in->args.query.rule,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ca34a63..40b2b29 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1916,13 +1916,41 @@ struct rte_flow_shared_action *
return ret;
}
-/** Dump all flow rules. */
+/** Dump flow rules. */
int
-port_flow_dump(portid_t port_id, const char *file_name)
+port_flow_dump(portid_t port_id, bool dump_all, uint32_t rule_id,
+ const char *file_name)
{
int ret = 0;
FILE *file = stdout;
struct rte_flow_error error;
+ struct rte_port *port;
+ struct port_flow *pflow;
+ struct rte_flow *tmpFlow = NULL;
+ bool found = false;
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+ port_id == (portid_t)RTE_PORT_ALL)
+ return -EINVAL;
+
+ if (!dump_all) {
+ port = &ports[port_id];
+ pflow = port->flow_list;
+ while (pflow) {
+ if (rule_id != pflow->id) {
+ pflow = pflow->next;
+ } else {
+ tmpFlow = pflow->flow;
+ if (tmpFlow)
+ found = true;
+ break;
+ }
+ }
+ if (found == false) {
+ printf("Failed to dump to flow %d\n", rule_id);
+ return -EINVAL;
+ }
+ }
if (file_name && strlen(file_name)) {
file = fopen(file_name, "w");
@@ -1932,7 +1960,11 @@ struct rte_flow_shared_action *
return -errno;
}
}
- ret = rte_flow_dev_dump(port_id, NULL, file, &error);
+
+ if (!dump_all)
+ ret = rte_flow_dev_dump(port_id, tmpFlow, file, &error);
+ else
+ ret = rte_flow_dev_dump(port_id, NULL, file, &error);
if (ret) {
port_flow_complain(&error);
printf("Failed to dump flow: %s\n", strerror(-ret));
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a87ccb0..36d8535 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -825,7 +825,8 @@ void update_age_action_context(const struct rte_flow_action *actions,
struct port_flow *pf);
int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
int port_flow_flush(portid_t port_id);
-int port_flow_dump(portid_t port_id, const char *file_name);
+int port_flow_dump(portid_t port_id, bool dump_all,
+ uint32_t rule, const char *file_name);
int port_flow_query(portid_t port_id, uint32_t rule,
const struct rte_flow_action *action);
void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 6d209a2..e3ae470 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -174,6 +174,8 @@ New Features
``dpdk-testpmd -- --eth-link-speed N``
* Added command to display Rx queue used descriptor count.
``show port (port_id) rxq (queue_id) desc used count``
+ * Added command to dump internal representation information of single flow.
+ ``flow dump (port_id) rule (rule_id)``
Removed Items
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 36f0a32..5454524 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3332,7 +3332,11 @@ following sections.
- Dump internal representation information of all flows in hardware::
- flow dump {port_id} {output_file}
+ flow dump {port_id} all {output_file}
+
+ for one flow :
+
+ flow dump {port_id} rule {rule_id} {output_file}
- List and destroy aged flow rules::
--
1.8.3.1
next prev parent reply other threads:[~2021-04-14 10:20 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 8:15 [dpdk-dev] [PATCH 0/4] *** Support for one flow dump *** Haifei Luo
2021-03-09 8:15 ` [dpdk-dev] [PATCH 1/4] ethdev: add rte API for single flow dump Haifei Luo
2021-03-10 0:39 ` Stephen Hemminger
2021-03-10 7:05 ` Ori Kam
2021-03-09 8:15 ` [dpdk-dev] [PATCH 2/4] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-03-09 8:15 ` [dpdk-dev] [PATCH 3/4] common/mlx5: add mlx5 APIs " Haifei Luo
2021-03-09 8:15 ` [dpdk-dev] [PATCH 4/4] net/mlx5: " Haifei Luo
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 0/5] support single flow dump Haifei Luo
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 1/5] ethdev: modify rte API for " Haifei Luo
2021-04-12 19:33 ` Ori Kam
2021-04-13 4:38 ` Ajit Khaparde
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 2/5] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-13 16:36 ` Ajit Khaparde
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 3/5] common/mlx5: add mlx5 APIs " Haifei Luo
2021-04-12 7:32 ` Slava Ovsiienko
2021-04-13 16:44 ` Kinsella, Ray
2021-04-14 2:40 ` Haifei Luo
2021-04-14 6:21 ` David Marchand
2021-04-14 6:23 ` Haifei Luo
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 4/5] net/mlx5: " Haifei Luo
2021-04-12 7:29 ` Slava Ovsiienko
2021-04-12 7:37 ` Slava Ovsiienko
2021-04-13 1:29 ` Haifei Luo
2021-04-13 7:22 ` Haifei Luo
2021-04-13 7:39 ` Slava Ovsiienko
2021-04-07 6:09 ` [dpdk-dev] [PATCH v2 5/5] doc: add single flow dump to guides Haifei Luo
2021-04-14 6:13 ` [dpdk-dev] [PATCH v3 0/3] support single flow dump Haifei Luo
2021-04-14 6:13 ` [dpdk-dev] [PATCH v3 1/3] ethdev: modify rte API for " Haifei Luo
2021-04-14 6:13 ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14 6:13 ` [dpdk-dev] [PATCH v3 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14 8:23 ` Ferruh Yigit
2021-04-14 8:25 ` Haifei Luo
2021-04-14 10:00 ` Haifei Luo
2021-04-14 8:41 ` [dpdk-dev] [PATCH v4 0/3] support single flow dump Haifei Luo
2021-04-14 8:41 ` [dpdk-dev] [PATCH v4 1/3] ethdev: modify rte API for " Haifei Luo
2021-04-14 8:57 ` Thomas Monjalon
2021-04-14 9:10 ` Haifei Luo
2021-04-14 9:01 ` Thomas Monjalon
2021-04-14 9:07 ` Haifei Luo
2021-04-14 9:31 ` Thomas Monjalon
2021-04-14 8:41 ` [dpdk-dev] [PATCH v4 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14 8:41 ` [dpdk-dev] [PATCH v4 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14 9:15 ` Ferruh Yigit
2021-04-14 9:51 ` [dpdk-dev] [PATCH v5 0/3] support single flow dump Haifei Luo
2021-04-14 9:51 ` [dpdk-dev] [PATCH v5 1/3] ethdev: dump single flow rule Haifei Luo
2021-04-14 10:33 ` Thomas Monjalon
2021-04-14 10:37 ` Haifei Luo
2021-04-14 9:51 ` [dpdk-dev] [PATCH v5 2/3] app/testpmd: add CLIs for single flow dump feature Haifei Luo
2021-04-14 9:51 ` [dpdk-dev] [PATCH v5 3/3] doc: add single flow dump to guides Haifei Luo
2021-04-14 10:19 ` [dpdk-dev] [PATCH v6 0/2] single flow dump Haifei Luo
2021-04-14 10:19 ` [dpdk-dev] [PATCH v6 1/2] ethdev: dump single flow rule Haifei Luo
2021-04-14 10:20 ` Haifei Luo [this message]
2021-04-14 11:26 ` [dpdk-dev] [PATCH v6 0/2] single flow dump Ferruh Yigit
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=1618395600-215396-3-git-send-email-haifeil@nvidia.com \
--to=haifeil@nvidia.com \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=viacheslavo@nvidia.com \
--cc=xiaoyun.li@intel.com \
--cc=xuemingl@nvidia.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).