]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/rdma/ib_umem_odp.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
[linux.git] / include / rdma / ib_umem_odp.h
index eeec4e53c4489c890ade19d41652b662bdbe54cb..479db5c98ff60f38fc9148fe3fd8f1632a4c4847 100644 (file)
@@ -76,6 +76,7 @@ struct ib_umem_odp {
 
        struct completion       notifier_completion;
        int                     dying;
+       unsigned int            page_shift;
        struct work_struct      work;
 };
 
@@ -84,6 +85,25 @@ static inline struct ib_umem_odp *to_ib_umem_odp(struct ib_umem *umem)
        return container_of(umem, struct ib_umem_odp, umem);
 }
 
+/* Returns the first page of an ODP umem. */
+static inline unsigned long ib_umem_start(struct ib_umem_odp *umem_odp)
+{
+       return ALIGN_DOWN(umem_odp->umem.address, 1UL << umem_odp->page_shift);
+}
+
+/* Returns the address of the page after the last one of an ODP umem. */
+static inline unsigned long ib_umem_end(struct ib_umem_odp *umem_odp)
+{
+       return ALIGN(umem_odp->umem.address + umem_odp->umem.length,
+                    1UL << umem_odp->page_shift);
+}
+
+static inline size_t ib_umem_odp_num_pages(struct ib_umem_odp *umem_odp)
+{
+       return (ib_umem_end(umem_odp) - ib_umem_start(umem_odp)) >>
+              umem_odp->page_shift;
+}
+
 /*
  * The lower 2 bits of the DMA address signal the R/W permissions for
  * the entry. To upgrade the permissions, provide the appropriate