diff --git a/include/spdk/env.h b/include/spdk/env.h index 540e56c16..8aae751aa 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -47,6 +47,8 @@ extern "C" { #include #include +#define SPDK_ENV_SOCKET_ID_ANY (-1) + struct spdk_pci_device; /** @@ -78,7 +80,7 @@ void spdk_free(void *buf); * socket_id and flags. * Return a pointer to the allocated memory address. If the allocation * cannot be done, return NULL. - * Note: to pick any socket id, just set socket_id to -1. + * Note: to pick any socket id, just set socket_id to SPDK_ENV_SOCKET_ID_ANY. */ void *spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags); diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index 69b441375..16ef775fc 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -82,7 +82,13 @@ spdk_free(void *buf) void * spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags) { - const struct rte_memzone *mz = rte_memzone_reserve(name, len, socket_id, flags); + const struct rte_memzone *mz; + + if (socket_id == SPDK_ENV_SOCKET_ID_ANY) { + socket_id = SOCKET_ID_ANY; + } + + mz = rte_memzone_reserve(name, len, socket_id, flags); if (mz != NULL) { memset(mz->addr, 0, len);