Skip to contentSkip to conversation

ethdev: jump to table support

PATCH Superseded Alexander Kozyrev 4 participants 30 messages Sep 19, 2024 – Sep 27, 2024

lore
Share & tools
lore
#0 lore raw

cover ethdev: jump to table support

Introduce new Flow API JUMP_TO_TABLE_INDEX action. It allows bypassing a hierarchy of groups and going directly to a specified flow table. That gives a user the flexibility to jump between different priorities in a group and eliminates the need to do a table lookup in the group hierarchy. The JUMP_TO_TABLE_INDEX action forwards a packet to the specified rule index inside the index-based flow table.

The current index-based flow table doesn't do any matching on the packet and executes the actions immediately. Add a new index-based flow table with pattern matching. The JUMP_TO_TABLE_INDEX can redirect a packet to another matching criteria at the specified index in this case.

RFC: https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/

Alexander Kozyrev (6):
ethdev: add insertion by index with pattern app/testpmd: add index with pattern insertion type
ethdev: add flow rule insertion by index with pattern app/testpmd: add insertion by index with pattern option
ethdev: add jump to table index action app/testpmd: add jump to table index action

 app/test-pmd/cmdline_flow.c            | 44 +++++++++++++-
 app/test-pmd/config.c                  | 22 +++++--
 app/test-pmd/testpmd.h                 |  2 +-
 doc/guides/prog_guide/rte_flow.rst     | 20 +++++++
 doc/guides/rel_notes/release_24_11.rst | 13 +++++
 lib/ethdev/ethdev_trace.h              | 44 ++++++++++++++
 lib/ethdev/ethdev_trace_points.c       |  6 ++
 lib/ethdev/rte_flow.c                  | 56 ++++++++++++++++++
 lib/ethdev/rte_flow.h                  | 81 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           | 14 +++++
 lib/ethdev/version.map                 |  3 +
 11 files changed, 296 insertions(+), 9 deletions(-)
Signature · 1 line
2.18.2
#1 lore raw

PATCH 1/6 ethdev: add insertion by index with pattern

There are two flow table rules insertion type today:
pattern-based insertion when packets match on the pattern and index-based insertion when packets always hit at the index. We need another mode that allows to match on the pattern at the index: insertion by index with pattern.

---
 doc/guides/rel_notes/release_24_11.rst | 4 ++++
 lib/ethdev/rte_flow.h                  | 4 ++++
 2 files changed, 8 insertions(+)
doc/guides/rel_notes/release_24_11.rst +4 -0
index 0ff70d9057..7056f17f3c 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added a new insertion by index with pattern table insertion type.**
+
+  Extended rte_flow_table_insertion_type enum with new
+  RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN type.
 
 Removed Items
 -------------
lib/ethdev/rte_flow.h +4 -0
index f864578f80..6f30dd7ae9 100644
@@ -5898,6 +5898,10 @@ enum rte_flow_table_insertion_type {
 	 * Index-based insertion.
 	 */
 	RTE_FLOW_TABLE_INSERTION_TYPE_INDEX,
+	/**
+	 * Index-based insertion with pattern.
+	 */
+	RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN,
 };
 
 /**
Signature · 1 line
2.18.2
Acked-by on v1 1/6
#2 lore raw

RE: [PATCH 1/6] ethdev: add insertion by index with pattern

Quoted 10 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 1/6] ethdev: add insertion by index with pattern

Quoted 7 lines

There are two flow table rules insertion type today:
pattern-based insertion when packets match on the pattern and index-based insertion when packets always hit at the index.
We need another mode that allows to match on the pattern at the index:
insertion by index with pattern.

Best regards,
Dariusz Sosnowski

#3 lore raw

PATCH 2/6 app/testpmd: add index with pattern insertion type

In reply to Alexander Kozyrev

Provide index_with_pattern command line option
for the template table insertion type.

flow template_table 0 create table_id 2 group 13 priority 0
insertion_type index_with_pattern ingress rules_number 64 pattern_template 2 actions_template 2

---
 app/test-pmd/cmdline_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +1 -1
index d04280eb3e..a794e5eba5 100644
@@ -1030,7 +1030,7 @@ static const char *const meter_colors[] = {
 };
 
 static const char *const table_insertion_types[] = {
-	"pattern", "index", NULL
+	"pattern", "index", "index_with_pattern", NULL
 };
 
 static const char *const table_hash_funcs[] = {
Signature · 1 line
2.18.2
Acked-by on v1 2/6
#4 lore raw

RE: [PATCH 2/6] app/testpmd: add index with pattern insertion type

Quoted 10 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 2/6] app/testpmd: add index with pattern insertion type

Quoted 8 lines

Provide index_with_pattern command line option for the template table insertion type.

flow template_table 0 create table_id 2 group 13 priority 0
insertion_type index_with_pattern ingress rules_number 64 pattern_template 2 actions_template 2

Best regards,
Dariusz Sosnowski

#5 lore raw

PATCH 3/6 ethdev: add flow rule insertion by index with pattern

In reply to Alexander Kozyrev

Add a new API to enqueue flow rule creation by index with pattern. The new template table rules insertion type,
index-based insertion with pattern, requires a new flow rule creation function with both rule index and pattern provided. Packets will match on the provided pattern at the provided index.

---
 doc/guides/prog_guide/rte_flow.rst     | 20 ++++++++++
 doc/guides/rel_notes/release_24_11.rst |  5 +++
 lib/ethdev/ethdev_trace.h              | 44 +++++++++++++++++++++
 lib/ethdev/ethdev_trace_points.c       |  6 +++
 lib/ethdev/rte_flow.c                  | 55 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow.h                  | 54 +++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           | 14 +++++++
 lib/ethdev/version.map                 |  3 ++
 8 files changed, 201 insertions(+)
doc/guides/prog_guide/rte_flow.rst +20 -0
index dad588763f..adbd9b1c20 100644
@@ -4156,6 +4156,26 @@ Enqueueing a flow rule creation operation to insert a rule at a table index.
 A valid handle in case of success is returned. It must be destroyed later
 by calling ``rte_flow_async_destroy()`` even if the rule is rejected by HW.
 
+Enqueue creation by index with pattern
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Enqueueing a flow rule creation operation to insert a rule at a table index with pattern.
+
+.. code-block:: c
+
+   struct rte_flow *
+   rte_flow_async_create_by_index_with_pattern(uint16_t port_id,
+                                               uint32_t queue_id,
+                                               const struct rte_flow_op_attr *op_attr,
+                                               struct rte_flow_template_table *template_table,
+                                               uint32_t rule_index,
+                                               const struct rte_flow_item pattern[],
+                                               uint8_t pattern_template_index,
+                                               const struct rte_flow_action actions[],
+                                               uint8_t actions_template_index,
+                                               void *user_data,
+                                               struct rte_flow_error *error);
+
 Enqueue destruction operation
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
doc/guides/rel_notes/release_24_11.rst +5 -0
index 7056f17f3c..f71a9ab562 100644
@@ -60,6 +60,11 @@ New Features
   Extended rte_flow_table_insertion_type enum with new
   RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN type.
 
+* **Added flow rule insertion by index with pattern to the Flow API.**
+
+  Added API for inserting the rule by index with pattern.
+  Introduced rte_flow_async_create_by_index_with_pattern() function.
+
 Removed Items
 -------------
 
lib/ethdev/ethdev_trace.h +44 -0

50 lines not on this page · raw message

lib/ethdev/ethdev_trace_points.c +6 -0
index 99e04f5893..0563fb1451 100644
@@ -583,6 +583,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_template_table_destroy,
 RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create,
 	lib.ethdev.flow.async_create)
 
+RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create_by_index,
+	lib.ethdev.flow.async_create_by_index)
+
+RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create_by_index_with_pattern,
+	lib.ethdev.flow.async_create_by_index_with_pattern)
+
 RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_destroy,
 	lib.ethdev.flow.async_destroy)
 
lib/ethdev/rte_flow.c +55 -0

73 lines not on this page · raw message

lib/ethdev/rte_flow.h +54 -0

60 lines not on this page · raw message

lib/ethdev/rte_flow_driver.h +14 -0
index 506d1262ab..e00a5d7f7e 100644
@@ -319,6 +319,19 @@ typedef struct rte_flow *(*rte_flow_async_create_by_index_t)(struct rte_eth_dev
 							     void *user_data,
 							     struct rte_flow_error *error);
 
+/** @internal Enqueue rule creation by index with pattern operation. */
+typedef struct rte_flow *(*rte_flow_async_create_by_index_with_pattern_t)(struct rte_eth_dev *dev,
+							uint32_t queue,
+							const struct rte_flow_op_attr *attr,
+							struct rte_flow_template_table *table,
+							uint32_t rule_index,
+							const struct rte_flow_item *items,
+							uint8_t pattern_template_index,
+							const struct rte_flow_action *actions,
+							uint8_t action_template_index,
+							void *user_data,
+							struct rte_flow_error *error);
+
 /** @internal Enqueue rule update operation. */
 typedef int (*rte_flow_async_actions_update_t)(struct rte_eth_dev *dev,
 					       uint32_t queue_id,
@@ -436,6 +449,7 @@ struct __rte_cache_aligned rte_flow_fp_ops {
 	rte_flow_async_create_t async_create;
 	rte_flow_async_create_by_index_t async_create_by_index;
 	rte_flow_async_actions_update_t async_actions_update;
+	rte_flow_async_create_by_index_with_pattern_t async_create_by_index_with_pattern;
 	rte_flow_async_destroy_t async_destroy;
 	rte_flow_push_t push;
 	rte_flow_pull_t pull;
lib/ethdev/version.map +3 -0
index 1669055ca5..8e02e1de8f 100644
@@ -325,6 +325,9 @@ EXPERIMENTAL {
 	rte_flow_template_table_resizable;
 	rte_flow_template_table_resize;
 	rte_flow_template_table_resize_complete;
+
+	# added in 24.11
+	rte_flow_async_create_by_index_with_pattern;
 };
 
 INTERNAL {
Signature · 1 line
2.18.2
#6 lore raw

RE: [PATCH 3/6] ethdev: add flow rule insertion by index with pattern

Quoted 17 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 3/6] ethdev: add flow rule insertion by index with pattern

Add a new API to enqueue flow rule creation by index with pattern. The new template table rules insertion type, index-based insertion with pattern, requires a new flow rule creation function with both rule index and pattern provided.
Packets will match on the provided pattern at the provided index.

[snip]

Quoted 9 lines
lib/ethdev/ethdev_trace.h +9 -0
+RTE_TRACE_POINT_FP(
+	rte_flow_trace_async_create_by_index,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id,
+		const struct rte_flow_op_attr *op_attr,
+		const struct rte_flow_template_table *template_table,
+		uint32_t rule_index,
+		const struct rte_flow_action *actions,
+		uint8_t actions_template_index,
+		const void *user_data, const struct rte_flow *flow),

lib/ethdev/ethdev_trace.h RTE_TRACE_POINT_FP( · line 2364

Quoted 10 lines
lib/ethdev/ethdev_trace.h +10 -0
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_u32(queue_id);
+	rte_trace_point_emit_ptr(op_attr);
+	rte_trace_point_emit_ptr(template_table);
+	rte_trace_point_emit_u32(rule_index);
+	rte_trace_point_emit_ptr(actions);
+	rte_trace_point_emit_u8(actions_template_index);
+	rte_trace_point_emit_ptr(user_data);
+	rte_trace_point_emit_ptr(flow);
+)

This tracepoint is not used anywhere and is not related to the addition of rte_flow_trace_async_create_by_index_with_pattern. Maybe this tracepoint should be added in a separate commit?

Quoted 13 lines
lib/ethdev/ethdev_trace.h +13 -0
+RTE_TRACE_POINT_FP(
+	rte_flow_trace_async_create_by_index_with_pattern,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id,
+		const struct rte_flow_op_attr *op_attr,
+		const struct rte_flow_template_table *template_table,
+		uint32_t rule_index,
+		const struct rte_flow_item *pattern,
+		uint8_t pattern_template_index,
+		const struct rte_flow_action *actions,
+		uint8_t actions_template_index,
+		const void *user_data, const struct rte_flow *flow),
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_u32(queue_id);

lib/ethdev/ethdev_trace.h RTE_TRACE_POINT_FP( · line 2388

Quoted 10 lines
lib/ethdev/ethdev_trace.h +10 -0
+	rte_trace_point_emit_ptr(op_attr);
+	rte_trace_point_emit_ptr(template_table);
+	rte_trace_point_emit_u32(rule_index);
+	rte_trace_point_emit_ptr(pattern);
+	rte_trace_point_emit_u8(pattern_template_index);
+	rte_trace_point_emit_ptr(actions);
+	rte_trace_point_emit_u8(actions_template_index);
+	rte_trace_point_emit_ptr(user_data);
+	rte_trace_point_emit_ptr(flow);
+)

This tracepoint is not used in this commit.
Could you please add the usage?

Best regards,
Dariusz Sosnowski

#7 lore raw

PATCH 4/6 app/testpmd: add insertion by index with pattern option

In reply to Alexander Kozyrev

Allow to specify both the rule index and the pattern
in the flow rule creation command line parameters.
Both are needed for rte_flow_async_create_by_index_with_pattern().

flow queue 0 create 0 template_table 2 rule_index 5
pattern_template 0 actions_template 0 postpone no pattern eth / end actions count / queue index 1 / end

---
 app/test-pmd/cmdline_flow.c |  8 +++++++-
 app/test-pmd/config.c       | 22 ++++++++++++++++------
 app/test-pmd/testpmd.h      |  2 +-
 3 files changed, 24 insertions(+), 8 deletions(-)
app/test-pmd/cmdline_flow.c +7 -1
index a794e5eba5..855273365e 100644
@@ -1585,6 +1585,12 @@ static const enum index next_async_insert_subcmd[] = {
 	ZERO,
 };
 
+static const enum index next_async_pattern_subcmd[] = {
+	QUEUE_PATTERN_TEMPLATE,
+	QUEUE_ACTIONS_TEMPLATE,
+	ZERO,
+};
+
 static const enum index item_param[] = {
 	ITEM_PARAM_IS,
 	ITEM_PARAM_SPEC,
@@ -3788,7 +3794,7 @@ static const struct token token_list[] = {
 	[QUEUE_RULE_ID] = {
 		.name = "rule_index",
 		.help = "specify flow rule index",
-		.next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
+		.next = NEXT(next_async_pattern_subcmd,
 			     NEXT_ENTRY(COMMON_UNSIGNED)),
 		.args = ARGS(ARGS_ENTRY(struct buffer,
 					args.vc.rule_id)),
app/test-pmd/config.c +16 -6
index 6f0beafa27..39924d8da9 100644
@@ -2636,8 +2636,8 @@ port_flow_template_table_create(portid_t port_id, uint32_t id,
 	}
 	pt->nb_pattern_templates = nb_pattern_templates;
 	pt->nb_actions_templates = nb_actions_templates;
-	rte_memcpy(&pt->flow_attr, &table_attr->flow_attr,
-		   sizeof(struct rte_flow_attr));
+	rte_memcpy(&pt->attr, table_attr,
+		   sizeof(struct rte_flow_template_table_attr));
 	printf("Template table #%u created\n", pt->id);
 	return 0;
 }
@@ -2835,7 +2835,7 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id,
 	}
 	job->type = QUEUE_JOB_TYPE_FLOW_CREATE;
 
-	pf = port_flow_new(&pt->flow_attr, pattern, actions, &error);
+	pf = port_flow_new(&pt->attr.flow_attr, pattern, actions, &error);
 	if (!pf) {
 		free(job);
 		return port_flow_complain(&error);
@@ -2846,12 +2846,22 @@ 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));
-	if (rule_idx == UINT32_MAX)
+	if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN)
 		flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table,
 			pattern, pattern_idx, actions, actions_idx, job, &error);
-	else
+	else if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_INDEX)
 		flow = rte_flow_async_create_by_index(port_id, queue_id, &op_attr, pt->table,
 			rule_idx, actions, actions_idx, job, &error);
+	else if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN)
+		flow = rte_flow_async_create_by_index_with_pattern(port_id, queue_id, &op_attr,
+			pt->table, rule_idx, pattern, pattern_idx, actions, actions_idx, job,
+			&error);
+	else {
+		free(pf);
+		free(job);
+		printf("Insertion type %d is invalid\n", pt->attr.insertion_type);
+		return -EINVAL;
+	}
 	if (!flow) {
 		free(pf);
 		free(job);
@@ -3060,7 +3070,7 @@ port_queue_flow_update(portid_t port_id, queueid_t queue_id,
 	}
 	job->type = QUEUE_JOB_TYPE_FLOW_UPDATE;
 
-	uf = port_flow_new(&pt->flow_attr, pf->rule.pattern_ro, actions, &error);
+	uf = port_flow_new(&pt->attr.flow_attr, pf->rule.pattern_ro, actions, &error);
 	if (!uf) {
 		free(job);
 		return port_flow_complain(&error);
app/test-pmd/testpmd.h +1 -1
index 9facd7f281..f9ab88d667 100644
@@ -220,7 +220,7 @@ struct port_table {
 	uint32_t id; /**< Table ID. */
 	uint32_t nb_pattern_templates; /**< Number of pattern templates. */
 	uint32_t nb_actions_templates; /**< Number of actions templates. */
-	struct rte_flow_attr flow_attr; /**< Flow attributes. */
+	struct rte_flow_template_table_attr attr; /**< Table attributes. */
 	struct rte_flow_template_table *table; /**< PMD opaque template object */
 };
 
Signature · 1 line
2.18.2
Acked-by on v1 4/6
#8 lore raw

RE: [PATCH 4/6] app/testpmd: add insertion by index with pattern option

Quoted 14 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 4/6] app/testpmd: add insertion by index with pattern option

Allow to specify both the rule index and the pattern in the flow rule creation command line parameters.
Both are needed for rte_flow_async_create_by_index_with_pattern().

Quoted 5 lines

flow queue 0 create 0 template_table 2 rule_index 5
pattern_template 0 actions_template 0 postpone no pattern eth / end actions count / queue index 1 / end

Best regards,
Dariusz Sosnowski

#9 lore raw

PATCH 5/6 ethdev: add jump to table index action

In reply to Alexander Kozyrev

Introduce the RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action. It redirects packets to a particular index in a flow table.

---
 doc/guides/rel_notes/release_24_11.rst |  4 ++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 23 +++++++++++++++++++++++
 3 files changed, 28 insertions(+)
doc/guides/rel_notes/release_24_11.rst +4 -0
index f71a9ab562..ccdc44f3d8 100644
@@ -65,6 +65,10 @@ New Features
   Added API for inserting the rule by index with pattern.
   Introduced rte_flow_async_create_by_index_with_pattern() function.
 
+* **Added the action to redirect packets to a particular index in a flow table.**
+
+  Introduced RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action type.
+
 Removed Items
 -------------
 
lib/ethdev/rte_flow.c +1 -0
index f6259343e8..a56391b156 100644
@@ -275,6 +275,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(PROG,
 		       sizeof(struct rte_flow_action_prog)),
 	MK_FLOW_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
+	MK_FLOW_ACTION(JUMP_TO_TABLE_INDEX, sizeof(struct rte_flow_action_jump_to_table_index)),
 };
 
 int
lib/ethdev/rte_flow.h +23 -0
index 84473241fb..a2929438bf 100644
@@ -3262,6 +3262,15 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_nat64
 	 */
 	RTE_FLOW_ACTION_TYPE_NAT64,
+
+	/**
+	 * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
+	 *
+	 * Redirects packets to a particular index in a flow table.
+	 *
+	 * @see struct rte_flow_action_jump_to_table_index.
+	 */
+	RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
 };
 
 /**
@@ -4266,6 +4275,20 @@ rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
 	*RTE_FLOW_DYNF_METADATA(m) = v;
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX
+ *
+ * Redirects packets to a particular index in a flow table.
+ *
+ */
+struct rte_flow_action_jump_to_table_index {
+	struct rte_flow_template_table *table;
+	uint32_t index;
+};
+
 /**
  * Definition of a single action.
  *
Signature · 1 line
2.18.2
Acked-by on v1 5/6
#10 lore raw

RE: [PATCH 5/6] ethdev: add jump to table index action

Quoted 10 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 5/6] ethdev: add jump to table index action

Quoted 4 lines

Introduce the RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action. It redirects packets to a particular index in a flow table.

Best regards,
Dariusz Sosnowski

#11 lore raw

PATCH 6/6 app/testpmd: add jump to table index action

In reply to Alexander Kozyrev

Add a new command line options to create the
RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action
from the testpmd command line.

flow queue 0 create 0 template_table 0 pattern_template 0
actions_template 0 postpone no pattern eth / end actions jump_to_table_index table 0x166f9ce00 index 5 / end

---
 app/test-pmd/cmdline_flow.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
app/test-pmd/cmdline_flow.c +34 -0
index 855273365e..b7bcf18311 100644
@@ -785,6 +785,9 @@ enum index {
 	ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
 	ACTION_NAT64,
 	ACTION_NAT64_MODE,
+	ACTION_JUMP_TO_TABLE_INDEX,
+	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
+	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -2328,6 +2331,7 @@ static const enum index next_action[] = {
 	ACTION_IPV6_EXT_REMOVE,
 	ACTION_IPV6_EXT_PUSH,
 	ACTION_NAT64,
+	ACTION_JUMP_TO_TABLE_INDEX,
 	ZERO,
 };
 
@@ -2688,6 +2692,13 @@ static const enum index next_hash_encap_dest_subcmd[] = {
 	ZERO,
 };
 
+static const enum index action_jump_to_table_index[] = {
+	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
+	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_set_raw_encap_decap(struct context *, const struct token *,
 				     const char *, unsigned int,
 				     void *, unsigned int);
@@ -7608,6 +7619,29 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_JUMP_TO_TABLE_INDEX] = {
+		.name = "jump_to_table_index",
+		.help = "Jump to table index",
+		.priv = PRIV_ACTION(JUMP_TO_TABLE_INDEX,
+				    sizeof(struct rte_flow_action_jump_to_table_index)),
+		.next = NEXT(action_jump_to_table_index),
+		.call = parse_vc,
+	},
+	[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)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
+		.name = "index",
+		.help = "rule index to redirect traffic to",
+		.next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, index)),
+		.call = parse_vc_conf,
+	},
+
 	/* Top level command. */
 	[SET] = {
 		.name = "set",
Signature · 1 line
2.18.2
Acked-by on v1 6/6
#12 lore raw

RE: [PATCH 6/6] app/testpmd: add jump to table index action

Quoted 14 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Thursday, September 19, 2024 02:48
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH 6/6] app/testpmd: add jump to table index action

Add a new command line options to create the RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action from the testpmd command line.

Quoted 5 lines

flow queue 0 create 0 template_table 0 pattern_template 0
actions_template 0 postpone no pattern eth / end actions jump_to_table_index table 0x166f9ce00 index 5 / end

Best regards,
Dariusz Sosnowski

#13 lore raw

v2 cover ethdev: jump to table support

In reply to Alexander Kozyrev

Introduce new Flow API JUMP_TO_TABLE_INDEX action. It allows bypassing a hierarchy of groups and going directly to a specified flow table. That gives a user the flexibility to jump between different priorities in a group and eliminates the need to do a table lookup in the group hierarchy. The JUMP_TO_TABLE_INDEX action forwards a packet to the specified rule index inside the index-based flow table.

The current index-based flow table doesn't do any matching on the packet and executes the actions immediately. Add a new index-based flow table with pattern matching. The JUMP_TO_TABLE_INDEX can redirect a packet to another matching criteria at the specified index in this case.

RFC: https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
v2: added trace point to flow insertion by index functions.

Alexander Kozyrev (7):
ethdev: add insertion by index with pattern app/testpmd: add index with pattern insertion type
ethdev: add flow rule insertion by index with pattern app/testpmd: add insertion by index with pattern option
ethdev: add jump to table index action app/testpmd: add jump to table index action
ethdev: add trace points to flow insertion by index

 app/test-pmd/cmdline_flow.c            | 44 +++++++++++++-
 app/test-pmd/config.c                  | 22 +++++--
 app/test-pmd/testpmd.h                 |  2 +-
 doc/guides/prog_guide/rte_flow.rst     | 20 +++++++
 doc/guides/rel_notes/release_24_11.rst | 13 +++++
 lib/ethdev/ethdev_trace.h              | 44 ++++++++++++++
 lib/ethdev/ethdev_trace_points.c       |  6 ++
 lib/ethdev/rte_flow.c                  | 72 ++++++++++++++++++++++-
 lib/ethdev/rte_flow.h                  | 81 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           | 14 +++++
 lib/ethdev/version.map                 |  1 +
 11 files changed, 309 insertions(+), 10 deletions(-)
Signature · 1 line
2.18.2
#14 lore raw

PATCH v2 1/7 ethdev: add insertion by index with pattern

There are two flow table rules insertion type today:
pattern-based insertion when packets match on the pattern and index-based insertion when packets always hit at the index. We need another mode that allows to match on the pattern at the index: insertion by index with pattern.

---
 doc/guides/rel_notes/release_24_11.rst | 4 ++++
 lib/ethdev/rte_flow.h                  | 4 ++++
 2 files changed, 8 insertions(+)
doc/guides/rel_notes/release_24_11.rst +4 -0
index ef0124a9e6..8d311aead2 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added a new insertion by index with pattern table insertion type.**
+
+  Extended rte_flow_table_insertion_type enum with new
+  RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN type.
 
 Removed Items
 -------------
lib/ethdev/rte_flow.h +4 -0
index f864578f80..6f30dd7ae9 100644
@@ -5898,6 +5898,10 @@ enum rte_flow_table_insertion_type {
 	 * Index-based insertion.
 	 */
 	RTE_FLOW_TABLE_INSERTION_TYPE_INDEX,
+	/**
+	 * Index-based insertion with pattern.
+	 */
+	RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN,
 };
 
 /**
Signature · 1 line
2.18.2
Acked-by on v2 1/7
#15 lore raw

RE: [PATCH v2 1/7] ethdev: add insertion by index with pattern

Quoted 6 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:05 PM

Quoted 8 lines

There are two flow table rules insertion type today:
pattern-based insertion when packets match on the pattern and index-based insertion when packets always hit at the index. We need another mode that allows to match on the pattern at the index: insertion by index with pattern.

---

Best,
Ori

#16 lore raw

PATCH v2 2/7 app/testpmd: add index with pattern insertion type

In reply to Alexander Kozyrev

Provide index_with_pattern command line option
for the template table insertion type.

flow template_table 0 create table_id 2 group 13 priority 0
insertion_type index_with_pattern ingress rules_number 64 pattern_template 2 actions_template 2

---
 app/test-pmd/cmdline_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +1 -1
index 858f4077bd..b048821e85 100644
@@ -1029,7 +1029,7 @@ static const char *const meter_colors[] = {
 };
 
 static const char *const table_insertion_types[] = {
-	"pattern", "index", NULL
+	"pattern", "index", "index_with_pattern", NULL
 };
 
 static const char *const table_hash_funcs[] = {
Signature · 1 line
2.18.2
Acked-by on v2 2/7
#17 lore raw

RE: [PATCH v2 2/7] app/testpmd: add index with pattern insertion type

Quoted 9 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:05 PM

Provide index_with_pattern command line option
for the template table insertion type.

Quoted 6 lines

flow template_table 0 create table_id 2 group 13 priority 0
insertion_type index_with_pattern ingress rules_number 64 pattern_template 2 actions_template 2

---

Best,
Ori

#18 lore raw

PATCH v2 3/7 ethdev: add flow rule insertion by index with pattern

In reply to Alexander Kozyrev

Add a new API to enqueue flow rule creation by index with pattern. The new template table rules insertion type,
index-based insertion with pattern, requires a new flow rule creation function with both rule index and pattern provided. Packets will match on the provided pattern at the provided index.

---
 doc/guides/prog_guide/rte_flow.rst     | 20 ++++++++++
 doc/guides/rel_notes/release_24_11.rst |  5 +++
 lib/ethdev/rte_flow.c                  | 55 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow.h                  | 54 +++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           | 14 +++++++
 lib/ethdev/version.map                 |  1 +
 6 files changed, 149 insertions(+)
doc/guides/prog_guide/rte_flow.rst +20 -0
index dad588763f..adbd9b1c20 100644
@@ -4156,6 +4156,26 @@ Enqueueing a flow rule creation operation to insert a rule at a table index.
 A valid handle in case of success is returned. It must be destroyed later
 by calling ``rte_flow_async_destroy()`` even if the rule is rejected by HW.
 
+Enqueue creation by index with pattern
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Enqueueing a flow rule creation operation to insert a rule at a table index with pattern.
+
+.. code-block:: c
+
+   struct rte_flow *
+   rte_flow_async_create_by_index_with_pattern(uint16_t port_id,
+                                               uint32_t queue_id,
+                                               const struct rte_flow_op_attr *op_attr,
+                                               struct rte_flow_template_table *template_table,
+                                               uint32_t rule_index,
+                                               const struct rte_flow_item pattern[],
+                                               uint8_t pattern_template_index,
+                                               const struct rte_flow_action actions[],
+                                               uint8_t actions_template_index,
+                                               void *user_data,
+                                               struct rte_flow_error *error);
+
 Enqueue destruction operation
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
doc/guides/rel_notes/release_24_11.rst +5 -0
index 8d311aead2..fd461128ee 100644
@@ -60,6 +60,11 @@ New Features
   Extended rte_flow_table_insertion_type enum with new
   RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN type.
 
+* **Added flow rule insertion by index with pattern to the Flow API.**
+
+  Added API for inserting the rule by index with pattern.
+  Introduced rte_flow_async_create_by_index_with_pattern() function.
+
 Removed Items
 -------------
 
lib/ethdev/rte_flow.c +55 -0

73 lines not on this page · raw message

lib/ethdev/rte_flow.h +54 -0

60 lines not on this page · raw message

lib/ethdev/rte_flow_driver.h +14 -0
index 506d1262ab..e00a5d7f7e 100644
@@ -319,6 +319,19 @@ typedef struct rte_flow *(*rte_flow_async_create_by_index_t)(struct rte_eth_dev
 							     void *user_data,
 							     struct rte_flow_error *error);
 
+/** @internal Enqueue rule creation by index with pattern operation. */
+typedef struct rte_flow *(*rte_flow_async_create_by_index_with_pattern_t)(struct rte_eth_dev *dev,
+							uint32_t queue,
+							const struct rte_flow_op_attr *attr,
+							struct rte_flow_template_table *table,
+							uint32_t rule_index,
+							const struct rte_flow_item *items,
+							uint8_t pattern_template_index,
+							const struct rte_flow_action *actions,
+							uint8_t action_template_index,
+							void *user_data,
+							struct rte_flow_error *error);
+
 /** @internal Enqueue rule update operation. */
 typedef int (*rte_flow_async_actions_update_t)(struct rte_eth_dev *dev,
 					       uint32_t queue_id,
@@ -436,6 +449,7 @@ struct __rte_cache_aligned rte_flow_fp_ops {
 	rte_flow_async_create_t async_create;
 	rte_flow_async_create_by_index_t async_create_by_index;
 	rte_flow_async_actions_update_t async_actions_update;
+	rte_flow_async_create_by_index_with_pattern_t async_create_by_index_with_pattern;
 	rte_flow_async_destroy_t async_destroy;
 	rte_flow_push_t push;
 	rte_flow_pull_t pull;
lib/ethdev/version.map +1 -0
index f6aca95069..37cc18c139 100644
@@ -330,6 +330,7 @@ EXPERIMENTAL {
 	__rte_ethdev_trace_rx_burst_nonempty;
 	__rte_eth_trace_call_rx_callbacks_empty;
 	__rte_eth_trace_call_rx_callbacks_nonempty;
+	rte_flow_async_create_by_index_with_pattern;
 };
 
 INTERNAL {
Signature · 1 line
2.18.2
Acked-by on v2 3/7
#19 lore raw

RE: [PATCH v2 3/7] ethdev: add flow rule insertion by index with pattern

Quoted 6 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:05 PM

Quoted 8 lines

Add a new API to enqueue flow rule creation by index with pattern. The new template table rules insertion type,
index-based insertion with pattern, requires a new flow rule creation function with both rule index and pattern provided. Packets will match on the provided pattern at the provided index.

---

Best,
Ori

#20 lore raw

PATCH v2 4/7 app/testpmd: add insertion by index with pattern option

In reply to Alexander Kozyrev

Allow to specify both the rule index and the pattern
in the flow rule creation command line parameters.
Both are needed for rte_flow_async_create_by_index_with_pattern().

flow queue 0 create 0 template_table 2 rule_index 5
pattern_template 0 actions_template 0 postpone no pattern eth / end actions count / queue index 1 / end

---
 app/test-pmd/cmdline_flow.c |  8 +++++++-
 app/test-pmd/config.c       | 22 ++++++++++++++++------
 app/test-pmd/testpmd.h      |  2 +-
 3 files changed, 24 insertions(+), 8 deletions(-)
app/test-pmd/cmdline_flow.c +7 -1
index b048821e85..65030936d2 100644
@@ -1583,6 +1583,12 @@ static const enum index next_async_insert_subcmd[] = {
 	ZERO,
 };
 
+static const enum index next_async_pattern_subcmd[] = {
+	QUEUE_PATTERN_TEMPLATE,
+	QUEUE_ACTIONS_TEMPLATE,
+	ZERO,
+};
+
 static const enum index item_param[] = {
 	ITEM_PARAM_IS,
 	ITEM_PARAM_SPEC,
@@ -3786,7 +3792,7 @@ static const struct token token_list[] = {
 	[QUEUE_RULE_ID] = {
 		.name = "rule_index",
 		.help = "specify flow rule index",
-		.next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
+		.next = NEXT(next_async_pattern_subcmd,
 			     NEXT_ENTRY(COMMON_UNSIGNED)),
 		.args = ARGS(ARGS_ENTRY(struct buffer,
 					args.vc.rule_id)),
app/test-pmd/config.c +16 -6
index 6f0beafa27..39924d8da9 100644
@@ -2636,8 +2636,8 @@ port_flow_template_table_create(portid_t port_id, uint32_t id,
 	}
 	pt->nb_pattern_templates = nb_pattern_templates;
 	pt->nb_actions_templates = nb_actions_templates;
-	rte_memcpy(&pt->flow_attr, &table_attr->flow_attr,
-		   sizeof(struct rte_flow_attr));
+	rte_memcpy(&pt->attr, table_attr,
+		   sizeof(struct rte_flow_template_table_attr));
 	printf("Template table #%u created\n", pt->id);
 	return 0;
 }
@@ -2835,7 +2835,7 @@ port_queue_flow_create(portid_t port_id, queueid_t queue_id,
 	}
 	job->type = QUEUE_JOB_TYPE_FLOW_CREATE;
 
-	pf = port_flow_new(&pt->flow_attr, pattern, actions, &error);
+	pf = port_flow_new(&pt->attr.flow_attr, pattern, actions, &error);
 	if (!pf) {
 		free(job);
 		return port_flow_complain(&error);
@@ -2846,12 +2846,22 @@ 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));
-	if (rule_idx == UINT32_MAX)
+	if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN)
 		flow = rte_flow_async_create(port_id, queue_id, &op_attr, pt->table,
 			pattern, pattern_idx, actions, actions_idx, job, &error);
-	else
+	else if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_INDEX)
 		flow = rte_flow_async_create_by_index(port_id, queue_id, &op_attr, pt->table,
 			rule_idx, actions, actions_idx, job, &error);
+	else if (pt->attr.insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN)
+		flow = rte_flow_async_create_by_index_with_pattern(port_id, queue_id, &op_attr,
+			pt->table, rule_idx, pattern, pattern_idx, actions, actions_idx, job,
+			&error);
+	else {
+		free(pf);
+		free(job);
+		printf("Insertion type %d is invalid\n", pt->attr.insertion_type);
+		return -EINVAL;
+	}
 	if (!flow) {
 		free(pf);
 		free(job);
@@ -3060,7 +3070,7 @@ port_queue_flow_update(portid_t port_id, queueid_t queue_id,
 	}
 	job->type = QUEUE_JOB_TYPE_FLOW_UPDATE;
 
-	uf = port_flow_new(&pt->flow_attr, pf->rule.pattern_ro, actions, &error);
+	uf = port_flow_new(&pt->attr.flow_attr, pf->rule.pattern_ro, actions, &error);
 	if (!uf) {
 		free(job);
 		return port_flow_complain(&error);
app/test-pmd/testpmd.h +1 -1
index 9facd7f281..f9ab88d667 100644
@@ -220,7 +220,7 @@ struct port_table {
 	uint32_t id; /**< Table ID. */
 	uint32_t nb_pattern_templates; /**< Number of pattern templates. */
 	uint32_t nb_actions_templates; /**< Number of actions templates. */
-	struct rte_flow_attr flow_attr; /**< Flow attributes. */
+	struct rte_flow_template_table_attr attr; /**< Table attributes. */
 	struct rte_flow_template_table *table; /**< PMD opaque template object */
 };
 
Signature · 1 line
2.18.2
Acked-by on v2 4/7
#21 lore raw

RE: [PATCH v2 4/7] app/testpmd: add insertion by index with pattern option

Quoted 10 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:05 PM

Allow to specify both the rule index and the pattern
in the flow rule creation command line parameters.
Both are needed for rte_flow_async_create_by_index_with_pattern().

Quoted 6 lines

flow queue 0 create 0 template_table 2 rule_index 5
pattern_template 0 actions_template 0 postpone no pattern eth / end actions count / queue index 1 / end

---

Best,
Ori

#22 lore raw

PATCH v2 5/7 ethdev: add jump to table index action

In reply to Alexander Kozyrev

Introduce the RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action. It redirects packets to a particular index in a flow table.

---
 doc/guides/rel_notes/release_24_11.rst |  4 ++++
 lib/ethdev/rte_flow.c                  |  1 +
 lib/ethdev/rte_flow.h                  | 23 +++++++++++++++++++++++
 3 files changed, 28 insertions(+)
doc/guides/rel_notes/release_24_11.rst +4 -0
index fd461128ee..67196c099a 100644
@@ -65,6 +65,10 @@ New Features
   Added API for inserting the rule by index with pattern.
   Introduced rte_flow_async_create_by_index_with_pattern() function.
 
+* **Added the action to redirect packets to a particular index in a flow table.**
+
+  Introduced RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action type.
+
 Removed Items
 -------------
 
lib/ethdev/rte_flow.c +1 -0
index f6259343e8..a56391b156 100644
@@ -275,6 +275,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
 	MK_FLOW_ACTION(PROG,
 		       sizeof(struct rte_flow_action_prog)),
 	MK_FLOW_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
+	MK_FLOW_ACTION(JUMP_TO_TABLE_INDEX, sizeof(struct rte_flow_action_jump_to_table_index)),
 };
 
 int
lib/ethdev/rte_flow.h +23 -0
index 84473241fb..a2929438bf 100644
@@ -3262,6 +3262,15 @@ enum rte_flow_action_type {
 	 * @see struct rte_flow_action_nat64
 	 */
 	RTE_FLOW_ACTION_TYPE_NAT64,
+
+	/**
+	 * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
+	 *
+	 * Redirects packets to a particular index in a flow table.
+	 *
+	 * @see struct rte_flow_action_jump_to_table_index.
+	 */
+	RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
 };
 
 /**
@@ -4266,6 +4275,20 @@ rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
 	*RTE_FLOW_DYNF_METADATA(m) = v;
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX
+ *
+ * Redirects packets to a particular index in a flow table.
+ *
+ */
+struct rte_flow_action_jump_to_table_index {
+	struct rte_flow_template_table *table;
+	uint32_t index;
+};
+
 /**
  * Definition of a single action.
  *
Signature · 1 line
2.18.2
#24 lore raw

PATCH v2 6/7 app/testpmd: add jump to table index action

In reply to Alexander Kozyrev

Add a new command line options to create the
RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action
from the testpmd command line.

flow queue 0 create 0 template_table 0 pattern_template 0
actions_template 0 postpone no pattern eth / end actions jump_to_table_index table 0x166f9ce00 index 5 / end

---
 app/test-pmd/cmdline_flow.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
app/test-pmd/cmdline_flow.c +34 -0
index 65030936d2..d150f6cca8 100644
@@ -784,6 +784,9 @@ enum index {
 	ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
 	ACTION_NAT64,
 	ACTION_NAT64_MODE,
+	ACTION_JUMP_TO_TABLE_INDEX,
+	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
+	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -2326,6 +2329,7 @@ static const enum index next_action[] = {
 	ACTION_IPV6_EXT_REMOVE,
 	ACTION_IPV6_EXT_PUSH,
 	ACTION_NAT64,
+	ACTION_JUMP_TO_TABLE_INDEX,
 	ZERO,
 };
 
@@ -2686,6 +2690,13 @@ static const enum index next_hash_encap_dest_subcmd[] = {
 	ZERO,
 };
 
+static const enum index action_jump_to_table_index[] = {
+	ACTION_JUMP_TO_TABLE_INDEX_TABLE,
+	ACTION_JUMP_TO_TABLE_INDEX_INDEX,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_set_raw_encap_decap(struct context *, const struct token *,
 				     const char *, unsigned int,
 				     void *, unsigned int);
@@ -7597,6 +7608,29 @@ static const struct token token_list[] = {
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_JUMP_TO_TABLE_INDEX] = {
+		.name = "jump_to_table_index",
+		.help = "Jump to table index",
+		.priv = PRIV_ACTION(JUMP_TO_TABLE_INDEX,
+				    sizeof(struct rte_flow_action_jump_to_table_index)),
+		.next = NEXT(action_jump_to_table_index),
+		.call = parse_vc,
+	},
+	[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)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
+		.name = "index",
+		.help = "rule index to redirect traffic to",
+		.next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, index)),
+		.call = parse_vc_conf,
+	},
+
 	/* Top level command. */
 	[SET] = {
 		.name = "set",
Signature · 1 line
2.18.2
Acked-by on v2 6/7
#25 lore raw

RE: [PATCH v2 6/7] app/testpmd: add jump to table index action

Quoted 10 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:06 PM

Add a new command line options to create the
RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action
from the testpmd command line.

Quoted 6 lines

flow queue 0 create 0 template_table 0 pattern_template 0
actions_template 0 postpone no pattern eth / end actions jump_to_table_index table 0x166f9ce00 index 5 / end

---

Best,
Ori

#26 lore raw

PATCH v2 7/7 ethdev: add trace points to flow insertion by index

In reply to Alexander Kozyrev

Adds trace points for rte_flow rule insertion by index functions:
rte_flow_async_create_by_index and rte_flow_async_create_by_index_with_pattern.

---
 lib/ethdev/ethdev_trace.h        | 44 ++++++++++++++++++++++++++++++++
 lib/ethdev/ethdev_trace_points.c |  6 +++++
 lib/ethdev/rte_flow.c            | 18 +++++++++++--
 3 files changed, 66 insertions(+), 2 deletions(-)
lib/ethdev/ethdev_trace.h +44 -0
index 3bec87bfdb..910bedbebd 100644
@@ -2343,6 +2343,50 @@ RTE_TRACE_POINT_FP(
 	rte_trace_point_emit_ptr(flow);
 )
 
+RTE_TRACE_POINT_FP(
+	rte_flow_trace_async_create_by_index,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id,
+		const struct rte_flow_op_attr *op_attr,
+		const struct rte_flow_template_table *template_table,
+		uint32_t rule_index,
+		const struct rte_flow_action *actions,
+		uint8_t actions_template_index,
+		const void *user_data, const struct rte_flow *flow),
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_u32(queue_id);
+	rte_trace_point_emit_ptr(op_attr);
+	rte_trace_point_emit_ptr(template_table);
+	rte_trace_point_emit_u32(rule_index);
+	rte_trace_point_emit_ptr(actions);
+	rte_trace_point_emit_u8(actions_template_index);
+	rte_trace_point_emit_ptr(user_data);
+	rte_trace_point_emit_ptr(flow);
+)
+
+RTE_TRACE_POINT_FP(
+	rte_flow_trace_async_create_by_index_with_pattern,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id,
+		const struct rte_flow_op_attr *op_attr,
+		const struct rte_flow_template_table *template_table,
+		uint32_t rule_index,
+		const struct rte_flow_item *pattern,
+		uint8_t pattern_template_index,
+		const struct rte_flow_action *actions,
+		uint8_t actions_template_index,
+		const void *user_data, const struct rte_flow *flow),
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_u32(queue_id);
+	rte_trace_point_emit_ptr(op_attr);
+	rte_trace_point_emit_ptr(template_table);
+	rte_trace_point_emit_u32(rule_index);
+	rte_trace_point_emit_ptr(pattern);
+	rte_trace_point_emit_u8(pattern_template_index);
+	rte_trace_point_emit_ptr(actions);
+	rte_trace_point_emit_u8(actions_template_index);
+	rte_trace_point_emit_ptr(user_data);
+	rte_trace_point_emit_ptr(flow);
+)
+
 RTE_TRACE_POINT_FP(
 	rte_flow_trace_async_destroy,
 	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue_id,
lib/ethdev/ethdev_trace_points.c +6 -0
index 6ecbee289b..902e4f7533 100644
@@ -589,6 +589,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_template_table_destroy,
 RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create,
 	lib.ethdev.flow.async_create)
 
+RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create_by_index,
+	lib.ethdev.flow.async_create_by_index)
+
+RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_create_by_index_with_pattern,
+	lib.ethdev.flow.async_create_by_index_with_pattern)
+
 RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_destroy,
 	lib.ethdev.flow.async_destroy)
 
lib/ethdev/rte_flow.c +16 -2
index a56391b156..4a7735b5ab 100644
@@ -2090,6 +2090,7 @@ rte_flow_async_create_by_index(uint16_t port_id,
 			       struct rte_flow_error *error)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	struct rte_flow *flow;
 
 #ifdef RTE_FLOW_DEBUG
 	if (!rte_eth_dev_is_valid_port(port_id)) {
@@ -2104,10 +2105,15 @@ rte_flow_async_create_by_index(uint16_t port_id,
 	}
 #endif
 
-	return dev->flow_fp_ops->async_create_by_index(dev, queue_id,
+	flow = dev->flow_fp_ops->async_create_by_index(dev, queue_id,
 						       op_attr, template_table, rule_index,
 						       actions, actions_template_index,
 						       user_data, error);
+
+	rte_flow_trace_async_create_by_index(port_id, queue_id, op_attr, template_table, rule_index,
+					     actions, actions_template_index, user_data, flow);
+
+	return flow;
 }
 
 struct rte_flow *
@@ -2124,6 +2130,7 @@ rte_flow_async_create_by_index_with_pattern(uint16_t port_id,
 					    struct rte_flow_error *error)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	struct rte_flow *flow;
 
 #ifdef RTE_FLOW_DEBUG
 	if (!rte_eth_dev_is_valid_port(port_id)) {
@@ -2139,11 +2146,18 @@ rte_flow_async_create_by_index_with_pattern(uint16_t port_id,
 	}
 #endif
 
-	return dev->flow_fp_ops->async_create_by_index_with_pattern(dev, queue_id, op_attr,
+	flow = dev->flow_fp_ops->async_create_by_index_with_pattern(dev, queue_id, op_attr,
 								    template_table, rule_index,
 								    pattern, pattern_template_index,
 								    actions, actions_template_index,
 								    user_data, error);
+
+	rte_flow_trace_async_create_by_index_with_pattern(port_id, queue_id, op_attr,
+							  template_table, rule_index, pattern,
+							  pattern_template_index, actions,
+							  actions_template_index, user_data, flow);
+
+	return flow;
 }
 
 int
Signature · 1 line
2.18.2
Acked-by on v2 7/7
#27 lore raw

RE: [PATCH v2 7/7] ethdev: add trace points to flow insertion by index

Quoted 6 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 9:06 PM

Quoted 6 lines

Adds trace points for rte_flow rule insertion by index functions:
rte_flow_async_create_by_index and rte_flow_async_create_by_index_with_pattern.

---

Best,
Ori

#28 lore raw
In reply to Alexander Kozyrev
Quoted 50 lines

-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Wednesday, September 25, 2024 20:05
To: [email protected]
Cc: Dariusz Sosnowski <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Matan Azrad <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v2 0/7] ethdev: jump to table support

Introduce new Flow API JUMP_TO_TABLE_INDEX action.
It allows bypassing a hierarchy of groups and going directly to a specified flow table. That gives a user the flexibility to jump between different priorities in a group and eliminates the need to do a table lookup in the group hierarchy. The JUMP_TO_TABLE_INDEX action forwards a packet to the specified rule index inside the index-based flow table.

The current index-based flow table doesn't do any matching on the packet and executes the actions immediately.
Add a new index-based flow table with pattern matching.
The JUMP_TO_TABLE_INDEX can redirect a packet to another matching criteria at the specified index in this case.

RFC:
https://patchwork.dpdk.org/project/dpdk/patch/20240822202753.3856703-
[email protected]/
v2: added trace point to flow insertion by index functions.

Alexander Kozyrev (7):
ethdev: add insertion by index with pattern app/testpmd: add index with pattern insertion type
ethdev: add flow rule insertion by index with pattern app/testpmd: add insertion by index with pattern option
ethdev: add jump to table index action app/testpmd: add jump to table index action
ethdev: add trace points to flow insertion by index

 app/test-pmd/cmdline_flow.c            | 44 +++++++++++++-
 app/test-pmd/config.c                  | 22 +++++--
 app/test-pmd/testpmd.h                 |  2 +-
 doc/guides/prog_guide/rte_flow.rst     | 20 +++++++
 doc/guides/rel_notes/release_24_11.rst | 13 +++++
 lib/ethdev/ethdev_trace.h              | 44 ++++++++++++++
 lib/ethdev/ethdev_trace_points.c       |  6 ++
 lib/ethdev/rte_flow.c                  | 72 ++++++++++++++++++++++-
 lib/ethdev/rte_flow.h                  | 81 ++++++++++++++++++++++++++
 lib/ethdev/rte_flow_driver.h           | 14 +++++
 lib/ethdev/version.map                 |  1 +
 11 files changed, 309 insertions(+), 10 deletions(-)
Quoted 2 lines

--
2.18.2

Best regards,
Dariusz Sosnowski

#29 lore raw
In reply to Alexander Kozyrev
Quoted 18 lines · Alexander Kozyrev

Introduce new Flow API JUMP_TO_TABLE_INDEX action. It allows bypassing a hierarchy of groups and going directly to a specified flow table. That gives a user the flexibility to jump between different priorities in a group and eliminates the need to do a table lookup in the group hierarchy. The JUMP_TO_TABLE_INDEX action forwards a packet to the specified rule index inside the index-based flow table.

The current index-based flow table doesn't do any matching on the packet and executes the actions immediately. Add a new index-based flow table with pattern matching. The JUMP_TO_TABLE_INDEX can redirect a packet to another matching criteria at the specified index in this case.

RFC: https://patchwork.dpdk.org/project/dpdk/patch/20240822202753.3856703-1-
[email protected]/
v2: added trace point to flow insertion by index functions.

Quoted 9 lines

Alexander Kozyrev (7):
ethdev: add insertion by index with pattern app/testpmd: add index with pattern insertion type
ethdev: add flow rule insertion by index with pattern app/testpmd: add insertion by index with pattern option
ethdev: add jump to table index action app/testpmd: add jump to table index action
ethdev: add trace points to flow insertion by index

Series applied to dpdk-next-net/main, thanks.