From 1960a28512d4ddd96e82e141f1135ace8cf6054b Mon Sep 17 00:00:00 2001 From: wenglianfa Date: Tue, 25 Feb 2025 20:18:01 +0800 Subject: [PATCH] libhns: Fix the max_inline_data value driver inclusion category: bugfix bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/IBSLL5 ---------------------------------------------------------------------- If max_inline_data=0, roundup_pow_of_two(0)=1. cap->max_inline_data will be modify to 1, which doesn't meet expectations. Here fix it. Fixes: e0c8de59b29a ("libhns: Fix the problem of sge nums") Signed-off-by: wenglianfa Signed-off-by: Xinghai Cen --- providers/hns/hns_roce_u_verbs.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index 47b1f8b..98a18c6 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -1714,6 +1714,18 @@ static unsigned int get_sge_num_from_max_inl_data(bool is_ud, return inline_sge; } +static uint32_t get_max_inline_data(struct hns_roce_context *ctx, + struct ibv_qp_cap *cap) +{ + if (cap->max_inline_data) { + return min_t(uint32_t, + roundup_pow_of_two(cap->max_inline_data), + ctx->max_inline_data); + } + + return 0; +} + static void set_ext_sge_param(struct hns_roce_context *ctx, struct ibv_qp_init_attr_ex *attr, struct hns_roce_qp *qp, unsigned int wr_cnt) @@ -1730,9 +1742,8 @@ static void set_ext_sge_param(struct hns_roce_context *ctx, attr->cap.max_send_sge); if (ctx->config & HNS_ROCE_RSP_EXSGE_FLAGS) { - attr->cap.max_inline_data = min_t(uint32_t, roundup_pow_of_two( - attr->cap.max_inline_data), - ctx->max_inline_data); + attr->cap.max_inline_data = + get_max_inline_data(ctx, &attr->cap); inline_ext_sge = max(ext_wqe_sge_cnt, get_sge_num_from_max_inl_data(is_ud, -- 2.33.0