env/vtophys: Break vtophys_get_paddr into two functions
This is in preparation for needing to know if the address is in the DPDK memsegs on unregister. Change-Id: Ie2febecae789808ae8ae63ce6889b9bbf3a72aab Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/375248 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
4f4bc79e98
commit
fdc397bc2d
@ -418,8 +418,9 @@ spdk_mem_map_translate(const struct spdk_mem_map *map, uint64_t vaddr)
|
||||
return map_2mb->translation_2mb;
|
||||
}
|
||||
|
||||
/* Try to get the paddr from the DPDK memsegs */
|
||||
static uint64_t
|
||||
vtophys_get_paddr(uint64_t vaddr)
|
||||
vtophys_get_paddr_memseg(uint64_t vaddr)
|
||||
{
|
||||
uintptr_t paddr;
|
||||
struct rte_mem_config *mcfg;
|
||||
@ -442,10 +443,15 @@ vtophys_get_paddr(uint64_t vaddr)
|
||||
}
|
||||
}
|
||||
|
||||
/* The memory is not registered with DPDK. Try to look it up
|
||||
* in /proc/self/pagemap. DPDK provides a utility function
|
||||
* to do this.
|
||||
*/
|
||||
return SPDK_VTOPHYS_ERROR;
|
||||
}
|
||||
|
||||
/* Try to get the paddr from /proc/self/pagemap */
|
||||
static uint64_t
|
||||
vtophys_get_paddr_pagemap(uint64_t vaddr)
|
||||
{
|
||||
uintptr_t paddr;
|
||||
|
||||
paddr = rte_mem_virt2phy((void *)vaddr);
|
||||
if (paddr == 0) {
|
||||
/*
|
||||
@ -460,7 +466,6 @@ vtophys_get_paddr(uint64_t vaddr)
|
||||
return paddr;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("could not find vaddr 0x%" PRIx64 " in DPDK mem config\n", vaddr);
|
||||
return SPDK_VTOPHYS_ERROR;
|
||||
}
|
||||
|
||||
@ -484,13 +489,17 @@ spdk_vtophys_notify(void *cb_ctx, struct spdk_mem_map *map,
|
||||
}
|
||||
|
||||
while (len > 0) {
|
||||
/* Get the physical address from the DPDK memsegs */
|
||||
paddr = vtophys_get_paddr_memseg((uint64_t)vaddr);
|
||||
|
||||
switch (action) {
|
||||
case SPDK_MEM_MAP_NOTIFY_REGISTER:
|
||||
paddr = vtophys_get_paddr((uint64_t)vaddr);
|
||||
|
||||
if (paddr == RTE_BAD_PHYS_ADDR) {
|
||||
DEBUG_PRINT("could not get phys addr for %p\n", vaddr);
|
||||
return -EFAULT;
|
||||
if (paddr == SPDK_VTOPHYS_ERROR) {
|
||||
paddr = vtophys_get_paddr_pagemap((uint64_t)vaddr);
|
||||
if (paddr == SPDK_VTOPHYS_ERROR) {
|
||||
DEBUG_PRINT("could not get phys addr for %p\n", vaddr);
|
||||
return -EFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
if (paddr & MASK_2MB) {
|
||||
|
Loading…
Reference in New Issue
Block a user