Skip to contentSkip to conversation

net/mlx5: fix assert failure in item translation

PATCH In review Suanming Mou 2 participants 2 messages Oct 26, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix assert failure in item translation

When HW Steering is enabled, mlx5dr translates flow items using DV item translation functions to configure flows in root flow table. Represented port item stores vport metadata tag in thread-local workspace when translate to DV spec. Due to the thread-local workspace was not created in HW Steering, it caused an assertion in mlx5_flow_get_thread_workspace()

This patch adds initialization of thread-local workspace when flow items are translated to DV spec in HW Steering mode.

Fixes cfddba76af4f ("net/mlx5: add hardware steering item translation function")
---
 drivers/net/mlx5/mlx5_flow.c    |  8 ++------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 20 +++++++++++++-------
 3 files changed, 17 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_flow.c +2 -6
index 13f7b92d6b..8e7d649d15 100644
@@ -81,10 +81,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. */
 extern const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops;
 
@@ -7586,7 +7582,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;
@@ -7623,7 +7619,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();
drivers/net/mlx5/mlx5_flow.h +2 -0
index 85d2fd219d..da9b65d8fe 100644
@@ -1920,6 +1920,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 {
drivers/net/mlx5/mlx5_flow_dv.c +13 -7
index f65407bd52..1e52278191 100644
@@ -13499,6 +13499,7 @@ flow_dv_translate_items_hws(const struct rte_flow_item *items,
 			    uint8_t *match_criteria,
 			    struct rte_flow_error *error)
 {
+	struct mlx5_flow_workspace *flow_wks = mlx5_flow_push_thread_workspace();
 	struct mlx5_flow_rss_desc rss_desc = { .level = attr->rss_level };
 	struct rte_flow_attr rattr = {
 		.group = attr->group,
@@ -13515,17 +13516,20 @@ flow_dv_translate_items_hws(const struct rte_flow_item *items,
 		.attr = &rattr,
 		.rss_desc = &rss_desc,
 	};
-	int ret;
+	int ret = 0;
 
+	RTE_SET_USED(flow_wks);
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
-		if (!mlx5_flow_os_item_supported(items->type))
-			return rte_flow_error_set(error, ENOTSUP,
-						  RTE_FLOW_ERROR_TYPE_ITEM,
-						  NULL, "item not supported");
+		if (!mlx5_flow_os_item_supported(items->type)) {
+			ret = rte_flow_error_set(error, ENOTSUP,
+						 RTE_FLOW_ERROR_TYPE_ITEM,
+						 NULL, "item not supported");
+			goto exit;
+		}
 		ret = flow_dv_translate_items(&rte_eth_devices[attr->port_id],
 			items, &wks, key, key_type,  NULL);
 		if (ret)
-			return ret;
+			goto exit;
 	}
 	if (wks.item_flags & MLX5_FLOW_ITEM_INTEGRITY) {
 		flow_dv_translate_item_integrity_post(key,
@@ -13569,7 +13573,9 @@ flow_dv_translate_items_hws(const struct rte_flow_item *items,
 		*match_criteria = flow_dv_matcher_enable(key);
 	if (item_flags)
 		*item_flags = wks.item_flags;
-	return 0;
+exit:
+	mlx5_flow_pop_thread_workspace();
+	return ret;
 }
 
 /**
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 15 lines

-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Wednesday, October 26, 2022 5:09 AM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH] net/mlx5: fix assert failure in item translation

When HW Steering is enabled, mlx5dr translates flow items using DV item translation functions to configure flows in root flow table. Represented port item stores vport metadata tag in thread-local workspace when translate to DV spec. Due to the thread-local workspace was not created in HW Steering, it caused an assertion in mlx5_flow_get_thread_workspace()

Quoted 8 lines

This patch adds initialization of thread-local workspace when flow items are translated to DV spec in HW Steering mode.

Fixes cfddba76af4f ("net/mlx5: add hardware steering item translation

function")

Squashed into relevant commit in next-net-mlx,

Kindest regards,
Raslan Darawsheh