Commit 4c550928 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

env: add a name for special "any socket ID" value



Change-Id: I1f339ee5ff80eee9cf7d6378daa71e2f59c158b2
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 4440cd8d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>

#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);

+7 −1
Original line number Diff line number Diff line
@@ -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);