* [PATCH 0/2] net/mlx5: flow counter pool fixes
@ 2025-04-25 19:41 Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 1/2] net/mlx5: fix counter pool init error propagation Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 2/2] net/mlx5: fix counter service thread init Dariusz Sosnowski
0 siblings, 2 replies; 3+ messages in thread
From: Dariusz Sosnowski @ 2025-04-25 19:41 UTC (permalink / raw)
To: Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou, Matan Azrad
Cc: dev, stable
This patch series includes several fixes for flow counter pool
used with HW Steering flow engine.
Dariusz Sosnowski (2):
net/mlx5: fix counter pool init error propagation
net/mlx5: fix counter service thread init
drivers/net/mlx5/mlx5_hws_cnt.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] net/mlx5: fix counter pool init error propagation
2025-04-25 19:41 [PATCH 0/2] net/mlx5: flow counter pool fixes Dariusz Sosnowski
@ 2025-04-25 19:41 ` Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 2/2] net/mlx5: fix counter service thread init Dariusz Sosnowski
1 sibling, 0 replies; 3+ messages in thread
From: Dariusz Sosnowski @ 2025-04-25 19:41 UTC (permalink / raw)
To: Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou,
Matan Azrad, Maayan Kashani
Cc: dev, stable
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] net/mlx5: fix counter service thread init
2025-04-25 19:41 [PATCH 0/2] net/mlx5: flow counter pool fixes Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 1/2] net/mlx5: fix counter pool init error propagation Dariusz Sosnowski
@ 2025-04-25 19:41 ` Dariusz Sosnowski
1 sibling, 0 replies; 3+ messages in thread
From: Dariusz Sosnowski @ 2025-04-25 19:41 UTC (permalink / raw)
To: Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou,
Matan Azrad, Xiaoyu Min
Cc: dev, stable
During counter pool initialization (mlx5_hws_cnt_pool_create()),
a background service thread is started by mlx5 PMD,
which refreshes counter values periodically.
During initialization it might happen that:
- background thread creation succeeds,
- pool creation fails (e.g. due to error in configuration
provided by the user).
In this case, the procedure on error rollback will not clean up
counter service thread, because rollback assumes that
is there is no pool, then there is nothing to clean up.
This patch fixes that, by moving background thread creation
to the end of counter pool initialization.
This ensures proper order of resource release during rollback.
Also, this patch adds missing "goto error" in case of
failure to initialize the service thread.
Fixes: 4d368e1da3a4 ("net/mlx5: support flow counter action for HWS")
Cc: jackmin@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 | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_hws_cnt.c b/drivers/net/mlx5/mlx5_hws_cnt.c
index fd12bcd7ec..5c7c0041aa 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.c
+++ b/drivers/net/mlx5/mlx5_hws_cnt.c
@@ -729,12 +729,6 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
}
goto success;
}
- /* init cnt service if not. */
- if (priv->sh->cnt_svc == NULL) {
- ret = mlx5_hws_cnt_svc_init(priv->sh, error);
- if (ret)
- goto error;
- }
cparam.fetch_sz = HWS_CNT_CACHE_FETCH_DEFAULT;
cparam.preload_sz = HWS_CNT_CACHE_PRELOAD_DEFAULT;
cparam.q_num = nb_queue;
@@ -769,6 +763,12 @@ mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
NULL, "failed to allocate counter actions");
goto error;
}
+ /* init cnt service if not. */
+ if (priv->sh->cnt_svc == NULL) {
+ ret = mlx5_hws_cnt_svc_init(priv->sh, error);
+ if (ret)
+ goto error;
+ }
priv->sh->cnt_svc->refcnt++;
cpool->priv = priv;
rte_spinlock_lock(&priv->sh->cpool_lock);
--
2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-25 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-25 19:41 [PATCH 0/2] net/mlx5: flow counter pool fixes Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 1/2] net/mlx5: fix counter pool init error propagation Dariusz Sosnowski
2025-04-25 19:41 ` [PATCH 2/2] net/mlx5: fix counter service thread init Dariusz Sosnowski
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).