summaryrefslogtreecommitdiff
path: root/lib/librte_mempool/rte_mempool.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_mempool/rte_mempool.h')
-rw-r--r--lib/librte_mempool/rte_mempool.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index a85341d..2df376e 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -955,16 +955,22 @@ rte_mempool_empty(const struct rte_mempool *mp)
* @return
* The physical address of the elt element.
*/
-static inline phys_addr_t rte_mempool_virt2phy(const struct rte_mempool *mp,
- const void *elt)
+static inline phys_addr_t
+rte_mempool_virt2phy(const struct rte_mempool *mp, const void *elt)
{
- uintptr_t off;
-
- off = (const char *)elt - (const char *)mp;
- return mp->phys_addr + off;
+ if (rte_eal_has_hugepages()) {
+ uintptr_t offset = (const char *)elt - (const char *)mp;
+ return mp->phys_addr + offset;
+ } else {
+ /*
+ * If huge pages are disabled, we cannot assume the
+ * memory region to be physically contiguous.
+ * Lookup for each element.
+ */
+ return rte_mem_virt2phy(elt);
+ }
}
-
/**
* Check the consistency of mempool objects.
*