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

Message ID 20230627082746.2466304-3-dsosnowski@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix counter object leaks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Dariusz Sosnowski June 27, 2023, 8:27 a.m. UTC
  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@nvidia.com

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

Patch

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;