From d5e41736168d567cc6f4a40a594836715506e38c Mon Sep 17 00:00:00 2001 From: ZHOU Huaping Date: Tue, 8 Jul 2025 17:11:24 +0800 Subject: [PATCH] mlx5: ignore QP max_recv_wr when SRQ is used According to the manual, max_recv_wr and max_recv_sge are ignored by `ibv_create_qp` if the QP is to be associated with an SRQ. Fix the bug where `ibv_create_qp` may fail due to uninitialized `max_recv_wr`. Signed-off-by: ZHOU Huaping --- providers/mlx5/verbs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 211767063..0d9690bba 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -1770,6 +1770,12 @@ static int mlx5_get_max_recv_wr(struct mlx5_context *ctx, struct mlx5dv_qp_init_attr *mlx5_qp_attr, uint32_t *max_recv_wr) { + /* Ignore max_recv_wr when SRQ is used. */ + if (attr->srq) { + *max_recv_wr = 0; + return 0; + } + if (mlx5_qp_attr && (mlx5_qp_attr->create_flags & MLX5DV_QP_CREATE_OOO_DP) && attr->cap.max_recv_wr > 1) { uint32_t max_recv_wr_cap = 0;