From patchwork Sat Mar 3 09:29:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10256033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5757360211 for ; Sat, 3 Mar 2018 09:30:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49D8D286F5 for ; Sat, 3 Mar 2018 09:30:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E43528753; Sat, 3 Mar 2018 09:30:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CBF9286F5 for ; Sat, 3 Mar 2018 09:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbeCCJ36 (ORCPT ); Sat, 3 Mar 2018 04:29:58 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:48567 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751800AbeCCJ36 (ORCPT ); Sat, 3 Mar 2018 04:29:58 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 664DA745E3B12; Sat, 3 Mar 2018 17:29:44 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Sat, 3 Mar 2018 17:29:42 +0800 From: Lijun Ou To: , CC: , Subject: [PATCH rdma-core 3/4] libhns: Update the algorithm for computing queue buffer Date: Sat, 3 Mar 2018 17:29:29 +0800 Message-ID: <1520069370-129426-4-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520069370-129426-1-git-send-email-oulijun@huawei.com> References: <1520069370-129426-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;