[PATCH 2/2] net/mlx5: fix counter allocation from shared pool

Dariusz Sosnowski dsosnowski at nvidia.com
Tue Jun 27 10:27:46 CEST 2023


mlx5_hws_cnt struct represents counter objects which are used
in flow rules. This struct contains a union which stores
the following information:

- If counter object is used:
  - `share` is set to 1 if and only if counter object is used
    in an indirect action.
  - `age_idx` is set to the relevant AGE object index.
  - Both of these fields are set at the time of allocatin
    a counter object from the pool.
- If counter object is unused:
  - `query_gen_when_free` is set to the current reset cycle
    of the counter service at the time of freeing the counter object.

When ports were configured to share the flow engine resources,
counter object allocation logic in mlx5_hws_cnt_pool_get()
did not reset the `share` field.
This caused issues when previously released counter object
had the least significant bit of `query_gen_when_free` set to 1.
That counter object was treated as shared counter (indirect action),
even if it was allocated by using COUNT action directly in the flow
rule.

This patch fixes this issue by adding the explicit reset of `share`
field.

Fixes: 13ea6bdcc7ee ("net/mlx5: support counters in cross port shared mode")
Cc: viacheslavo at nvidia.com

Signed-off-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
Acked-by: Ori Kam <orika at nvidia.com>
---
 drivers/net/mlx5/mlx5_hws_cnt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5_hws_cnt.h b/drivers/net/mlx5/mlx5_hws_cnt.h
index f37a7d6151..f462665eac 100644
--- a/drivers/net/mlx5/mlx5_hws_cnt.h
+++ b/drivers/net/mlx5/mlx5_hws_cnt.h
@@ -506,6 +506,7 @@ mlx5_hws_cnt_pool_get(struct mlx5_hws_cnt_pool *cpool, uint32_t *queue,
 		__hws_cnt_query_raw(cpool, *cnt_id,
 				    &cpool->pool[iidx].reset.hits,
 				    &cpool->pool[iidx].reset.bytes);
+		cpool->pool[iidx].share = 0;
 		MLX5_ASSERT(!cpool->pool[iidx].in_used);
 		cpool->pool[iidx].in_used = true;
 		cpool->pool[iidx].age_idx = age_idx;
-- 
2.25.1



More information about the dev mailing list