1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
3 * Copyright (c) 2007 Cisco Systems. All rights reserved.
9 #include <linux/list.h>
10 #include <linux/scatterlist.h>
11 #include <linux/workqueue.h>
12 #include <rdma/ib_verbs.h>
18 struct ib_device *ibdev;
19 struct mm_struct *owning_mm;
21 unsigned long address;
24 struct work_struct work;
25 struct sg_table sg_head;
27 unsigned int sg_nents;
30 /* Returns the offset of the umem start relative to the first page. */
31 static inline int ib_umem_offset(struct ib_umem *umem)
33 return umem->address & ~PAGE_MASK;
36 static inline size_t ib_umem_num_pages(struct ib_umem *umem)
38 return (ALIGN(umem->address + umem->length, PAGE_SIZE) -
39 ALIGN_DOWN(umem->address, PAGE_SIZE)) >>
43 #ifdef CONFIG_INFINIBAND_USER_MEM
45 struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
46 size_t size, int access);
47 void ib_umem_release(struct ib_umem *umem);
48 int ib_umem_page_count(struct ib_umem *umem);
49 int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
51 unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
52 unsigned long pgsz_bitmap,
55 #else /* CONFIG_INFINIBAND_USER_MEM */
57 #include <linux/err.h>
59 static inline struct ib_umem *ib_umem_get(struct ib_device *device,
60 unsigned long addr, size_t size,
63 return ERR_PTR(-EINVAL);
65 static inline void ib_umem_release(struct ib_umem *umem) { }
66 static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
67 static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
71 static inline int ib_umem_find_best_pgsz(struct ib_umem *umem,
72 unsigned long pgsz_bitmap,
77 #endif /* CONFIG_INFINIBAND_USER_MEM */
79 #endif /* IB_UMEM_H */