Spdk/include/spdk/env.h

1249 lines
38 KiB
C
Raw Normal View History

/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* Copyright (c) NetApp, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file
* Encapsulated third-party dependencies
*/
#ifndef SPDK_ENV_H
#define SPDK_ENV_H
#include "spdk/stdinc.h"
#include "spdk/queue.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SPDK_ENV_SOCKET_ID_ANY (-1)
#define SPDK_ENV_LCORE_ID_ANY (UINT32_MAX)
/**
* Memory is dma-safe.
*/
#define SPDK_MALLOC_DMA 0x01
/**
* Memory is sharable across process boundries.
*/
#define SPDK_MALLOC_SHARE 0x02
#define SPDK_MAX_MEMZONE_NAME_LEN 32
#define SPDK_MAX_MEMPOOL_NAME_LEN 29
/**
* Memzone flags
*/
#define SPDK_MEMZONE_NO_IOVA_CONTIG 0x00100000 /**< no iova contiguity */
/**
* \brief Environment initialization options
*/
struct spdk_env_opts {
const char *name;
const char *core_mask;
int shm_id;
int mem_channel;
int master_core;
int mem_size;
bool no_pci;
bool hugepage_single_segments;
bool unlink_hugepage;
size_t num_pci_addr;
const char *hugedir;
struct spdk_pci_addr *pci_blacklist;
struct spdk_pci_addr *pci_whitelist;
/** Opaque context for use of the env implementation. */
void *env_context;
};
/**
* Allocate dma/sharable memory based on a given dma_flg. It is a memory buffer
* with the given size, alignment and socket id.
*
* \param size Size in bytes.
* \param align If non-zero, the allocated buffer is aligned to a multiple of
* align. In this case, it must be a power of two. The returned buffer is always
* aligned to at least cache line size.
* \param phys_addr **Deprecated**. Please use spdk_vtophys() for retrieving physical
* addresses. A pointer to the variable to hold the physical address of
* the allocated buffer is passed. If NULL, the physical address is not returned.
* \param socket_id Socket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY
* for any socket.
* \param flags Combination of SPDK_MALLOC flags (\ref SPDK_MALLOC_DMA, \ref SPDK_MALLOC_SHARE).