From patchwork Mon Feb 8 12:43:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 8249381 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A2A339F3CD for ; Mon, 8 Feb 2016 12:44:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C01C5203B8 for ; Mon, 8 Feb 2016 12:44:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDB76203B7 for ; Mon, 8 Feb 2016 12:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbcBHMoe (ORCPT ); Mon, 8 Feb 2016 07:44:34 -0500 Received: from [193.47.165.129] ([193.47.165.129]:59282 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752678AbcBHMod (ORCPT ); Mon, 8 Feb 2016 07:44:33 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Feb 2016 14:43:54 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u18ChsIL007052; Mon, 8 Feb 2016 14:43:54 +0200 Received: from vnc17.mtl.labs.mlnx (localhost.localdomain [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id u18ChsR2015332; Mon, 8 Feb 2016 14:43:54 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id u18Chsj1015330; Mon, 8 Feb 2016 14:43:54 +0200 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, matanb@mellanox.com, majd@mellanox.com, talal@mellanox.com, ogerlitz@mellanox.com Subject: [PATCH V1 libibverbs 3/7] Add bind/unbind support for Memory Window type one Date: Mon, 8 Feb 2016 14:43:18 +0200 Message-Id: <1454935402-15192-4-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1454935402-15192-1-git-send-email-yishaih@mellanox.com> References: <1454935402-15192-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Type one: - Bind through a verb. - The R_key is allocated by the verb. - To unbind, the bind verb should be used with size of 0. - Belongs to a PD (no QP association). Add above functionality by: - Restructuring struct ibv_mw_bind. - Expose ibv_bind_mw verb. - Add an helper API to be used by drivers to increment the tag part of the R_key. - Add IBV_ACCESS_ZERO_BASED to expose the zero based address option. Signed-off-by: Yishai Hadas --- include/infiniband/verbs.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 7d67cc8..528bff5 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -383,9 +383,17 @@ enum ibv_access_flags { IBV_ACCESS_REMOTE_READ = (1<<2), IBV_ACCESS_REMOTE_ATOMIC = (1<<3), IBV_ACCESS_MW_BIND = (1<<4), + IBV_ACCESS_ZERO_BASED = (1<<5), IBV_ACCESS_ON_DEMAND = (1<<6), }; +struct ibv_mw_bind_info { + struct ibv_mr *mr; + uint64_t addr; + uint64_t length; + int mw_access_flags; /* use ibv_access_flags */ +}; + struct ibv_pd { struct ibv_context *context; uint32_t handle; @@ -750,11 +758,8 @@ struct ibv_recv_wr { struct ibv_mw_bind { uint64_t wr_id; - struct ibv_mr *mr; - void *addr; - size_t length; int send_flags; - int mw_access_flags; + struct ibv_mw_bind_info bind_info; }; struct ibv_srq { @@ -1267,6 +1272,29 @@ static inline int ibv_dealloc_mw(struct ibv_mw *mw) } /** + * ibv_inc_rkey - Increase the 8 lsb in the given rkey + */ +static inline uint32_t ibv_inc_rkey(uint32_t rkey) +{ + const uint32_t mask = 0x000000ff; + uint8_t newtag = (uint8_t)((rkey + 1) & mask); + + return (rkey & ~mask) | newtag; +} + +/** + * ibv_bind_mw - Bind a memory window to a region + */ +static inline int ibv_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw, + struct ibv_mw_bind *mw_bind) +{ + if (mw->type != IBV_MW_TYPE_1) + return EINVAL; + + return mw->context->ops.bind_mw(qp, mw, mw_bind); +} + +/** * ibv_create_comp_channel - Create a completion event channel */ struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);