From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
Maayan Kashani <mkashani@nvidia.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>
Subject: [PATCH 1/2] net/mlx5: fix counter pool init error propagation
Date: Fri, 25 Apr 2025 21:41:04 +0200 [thread overview]
Message-ID: <20250425194105.39401-2-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20250425194105.39401-1-dsosnowski@nvidia.com>
In case of an error in mlx5_hws_cnt_pool_create(),
value stored in ret is used as "error code".
There are however a few cases inside this function,
when this variable is not set, leading to failed
assertions (e.g., when requested number of counters is bigger
than maximum supported).
This patch addresses these cases, by propagating the rte_errno
set by failing functions.
Fixes: e1c83d295dd9 ("net/mlx5: support ASO actions with non-template flow")
Cc: mkashani@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
drivers/net/mlx5/mlx5_hws_cnt.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index 7b5e7310af..fd12bcd7ec 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -704,8 +704,11 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
size_t sz;
mp_name = mlx5_malloc(MLX5_MEM_ZERO, RTE_MEMZONE_NAMESIZE, 0, SOCKET_ID_ANY);
- if (mp_name == NULL)
+ if (mp_name == NULL) {
+ ret = rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+ "failed to allocate counter pool name prefix");
goto error;
+ }
snprintf(mp_name, RTE_MEMZONE_NAMESIZE, "MLX5_HWS_CNT_P_%x", dev->data->port_id);
pcfg.name = mp_name;
pcfg.request_num = nb_counters;
@@ -713,8 +716,10 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
if (chost) {
pcfg.host_cpool = chost;
cpool = mlx5_hws_cnt_pool_init(priv->sh, &pcfg, &cparam, error);
- if (cpool == NULL)
+ if (cpool == NULL) {
+ ret = -rte_errno;
goto error;
+ }
ret = mlx5_hws_cnt_pool_action_create(priv, cpool);
if (ret != 0) {
rte_flow_error_set(error, -ret,
@@ -736,15 +741,19 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
cparam.threshold = HWS_CNT_CACHE_THRESHOLD_DEFAULT;
cparam.size = HWS_CNT_CACHE_SZ_DEFAULT;
cpool = mlx5_hws_cnt_pool_init(priv->sh, &pcfg, &cparam, error);
- if (cpool == NULL)
+ if (cpool == NULL) {
+ ret = -rte_errno;
goto error;
+ }
ret = mlx5_hws_cnt_pool_dcs_alloc(priv->sh, cpool, error);
if (ret != 0)
goto error;
sz = RTE_ALIGN_CEIL(mlx5_hws_cnt_pool_get_size(cpool), 4);
cpool->raw_mng = mlx5_hws_cnt_raw_data_alloc(priv->sh, sz, error);
- if (cpool->raw_mng == NULL)
+ if (cpool->raw_mng == NULL) {
+ ret = -rte_errno;
goto error;
+ }
__hws_cnt_id_load(cpool);
/*
* Bump query gen right after pool create so the
--
2.39.5
next prev parent reply other threads:[~2025-04-25 19:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-25 19:41 [PATCH 0/2] net/mlx5: flow counter pool fixes Dariusz Sosnowski
2025-04-25 19:41 ` Dariusz Sosnowski [this message]
2025-04-25 19:41 ` [PATCH 2/2] net/mlx5: fix counter service thread init Dariusz Sosnowski
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=20250425194105.39401-2-dsosnowski@nvidia.com \
--to=dsosnowski@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
--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).