[PATCH rdma-core 3/4] libhns: Update the algorithm for computing queue buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Due to the hip06 hardware limitations, the buffer size actually
requested by the hardware is applied when the number of
tasks issued by the user is less than the minimum cq&qp
specifications. However, the hip08 hardware is not limited.

Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx>
---
 providers/hns/hns_roce_u_verbs.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 11390de..785a343 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -194,6 +194,16 @@ static int align_qp_size(int req)
 	return nent;
 }
 
+static int align_queue_size(int req)
+{
+	int nent;
+
+	for (nent = 1; nent < req; nent <<= 1)
+		;
+
+	return nent;
+}
+
 static void hns_roce_set_sq_sizes(struct hns_roce_qp *qp,
 				  struct ibv_qp_cap *cap, enum ibv_qp_type type)
 {
@@ -269,7 +279,10 @@ struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe,
 	if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
 		goto err;
 
-	cqe = align_cq_size(cqe);
+	if (to_hr_dev(context->device)->hw_version == HNS_ROCE_HW_VER1)
+		cqe = align_cq_size(cqe);
+	else
+		cqe = align_queue_size(cqe);
 
 	if (hns_roce_alloc_cq_buf(to_hr_dev(context->device), &cq->buf, cqe))
 		goto err;
@@ -518,8 +531,14 @@ struct ibv_qp *hns_roce_u_create_qp(struct ibv_pd *pd,
 	}
 
 	hns_roce_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp);
-	qp->sq.wqe_cnt = align_qp_size(attr->cap.max_send_wr);
-	qp->rq.wqe_cnt = align_qp_size(attr->cap.max_recv_wr);
+
+	if (to_hr_dev(pd->context->device)->hw_version == HNS_ROCE_HW_VER1) {
+		qp->sq.wqe_cnt = align_qp_size(attr->cap.max_send_wr);
+		qp->rq.wqe_cnt = align_qp_size(attr->cap.max_recv_wr);
+	} else {
+		qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr);
+		qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
+	}
 
 	if (to_hr_dev(pd->context->device)->hw_version == HNS_ROCE_HW_VER1) {
 		qp->sq.max_gs = 2;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux