summaryrefslogtreecommitdiff
path: root/drivers/bus/fslmc
diff options
context:
space:
mode:
authorAnatoly Burakov <anatoly.burakov@intel.com>2018-04-11 13:30:16 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-04-11 19:54:56 +0200
commit0e41bb3b0046987d8926d9c671899090ec8e8bc0 (patch)
tree221d9e8675136453471bbad6e70eeeb46220d847 /drivers/bus/fslmc
parentf901e64d2102a515f06fd1bbe1a0543f6c073e0c (diff)
downloaddpdk-0e41bb3b0046987d8926d9c671899090ec8e8bc0.zip
dpdk-0e41bb3b0046987d8926d9c671899090ec8e8bc0.tar.gz
dpdk-0e41bb3b0046987d8926d9c671899090ec8e8bc0.tar.xz
bus/fslmc: use virt2memseg instead of iteration
Reduce dependency on internal details of EAL memory subsystem, and simplify code. Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Tested-by: Santosh Shukla <santosh.shukla@caviumnetworks.com> Tested-by: Hemant Agrawal <hemant.agrawal@nxp.com> Tested-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Diffstat (limited to 'drivers/bus/fslmc')
-rw-r--r--drivers/bus/fslmc/portal/dpaa2_hw_pvt.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index d38fc49..45fd41e 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -270,20 +270,14 @@ static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr) __attribute__((unused));
static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr)
{
const struct rte_memseg *memseg;
- int i;
if (dpaa2_virt_mode)
return vaddr;
- memseg = rte_eal_get_physmem_layout();
-
- for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) {
- if (vaddr >= memseg[i].addr_64 &&
- vaddr < memseg[i].addr_64 + memseg[i].len)
- return memseg[i].iova
- + (vaddr - memseg[i].addr_64);
- }
- return (size_t)(NULL);
+ memseg = rte_mem_virt2memseg((void *)(uintptr_t)vaddr);
+ if (memseg)
+ return memseg->phys_addr + RTE_PTR_DIFF(vaddr, memseg->addr);
+ return (size_t)NULL;
}
/**