The sending queue (SQ) size of BWC API is not fixed and the same as
that of other HWS rule insertion SQs. When checking the queue full
state, the number of queue entries and the used entries should be
used instead of the macro "MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ".

Or else, when resizing the matcher and moving the rules, sometimes
it would fail incorrectly. For example, once a hiccup of generating
CQE happened, the polling of CQ exited directly without any retry.
Then there was no enough room for the next rule to be moved.

Using the correct state of a SQ will solve this issue, the polling
of associative CQ will continue until a new CQE is generated.

Fixes: 87026d2e6601 ("net/mlx5/hws: support backward-compatible API")

Signed-off-by: Bing Zhao <bi...@nvidia.com>
Reviewed-by: Yevgeny Kliteynik <klit...@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnow...@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_bwc.c | 4 +++-
 drivers/net/mlx5/hws/mlx5dr_bwc.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.c 
b/drivers/net/mlx5/hws/mlx5dr_bwc.c
index e0b6390ed9..9233452118 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.c
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.c
@@ -181,10 +181,10 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
                      uint32_t *pending_rules,
                      bool drain)
 {
-       bool queue_full = *pending_rules == MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ;
        struct rte_flow_op_result comp[MLX5DR_BWC_MATCHER_REHASH_BURST_TH];
        uint16_t burst_th = mlx5dr_bwc_get_burst_th(ctx, queue_id);
        bool got_comp = *pending_rules >= burst_th;
+       bool queue_full;
        int err = 0;
        int ret;
        int i;
@@ -193,6 +193,8 @@ mlx5dr_bwc_queue_poll(struct mlx5dr_context *ctx,
        if (!got_comp && !drain)
                return 0;
 
+       /* The FULL state of a SQ is always a subcondition of the original 
'got_comp'. */
+       queue_full = mlx5dr_send_engine_full(&ctx->send_queue[queue_id]);
        while (queue_full || ((got_comp || drain) && *pending_rules)) {
                ret = mlx5dr_send_queue_poll(ctx, queue_id, comp, burst_th);
                if (unlikely(ret < 0)) {
diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.h 
b/drivers/net/mlx5/hws/mlx5dr_bwc.h
index 648443861b..8c3f721ac2 100644
--- a/drivers/net/mlx5/hws/mlx5dr_bwc.h
+++ b/drivers/net/mlx5/hws/mlx5dr_bwc.h
@@ -9,7 +9,6 @@
 #define MLX5DR_BWC_MATCHER_SIZE_LOG_STEP 1
 #define MLX5DR_BWC_MATCHER_REHASH_PERCENT_TH 70
 #define MLX5DR_BWC_MATCHER_REHASH_BURST_TH 32
-#define MLX5DR_BWC_MATCHER_REHASH_QUEUE_SZ 256
 #define MLX5DR_BWC_MATCHER_ATTACH_AT_NUM 255
 
 struct mlx5dr_bwc_matcher {
-- 
2.34.1

Reply via email to