aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorHaggai Eran <haggaie@mellanox.com>2014-12-11 10:04:12 -0500
committerRoland Dreier <roland@purestorage.com>2014-12-15 21:13:35 -0500
commit406f9e5fa9a7a60b42e676841e39f2d752266814 (patch)
treeea6b1776793ed0ae3079d9860132a9e062801b18 /include/rdma
parent968e78dd96443e2cc963c493070574778805e76a (diff)
IB/core: Replace ib_umem's offset field with a full address
In order to allow umems that do not pin memory, we need the umem to keep track of its region's address. This makes the offset field redundant, and so this patch removes it. Signed-off-by: Haggai Eran <haggaie@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_umem.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index a2bf41e0bde9..7ed6d4ff58dc 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -42,7 +42,7 @@ struct ib_ucontext;
42struct ib_umem { 42struct ib_umem {
43 struct ib_ucontext *context; 43 struct ib_ucontext *context;
44 size_t length; 44 size_t length;
45 int offset; 45 unsigned long address;
46 int page_size; 46 int page_size;
47 int writable; 47 int writable;
48 int hugetlb; 48 int hugetlb;
@@ -55,6 +55,29 @@ struct ib_umem {
55 int npages; 55 int npages;
56}; 56};
57 57
58/* Returns the offset of the umem start relative to the first page. */
59static inline int ib_umem_offset(struct ib_umem *umem)
60{
61 return umem->address & ((unsigned long)umem->page_size - 1);
62}
63
64/* Returns the first page of an ODP umem. */
65static inline unsigned long ib_umem_start(struct ib_umem *umem)
66{
67 return umem->address - ib_umem_offset(umem);
68}
69
70/* Returns the address of the page after the last one of an ODP umem. */
71static inline unsigned long ib_umem_end(struct ib_umem *umem)
72{
73 return PAGE_ALIGN(umem->address + umem->length);
74}
75
76static inline size_t ib_umem_num_pages(struct ib_umem *umem)
77{
78 return (ib_umem_end(umem) - ib_umem_start(umem)) >> PAGE_SHIFT;
79}
80
58#ifdef CONFIG_INFINIBAND_USER_MEM 81#ifdef CONFIG_INFINIBAND_USER_MEM
59 82
60struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, 83struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,