DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@nvidia.com>
To: Alexander Kozyrev <akozyrev@nvidia.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>,
	Raslan Darawsheh <rasland@nvidia.com>, Ori Kam <orika@nvidia.com>,
	"NBU-Contact-Thomas Monjalon (EXTERNAL)" <thomas@monjalon.net>
Subject: RE: [PATCH] app/testpmd: use table ID for jump to matcher action
Date: Tue, 19 Aug 2025 14:50:40 +0000	[thread overview]
Message-ID: <IA4PR12MB9763631C4FA0466668F81E41D030A@IA4PR12MB9763.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20250819144508.722653-1-akozyrev@nvidia.com>

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>


      reply	other threads:[~2025-08-19 14:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 14:45 Alexander Kozyrev
2025-08-19 14:50 ` Bing Zhao [this message]

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=IA4PR12MB9763631C4FA0466668F81E41D030A@IA4PR12MB9763.namprd12.prod.outlook.com \
    --to=bingz@nvidia.com \
    --cc=akozyrev@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --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).