[PATCH net-next 4/6] net/mlx5: HWS, Add timeout mechanism to draining send queues

From: Tariq Toukan

Date: Tue Sep 15 2026 - 07:40:06 EST


From: Yevgeny Kliteynik <kliteyn@xxxxxxxxxx>

HWS has a timeout mechanism for usual polling for completion,
but it was missing such a mechanism for draining the send queues.

Signed-off-by: Yevgeny Kliteynik <kliteyn@xxxxxxxxxx>
Reviewed-by: Erez Shitrit <erezsh@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
.../ethernet/mellanox/mlx5/core/steering/hws/bwc.c | 4 +++-
.../ethernet/mellanox/mlx5/core/steering/hws/send.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
index 3bcf412a08c4..14a2bb9167a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc.c
@@ -460,7 +460,9 @@ int mlx5hws_bwc_queue_poll(struct mlx5hws_context *ctx,
got_comp = !!ret;

if (unlikely(!got_comp && time_after(jiffies, timeout))) {
- mlx5hws_err(ctx, "BWC poll error: polling queue %d - TIMEOUT\n", queue_id);
+ mlx5hws_err(ctx,
+ "BWC poll error: polling queue %d - TIMEOUT (%d sec)\n",
+ queue_id, MLX5HWS_BWC_POLLING_TIMEOUT);
return -ETIMEDOUT;
}
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
index 49dee44d0bef..9ff109fc8230 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
@@ -1192,6 +1192,8 @@ int mlx5hws_send_queue_action(struct mlx5hws_context *ctx,
u16 queue_id,
u32 actions)
{
+ unsigned long timeout = jiffies +
+ secs_to_jiffies(MLX5HWS_BWC_POLLING_TIMEOUT);
struct mlx5hws_send_ring_sq *send_sq;
struct mlx5hws_send_engine *queue;
bool wait_comp = false;
@@ -1213,9 +1215,18 @@ int mlx5hws_send_queue_action(struct mlx5hws_context *ctx,
mlx5hws_send_engine_flush_queue(queue);

/* Poll queue until empty */
- while (wait_comp && !mlx5hws_send_engine_empty(queue))
+ while (wait_comp && !mlx5hws_send_engine_empty(queue)) {
hws_send_engine_poll_cq(queue, NULL, &polled, 0);

+ if (unlikely(time_after(jiffies, timeout))) {
+ mlx5hws_err(ctx,
+ "Error draining send queue %d - TIMEOUT (%d sec)\n",
+ queue_id,
+ MLX5HWS_BWC_POLLING_TIMEOUT);
+ return -ETIMEDOUT;
+ }
+ }
+
break;
default:
return -EINVAL;
--
2.44.0