From: Alexander Kozyrev <akozyrev@nvidia.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <ferruh.yigit@amd.com>,
<andrew.rybchenko@oktetlabs.ru>, <orika@nvidia.com>
Subject: [PATCH v2 3/4] app/testpmd: add template table insertion type
Date: Fri, 27 Jan 2023 01:28:01 +0200 [thread overview]
Message-ID: <20230126232802.3960109-4-akozyrev@nvidia.com> (raw)
In-Reply-To: <20230126232802.3960109-1-akozyrev@nvidia.com>
Add testpmd CLI interface for specifying a template table insertion type.
Available types are: pattern and index.
flow template_table 0 create table_id 0 insertion_type index ...
Allow specifying the rule index instead of the pattern template index:
flow queue 0 create 0 template_table 0 rule_index 5 actions_template 0 ...
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
app/test-pmd/cmdline_flow.c | 97 ++++++++++++++++++++++++++++++++++---
app/test-pmd/config.c | 10 ++--
app/test-pmd/testpmd.h | 2 +-
3 files changed, 99 insertions(+), 10 deletions(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 88108498e0..f1d6813baa 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -133,12 +133,11 @@ enum index {
QUEUE_INDIRECT_ACTION,
/* Queue create arguments. */
- QUEUE_CREATE_ID,
QUEUE_CREATE_POSTPONE,
QUEUE_TEMPLATE_TABLE,
QUEUE_PATTERN_TEMPLATE,
QUEUE_ACTIONS_TEMPLATE,
- QUEUE_SPEC,
+ QUEUE_RULE_ID,
/* Queue destroy arguments. */
QUEUE_DESTROY_ID,
@@ -179,6 +178,8 @@ enum index {
TABLE_DESTROY,
TABLE_CREATE_ID,
TABLE_DESTROY_ID,
+ TABLE_INSERTION_TYPE,
+ TABLE_INSERTION_TYPE_NAME,
TABLE_GROUP,
TABLE_PRIORITY,
TABLE_INGRESS,
@@ -814,6 +815,12 @@ static const char *const meter_colors[] = {
"green", "yellow", "red", "all", NULL
};
+static const char *const table_insertion_types[] = {
+ "pattern", "index", NULL
+};
+
+#define RAW_IPSEC_CONFS_MAX_NUM 8
+
/** Maximum number of subsequent tokens and arguments on the stack. */
#define CTX_STACK_SIZE 16
@@ -1015,6 +1022,7 @@ struct buffer {
struct {
uint32_t table_id;
uint32_t pat_templ_id;
+ uint32_t rule_id;
uint32_t act_templ_id;
struct rte_flow_attr attr;
struct tunnel_ops tunnel_ops;
@@ -1154,6 +1162,7 @@ static const enum index next_table_subcmd[] = {
static const enum index next_table_attr[] = {
TABLE_CREATE_ID,
TABLE_GROUP,
+ TABLE_INSERTION_TYPE,
TABLE_PRIORITY,
TABLE_INGRESS,
TABLE_EGRESS,
@@ -1287,6 +1296,12 @@ static const enum index next_ia_destroy_attr[] = {
ZERO,
};
+static const enum index next_async_insert_subcmd[] = {
+ QUEUE_PATTERN_TEMPLATE,
+ QUEUE_RULE_ID,
+ ZERO,
+};
+
static const enum index item_param[] = {
ITEM_PARAM_IS,
ITEM_PARAM_SPEC,
@@ -2399,6 +2414,9 @@ static int parse_meter_policy_id2ptr(struct context *ctx,
static int parse_meter_color(struct context *ctx, const struct token *token,
const char *str, unsigned int len, void *buf,
unsigned int size);
+static int parse_insertion_table_type(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len, void *buf,
+ unsigned int size);
static int comp_none(struct context *, const struct token *,
unsigned int, char *, unsigned int);
static int comp_boolean(struct context *, const struct token *,
@@ -2431,6 +2449,8 @@ static int comp_queue_id(struct context *, const struct token *,
unsigned int, char *, unsigned int);
static int comp_meter_color(struct context *, const struct token *,
unsigned int, char *, unsigned int);
+static int comp_insertion_table_type(struct context *, const struct token *,
+ unsigned int, char *, unsigned int);
/** Token definitions. */
static const struct token token_list[] = {
@@ -2901,6 +2921,20 @@ static const struct token token_list[] = {
args.table_destroy.table_id)),
.call = parse_table_destroy,
},
+ [TABLE_INSERTION_TYPE] = {
+ .name = "insertion_type",
+ .help = "specify insertion type",
+ .next = NEXT(next_table_attr,
+ NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)),
+ .args = ARGS(ARGS_ENTRY(struct buffer,
+ args.table.attr.insertion_type)),
+ },
+ [TABLE_INSERTION_TYPE_NAME] = {
+ .name = "insertion_type_name",
+ .help = "insertion type name",
+ .call = parse_insertion_table_type,
+ .comp = comp_insertion_table_type,
+ },
[TABLE_GROUP] = {
.name = "group",
.help = "specify a group",
@@ -3002,7 +3036,7 @@ static const struct token token_list[] = {
[QUEUE_TEMPLATE_TABLE] = {
.name = "template_table",
.help = "specify table id",
- .next = NEXT(NEXT_ENTRY(QUEUE_PATTERN_TEMPLATE),
+ .next = NEXT(next_async_insert_subcmd,
NEXT_ENTRY(COMMON_TABLE_ID)),
.args = ARGS(ARGS_ENTRY(struct buffer,
args.vc.table_id)),
@@ -3026,6 +3060,15 @@ static const struct token token_list[] = {
args.vc.act_templ_id)),
.call = parse_qo,
},
+ [QUEUE_RULE_ID] = {
+ .name = "rule_index",
+ .help = "specify flow rule index",
+ .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
+ NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct buffer,
+ args.vc.rule_id)),
+ .call = parse_qo,
+ },
[QUEUE_CREATE_POSTPONE] = {
.name = "postpone",
.help = "postpone create operation",
@@ -9069,11 +9112,13 @@ parse_qo(struct context *ctx, const struct token *token,
ctx->objdata = 0;
ctx->object = out;
ctx->objmask = NULL;
+ out->args.vc.rule_id = UINT32_MAX;
return len;
case QUEUE_TEMPLATE_TABLE:
case QUEUE_PATTERN_TEMPLATE:
case QUEUE_ACTIONS_TEMPLATE:
case QUEUE_CREATE_POSTPONE:
+ case QUEUE_RULE_ID:
return len;
case ITEM_PATTERN:
out->args.vc.pattern =
@@ -10052,6 +10097,32 @@ parse_meter_color(struct context *ctx, const struct token *token,
return len;
}
+/** Parse Insertion Table Type name */
+static int
+parse_insertion_table_type(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len, void *buf,
+ unsigned int size)
+{
+ const struct arg *arg = pop_args(ctx);
+ unsigned int i;
+ char tmp[2];
+ int ret;
+
+ (void)size;
+ /* Argument is expected. */
+ if (!arg)
+ return -1;
+ for (i = 0; table_insertion_types[i]; ++i)
+ if (!strcmp_partial(table_insertion_types[i], str, len))
+ break;
+ if (!table_insertion_types[i])
+ return -1;
+ push_args(ctx, arg);
+ snprintf(tmp, sizeof(tmp), "%u", i);
+ ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
+ return ret > 0 ? (int)len : ret;
+}
+
/** No completion. */
static int
comp_none(struct context *ctx, const struct token *token,
@@ -10357,6 +10428,20 @@ comp_meter_color(struct context *ctx, const struct token *token,
return -1;
}
+/** Complete available Insertion Table types. */
+static int
+comp_insertion_table_type(struct context *ctx, const struct token *token,
+ unsigned int ent, char *buf, unsigned int size)
+{
+ RTE_SET_USED(ctx);
+ RTE_SET_USED(token);
+ if (!buf)
+ return RTE_DIM(table_insertion_types);
+ if (ent < RTE_DIM(table_insertion_types) - 1)
+ return rte_strscpy(buf, table_insertion_types[ent], size);
+ return -1;
+}
+
/** Internal context. */
static struct context cmd_flow_context;
@@ -10670,9 +10755,9 @@ cmd_flow_parsed(const struct buffer *in)
break;
case QUEUE_CREATE:
port_queue_flow_create(in->port, in->queue, in->postpone,
- in->args.vc.table_id, in->args.vc.pat_templ_id,
- in->args.vc.act_templ_id, in->args.vc.pattern,
- in->args.vc.actions);
+ in->args.vc.table_id, in->args.vc.rule_id,
+ in->args.vc.pat_templ_id, in->args.vc.act_templ_id,
+ in->args.vc.pattern, in->args.vc.actions);
break;
case QUEUE_DESTROY:
port_queue_flow_destroy(in->port, in->queue, in->postpone,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index acccb6b035..41484c3dde 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2609,7 +2609,7 @@ port_flow_template_table_flush(portid_t port_id)
/** Enqueue create flow rule operation. */
int
port_queue_flow_create(portid_t port_id, queueid_t queue_id,
- bool postpone, uint32_t table_id,
+ bool postpone, uint32_t table_id, uint32_t rule_idx,
uint32_t pattern_idx, uint32_t actions_idx,
const struct rte_flow_item *pattern,
const struct rte_flow_action *actions)
@@ -2685,8 +2685,12 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id,
}
/* Poisoning to make sure PMDs update it in case of error. */
memset(&error, 0x11, sizeof(error));
- flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table,
- pattern, pattern_idx, actions, actions_idx, job, &error);
+ if (rule_idx == UINT32_MAX)
+ flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table,
+ pattern, pattern_idx, actions, actions_idx, job, &error);
+ else
+ flow = rte_flow_async_create_by_index(port_id, queue_id, &op_attr, pt->table,
+ rule_idx, actions, actions_idx, job, &error);
if (!flow) {
uint32_t flow_id = pf->id;
port_queue_flow_destroy(port_id, queue_id, true, 1, &flow_id);
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 7d24d25970..22d02a742c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -930,7 +930,7 @@ int port_flow_template_table_destroy(portid_t port_id,
uint32_t n, const uint32_t *table);
int port_flow_template_table_flush(portid_t port_id);
int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
- bool postpone, uint32_t table_id,
+ bool postpone, uint32_t table_id, uint32_t rule_idx,
uint32_t pattern_idx, uint32_t actions_idx,
const struct rte_flow_item *pattern,
const struct rte_flow_action *actions);
--
2.18.2
next prev parent reply other threads:[~2023-01-26 23:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 2:21 [RFC] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-01-08 14:22 ` Ori Kam
2023-01-18 8:50 ` Thomas Monjalon
2023-01-20 23:06 ` Alexander Kozyrev
2023-01-22 20:55 ` Thomas Monjalon
2023-01-23 22:02 ` Alexander Kozyrev
2023-01-30 14:47 ` Thomas Monjalon
2023-01-21 5:21 ` [PATCH 0/4] " Alexander Kozyrev
2023-01-21 5:21 ` [PATCH 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-01-21 5:21 ` [PATCH 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-01-21 5:21 ` [PATCH 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-01-21 5:21 ` [PATCH 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-01-26 23:27 ` [PATCH v2 0/4] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-01-26 23:27 ` [PATCH v2 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-02 10:57 ` Andrew Rybchenko
2023-02-07 15:06 ` Alexander Kozyrev
2023-01-26 23:28 ` [PATCH v2 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-01-26 23:28 ` Alexander Kozyrev [this message]
2023-01-26 23:28 ` [PATCH v2 4/4] app/testpmd: " Alexander Kozyrev
2023-02-01 16:09 ` [PATCH v2 0/4] ethdev: add template table insertion and matching types Ori Kam
2023-02-08 2:47 ` [PATCH v3 " Alexander Kozyrev
2023-02-08 2:47 ` [PATCH v3 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-08 2:47 ` [PATCH v3 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-02-08 2:47 ` [PATCH v3 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-02-08 2:47 ` [PATCH v3 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-02-08 3:06 ` [PATCH v4 0/4] ethdev: add template table insertion and matching types Alexander Kozyrev
2023-02-08 3:06 ` [PATCH v4 1/4] ethdev: add template table insertion type Alexander Kozyrev
2023-02-08 3:06 ` [PATCH v4 2/4] ethdev: add template table hash calculation function Alexander Kozyrev
2023-02-08 3:06 ` [PATCH v4 3/4] app/testpmd: add template table insertion type Alexander Kozyrev
2023-02-08 3:06 ` [PATCH v4 4/4] app/testpmd: add template table hash calculation function Alexander Kozyrev
2023-02-10 17:42 ` [PATCH v4 0/4] ethdev: add template table insertion and matching types 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=20230126232802.3960109-4-akozyrev@nvidia.com \
--to=akozyrev@nvidia.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=orika@nvidia.com \
--cc=thomas@monjalon.net \
/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).