diff options
author | Haggai Eran <haggaie@mellanox.com> | 2014-12-11 10:04:12 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-12-15 21:13:35 -0500 |
commit | 406f9e5fa9a7a60b42e676841e39f2d752266814 (patch) | |
tree | ea6b1776793ed0ae3079d9860132a9e062801b18 /include/rdma | |
parent | 968e78dd96443e2cc963c493070574778805e76a (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.h | 25 |
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; | |||
42 | struct ib_umem { | 42 | struct 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. */ | ||
59 | static 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. */ | ||
65 | static 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. */ | ||
71 | static inline unsigned long ib_umem_end(struct ib_umem *umem) | ||
72 | { | ||
73 | return PAGE_ALIGN(umem->address + umem->length); | ||
74 | } | ||
75 | |||
76 | static 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 | ||
60 | struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | 83 | struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, |