Bugfix for hns SRQ and SGE. And also added all related cleanups and refactorings. Signed-off-by: zhengfeng luo <luozhengfeng@h-partners.com> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
70 lines
2.4 KiB
Diff
70 lines
2.4 KiB
Diff
From d68ac72a8e4f2cf9754d3fcbbb8ff2a03e514c2f Mon Sep 17 00:00:00 2001
|
|
From: Wenpeng Liang <liangwenpeng@huawei.com>
|
|
Date: Tue, 11 May 2021 19:06:40 +0800
|
|
Subject: libhns: Remove the reserved wqe of SRQ
|
|
|
|
There is an unreasonable reserved WQE in SRQ, it should be removed.
|
|
|
|
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
|
|
Signed-off-by: Weihang Li <liweihang@huawei.com>
|
|
---
|
|
providers/hns/hns_roce_u.h | 1 +
|
|
providers/hns/hns_roce_u_hw_v2.c | 4 +---
|
|
providers/hns/hns_roce_u_verbs.c | 5 ++++-
|
|
3 files changed, 6 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h
|
|
index a437727c..0d7abd81 100644
|
|
--- a/providers/hns/hns_roce_u.h
|
|
+++ b/providers/hns/hns_roce_u.h
|
|
@@ -64,6 +64,7 @@
|
|
#define HNS_ROCE_MIN_CQE_NUM 0x40
|
|
#define HNS_ROCE_V1_MIN_WQE_NUM 0x20
|
|
#define HNS_ROCE_V2_MIN_WQE_NUM 0x40
|
|
+#define HNS_ROCE_MIN_SRQ_WQE_NUM 1
|
|
|
|
#define HNS_ROCE_CQE_SIZE 0x20
|
|
#define HNS_ROCE_V3_CQE_SIZE 0x40
|
|
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
|
|
index d4e7e4f9..2fb6cdaf 100644
|
|
--- a/providers/hns/hns_roce_u_hw_v2.c
|
|
+++ b/providers/hns/hns_roce_u_hw_v2.c
|
|
@@ -1530,10 +1530,8 @@ static int hns_roce_u_v2_destroy_qp(struct ibv_qp *ibqp)
|
|
static int hns_roce_v2_srqwq_overflow(struct hns_roce_srq *srq)
|
|
{
|
|
struct hns_roce_idx_que *idx_que = &srq->idx_que;
|
|
- unsigned int cur;
|
|
|
|
- cur = idx_que->head - idx_que->tail;
|
|
- return cur >= srq->wqe_cnt - 1;
|
|
+ return idx_que->head - idx_que->tail >= srq->wqe_cnt;
|
|
}
|
|
|
|
static int check_post_srq_valid(struct hns_roce_srq *srq,
|
|
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
|
|
index 75b9e530..4847639b 100644
|
|
--- a/providers/hns/hns_roce_u_verbs.c
|
|
+++ b/providers/hns/hns_roce_u_verbs.c
|
|
@@ -489,6 +489,9 @@ static int verify_srq_create_attr(struct hns_roce_context *context,
|
|
attr->attr.max_sge > context->max_srq_sge)
|
|
return -EINVAL;
|
|
|
|
+ attr->attr.max_wr = max_t(uint32_t, attr->attr.max_wr,
|
|
+ HNS_ROCE_MIN_SRQ_WQE_NUM);
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -498,7 +501,7 @@ static void set_srq_param(struct ibv_context *context, struct hns_roce_srq *srq,
|
|
if (to_hr_dev(context->device)->hw_version == HNS_ROCE_HW_VER2)
|
|
srq->rsv_sge = 1;
|
|
|
|
- srq->wqe_cnt = roundup_pow_of_two(attr->attr.max_wr + 1);
|
|
+ srq->wqe_cnt = roundup_pow_of_two(attr->attr.max_wr);
|
|
srq->max_gs = roundup_pow_of_two(attr->attr.max_sge + srq->rsv_sge);
|
|
srq->wqe_shift = hr_ilog32(roundup_pow_of_two(HNS_ROCE_SGE_SIZE *
|
|
srq->max_gs));
|
|
--
|
|
2.30.0
|
|
|