From patchwork Sat Feb 18 15:43:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 9581123 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 3928160586 for ; Sat, 18 Feb 2017 15:44:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B2B52871E for ; Sat, 18 Feb 2017 15:44:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2041B28731; Sat, 18 Feb 2017 15:44:29 +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 4683B28728 for ; Sat, 18 Feb 2017 15:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbdBRPo0 (ORCPT ); Sat, 18 Feb 2017 10:44:26 -0500 Received: from mail-wr0-f173.google.com ([209.85.128.173]:33413 "EHLO mail-wr0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752971AbdBRPoZ (ORCPT ); Sat, 18 Feb 2017 10:44:25 -0500 Received: by mail-wr0-f173.google.com with SMTP id 35so3662367wrw.0 for ; Sat, 18 Feb 2017 07:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=8sQHBYsMvJHMAJT3HkWVyafTaFrw3bzJ/fhghPYWXuI=; b=IVYa/5I/IAjAMbCPwAqW8FA8R+RV98VmjSbnYd8Yb/b+ovDg19ndeo1UgY1PMhxezv viMjlVDyfnEs/gTOgAi7Y1veYXxxHGnZNe5LicD1CWc+qxAoHpqeJb79z6S1Y71gdYD+ TrO9K144PbOJb7qGIzbLIylJN4okOb58EC0r4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8sQHBYsMvJHMAJT3HkWVyafTaFrw3bzJ/fhghPYWXuI=; b=ZVQN3hfv27PxhmN6hZYhGSxt4bSW7tIJ2918+BXPz/fZvSAhICKVroaXEs2er3jw4e OC3fgHa8SJY2V+dSHo1p8Egd5p3m3rOyilrLZ8CkdiGmLjMP3c10W7sNhHwMLHudCMKO fGonKo3UARyEFJGnBdBlB2H9lQ/WGOiBjlaTBZW1SHspFzCAz6AI1le6ECSD0IagtXwF h0qd9QysjxNYRvn0YXzaGgKoaHiBPJw+DJeDnFtgsaf4HBRWT2mbvbPRVQJGpWEFmQQp MYBHVYXs659S1TXI40E7pjzMwHvHrs5HtGb7TJ3AN1USWf7sNOCIX0U7GheMsMPJKlNH eUqg== X-Gm-Message-State: AMke39nfPLtCh5vcdBgkAXiEfMdQ398iMJ75GIXRIyYheZAKl7XPeEe2YatyFrl5gxnH+iAK X-Received: by 10.223.174.183 with SMTP id y52mr10977912wrc.112.1487432664171; Sat, 18 Feb 2017 07:44:24 -0800 (PST) Received: from neo00-el73.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id l67sm6076098wmf.1.2017.02.18.07.44.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 07:44:22 -0800 (PST) From: Devesh Sharma To: linux-rdma@vger.kernel.org Subject: [rdma-core v2 2/9] libbnxt_re: Add support for user memory regions Date: Sat, 18 Feb 2017 10:43:51 -0500 Message-Id: <1487432638-19607-3-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487432638-19607-1-git-send-email-devesh.sharma@broadcom.com> References: <1487432638-19607-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/bnxt_re/bnxt_re-abi.h | 4 ++++ providers/bnxt_re/verbs.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/providers/bnxt_re/bnxt_re-abi.h b/providers/bnxt_re/bnxt_re-abi.h index 05a0888..53645d5 100644 --- a/providers/bnxt_re/bnxt_re-abi.h +++ b/providers/bnxt_re/bnxt_re-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/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c index 5b3e1cc..72a3443 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c @@ -129,12 +129,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,