DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: use table ID for jump to matcher action
@ 2025-08-19 14:45 Alexander Kozyrev
  2025-08-19 14:50 ` Bing Zhao
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kozyrev @ 2025-08-19 14:45 UTC (permalink / raw)
  To: dev; +Cc: stable, rasland, bingz, orika

Current implementation requires specifying the pointer to the table
you want to jump to in the jump to matcher action. It is inconvenient
since there is no table pointer shown anywhere in the table management.
Table creation/destruction uses the standard table ID for that purpose.
Use the table ID in the jump to matcher action as well.

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 59 +++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 38e751f3f3..5d9c8f04f2 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -788,6 +788,7 @@ enum index {
 	ACTION_NAT64_MODE,
 	ACTION_JUMP_TO_TABLE_INDEX,
 	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
+	ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE,
 	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
 };
 
@@ -2864,6 +2865,9 @@ static int parse_table(struct context *, const struct token *,
 static int parse_table_destroy(struct context *, const struct token *,
 			       const char *, unsigned int,
 			       void *, unsigned int);
+static int parse_jump_table_id(struct context *, const struct token *,
+			       const char *, unsigned int,
+			       void *, unsigned int);
 static int parse_qo(struct context *, const struct token *,
 		    const char *, unsigned int,
 		    void *, unsigned int);
@@ -7634,11 +7638,19 @@ static const struct token token_list[] = {
 	},
 	[ACTION_JUMP_TO_TABLE_INDEX_TABLE] = {
 		.name = "table",
-		.help = "table to redirect traffic to",
-		.next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
+		.help = "table id to redirect traffic to",
+		.next = NEXT(action_jump_to_table_index,
+			NEXT_ENTRY(ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE)),
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE] = {
+		.name = "{table_id}",
+		.type = "TABLE_ID",
+		.help = "table id for jump action",
+		.call = parse_jump_table_id,
+		.comp = comp_table_id,
+	},
 	[ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
 		.name = "index",
 		.help = "rule index to redirect traffic to",
@@ -11182,6 +11194,49 @@ parse_table_destroy(struct context *ctx, const struct token *token,
 	return len;
 }
 
+/** Parse table id and convert to table pointer for jump_to_table_index action. */
+static int
+parse_jump_table_id(struct context *ctx, const struct token *token,
+		    const char *str, unsigned int len,
+		    void *buf, unsigned int size)
+{
+	struct buffer *out = buf;
+	struct rte_port *port;
+	struct port_table *pt;
+	uint32_t table_id;
+	const struct arg *arg;
+	void *entry_ptr;
+
+	/* Get the arg before parse_int consumes it */
+	arg = pop_args(ctx);
+	if (!arg)
+		return -1;
+	/* Push it back and do the standard integer parsing */
+	if (push_args(ctx, arg) < 0)
+		return -1;
+	if (parse_int(ctx, token, str, len, buf, size) < 0)
+		return -1;
+	/* Nothing else to do if there is no buffer */
+	if (!out || !ctx->object)
+		return len;
+	/* Get the parsed table ID from where parse_int stored it */
+	entry_ptr = (uint8_t *)ctx->object + arg->offset;
+	table_id = *(uint32_t *)entry_ptr;
+	/* Look up the table using table ID */
+	port = &ports[ctx->port];
+	for (pt = port->table_list; pt != NULL; pt = pt->next) {
+		if (pt->id == table_id)
+			break;
+	}
+	if (!pt || !pt->table) {
+		printf("Table #%u not found on port %u\n", table_id, ctx->port);
+		return -1;
+	}
+	/* Replace the table ID with the table pointer */
+	*(struct rte_flow_template_table **)entry_ptr = pt->table;
+	return len;
+}
+
 /** Parse tokens for queue create commands. */
 static int
 parse_qo(struct context *ctx, const struct token *token,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] app/testpmd: use table ID for jump to matcher action
  2025-08-19 14:45 [PATCH] app/testpmd: use table ID for jump to matcher action Alexander Kozyrev
@ 2025-08-19 14:50 ` Bing Zhao
  0 siblings, 0 replies; 2+ messages in thread
From: Bing Zhao @ 2025-08-19 14:50 UTC (permalink / raw)
  To: Alexander Kozyrev, dev
  Cc: stable, Raslan Darawsheh, Ori Kam,
	NBU-Contact-Thomas Monjalon (EXTERNAL)

Hi,

The testpmd maintainers should also take a look.

> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Tuesday, August 19, 2025 10:45 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>; Bing Zhao
> <bingz@nvidia.com>; Ori Kam <orika@nvidia.com>
> Subject: [PATCH] app/testpmd: use table ID for jump to matcher action
> 
> Current implementation requires specifying the pointer to the table you
> want to jump to in the jump to matcher action. It is inconvenient since
> there is no table pointer shown anywhere in the table management.
> Table creation/destruction uses the standard table ID for that purpose.
> Use the table ID in the jump to matcher action as well.
> 
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c | 59 +++++++++++++++++++++++++++++++++++--
>  1 file changed, 57 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 38e751f3f3..5d9c8f04f2 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -788,6 +788,7 @@ enum index {
>  	ACTION_NAT64_MODE,
>  	ACTION_JUMP_TO_TABLE_INDEX,
>  	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
> +	ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE,
>  	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
>  };
> 
> @@ -2864,6 +2865,9 @@ static int parse_table(struct context *, const
> struct token *,  static int parse_table_destroy(struct context *, const
> struct token *,
>  			       const char *, unsigned int,
>  			       void *, unsigned int);
> +static int parse_jump_table_id(struct context *, const struct token *,
> +			       const char *, unsigned int,
> +			       void *, unsigned int);
>  static int parse_qo(struct context *, const struct token *,
>  		    const char *, unsigned int,
>  		    void *, unsigned int);
> @@ -7634,11 +7638,19 @@ static const struct token token_list[] = {
>  	},
>  	[ACTION_JUMP_TO_TABLE_INDEX_TABLE] = {
>  		.name = "table",
> -		.help = "table to redirect traffic to",
> -		.next = NEXT(action_jump_to_table_index,
> NEXT_ENTRY(COMMON_UNSIGNED)),
> +		.help = "table id to redirect traffic to",
> +		.next = NEXT(action_jump_to_table_index,
> +			NEXT_ENTRY(ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE)),
>  		.args = ARGS(ARGS_ENTRY(struct
> rte_flow_action_jump_to_table_index, table)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE] = {
> +		.name = "{table_id}",
> +		.type = "TABLE_ID",
> +		.help = "table id for jump action",
> +		.call = parse_jump_table_id,
> +		.comp = comp_table_id,
> +	},
>  	[ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
>  		.name = "index",
>  		.help = "rule index to redirect traffic to", @@ -11182,6
> +11194,49 @@ parse_table_destroy(struct context *ctx, const struct token
> *token,
>  	return len;
>  }
> 
> +/** Parse table id and convert to table pointer for jump_to_table_index
> +action. */ static int parse_jump_table_id(struct context *ctx, const
> +struct token *token,
> +		    const char *str, unsigned int len,
> +		    void *buf, unsigned int size)
> +{
> +	struct buffer *out = buf;
> +	struct rte_port *port;
> +	struct port_table *pt;
> +	uint32_t table_id;
> +	const struct arg *arg;
> +	void *entry_ptr;
> +
> +	/* Get the arg before parse_int consumes it */
> +	arg = pop_args(ctx);
> +	if (!arg)
> +		return -1;
> +	/* Push it back and do the standard integer parsing */
> +	if (push_args(ctx, arg) < 0)
> +		return -1;
> +	if (parse_int(ctx, token, str, len, buf, size) < 0)
> +		return -1;
> +	/* Nothing else to do if there is no buffer */
> +	if (!out || !ctx->object)
> +		return len;
> +	/* Get the parsed table ID from where parse_int stored it */
> +	entry_ptr = (uint8_t *)ctx->object + arg->offset;
> +	table_id = *(uint32_t *)entry_ptr;
> +	/* Look up the table using table ID */
> +	port = &ports[ctx->port];
> +	for (pt = port->table_list; pt != NULL; pt = pt->next) {
> +		if (pt->id == table_id)
> +			break;
> +	}
> +	if (!pt || !pt->table) {
> +		printf("Table #%u not found on port %u\n", table_id, ctx-
> >port);
> +		return -1;
> +	}
> +	/* Replace the table ID with the table pointer */
> +	*(struct rte_flow_template_table **)entry_ptr = pt->table;
> +	return len;
> +}
> +
>  /** Parse tokens for queue create commands. */  static int
> parse_qo(struct context *ctx, const struct token *token,
> --
> 2.43.0

Reviewed-by: Bing Zhao <bingz@nvidia.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-19 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-19 14:45 [PATCH] app/testpmd: use table ID for jump to matcher action Alexander Kozyrev
2025-08-19 14:50 ` Bing Zhao

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).