aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma/ib_umem.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/rdma/ib_umem.h')
-rw-r--r--include/rdma/ib_umem.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index a2bf41e0bde9..2d83cfd7e6ce 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -38,11 +38,12 @@
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39 39
40struct ib_ucontext; 40struct ib_ucontext;
41struct ib_umem_odp;
41 42
42struct ib_umem { 43struct ib_umem {
43 struct ib_ucontext *context; 44 struct ib_ucontext *context;
44 size_t length; 45 size_t length;
45 int offset; 46 unsigned long address;
46 int page_size; 47 int page_size;
47 int writable; 48 int writable;
48 int hugetlb; 49 int hugetlb;
@@ -50,17 +51,43 @@ struct ib_umem {
50 struct pid *pid; 51 struct pid *pid;
51 struct mm_struct *mm; 52 struct mm_struct *mm;
52 unsigned long diff; 53 unsigned long diff;
54 struct ib_umem_odp *odp_data;
53 struct sg_table sg_head; 55 struct sg_table sg_head;
54 int nmap; 56 int nmap;
55 int npages; 57 int npages;
56}; 58};
57 59
60/* Returns the offset of the umem start relative to the first page. */
61static inline int ib_umem_offset(struct ib_umem *umem)
62{
63 return umem->address & ((unsigned long)umem->page_size - 1);
64}
65
66/* Returns the first page of an ODP umem. */
67static inline unsigned long ib_umem_start(struct ib_umem *umem)
68{
69 return umem->address - ib_umem_offset(umem);
70}
71
72/* Returns the address of the page after the last one of an ODP umem. */
73static inline unsigned long ib_umem_end(struct ib_umem *umem)
74{
75 return PAGE_ALIGN(umem->address + umem->length);
76}
77
78static inline size_t ib_umem_num_pages(struct ib_umem *umem)
79{
80 return (ib_umem_end(umem) - ib_umem_start(umem)) >> PAGE_SHIFT;
81}
82
58#ifdef CONFIG_INFINIBAND_USER_MEM 83#ifdef CONFIG_INFINIBAND_USER_MEM
59 84
60struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, 85struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
61 size_t size, int access, int dmasync); 86 size_t size, int access, int dmasync);
62void ib_umem_release(struct ib_umem *umem); 87void ib_umem_release(struct ib_umem *umem);
63int ib_umem_page_count(struct ib_umem *umem); 88int ib_umem_page_count(struct ib_umem *umem);
89int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
90 size_t length);
64 91
65#else /* CONFIG_INFINIBAND_USER_MEM */ 92#else /* CONFIG_INFINIBAND_USER_MEM */
66 93
@@ -73,7 +100,10 @@ static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
73} 100}
74static inline void ib_umem_release(struct ib_umem *umem) { } 101static inline void ib_umem_release(struct ib_umem *umem) { }
75static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; } 102static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
76 103static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
104 size_t length) {
105 return -EINVAL;
106}
77#endif /* CONFIG_INFINIBAND_USER_MEM */ 107#endif /* CONFIG_INFINIBAND_USER_MEM */
78 108
79#endif /* IB_UMEM_H */ 109#endif /* IB_UMEM_H */