IB/core: Replace ib_umem's offset field with a full address
[deliverable/linux.git] / include / rdma / ib_umem.h
index a2bf41e0bde969c0ea0090a6af6a11087f51fa2f..7ed6d4ff58dc1ab584b6b2260d655104cda77dd7 100644 (file)
@@ -42,7 +42,7 @@ struct ib_ucontext;
 struct ib_umem {
        struct ib_ucontext     *context;
        size_t                  length;
-       int                     offset;
+       unsigned long           address;
        int                     page_size;
        int                     writable;
        int                     hugetlb;
@@ -55,6 +55,29 @@ struct ib_umem {
        int             npages;
 };
 
+/* Returns the offset of the umem start relative to the first page. */
+static inline int ib_umem_offset(struct ib_umem *umem)
+{
+       return umem->address & ((unsigned long)umem->page_size - 1);
+}
+
+/* Returns the first page of an ODP umem. */
+static inline unsigned long ib_umem_start(struct ib_umem *umem)
+{
+       return umem->address - ib_umem_offset(umem);
+}
+
+/* Returns the address of the page after the last one of an ODP umem. */
+static inline unsigned long ib_umem_end(struct ib_umem *umem)
+{
+       return PAGE_ALIGN(umem->address + umem->length);
+}
+
+static inline size_t ib_umem_num_pages(struct ib_umem *umem)
+{
+       return (ib_umem_end(umem) - ib_umem_start(umem)) >> PAGE_SHIFT;
+}
+
 #ifdef CONFIG_INFINIBAND_USER_MEM
 
 struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
This page took 0.027099 seconds and 5 git commands to generate.