From patchwork Thu Jul 29 16:36:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tucker X-Patchwork-Id: 115251 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 o6TGRhUu009336 for ; Thu, 29 Jul 2010 16:36:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758027Ab0G2Qgv (ORCPT ); Thu, 29 Jul 2010 12:36:51 -0400 Received: from smtp.opengridcomputing.com ([209.198.142.2]:56506 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754652Ab0G2Qgu (ORCPT ); Thu, 29 Jul 2010 12:36:50 -0400 Received: from build.ogc.int (build.ogc.int [10.10.0.2]) by smtp.opengridcomputing.com (Postfix) with ESMTP id 8A6B97C777; Thu, 29 Jul 2010 11:36:50 -0500 (CDT) From: Tom Tucker Subject: [RFC PATCH] libmthca: Add support for the reg_io_mr verb. 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:36:50 -0500 Message-ID: <20100729163650.15024.66012.stgit@build.ogc.int> In-Reply-To: <20100729163624.15024.57249.stgit@build.ogc.int> References: <20100729163624.15024.57249.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:36:52 +0000 (UTC) diff --git a/src/mthca-abi.h b/src/mthca-abi.h index 4fbd98b..c0145d6 100644 --- a/src/mthca-abi.h +++ b/src/mthca-abi.h @@ -61,6 +61,10 @@ struct mthca_reg_mr { __u32 reserved; }; +struct mthca_reg_io_mr { + struct ibv_reg_io_mr ibv_cmd; +}; + struct mthca_create_cq { struct ibv_create_cq ibv_cmd; __u32 lkey; diff --git a/src/mthca.c b/src/mthca.c index e33bf7f..8892504 100644 --- a/src/mthca.c +++ b/src/mthca.c @@ -113,6 +113,8 @@ static struct ibv_context_ops mthca_ctx_ops = { .dealloc_pd = mthca_free_pd, .reg_mr = mthca_reg_mr, .dereg_mr = mthca_dereg_mr, + .reg_io_mr = mthca_reg_io_mr, + .dereg_io_mr = mthca_dereg_io_mr, .create_cq = mthca_create_cq, .poll_cq = mthca_poll_cq, .resize_cq = mthca_resize_cq, diff --git a/src/mthca.h b/src/mthca.h index bd1e7a2..92a8649 100644 --- a/src/mthca.h +++ b/src/mthca.h @@ -312,6 +312,10 @@ struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access); int mthca_dereg_mr(struct ibv_mr *mr); +struct ibv_mr *mthca_reg_io_mr(struct ibv_pd *pd, void *addr, + size_t length, enum ibv_access_flags access); +int mthca_dereg_io_mr(struct ibv_mr *mr); + struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector); diff --git a/src/verbs.c b/src/verbs.c index b6782c9..3580ad2 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -174,6 +174,56 @@ int mthca_dereg_mr(struct ibv_mr *mr) return 0; } + +static struct ibv_mr *__mthca_reg_io_mr(struct ibv_pd *pd, void *addr, + size_t length, uint64_t hca_va, + enum ibv_access_flags access) +{ + struct ibv_mr *mr; + struct mthca_reg_io_mr cmd; + int ret; + + mr = malloc(sizeof *mr); + if (!mr) + return NULL; + +#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS + { + struct ibv_reg_io_mr_resp resp; + + ret = ibv_cmd_reg_io_mr(pd, addr, length, hca_va, access, mr, + &cmd.ibv_cmd, sizeof cmd, &resp, sizeof resp); + } +#else + ret = ibv_cmd_reg_io_mr(pd, addr, length, hca_va, access, mr, + &cmd.ibv_cmd, sizeof cmd); +#endif + if (ret) { + free(mr); + return NULL; + } + + return mr; +} + +struct ibv_mr *mthca_reg_io_mr(struct ibv_pd *pd, void *addr, + size_t length, enum ibv_access_flags access) +{ + return __mthca_reg_io_mr(pd, addr, length, (uintptr_t) addr, access); +} + +int mthca_dereg_io_mr(struct ibv_mr *mr) +{ + int ret; + + ret = ibv_cmd_dereg_mr(mr); + if (ret) + return ret; + + free(mr); + return 0; +} + static int align_cq_size(int cqe) { int nent;