net/mlx5: fix error notification for large patterns

Message ID 20250506133206.379993-1-getelson@nvidia.com (mailing list archive)
State Awaiting Upstream
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix error notification for large patterns |

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/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/aws-unit-testing success Unit Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Gregory Etelson May 6, 2025, 1:31 p.m. UTC
HWS has limited resources to translate flow pattern.
When pattern translation does not fit STE, HWS translation fails with
E2BIG error.

The patch verifies that the E2BIG error value is kept during flow
error notification.

Fixes: e38776c36c8a ("net/mlx5: introduce HWS for non-template flow API")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_bwc.c | 2 +-
 drivers/net/mlx5/mlx5_flow_hw.c   | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
  

Comments

Raslan Darawsheh May 15, 2025, 7:09 a.m. UTC | #1
Hi,


On 06/05/2025 4:31 PM, Gregory Etelson wrote:
> HWS has limited resources to translate flow pattern.
> When pattern translation does not fit STE, HWS translation fails with
> E2BIG error.
> 
> The patch verifies that the E2BIG error value is kept during flow
> error notification.
> 
> Fixes: e38776c36c8a ("net/mlx5: introduce HWS for non-template flow API")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>


Patch applied to next-net-mlx,
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.c b/drivers/net/mlx5/hws/mlx5dr_bwc.c
index 9233452118..0086cd2c90 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.c
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.c
@@ -137,7 +137,7 @@  mlx5dr_bwc_matcher_create(struct mlx5dr_table *table,
 						     bwc_matcher->num_of_at,
 						     &attr);
 	if (!bwc_matcher->matcher) {
-		rte_errno = EINVAL;
+		/* rte_errno must be set */
 		goto free_at;
 	}
 
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 20d38ce414..b79e629d52 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -13894,7 +13894,7 @@  static int flow_hw_register_matcher(struct rte_eth_dev *dev,
 		if (sub_error.type != RTE_FLOW_ERROR_TYPE_NONE)
 			rte_memcpy(error, &sub_error, sizeof(sub_error));
 	}
-	return rte_flow_error_set(error, ENOMEM,
+	return rte_flow_error_set(error, rte_errno,
 					RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 					NULL, "fail to register matcher");
 }
@@ -14070,8 +14070,12 @@  flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 			goto error;
 		}
 	ret = flow_hw_register_matcher(dev, attr, items, external, *flow, &matcher, error);
-	if (ret)
+	if (ret) {
+		if (rte_errno == E2BIG)
+			rte_flow_error_set(error, E2BIG, RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+				"flow pattern is too big");
 		goto error;
+	}
 
 	/*
 	 * ASO allocation – iterating on actions list to allocate missing resources.