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_pci_device_provider |
struct | spdk_mem_map_ops |
A function table to be implemented by each memory map. More... | |
struct | spdk_pci_event |
Macros | |
#define | SPDK_ENV_NUMA_ID_ANY (-1) |
#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. | |
#define | SPDK_MEMPOOL_DEFAULT_CACHE_SIZE SIZE_MAX |
#define | SPDK_ENV_FOREACH_CORE(i) |
#define | SPDK_ENV_FOREACH_NUMA_ID(i) |
#define | SPDK_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL) |
#define | SPDK_PCI_DRIVER_NEED_MAPPING 0x0001 |
Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) | |
#define | SPDK_PCI_DRIVER_WC_ACTIVATE 0x0002 |
Device needs PCI BAR mapping with enabled write combining (wc) | |
#define | SPDK_PCI_DEVICE(vend, dev) |
#define | SPDK_PCI_DRIVER_REGISTER(name, id_table, flags) |
#define | SPDK_PCI_REGISTER_DEVICE_PROVIDER(name, provider) |
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. | |
typedef void | spdk_mempool_mem_cb_t(struct spdk_mempool *mp, void *opaque, void *addr, uint64_t iova, size_t len, unsigned mem_idx) |
A memory chunk callback function for memory pool. | |
typedef int(* | thread_start_fn) (void *) |
typedef int(* | spdk_pci_enum_cb) (void *enum_ctx, struct spdk_pci_device *dev) |
Callback for device attach handling. | |
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) |
typedef void(* | spdk_pci_error_handler) (const void *failure_addr, void *ctx) |
Functions | |
SPDK_STATIC_ASSERT (sizeof(struct spdk_env_opts)==128, "Incorrect size") | |
void * | spdk_malloc (size_t size, size_t align, uint64_t *unused, int numa_id, uint32_t flags) |
Allocate dma/sharable memory based on a given dma_flg. | |
void * | spdk_zmalloc (size_t size, size_t align, uint64_t *unused, int numa_id, uint32_t flags) |
Allocate dma/sharable memory based on a given dma_flg. | |
void * | spdk_realloc (void *buf, size_t size, size_t align) |
Resize a dma/sharable memory buffer with the given new size and alignment. | |
void | spdk_free (void *buf) |
Free buffer memory that was previously allocated with spdk_malloc() or spdk_zmalloc(). | |
void | spdk_env_opts_init (struct spdk_env_opts *opts) |
Initialize the default value of opts. | |
int | spdk_env_init (const struct spdk_env_opts *opts) |
Initialize or reinitialize the environment library. | |
void | spdk_env_fini (void) |
Release any resources of the environment library that were allocated with spdk_env_init(). | |
void * | spdk_dma_malloc (size_t size, size_t align, uint64_t *unused) |
Allocate a pinned memory buffer with the given size and alignment. | |
void * | spdk_dma_malloc_socket (size_t size, size_t align, uint64_t *unused, int numa_id) |
Allocate a pinned, memory buffer with the given size, alignment and socket id. | |
void * | spdk_dma_zmalloc (size_t size, size_t align, uint64_t *unused) |
Allocate a pinned memory buffer with the given size and alignment. | |
void * | spdk_dma_zmalloc_socket (size_t size, size_t align, uint64_t *unused, int numa_id) |
Allocate a pinned memory buffer with the given size, alignment and socket id. | |
void * | spdk_dma_realloc (void *buf, size_t size, size_t align, uint64_t *unused) |
Resize the allocated and pinned memory buffer with the given new size and alignment. | |
void | spdk_dma_free (void *buf) |
Free a memory buffer previously allocated, for example from spdk_dma_zmalloc(). | |
void * | spdk_memzone_reserve (const char *name, size_t len, int numa_id, unsigned flags) |
Reserve a named, process shared memory zone with the given size, numa_id and flags. | |
void * | spdk_memzone_reserve_aligned (const char *name, size_t len, int numa_id, unsigned flags, unsigned align) |
Reserve a named, process shared memory zone with the given size, numa_id, flags and alignment. | |
void * | spdk_memzone_lookup (const char *name) |
Lookup the memory zone identified by the given name. | |
int | spdk_memzone_free (const char *name) |
Free the memory zone identified by the given name. | |
void | spdk_memzone_dump (FILE *f) |
Dump debug information about all memzones. | |
struct spdk_mempool * | spdk_mempool_create (const char *name, size_t count, size_t ele_size, size_t cache_size, int numa_id) |
Create a thread-safe memory pool. | |
struct spdk_mempool * | spdk_mempool_create_ctor (const char *name, size_t count, size_t ele_size, size_t cache_size, int numa_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. | |
char * | spdk_mempool_get_name (struct spdk_mempool *mp) |
Get the name of a memory pool. | |
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. | |
int | spdk_mempool_get_bulk (struct spdk_mempool *mp, void **ele_arr, size_t count) |
Get multiple elements from a memory pool. | |
void | spdk_mempool_put (struct spdk_mempool *mp, void *ele) |
Put an element back into the memory pool. | |
void | spdk_mempool_put_bulk (struct spdk_mempool *mp, void **ele_arr, size_t count) |
Put multiple elements back into the memory pool. | |
size_t | spdk_mempool_count (const struct spdk_mempool *pool) |
Get the number of entries in the memory pool. | |
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. | |
uint32_t | spdk_mempool_mem_iter (struct spdk_mempool *mp, spdk_mempool_mem_cb_t mem_cb, void *mem_cb_arg) |
Iterate through all memory chunks of the pool and call a function on each one. | |
struct spdk_mempool * | spdk_mempool_lookup (const char *name) |
Lookup the memory pool identified by the given name. | |
uint32_t | spdk_env_get_core_count (void) |
Get the number of dedicated CPU cores utilized by this env abstraction. | |
uint32_t | spdk_env_get_current_core (void) |
Get the CPU core index of the current thread. | |
uint32_t | spdk_env_get_main_core (void) |
Get the index of the main 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. | |
uint32_t | spdk_env_get_last_core (void) |
Get the index of the last dedicated CPU core for this application. | |
uint32_t | spdk_env_get_next_core (uint32_t prev_core) |
Get the index of the next dedicated CPU core for this application. | |
int32_t | spdk_env_get_numa_id (uint32_t core) |
Get the NUMA node ID for the given core. | |
uint32_t | spdk_env_get_socket_id (uint32_t core) |
Get the NUMA node ID for the given core. | |
int32_t | spdk_env_get_first_numa_id (void) |
Get the ID of the first NUMA node on this system. | |
int32_t | spdk_env_get_last_numa_id (void) |
Get the ID of the last NUMA node on this system. | |
int32_t | spdk_env_get_next_numa_id (int32_t prev_numa_id) |
Get the index of the next NUMA node on this system. | |
void | spdk_env_get_cpuset (struct spdk_cpuset *cpuset) |
Create a cpuset with each dedicated core's bit set to true. | |
bool | spdk_env_core_get_smt_cpuset (struct spdk_cpuset *cpuset, uint32_t core) |
Create a cpuset with each SMT sibling core's bit set to true. | |
int | spdk_env_thread_launch_pinned (uint32_t core, thread_start_fn fn, void *arg) |
Launch a thread pinned to the given core. | |
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. | |
uint64_t | spdk_get_ticks (void) |
Get a monotonic timestamp counter. | |
uint64_t | spdk_get_ticks_hz (void) |
Get the tick rate of spdk_get_ticks() per second. | |
void | spdk_delay_us (unsigned int us) |
Delay the given number of microseconds. | |
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 numa_id) |
Create a ring. | |
void | spdk_ring_free (struct spdk_ring *ring) |
Free the ring. | |
size_t | spdk_ring_count (struct spdk_ring *ring) |
Get the number of objects in the ring. | |
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. | |
size_t | spdk_ring_dequeue (struct spdk_ring *ring, void **objs, size_t count) |
Dequeue count objects from the ring into the array objs. | |
bool | spdk_iommu_is_enabled (void) |
Reports whether the SPDK application is using the IOMMU for DMA. | |
uint64_t | spdk_vtophys (const void *buf, uint64_t *size) |
Get the physical address of a buffer. | |
void | spdk_pci_driver_register (const char *name, struct spdk_pci_id *id_table, uint32_t flags) |
struct spdk_pci_driver * | spdk_pci_vmd_get_driver (void) |
Get the VMD PCI driver object. | |
struct spdk_pci_driver * | spdk_pci_ioat_get_driver (void) |
Get the I/OAT PCI driver object. | |
struct spdk_pci_driver * | spdk_pci_idxd_get_driver (void) |
Get the IDXD PCI driver object. | |
struct spdk_pci_driver * | spdk_pci_virtio_get_driver (void) |
Get the Virtio PCI driver object. | |
struct spdk_pci_driver * | spdk_pci_get_driver (const char *name) |
Get PCI driver by name (e.g. | |
struct spdk_pci_driver * | spdk_pci_nvme_get_driver (void) |
Get the NVMe PCI driver object. | |
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. | |
void | spdk_pci_for_each_device (void *ctx, void(*fn)(void *ctx, struct spdk_pci_device *dev)) |
Call the provided function pointer for every enumerated PCI device. | |
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. | |
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. | |
int | spdk_pci_device_enable_interrupt (struct spdk_pci_device *dev) |
Enable PCI device interrupts. | |
int | spdk_pci_device_disable_interrupt (struct spdk_pci_device *dev) |
Disable PCI device interrupts. | |
int | spdk_pci_device_get_interrupt_efd (struct spdk_pci_device *dev) |
Get an event file descriptor associated with a PCI device interrupt. | |
int | spdk_pci_device_enable_interrupts (struct spdk_pci_device *dev, uint32_t efd_count) |
Enable PCI device interrupts, only if VFIO MSI-X is supported. | |
int | spdk_pci_device_disable_interrupts (struct spdk_pci_device *dev) |
Disable PCI device interrupts. | |
int | spdk_pci_device_get_interrupt_efd_by_index (struct spdk_pci_device *dev, uint32_t index) |
Get an event file descriptor associated with a PCI device, for a particular MSI-X index. | |
uint32_t | spdk_pci_device_get_domain (struct spdk_pci_device *dev) |
Get the domain of a PCI device. | |
uint8_t | spdk_pci_device_get_bus (struct spdk_pci_device *dev) |
Get the bus number of a PCI device. | |
uint8_t | spdk_pci_device_get_dev (struct spdk_pci_device *dev) |
Get the device number within the PCI bus the device is on. | |
uint8_t | spdk_pci_device_get_func (struct spdk_pci_device *dev) |
Get the particular function number represented by struct spdk_pci_device. | |
struct spdk_pci_addr | spdk_pci_device_get_addr (struct spdk_pci_device *dev) |
Get the full DomainBDF address of a PCI device. | |
uint16_t | spdk_pci_device_get_vendor_id (struct spdk_pci_device *dev) |
Get the vendor ID of a PCI device. | |
uint16_t | spdk_pci_device_get_device_id (struct spdk_pci_device *dev) |
Get the device ID of a PCI device. | |
uint16_t | spdk_pci_device_get_subvendor_id (struct spdk_pci_device *dev) |
Get the subvendor ID of a PCI device. | |
uint16_t | spdk_pci_device_get_subdevice_id (struct spdk_pci_device *dev) |
Get the subdevice ID of a PCI device. | |
struct spdk_pci_id | spdk_pci_device_get_id (struct spdk_pci_device *dev) |
Get the PCI ID of a PCI device. | |
int | spdk_pci_device_get_numa_id (struct spdk_pci_device *dev) |
Get the NUMA node the PCI device is on. | |
int | spdk_pci_device_get_socket_id (struct spdk_pci_device *dev) |
Get the NUMA node the PCI device is on. | |
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. | |
int | spdk_pci_device_claim (struct spdk_pci_device *dev) |
Claim a PCI device for exclusive SPDK userspace access. | |
void | spdk_pci_device_unclaim (struct spdk_pci_device *dev) |
Undo spdk_pci_device_claim(). | |
void | spdk_pci_device_detach (struct spdk_pci_device *device) |
Release all resources associated with the given device and detach it. | |
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. | |
int | spdk_pci_device_allow (struct spdk_pci_addr *pci_addr) |
Allow the specified PCI device to be probed by the calling process. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
bool | spdk_pci_device_is_removed (struct spdk_pci_device *dev) |
Check if device was requested to be removed from the process. | |
int | spdk_pci_addr_compare (const struct spdk_pci_addr *a1, const struct spdk_pci_addr *a2) |
Compare two PCI addresses. | |
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. | |
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. | |
int | spdk_pci_hook_device (struct spdk_pci_driver *drv, struct spdk_pci_device *dev) |
Hook a custom PCI device into the PCI layer. | |
void | spdk_pci_unhook_device (struct spdk_pci_device *dev) |
Un-hook a custom PCI device from the PCI layer. | |
const char * | spdk_pci_device_get_type (const struct spdk_pci_device *dev) |
Return the type of the PCI device. | |
void | spdk_pci_register_device_provider (struct spdk_pci_device_provider *provider) |
Register a PCI device provdier. | |
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. | |
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. | |
void | spdk_mem_map_free (struct spdk_mem_map **pmap) |
Free a memory map previously allocated by spdk_mem_map_alloc(). | |
uint64_t | spdk_mem_map_get_page_size (void) |
Get the currently using page size for memory mapping. | |
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. | |
int | spdk_mem_map_clear_translation (struct spdk_mem_map *map, uint64_t vaddr, uint64_t size) |
Unregister an address translation. | |
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. | |
int | spdk_mem_register (void *vaddr, size_t len) |
Register the specified memory region for address translation. | |
int | spdk_mem_unregister (void *vaddr, size_t len) |
Unregister the specified memory region from vtophys address translation. | |
int | spdk_mem_reserve (void *vaddr, size_t len) |
Reserve the address space specified in all memory maps. | |
int32_t | spdk_mem_get_numa_id (const void *buf, uint64_t *size) |
Get the NUMA node ID for the specified memory buffer. | |
int | spdk_mem_get_fd_and_offset (void *vaddr, uint64_t *offset) |
Get the address's file descriptor and offset, it works with spdk memory allocation APIs. | |
int | spdk_pci_event_listen (void) |
Begin listening for PCI bus events. | |
int | spdk_pci_get_event (int fd, struct spdk_pci_event *event) |
Get the next PCI bus event. | |
int | spdk_pci_register_error_handler (spdk_pci_error_handler sighandler, void *ctx) |
Register a signal handler to handle bus errors on the PCI bus. | |
void | spdk_pci_unregister_error_handler (spdk_pci_error_handler sighandler) |
Register a signal handler to handle bus errors on the PCI bus. | |
int | spdk_get_tid (void) |
Get the tid of the current thread. | |
Encapsulated third-party dependencies.
#define SPDK_ENV_FOREACH_CORE | ( | i | ) |
#define SPDK_ENV_FOREACH_NUMA_ID | ( | i | ) |
#define SPDK_MEMZONE_NO_IOVA_CONTIG 0x00100000 |
Memzone flags.
no iova contiguity
#define SPDK_PCI_DEVICE | ( | vend, | |
dev ) |
#define SPDK_PCI_DRIVER_REGISTER | ( | name, | |
id_table, | |||
flags ) |
#define SPDK_PCI_REGISTER_DEVICE_PROVIDER | ( | name, | |
provider ) |
typedef void spdk_mempool_mem_cb_t(struct spdk_mempool *mp, void *opaque, void *addr, uint64_t iova, size_t len, unsigned mem_idx) |
A memory chunk callback function for memory pool.
Used by spdk_mempool_mem_iter().
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().
typedef int(* spdk_pci_enum_cb) (void *enum_ctx, struct spdk_pci_device *dev) |
Callback for device attach handling.
enum_ctx | Opaque value. |
dev | PCI device. |
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.
cb | Function to call |
arg | Parameter to the function cb(). |
void spdk_delay_us | ( | unsigned int | us | ) |
Delay the given number of microseconds.
us | Number of microseconds. |
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.
buf | Buffer to free. |
void * spdk_dma_malloc | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused ) |
Allocate a pinned memory buffer with the given size and alignment.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
void * spdk_dma_malloc_socket | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused, | ||
int | numa_id ) |
Allocate a pinned, memory buffer with the given size, alignment and socket id.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
void * spdk_dma_realloc | ( | void * | buf, |
size_t | size, | ||
size_t | align, | ||
uint64_t * | unused ) |
Resize the allocated and pinned memory buffer with the given new size and alignment.
Existing contents are preserved.
buf | Buffer to resize. |
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
void * spdk_dma_zmalloc | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused ) |
Allocate a pinned memory buffer with the given size and alignment.
The buffer will be zeroed.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
void * spdk_dma_zmalloc_socket | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused, | ||
int | numa_id ) |
Allocate a pinned memory buffer with the given size, alignment and socket id.
The buffer will be zeroed.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
bool spdk_env_core_get_smt_cpuset | ( | struct spdk_cpuset * | cpuset, |
uint32_t | core ) |
Create a cpuset with each SMT sibling core's bit set to true.
This function will first zero the cpuset and then set the bit for each SMT sibling core to true.
If the specified core has no SMT siblings, then only the specified core's bit will be set.
If the specified core has SMT siblings, then all of the siblings, including the specified core, will be set. Note: this will set bits for all siblings, even ones not part of the application's core mask.
If the specified core is UINT32_MAX, then bits will be set for all SMT siblings of all cores in the application's core mask.
cpuset | spdk_cpuset for SMT sibling cores |
core | core to get siblings for (UINT32_MAX for all cores in app core mask) |
void spdk_env_fini | ( | void | ) |
Release any resources of the environment library that were allocated 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 or before reinitializing the environment library within the same process.
uint32_t spdk_env_get_core_count | ( | void | ) |
Get the number of dedicated CPU cores utilized by this env abstraction.
void spdk_env_get_cpuset | ( | struct spdk_cpuset * | cpuset | ) |
Create a cpuset with each dedicated core's bit set to true.
This function will first zero the cpuset and then set the bit for each core dedicated to this application to true.
cpuset | spdk_cpuset to initialize |
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.
uint32_t spdk_env_get_first_core | ( | void | ) |
Get the index of the first dedicated CPU core for this application.
int32_t spdk_env_get_first_numa_id | ( | void | ) |
Get the ID of the first NUMA node on this system.
uint32_t spdk_env_get_last_core | ( | void | ) |
Get the index of the last dedicated CPU core for this application.
int32_t spdk_env_get_last_numa_id | ( | void | ) |
Get the ID of the last NUMA node on this system.
uint32_t spdk_env_get_main_core | ( | void | ) |
Get the index of the main dedicated CPU core for this application.
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.
prev_core | Index of previous core. |
int32_t spdk_env_get_next_numa_id | ( | int32_t | prev_numa_id | ) |
Get the index of the next NUMA node on this system.
If there is no next NUMA ID, or the passed prev_numa_id is not a valid NUMA ID, return INT32_MAX.
prev_numa_id | Index of previous NUMA ID. |
int32_t spdk_env_get_numa_id | ( | uint32_t | core | ) |
Get the NUMA node ID for the given core.
core | CPU core to query. |
uint32_t spdk_env_get_socket_id | ( | uint32_t | core | ) |
Get the NUMA node ID for the given core.
Deprecated, use spdk_env_get_numa_id() instead.
core | CPU core to query. |
int spdk_env_init | ( | const struct spdk_env_opts * | opts | ) |
Initialize or reinitialize the environment library.
For initialization, this must be called prior to using any other functions in this library. For reinitialization, the parameter opts
must be set to NULL and this must be called after the environment library was finished by spdk_env_fini() within the same process.
opts | Environment initialization options. |
void spdk_env_opts_init | ( | struct spdk_env_opts * | opts | ) |
Initialize the default value of opts.
opts | Data structure where SPDK will initialize the default options. |
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.
core | The core to pin the thread to. |
fn | Entry point on the new thread. |
arg | Argument passed to thread_start_fn |
void spdk_free | ( | void * | buf | ) |
Free buffer memory that was previously allocated with spdk_malloc() or spdk_zmalloc().
buf | Buffer to free. |
uint64_t spdk_get_ticks | ( | void | ) |
Get a monotonic timestamp counter.
uint64_t spdk_get_ticks_hz | ( | void | ) |
Get the tick rate of spdk_get_ticks() per second.
bool spdk_iommu_is_enabled | ( | void | ) |
Reports whether the SPDK application is using the IOMMU for DMA.
void * spdk_malloc | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused, | ||
int | numa_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.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
flags | Combination of SPDK_MALLOC flags (SPDK_MALLOC_DMA, SPDK_MALLOC_SHARE). At least one flag must be specified. |
int spdk_mem_get_fd_and_offset | ( | void * | vaddr, |
uint64_t * | offset ) |
Get the address's file descriptor and offset, it works with spdk memory allocation APIs.
vaddr | Virtual address to get |
offset | Virtual address's map offset to the file descriptor |
int32_t spdk_mem_get_numa_id | ( | const void * | buf, |
uint64_t * | size ) |
Get the NUMA node ID for the specified memory buffer.
Note: this only works for memory allocated via the environment layer.
buf | A pointer to a buffer. |
size | Contains 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. |
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.
default_translation | Default translation for the map. |
ops | Table of callback functions for map operations. |
cb_ctx | Argument passed to the callback function. |
int spdk_mem_map_clear_translation | ( | struct spdk_mem_map * | map, |
uint64_t | vaddr, | ||
uint64_t | size ) |
Unregister an address translation.
map | Memory map. |
vaddr | Virtual address of the region to unregister - must be page size aligned. |
size | Size of the region in bytes - must be multiple of page size in the current implementation. |
void spdk_mem_map_free | ( | struct spdk_mem_map ** | pmap | ) |
Free a memory map previously allocated by spdk_mem_map_alloc().
pmap | Memory map to free. |
uint64_t spdk_mem_map_get_page_size | ( | void | ) |
Get the currently using page size for memory mapping.
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.
map | Memory map. |
vaddr | Virtual address of the region to register - must be page size aligned. |
size | Size of the region in bytes - must be multiple of page size in the current implementation. |
translation | Translation to store in the map for this address range. |
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.
map | Memory map. |
vaddr | Virtual address. |
size | Contains 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. |
int spdk_mem_register | ( | void * | vaddr, |
size_t | len ) |
Register the specified memory region for address translation.
vaddr | Virtual address to register. |
len | Length in bytes of the vaddr. |
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.
vaddr | Virtual address to reserve |
len | Length in bytes of vaddr |
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.
vaddr | Virtual address to unregister. |
len | Length in bytes of the vaddr. |
size_t spdk_mempool_count | ( | const struct spdk_mempool * | pool | ) |
Get the number of entries in the memory pool.
pool | Memory pool to query. |
struct spdk_mempool * spdk_mempool_create | ( | const char * | name, |
size_t | count, | ||
size_t | ele_size, | ||
size_t | cache_size, | ||
int | numa_id ) |
Create a thread-safe memory pool.
name | Name for the memory pool. |
count | Count of elements. |
ele_size | Element size in bytes. |
cache_size | How 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. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
struct spdk_mempool * spdk_mempool_create_ctor | ( | const char * | name, |
size_t | count, | ||
size_t | ele_size, | ||
size_t | cache_size, | ||
int | numa_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.
name | Name for the memory pool. |
count | Count of elements. |
ele_size | Element size in bytes. |
cache_size | How 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. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
obj_init | User provided object callback initialization function. |
obj_init_arg | User provided callback initialization function argument. |
void * spdk_mempool_get | ( | struct spdk_mempool * | mp | ) |
Get an element from a memory pool.
If no elements remain, return NULL.
mp | Memory pool to query. |
int spdk_mempool_get_bulk | ( | struct spdk_mempool * | mp, |
void ** | ele_arr, | ||
size_t | count ) |
Get multiple elements from a memory pool.
mp | Memory pool to get multiple elements from. |
ele_arr | Array of the elements to fill. |
count | Count of elements to get. |
char * spdk_mempool_get_name | ( | struct spdk_mempool * | mp | ) |
Get the name of a memory pool.
mp | Memory pool to query. |
struct spdk_mempool * spdk_mempool_lookup | ( | const char * | name | ) |
Lookup the memory pool identified by the given name.
name | Name of the memory pool. |
uint32_t spdk_mempool_mem_iter | ( | struct spdk_mempool * | mp, |
spdk_mempool_mem_cb_t | mem_cb, | ||
void * | mem_cb_arg ) |
Iterate through all memory chunks of the pool and call a function on each one.
mp | Memory pool to iterate on. |
mem_cb | Function to call on each memory chunk. |
mem_cb_arg | Opaque pointer passed to the callback function. |
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.
mp | Memory pool to iterate on. |
obj_cb | Function to call on each element. |
obj_cb_arg | Opaque pointer passed to the callback function. |
void spdk_mempool_put | ( | struct spdk_mempool * | mp, |
void * | ele ) |
Put an element back into the memory pool.
mp | Memory pool to put element back into. |
ele | Element to put. |
void spdk_mempool_put_bulk | ( | struct spdk_mempool * | mp, |
void ** | ele_arr, | ||
size_t | count ) |
Put multiple elements back into the memory pool.
mp | Memory pool to put multiple elements back into. |
ele_arr | Array of the elements to put. |
count | Count of elements to put. |
void spdk_memzone_dump | ( | FILE * | f | ) |
Dump debug information about all memzones.
f | File to write debug information to. |
int spdk_memzone_free | ( | const char * | name | ) |
Free the memory zone identified by the given name.
void * spdk_memzone_lookup | ( | const char * | name | ) |
Lookup the memory zone identified by the given name.
name | Name of the memory zone. |
void * spdk_memzone_reserve | ( | const char * | name, |
size_t | len, | ||
int | numa_id, | ||
unsigned | flags ) |
Reserve a named, process shared memory zone with the given size, numa_id and flags.
Unless SPDK_MEMZONE_NO_IOVA_CONTIG
flag is provided, the returned memory will be IOVA contiguous.
name | Name to set for this memory zone. |
len | Length in bytes. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
flags | Flags to set for this memory zone. |
void * spdk_memzone_reserve_aligned | ( | const char * | name, |
size_t | len, | ||
int | numa_id, | ||
unsigned | flags, | ||
unsigned | align ) |
Reserve a named, process shared memory zone with the given size, numa_id, flags and alignment.
Unless SPDK_MEMZONE_NO_IOVA_CONTIG
flag is provided, the returned memory will be IOVA contiguous.
name | Name to set for this memory zone. |
len | Length in bytes. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
flags | Flags to set for this memory zone. |
align | Alignment for resulting memzone. Must be a power of 2. |
int spdk_pci_addr_compare | ( | const struct spdk_pci_addr * | a1, |
const struct spdk_pci_addr * | a2 ) |
Compare two PCI addresses.
a1 | PCI address 1. |
a2 | PCI address 2. |
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.
bdf | String into which a string will be output in the format domain:bus:device.function. The string must be at least 14 characters in size. |
sz | Size of bdf in bytes. Must be at least 14. |
addr | PCI address. |
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.
addr | PCI address output on success. |
bdf | PCI address in domain:bus:device.function format or domain.bus.device.function format. |
int spdk_pci_device_allow | ( | struct spdk_pci_addr * | pci_addr | ) |
Allow the specified PCI device to be probed by the calling process.
When using spdk_pci_enumerate(), only devices with allowed PCI addresses will be probed. By default, this is all PCI addresses, but the pci_allowed and pci_blocked environment options can override this behavior. This API enables the caller to allow a new PCI address that may have previously been blocked.
pci_addr | PCI address to allow |
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 blocked list 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.
driver | Driver for a specific device type. The device will only be attached if it's supported by this driver. |
enum_cb | Callback to be called for the PCI device once it's found. |
enum_ctx | Additional context passed to the callback function. |
pci_address | Address of the device to attach. |
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.
dev | PCI device. |
buf | A buffer to copy the data into. |
len | Number of bytes to read. |
offset | Offset (in bytes) in the PCI config space to start reading from. |
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.
dev | PCI device. |
value | A buffer to copy the data into. |
offset | Offset (in bytes) in the PCI config space to start reading from. |
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.
dev | PCI device. |
value | A buffer to copy the data into. |
offset | Offset (in bytes) in the PCI config space to start reading from. |
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.
dev | PCI device. |
value | A buffer to copy the data into. |
offset | Offset (in bytes) in the PCI config space to start reading from. |
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.
dev | PCI device. |
buf | A buffer to copy the data from. |
len | Number of bytes to write. |
offset | Offset (in bytes) in the PCI config space to start writing to. |
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.
dev | PCI device. |
value | A value to write. |
offset | Offset (in bytes) in the PCI config space to start writing to. |
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.
dev | PCI device. |
value | A value to write. |
offset | Offset (in bytes) in the PCI config space to start writing to. |
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.
dev | PCI device. |
value | A value to write. |
offset | Offset (in bytes) in the PCI config space to start writing to. |
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.
dev | PCI device to claim. |
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.
device | PCI device. |
int spdk_pci_device_disable_interrupt | ( | struct spdk_pci_device * | dev | ) |
Disable PCI device interrupts.
(Experimental)
dev | PCI device. |
int spdk_pci_device_disable_interrupts | ( | struct spdk_pci_device * | dev | ) |
Disable PCI device interrupts.
This disables the MSI-X interrupts for all the created event file descriptors and frees them.
dev | PCI device. |
int spdk_pci_device_enable_interrupt | ( | struct spdk_pci_device * | dev | ) |
Enable PCI device interrupts.
(Experimental)
dev | PCI device. |
int spdk_pci_device_enable_interrupts | ( | struct spdk_pci_device * | dev, |
uint32_t | efd_count ) |
Enable PCI device interrupts, only if VFIO MSI-X is supported.
This creates a bunch of event file descriptors, for which VFIO IRQ are set, which then can be used to enable interrupts.
dev | PCI device. |
efd_count | Number of event fds to create. |
struct spdk_pci_addr spdk_pci_device_get_addr | ( | struct spdk_pci_device * | dev | ) |
Get the full DomainBDF address of a PCI device.
dev | PCI device. |
uint8_t spdk_pci_device_get_bus | ( | struct spdk_pci_device * | dev | ) |
Get the bus number of a PCI device.
dev | PCI device. |
uint8_t spdk_pci_device_get_dev | ( | struct spdk_pci_device * | dev | ) |
Get the device number within the PCI bus the device is on.
dev | PCI device. |
uint16_t spdk_pci_device_get_device_id | ( | struct spdk_pci_device * | dev | ) |
Get the device ID of a PCI device.
dev | PCI device. |
uint32_t spdk_pci_device_get_domain | ( | struct spdk_pci_device * | dev | ) |
Get the domain of a PCI device.
dev | PCI device. |
uint8_t spdk_pci_device_get_func | ( | struct spdk_pci_device * | dev | ) |
Get the particular function number represented by struct spdk_pci_device.
dev | PCI device. |
struct spdk_pci_id spdk_pci_device_get_id | ( | struct spdk_pci_device * | dev | ) |
Get the PCI ID of a PCI device.
dev | PCI device. |
int spdk_pci_device_get_interrupt_efd | ( | struct spdk_pci_device * | dev | ) |
Get an event file descriptor associated with a PCI device interrupt.
(Experimental)
dev | PCI device. |
int spdk_pci_device_get_interrupt_efd_by_index | ( | struct spdk_pci_device * | dev, |
uint32_t | index ) |
Get an event file descriptor associated with a PCI device, for a particular MSI-X index.
dev | PCI device. |
index | event file descriptor index. |
int spdk_pci_device_get_numa_id | ( | struct spdk_pci_device * | dev | ) |
Get the NUMA node the PCI device is on.
dev | PCI device. |
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.
dev | PCI device. |
sn | Buffer to store the serial number in. |
len | Length of buffer. Must be at least 17. |
int spdk_pci_device_get_socket_id | ( | struct spdk_pci_device * | dev | ) |
Get the NUMA node the PCI device is on.
Deprecated. Use ref spdk_pci_device_get_numa_id()
instead.
dev | PCI device. |
uint16_t spdk_pci_device_get_subdevice_id | ( | struct spdk_pci_device * | dev | ) |
Get the subdevice ID of a PCI device.
dev | PCI device. |
uint16_t spdk_pci_device_get_subvendor_id | ( | struct spdk_pci_device * | dev | ) |
Get the subvendor ID of a PCI device.
dev | PCI device. |
const char * spdk_pci_device_get_type | ( | const struct spdk_pci_device * | dev | ) |
Return the type of the PCI device.
dev | PCI device |
uint16_t spdk_pci_device_get_vendor_id | ( | struct spdk_pci_device * | dev | ) |
Get the vendor ID of a PCI device.
dev | PCI device. |
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.
dev | PCI device. |
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.
dev | PCI device. |
bar | BAR number. |
mapped_addr | A variable to store the virtual address of the mapping. |
phys_addr | A variable to store the physical address of the mapping. |
size | A variable to store the size of the bar (in bytes). |
void spdk_pci_device_unclaim | ( | struct spdk_pci_device * | dev | ) |
Undo spdk_pci_device_claim().
dev | PCI device to unclaim. |
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.
dev | PCI device. |
bar | BAR number. |
mapped_addr | Virtual address of the bar. |
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.
During enumeration all registered pci devices with exposed access to userspace are getting probed internally unless not explicitly specified on denylist. Because of that it becomes not possible to either use such devices with another application or unbind the driver (e.g. vfio).
2s asynchronous delay is introduced to avoid race conditions between user space software initialization and in-kernel device handling for newly inserted devices. Subsequent enumerate call after the delay shall allow for a successful device attachment.
driver | Driver for a specific device type. |
enum_cb | Callback to be called for each non-attached PCI device. |
enum_ctx | Additional context passed to the callback function. |
int spdk_pci_event_listen | ( | void | ) |
Begin listening for PCI bus events.
This is used to detect hot-insert and hot-remove events. Once the system is listening, events may be retrieved by calling spdk_pci_get_event() periodically.
void spdk_pci_for_each_device | ( | void * | ctx, |
void(* | fn )(void *ctx, struct spdk_pci_device *dev) ) |
Call the provided function pointer for every enumerated PCI device.
ctx | Context parameter to pass to fn. |
fn | Function to call for each PCI device |
struct spdk_pci_driver * spdk_pci_get_driver | ( | const char * | name | ) |
Get PCI driver by name (e.g.
"nvme", "vmd", "ioat").
int spdk_pci_get_event | ( | int | fd, |
struct spdk_pci_event * | event ) |
Get the next PCI bus event.
fd | A file descriptor returned by spdk_pci_event_listen() |
event | An event on the PCI bus |
int 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.
drv | driver that will be able to attach the device |
dev | fully initialized PCI device struct |
struct spdk_pci_driver * spdk_pci_idxd_get_driver | ( | void | ) |
Get the IDXD PCI driver object.
struct spdk_pci_driver * spdk_pci_ioat_get_driver | ( | void | ) |
Get the I/OAT PCI driver object.
struct spdk_pci_driver * spdk_pci_nvme_get_driver | ( | void | ) |
Get the NVMe PCI driver object.
void spdk_pci_register_device_provider | ( | struct spdk_pci_device_provider * | provider | ) |
Register a PCI device provdier.
provider | PCI device provider. |
int spdk_pci_register_error_handler | ( | spdk_pci_error_handler | sighandler, |
void * | ctx ) |
Register a signal handler to handle bus errors on the PCI bus.
sighandler | Signal bus handler of the PCI bus |
ctx | The arg pass to the registered signal bus handler. |
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.
dev | fully initialized PCI device struct |
void spdk_pci_unregister_error_handler | ( | spdk_pci_error_handler | sighandler | ) |
Register a signal handler to handle bus errors on the PCI bus.
sighandler | Signal bus handler of the PCI bus |
struct spdk_pci_driver * spdk_pci_virtio_get_driver | ( | void | ) |
Get the Virtio PCI driver object.
struct spdk_pci_driver * spdk_pci_vmd_get_driver | ( | void | ) |
Get the VMD PCI driver object.
bool spdk_process_is_primary | ( | void | ) |
Check whether the calling process is primary process.
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.
buf | Buffer to resize. |
size | Size in bytes. |
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. |
size_t spdk_ring_count | ( | struct spdk_ring * | ring | ) |
Get the number of objects in the ring.
ring | the ring. |
struct spdk_ring * spdk_ring_create | ( | enum spdk_ring_type | type, |
size_t | count, | ||
int | numa_id ) |
Create a ring.
type | Type for the ring. (SPDK_RING_TYPE_SP_SC or SPDK_RING_TYPE_MP_SC). |
count | Size of the ring in elements. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
size_t spdk_ring_dequeue | ( | struct spdk_ring * | ring, |
void ** | objs, | ||
size_t | count ) |
Dequeue count objects from the ring into the array objs.
ring | A pointer to the ring. |
objs | A pointer to the array to be dequeued. |
count | Maximum number of elements to be dequeued. |
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.
ring | A pointer to the ring. |
objs | A pointer to the array to be queued. |
count | Length count of the array of objects. |
free_space | If non-NULL, amount of free space after the enqueue has finished. |
void spdk_ring_free | ( | struct spdk_ring * | ring | ) |
Free the ring.
ring | Ring to free. |
uint64_t spdk_vtophys | ( | const void * | buf, |
uint64_t * | size ) |
Get the physical address of a buffer.
buf | A pointer to a buffer. |
size | Contains 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. |
void * spdk_zmalloc | ( | size_t | size, |
size_t | align, | ||
uint64_t * | unused, | ||
int | numa_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.
size | Size in bytes. |
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. |
unused | Invalid. If not a NULL, the function will fail and return NULL. |
numa_id | NUMA node ID to allocate memory on, or SPDK_ENV_NUMA_ID_ANY for any NUMA node. |
flags | Combination of SPDK_MALLOC flags (SPDK_MALLOC_DMA, SPDK_MALLOC_SHARE). |