From patchwork Mon Apr 24 18:53:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 9696977 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 510F660224 for ; Mon, 24 Apr 2017 18:53:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4597F2841F for ; Mon, 24 Apr 2017 18:53:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3982F2842A; Mon, 24 Apr 2017 18:53:33 +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 BC83A2841F for ; Mon, 24 Apr 2017 18:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1173863AbdDXSxb (ORCPT ); Mon, 24 Apr 2017 14:53:31 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34024 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1173865AbdDXSxa (ORCPT ); Mon, 24 Apr 2017 14:53:30 -0400 Received: by mail-pf0-f171.google.com with SMTP id c198so16427395pfc.1 for ; Mon, 24 Apr 2017 11:53:30 -0700 (PDT) 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=PQHMYBpwp2TgSow3OMsyS7vz4AU9+srlwnuY3esFfjk=; b=K/wBPLmOSfphnFIKZ5tNC5/JbLTOKwzblKQVX1miQqqlXbWFOlN/rvAPkwFTqMmLdt zExpOd1e8OpcOnQmm88dboUiYBtVzIQjKw9ScJb3MD0ZckytdceZdq5Kzt1Ig7tJp7gB aGAOagkrcWI2gcqD/fNF6LmapYJ/4Y/sulKQA= 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=PQHMYBpwp2TgSow3OMsyS7vz4AU9+srlwnuY3esFfjk=; b=tv8+sg+ivT7ISrETQjO78cQmb9nsMwQQfKI72JBhK/ZDE/+PqwifYkWiFh5oFdM3dC dCrnUAnLDyLVG3GYks6y5/k9MkWB7GgCndQezf49G1d6pPDaLLsIjFefZ+ymphab3QEi oS0HMFaSCurnHrU5EB9wK9hlFY6dVlrpLJH1ClVzB9d2bLCPSS1A8NJrGgI+h8nEEk/p kG4nlYBTu6OaJBG/5b5I/+HyhTCY+NwDPCnWWqiJ5l7Z7O33bqioEdSt/uKZxQc+1J0O aNEDnfb1A+GisTJhLdU+2VvNbUFPktT/fWvpQh024rAVkhTRfqOCRTdYc3s9WCN5K1xV g/AQ== X-Gm-Message-State: AN3rC/4jDnhiWYwxiH4ZI2wRgxMR3F4Y+qzI4BuVeSRkxxsGCNhS6+jt FGt2LzwLFrYT+rfd5nc= X-Received: by 10.84.204.133 with SMTP id b5mr9455458ple.98.1493060009776; Mon, 24 Apr 2017 11:53:29 -0700 (PDT) Received: from neo00-el73.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id w5sm20333554pfd.23.2017.04.24.11.53.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2017 11:53:28 -0700 (PDT) From: Devesh Sharma To: linux-rdma@vger.kernel.org Subject: [rdma-core v5 2/8] libbnxt_re: Add support for user memory regions Date: Mon, 24 Apr 2017 14:53:09 -0400 Message-Id: <1493059995-636-3-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1493059995-636-1-git-send-email-devesh.sharma@broadcom.com> References: <1493059995-636-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 3993c61..f67e37d 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c @@ -131,12 +131,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, (uintptr_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,