From: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
To: jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Cc: sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH RFC] RDMA/core: add rdma_get_dma_mr()
Date: Thu, 25 Jun 2015 16:29:17 -0500 [thread overview]
Message-ID: <20150625212917.14869.66238.stgit@build.ogc.int> (raw)
The semantics for MR access rights are not consistent across RDMA
protocols. So rather than have applications try and glean what they need,
have them pass in the intended roles for the MR to be allocated and let
the RDMA core select the appropriate access rights given the roles and
device capabilities.
This patch is just for reviewing the proposed API for allocating a dma mr
in a transport-independent way. It is uncompiled/untested. If this looks
ok for folks, then I'll incorporate it into the iSER/iWARP series and make
use of it in isert.
Steve.
---
drivers/infiniband/core/verbs.c | 34 ++++++++++++++++++++++++++++++++++
include/rdma/ib_verbs.h | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index bac3fb4..8a365d5 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1144,6 +1144,40 @@ struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
}
EXPORT_SYMBOL(ib_get_dma_mr);
+struct ib_mr *rdma_get_dma_mr(struct ib_pd *pd, int mr_roles)
+{
+ int access_flags = 0;
+ struct ib_mr *mr;
+ int err;
+
+ if (mr_roles & RDMA_MRR_RECV)
+ access_flags |= IB_ACCESS_LOCAL_WRITE;
+
+ if (mr_roles & RDMA_MRR_WRITE_SINK)
+ access_flags |= IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE;
+
+ if (mr_roles & RDMA_MRR_READ_SINK) {
+ access_flags |= IB_ACCESS_LOCAL_WRITE;
+ if (rdma_protocol_iwarp(pd->device, rdma_start_port(pd->device))
+ access_flags |= IB_ACCESS_REMOTE_WRITE;
+ }
+
+ if (mr_roles & RDMA_MRR_ATOMIC)
+ access_flags |= IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_ATOMIC;
+
+ if (mr_roles & RDMA_MRR_MW_BIND)
+ access_flags |= IB_ACCESS_MW_BIND:
+
+ if (mr_roles & RDMA_MRR_ZERO_BASED)
+ access_flags |= IB_ACCESS_ZERO_BASED:
+
+ if (mr_roles & RDMA_MRR_ON_DEMAND)
+ access_flags |= IB_ACCESS_ON_DEMAND:
+
+ return ib_get_dma_mr(pd, access_flags);
+}
+EXPORT_SYMBOL(rdma_get_dma_mr);
+
struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 986fddb..feee869 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2494,7 +2494,43 @@ static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
/**
- * ib_dma_mapping_error - check a DMA addr for error
+ * rdma_mr_roles - possible roles a MR will be used for
+ *
+ * This allows a transport independent RDMA application to
+ * create MRs that are usable for all the desired roles w/o
+ * having to understand which access rights are needed.
+ */
+enum rdma_mr_roles {
+ RDMA_MRR_RECV = 1,
+ RDMA_MRR_SEND = (1<<1),
+ RDMA_MRR_READ_SOURCE = (1<<2),
+ RDMA_MRR_READ_SINK = (1<<3),
+ RDMA_MRR_WRITE_SOURCE = (1<<4),
+ RDMA_MRR_WRITE_SINK = (1<<5),
+ RDMA_MRR_ATOMIC = (1<<6),
+ RDMA_MRR_MW_BIND = (1<<7),
+ RDMA_MRR_ZERO_BASED = (1<<8),
+ RDMA_MRR_ACCESS_ON_DEMAND = (1<<9),
+};
+
+/**
+ * rdma_get_dma_mr - Returns a memory region for system memory that is
+ * usable for DMA.
+ * @pd: The protection domain associated with the memory region.
+ * @mr_roles: Specifies the intended roles of the MR
+ *
+ * Use the intended roles from @mr_roles along with the device
+ * capabilities to define the needed access rights, and call
+ * ib_get_dma_mr() to allocate the MR.
+ *
+ * Note that the ib_dma_*() functions defined below must be used
+ * to create/destroy addresses used with the Lkey or Rkey returned
+ * by ib_get_dma_mr().
+ */
+struct ib_mr *rdma_get_dma_mr(struct ib_pd *pd, int mr_roles);
+
+/**
+ * rdma_dma_mapping_error - check a DMA addr for error
* @dev: The device for which the dma_addr was created
* @dma_addr: The DMA address to check
*/
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2015-06-25 21:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 21:29 Steve Wise [this message]
[not found] ` <20150625212917.14869.66238.stgit-T4OLL4TyM9aNDNWfRnPdfg@public.gmane.org>
2015-06-25 21:39 ` [PATCH RFC] RDMA/core: add rdma_get_dma_mr() Jason Gunthorpe
[not found] ` <20150625213944.GA27780-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-06-25 21:48 ` Steve Wise
2015-06-25 22:37 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373A8FF9ECA-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-06-26 14:02 ` Steve Wise
[not found] ` <558D5B6E.6090900-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
2015-06-26 15:18 ` Steve Wise
2015-06-28 15:44 ` Haggai Eran
2015-06-28 15:47 ` Haggai Eran
[not found] ` <55901703.3050001-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-06-29 13:47 ` Steve Wise
2015-06-29 15:55 ` Jason Gunthorpe
[not found] ` <20150629155503.GA2755-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-06-29 16:08 ` Hefty, Sean
2015-06-28 16:01 ` Haggai Eran
[not found] ` <55901A44.8020103-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-06-29 1:31 ` Hefty, Sean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150625212917.14869.66238.stgit@build.ogc.int \
--to=swise-7bpotxp6k4+p2yhjcf5u+vpxobypeauw@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=roid-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox