Skip to contentSkip to conversation

app/testpmd: use table ID for jump to matcher action

PATCH Superseded Alexander Kozyrev 3 participants 6 messages Aug 19, 2025 – Oct 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 app/test-pmd/cmdline_flow.c | 59 +++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +57 -2
index 38e751f3f3..5d9c8f04f2 100644
@@ -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,
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Hi,

The testpmd maintainers should also take a look.

Quoted 116 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, August 19, 2025 10:45 PM
To: [email protected]
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>
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.

---
 app/test-pmd/cmdline_flow.c | 59 +++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +1 -0
index 38e751f3f3..5d9c8f04f2 100644
@@ -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 *,

app/test-pmd/cmdline_flow.c +13 -2
 			       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] = {
app/test-pmd/cmdline_flow.c +1 -0
 		.name = "index",
 		.help = "rule index to redirect traffic to", @@ -11182,6
+11194,49 @@ parse_table_destroy(struct context *ctx, const struct token

*token,

app/test-pmd/cmdline_flow.c +36 -0
 	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-
Quoted 1 line

port);

app/test-pmd/cmdline_flow.c +7 -0
+		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
Quoted 3 lines

parse_qo(struct context *ctx, const struct token *token, --
2.43.0

#2 lore raw
In reply to Alexander Kozyrev
Quoted 18 lines · On Tue, 19 Aug 2025 17:45:05 +0300 Alexander Kozyrev <[email protected]>…
app/test-pmd/cmdline_flow.c +18 -0
+/** 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 */

app/test-pmd/cmdline_flow.c parse_table_destroy(struct context *ctx, const struct token *token, · line 11224

Quoted 10 lines
app/test-pmd/cmdline_flow.c +10 -0
+	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;

This creates a possibly unaligned memory access. Is that OK?

Other code in cmdline_flow.c like parse_action is using memcpy to avoid this.

#3 lore raw
In reply to Alexander Kozyrev
Quoted 7 lines · On Tue, 19 Aug 2025 17:45:05 +0300 Alexander Kozyrev <[email protected]>…

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.

The cmdline code doesn't guarantee that the space in the context will be aligned. Therefore using memcpy like this (untested) would be safer. Please review this as possiblity and resubmit if needed.

app/test-pmd/cmdline_flow.c +2 -2
index 5d9c8f04f2..04d3dbbdca 100644
@@ -11221,7 +11221,7 @@ parse_jump_table_id(struct context *ctx, const struct token *token,
                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;
+       memcpy(&table_id, entry_ptr, sizeof(uint32_t));
        /* Look up the table using table ID */
        port = &ports[ctx->port];
        for (pt = port->table_list; pt != NULL; pt = pt->next) {
@@ -11233,7 +11233,7 @@ parse_jump_table_id(struct context *ctx, const struct token *token,
                return -1;
        }
        /* Replace the table ID with the table pointer */
-       *(struct rte_flow_template_table **)entry_ptr = pt->table;
+       memcpy(entry_ptr, &pt->table, sizeof(struct rte_flow_template_table *));
        return len;
 }
 
#4 lore raw

PATCH v2 1/1 app/testpmd: use table ID for jump to matcher action

In reply to Alexander Kozyrev

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.

---
 app/test-pmd/cmdline_flow.c | 59 +++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +57 -2
index 38e751f3f3..04d3dbbdca 100644
@@ -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;
+	memcpy(&table_id, entry_ptr, sizeof(uint32_t));
+	/* 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 */
+	memcpy(entry_ptr, &pt->table, sizeof(struct rte_flow_template_table *));
+	return len;
+}
+
 /** Parse tokens for queue create commands. */
 static int
 parse_qo(struct context *ctx, const struct token *token,
Signature · 1 line
2.43.0
#5 lore raw
Quoted 8 lines · On Fri, 26 Sep 2025 15:30:33 +0300 Alexander Kozyrev <[email protected]>…

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.

---

Queued to next-net