net/mlx5: fix HW flow counter query
PATCH 1/1 net/mlx5: fix HW flow counter query
From: Xiaoyu Min <[email protected]>
There are a couple of issues in the logic used by counter service thread to refresh flow counter values in HW Steering mode:
1. Flow counter offset in bulk is not taken into account correctly during query.
2. Number of WQEs used up during query is not tracked correctly.
Regarding the 1st issue, HW flow counters are queried by posting WQEs. Each WQE queries 4 flow counters at once.
Flow counters are addressed by base ID (ASO object ID)
and offset (divided by 4).
During periodic counter refresh, mlx5 PMD fills whole queue with WQEs and waits for query completion. This is repeated until all known counters are refreshed.
The issue is that, between different iterations the base offset was not adjusted. This lead to the same 64k counters (max achievable through single queue) were being queried. Any flow counters above that limit would get incorrect values.
This patch addresses that by adding proper offset calculation during query loop.
Regarding the 2nd issue, tracking of how many counters were really queried during single loop was incorrect.
In case when there weren't enough free WQEs in the queue, fewer counters were queried than expected.
This mismatch was not taken into account, which in the resulted in some counters not being queried.
This patch addresses that by adding proper reporting of the number of queried counters to mlx5_aso_cnt_sq_enqueue_burst().
--- .mailmap | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 44 +++++++++++++++++--------------- 2 files changed, 24 insertions(+), 21 deletions(-)
.mailmap +1 -0
@@ -1108,6 +1108,7 @@ Mohamed Feroz Abdul Majeeth <[email protected]> Mohammad Abdul Awal <[email protected]> Mohammad Iqbal Ahmad <[email protected]> Mohammed Gamal <[email protected]> +Mohand Alrasheed <[email protected]> Mohsin Kazmi <[email protected]> Mohsin Mazhar Shaikh <[email protected]> Mohsin Shaikh <[email protected]>
drivers/net/mlx5/mlx5_flow_aso.c +23 -21
108 lines not on this page · raw message
Signature · 1 line
2.47.3
Hi Dariusz and Xiaoyu,
Thank you both for identifying and fixing these issues.
I tested the patch locally. Based on my testing, the HW flow counter data is consistent and the issue I observed is resolved.
Best regards,
Mohand
-----Original Message-----
From: Dariusz <[email protected]>
To: Viacheslav <[email protected]>; Bing <[email protected]>; Ori <[email protected]>; Suanming <[email protected]>; Matan <[email protected]>
Cc: dev <[email protected]>; Raslan <[email protected]>; Xiaoyu <[email protected]>; stable <[email protected]>; Mohand <[email protected]>
Date: Monday, 12 January 2026 11:56 PM +03
Subject: [PATCH] net/mlx5: fix HW flow counter query
From: Xiaoyu Min <[email protected]>
There are a couple of issues in the logic used by counter service thread to refresh flow counter values in HW Steering mode:
1. Flow counter offset in bulk is not taken into account correctly during query.
2. Number of WQEs used up during query is not tracked correctly.
Regarding the 1st issue, HW flow counters are queried by posting WQEs. Each WQE queries 4 flow counters at once.
Flow counters are addressed by base ID (ASO object ID)
and offset (divided by 4).
During periodic counter refresh, mlx5 PMD fills whole queue with WQEs and waits for query completion. This is repeated until all known counters are refreshed.
The issue is that, between different iterations the base offset was not adjusted. This lead to the same 64k counters (max achievable through single queue) were being queried. Any flow counters above that limit would get incorrect values.
This patch addresses that by adding proper offset calculation during query loop.
Regarding the 2nd issue, tracking of how many counters were really queried during single loop was incorrect.
In case when there weren't enough free WQEs in the queue, fewer counters were queried than expected.
This mismatch was not taken into account, which in the resulted in some counters not being queried.
This patch addresses that by adding proper reporting of the number of queried counters to mlx5_aso_cnt_sq_enqueue_burst().
--- .mailmap | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 44 +++++++++++++++++--------------- 2 files changed, 24 insertions(+), 21 deletions(-)
.mailmap +1 -0
@@ -1108,6 +1108,7 @@ Mohamed Feroz Abdul Majeeth <[email protected]> Mohammad Abdul Awal <[email protected]> Mohammad Iqbal Ahmad <[email protected]> Mohammed Gamal <[email protected]> +Mohand Alrasheed <[email protected]> Mohsin Kazmi <[email protected]> Mohsin Mazhar Shaikh <[email protected]> Mohsin Shaikh <[email protected]>
drivers/net/mlx5/mlx5_flow_aso.c +23 -21
108 lines not on this page · raw message
Signature · 1 line
2.47.3
Quoted 8 lines · Mohand Alrasheed
Hi Dariusz and Xiaoyu,
Thank you both for identifying and fixing these issues.
I tested the patch locally. Based on my testing, the HW flow counter data is consistent and the issue I observed is resolved.
Best regards,
Mohand
Glad to hear it and thank you for the feedback.
Best regards,
Dariusz Sosnowski
[snip]
Hi,
Quoted 34 lines · Dariusz Sosnowski
From: Xiaoyu Min <[email protected]>
There are a couple of issues in the logic used by counter service thread to refresh flow counter values in HW Steering mode:
1. Flow counter offset in bulk is not taken into account correctly during query.
2. Number of WQEs used up during query is not tracked correctly.Regarding the 1st issue, HW flow counters are queried by posting WQEs. Each WQE queries 4 flow counters at once.
Flow counters are addressed by base ID (ASO object ID)
and offset (divided by 4).
During periodic counter refresh, mlx5 PMD fills whole queue with WQEs and waits for query completion. This is repeated until all known counters are refreshed.The issue is that, between different iterations the base offset was not adjusted. This lead to the same 64k counters (max achievable through single queue) were being queried. Any flow counters above that limit would get incorrect values.
This patch addresses that by adding proper offset calculation during query loop.Regarding the 2nd issue, tracking of how many counters were really queried during single loop was incorrect.
In case when there weren't enough free WQEs in the queue, fewer counters were queried than expected.
This mismatch was not taken into account, which in the resulted in some counters not being queried.
This patch addresses that by adding proper reporting of the number of queried counters tomlx5_aso_cnt_sq_enqueue_burst().
Quoted 6 lines
Fixes 4d368e1da3a4 ("net/mlx5: support flow counter action for HWS")Reported-by Mohand Alrasheed <[email protected]>Signed-off-by Xiaoyu Min <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh