From: Anatoly Burakov Date: Wed, 11 Apr 2018 12:30:17 +0000 (+0100) Subject: crypto/dpaa_sec: use virt2memseg instead of iteration X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=29f3c9e55d96cbeebc39a78c0da4d8db560f7d5e;p=dpdk.git crypto/dpaa_sec: use virt2memseg instead of iteration Reduce dependency on internal details of EAL memory subsystem, and simplify code. Signed-off-by: Anatoly Burakov Tested-by: Santosh Shukla Tested-by: Hemant Agrawal Tested-by: Gowrishankar Muthukrishnan --- diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index b04510f417..a14e66948b 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -93,20 +93,11 @@ dpaa_sec_alloc_ctx(dpaa_sec_session *ses) static inline rte_iova_t dpaa_mem_vtop(void *vaddr) { - const struct rte_memseg *memseg = rte_eal_get_physmem_layout(); - uint64_t vaddr_64, paddr; - int i; - - vaddr_64 = (size_t)vaddr; - for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) { - if (vaddr_64 >= memseg[i].addr_64 && - vaddr_64 < memseg[i].addr_64 + memseg[i].len) { - paddr = memseg[i].iova + - (vaddr_64 - memseg[i].addr_64); - - return (rte_iova_t)paddr; - } - } + const struct rte_memseg *ms; + + ms = rte_mem_virt2memseg(vaddr); + if (ms) + return ms->iova + RTE_PTR_DIFF(vaddr, ms->addr); return (size_t)NULL; }