From: "Minggang Li(Gavin)" <gavinl@nvidia.com>
To: <matan@nvidia.com>, <viacheslavo@nvidia.com>, <orika@nvidia.com>,
<thomas@monjalon.net>, Dariusz Sosnowski <dsosnowski@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
Alexander Kozyrev <akozyrev@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <stable@dpdk.org>
Subject: [PATCH V3 1/3] net/mlx5: set rte errno if malloc failed
Date: Tue, 24 Sep 2024 13:52:56 +0300 [thread overview]
Message-ID: <20240924105258.58037-2-gavinl@nvidia.com> (raw)
In-Reply-To: <20240924105258.58037-1-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 allocation failed. To
fix the issue, set rte_errno to ENOMEM if mlx5_ipool_malloc failed to
allocate ID.
Fixes: c40c061a022e ("net/mlx5: add basic flow queue operation")
Fixes: 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action with HWS")
cc: stable@dpdk.org
Signed-off-by: Minggang Li(Gavin) <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 a275154d4b..f34670b3ec 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -1905,7 +1905,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;
@@ -1917,8 +1917,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;
@@ -3926,8 +3933,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
@@ -3938,8 +3947,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;
@@ -4070,8 +4081,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
@@ -4082,8 +4095,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;
@@ -4218,8 +4233,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
parent reply other threads:[~2024-09-24 10:53 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20240924105258.58037-1-gavinl@nvidia.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240924105258.58037-2-gavinl@nvidia.com \
--to=gavinl@nvidia.com \
--cc=akozyrev@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
--cc=thomas@monjalon.net \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).