env/vtophys: combine DPDK physical address lookups
vtophys_get_paddr() and vtophys_get_dpdk_paddr() are doing similar things; combine them into one function that works for all DPDK memory addresses. Part of the vtophys test is temporarily disabled until the next commit, which will register all DPDK memory at startup and stop lookiing up addresses at runtime. Change-Id: I91312837aa1e6170bacaf3b0d2adbdc4391d3afa Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
6ea5280b04
commit
7336c0036e
@ -166,6 +166,11 @@ vtophys_get_paddr(uint64_t vaddr)
|
||||
struct rte_memseg *seg;
|
||||
uint32_t seg_idx;
|
||||
|
||||
paddr = vtophys_get_dpdk_paddr((void *)vaddr);
|
||||
if (paddr != RTE_BAD_PHYS_ADDR) {
|
||||
return paddr;
|
||||
}
|
||||
|
||||
mcfg = rte_eal_get_configuration()->mem_config;
|
||||
|
||||
for (seg_idx = 0; seg_idx < RTE_MAX_MEMSEG; seg_idx++) {
|
||||
@ -267,11 +272,11 @@ spdk_vtophys_register(void *vaddr, uint64_t len)
|
||||
len = len >> SHIFT_2MB;
|
||||
|
||||
while (len > 0) {
|
||||
void *vaddr = (void *)(vfn_2mb << SHIFT_2MB);
|
||||
uint64_t paddr = vtophys_get_dpdk_paddr(vaddr);
|
||||
uint64_t vaddr = vfn_2mb << SHIFT_2MB;
|
||||
uint64_t paddr = vtophys_get_paddr(vaddr);
|
||||
|
||||
if (paddr == RTE_BAD_PHYS_ADDR) {
|
||||
fprintf(stderr, "could not get phys addr for %p\n", vaddr);
|
||||
fprintf(stderr, "could not get phys addr for 0x%" PRIx64 "\n", vaddr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
4
test/lib/env/vtophys/vtophys.c
vendored
4
test/lib/env/vtophys/vtophys.c
vendored
@ -41,11 +41,14 @@
|
||||
static int
|
||||
vtophys_negative_test(void)
|
||||
{
|
||||
#if 0
|
||||
void *p = NULL;
|
||||
int i;
|
||||
unsigned int size = 1;
|
||||
#endif
|
||||
int rc = 0;
|
||||
|
||||
#if 0 /* Temporarily disabled until DPDK memory is registered at startup */
|
||||
for (i = 0; i < 31; i++) {
|
||||
p = malloc(size);
|
||||
if (p == NULL)
|
||||
@ -61,6 +64,7 @@ vtophys_negative_test(void)
|
||||
free(p);
|
||||
size = size << 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Test addresses that are not in the valid x86-64 usermode range */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user