[PATCH rdma-next 2/6] RDMA/umem: Add ODP type indicator within ib_umem_odp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Erez Alfasi <ereza@xxxxxxxxxxxx>

ODP type can be divided into 2 subclasses:
Explicit and Implicit ODP.

Adding a type enums and an odp type flag within
ib_umem_odp will give us an indication whether a
given MR is ODP implicit/explicit registered.

Signed-off-by: Erez Alfasi <ereza@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/umem.c    |  1 +
 include/rdma/ib_umem_odp.h        | 14 ++++++++++++++
 include/uapi/rdma/ib_user_verbs.h |  5 +++++
 3 files changed, 20 insertions(+)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 08da840ed7ee..04b737739b74 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -236,6 +236,7 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
 		if (!umem)
 			return ERR_PTR(-ENOMEM);
 		umem->is_odp = 1;
+		ib_umem_odp_set_type(to_ib_umem_odp(umem), addr, size);
 	} else {
 		umem = kzalloc(sizeof(*umem), GFP_KERNEL);
 		if (!umem)
diff --git a/include/rdma/ib_umem_odp.h b/include/rdma/ib_umem_odp.h
index 479db5c98ff6..81dc53a2848c 100644
--- a/include/rdma/ib_umem_odp.h
+++ b/include/rdma/ib_umem_odp.h
@@ -67,6 +67,11 @@ struct ib_umem_odp {
 	struct mutex		umem_mutex;
 	void			*private; /* for the HW driver to use. */
 
+	/*
+	 * ODP type indicator e.g. implicit/explicit.
+	 */
+	u8			type;
+
 	int notifiers_seq;
 	int notifiers_count;
 	int npages;
@@ -104,6 +109,15 @@ static inline size_t ib_umem_odp_num_pages(struct ib_umem_odp *umem_odp)
 	       umem_odp->page_shift;
 }
 
+static inline void ib_umem_odp_set_type(struct ib_umem_odp *umem_odp,
+					unsigned long start, size_t end)
+{
+	if (!start && !end)
+		umem_odp->type = IB_ODP_TYPE_IMPLICIT;
+	else
+		umem_odp->type = IB_ODP_TYPE_EXPLICIT;
+}
+
 /*
  * The lower 2 bits of the DMA address signal the R/W permissions for
  * the entry. To upgrade the permissions, provide the appropriate
diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h
index 0474c7400268..42c9bda21f16 100644
--- a/include/uapi/rdma/ib_user_verbs.h
+++ b/include/uapi/rdma/ib_user_verbs.h
@@ -46,6 +46,11 @@
 #define IB_USER_VERBS_ABI_VERSION	6
 #define IB_USER_VERBS_CMD_THRESHOLD    50
 
+enum ib_odp_type {
+	IB_ODP_TYPE_IMPLICIT,
+	IB_ODP_TYPE_EXPLICIT,
+};
+
 enum ib_uverbs_write_cmds {
 	IB_USER_VERBS_CMD_GET_CONTEXT,
 	IB_USER_VERBS_CMD_QUERY_DEVICE,
-- 
2.20.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux