crypto/dpaa_sec: use virt2memseg instead of iteration
authorAnatoly Burakov <anatoly.burakov@intel.com>
Wed, 11 Apr 2018 12:30:17 +0000 (13:30 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 11 Apr 2018 17:54:58 +0000 (19:54 +0200)
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>
drivers/crypto/dpaa_sec/dpaa_sec.c

index b04510f..a14e669 100644 (file)
@@ -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;
 }