From 996bca51e2063dc790286cbc894e2c438f499441 Mon Sep 17 00:00:00 2001
From: Luoyouming <luoyouming@huawei.com>
Date: Mon, 10 Oct 2022 21:49:35 +0800
Subject: [PATCH v4 06/10] libhns: Add compatibility handling for rq inline

Add compatibility processing between different user space
and kernel space.

Signed-off-by: Luoyouming <luoyouming@huawei.com>
Reviewed-by: Yangyang Li <liyangyang20@huawei.com>
---
 providers/hns/hns_roce_u.c       | 2 +-
 providers/hns/hns_roce_u_verbs.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 1bd5bb1..6c9aefa 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -113,7 +113,7 @@ static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
 	if (!context)
 		return NULL;
 
-	cmd.config |= HNS_ROCE_EXSGE_FLAGS;
+	cmd.config |= HNS_ROCE_EXSGE_FLAGS | HNS_ROCE_RQ_INLINE_FLAGS;
 	if (ibv_cmd_get_context(&context->ibv_ctx, &cmd.ibv_cmd, sizeof(cmd),
 				&resp.ibv_resp, sizeof(resp)))
 		goto err_free;
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 851b145..3e9a306 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -1079,7 +1079,9 @@ static void hns_roce_set_qp_params(struct ibv_qp_init_attr_ex *attr,
 		cnt = roundup_pow_of_two(attr->cap.max_recv_wr);
 		qp->rq.wqe_cnt = cnt;
 		qp->rq.shift = hr_ilog32(cnt);
-		qp->rq_rinl_buf.wqe_cnt = cnt;
+		qp->rq_rinl_buf.wqe_cnt = 0;
+		if (ctx->config & HNS_ROCE_RSP_RQ_INLINE_FLAGS)
+			qp->rq_rinl_buf.wqe_cnt = cnt;
 
 		attr->cap.max_recv_wr = qp->rq.wqe_cnt;
 		attr->cap.max_recv_sge = qp->rq.max_gs;
-- 
2.30.0

