From patchwork Sun Oct 14 02:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yixian Liu X-Patchwork-Id: 10640503 X-Patchwork-Delegate: jgg@ziepe.ca 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 DF47E14E2 for ; Sun, 14 Oct 2018 02:43:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D03B22A5FA for ; Sun, 14 Oct 2018 02:43:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4D5F2A609; Sun, 14 Oct 2018 02:43:47 +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 6ED772A5FA for ; Sun, 14 Oct 2018 02:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbeJNKXI (ORCPT ); Sun, 14 Oct 2018 06:23:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13633 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726265AbeJNKXI (ORCPT ); Sun, 14 Oct 2018 06:23:08 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id AF98347143D58; Sun, 14 Oct 2018 10:43:40 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.399.0; Sun, 14 Oct 2018 10:43:38 +0800 From: Yixian Liu To: , CC: , Subject: [PATCH v3 rdma-core 1/3] libhns: Add alloc mw support for hip08 Date: Sun, 14 Oct 2018 10:44:00 +0800 Message-ID: <1539485042-50118-2-git-send-email-liuyixian@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539485042-50118-1-git-send-email-liuyixian@huawei.com> References: <1539485042-50118-1-git-send-email-liuyixian@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.132] 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 This patch adds memory window (mw) allocation support in the user space driver. Signed-off-by: Yixian Liu --- providers/hns/hns_roce_u.c | 1 + providers/hns/hns_roce_u.h | 2 ++ providers/hns/hns_roce_u_verbs.c | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c index 633f6ed..8bf0358 100644 --- a/providers/hns/hns_roce_u.c +++ b/providers/hns/hns_roce_u.c @@ -62,6 +62,7 @@ static const struct verbs_match_ent hca_table[] = { }; static const struct verbs_context_ops hns_common_ops = { + .alloc_mw = hns_roce_u_alloc_mw, .alloc_pd = hns_roce_u_alloc_pd, .cq_event = hns_roce_u_cq_event, .create_cq = hns_roce_u_create_cq, diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h index 6c56bee..f023b6a 100644 --- a/providers/hns/hns_roce_u.h +++ b/providers/hns/hns_roce_u.h @@ -275,6 +275,8 @@ int hns_roce_u_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd, void *addr, size_t length, int access); int hns_roce_u_dereg_mr(struct verbs_mr *mr); +struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type); + struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector); diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index 14eeb5e..be14430 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -175,6 +175,25 @@ int hns_roce_u_dereg_mr(struct verbs_mr *vmr) return ret; } +struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type) +{ + struct ibv_mw *mw; + struct ibv_alloc_mw cmd = {}; + struct ib_uverbs_alloc_mw_resp resp = {}; + + mw = malloc(sizeof(*mw)); + if (!mw) + return NULL; + + if (ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd), + &resp, sizeof(resp))) { + free(mw); + return NULL; + } + + return mw; +} + static int align_cq_size(int req) { int nent;