From patchwork Thu Jul 29 16:32:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tucker X-Patchwork-Id: 115250 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6TGRhUr009336 for ; Thu, 29 Jul 2010 16:32:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757926Ab0G2QcE (ORCPT ); Thu, 29 Jul 2010 12:32:04 -0400 Received: from smtp.opengridcomputing.com ([209.198.142.2]:46346 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754609Ab0G2QcC (ORCPT ); Thu, 29 Jul 2010 12:32:02 -0400 Received: from build.ogc.int (build.ogc.int [10.10.0.2]) by smtp.opengridcomputing.com (Postfix) with ESMTP id 9F19E7C777; Thu, 29 Jul 2010 11:32:02 -0500 (CDT) From: Tom Tucker Subject: [RFC PATCH 3/3] libibverbs: Add reg/unreg I/O memory verbs To: rdreier@cisco.com Cc: linux-rdma@vger.kernel.org, brandt@sandia.gov, tom@ogc.us, swise@ogc.us Date: Thu, 29 Jul 2010 11:32:02 -0500 Message-ID: <20100729163202.14901.44211.stgit@build.ogc.int> In-Reply-To: <20100729163030.14901.87547.stgit@build.ogc.int> References: <20100729163030.14901.87547.stgit@build.ogc.int> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 29 Jul 2010 16:32:05 +0000 (UTC) diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h index 9a81416..37c0ed1 100644 --- a/include/infiniband/driver.h +++ b/include/infiniband/driver.h @@ -82,6 +82,12 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length, size_t cmd_size, struct ibv_reg_mr_resp *resp, size_t resp_size); int ibv_cmd_dereg_mr(struct ibv_mr *mr); +int ibv_cmd_reg_io_mr(struct ibv_pd *pd, void *addr, size_t length, + uint64_t hca_va, int access, + struct ibv_mr *mr, struct ibv_reg_io_mr *cmd, + size_t cmd_size, + struct ibv_reg_io_mr_resp *resp, size_t resp_size); +int ibv_cmd_dereg_io_mr(struct ibv_mr *mr); int ibv_cmd_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector, struct ibv_cq *cq, diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 0f1cb2e..a0d969a 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -640,6 +640,9 @@ struct ibv_context_ops { size_t length, int access); int (*dereg_mr)(struct ibv_mr *mr); + struct ibv_mr * (*reg_io_mr)(struct ibv_pd *pd, void *addr, size_t length, + int access); + int (*dereg_io_mr)(struct ibv_mr *mr); struct ibv_mw * (*alloc_mw)(struct ibv_pd *pd, enum ibv_mw_type type); int (*bind_mw)(struct ibv_qp *qp, struct ibv_mw *mw, struct ibv_mw_bind *mw_bind); @@ -801,6 +804,17 @@ struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, int ibv_dereg_mr(struct ibv_mr *mr); /** + * ibv_reg_io_mr - Register a physical memory region + */ +struct ibv_mr *ibv_reg_io_mr(struct ibv_pd *pd, void *addr, + size_t length, int access); + +/** + * ibv_dereg_io_mr - Deregister a physical memory region + */ +int ibv_dereg_io_mr(struct ibv_mr *mr); + +/** * ibv_create_comp_channel - Create a completion event channel */ struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context); diff --git a/src/verbs.c b/src/verbs.c index ba3c0a4..7d215c1 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -189,6 +189,41 @@ int __ibv_dereg_mr(struct ibv_mr *mr) } default_symver(__ibv_dereg_mr, ibv_dereg_mr); +struct ibv_mr *__ibv_reg_io_mr(struct ibv_pd *pd, void *addr, + size_t length, int access) +{ + struct ibv_mr *mr; + + if (ibv_dontfork_range(addr, length)) + return NULL; + + mr = pd->context->ops.reg_io_mr(pd, addr, length, access); + if (mr) { + mr->context = pd->context; + mr->pd = pd; + mr->addr = addr; + mr->length = length; + } else + ibv_dofork_range(addr, length); + + return mr; +} +default_symver(__ibv_reg_io_mr, ibv_reg_io_mr); + +int __ibv_dereg_io_mr(struct ibv_mr *mr) +{ + int ret; + void *addr = mr->addr; + size_t length = mr->length; + + ret = mr->context->ops.dereg_io_mr(mr); + if (!ret) + ibv_dofork_range(addr, length); + + return ret; +} +default_symver(__ibv_dereg_io_mr, ibv_dereg_io_mr); + static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context) { struct ibv_abi_compat_v2 *t = context->abi_compat;