From patchwork Sat Oct 27 10:56:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun Ou X-Patchwork-Id: 10658341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2727513A9 for ; Sat, 27 Oct 2018 10:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 207402B1A1 for ; Sat, 27 Oct 2018 10:54:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 149552B562; Sat, 27 Oct 2018 10:54:50 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 B127E2B1A1 for ; Sat, 27 Oct 2018 10:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728488AbeJ0TfV (ORCPT ); Sat, 27 Oct 2018 15:35:21 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14146 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728474AbeJ0TfV (ORCPT ); Sat, 27 Oct 2018 15:35:21 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9CD529D726BC9; Sat, 27 Oct 2018 18:54:42 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Sat, 27 Oct 2018 18:54:40 +0800 From: Lijun Ou To: , CC: , Subject: [PATCH rdma-core 6/6] libhns: Update poll cq for supporting srq Date: Sat, 27 Oct 2018 18:56:37 +0800 Message-ID: <1540637797-97065-7-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1540637797-97065-1-git-send-email-oulijun@huawei.com> References: <1540637797-97065-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 When poll cqe generated by srq wqe, it need to get the corresponding cqe and free the srq wqe index, write it into the queue and update the wqe index. This patch mainly implements the above operation. Signed-off-by: Lijun Ou --- providers/hns/hns_roce_u_hw_v2.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index bdf8bbb..d00bd42 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c @@ -154,6 +154,21 @@ static void *get_srq_wqe(struct hns_roce_srq *srq, int n) return srq->buf.buf + (n << srq->wqe_shift); } +static void hns_roce_free_srq_wqe(struct hns_roce_srq *srq, int ind) +{ + uint32_t bitmap_num; + int bit_num; + + pthread_spin_lock(&srq->lock); + + bitmap_num = ind / (sizeof(uint64_t) * BIT_CNT_PER_BYTE); + bit_num = ind % (sizeof(uint64_t) * BIT_CNT_PER_BYTE); + srq->idx_que.bitmap[bitmap_num] |= (1ULL << bit_num); + srq->tail++; + + pthread_spin_unlock(&srq->lock); +} + static int hns_roce_v2_wq_overflow(struct hns_roce_wq *wq, int nreq, struct hns_roce_cq *cq) { @@ -268,6 +283,7 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *cq, struct hns_roce_wq *wq = NULL; struct hns_roce_v2_cqe *cqe = NULL; struct hns_roce_rinl_sge *sge_list; + struct hns_roce_srq *srq = NULL; uint32_t opcode; struct ibv_qp_attr attr; int attr_mask; @@ -305,6 +321,7 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *cq, } wc->qp_num = qpn & 0xffffff; + srq = (*cur_qp)->ibv_qp.srq ? to_hr_srq((*cur_qp)->ibv_qp.srq) : NULL; if (is_send) { wq = &(*cur_qp)->sq; /* @@ -325,6 +342,12 @@ static int hns_roce_v2_poll_one(struct hns_roce_cq *cq, /* write the wr_id of wq into the wc */ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; ++wq->tail; + } else if (srq) { + wqe_ctr = (uint16_t)(roce_get_field(cqe->byte_4, + CQE_BYTE_4_WQE_IDX_M, + CQE_BYTE_4_WQE_IDX_S)); + wc->wr_id = srq->wrid[wqe_ctr]; + hns_roce_free_srq_wqe(srq, wqe_ctr); } else { wq = &(*cur_qp)->rq; wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];