All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mike Marciniszyn
	<mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Jianxin Xiong
	<jianxin.xiong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 04/28] IB/rdmavt: Add support for ib_map_mr_sg
Date: Mon, 25 Jul 2016 13:38:13 -0700	[thread overview]
Message-ID: <20160725203812.4800.50880.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20160725203554.4800.37248.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>

From: Jianxin Xiong <jianxin.xiong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

This implements the device specific function needed by the verbs
API function ib_map_mr_sg().

Reviewed-by: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Jianxin Xiong <jianxin.xiong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/sw/rdmavt/mr.c |   51 +++++++++++++++++++++++++++++++++++++
 drivers/infiniband/sw/rdmavt/mr.h |    2 +
 drivers/infiniband/sw/rdmavt/vt.c |    7 +++++
 3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c
index 0f4d450..75f158a 100644
--- a/drivers/infiniband/sw/rdmavt/mr.c
+++ b/drivers/infiniband/sw/rdmavt/mr.c
@@ -480,6 +480,57 @@ struct ib_mr *rvt_alloc_mr(struct ib_pd *pd,
 }
 
 /**
+ * rvt_set_page - page assignment function called by ib_sg_to_pages
+ * @ibmr: memory region
+ * @addr: dma address of mapped page
+ *
+ * Return: 0 on success
+ */
+static int rvt_set_page(struct ib_mr *ibmr, u64 addr)
+{
+	struct rvt_mr *mr = to_imr(ibmr);
+	u32 ps = 1 << mr->mr.page_shift;
+	u32 mapped_segs = mr->mr.length >> mr->mr.page_shift;
+	int m, n;
+
+	if (unlikely(mapped_segs == mr->mr.max_segs))
+		return -ENOMEM;
+
+	if (mr->mr.length == 0) {
+		mr->mr.user_base = addr;
+		mr->mr.iova = addr;
+	}
+
+	m = mapped_segs / RVT_SEGSZ;
+	n = mapped_segs % RVT_SEGSZ;
+	mr->mr.map[m]->segs[n].vaddr = (void *)addr;
+	mr->mr.map[m]->segs[n].length = ps;
+	mr->mr.length += ps;
+
+	return 0;
+}
+
+/**
+ * rvt_map_mr_sg - map sg list and set it the memory region
+ * @ibmr: memory region
+ * @sg: dma mapped scatterlist
+ * @sg_nents: number of entries in sg
+ * @sg_offset: offset in bytes into sg
+ *
+ * Return: number of sg elements mapped to the memory region
+ */
+int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
+		  int sg_nents, unsigned int *sg_offset)
+{
+	struct rvt_mr *mr = to_imr(ibmr);
+
+	mr->mr.length = 0;
+	mr->mr.page_shift = PAGE_SHIFT;
+	return ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset,
+			      rvt_set_page);
+}
+
+/**
  * rvt_alloc_fmr - allocate a fast memory region
  * @pd: the protection domain for this memory region
  * @mr_access_flags: access flags for this memory region
diff --git a/drivers/infiniband/sw/rdmavt/mr.h b/drivers/infiniband/sw/rdmavt/mr.h
index 6938051..132800e 100644
--- a/drivers/infiniband/sw/rdmavt/mr.h
+++ b/drivers/infiniband/sw/rdmavt/mr.h
@@ -82,6 +82,8 @@ int rvt_dereg_mr(struct ib_mr *ibmr);
 struct ib_mr *rvt_alloc_mr(struct ib_pd *pd,
 			   enum ib_mr_type mr_type,
 			   u32 max_num_sg);
+int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
+		  int sg_nents, unsigned int *sg_offset);
 struct ib_fmr *rvt_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
 			     struct ib_fmr_attr *fmr_attr);
 int rvt_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index 89fe967..d430c2f 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -370,6 +370,7 @@ enum {
 	REG_USER_MR,
 	DEREG_MR,
 	ALLOC_MR,
+	MAP_MR_SG,
 	ALLOC_FMR,
 	MAP_PHYS_FMR,
 	UNMAP_FMR,
@@ -634,6 +635,12 @@ static noinline int check_support(struct rvt_dev_info *rdi, int verb)
 				      rvt_alloc_mr);
 		break;
 
+	case MAP_MR_SG:
+		check_driver_override(rdi, offsetof(struct ib_device,
+						    map_mr_sg),
+				      rvt_map_mr_sg);
+		break;
+
 	case MAP_PHYS_FMR:
 		check_driver_override(rdi, offsetof(struct ib_device,
 						    map_phys_fmr),

--
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

  parent reply	other threads:[~2016-07-25 20:38 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-25 20:37 [PATCH 00/28] RDMA/hfi1,qib,rdmavt: Second round of fixes for 4.8 Dennis Dalessandro
2016-07-25 20:37 ` Dennis Dalessandro
2016-07-25 20:39 ` [PATCH 13/28] IB/rdmavt: Add missing spin_lock_init call for rdi->n_cqs_lock Dennis Dalessandro
     [not found] ` <20160725203554.4800.37248.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-07-25 20:37   ` [PATCH 01/28] IB/hfi1: Fix integrity errors counter value calculation Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 02/28] IB/hfi1: Fix to fully initialize send context area Dennis Dalessandro
     [not found]     ` <20160725203759.4800.2358.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-07-26  5:26       ` Leon Romanovsky
     [not found]         ` <20160726052657.GD20674-2ukJVAZIZ/Y@public.gmane.org>
2016-07-26 14:18           ` Dalessandro, Dennis
2016-07-28 16:32           ` ira.weiny
     [not found]             ` <20160728163209.GA28030-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org>
2016-07-31  6:53               ` Leon Romanovsky
2016-07-25 20:38   ` [PATCH 03/28] IB/hfi1: Pull FECN/BECN processing to a common place Dennis Dalessandro
2016-07-25 20:38   ` Dennis Dalessandro [this message]
2016-07-25 20:38   ` [PATCH 05/28] IB/rdmavt: Add mechanism to invalidate MR keys Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 06/28] IB/rdmavt: Handle local operations in post send Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 07/28] IB/hfi1: Handle send with invalidate opcode in the RC recv path Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 08/28] IB/hfi1: Work request processing for fast register mr and invalidate Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 09/28] IB/hfi1: Add support for extended memory management Dennis Dalessandro
     [not found]     ` <20160725203842.4800.60710.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2016-07-25 21:24       ` Jason Gunthorpe
     [not found]         ` <20160725212457.GA21162-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-07-25 21:39           ` Dalessandro, Dennis
2016-07-25 20:38   ` [PATCH 10/28] IB/hfi1: Modify the default number of kernel receive conexts Dennis Dalessandro
2016-07-25 20:38   ` [PATCH 11/28] IB/hfi1: Explain state complete frame details Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 12/28] IB/hfi1: Read all firmware versions Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 14/28] IB/hfi1: Fix "suspicious rcu_dereference_check() usage" warnings Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 15/28] IB/hfi1: Add static PCIe Gen3 CTLE tuning Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 16/28] IB/hfi1: Add sysfs entry to override SDMA interrupt affinity Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 17/28] IB/hfi1: Fix trace message units Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 18/28] IB/hfi1: Add the capability for reserved operations Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 19/28] IB/rdmavt, hfi1: Fix NFSoRDMA failure with FRMR enabled Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 20/28] IB/hfi1: Disable external device configuration requests Dennis Dalessandro
2016-07-25 20:39   ` [PATCH 21/28] IB/hfi1: Ignore QSFP interrupts until power stabilizes Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 22/28] IB/hfi1: Reset QSFP on every run through channel tuning Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 23/28] IB/hfi1: Remove unused elements from struct ahg_ib_header Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 24/28] IB/hfi1: Rename struct ahg_ib_header to struct hfi1_ahg_info Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 25/28] IB/hfi1: Rename hfi1_pio_header to hfi1_sdma_header Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 26/28] IB/hfi1: Cleanup UD packet handler Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 27/28] IB/hfi1: Use hdr2sc function to calculate 5-bit SC Dennis Dalessandro
2016-07-25 20:40   ` [PATCH 28/28] IB/qib, IB/hfi1: Fix grh creation in ud loopback Dennis Dalessandro
2016-08-03  2:40   ` [PATCH 00/28] RDMA/hfi1,qib,rdmavt: Second round of fixes for 4.8 Doug Ledford

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=20160725203812.4800.50880.stgit@scvm10.sc.intel.com \
    --to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jianxin.xiong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mike.marciniszyn-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.