[PATCH 21.11] net/mlx5: fix assert when creating meter policy

Shun Hao shunh at nvidia.com
Mon Nov 28 10:25:50 CET 2022


[ upstream commit afb98009a0a55970851ba51c14a22bb2623ba1d5 ]

When creating meter policy rules, it's possible to use flow items
translation to add src port match criteria. Currently the items
translation process needs to get thread workspace to store vport
metadata tag, but in policy creation, the thread workspace was not
initialized so it will cause assert failure.

This patch adds initialization of thread-local workspace when creating
meter policy rules to avoid that assert.

Fixes: e9de8f33ca89 ("net/mlx5: fix source port checking in sample flow rule")

Signed-off-by: Shun Hao <shunh at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    |  6 ++----
 drivers/net/mlx5/mlx5_flow.h    |  3 ++-
 drivers/net/mlx5/mlx5_flow_dv.c | 10 ++++++++--
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 1418631bc3..6921e5a927 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -64,8 +64,6 @@ tunnel_flow_group_to_flow_table(struct rte_eth_dev *dev,
 				uint32_t group, uint32_t *table,
 				struct rte_flow_error *error);
 
-static struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace(void);
-static void mlx5_flow_pop_thread_workspace(void);
 
 
 /** Device flow drivers. */
@@ -7148,7 +7146,7 @@ flow_alloc_thread_workspace(void)
  *
  * @return pointer to thread specific flow workspace data, NULL on error.
  */
-static struct mlx5_flow_workspace*
+struct mlx5_flow_workspace*
 mlx5_flow_push_thread_workspace(void)
 {
 	struct mlx5_flow_workspace *curr;
@@ -7185,7 +7183,7 @@ mlx5_flow_push_thread_workspace(void)
  *
  * @return pointer to thread specific flow workspace data, NULL on error.
  */
-static void
+void
 mlx5_flow_pop_thread_workspace(void)
 {
 	struct mlx5_flow_workspace *data = mlx5_flow_get_thread_workspace();
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 7b5fde4823..c2dc60670d 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1300,7 +1300,8 @@ struct mlx5_flow_driver_ops {
 };
 
 /* mlx5_flow.c */
-
+struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace(void);
+void mlx5_flow_pop_thread_workspace(void);
 struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace(void);
 __extension__
 struct flow_grp_info {
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index d4df5f8bca..3775063110 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -16577,8 +16577,11 @@ flow_dv_create_policy_rules(struct rte_eth_dev *dev,
 			     struct mlx5_flow_meter_policy *mtr_policy)
 {
 	int i;
+	int ret = 0;
 	uint16_t sub_policy_num;
+	struct mlx5_flow_workspace *wks = mlx5_flow_push_thread_workspace();
 
+	RTE_SET_USED(wks);
 	for (i = 0; i < MLX5_MTR_DOMAIN_MAX; i++) {
 		sub_policy_num = (mtr_policy->sub_policy_num >>
 			(MLX5_MTR_SUB_POLICY_NUM_SHIFT * i)) &
@@ -16590,10 +16593,13 @@ flow_dv_create_policy_rules(struct rte_eth_dev *dev,
 			mtr_policy->sub_policys[i][0], i)) {
 			DRV_LOG(ERR, "Failed to create policy action "
 				"list per domain.");
-			return -1;
+			ret = -1;
+			goto exit;
 		}
 	}
-	return 0;
+exit:
+	mlx5_flow_pop_thread_workspace();
+	return ret;
 }
 
 static int
-- 
2.20.0



More information about the stable mailing list