Skip to contentSkip to conversation

net/mlx5: fix error notifications in counter initialization

PATCH In review Gregory Etelson 2 participants 2 messages Oct 27, 2024 – Oct 28, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix error notifications in counter initialization

If counter action initialization failed, the PMD used integer values, primarily (-1) or errno, to notify upper layers.

The patch uses the rte_flow_error structure for counter initialization failure notifications.

Fixes 4d368e1da3a4 ("net/mlx5: support flow counter action for HWS")
---
 drivers/net/mlx5/mlx5_flow_hw.c |  31 ++++++--
 drivers/net/mlx5/mlx5_hws_cnt.c | 123 ++++++++++++++++++++++++--------
 drivers/net/mlx5/mlx5_hws_cnt.h |   5 +-
 drivers/net/mlx5/mlx5_trigger.c |  10 ++-
 4 files changed, 128 insertions(+), 41 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +25 -6
index 5b34154bf1..6081ebc7e2 100644
@@ -11669,6 +11669,7 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 	uint32_t action_flags;
 	bool strict_queue = false;
 
+	error->type = RTE_FLOW_ERROR_TYPE_NONE;
 	if (mlx5dr_rule_get_handle_size() != MLX5_DR_RULE_SIZE) {
 		rte_errno = EINVAL;
 		goto err;
@@ -11906,9 +11907,11 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 			goto err;
 	}
 	if (port_attr->nb_counters || (host_priv && host_priv->hws_cpool)) {
-		if (mlx5_hws_cnt_pool_create(dev, port_attr->nb_counters,
-						nb_queue,
-						(host_priv ? host_priv->hws_cpool : NULL)))
+		struct mlx5_hws_cnt_pool *hws_cpool = host_priv ? host_priv->hws_cpool : NULL;
+
+		ret = mlx5_hws_cnt_pool_create(dev, port_attr->nb_counters,
+					       nb_queue, hws_cpool, error);
+		if (ret)
 			goto err;
 	}
 	if (port_attr->nb_aging_objects) {
@@ -11957,7 +11960,7 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 	if (_queue_attr)
 		mlx5_free(_queue_attr);
 	/* Do not overwrite the internal errno information. */
-	if (ret)
+	if (ret && error->type != RTE_FLOW_ERROR_TYPE_NONE)
 		return ret;
 	return rte_flow_error_set(error, rte_errno,
 				  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -11988,6 +11991,10 @@ flow_hw_configure(struct rte_eth_dev *dev,
 		  const struct rte_flow_queue_attr *queue_attr[],
 		  struct rte_flow_error *error)
 {
+	struct rte_flow_error shadow_error = {0, };
+
+	if (!error)
+		error = &shadow_error;
 	return __flow_hw_configure(dev, port_attr, nb_queue, queue_attr, false, error);
 }
 
@@ -12852,6 +12859,10 @@ flow_hw_action_validate(struct rte_eth_dev *dev,
 			const struct rte_flow_action *action,
 			struct rte_flow_error *err)
 {
+	struct rte_flow_error shadow_error = {0, };
+
+	if (!err)
+		err = &shadow_error;
 	return flow_hw_action_handle_validate(dev, MLX5_HW_INV_QUEUE, NULL,
 					      conf, action, NULL, err);
 }
@@ -13606,6 +13617,7 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev,
 	int ret;
 	uint obj_num;
 
+	error->type = RTE_FLOW_ERROR_TYPE_NONE;
 	if (action_flags & MLX5_FLOW_ACTION_AGE) {
 		/* If no age objects were previously allocated. */
 		if (!priv->hws_age_req) {
@@ -13613,7 +13625,8 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev,
 			if (!priv->hws_cpool) {
 				obj_num = MLX5_CNT_NT_MAX(priv);
 				ret = mlx5_hws_cnt_pool_create(dev, obj_num,
-							       priv->nb_queue, NULL);
+							       priv->nb_queue,
+							       NULL, error);
 				if (ret)
 					goto err;
 			}
@@ -13629,7 +13642,8 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev,
 		if (!priv->hws_cpool) {
 			obj_num = MLX5_CNT_NT_MAX(priv);
 			ret = mlx5_hws_cnt_pool_create(dev, obj_num,
-						       priv->nb_queue, NULL);
+						       priv->nb_queue, NULL,
+						       error);
 			if (ret)
 				goto err;
 		}
@@ -13655,6 +13669,8 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev,
 	}
 	return 0;
 err:
+	if (ret && error->type != RTE_FLOW_ERROR_TYPE_NONE)
+		return ret;
 	return rte_flow_error_set(error, ret,
 				  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 				  NULL, "fail to allocate actions");
@@ -13927,6 +13943,7 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
 			.actions = actions,
 		},
 	};
+	struct rte_flow_error shadow_error = {0, };
 
 	/*
 	 * TODO: add a call to flow_hw_validate function once it exist.
@@ -13934,6 +13951,8 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,
 	 */
 
 	RTE_SET_USED(encap_idx);
+	if (!error)
+		error = &shadow_error;
 	split = mlx5_flow_nta_split_metadata(dev, attr, actions, qrss, action_flags,
 					     actions_n, external, &resource, error);
 	if (split < 0)
drivers/net/mlx5/mlx5_hws_cnt.c +92 -31

298 lines not on this page · raw message

drivers/net/mlx5/mlx5_hws_cnt.h +3 -2
index 996ac8dd9a..d8da9dfcdd 100644
@@ -715,14 +715,15 @@ mlx5_hws_cnt_service_thread_destroy(struct mlx5_dev_ctx_shared *sh);
 int
 mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
 		uint32_t nb_counters, uint16_t nb_queue,
-		struct mlx5_hws_cnt_pool *chost);
+		struct mlx5_hws_cnt_pool *chost, struct rte_flow_error *error);
 
 void
 mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
 		struct mlx5_hws_cnt_pool *cpool);
 
 int
-mlx5_hws_cnt_svc_init(struct mlx5_dev_ctx_shared *sh);
+mlx5_hws_cnt_svc_init(struct mlx5_dev_ctx_shared *sh,
+		      struct rte_flow_error *error);
 
 void
 mlx5_hws_cnt_svc_deinit(struct mlx5_dev_ctx_shared *sh);
drivers/net/mlx5/mlx5_trigger.c +8 -2
index cac532b1a1..79b3d4d982 100644
@@ -1160,11 +1160,17 @@ mlx5_dev_start(struct rte_eth_dev *dev)
 	DRV_LOG(DEBUG, "port %u starting device", dev->data->port_id);
 #ifdef HAVE_MLX5_HWS_SUPPORT
 	if (priv->sh->config.dv_flow_en == 2) {
+		struct rte_flow_error error = { 0, };
+
 		/*If previous configuration does not exist. */
 		if (!(priv->dr_ctx)) {
-			ret = flow_hw_init(dev, NULL);
-			if (ret)
+			ret = flow_hw_init(dev, &error);
+			if (ret) {
+				DRV_LOG(ERR, "Failed to start port %u %s: %s",
+					dev->data->port_id, dev->data->name,
+					error.message);
 				return ret;
+			}
 		}
 		/* If there is no E-Switch, then there are no start/stop order limitations. */
 		if (!priv->sh->config.dv_esw_en)
Signature · 1 line
2.43.0
Acked-by Dariusz Sosnowski on v1 1/1
#1 lore raw

Hi,

From: Gregory Etelson <[email protected]>
Sent: Sunday, October 27, 2024 3:58 PM
To: [email protected]
Cc: Gregory Etelson; Maayan Kashani; Raslan Darawsheh; [email protected]; Dariusz Sosnowski; Slava Ovsiienko; Bing Zhao; Ori Kam; Suanming Mou; Matan Azrad; Jack Min
Subject: [PATCH] net/mlx5: fix error notifications in counter initialization

If counter action initialization failed, the PMD used integer values, primarily (-1) or errno, to notify upper layers.

The patch uses the rte_flow_error structure for counter initialization failure notifications.

Fixes 4d368e1da3a4 ("net/mlx5: support flow counter action for HWS")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh