DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] net/mlx5: fix non template set VLAN VID
@ 2025-02-27 10:45 Maayan Kashani
  2025-02-27 10:45 ` [PATCH 2/2] net/mlx5: fix error info in actions construct Maayan Kashani
  0 siblings, 1 reply; 2+ messages in thread
From: Maayan Kashani @ 2025-02-27 10:45 UTC (permalink / raw)
  To: dev
  Cc: mkashani, dsosnowski, rasland, stable, Viacheslav Ovsiienko,
	Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, Gregory Etelson

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")
Cc: stable@dpdk.org

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 3bfb2f35c12..ec047e855e3 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -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;
 		}
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] net/mlx5: fix error info in actions construct
  2025-02-27 10:45 [PATCH 1/2] net/mlx5: fix non template set VLAN VID Maayan Kashani
@ 2025-02-27 10:45 ` Maayan Kashani
  0 siblings, 0 replies; 2+ messages in thread
From: Maayan Kashani @ 2025-02-27 10:45 UTC (permalink / raw)
  To: dev
  Cc: mkashani, dsosnowski, rasland, stable, Viacheslav Ovsiienko,
	Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad, Gregory Etelson

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

Fixes: 654ebd8cb7a3 ("net/mlx5: support flow table resizing")
Cc: stable@dpdk.org

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index ec047e855e3..1820b79d229 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -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 *
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-27 10:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-27 10:45 [PATCH 1/2] net/mlx5: fix non template set VLAN VID Maayan Kashani
2025-02-27 10:45 ` [PATCH 2/2] net/mlx5: fix error info in actions construct Maayan Kashani

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).