diff --git a/include/spdk/env.h b/include/spdk/env.h index 6b236940c..b22ccf51d 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -49,6 +49,13 @@ extern "C" { struct spdk_pci_device; +/** + * Allocate a pinned, physically contiguous memory buffer with the + * given size and alignment. + */ +void * +spdk_malloc(size_t size, size_t align, uint64_t *phys_addr); + /** * Allocate a pinned, physically contiguous memory buffer with the * given size and alignment. The buffer will be zeroed. diff --git a/lib/env/env.c b/lib/env/env.c index 6772fc958..c9c07d8f3 100644 --- a/lib/env/env.c +++ b/lib/env/env.c @@ -43,14 +43,21 @@ #include void * -spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) +spdk_malloc(size_t size, size_t align, uint64_t *phys_addr) { void *buf = rte_malloc(NULL, size, align); + if (buf && phys_addr) { + *phys_addr = rte_malloc_virt2phy(buf); + } + return buf; +} + +void * +spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) +{ + void *buf = spdk_malloc(size, align, phys_addr); if (buf) { memset(buf, 0, size); - if (phys_addr) { - *phys_addr = rte_malloc_virt2phy(buf); - } } return buf; }