From: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Sagi Grimberg <sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Tom Talpey <tom-CLs1Zie5N5HQT0dZR+AlfA@public.gmane.org>,
Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH RFC 1/3] IB/core: Expose a device attribute for rdma_read access flags
Date: Tue, 10 Nov 2015 05:41:47 -0800 [thread overview]
Message-ID: <20151110134147.GA12814@infradead.org> (raw)
In-Reply-To: <20151110130648.GA10682-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
FYI, this is the API I'd aim for (only SRP and no HW driver converted
yet):
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 0e21367..7ea695c 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1484,14 +1484,15 @@ EXPORT_SYMBOL(ib_check_mr_status);
int ib_map_mr_sg(struct ib_mr *mr,
struct scatterlist *sg,
int sg_nents,
- unsigned int page_size)
+ unsigned int page_size,
+ unsigned int flags)
{
if (unlikely(!mr->device->map_mr_sg))
return -ENOSYS;
mr->page_size = page_size;
- return mr->device->map_mr_sg(mr, sg, sg_nents);
+ return mr->device->map_mr_sg(mr, sg, sg_nents, flags);
}
EXPORT_SYMBOL(ib_map_mr_sg);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 62b6cba..d77a5b4 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1314,7 +1314,6 @@ static int srp_map_finish_fr(struct srp_map_state *state,
struct srp_target_port *target = ch->target;
struct srp_device *dev = target->srp_host->srp_dev;
struct ib_send_wr *bad_wr;
- struct ib_reg_wr wr;
struct srp_fr_desc *desc;
u32 rkey;
int n, err;
@@ -1342,20 +1341,17 @@ static int srp_map_finish_fr(struct srp_map_state *state,
ib_update_fast_reg_key(desc->mr, rkey);
n = ib_map_mr_sg(desc->mr, state->sg, state->sg_nents,
- dev->mr_page_size);
+ dev->mr_page_size,
+ /*
+ * XXX: add a bool write argument to this function,
+ * so that we only need to open up the required
+ * permissions.
+ */
+ IB_MR_REMOTE | IB_MR_RDMA_READ | IB_MR_RDMA_WRITE);
if (unlikely(n < 0))
return n;
- wr.wr.next = NULL;
- wr.wr.opcode = IB_WR_REG_MR;
- wr.wr.wr_id = FAST_REG_WR_ID_MASK;
- wr.wr.num_sge = 0;
- wr.wr.send_flags = 0;
- wr.mr = desc->mr;
- wr.key = desc->mr->rkey;
- wr.access = (IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_READ |
- IB_ACCESS_REMOTE_WRITE);
+ desc->mr->wr.wr_id = FAST_REG_WR_ID_MASK;
*state->fr.next++ = desc;
state->nmdesc++;
@@ -1363,7 +1359,7 @@ static int srp_map_finish_fr(struct srp_map_state *state,
srp_map_desc(state, desc->mr->iova,
desc->mr->length, desc->mr->rkey);
- err = ib_post_send(ch->qp, &wr.wr, &bad_wr);
+ err = ib_post_send(ch->qp, &desc->mr->wr, &bad_wr);
if (unlikely(err))
return err;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 83d6ee8..b168b3a 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1105,18 +1105,6 @@ static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr)
return container_of(wr, struct ib_ud_wr, wr);
}
-struct ib_reg_wr {
- struct ib_send_wr wr;
- struct ib_mr *mr;
- u32 key;
- int access;
-};
-
-static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr)
-{
- return container_of(wr, struct ib_reg_wr, wr);
-}
-
struct ib_bind_mw_wr {
struct ib_send_wr wr;
struct ib_mw *mw;
@@ -1314,7 +1302,18 @@ struct ib_qp {
enum ib_qp_type qp_type;
};
+enum ib_mr_flags {
+ /* scope: either remote or local */
+ IB_MR_REMOTE,
+ IB_MR_LOCAL,
+
+ /* direction: one or both can be ORed into the scope above */
+ IB_MR_RDMA_READ = (1 << 10),
+ IB_MR_RDMA_WRITE = (1 << 11)
+};
+
struct ib_mr {
+ struct ib_send_wr wr;
struct ib_device *device;
struct ib_pd *pd;
struct ib_uobject *uobject;
@@ -1326,6 +1325,11 @@ struct ib_mr {
atomic_t usecnt; /* count number of MWs */
};
+static inline struct ib_mr *wr_to_mr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_mr, wr);
+}
+
struct ib_mw {
struct ib_device *device;
struct ib_pd *pd;
@@ -1706,7 +1710,8 @@ struct ib_device {
u32 max_num_sg);
int (*map_mr_sg)(struct ib_mr *mr,
struct scatterlist *sg,
- int sg_nents);
+ int sg_nents,
+ unsigned int flags);
int (*rereg_phys_mr)(struct ib_mr *mr,
int mr_rereg_mask,
struct ib_pd *pd,
@@ -3022,17 +3027,19 @@ struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u8 port,
int ib_map_mr_sg(struct ib_mr *mr,
struct scatterlist *sg,
int sg_nents,
- unsigned int page_size);
+ unsigned int page_size,
+ unsigned int flags);
static inline int
ib_map_mr_sg_zbva(struct ib_mr *mr,
struct scatterlist *sg,
int sg_nents,
- unsigned int page_size)
+ unsigned int page_size,
+ unsigned int flags)
{
int n;
- n = ib_map_mr_sg(mr, sg, sg_nents, page_size);
+ n = ib_map_mr_sg(mr, sg, sg_nents, page_size, flags);
mr->iova = 0;
return n;
--
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 prev parent reply other threads:[~2015-11-10 13:41 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 10:44 [PATCH RFC 0/3] Introduce device attribute rdma_read_access_flags Sagi Grimberg
[not found] ` <1447152255-28231-1-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 10:44 ` [PATCH RFC 1/3] IB/core: Expose a device attribute for rdma_read access flags Sagi Grimberg
[not found] ` <1447152255-28231-2-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 11:25 ` Christoph Hellwig
[not found] ` <20151110112537.GA8991-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 11:36 ` Sagi Grimberg
2015-11-10 11:51 ` Yann Droneaud
[not found] ` <1447156270.7089.3.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
2015-11-10 12:28 ` Sagi Grimberg
[not found] ` <5641E2D1.8070209-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-10 12:39 ` Sagi Grimberg
2015-11-10 12:36 ` Tom Talpey
[not found] ` <5641E4C9.7000206-CLs1Zie5N5HQT0dZR+AlfA@public.gmane.org>
2015-11-10 12:42 ` Sagi Grimberg
[not found] ` <5641E644.7080101-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 13:06 ` Christoph Hellwig
[not found] ` <20151110130648.GA10682-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 13:41 ` Christoph Hellwig [this message]
[not found] ` <20151110134147.GA12814-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 18:36 ` Jason Gunthorpe
[not found] ` <20151110183627.GJ12667-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-11-11 8:03 ` Christoph Hellwig
2015-11-11 9:07 ` Sagi Grimberg
[not found] ` <56430542.5090008-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-11 10:25 ` Christoph Hellwig
2015-11-10 18:06 ` Jason Gunthorpe
2015-11-10 18:01 ` Jason Gunthorpe
[not found] ` <20151110180156.GE12667-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-11-11 8:08 ` Christoph Hellwig
[not found] ` <20151111080837.GA14662-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-11 9:09 ` Sagi Grimberg
[not found] ` <564305AF.3020903-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-11 10:26 ` Christoph Hellwig
2015-11-10 10:44 ` [PATCH RFC 2/3] svcrdma: Use device rdma_read_access_flags Sagi Grimberg
[not found] ` <1447152255-28231-3-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 11:38 ` Christoph Hellwig
[not found] ` <20151110113839.GA32523-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 11:42 ` Sagi Grimberg
2015-11-10 17:03 ` Chuck Lever
2015-11-10 11:41 ` Christoph Hellwig
[not found] ` <20151110114145.GA2810-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 11:46 ` Sagi Grimberg
[not found] ` <5641D920.5000409-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 12:04 ` Christoph Hellwig
[not found] ` <20151110120432.GA8230-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 14:34 ` Chuck Lever
[not found] ` <F60E8BA6-D728-44E4-9331-0C23AB96E634-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-11-10 15:16 ` Tom Talpey
2015-11-10 18:25 ` Jason Gunthorpe
[not found] ` <20151110182546.GI12667-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-11-10 21:00 ` Tom Talpey
[not found] ` <56425AFB.30202-CLs1Zie5N5HQT0dZR+AlfA@public.gmane.org>
2015-11-10 21:17 ` Jason Gunthorpe
[not found] ` <20151110211716.GA21631-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-11-10 21:30 ` Tom Talpey
[not found] ` <564261EF.4000008-CLs1Zie5N5HQT0dZR+AlfA@public.gmane.org>
2015-11-10 23:01 ` Chuck Lever
[not found] ` <54CF0111-E9C4-4196-BF92-7E134A6A329A-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-11-10 23:55 ` Jason Gunthorpe
[not found] ` <20151110235551.GA12795-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-11-11 8:07 ` Christoph Hellwig
2015-11-11 9:28 ` Sagi Grimberg
[not found] ` <56430A20.6040600-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-11 16:19 ` Chuck Lever
[not found] ` <D4228973-6DFA-4181-9848-41BFE8E75200-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-11-11 16:29 ` Sagi Grimberg
[not found] ` <56436CDB.6090305-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-11 20:50 ` Chuck Lever
2015-11-11 9:25 ` Sagi Grimberg
[not found] ` <56430972.8080703-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-11-11 17:39 ` Jason Gunthorpe
2015-11-11 8:02 ` Christoph Hellwig
[not found] ` <20151111080225.GA31508-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-11 17:23 ` Jason Gunthorpe
2015-11-10 16:12 ` Steve Wise
2015-11-10 10:44 ` [PATCH RFC 3/3] RDS_IW: " Sagi Grimberg
[not found] ` <1447152255-28231-4-git-send-email-sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-11-10 11:26 ` Christoph Hellwig
[not found] ` <20151110112638.GB8991-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 11:35 ` Sagi Grimberg
2015-11-10 11:31 ` [PATCH RFC 0/3] Introduce device attribute rdma_read_access_flags Christoph Hellwig
[not found] ` <20151110113141.GA23093-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2015-11-10 11:40 ` Sagi Grimberg
2015-11-10 16:18 ` Steve Wise
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=20151110134147.GA12814@infradead.org \
--to=hch-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sagig-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=tom-CLs1Zie5N5HQT0dZR+AlfA@public.gmane.org \
--cc=ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@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;
as well as URLs for NNTP newsgroup(s).