patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 1/3] net/mlx5: set rte errno if malloc failed
       [not found] <20240906102151.171965-1-gavinl@nvidia.com>
@ 2024-09-06 10:21 ` Gavin Li
  0 siblings, 0 replies; only message in thread
From: Gavin Li @ 2024-09-06 10:21 UTC (permalink / raw)
  To: matan, viacheslavo, orika, thomas, Dariusz Sosnowski, Bing Zhao,
	Suanming Mou, Alexander Kozyrev
  Cc: dev, rasland, Minggang Li (Gavin), stable

From: "Minggang Li (Gavin)" <gavinl@nvidia.com>

rte_errno should be set if anything wrong happened in under layer so that
user can figure out what's going on.

There were some cases that did not set it when ipool allcation failed. To
fix the issue, set rte_errno to ENOMEM if mlx5_ipool_malloc failed to
allocate ID.

Fixes: c40c061a02 ("net/mlx5: add basic flow queue operation")
Fixes: 48fbb0e93d ("net/mlx5: support flow meter mark indirect action with HWS")
cc: stable@dpdk.org
Signed-off-by: Gavin Li <gavinl@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 50888944a5..509de2a6a4 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -1897,7 +1897,7 @@ flow_hw_meter_mark_alloc(struct rte_eth_dev *dev, uint32_t queue,
 	const struct rte_flow_action_meter_mark *meter_mark = action->conf;
 	struct mlx5_aso_mtr *aso_mtr;
 	struct mlx5_flow_meter_info *fm;
-	uint32_t mtr_id;
+	uint32_t mtr_id = 0;
 	uintptr_t handle = (uintptr_t)MLX5_INDIRECT_ACTION_TYPE_METER_MARK <<
 					MLX5_INDIRECT_ACTION_TYPE_OFFSET;
 
@@ -1909,8 +1909,15 @@ flow_hw_meter_mark_alloc(struct rte_eth_dev *dev, uint32_t queue,
 	if (meter_mark->profile == NULL)
 		return NULL;
 	aso_mtr = mlx5_ipool_malloc(pool->idx_pool, &mtr_id);
-	if (!aso_mtr)
+	if (!aso_mtr) {
+		rte_flow_error_set(error, ENOMEM,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "failed to allocate aso meter entry");
+		if (mtr_id)
+			mlx5_ipool_free(pool->idx_pool, mtr_id);
 		return NULL;
+	}
 	/* Fill the flow meter parameters. */
 	aso_mtr->type = ASO_METER_INDIRECT;
 	fm = &aso_mtr->fm;
@@ -3918,8 +3925,10 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev,
 			return NULL;
 	}
 	flow = mlx5_ipool_malloc(table->flow, &flow_idx);
-	if (!flow)
+	if (!flow) {
+		rte_errno = ENOMEM;
 		goto error;
+	}
 	rule_acts = flow_hw_get_dr_action_buffer(priv, table, action_template_index, queue);
 	/*
 	 * Set the table here in order to know the destination table
@@ -3930,8 +3939,10 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev,
 	flow->idx = flow_idx;
 	if (table->resource) {
 		mlx5_ipool_malloc(table->resource, &res_idx);
-		if (!res_idx)
+		if (!res_idx) {
+			rte_errno = ENOMEM;
 			goto error;
+		}
 		flow->res_idx = res_idx;
 	} else {
 		flow->res_idx = flow_idx;
@@ -4062,8 +4073,10 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev,
 			return NULL;
 	}
 	flow = mlx5_ipool_malloc(table->flow, &flow_idx);
-	if (!flow)
+	if (!flow) {
+		rte_errno = ENOMEM;
 		goto error;
+	}
 	rule_acts = flow_hw_get_dr_action_buffer(priv, table, action_template_index, queue);
 	/*
 	 * Set the table here in order to know the destination table
@@ -4074,8 +4087,10 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev,
 	flow->idx = flow_idx;
 	if (table->resource) {
 		mlx5_ipool_malloc(table->resource, &res_idx);
-		if (!res_idx)
+		if (!res_idx) {
+			rte_errno = ENOMEM;
 			goto error;
+		}
 		flow->res_idx = res_idx;
 	} else {
 		flow->res_idx = flow_idx;
@@ -4210,8 +4225,10 @@ flow_hw_async_flow_update(struct rte_eth_dev *dev,
 	nf->idx = of->idx;
 	if (table->resource) {
 		mlx5_ipool_malloc(table->resource, &res_idx);
-		if (!res_idx)
+		if (!res_idx) {
+			rte_errno = ENOMEM;
 			goto error;
+		}
 		nf->res_idx = res_idx;
 	} else {
 		nf->res_idx = of->res_idx;
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-09-06 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240906102151.171965-1-gavinl@nvidia.com>
2024-09-06 10:21 ` [PATCH 1/3] net/mlx5: set rte errno if malloc failed Gavin Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).