Skip to contentSkip to conversation

net/mlx5: reuse reformat and modify header actions in a table

PATCH Superseded Gregory Etelson 2 participants 4 messages Sep 19, 2023 – Oct 29, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: reuse reformat and modify header actions in a table

If application defined several actions templates with non-shared reformat or modify headers actions AND used these templates to create a table, HWS could share reformat or modify headers resources, instead of creating a resource for each action template.

The patch activates HWS code in a way that provides reformat or modify header resources sharing.

The patch updates modify field and raw encap template actions validations:
- modify field does not allow empty action template masks.
- raw encap added action template mask validation.

---
Depends-on: patch-129406 ("net/mlx5/hws: add support for multi pattern")

---
 drivers/net/mlx5/mlx5_flow.h    |   8 +-
 drivers/net/mlx5/mlx5_flow_dv.c |   3 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 568 +++++++++++++++++++++++++-------
 3 files changed, 452 insertions(+), 127 deletions(-)
drivers/net/mlx5/mlx5_flow.h +6 -2
index 3a97975d69..68fa6cf46d 100644
@@ -1318,7 +1318,9 @@ struct mlx5_hw_jump_action {
 struct mlx5_hw_encap_decap_action {
 	struct mlx5dr_action *action; /* Action object. */
 	/* Is header_reformat action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	size_t data_size; /* Action metadata size. */
 	uint8_t data[]; /* Action data. */
 };
@@ -1332,7 +1334,9 @@ struct mlx5_hw_modify_header_action {
 	/* Modify header action position in action rule table. */
 	uint16_t pos;
 	/* Is MODIFY_HEADER action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	/* Amount of modification commands stored in the precompiled buffer. */
 	uint32_t mhdr_cmds_num;
 	/* Precompiled modification commands. */
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
index 3f4325c5c8..d3e002ec41 100644
@@ -4573,7 +4573,8 @@ flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
 						  (void *)items->type,
 						  "items total size is too big"
 						  " for encap action");
-		rte_memcpy((void *)&buf[temp_size], items->spec, len);
+		if (items->spec)
+			rte_memcpy(&buf[temp_size], items->spec, len);
 		switch (items->type) {
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			eth = (struct rte_ether_hdr *)&buf[temp_size];
drivers/net/mlx5/mlx5_flow_hw.c +444 -124

704 lines not on this page · raw message

Signature · 1 line
2.39.2
#1 lore raw

PATCH v2 1/1 net/mlx5: reuse reformat and modify header actions in a table

If application defined several actions templates with non-shared reformat or modify headers actions AND used these templates to create a table, HWS could share reformat or modify headers resources, instead of creating a resource for each action template.

The patch activates HWS code in a way that provides reformat or modify header resources sharing.

The patch updates modify field and raw encap template actions validations:
- modify field does not allow empty action template masks.
- raw encap added action template mask validation.

---
v2: remove Depends-on

---
 drivers/net/mlx5/mlx5_flow.h    |   8 +-
 drivers/net/mlx5/mlx5_flow_dv.c |   3 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 568 +++++++++++++++++++++++++-------
 3 files changed, 452 insertions(+), 127 deletions(-)
drivers/net/mlx5/mlx5_flow.h +6 -2
index 3a97975d69..68fa6cf46d 100644
@@ -1318,7 +1318,9 @@ struct mlx5_hw_jump_action {
 struct mlx5_hw_encap_decap_action {
 	struct mlx5dr_action *action; /* Action object. */
 	/* Is header_reformat action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	size_t data_size; /* Action metadata size. */
 	uint8_t data[]; /* Action data. */
 };
@@ -1332,7 +1334,9 @@ struct mlx5_hw_modify_header_action {
 	/* Modify header action position in action rule table. */
 	uint16_t pos;
 	/* Is MODIFY_HEADER action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	/* Amount of modification commands stored in the precompiled buffer. */
 	uint32_t mhdr_cmds_num;
 	/* Precompiled modification commands. */
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
index 3f4325c5c8..d3e002ec41 100644
@@ -4573,7 +4573,8 @@ flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
 						  (void *)items->type,
 						  "items total size is too big"
 						  " for encap action");
-		rte_memcpy((void *)&buf[temp_size], items->spec, len);
+		if (items->spec)
+			rte_memcpy(&buf[temp_size], items->spec, len);
 		switch (items->type) {
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			eth = (struct rte_ether_hdr *)&buf[temp_size];
drivers/net/mlx5/mlx5_flow_hw.c +444 -124

704 lines not on this page · raw message

Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 1/1 net/mlx5: reuse reformat and modify header actions in a table

In reply to Gregory Etelson

If application defined several actions templates with non-shared reformat or modify headers actions AND used these templates to create a table, HWS could share reformat or modify headers resources, instead of creating a resource for each action template.

The patch activates HWS code in a way that provides reformat or modify header resources sharing.

The patch updates modify field and raw encap template actions validations:
- modify field does not allow empty action template masks.
- raw encap added action template mask validation.

---
Depends-on: series-28881 ("net/mlx5/hws: add support for multi pattern")
---
v2: remove Depends-on: patch
v3: add Depends-on: series

---
 drivers/net/mlx5/mlx5_flow.h    |   8 +-
 drivers/net/mlx5/mlx5_flow_dv.c |   3 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 568 +++++++++++++++++++++++++-------
 3 files changed, 452 insertions(+), 127 deletions(-)
drivers/net/mlx5/mlx5_flow.h +6 -2
index 3a97975d69..68fa6cf46d 100644
@@ -1318,7 +1318,9 @@ struct mlx5_hw_jump_action {
 struct mlx5_hw_encap_decap_action {
 	struct mlx5dr_action *action; /* Action object. */
 	/* Is header_reformat action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	size_t data_size; /* Action metadata size. */
 	uint8_t data[]; /* Action data. */
 };
@@ -1332,7 +1334,9 @@ struct mlx5_hw_modify_header_action {
 	/* Modify header action position in action rule table. */
 	uint16_t pos;
 	/* Is MODIFY_HEADER action shared across flows in table. */
-	bool shared;
+	uint32_t shared:1;
+	uint32_t multi_pattern:1;
+	volatile uint32_t *multi_pattern_refcnt;
 	/* Amount of modification commands stored in the precompiled buffer. */
 	uint32_t mhdr_cmds_num;
 	/* Precompiled modification commands. */
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
index 3f4325c5c8..d3e002ec41 100644
@@ -4573,7 +4573,8 @@ flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
 						  (void *)items->type,
 						  "items total size is too big"
 						  " for encap action");
-		rte_memcpy((void *)&buf[temp_size], items->spec, len);
+		if (items->spec)
+			rte_memcpy(&buf[temp_size], items->spec, len);
 		switch (items->type) {
 		case RTE_FLOW_ITEM_TYPE_ETH:
 			eth = (struct rte_ether_hdr *)&buf[temp_size];
drivers/net/mlx5/mlx5_flow_hw.c +444 -124

704 lines not on this page · raw message

Signature · 1 line
2.39.2
Acked-by on v3 1/1
#3 lore raw
Quoted 19 lines

-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, September 24, 2023 12:41 PM

If application defined several actions templates with non-shared reformat or modify headers actions AND used these templates to create a table, HWS could share reformat or modify headers resources, instead of creating a resource for each action template.

The patch activates HWS code in a way that provides reformat or modify header resources sharing.

The patch updates modify field and raw encap template actions validations:
- modify field does not allow empty action template masks.
- raw encap added action template mask validation.

Quoted 7 lines

---
Depends-on: series-28881 ("net/mlx5/hws: add support for multi pattern")
---
v2: remove Depends-on: patch
v3: add Depends-on: series
---

Best,
Ori