Skip to content

Commit b28ca7c

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Limit extend sq sge num
According to hip08 limit, the buffer size of extend sge needs to be an integer wqe_sge_buf_page size. For example, the value of sge_shift field of qp context is greater or equal to eight when buffer page size is 4K size. The value of sge_shift field of qp context assigned by hr_qp->sge.sge_cnt. Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 3a63c96 commit b28ca7c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_qp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
344344
{
345345
u32 roundup_sq_stride = roundup_pow_of_two(hr_dev->caps.max_sq_desc_sz);
346346
u8 max_sq_stride = ilog2(roundup_sq_stride);
347+
u32 ex_sge_num;
347348
u32 page_size;
348349
u32 max_cnt;
349350

@@ -384,6 +385,7 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
384385
}
385386

386387
hr_qp->sge.sge_shift = 4;
388+
ex_sge_num = hr_qp->sge.sge_cnt;
387389

388390
/* Get buf size, SQ and RQ are aligned to page_szie */
389391
if (hr_dev->caps.max_sq_sg <= 2) {
@@ -397,6 +399,8 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
397399
hr_qp->sq.wqe_shift), PAGE_SIZE);
398400
} else {
399401
page_size = 1 << (hr_dev->caps.mtt_buf_pg_sz + PAGE_SHIFT);
402+
hr_qp->sge.sge_cnt =
403+
max(page_size / (1 << hr_qp->sge.sge_shift), ex_sge_num);
400404
hr_qp->buff_size = HNS_ROCE_ALOGN_UP((hr_qp->rq.wqe_cnt <<
401405
hr_qp->rq.wqe_shift), page_size) +
402406
HNS_ROCE_ALOGN_UP((hr_qp->sge.sge_cnt <<
@@ -405,7 +409,7 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
405409
hr_qp->sq.wqe_shift), page_size);
406410

407411
hr_qp->sq.offset = 0;
408-
if (hr_qp->sge.sge_cnt) {
412+
if (ex_sge_num) {
409413
hr_qp->sge.offset = HNS_ROCE_ALOGN_UP(
410414
(hr_qp->sq.wqe_cnt <<
411415
hr_qp->sq.wqe_shift),
@@ -491,6 +495,8 @@ static int hns_roce_set_kernel_sq_size(struct hns_roce_dev *hr_dev,
491495
page_size);
492496

493497
if (hr_dev->caps.max_sq_sg > 2 && hr_qp->sge.sge_cnt) {
498+
hr_qp->sge.sge_cnt = max(page_size/(1 << hr_qp->sge.sge_shift),
499+
(u32)hr_qp->sge.sge_cnt);
494500
hr_qp->sge.offset = size;
495501
size += HNS_ROCE_ALOGN_UP(hr_qp->sge.sge_cnt <<
496502
hr_qp->sge.sge_shift, page_size);

0 commit comments

Comments
 (0)