From: Santosh Shukla Date: Fri, 6 Oct 2017 11:03:46 +0000 (+0530) Subject: mem: honor IOVA mode in malloc virt2phy X-Git-Tag: spdx-start~1734 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=72d013644bd64ef35e2657a4525e1642d3c87a27;p=dpdk.git mem: honor IOVA mode in malloc virt2phy Check iova mode and accordingly return phy addr. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob Reviewed-by: Maxime Coquelin Reviewed-by: Anatoly Burakov Tested-by: Hemant Agrawal --- diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c index 5c0627bf44..d65c05a4db 100644 --- a/lib/librte_eal/common/rte_malloc.c +++ b/lib/librte_eal/common/rte_malloc.c @@ -251,10 +251,17 @@ rte_malloc_set_limit(__rte_unused const char *type, phys_addr_t rte_malloc_virt2phy(const void *addr) { + phys_addr_t paddr; const struct malloc_elem *elem = malloc_elem_from_data(addr); if (elem == NULL) return RTE_BAD_PHYS_ADDR; if (elem->ms->phys_addr == RTE_BAD_PHYS_ADDR) return RTE_BAD_PHYS_ADDR; - return elem->ms->phys_addr + ((uintptr_t)addr - (uintptr_t)elem->ms->addr); + + if (rte_eal_iova_mode() == RTE_IOVA_VA) + paddr = (uintptr_t)addr; + else + paddr = elem->ms->phys_addr + + ((uintptr_t)addr - (uintptr_t)elem->ms->addr); + return paddr; }