Skip to contentSkip to conversation

net/mlx5: fix non template set VLAN VID

PATCH In review Maayan Kashani 2 participants 3 messages Feb 27, 2025 – Mar 11, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/mlx5: fix non template set VLAN VID

Support set vlan vid in non template on top of HWS.
Update relevant return errors in the relevant functions to avoid crash. Mask the vlan vid action in non template mode
such that the action template create will use the vid value.

Fixes 00a0a6b80674 ("net/mlx5: support indirect actions in non-template setup")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +18 -7
index 3bfb2f35c12..ec047e855e3 100644
@@ -714,6 +714,9 @@ flow_hw_action_flags_get(const struct rte_flow_action actions[],
 		case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN:
 			action_flags |= MLX5_FLOW_ACTION_OF_POP_VLAN;
 			break;
+		case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+			action_flags |= MLX5_FLOW_ACTION_OF_SET_VLAN_VID;
+			break;
 		case RTE_FLOW_ACTION_TYPE_JUMP:
 			action_flags |= MLX5_FLOW_ACTION_JUMP;
 			break;
@@ -7811,22 +7814,23 @@ flow_hw_parse_flow_actions_to_dr_actions(struct rte_eth_dev *dev,
 	return -EINVAL;
 }
 
-static void
+static int
 flow_hw_set_vlan_vid(struct rte_eth_dev *dev,
 		     struct rte_flow_action *ra,
 		     struct rte_flow_action *rm,
 		     struct rte_flow_action_modify_field *spec,
 		     struct rte_flow_action_modify_field *mask,
-		     int set_vlan_vid_ix)
+		     int set_vlan_vid_ix,
+		     struct rte_flow_error *error)
 {
-	struct rte_flow_error error;
 	const bool masked = rm[set_vlan_vid_ix].conf &&
 		(((const struct rte_flow_action_of_set_vlan_vid *)
 			rm[set_vlan_vid_ix].conf)->vlan_vid != 0);
 	const struct rte_flow_action_of_set_vlan_vid *conf =
 		ra[set_vlan_vid_ix].conf;
 	int width = mlx5_flow_item_field_width(dev, RTE_FLOW_FIELD_VLAN_ID, 0,
-					       NULL, &error);
+					       NULL, error);
+	MLX5_ASSERT(width);
 	*spec = (typeof(*spec)) {
 		.operation = RTE_FLOW_MODIFY_SET,
 		.dst = {
@@ -7859,6 +7863,7 @@ flow_hw_set_vlan_vid(struct rte_eth_dev *dev,
 	ra[set_vlan_vid_ix].conf = spec;
 	rm[set_vlan_vid_ix].type = RTE_FLOW_ACTION_TYPE_MODIFY_FIELD;
 	rm[set_vlan_vid_ix].conf = mask;
+	return 0;
 }
 
 static __rte_always_inline int
@@ -8104,9 +8109,11 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev,
 								   tmp_mask,
 								   &ra, &rm,
 								   act_num);
-		flow_hw_set_vlan_vid(dev, ra, rm,
-				     &set_vlan_vid_spec, &set_vlan_vid_mask,
-				     set_vlan_vid_ix);
+		ret = flow_hw_set_vlan_vid(dev, ra, rm,
+					   &set_vlan_vid_spec, &set_vlan_vid_mask,
+					   set_vlan_vid_ix, error);
+		if (ret)
+			goto error;
 		action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD;
 	}
 	if (action_flags & MLX5_FLOW_ACTION_QUOTA) {
@@ -13744,6 +13751,10 @@ flow_nta_build_template_mask(const struct rte_flow_action actions[],
 					action->conf)->definition;
 			mask->conf = conf;
 			break;
+		case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID:
+			memset(conf, 0xff, sizeof(struct rte_flow_action_of_set_vlan_vid));
+			mask->conf = conf;
+			break;
 		default:
 			break;
 		}
Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/2 net/mlx5: fix error info in actions construct

In some cases in debug it misses the error info.
Fix to update the error structure.

Fixes 654ebd8cb7a3 ("net/mlx5: support flow table resizing")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +4 -3
index ec047e855e3..1820b79d229 100644
@@ -3615,7 +3615,8 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
 
 		mp_segment = mlx5_multi_pattern_segment_find(table, flow->res_idx);
 		if (!mp_segment || !mp_segment->mhdr_action)
-			return -1;
+			return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+						  NULL, "No modify header action found");
 		rule_acts[pos].action = mp_segment->mhdr_action;
 		/* offset is relative to DR action */
 		rule_acts[pos].modify_header.offset =
@@ -3946,8 +3947,8 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
 
 error:
 	flow_hw_release_actions(dev, queue, flow);
-	rte_errno = EINVAL;
-	return -rte_errno;
+	return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				  NULL, "Action construction failed");
 }
 
 static const struct rte_flow_item *
Signature · 1 line
2.21.0
Acked-by Dariusz Sosnowski on v1 1/2
#2 lore raw
In reply to Maayan Kashani

Hi,

From: Maayan Kashani <[email protected]>
Sent: Thursday, February 27, 2025 12:45 PM
To: [email protected]
Cc: Maayan Kashani; Dariusz Sosnowski; Raslan Darawsheh; [email protected]; Slava Ovsiienko; Bing Zhao; Ori Kam; Suanming Mou; Matan Azrad; Gregory Etelson
Subject: [PATCH 1/2] net/mlx5: fix non template set VLAN VID

Support set vlan vid in non template on top of HWS.
Update relevant return errors in the relevant functions to avoid crash. Mask the vlan vid action in non template mode
such that the action template create will use the vid value.

Fixes 00a0a6b80674 ("net/mlx5: support indirect actions in non-template setup")

series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh