RDMA/hns: Refactor process of setting extended sge
The variable 'cnt' is used to represent the max number of sge an SQ WQE can use at first, then it means how many extended sge an SQ has. In addition, this function has no need to return a value. So refactor and encapsulate the parts of getting number of extended sge a WQE can use to make it easier to understand. Link: https://lore.kernel.org/r/1606558959-48510-4-git-send-email-liweihang@huawei.com Signed-off-by: Weihang Li <liweihang@huawei.com> Reviewed-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
d34895c319
commit
05201e01be
|
@ -465,42 +465,43 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_extend_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,
|
static u32 get_wqe_ext_sge_cnt(struct hns_roce_qp *qp)
|
||||||
struct hns_roce_qp *hr_qp,
|
|
||||||
struct ib_qp_cap *cap)
|
|
||||||
{
|
{
|
||||||
u32 cnt;
|
/* GSI/UD QP only has extended sge */
|
||||||
|
if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_UD)
|
||||||
|
return qp->sq.max_gs;
|
||||||
|
|
||||||
cnt = max(1U, cap->max_send_sge);
|
if (qp->sq.max_gs > HNS_ROCE_SGE_IN_WQE)
|
||||||
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
|
return qp->sq.max_gs - HNS_ROCE_SGE_IN_WQE;
|
||||||
hr_qp->sq.max_gs = roundup_pow_of_two(cnt);
|
|
||||||
hr_qp->sge.sge_cnt = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr_qp->sq.max_gs = cnt;
|
static void set_ext_sge_param(struct hns_roce_dev *hr_dev, u32 sq_wqe_cnt,
|
||||||
|
struct hns_roce_qp *hr_qp, struct ib_qp_cap *cap)
|
||||||
/* UD sqwqe's sge use extend sge */
|
{
|
||||||
if (hr_qp->ibqp.qp_type == IB_QPT_GSI ||
|
u32 total_sge_cnt;
|
||||||
hr_qp->ibqp.qp_type == IB_QPT_UD) {
|
u32 wqe_sge_cnt;
|
||||||
cnt = roundup_pow_of_two(sq_wqe_cnt * hr_qp->sq.max_gs);
|
|
||||||
} else if (hr_qp->sq.max_gs > HNS_ROCE_SGE_IN_WQE) {
|
|
||||||
cnt = roundup_pow_of_two(sq_wqe_cnt *
|
|
||||||
(hr_qp->sq.max_gs - HNS_ROCE_SGE_IN_WQE));
|
|
||||||
} else {
|
|
||||||
cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT;
|
hr_qp->sge.sge_shift = HNS_ROCE_SGE_SHIFT;
|
||||||
|
|
||||||
|
if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
|
||||||
|
hr_qp->sq.max_gs = HNS_ROCE_SGE_IN_WQE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr_qp->sq.max_gs = max(1U, cap->max_send_sge);
|
||||||
|
|
||||||
|
wqe_sge_cnt = get_wqe_ext_sge_cnt(hr_qp);
|
||||||
|
|
||||||
/* If the number of extended sge is not zero, they MUST use the
|
/* If the number of extended sge is not zero, they MUST use the
|
||||||
* space of HNS_HW_PAGE_SIZE at least.
|
* space of HNS_HW_PAGE_SIZE at least.
|
||||||
*/
|
*/
|
||||||
hr_qp->sge.sge_cnt = cnt ?
|
if (wqe_sge_cnt) {
|
||||||
max(cnt, (u32)HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE) : 0;
|
total_sge_cnt = roundup_pow_of_two(sq_wqe_cnt * wqe_sge_cnt);
|
||||||
|
hr_qp->sge.sge_cnt = max(total_sge_cnt,
|
||||||
return 0;
|
(u32)HNS_HW_PAGE_SIZE / HNS_ROCE_SGE_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_sq_size_with_integrity(struct hns_roce_dev *hr_dev,
|
static int check_sq_size_with_integrity(struct hns_roce_dev *hr_dev,
|
||||||
|
@ -545,9 +546,7 @@ static int set_user_sq_size(struct hns_roce_dev *hr_dev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = set_extend_sge_param(hr_dev, cnt, hr_qp, cap);
|
set_ext_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
hr_qp->sq.wqe_shift = ucmd->log_sq_stride;
|
hr_qp->sq.wqe_shift = ucmd->log_sq_stride;
|
||||||
hr_qp->sq.wqe_cnt = cnt;
|
hr_qp->sq.wqe_cnt = cnt;
|
||||||
|
@ -612,7 +611,6 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
|
||||||
{
|
{
|
||||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||||
u32 cnt;
|
u32 cnt;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!cap->max_send_wr || cap->max_send_wr > hr_dev->caps.max_wqes ||
|
if (!cap->max_send_wr || cap->max_send_wr > hr_dev->caps.max_wqes ||
|
||||||
cap->max_send_sge > hr_dev->caps.max_sq_sg) {
|
cap->max_send_sge > hr_dev->caps.max_sq_sg) {
|
||||||
|
@ -632,9 +630,7 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
|
||||||
hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
|
hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
|
||||||
hr_qp->sq.wqe_cnt = cnt;
|
hr_qp->sq.wqe_cnt = cnt;
|
||||||
|
|
||||||
ret = set_extend_sge_param(hr_dev, cnt, hr_qp, cap);
|
set_ext_sge_param(hr_dev, cnt, hr_qp, cap);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* sync the parameters of kernel QP to user's configuration */
|
/* sync the parameters of kernel QP to user's configuration */
|
||||||
cap->max_send_wr = cnt;
|
cap->max_send_wr = cnt;
|
||||||
|
|
Loading…
Reference in New Issue