#include <rte_memcpy.h>
#include <rte_memory.h>
-#include <rte_memzone.h>
#include <rte_eal.h>
#include <rte_eal_memconfig.h>
#include <rte_branch_prediction.h>
if (size == 0 || (align && !rte_is_power_of_2(align)))
return NULL;
+ if (!rte_eal_has_hugepages())
+ socket_arg = SOCKET_ID_ANY;
+
if (socket_arg == SOCKET_ID_ANY)
socket = malloc_get_numa_socket();
else
return NULL;
ret = malloc_heap_alloc(&mcfg->malloc_heaps[socket], type,
- size, align == 0 ? 1 : align);
+ size, 0, align == 0 ? 1 : align, 0);
if (ret != NULL || socket_arg != SOCKET_ID_ANY)
return ret;
continue;
ret = malloc_heap_alloc(&mcfg->malloc_heaps[i], type,
- size, align == 0 ? 1 : align);
+ size, 0, align == 0 ? 1 : align, 0);
if (ret != NULL)
return ret;
}
void *
rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
{
- void *ptr = rte_malloc_socket(type, size, align, socket);
-
- if (ptr != NULL)
- memset(ptr, 0, size);
- return ptr;
+ return rte_malloc_socket(type, size, align, socket);
}
/*
phys_addr_t
rte_malloc_virt2phy(const void *addr)
{
+ phys_addr_t paddr;
const struct malloc_elem *elem = malloc_elem_from_data(addr);
if (elem == NULL)
- return 0;
- return elem->mz->phys_addr + ((uintptr_t)addr - (uintptr_t)elem->mz->addr);
+ return RTE_BAD_PHYS_ADDR;
+ if (elem->ms->iova == RTE_BAD_IOVA)
+ return RTE_BAD_IOVA;
+
+ if (rte_eal_iova_mode() == RTE_IOVA_VA)
+ paddr = (uintptr_t)addr;
+ else
+ paddr = elem->ms->iova +
+ ((uintptr_t)addr - (uintptr_t)elem->ms->addr);
+ return paddr;
}