net/mlx5: fix raw encap validation

Message ID 20241027052625.208681-1-getelson@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix raw encap validation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing pending Testing pending
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Etelson, Gregory Oct. 27, 2024, 5:26 a.m. UTC
In SWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for
flow action. The action validation checks for both size and data
parameters.

In HWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for
the action template and validates the action mask.

The patch separates encap validation in
`mlx5_flow_dv_validate_action_raw_encap_decap` for SWS and HWS cases.

Fixes: cbfa4ed03913 ("net/mlx5: update flow actions validation before template creation")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
  

Comments

Dariusz Sosnowski Oct. 28, 2024, 8:47 a.m. UTC | #1
> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Sunday, October 27, 2024 06:26
> To: dev@dpdk.org
> Cc: Gregory Etelson <getelson@nvidia.com>; Maayan Kashani
> <mkashani@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Dariusz
> Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Bing Zhao <bingz@nvidia.com>; Ori Kam
> <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan
> Azrad <matan@nvidia.com>
> Subject: [PATCH] net/mlx5: fix raw encap validation
> 
> In SWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for flow
> action. The action validation checks for both size and data parameters.
> 
> In HWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for the
> action template and validates the action mask.
> 
> The patch separates encap validation in
> `mlx5_flow_dv_validate_action_raw_encap_decap` for SWS and HWS cases.
> 
> Fixes: cbfa4ed03913 ("net/mlx5: update flow actions validation before
> template creation")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>

Best regards,
Dariusz Sosnowski
  
Raslan Darawsheh Oct. 30, 2024, 2:21 p.m. UTC | #2
Hi,

From: Gregory Etelson <getelson@nvidia.com>
Sent: Sunday, October 27, 2024 7:26 AM
To: dev@dpdk.org
Cc: Gregory Etelson; Maayan Kashani; Raslan Darawsheh; Dariusz Sosnowski; Slava Ovsiienko; Bing Zhao; Ori Kam; Suanming Mou; Matan Azrad
Subject: [PATCH] net/mlx5: fix raw encap validation

In SWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for
flow action. The action validation checks for both size and data
parameters.

In HWS, `mlx5_flow_dv_validate_action_raw_encap_decap` is called for
the action template and validates the action mask.

The patch separates encap validation in
`mlx5_flow_dv_validate_action_raw_encap_decap` for SWS and HWS cases.

Fixes: cbfa4ed03913 ("net/mlx5: update flow actions validation before template creation")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 89057edbcf..294e23de98 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4047,10 +4047,19 @@  mlx5_flow_dv_validate_action_raw_encap_decap
 	const struct mlx5_priv *priv = dev->data->dev_private;
 	int ret;
 
-	if (encap && (!encap->size || !encap->data))
-		return rte_flow_error_set(error, EINVAL,
-					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
-					  "raw encap data cannot be empty");
+	if (encap) {
+		if (!mlx5_hws_active(dev)) {
+			if (!encap->size || !encap->data)
+				return rte_flow_error_set
+					(error, EINVAL,
+					 RTE_FLOW_ERROR_TYPE_ACTION, NULL, "raw encap data cannot be empty");
+		} else {
+			if (!encap->size)
+				return rte_flow_error_set
+					(error, EINVAL,
+					 RTE_FLOW_ERROR_TYPE_ACTION, NULL, "raw encap size cannot be 0");
+		}
+	}
 	if (decap && encap) {
 		if (decap->size <= MLX5_ENCAPSULATION_DECISION_SIZE &&
 		    encap->size > MLX5_ENCAPSULATION_DECISION_SIZE)