Skip to contentSkip to conversation

net/mlx5: fix indirect action template error handling

PATCH In review Maayan Kashani 2 participants 2 messages May 26, 2024 – May 27, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix indirect action template error handling

For indirect action type, on error case the function jumped to err but returned zero cause rte_errno was not initialized before the jump. It caused no error in table creation.

In case reaching an error, if rte_errno is not initialized, it will be set to EINVAL.
Now table creation should fail if the translate of the action fails. Added driver log warnings so it can be easy to track failure on shared actions translate.

Fixes 7ab3962d2d2b ("net/mlx5: add indirect HW steering action")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +15 -4
index 80efcf44fa..d0a1ec85ec 100644
@@ -1106,15 +1106,19 @@ flow_hw_shared_action_translate(struct rte_eth_dev *dev,
 		if (!shared_rss || __flow_hw_act_data_shared_rss_append
 		    (priv, acts,
 		    (enum rte_flow_action_type)MLX5_RTE_FLOW_ACTION_TYPE_RSS,
-		    action_src, action_dst, idx, shared_rss))
+		    action_src, action_dst, idx, shared_rss)) {
+			DRV_LOG(WARNING, "Indirect RSS action index %d translate failed", act_idx);
 			return -1;
+		}
 		break;
 	case MLX5_INDIRECT_ACTION_TYPE_COUNT:
 		if (__flow_hw_act_data_shared_cnt_append(priv, acts,
 			(enum rte_flow_action_type)
 			MLX5_RTE_FLOW_ACTION_TYPE_COUNT,
-			action_src, action_dst, act_idx))
+			action_src, action_dst, act_idx)) {
+			DRV_LOG(WARNING, "Indirect count action translate failed");
 			return -1;
+		}
 		break;
 	case MLX5_INDIRECT_ACTION_TYPE_AGE:
 		/* Not supported, prevent by validate function. */
@@ -1122,15 +1126,19 @@ flow_hw_shared_action_translate(struct rte_eth_dev *dev,
 		break;
 	case MLX5_INDIRECT_ACTION_TYPE_CT:
 		if (flow_hw_ct_compile(dev, MLX5_HW_INV_QUEUE,
-				       idx, &acts->rule_acts[action_dst]))
+				       idx, &acts->rule_acts[action_dst])) {
+			DRV_LOG(WARNING, "Indirect CT action translate failed");
 			return -1;
+		}
 		break;
 	case MLX5_INDIRECT_ACTION_TYPE_METER_MARK:
 		if (__flow_hw_act_data_shared_mtr_append(priv, acts,
 			(enum rte_flow_action_type)
 			MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK,
-			action_src, action_dst, idx))
+			action_src, action_dst, idx)) {
+			DRV_LOG(WARNING, "Indirect meter mark action translate failed");
 			return -1;
+		}
 		break;
 	case MLX5_INDIRECT_ACTION_TYPE_QUOTA:
 		flow_hw_construct_quota(priv, &acts->rule_acts[action_dst], idx);
@@ -2641,6 +2649,9 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev,
 	}
 	return 0;
 err:
+	/*If rte_errno was not initialized and reached error state. */
+	if (!rte_errno)
+		rte_errno = EINVAL;
 	err = rte_errno;
 	__flow_hw_action_template_destroy(dev, acts);
 	return rte_flow_error_set(error, err,
Signature · 1 line
2.34.1
Acked-by Suanming Mou on v1 1/1
#1 lore raw

Hi,

From: Maayan Kashani <[email protected]>
Sent: Sunday, May 26, 2024 4:22 PM
To: [email protected]
Cc: Maayan Kashani; Suanming Mou; Raslan Darawsheh; [email protected]; Dariusz Sosnowski; Slava Ovsiienko; Ori Kam; Matan Azrad
Subject: [PATCH] net/mlx5: fix indirect action template error handling

For indirect action type, on error case the function jumped to err but returned zero cause rte_errno was not initialized before the jump. It caused no error in table creation.

In case reaching an error, if rte_errno is not initialized, it will be set to EINVAL.
Now table creation should fail if the translate of the action fails. Added driver log warnings so it can be easy to track failure on shared actions translate.

Fixes 7ab3962d2d2b ("net/mlx5: add indirect HW steering action")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh