From patchwork Sat Jan 28 22:13:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 9543489 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 87DD360415 for ; Sat, 28 Jan 2017 22:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FD2A28339 for ; Sat, 28 Jan 2017 22:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FB212833A; Sat, 28 Jan 2017 22:15:58 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 DD5512808F for ; Sat, 28 Jan 2017 22:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752411AbdA1WPb (ORCPT ); Sat, 28 Jan 2017 17:15:31 -0500 Received: from lpdvsmtp01.broadcom.com ([192.19.211.62]:57680 "EHLO relay.smtp.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752180AbdA1WPS (ORCPT ); Sat, 28 Jan 2017 17:15:18 -0500 Received: from neo01-el72.iig.avagotech.net (neo01-el72.iig.avagotech.net [10.192.204.126]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 6389028000A; Sat, 28 Jan 2017 14:13:46 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 6389028000A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1485641626; bh=G/fLgraVWkIW/HQouUj4sfQVbIYuUFCi/K9XOMMfMlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2AXfrMYl18cX4mfGghQLHHSFKFtFbadLc/k01NOn2ZH5TszCJeIGhAkRlDM+gNtC HqXJnO0TF0qXm2E8tk+mi4u5czPa+VOX8ksayt8sx/Jg51n0nPIkns13iIWPcNmfpK aKXp9pS2ELTy5ncpxJT1spU/z+ehmpiIxKVQzP+Y= From: Devesh Sharma To: linux-rdma@vger.kernel.org Cc: Devesh Sharma , Sriharsha Basavapatna , Somnath Kotur , Selvin Xavier Subject: [PATCH rdma-core 02/11] libbnxtre: Add support for user memory regions Date: Sat, 28 Jan 2017 17:13:33 -0500 Message-Id: <1485641622-30015-3-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1485641622-30015-1-git-send-email-devesh.sharma@broadcom.com> References: <1485641622-30015-1-git-send-email-devesh.sharma@broadcom.com> 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 code to allow user applications to register and unregister memory buffers with the HCA. Following functions are now supported: - ibv_reg_mr() - ibv_dereg_mr() Signed-off-by: Sriharsha Basavapatna Signed-off-by: Somnath Kotur Signed-off-by: Selvin Xavier Signed-off-by: Devesh Sharma --- providers/bnxtre/abi.h | 4 ++++ providers/bnxtre/verbs.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/providers/bnxtre/abi.h b/providers/bnxtre/abi.h index 653ac71..0568d67 100644 --- a/providers/bnxtre/abi.h +++ b/providers/bnxtre/abi.h @@ -56,4 +56,8 @@ struct bnxt_re_pd_resp { __u64 dbr; }; +struct bnxt_re_mr_resp { + struct ibv_reg_mr_resp resp; +}; + #endif diff --git a/providers/bnxtre/verbs.c b/providers/bnxtre/verbs.c index ab1a453..9813db8 100644 --- a/providers/bnxtre/verbs.c +++ b/providers/bnxtre/verbs.c @@ -134,12 +134,34 @@ int bnxt_re_free_pd(struct ibv_pd *ibvpd) struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len, int access) { - return NULL; + struct bnxt_re_mr *mr; + struct ibv_reg_mr cmd; + struct bnxt_re_mr_resp resp; + + mr = calloc(1, sizeof(*mr)); + if (!mr) + return NULL; + + if (ibv_cmd_reg_mr(ibvpd, sva, len, (uint64_t)sva, access, &mr->ibvmr, + &cmd, sizeof(cmd), &resp.resp, sizeof(resp))) { + free(mr); + return NULL; + } + + return &mr->ibvmr; } int bnxt_re_dereg_mr(struct ibv_mr *ibvmr) { - return -ENOSYS; + struct bnxt_re_mr *mr = (struct bnxt_re_mr *)ibvmr; + int status; + + status = ibv_cmd_dereg_mr(ibvmr); + if (status) + return status; + free(mr); + + return 0; } struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,