From patchwork Thu Apr 13 15:56:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 9679673 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 61BF560383 for ; Thu, 13 Apr 2017 15:56:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 542A828658 for ; Thu, 13 Apr 2017 15:56:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 472592866A; Thu, 13 Apr 2017 15:56:28 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 A925C28658 for ; Thu, 13 Apr 2017 15:56:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753020AbdDMP40 (ORCPT ); Thu, 13 Apr 2017 11:56:26 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33363 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751324AbdDMP4Z (ORCPT ); Thu, 13 Apr 2017 11:56:25 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 13 Apr 2017 18:56:18 +0300 Received: from r-vnc08.mtr.labs.mlnx (r-vnc08.mtr.labs.mlnx [10.208.0.121]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v3DFuHou028607; Thu, 13 Apr 2017 18:56:18 +0300 From: Max Gurtovoy To: linux-nvme@lists.infradead.org, keith.busch@intel.com, hch@lst.de, linux-rdma@vger.kernel.org, leon@kernel.org Cc: vladimirk@mellanox.com, maxg@mellanox.com Subject: [PATCH v2 1/4] IB/core: Add inline function to get sg mr type Date: Thu, 13 Apr 2017 18:56:14 +0300 Message-Id: <1492098977-5231-2-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1492098977-5231-1-git-send-email-maxg@mellanox.com> References: <1492098977-5231-1-git-send-email-maxg@mellanox.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 ULPs such as iSER/NVMEoF can use memory regions that support arbitrary sg list mapping in order to allow the block layer to send us gappy bios and reduce the stack workload. Add an helper function to get IB_MR_TYPE_SG_GAPS mr_type if the device support this kind of mapping. Signed-off-by: Max Gurtovoy Reviewed-by: Leon Romanovsky --- include/rdma/ib_verbs.h | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 99e4423..dd97169 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -3375,6 +3375,23 @@ int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents, unsigned int *sg_offset, int (*set_page)(struct ib_mr *, u64)); +/** + * ib_get_sg_mr_type() - check if the device support arbitrary + * sg mapping and return a suitable mr type. + * @device: The device on which to check support. + * + * Return: IB_MR_TYPE_SG_GAPS if the device support. + * Otherwise, return IB_MR_TYPE_MEM_REG. + */ +static inline enum ib_mr_type ib_get_sg_mr_type(struct ib_device *device) +{ + if (device->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG) + return IB_MR_TYPE_SG_GAPS; + else + return IB_MR_TYPE_MEM_REG; + +} + void ib_drain_rq(struct ib_qp *qp); void ib_drain_sq(struct ib_qp *qp); void ib_drain_qp(struct ib_qp *qp);