env.h File Reference

Encapsulated third-party dependencies. More...

Data Structures

struct  spdk_env_opts
 Environment initialization options. More...
 
struct  spdk_pci_addr
 
struct  spdk_pci_id
 
struct  spdk_pci_device
 
struct  spdk_pci_device::_spdk_pci_device_internal
 
struct  spdk_mem_map_ops
 A function table to be implemented by each memory map. More...
 

Macros

#define SPDK_ENV_SOCKET_ID_ANY   (-1)
 
#define SPDK_ENV_LCORE_ID_ANY   (UINT32_MAX)
 
#define SPDK_MALLOC_DMA   0x01
 Memory is dma-safe.
 
#define SPDK_MALLOC_SHARE   0x02
 Memory is sharable across process boundaries.
 
#define SPDK_MAX_MEMZONE_NAME_LEN   32
 
#define SPDK_MAX_MEMPOOL_NAME_LEN   29
 
#define SPDK_MEMZONE_NO_IOVA_CONTIG   0x00100000
 Memzone flags. More...
 
#define SPDK_MEMPOOL_DEFAULT_CACHE_SIZE   SIZE_MAX
 
#define SPDK_ENV_FOREACH_CORE(i)
 
#define SPDK_VTOPHYS_ERROR   (0xFFFFFFFFFFFFFFFFULL)
 

Typedefs

typedef void() spdk_mempool_obj_cb_t(struct spdk_mempool *mp, void *opaque, void *obj, unsigned obj_idx)
 An object callback function for memory pool. More...
 
typedef int(* thread_start_fn) (void *)
 
typedef int(* spdk_pci_enum_cb) (void *enum_ctx, struct spdk_pci_device *pci_dev)
 
typedef int(* spdk_mem_map_notify_cb) (void *cb_ctx, struct spdk_mem_map *map, enum spdk_mem_map_notify_action action, void *vaddr, size_t size)
 
typedef int(* spdk_mem_map_contiguous_translations) (uint64_t addr_1, uint64_t addr_2)
 

Enumerations

enum  spdk_ring_type { SPDK_RING_TYPE_SP_SC, SPDK_RING_TYPE_MP_SC, SPDK_RING_TYPE_MP_MC }
 
enum  spdk_mem_map_notify_action { SPDK_MEM_MAP_NOTIFY_REGISTER, SPDK_MEM_MAP_NOTIFY_UNREGISTER }
 

Functions

void * spdk_malloc (size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags)
 Allocate dma/sharable memory based on a given dma_flg. More...
 
void * spdk_zmalloc (size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags)
 Allocate dma/sharable memory based on a given dma_flg. More...
 
void * spdk_realloc (void *buf, size_t size, size_t align)
 Resize a dma/sharable memory buffer with the given new size and alignment. More...
 
void spdk_free (void *buf)
 Free buffer memory that was previously allocated with spdk_malloc() or spdk_zmalloc(). More...
 
void spdk_env_opts_init (struct spdk_env_opts *opts)
 Initialize the default value of opts. More...
 
int spdk_env_init (const struct spdk_env_opts *opts)
 Initialize the environment library. More...
 
void spdk_env_fini (void)
 Release any resources of the environment library that were alllocated with spdk_env_init(). More...
 
void * spdk_dma_malloc (size_t size, size_t align, uint64_t *phys_addr)
 Allocate a pinned memory buffer with the given size and alignment. More...
 
void * spdk_dma_malloc_socket (size_t size, size_t align, uint64_t *phys_addr, int socket_id)
 Allocate a pinned, memory buffer with the given size, alignment and socket id. More...
 
void * spdk_dma_zmalloc (size_t size, size_t align, uint64_t *phys_addr)
 Allocate a pinned memory buffer with the given size and alignment. More...
 
void * spdk_dma_zmalloc_socket (size_t size, size_t align, uint64_t *phys_addr, int socket_id)
 Allocate a pinned memory buffer with the given size, alignment and socket id. More...
 
void * spdk_dma_realloc (void *buf, size_t size, size_t align, uint64_t *phys_addr)
 Resize the allocated and pinned memory buffer with the given new size and alignment. More...
 
void spdk_dma_free (void *buf)
 Free a memory buffer previously allocated, for example from spdk_dma_zmalloc(). More...
 
void * spdk_memzone_reserve (const char *name, size_t len, int socket_id, unsigned flags)
 Reserve a named, process shared memory zone with the given size, socket_id and flags. More...
 
void * spdk_memzone_reserve_aligned (const char *name, size_t len, int socket_id, unsigned flags, unsigned align)
 Reserve a named, process shared memory zone with the given size, socket_id, flags and alignment. More...
 
void * spdk_memzone_lookup (const char *name)
 Lookup the memory zone identified by the given name. More...
 
int spdk_memzone_free (const char *name)
 Free the memory zone identified by the given name. More...
 
void spdk_memzone_dump (FILE *f)
 Dump debug information about all memzones. More...
 
struct spdk_mempool * spdk_mempool_create (const char *name, size_t count, size_t ele_size, size_t cache_size, int socket_id)
 Create a thread-safe memory pool. More...
 
struct spdk_mempool * spdk_mempool_create_ctor (const char *name, size_t count, size_t ele_size, size_t cache_size, int socket_id, spdk_mempool_obj_cb_t *obj_init, void *obj_init_arg)
 Create a thread-safe memory pool with user provided initialization function and argument. More...
 
char * spdk_mempool_get_name (struct spdk_mempool *mp)
 Get the name of a memory pool. More...
 
void spdk_mempool_free (struct spdk_mempool *mp)
 Free a memory pool.
 
void * spdk_mempool_get (struct spdk_mempool *mp)
 Get an element from a memory pool. More...
 
int spdk_mempool_get_bulk (struct spdk_mempool *mp, void **ele_arr, size_t count)
 Get multiple elements from a memory pool. More...
 
void spdk_mempool_put (struct spdk_mempool *mp, void *ele)
 Put an element back into the memory pool. More...
 
void spdk_mempool_put_bulk (struct spdk_mempool *mp, void **ele_arr, size_t count)
 Put multiple elements back into the memory pool. More...
 
size_t spdk_mempool_count (const struct spdk_mempool *pool)
 Get the number of entries in the memory pool. More...
 
uint32_t spdk_mempool_obj_iter (struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb, void *obj_cb_arg)
 Iterate through all elements of the pool and call a function on each one. More...
 
struct spdk_mempool * spdk_mempool_lookup (const char *name)
 Lookup the memory pool identified by the given name. More...
 
uint32_t spdk_env_get_core_count (void)
 Get the number of dedicated CPU cores utilized by this env abstraction. More...
 
uint32_t spdk_env_get_current_core (void)
 Get the CPU core index of the current thread. More...
 
uint32_t spdk_env_get_first_core (void)
 Get the index of the first dedicated CPU core for this application. More...
 
uint32_t spdk_env_get_last_core (void)
 Get the index of the last dedicated CPU core for this application. More...
 
uint32_t spdk_env_get_next_core (uint32_t prev_core)
 Get the index of the next dedicated CPU core for this application. More...
 
uint32_t spdk_env_get_socket_id (uint32_t core)
 Get the socket ID for the given core. More...
 
int spdk_env_thread_launch_pinned (uint32_t core, thread_start_fn fn, void *arg)
 Launch a thread pinned to the given core. More...
 
void spdk_env_thread_wait_all (void)
 Wait for all threads to exit before returning.
 
bool spdk_process_is_primary (void)
 Check whether the calling process is primary process. More...
 
uint64_t spdk_get_ticks (void)
 Get a monotonic timestamp counter. More...
 
uint64_t spdk_get_ticks_hz (void)
 Get the tick rate of spdk_get_ticks() per second. More...
 
void spdk_delay_us (unsigned int us)
 Delay the given number of microseconds. More...
 
void spdk_pause (void)
 Pause CPU execution for a short while.
 
struct spdk_ring * spdk_ring_create (enum spdk_ring_type type, size_t count, int socket_id)
 Create a ring. More...
 
void spdk_ring_free (struct spdk_ring *ring)
 Free the ring. More...
 
size_t spdk_ring_count (struct spdk_ring *ring)
 Get the number of objects in the ring. More...
 
size_t spdk_ring_enqueue (struct spdk_ring *ring, void **objs, size_t count, size_t *free_space)
 Queue the array of objects (with length count) on the ring. More...
 
size_t spdk_ring_dequeue (struct spdk_ring *ring, void **objs, size_t count)
 Dequeue count objects from the ring into the array objs. More...
 
bool spdk_iommu_is_enabled (void)
 Reports whether the SPDK application is using the IOMMU for DMA. More...
 
uint64_t spdk_vtophys (void *buf, uint64_t *size)
 Get the physical address of a buffer. More...
 
struct spdk_pci_driver * spdk_pci_nvme_get_driver (void)
 Get the NVMe PCI driver object. More...
 
struct spdk_pci_driver * spdk_pci_vmd_get_driver (void)
 Get the VMD PCI driver object. More...
 
struct spdk_pci_driver * spdk_pci_ioat_get_driver (void)
 Get the I/OAT PCI driver object. More...
 
struct spdk_pci_driver * spdk_pci_idxd_get_driver (void)
 Get the IDXD PCI driver object. More...
 
struct spdk_pci_driver * spdk_pci_virtio_get_driver (void)
 Get the Virtio PCI driver object. More...
 
int spdk_pci_enumerate (struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx)
 Enumerate all PCI devices supported by the provided driver and try to attach those that weren't attached yet. More...
 
struct spdk_pci_devicespdk_pci_get_first_device (void)
 Begin iterating over enumerated PCI device by calling this function to get the first PCI device. More...
 
struct spdk_pci_devicespdk_pci_get_next_device (struct spdk_pci_device *prev)
 Continue iterating over enumerated PCI devices. More...
 
int spdk_pci_device_map_bar (struct spdk_pci_device *dev, uint32_t bar, void **mapped_addr, uint64_t *phys_addr, uint64_t *size)
 Map a PCI BAR in the current process. More...
 
int spdk_pci_device_unmap_bar (struct spdk_pci_device *dev, uint32_t bar, void *mapped_addr)
 Unmap a PCI BAR from the current process. More...
 
uint32_t spdk_pci_device_get_domain (struct spdk_pci_device *dev)
 Get the domain of a PCI device. More...
 
uint8_t spdk_pci_device_get_bus (struct spdk_pci_device *dev)
 Get the bus number of a PCI device. More...
 
uint8_t spdk_pci_device_get_dev (struct spdk_pci_device *dev)
 Get the device number within the PCI bus the device is on. More...
 
uint8_t spdk_pci_device_get_func (struct spdk_pci_device *dev)
 Get the particular function number represented by struct spdk_pci_device. More...
 
struct spdk_pci_addr spdk_pci_device_get_addr (struct spdk_pci_device *dev)
 Get the full DomainBDF address of a PCI device. More...
 
uint16_t spdk_pci_device_get_vendor_id (struct spdk_pci_device *dev)
 Get the vendor ID of a PCI device. More...
 
uint16_t spdk_pci_device_get_device_id (struct spdk_pci_device *dev)
 Get the device ID of a PCI device. More...
 
uint16_t spdk_pci_device_get_subvendor_id (struct spdk_pci_device *dev)
 Get the subvendor ID of a PCI device. More...
 
uint16_t spdk_pci_device_get_subdevice_id (struct spdk_pci_device *dev)
 Get the subdevice ID of a PCI device. More...
 
struct spdk_pci_id spdk_pci_device_get_id (struct spdk_pci_device *dev)
 Get the PCI ID of a PCI device. More...
 
int spdk_pci_device_get_socket_id (struct spdk_pci_device *dev)
 Get the NUMA node the PCI device is on. More...
 
int spdk_pci_device_get_serial_number (struct spdk_pci_device *dev, char *sn, size_t len)
 Serialize the PCIe Device Serial Number into the provided buffer. More...
 
int spdk_pci_device_claim (struct spdk_pci_device *dev)
 Claim a PCI device for exclusive SPDK userspace access. More...
 
void spdk_pci_device_unclaim (struct spdk_pci_device *dev)
 Undo spdk_pci_device_claim(). More...
 
void spdk_pci_device_detach (struct spdk_pci_device *device)
 Release all resources associated with the given device and detach it. More...
 
int spdk_pci_device_attach (struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx, struct spdk_pci_addr *pci_address)
 Attach a PCI device. More...
 
int spdk_pci_device_cfg_read (struct spdk_pci_device *dev, void *buf, uint32_t len, uint32_t offset)
 Read len bytes from the PCI configuration space. More...
 
int spdk_pci_device_cfg_write (struct spdk_pci_device *dev, void *buf, uint32_t len, uint32_t offset)
 Write len bytes into the PCI configuration space. More...
 
int spdk_pci_device_cfg_read8 (struct spdk_pci_device *dev, uint8_t *value, uint32_t offset)
 Read 1 byte from the PCI configuration space. More...
 
int spdk_pci_device_cfg_write8 (struct spdk_pci_device *dev, uint8_t value, uint32_t offset)
 Write 1 byte into the PCI configuration space. More...
 
int spdk_pci_device_cfg_read16 (struct spdk_pci_device *dev, uint16_t *value, uint32_t offset)
 Read 2 bytes from the PCI configuration space. More...
 
int spdk_pci_device_cfg_write16 (struct spdk_pci_device *dev, uint16_t value, uint32_t offset)
 Write 2 bytes into the PCI configuration space. More...
 
int spdk_pci_device_cfg_read32 (struct spdk_pci_device *dev, uint32_t *value, uint32_t offset)
 Read 4 bytes from the PCI configuration space. More...
 
int spdk_pci_device_cfg_write32 (struct spdk_pci_device *dev, uint32_t value, uint32_t offset)
 Write 4 bytes into the PCI configuration space. More...
 
bool spdk_pci_device_is_removed (struct spdk_pci_device *dev)
 Check if device was requested to be removed from the process. More...
 
int spdk_pci_addr_compare (const struct spdk_pci_addr *a1, const struct spdk_pci_addr *a2)
 Compare two PCI addresses. More...
 
int spdk_pci_addr_parse (struct spdk_pci_addr *addr, const char *bdf)
 Convert a string representation of a PCI address into a struct spdk_pci_addr. More...
 
int spdk_pci_addr_fmt (char *bdf, size_t sz, const struct spdk_pci_addr *addr)
 Convert a struct spdk_pci_addr to a string. More...
 
void spdk_pci_hook_device (struct spdk_pci_driver *drv, struct spdk_pci_device *dev)
 Hook a custom PCI device into the PCI layer. More...
 
void spdk_pci_unhook_device (struct spdk_pci_device *dev)
 Un-hook a custom PCI device from the PCI layer. More...
 
const char * spdk_pci_device_get_type (const struct spdk_pci_device *dev)
 Return the type of the PCI device. More...
 
void spdk_unaffinitize_thread (void)
 Remove any CPU affinity from the current thread.
 
void * spdk_call_unaffinitized (void *cb(void *arg), void *arg)
 Call a function with CPU affinity unset. More...
 
struct spdk_mem_map * spdk_mem_map_alloc (uint64_t default_translation, const struct spdk_mem_map_ops *ops, void *cb_ctx)
 Allocate a virtual memory address translation map. More...
 
void spdk_mem_map_free (struct spdk_mem_map **pmap)
 Free a memory map previously allocated by spdk_mem_map_alloc(). More...
 
int spdk_mem_map_set_translation (struct spdk_mem_map *map, uint64_t vaddr, uint64_t size, uint64_t translation)
 Register an address translation for a range of virtual memory. More...
 
int spdk_mem_map_clear_translation (struct spdk_mem_map *map, uint64_t vaddr, uint64_t size)
 Unregister an address translation. More...
 
uint64_t spdk_mem_map_translate (const struct spdk_mem_map *map, uint64_t vaddr, uint64_t *size)
 Look up the translation of a virtual address in a memory map. More...
 
int spdk_mem_register (void *vaddr, size_t len)
 Register the specified memory region for address translation. More...
 
int spdk_mem_unregister (void *vaddr, size_t len)
 Unregister the specified memory region from vtophys address translation. More...
 
int spdk_mem_reserve (void *vaddr, size_t len)
 Reserve the address space specified in all memory maps. More...
 

Detailed Description

Encapsulated third-party dependencies.

Macro Definition Documentation

◆ SPDK_ENV_FOREACH_CORE

#define SPDK_ENV_FOREACH_CORE (   i)
Value:
i < UINT32_MAX; \
uint32_t spdk_env_get_next_core(uint32_t prev_core)
Get the index of the next dedicated CPU core for this application.
uint32_t spdk_env_get_first_core(void)
Get the index of the first dedicated CPU core for this application.

◆ SPDK_MEMZONE_NO_IOVA_CONTIG

#define SPDK_MEMZONE_NO_IOVA_CONTIG   0x00100000

Memzone flags.

no iova contiguity

Typedef Documentation

◆ spdk_mempool_obj_cb_t

typedef void() spdk_mempool_obj_cb_t(struct spdk_mempool *mp, void *opaque, void *obj, unsigned obj_idx)

An object callback function for memory pool.

Used by spdk_mempool_create_ctor().

Function Documentation

◆ spdk_call_unaffinitized()

void* spdk_call_unaffinitized ( void *  cbvoid *arg,
void *  arg 
)

Call a function with CPU affinity unset.

This can be used to run a function that creates other threads without inheriting the calling thread's CPU affinity.

Parameters
cbFunction to call
argParameter to the function cb().
Returns
the return value of cb().

◆ spdk_delay_us()

void spdk_delay_us ( unsigned int  us)

Delay the given number of microseconds.

Parameters
usNumber of microseconds.

◆ spdk_dma_free()

void spdk_dma_free ( void *  buf)

Free a memory buffer previously allocated, for example from spdk_dma_zmalloc().

This call is never made from the performance path.

Parameters
bufBuffer to free.

◆ spdk_dma_malloc()

void* spdk_dma_malloc ( size_t  size,
size_t  align,
uint64_t *  phys_addr 
)

Allocate a pinned memory buffer with the given size and alignment.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrA pointer to the variable to hold the physical address of the allocated buffer is passed. If NULL, the physical address is not returned.
Returns
a pointer to the allocated memory buffer.

◆ spdk_dma_malloc_socket()

void* spdk_dma_malloc_socket ( size_t  size,
size_t  align,
uint64_t *  phys_addr,
int  socket_id 
)

Allocate a pinned, memory buffer with the given size, alignment and socket id.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrA pointer to the variable to hold the physical address of the allocated buffer is passed. If NULL, the physical address is not returned.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
Returns
a pointer to the allocated memory buffer.

◆ spdk_dma_realloc()

void* spdk_dma_realloc ( void *  buf,
size_t  size,
size_t  align,
uint64_t *  phys_addr 
)

Resize the allocated and pinned memory buffer with the given new size and alignment.

Existing contents are preserved.

Parameters
bufBuffer to resize.
sizeSize in bytes.
alignIf 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.
phys_addrA pointer to the variable to hold the physical address of the allocated buffer is passed. If NULL, the physical address is not returned.
Returns
a pointer to the resized memory buffer.

◆ spdk_dma_zmalloc()

void* spdk_dma_zmalloc ( size_t  size,
size_t  align,
uint64_t *  phys_addr 
)

Allocate a pinned memory buffer with the given size and alignment.

The buffer will be zeroed.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrA pointer to the variable to hold the physical address of the allocated buffer is passed. If NULL, the physical address is not returned.
Returns
a pointer to the allocated memory buffer.

◆ spdk_dma_zmalloc_socket()

void* spdk_dma_zmalloc_socket ( size_t  size,
size_t  align,
uint64_t *  phys_addr,
int  socket_id 
)

Allocate a pinned memory buffer with the given size, alignment and socket id.

The buffer will be zeroed.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrA pointer to the variable to hold the physical address of the allocated buffer is passed. If NULL, the physical address is not returned.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
Returns
a pointer to the allocated memory buffer.

◆ spdk_env_fini()

void spdk_env_fini ( void  )

Release any resources of the environment library that were alllocated with spdk_env_init().

After this call, no SPDK env function calls may be made. It is expected that common usage of this function is to call it just before terminating the process.

◆ spdk_env_get_core_count()

uint32_t spdk_env_get_core_count ( void  )

Get the number of dedicated CPU cores utilized by this env abstraction.

Returns
the number of dedicated CPU cores.

◆ spdk_env_get_current_core()

uint32_t spdk_env_get_current_core ( void  )

Get the CPU core index of the current thread.

This will only function when called from threads set up by this environment abstraction. For any other threads SPDK_ENV_LCORE_ID_ANY will be returned.

Returns
the CPU core index of the current thread.

◆ spdk_env_get_first_core()

uint32_t spdk_env_get_first_core ( void  )

Get the index of the first dedicated CPU core for this application.

Returns
the index of the first dedicated CPU core.

◆ spdk_env_get_last_core()

uint32_t spdk_env_get_last_core ( void  )

Get the index of the last dedicated CPU core for this application.

Returns
the index of the last dedicated CPU core.

◆ spdk_env_get_next_core()

uint32_t spdk_env_get_next_core ( uint32_t  prev_core)

Get the index of the next dedicated CPU core for this application.

If there is no next core, return UINT32_MAX.

Parameters
prev_coreIndex of previous core.
Returns
the index of the next dedicated CPU core.

◆ spdk_env_get_socket_id()

uint32_t spdk_env_get_socket_id ( uint32_t  core)

Get the socket ID for the given core.

Parameters
coreCPU core to query.
Returns
the socket ID for the given core.

◆ spdk_env_init()

int spdk_env_init ( const struct spdk_env_opts opts)

Initialize the environment library.

This must be called prior to using any other functions in this library.

Parameters
optsEnvironment initialization options.
Returns
0 on success, or negative errno on failure.

◆ spdk_env_opts_init()

void spdk_env_opts_init ( struct spdk_env_opts opts)

Initialize the default value of opts.

Parameters
optsData structure where SPDK will initialize the default options.

◆ spdk_env_thread_launch_pinned()

int spdk_env_thread_launch_pinned ( uint32_t  core,
thread_start_fn  fn,
void *  arg 
)

Launch a thread pinned to the given core.

Only a single pinned thread may be launched per core. Subsequent attempts to launch pinned threads on that core will fail.

Parameters
coreThe core to pin the thread to.
fnEntry point on the new thread.
argArgument apssed to thread_start_fn
Returns
0 on success, negative errno on failure.

◆ spdk_free()

void spdk_free ( void *  buf)

Free buffer memory that was previously allocated with spdk_malloc() or spdk_zmalloc().

Parameters
bufBuffer to free.

◆ spdk_get_ticks()

uint64_t spdk_get_ticks ( void  )

Get a monotonic timestamp counter.

Returns
the monotonic timestamp counter.

◆ spdk_get_ticks_hz()

uint64_t spdk_get_ticks_hz ( void  )

Get the tick rate of spdk_get_ticks() per second.

Returns
the tick rate of spdk_get_ticks() per second.

◆ spdk_iommu_is_enabled()

bool spdk_iommu_is_enabled ( void  )

Reports whether the SPDK application is using the IOMMU for DMA.

Returns
True if we are using the IOMMU, false otherwise.

◆ spdk_malloc()

void* spdk_malloc ( size_t  size,
size_t  align,
uint64_t *  phys_addr,
int  socket_id,
uint32_t  flags 
)

Allocate dma/sharable memory based on a given dma_flg.

It is a memory buffer with the given size, alignment and socket id.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrDeprecated. 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.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
flagsCombination of SPDK_MALLOC flags (SPDK_MALLOC_DMA, SPDK_MALLOC_SHARE). At least one flag must be specified.
Returns
a pointer to the allocated memory buffer.

◆ spdk_mem_map_alloc()

struct spdk_mem_map* spdk_mem_map_alloc ( uint64_t  default_translation,
const struct spdk_mem_map_ops ops,
void *  cb_ctx 
)

Allocate a virtual memory address translation map.

Parameters
default_translationDefault translation for the map.
opsTable of callback functions for map operations.
cb_ctxArgument passed to the callback function.
Returns
a pointer to the allocated virtual memory address translation map.

◆ spdk_mem_map_clear_translation()

int spdk_mem_map_clear_translation ( struct spdk_mem_map *  map,
uint64_t  vaddr,
uint64_t  size 
)

Unregister an address translation.

Parameters
mapMemory map.
vaddrVirtual address of the region to unregister - must be 2 MB aligned.
sizeSize of the region in bytes - must be multiple of 2 MB in the current implementation.
See also
spdk_mem_map_set_translation().
Returns
0 on success, negative errno on failure.

◆ spdk_mem_map_free()

void spdk_mem_map_free ( struct spdk_mem_map **  pmap)

Free a memory map previously allocated by spdk_mem_map_alloc().

Parameters
pmapMemory map to free.

◆ spdk_mem_map_set_translation()

int spdk_mem_map_set_translation ( struct spdk_mem_map *  map,
uint64_t  vaddr,
uint64_t  size,
uint64_t  translation 
)

Register an address translation for a range of virtual memory.

Parameters
mapMemory map.
vaddrVirtual address of the region to register - must be 2 MB aligned.
sizeSize of the region in bytes - must be multiple of 2 MB in the current implementation.
translationTranslation to store in the map for this address range.
See also
spdk_mem_map_clear_translation().
Returns
0 on success, negative errno on failure.

◆ spdk_mem_map_translate()

uint64_t spdk_mem_map_translate ( const struct spdk_mem_map *  map,
uint64_t  vaddr,
uint64_t *  size 
)

Look up the translation of a virtual address in a memory map.

Parameters
mapMemory map.
vaddrVirtual address.
sizeContains the size of the memory region pointed to by vaddr. If vaddr is successfully translated, then this is updated with the size of the memory region for which the translation is valid.
Returns
the translation of vaddr stored in the map, or default_translation as specified in spdk_mem_map_alloc() if vaddr is not present in the map.

◆ spdk_mem_register()

int spdk_mem_register ( void *  vaddr,
size_t  len 
)

Register the specified memory region for address translation.

The memory region must map to pinned huge pages (2MB or greater).

Parameters
vaddrVirtual address to register.
lenLength in bytes of the vaddr.
Returns
0 on success, negative errno on failure.

◆ spdk_mem_reserve()

int spdk_mem_reserve ( void *  vaddr,
size_t  len 
)

Reserve the address space specified in all memory maps.

This pre-allocates the necessary space in the memory maps such that future calls to spdk_mem_register() on that region require no internal memory allocations.

Parameters
vaddrVirtual address to reserve
lenLength in bytes of vaddr
Returns
0 on success, negated errno on failure.

◆ spdk_mem_unregister()

int spdk_mem_unregister ( void *  vaddr,
size_t  len 
)

Unregister the specified memory region from vtophys address translation.

The caller must ensure all in-flight DMA operations to this memory region are completed or cancelled before calling this function.

Parameters
vaddrVirtual address to unregister.
lenLength in bytes of the vaddr.
Returns
0 on success, negative errno on failure.

◆ spdk_mempool_count()

size_t spdk_mempool_count ( const struct spdk_mempool *  pool)

Get the number of entries in the memory pool.

Parameters
poolMemory pool to query.
Returns
the number of entries in the memory pool.

◆ spdk_mempool_create()

struct spdk_mempool* spdk_mempool_create ( const char *  name,
size_t  count,
size_t  ele_size,
size_t  cache_size,
int  socket_id 
)

Create a thread-safe memory pool.

Parameters
nameName for the memory pool.
countCount of elements.
ele_sizeElement size in bytes.
cache_sizeHow many elements may be cached in per-core caches. Use SPDK_MEMPOOL_DEFAULT_CACHE_SIZE for a reasonable default, or 0 for no per-core cache.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
Returns
a pointer to the created memory pool.

◆ spdk_mempool_create_ctor()

struct spdk_mempool* spdk_mempool_create_ctor ( const char *  name,
size_t  count,
size_t  ele_size,
size_t  cache_size,
int  socket_id,
spdk_mempool_obj_cb_t obj_init,
void *  obj_init_arg 
)

Create a thread-safe memory pool with user provided initialization function and argument.

Parameters
nameName for the memory pool.
countCount of elements.
ele_sizeElement size in bytes.
cache_sizeHow many elements may be cached in per-core caches. Use SPDK_MEMPOOL_DEFAULT_CACHE_SIZE for a reasonable default, or 0 for no per-core cache.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
obj_initUser provided object calllback initialization function.
obj_init_argUser provided callback initialization function argument.
Returns
a pointer to the created memory pool.

◆ spdk_mempool_get()

void* spdk_mempool_get ( struct spdk_mempool *  mp)

Get an element from a memory pool.

If no elements remain, return NULL.

Parameters
mpMemory pool to query.
Returns
a pointer to the element.

◆ spdk_mempool_get_bulk()

int spdk_mempool_get_bulk ( struct spdk_mempool *  mp,
void **  ele_arr,
size_t  count 
)

Get multiple elements from a memory pool.

Parameters
mpMemory pool to get multiple elements from.
ele_arrArray of the elements to fill.
countCount of elements to get.
Returns
0 on success, negative errno on failure.

◆ spdk_mempool_get_name()

char* spdk_mempool_get_name ( struct spdk_mempool *  mp)

Get the name of a memory pool.

Parameters
mpMemory pool to query.
Returns
the name of the memory pool.

◆ spdk_mempool_lookup()

struct spdk_mempool* spdk_mempool_lookup ( const char *  name)

Lookup the memory pool identified by the given name.

Parameters
nameName of the memory pool.
Returns
a pointer to the memory pool on success, or NULL on failure.

◆ spdk_mempool_obj_iter()

uint32_t spdk_mempool_obj_iter ( struct spdk_mempool *  mp,
spdk_mempool_obj_cb_t  obj_cb,
void *  obj_cb_arg 
)

Iterate through all elements of the pool and call a function on each one.

Parameters
mpMemory pool to iterate on.
obj_cbFunction to call on each element.
obj_cb_argOpaque pointer passed to the callback function.
Returns
Number of elements iterated.

◆ spdk_mempool_put()

void spdk_mempool_put ( struct spdk_mempool *  mp,
void *  ele 
)

Put an element back into the memory pool.

Parameters
mpMemory pool to put element back into.
eleElement to put.

◆ spdk_mempool_put_bulk()

void spdk_mempool_put_bulk ( struct spdk_mempool *  mp,
void **  ele_arr,
size_t  count 
)

Put multiple elements back into the memory pool.

Parameters
mpMemory pool to put multiple elements back into.
ele_arrArray of the elements to put.
countCount of elements to put.

◆ spdk_memzone_dump()

void spdk_memzone_dump ( FILE *  f)

Dump debug information about all memzones.

Parameters
fFile to write debug information to.

◆ spdk_memzone_free()

int spdk_memzone_free ( const char *  name)

Free the memory zone identified by the given name.

Returns
0 on success, -1 on failure.

◆ spdk_memzone_lookup()

void* spdk_memzone_lookup ( const char *  name)

Lookup the memory zone identified by the given name.

Parameters
nameName of the memory zone.
Returns
a pointer to the reserved memory address on success, or NULL on failure.

◆ spdk_memzone_reserve()

void* spdk_memzone_reserve ( const char *  name,
size_t  len,
int  socket_id,
unsigned  flags 
)

Reserve a named, process shared memory zone with the given size, socket_id and flags.

Unless SPDK_MEMZONE_NO_IOVA_CONTIG flag is provided, the returned memory will be IOVA contiguous.

Parameters
nameName to set for this memory zone.
lenLength in bytes.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
flagsFlags to set for this memory zone.
Returns
a pointer to the allocated memory address on success, or NULL on failure.

◆ spdk_memzone_reserve_aligned()

void* spdk_memzone_reserve_aligned ( const char *  name,
size_t  len,
int  socket_id,
unsigned  flags,
unsigned  align 
)

Reserve a named, process shared memory zone with the given size, socket_id, flags and alignment.

Unless SPDK_MEMZONE_NO_IOVA_CONTIG flag is provided, the returned memory will be IOVA contiguous.

Parameters
nameName to set for this memory zone.
lenLength in bytes.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
flagsFlags to set for this memory zone.
alignAlignment for resulting memzone. Must be a power of 2.
Returns
a pointer to the allocated memory address on success, or NULL on failure.

◆ spdk_pci_addr_compare()

int spdk_pci_addr_compare ( const struct spdk_pci_addr a1,
const struct spdk_pci_addr a2 
)

Compare two PCI addresses.

Parameters
a1PCI address 1.
a2PCI address 2.
Returns
0 if a1 == a2, less than 0 if a1 < a2, greater than 0 if a1 > a2

◆ spdk_pci_addr_fmt()

int spdk_pci_addr_fmt ( char *  bdf,
size_t  sz,
const struct spdk_pci_addr addr 
)

Convert a struct spdk_pci_addr to a string.

Parameters
bdfString into which a string will be output in the format domain:bus:device.function. The string must be at least 14 characters in size.
szSize of bdf in bytes. Must be at least 14.
addrPCI address.
Returns
0 on success, or a negated errno on failure.

◆ spdk_pci_addr_parse()

int spdk_pci_addr_parse ( struct spdk_pci_addr addr,
const char *  bdf 
)

Convert a string representation of a PCI address into a struct spdk_pci_addr.

Parameters
addrPCI adddress output on success.
bdfPCI address in domain:bus:device.function format or domain.bus.device.function format.
Returns
0 on success, negative errno on failure.

◆ spdk_pci_device_attach()

int spdk_pci_device_attach ( struct spdk_pci_driver *  driver,
spdk_pci_enum_cb  enum_cb,
void *  enum_ctx,
struct spdk_pci_addr pci_address 
)

Attach a PCI device.

This will bypass all blacklist rules and explicitly attach a device at the provided address. The return code of the provided callback will decide whether that device is attached or not. Attached devices have to be manually detached with spdk_pci_device_detach() to be attach-able again.

Parameters
driverDriver for a specific device type. The device will only be attached if it's supported by this driver.
enum_cbCallback to be called for the PCI device once it's found. The return code can be as follows: -1, 1 - an error occurred, fail the attach request entirely 0 - device attached successfully
enum_ctxAdditional context passed to the callback function.
pci_addressAddress of the device to attach.
Returns
-1 if a device at the provided PCI address couldn't be found, -1 if an internal error happened or the provided callback returned non-zero, 0 otherwise

◆ spdk_pci_device_cfg_read()

int spdk_pci_device_cfg_read ( struct spdk_pci_device dev,
void *  buf,
uint32_t  len,
uint32_t  offset 
)

Read len bytes from the PCI configuration space.

Parameters
devPCI device.
bufA buffer to copy the data into.
lenNumber of bytes to read.
offsetOffset (in bytes) in the PCI config space to start reading from.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_read16()

int spdk_pci_device_cfg_read16 ( struct spdk_pci_device dev,
uint16_t *  value,
uint32_t  offset 
)

Read 2 bytes from the PCI configuration space.

Parameters
devPCI device.
valueA buffer to copy the data into.
offsetOffset (in bytes) in the PCI config space to start reading from.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_read32()

int spdk_pci_device_cfg_read32 ( struct spdk_pci_device dev,
uint32_t *  value,
uint32_t  offset 
)

Read 4 bytes from the PCI configuration space.

Parameters
devPCI device.
valueA buffer to copy the data into.
offsetOffset (in bytes) in the PCI config space to start reading from.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_read8()

int spdk_pci_device_cfg_read8 ( struct spdk_pci_device dev,
uint8_t *  value,
uint32_t  offset 
)

Read 1 byte from the PCI configuration space.

Parameters
devPCI device.
valueA buffer to copy the data into.
offsetOffset (in bytes) in the PCI config space to start reading from.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_write()

int spdk_pci_device_cfg_write ( struct spdk_pci_device dev,
void *  buf,
uint32_t  len,
uint32_t  offset 
)

Write len bytes into the PCI configuration space.

Parameters
devPCI device.
bufA buffer to copy the data from.
lenNumber of bytes to write.
offsetOffset (in bytes) in the PCI config space to start writing to.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_write16()

int spdk_pci_device_cfg_write16 ( struct spdk_pci_device dev,
uint16_t  value,
uint32_t  offset 
)

Write 2 bytes into the PCI configuration space.

Parameters
devPCI device.
valueA value to write.
offsetOffset (in bytes) in the PCI config space to start writing to.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_write32()

int spdk_pci_device_cfg_write32 ( struct spdk_pci_device dev,
uint32_t  value,
uint32_t  offset 
)

Write 4 bytes into the PCI configuration space.

Parameters
devPCI device.
valueA value to write.
offsetOffset (in bytes) in the PCI config space to start writing to.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_cfg_write8()

int spdk_pci_device_cfg_write8 ( struct spdk_pci_device dev,
uint8_t  value,
uint32_t  offset 
)

Write 1 byte into the PCI configuration space.

Parameters
devPCI device.
valueA value to write.
offsetOffset (in bytes) in the PCI config space to start writing to.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_claim()

int spdk_pci_device_claim ( struct spdk_pci_device dev)

Claim a PCI device for exclusive SPDK userspace access.

Uses F_SETLK on a shared memory file with the PCI address embedded in its name. As long as this file remains open with the lock acquired, other processes will not be able to successfully call this function on the same PCI device.

The device can be un-claimed by the owning process with spdk_pci_device_unclaim(). It will be also unclaimed automatically when detached.

Parameters
devPCI device to claim.
Returns
-EACCES if the device has already been claimed, negative errno on unexpected errors, 0 on success.

◆ spdk_pci_device_detach()

void spdk_pci_device_detach ( struct spdk_pci_device device)

Release all resources associated with the given device and detach it.

As long as the PCI device is physically available, it will attachable again.

Parameters
devicePCI device.

◆ spdk_pci_device_get_addr()

struct spdk_pci_addr spdk_pci_device_get_addr ( struct spdk_pci_device dev)

Get the full DomainBDF address of a PCI device.

Parameters
devPCI device.
Returns
PCI address.

◆ spdk_pci_device_get_bus()

uint8_t spdk_pci_device_get_bus ( struct spdk_pci_device dev)

Get the bus number of a PCI device.

Parameters
devPCI device.
Returns
PCI bus number.

◆ spdk_pci_device_get_dev()

uint8_t spdk_pci_device_get_dev ( struct spdk_pci_device dev)

Get the device number within the PCI bus the device is on.

Parameters
devPCI device.
Returns
PCI device number.

◆ spdk_pci_device_get_device_id()

uint16_t spdk_pci_device_get_device_id ( struct spdk_pci_device dev)

Get the device ID of a PCI device.

Parameters
devPCI device.
Returns
device ID.

◆ spdk_pci_device_get_domain()

uint32_t spdk_pci_device_get_domain ( struct spdk_pci_device dev)

Get the domain of a PCI device.

Parameters
devPCI device.
Returns
PCI device domain.

◆ spdk_pci_device_get_func()

uint8_t spdk_pci_device_get_func ( struct spdk_pci_device dev)

Get the particular function number represented by struct spdk_pci_device.

Parameters
devPCI device.
Returns
PCI function number.

◆ spdk_pci_device_get_id()

struct spdk_pci_id spdk_pci_device_get_id ( struct spdk_pci_device dev)

Get the PCI ID of a PCI device.

Parameters
devPCI device.
Returns
PCI ID.

◆ spdk_pci_device_get_serial_number()

int spdk_pci_device_get_serial_number ( struct spdk_pci_device dev,
char *  sn,
size_t  len 
)

Serialize the PCIe Device Serial Number into the provided buffer.

The buffer will contain a 16-character-long serial number followed by a NULL terminator.

Parameters
devPCI device.
snBuffer to store the serial number in.
lenLength of buffer. Must be at least 17.
Returns
0 on success, -1 on failure.

◆ spdk_pci_device_get_socket_id()

int spdk_pci_device_get_socket_id ( struct spdk_pci_device dev)

Get the NUMA node the PCI device is on.

Parameters
devPCI device.
Returns
NUMA node index (>= 0).

◆ spdk_pci_device_get_subdevice_id()

uint16_t spdk_pci_device_get_subdevice_id ( struct spdk_pci_device dev)

Get the subdevice ID of a PCI device.

Parameters
devPCI device.
Returns
subdevice ID.

◆ spdk_pci_device_get_subvendor_id()

uint16_t spdk_pci_device_get_subvendor_id ( struct spdk_pci_device dev)

Get the subvendor ID of a PCI device.

Parameters
devPCI device.
Returns
subvendor ID.

◆ spdk_pci_device_get_type()

const char* spdk_pci_device_get_type ( const struct spdk_pci_device dev)

Return the type of the PCI device.

Parameters
devPCI device
Returns
string representing the type of the device

◆ spdk_pci_device_get_vendor_id()

uint16_t spdk_pci_device_get_vendor_id ( struct spdk_pci_device dev)

Get the vendor ID of a PCI device.

Parameters
devPCI device.
Returns
vendor ID.

◆ spdk_pci_device_is_removed()

bool spdk_pci_device_is_removed ( struct spdk_pci_device dev)

Check if device was requested to be removed from the process.

This can be caused either by physical device hotremoval or OS-triggered removal. In the latter case, the device may continue to function properly even if this function returns true . The upper-layer driver may check this function periodically and eventually detach the device.

Parameters
devPCI device.
Returns
if device was requested to be removed

◆ spdk_pci_device_map_bar()

int spdk_pci_device_map_bar ( struct spdk_pci_device dev,
uint32_t  bar,
void **  mapped_addr,
uint64_t *  phys_addr,
uint64_t *  size 
)

Map a PCI BAR in the current process.

Parameters
devPCI device.
barBAR number.
mapped_addrA variable to store the virtual address of the mapping.
phys_addrA variable to store the physical address of the mapping.
sizeA variable to store the size of the bar (in bytes).
Returns
0 on success.

◆ spdk_pci_device_unclaim()

void spdk_pci_device_unclaim ( struct spdk_pci_device dev)

Undo spdk_pci_device_claim().

Parameters
devPCI device to unclaim.

◆ spdk_pci_device_unmap_bar()

int spdk_pci_device_unmap_bar ( struct spdk_pci_device dev,
uint32_t  bar,
void *  mapped_addr 
)

Unmap a PCI BAR from the current process.

This happens automatically when the PCI device is detached.

Parameters
devPCI device.
barBAR number.
mapped_addrVirtual address of the bar.
Returns
0 on success.

◆ spdk_pci_enumerate()

int spdk_pci_enumerate ( struct spdk_pci_driver *  driver,
spdk_pci_enum_cb  enum_cb,
void *  enum_ctx 
)

Enumerate all PCI devices supported by the provided driver and try to attach those that weren't attached yet.

The provided callback will be called for each such device and its return code will decide whether that device is attached or not. Attached devices have to be manually detached with spdk_pci_device_detach() to be attach-able again.

Parameters
driverDriver for a specific device type.
enum_cbCallback to be called for each non-attached PCI device. The return code can be as follows: -1 - device was not attached, the enumeration is stopped 0 - device attached successfully, enumeration continues 1 - device was not attached, enumeration continues
enum_ctxAdditional context passed to the callback function.
Returns
-1 if an internal error occured or the provided callback returned -1, 0 otherwise

◆ spdk_pci_get_first_device()

struct spdk_pci_device* spdk_pci_get_first_device ( void  )

Begin iterating over enumerated PCI device by calling this function to get the first PCI device.

If there no PCI devices enumerated, return NULL

Returns
a pointer to a PCI device on success, NULL otherwise.

◆ spdk_pci_get_next_device()

struct spdk_pci_device* spdk_pci_get_next_device ( struct spdk_pci_device prev)

Continue iterating over enumerated PCI devices.

If no additional PCI devices, return NULL

Parameters
prevPrevious PCI device returned from spdk_pci_get_first_device or spdk_pci_get_next_device
Returns
a pointer to the next PCI device on success, NULL otherwise.

◆ spdk_pci_hook_device()

void spdk_pci_hook_device ( struct spdk_pci_driver *  drv,
struct spdk_pci_device dev 
)

Hook a custom PCI device into the PCI layer.

The device will be attachable, enumerable, and will call provided callbacks on each PCI resource access request.

Parameters
drvdriver that will be able to attach the device
devfully initialized PCI device struct

◆ spdk_pci_idxd_get_driver()

struct spdk_pci_driver* spdk_pci_idxd_get_driver ( void  )

Get the IDXD PCI driver object.

Returns
PCI driver.

◆ spdk_pci_ioat_get_driver()

struct spdk_pci_driver* spdk_pci_ioat_get_driver ( void  )

Get the I/OAT PCI driver object.

Returns
PCI driver.

◆ spdk_pci_nvme_get_driver()

struct spdk_pci_driver* spdk_pci_nvme_get_driver ( void  )

Get the NVMe PCI driver object.

Returns
PCI driver.

◆ spdk_pci_unhook_device()

void spdk_pci_unhook_device ( struct spdk_pci_device dev)

Un-hook a custom PCI device from the PCI layer.

The device must not be attached.

Parameters
devfully initialized PCI device struct

◆ spdk_pci_virtio_get_driver()

struct spdk_pci_driver* spdk_pci_virtio_get_driver ( void  )

Get the Virtio PCI driver object.

Returns
PCI driver.

◆ spdk_pci_vmd_get_driver()

struct spdk_pci_driver* spdk_pci_vmd_get_driver ( void  )

Get the VMD PCI driver object.

Returns
PCI driver.

◆ spdk_process_is_primary()

bool spdk_process_is_primary ( void  )

Check whether the calling process is primary process.

Returns
true if the calling process is primary process, or false otherwise.

◆ spdk_realloc()

void* spdk_realloc ( void *  buf,
size_t  size,
size_t  align 
)

Resize a dma/sharable memory buffer with the given new size and alignment.

Existing contents are preserved.

Parameters
bufBuffer to resize.
sizeSize in bytes.
alignIf 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.
Returns
a pointer to the resized memory buffer.

◆ spdk_ring_count()

size_t spdk_ring_count ( struct spdk_ring *  ring)

Get the number of objects in the ring.

Parameters
ringthe ring.
Returns
the number of objects in the ring.

◆ spdk_ring_create()

struct spdk_ring* spdk_ring_create ( enum spdk_ring_type  type,
size_t  count,
int  socket_id 
)

Create a ring.

Parameters
typeType for the ring. (SPDK_RING_TYPE_SP_SC or SPDK_RING_TYPE_MP_SC).
countSize of the ring in elements.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
Returns
a pointer to the created ring.

◆ spdk_ring_dequeue()

size_t spdk_ring_dequeue ( struct spdk_ring *  ring,
void **  objs,
size_t  count 
)

Dequeue count objects from the ring into the array objs.

Parameters
ringA pointer to the ring.
objsA pointer to the array to be dequeued.
countMaximum number of elements to be dequeued.
Returns
the number of objects dequeued which is less than 'count'.

◆ spdk_ring_enqueue()

size_t spdk_ring_enqueue ( struct spdk_ring *  ring,
void **  objs,
size_t  count,
size_t *  free_space 
)

Queue the array of objects (with length count) on the ring.

Parameters
ringA pointer to the ring.
objsA pointer to the array to be queued.
countLength count of the array of objects.
free_spaceIf non-NULL, amount of free space after the enqueue has finished.
Returns
the number of objects enqueued.

◆ spdk_ring_free()

void spdk_ring_free ( struct spdk_ring *  ring)

Free the ring.

Parameters
ringRing to free.

◆ spdk_vtophys()

uint64_t spdk_vtophys ( void *  buf,
uint64_t *  size 
)

Get the physical address of a buffer.

Parameters
bufA pointer to a buffer.
sizeContains the size of the memory region pointed to by vaddr. If vaddr is successfully translated, then this is updated with the size of the memory region for which the translation is valid.
Returns
the physical address of this buffer on success, or SPDK_VTOPHYS_ERROR on failure.

◆ spdk_zmalloc()

void* spdk_zmalloc ( size_t  size,
size_t  align,
uint64_t *  phys_addr,
int  socket_id,
uint32_t  flags 
)

Allocate dma/sharable memory based on a given dma_flg.

It is a memory buffer with the given size, alignment and socket id. Also, the buffer will be zeroed.

Parameters
sizeSize in bytes.
alignIf 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.
phys_addrDeprecated. 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.
socket_idSocket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
flagsCombination of SPDK_MALLOC flags (SPDK_MALLOC_DMA, SPDK_MALLOC_SHARE).
Returns
a pointer to the allocated memory buffer.