nvmf.h File Reference

NVMe over Fabrics target public API. More...

Data Structures

struct  spdk_nvmf_target_opts
 
struct  spdk_nvmf_transport_opts
 
struct  spdk_nvmf_poll_group_stat
 
struct  spdk_nvmf_rdma_device_stat
 
struct  spdk_nvmf_transport_poll_group_stat
 
struct  spdk_nvmf_ns_opts
 NVMe-oF target namespace creation options. More...
 

Macros

#define NVMF_TGT_NAME_MAX_LENGTH   256
 

Typedefs

typedef void(* new_qpair_fn) (struct spdk_nvmf_qpair *qpair, void *cb_arg)
 Function to be called for each newly discovered qpair. More...
 
typedef void(* spdk_nvmf_tgt_subsystem_listen_done_fn) (void *ctx, int status)
 Function to be called once the listener is associated with a subsystem. More...
 
typedef void() spdk_nvmf_tgt_destroy_done_fn(void *ctx, int status)
 
typedef void(* spdk_nvmf_poll_group_destroy_done_fn) (void *cb_arg, int status)
 
typedef void(* nvmf_qpair_disconnect_cb) (void *ctx)
 
typedef void(* spdk_nvmf_subsystem_state_change_done) (struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status)
 Function to be called once the subsystem has changed state. More...
 
typedef void(* spdk_nvmf_tgt_add_transport_done_fn) (void *cb_arg, int status)
 Function to be called once transport add is complete. More...
 

Functions

struct spdk_nvmf_tgt * spdk_nvmf_tgt_create (struct spdk_nvmf_target_opts *opts)
 Construct an NVMe-oF target. More...
 
void spdk_nvmf_tgt_destroy (struct spdk_nvmf_tgt *tgt, spdk_nvmf_tgt_destroy_done_fn cb_fn, void *cb_arg)
 Destroy an NVMe-oF target. More...
 
const char * spdk_nvmf_tgt_get_name (struct spdk_nvmf_tgt *tgt)
 Get the name of an NVMe-oF target. More...
 
struct spdk_nvmf_tgt * spdk_nvmf_get_tgt (const char *name)
 Get a pointer to an NVMe-oF target. More...
 
struct spdk_nvmf_tgt * spdk_nvmf_get_first_tgt (void)
 Get the pointer to the first NVMe-oF target. More...
 
struct spdk_nvmf_tgt * spdk_nvmf_get_next_tgt (struct spdk_nvmf_tgt *prev)
 Get the pointer to the first NVMe-oF target. More...
 
void spdk_nvmf_tgt_write_config_json (struct spdk_json_write_ctx *w, struct spdk_nvmf_tgt *tgt)
 Write NVMe-oF target configuration into provided JSON context. More...
 
int spdk_nvmf_tgt_listen (struct spdk_nvmf_tgt *tgt, struct spdk_nvme_transport_id *trid)
 Begin accepting new connections at the address provided. More...
 
int spdk_nvmf_tgt_stop_listen (struct spdk_nvmf_tgt *tgt, struct spdk_nvme_transport_id *trid)
 Stop accepting new connections at the provided address. More...
 
void spdk_nvmf_tgt_accept (struct spdk_nvmf_tgt *tgt, new_qpair_fn cb_fn, void *cb_arg)
 Poll the target for incoming connections. More...
 
struct spdk_nvmf_poll_groupspdk_nvmf_poll_group_create (struct spdk_nvmf_tgt *tgt)
 Create a poll group. More...
 
struct spdk_nvmf_poll_groupspdk_nvmf_get_optimal_poll_group (struct spdk_nvmf_qpair *qpair)
 Get optimal nvmf poll group for the qpair. More...
 
void spdk_nvmf_poll_group_destroy (struct spdk_nvmf_poll_group *group, spdk_nvmf_poll_group_destroy_done_fn cb_fn, void *cb_arg)
 Destroy a poll group. More...
 
int spdk_nvmf_poll_group_add (struct spdk_nvmf_poll_group *group, struct spdk_nvmf_qpair *qpair)
 Add the given qpair to the poll group. More...
 
int spdk_nvmf_poll_group_get_stat (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_poll_group_stat *stat)
 Get current poll group statistics. More...
 
int spdk_nvmf_qpair_disconnect (struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn, void *ctx)
 Disconnect an NVMe-oF qpair. More...
 
int spdk_nvmf_qpair_get_peer_trid (struct spdk_nvmf_qpair *qpair, struct spdk_nvme_transport_id *trid)
 Get the peer's transport ID for this queue pair. More...
 
int spdk_nvmf_qpair_get_local_trid (struct spdk_nvmf_qpair *qpair, struct spdk_nvme_transport_id *trid)
 Get the local transport ID for this queue pair. More...
 
int spdk_nvmf_qpair_get_listen_trid (struct spdk_nvmf_qpair *qpair, struct spdk_nvme_transport_id *trid)
 Get the associated listener transport ID for this queue pair. More...
 
struct spdk_nvmf_subsystem * spdk_nvmf_subsystem_create (struct spdk_nvmf_tgt *tgt, const char *nqn, enum spdk_nvmf_subtype type, uint32_t num_ns)
 Create an NVMe-oF subsystem. More...
 
void spdk_nvmf_subsystem_destroy (struct spdk_nvmf_subsystem *subsystem)
 Destroy an NVMe-oF subsystem. More...
 
int spdk_nvmf_subsystem_start (struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_subsystem_state_change_done cb_fn, void *cb_arg)
 Transition an NVMe-oF subsystem from Inactive to Active state. More...
 
int spdk_nvmf_subsystem_stop (struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_subsystem_state_change_done cb_fn, void *cb_arg)
 Transition an NVMe-oF subsystem from Active to Inactive state. More...
 
int spdk_nvmf_subsystem_pause (struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_subsystem_state_change_done cb_fn, void *cb_arg)
 Transition an NVMe-oF subsystem from Active to Paused state. More...
 
int spdk_nvmf_subsystem_resume (struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_subsystem_state_change_done cb_fn, void *cb_arg)
 Transition an NVMe-oF subsystem from Paused to Active state. More...
 
struct spdk_nvmf_subsystem * spdk_nvmf_tgt_find_subsystem (struct spdk_nvmf_tgt *tgt, const char *subnqn)
 Search the target for a subsystem with the given NQN. More...
 
struct spdk_nvmf_subsystem * spdk_nvmf_subsystem_get_first (struct spdk_nvmf_tgt *tgt)
 Begin iterating over all known subsystems. More...
 
struct spdk_nvmf_subsystem * spdk_nvmf_subsystem_get_next (struct spdk_nvmf_subsystem *subsystem)
 Continue iterating over all known subsystems. More...
 
int spdk_nvmf_subsystem_add_host (struct spdk_nvmf_subsystem *subsystem, const char *hostnqn)
 Allow the given host NQN to connect to the given subsystem. More...
 
int spdk_nvmf_subsystem_remove_host (struct spdk_nvmf_subsystem *subsystem, const char *hostnqn)
 Remove the given host NQN from the allowed hosts whitelist. More...
 
int spdk_nvmf_subsystem_set_allow_any_host (struct spdk_nvmf_subsystem *subsystem, bool allow_any_host)
 Set whether a subsystem should allow any host or only hosts in the allowed list. More...
 
bool spdk_nvmf_subsystem_get_allow_any_host (const struct spdk_nvmf_subsystem *subsystem)
 Check whether a subsystem should allow any host or only hosts in the allowed list. More...
 
bool spdk_nvmf_subsystem_host_allowed (struct spdk_nvmf_subsystem *subsystem, const char *hostnqn)
 Check if the given host is allowed to connect to the subsystem. More...
 
struct spdk_nvmf_host * spdk_nvmf_subsystem_get_first_host (struct spdk_nvmf_subsystem *subsystem)
 Get the first allowed host in a subsystem. More...
 
struct spdk_nvmf_host * spdk_nvmf_subsystem_get_next_host (struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_host *prev_host)
 Get the next allowed host in a subsystem. More...
 
const char * spdk_nvmf_host_get_nqn (const struct spdk_nvmf_host *host)
 Get a host's NQN. More...
 
void spdk_nvmf_subsystem_add_listener (struct spdk_nvmf_subsystem *subsystem, struct spdk_nvme_transport_id *trid, spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn, void *cb_arg)
 Accept new connections on the address provided. More...
 
int spdk_nvmf_subsystem_remove_listener (struct spdk_nvmf_subsystem *subsystem, const struct spdk_nvme_transport_id *trid)
 Remove the listener from subsystem. More...
 
bool spdk_nvmf_subsystem_listener_allowed (struct spdk_nvmf_subsystem *subsystem, const struct spdk_nvme_transport_id *trid)
 Check if connections originated from the given address are allowed to connect to the subsystem. More...
 
struct spdk_nvmf_subsystem_listener * spdk_nvmf_subsystem_get_first_listener (struct spdk_nvmf_subsystem *subsystem)
 Get the first allowed listen address in the subsystem. More...
 
struct spdk_nvmf_subsystem_listener * spdk_nvmf_subsystem_get_next_listener (struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_subsystem_listener *prev_listener)
 Get the next allowed listen address in a subsystem. More...
 
const struct spdk_nvme_transport_idspdk_nvmf_subsystem_listener_get_trid (struct spdk_nvmf_subsystem_listener *listener)
 Get a listen address' transport ID. More...
 
void spdk_nvmf_subsystem_allow_any_listener (struct spdk_nvmf_subsystem *subsystem, bool allow_any_listener)
 Set whether a subsystem should allow any listen address or only addresses in the allowed list. More...
 
bool spdk_nvmf_subsytem_any_listener_allowed (struct spdk_nvmf_subsystem *subsystem)
 Check whether a subsystem allows any listen address or only addresses in the allowed list. More...
 
void spdk_nvmf_ns_opts_get_defaults (struct spdk_nvmf_ns_opts *opts, size_t opts_size)
 Get default namespace creation options. More...
 
uint32_t spdk_nvmf_subsystem_add_ns (struct spdk_nvmf_subsystem *subsystem, struct spdk_bdev *bdev, const struct spdk_nvmf_ns_opts *opts, size_t opts_size, const char *ptpl_file)
 Add a namespace to a subsytem. More...
 
int spdk_nvmf_subsystem_remove_ns (struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
 Remove a namespace from a subsytem. More...
 
struct spdk_nvmf_ns * spdk_nvmf_subsystem_get_first_ns (struct spdk_nvmf_subsystem *subsystem)
 Get the first allocated namespace in a subsystem. More...
 
struct spdk_nvmf_ns * spdk_nvmf_subsystem_get_next_ns (struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_ns *prev_ns)
 Get the next allocated namespace in a subsystem. More...
 
struct spdk_nvmf_ns * spdk_nvmf_subsystem_get_ns (struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
 Get a namespace in a subsystem by NSID. More...
 
uint32_t spdk_nvmf_subsystem_get_max_namespaces (const struct spdk_nvmf_subsystem *subsystem)
 Get the maximum number of namespaces allowed in a subsystem. More...
 
uint32_t spdk_nvmf_ns_get_id (const struct spdk_nvmf_ns *ns)
 Get a namespace's NSID. More...
 
struct spdk_bdevspdk_nvmf_ns_get_bdev (struct spdk_nvmf_ns *ns)
 Get a namespace's associated bdev. More...
 
void spdk_nvmf_ns_get_opts (const struct spdk_nvmf_ns *ns, struct spdk_nvmf_ns_opts *opts, size_t opts_size)
 Get the options specified for a namespace. More...
 
const char * spdk_nvmf_subsystem_get_sn (const struct spdk_nvmf_subsystem *subsystem)
 Get the serial number of the specified subsystem. More...
 
int spdk_nvmf_subsystem_set_sn (struct spdk_nvmf_subsystem *subsystem, const char *sn)
 Set the serial number for the specified subsystem. More...
 
const char * spdk_nvmf_subsystem_get_mn (const struct spdk_nvmf_subsystem *subsystem)
 Get the model number of the specified subsystem. More...
 
int spdk_nvmf_subsystem_set_mn (struct spdk_nvmf_subsystem *subsystem, const char *mn)
 Set the model number for the specified subsystem. More...
 
const char * spdk_nvmf_subsystem_get_nqn (const struct spdk_nvmf_subsystem *subsystem)
 Get the NQN of the specified subsystem. More...
 
enum spdk_nvmf_subtype spdk_nvmf_subsystem_get_type (struct spdk_nvmf_subsystem *subsystem)
 Get the type of the specified subsystem. More...
 
uint32_t spdk_nvmf_subsystem_get_max_nsid (struct spdk_nvmf_subsystem *subsystem)
 Get maximum namespace id of the specified subsystem. More...
 
bool spdk_nvmf_transport_opts_init (const char *transport_name, struct spdk_nvmf_transport_opts *opts)
 Initialize transport options. More...
 
struct spdk_nvmf_transportspdk_nvmf_transport_create (const char *transport_name, struct spdk_nvmf_transport_opts *opts)
 Create a protocol transport. More...
 
int spdk_nvmf_transport_destroy (struct spdk_nvmf_transport *transport)
 Destroy a protocol transport. More...
 
struct spdk_nvmf_transportspdk_nvmf_tgt_get_transport (struct spdk_nvmf_tgt *tgt, const char *transport_name)
 Get an existing transport from the target. More...
 
struct spdk_nvmf_transportspdk_nvmf_transport_get_first (struct spdk_nvmf_tgt *tgt)
 Get the first transport registered with the given target. More...
 
struct spdk_nvmf_transportspdk_nvmf_transport_get_next (struct spdk_nvmf_transport *transport)
 Get the next transport in a target's list. More...
 
const struct spdk_nvmf_transport_optsspdk_nvmf_get_transport_opts (struct spdk_nvmf_transport *transport)
 Get the opts for a given transport. More...
 
spdk_nvme_transport_type_t spdk_nvmf_get_transport_type (struct spdk_nvmf_transport *transport)
 Get the transport type for a given transport. More...
 
const char * spdk_nvmf_get_transport_name (struct spdk_nvmf_transport *transport)
 Get the transport name for a given transport. More...
 
void spdk_nvmf_tgt_add_transport (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_transport *transport, spdk_nvmf_tgt_add_transport_done_fn cb_fn, void *cb_arg)
 Add a transport to a target. More...
 
int spdk_nvmf_transport_listen (struct spdk_nvmf_transport *transport, const struct spdk_nvme_transport_id *trid)
 Add listener to transport and begin accepting new connections. More...
 
int spdk_nvmf_transport_stop_listen (struct spdk_nvmf_transport *transport, const struct spdk_nvme_transport_id *trid)
 Remove listener from transport and stop accepting new connections. More...
 
void spdk_nvmf_tgt_transport_write_config_json (struct spdk_json_write_ctx *w, struct spdk_nvmf_tgt *tgt)
 Write NVMe-oF target's transport configurations into provided JSON context. More...
 
int spdk_nvmf_transport_poll_group_get_stat (struct spdk_nvmf_tgt *tgt, struct spdk_nvmf_transport *transport, struct spdk_nvmf_transport_poll_group_stat **stat)
 Get current transport poll group statistics. More...
 
void spdk_nvmf_transport_poll_group_free_stat (struct spdk_nvmf_transport *transport, struct spdk_nvmf_transport_poll_group_stat *stat)
 Free statistics memory previously allocated with spdk_nvmf_transport_poll_group_get_stat(). More...
 
void spdk_nvmf_rdma_init_hooks (struct spdk_nvme_rdma_hooks *hooks)
 Set the global hooks for the RDMA transport, if necessary. More...
 

Detailed Description

NVMe over Fabrics target public API.

Typedef Documentation

◆ new_qpair_fn

typedef void(* new_qpair_fn) (struct spdk_nvmf_qpair *qpair, void *cb_arg)

Function to be called for each newly discovered qpair.

Parameters
qpairThe newly discovered qpair.
cb_argA context argument passed to this function.

◆ spdk_nvmf_subsystem_state_change_done

typedef void(* spdk_nvmf_subsystem_state_change_done) (struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status)

Function to be called once the subsystem has changed state.

Parameters
subsytemNVMe-oF subsystem that has changed state.
cb_argArgument passed to callback function.
status0 if it completed successfully, or negative errno if it failed.

◆ spdk_nvmf_tgt_add_transport_done_fn

typedef void(* spdk_nvmf_tgt_add_transport_done_fn) (void *cb_arg, int status)

Function to be called once transport add is complete.

Parameters
cb_argCallback argument passed to this function.
status0 if it completed successfully, or negative errno if it failed.

◆ spdk_nvmf_tgt_subsystem_listen_done_fn

typedef void(* spdk_nvmf_tgt_subsystem_listen_done_fn) (void *ctx, int status)

Function to be called once the listener is associated with a subsystem.

Parameters
ctxContext argument passed to this function.
status0 if it completed successfully, or negative errno if it failed.

Function Documentation

◆ spdk_nvmf_get_first_tgt()

struct spdk_nvmf_tgt* spdk_nvmf_get_first_tgt ( void  )

Get the pointer to the first NVMe-oF target.

Combined with spdk_nvmf_get_next_tgt to iterate over all available targets.

Returns
The first NVMe-oF target.

◆ spdk_nvmf_get_next_tgt()

struct spdk_nvmf_tgt* spdk_nvmf_get_next_tgt ( struct spdk_nvmf_tgt *  prev)

Get the pointer to the first NVMe-oF target.

Combined with spdk_nvmf_get_first_tgt to iterate over all available targets.

Parameters
prevA pointer to the last NVMe-oF target.
Returns
The first NVMe-oF target.

◆ spdk_nvmf_get_optimal_poll_group()

struct spdk_nvmf_poll_group* spdk_nvmf_get_optimal_poll_group ( struct spdk_nvmf_qpair qpair)

Get optimal nvmf poll group for the qpair.

Parameters
qpairRequested qpair
Returns
a poll group on success, or NULL on failure.

◆ spdk_nvmf_get_tgt()

struct spdk_nvmf_tgt* spdk_nvmf_get_tgt ( const char *  name)

Get a pointer to an NVMe-oF target.

In order to support some legacy applications and RPC methods that may rely on the concept that there is only one target, the name parameter can be passed as NULL. If there is only one available target, that target will be returned. Otherwise, name is a required parameter.

Parameters
nameThe name provided when the target was created.
Returns
The target with the given name, or NULL if no match was found.

◆ spdk_nvmf_get_transport_name()

const char* spdk_nvmf_get_transport_name ( struct spdk_nvmf_transport transport)

Get the transport name for a given transport.

Parameters
transportThe transport to query
Returns
the transport name for the given transport

◆ spdk_nvmf_get_transport_opts()

const struct spdk_nvmf_transport_opts* spdk_nvmf_get_transport_opts ( struct spdk_nvmf_transport transport)

Get the opts for a given transport.

Parameters
transportThe transport to query
Returns
The opts associated with the given transport

◆ spdk_nvmf_get_transport_type()

spdk_nvme_transport_type_t spdk_nvmf_get_transport_type ( struct spdk_nvmf_transport transport)

Get the transport type for a given transport.

Parameters
transportThe transport to query
Returns
the transport type for the given transport

◆ spdk_nvmf_host_get_nqn()

const char* spdk_nvmf_host_get_nqn ( const struct spdk_nvmf_host *  host)

Get a host's NQN.

Parameters
hostHost to query.
Returns
NQN of host.

◆ spdk_nvmf_ns_get_bdev()

struct spdk_bdev* spdk_nvmf_ns_get_bdev ( struct spdk_nvmf_ns *  ns)

Get a namespace's associated bdev.

Parameters
nsNamespace to query.
Returns
backing bdev of ns.

◆ spdk_nvmf_ns_get_id()

uint32_t spdk_nvmf_ns_get_id ( const struct spdk_nvmf_ns *  ns)

Get a namespace's NSID.

Parameters
nsNamespace to query.
Returns
NSID of ns.

◆ spdk_nvmf_ns_get_opts()

void spdk_nvmf_ns_get_opts ( const struct spdk_nvmf_ns *  ns,
struct spdk_nvmf_ns_opts opts,
size_t  opts_size 
)

Get the options specified for a namespace.

Parameters
nsNamespace to query.
optsOutput parameter for options.
opts_sizesizeof(*opts)

◆ spdk_nvmf_ns_opts_get_defaults()

void spdk_nvmf_ns_opts_get_defaults ( struct spdk_nvmf_ns_opts opts,
size_t  opts_size 
)

Get default namespace creation options.

Parameters
optsNamespace options to fill with defaults.
opts_sizesizeof(struct spdk_nvmf_ns_opts)

◆ spdk_nvmf_poll_group_add()

int spdk_nvmf_poll_group_add ( struct spdk_nvmf_poll_group group,
struct spdk_nvmf_qpair qpair 
)

Add the given qpair to the poll group.

Parameters
groupThe group to add qpair to.
qpairThe qpair to add.
Returns
0 on success, -1 on failure.

◆ spdk_nvmf_poll_group_create()

struct spdk_nvmf_poll_group* spdk_nvmf_poll_group_create ( struct spdk_nvmf_tgt *  tgt)

Create a poll group.

Parameters
tgtThe target to create a poll group.
Returns
a poll group on success, or NULL on failure.

◆ spdk_nvmf_poll_group_destroy()

void spdk_nvmf_poll_group_destroy ( struct spdk_nvmf_poll_group group,
spdk_nvmf_poll_group_destroy_done_fn  cb_fn,
void *  cb_arg 
)

Destroy a poll group.

Parameters
groupThe poll group to destroy.
cb_fnA callback that will be called once the poll group is destroyed.
cb_argA context argument passed to cb_fn.

◆ spdk_nvmf_poll_group_get_stat()

int spdk_nvmf_poll_group_get_stat ( struct spdk_nvmf_tgt *  tgt,
struct spdk_nvmf_poll_group_stat stat 
)

Get current poll group statistics.

Parameters
tgtThe NVMf target.
statPointer to allocated statistics structure to fill with values.
Returns
0 upon success.
-EINVAL if either group or stat is NULL.

◆ spdk_nvmf_qpair_disconnect()

int spdk_nvmf_qpair_disconnect ( struct spdk_nvmf_qpair qpair,
nvmf_qpair_disconnect_cb  cb_fn,
void *  ctx 
)

Disconnect an NVMe-oF qpair.

Parameters
qpairThe NVMe-oF qpair to disconnect.
cb_fnThe function to call upon completion of the disconnect.
ctxThe context to pass to the callback function.
Returns
0 upon success.
-ENOMEM if the function specific context could not be allocated.

◆ spdk_nvmf_qpair_get_listen_trid()

int spdk_nvmf_qpair_get_listen_trid ( struct spdk_nvmf_qpair qpair,
struct spdk_nvme_transport_id trid 
)

Get the associated listener transport ID for this queue pair.

Parameters
qpairThe NVMe-oF qpair
tridOutput parameter that will contain the transport id.
Returns
0 for success.
-EINVAL if the qpair is not connected.

◆ spdk_nvmf_qpair_get_local_trid()

int spdk_nvmf_qpair_get_local_trid ( struct spdk_nvmf_qpair qpair,
struct spdk_nvme_transport_id trid 
)

Get the local transport ID for this queue pair.

Parameters
qpairThe NVMe-oF qpair
tridOutput parameter that will contain the transport id.
Returns
0 for success.
-EINVAL if the qpair is not connected.

◆ spdk_nvmf_qpair_get_peer_trid()

int spdk_nvmf_qpair_get_peer_trid ( struct spdk_nvmf_qpair qpair,
struct spdk_nvme_transport_id trid 
)

Get the peer's transport ID for this queue pair.

Parameters
qpairThe NVMe-oF qpair
tridOutput parameter that will contain the transport id.
Returns
0 for success.
-EINVAL if the qpair is not connected.

◆ spdk_nvmf_rdma_init_hooks()

void spdk_nvmf_rdma_init_hooks ( struct spdk_nvme_rdma_hooks hooks)

Set the global hooks for the RDMA transport, if necessary.

This call is optional and must be performed prior to probing for any devices. By default, the RDMA transport will use the ibverbs library to create protection domains and register memory. This is a mechanism to subvert that and use an existing registration.

This function may only be called one time per process.

Parameters
hooksfor initializing global hooks

◆ spdk_nvmf_subsystem_add_host()

int spdk_nvmf_subsystem_add_host ( struct spdk_nvmf_subsystem *  subsystem,
const char *  hostnqn 
)

Allow the given host NQN to connect to the given subsystem.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to add host to.
hostnqnThe NQN for the host.
Returns
0 on success, or negated errno value on failure.

◆ spdk_nvmf_subsystem_add_listener()

void spdk_nvmf_subsystem_add_listener ( struct spdk_nvmf_subsystem *  subsystem,
struct spdk_nvme_transport_id trid,
spdk_nvmf_tgt_subsystem_listen_done_fn  cb_fn,
void *  cb_arg 
)

Accept new connections on the address provided.

This does not start the listener. Use spdk_nvmf_tgt_listen() for that.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to add listener to.
tridThe address to accept connections from.
cb_fnA callback that will be called once the association is complete.
cb_argArgument passed to cb_fn.

◆ spdk_nvmf_subsystem_add_ns()

uint32_t spdk_nvmf_subsystem_add_ns ( struct spdk_nvmf_subsystem *  subsystem,
struct spdk_bdev bdev,
const struct spdk_nvmf_ns_opts opts,
size_t  opts_size,
const char *  ptpl_file 
)

Add a namespace to a subsytem.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to add namespace to.
bdevBlock device to add as a namespace.
optsNamespace options, or NULL to use defaults.
opts_sizesizeof(*opts)
ptpl_filePersist through power loss file path.
Returns
newly added NSID on success, or 0 on failure.

◆ spdk_nvmf_subsystem_allow_any_listener()

void spdk_nvmf_subsystem_allow_any_listener ( struct spdk_nvmf_subsystem *  subsystem,
bool  allow_any_listener 
)

Set whether a subsystem should allow any listen address or only addresses in the allowed list.

Parameters
subsystemSubsystem to allow dynamic listener assignment.
allow_any_listenertrue to allow dynamic listener assignment for this subsystem, or false to enforce the whitelist configured during subsystem setup.

◆ spdk_nvmf_subsystem_create()

struct spdk_nvmf_subsystem* spdk_nvmf_subsystem_create ( struct spdk_nvmf_tgt *  tgt,
const char *  nqn,
enum spdk_nvmf_subtype  type,
uint32_t  num_ns 
)

Create an NVMe-oF subsystem.

Subsystems are in one of three states: Inactive, Active, Paused. This state affects which operations may be performed on the subsystem. Upon creation, the subsystem will be in the Inactive state and may be activated by calling spdk_nvmf_subsystem_start(). No I/O will be processed in the Inactive or Paused states, but changes to the state of the subsystem may be made.

Parameters
tgtThe NVMe-oF target that will own this subsystem.
nqnThe NVMe qualified name of this subsystem.
typeWhether this subsystem is an I/O subsystem or a Discovery subsystem.
num_nsThe number of namespaces this subsystem contains.
Returns
a pointer to a NVMe-oF subsystem on success, or NULL on failure.

◆ spdk_nvmf_subsystem_destroy()

void spdk_nvmf_subsystem_destroy ( struct spdk_nvmf_subsystem *  subsystem)

Destroy an NVMe-oF subsystem.

A subsystem may only be destroyed when in the Inactive state. See spdk_nvmf_subsystem_stop().

Parameters
subsystemThe NVMe-oF subsystem to destroy.

◆ spdk_nvmf_subsystem_get_allow_any_host()

bool spdk_nvmf_subsystem_get_allow_any_host ( const struct spdk_nvmf_subsystem *  subsystem)

Check whether a subsystem should allow any host or only hosts in the allowed list.

Parameters
subsystemSubsystem to query.
Returns
true if any host is allowed to connect to this subsystem, or false if connecting hosts must be in the whitelist configured with spdk_nvmf_subsystem_add_host().

◆ spdk_nvmf_subsystem_get_first()

struct spdk_nvmf_subsystem* spdk_nvmf_subsystem_get_first ( struct spdk_nvmf_tgt *  tgt)

Begin iterating over all known subsystems.

If no subsystems are present, return NULL.

Parameters
tgtThe NVMe-oF target to iterate.
Returns
a pointer to the first NVMe-oF subsystem on success, or NULL on failure.

◆ spdk_nvmf_subsystem_get_first_host()

struct spdk_nvmf_host* spdk_nvmf_subsystem_get_first_host ( struct spdk_nvmf_subsystem *  subsystem)

Get the first allowed host in a subsystem.

Parameters
subsystemSubsystem to query.
Returns
first allowed host in this subsystem, or NULL if none allowed.

◆ spdk_nvmf_subsystem_get_first_listener()

struct spdk_nvmf_subsystem_listener* spdk_nvmf_subsystem_get_first_listener ( struct spdk_nvmf_subsystem *  subsystem)

Get the first allowed listen address in the subsystem.

Parameters
subsystemSubsystem to query.
Returns
first allowed listen address in this subsystem, or NULL if none allowed.

◆ spdk_nvmf_subsystem_get_first_ns()

struct spdk_nvmf_ns* spdk_nvmf_subsystem_get_first_ns ( struct spdk_nvmf_subsystem *  subsystem)

Get the first allocated namespace in a subsystem.

Parameters
subsystemSubsystem to query.
Returns
first allocated namespace in this subsystem, or NULL if this subsystem has no namespaces.

◆ spdk_nvmf_subsystem_get_max_namespaces()

uint32_t spdk_nvmf_subsystem_get_max_namespaces ( const struct spdk_nvmf_subsystem *  subsystem)

Get the maximum number of namespaces allowed in a subsystem.

Parameters
subsystemSubsystem to query.
Returns
Maximum number of namespaces allowed in the subsystem, or 0 for unlimited.

◆ spdk_nvmf_subsystem_get_max_nsid()

uint32_t spdk_nvmf_subsystem_get_max_nsid ( struct spdk_nvmf_subsystem *  subsystem)

Get maximum namespace id of the specified subsystem.

Parameters
subsystemSubsystem to query.
Returns
maximum namespace id

◆ spdk_nvmf_subsystem_get_mn()

const char* spdk_nvmf_subsystem_get_mn ( const struct spdk_nvmf_subsystem *  subsystem)

Get the model number of the specified subsystem.

Parameters
subsystemSubsystem to query.
Returns
model number of the specified subsystem.

◆ spdk_nvmf_subsystem_get_next()

struct spdk_nvmf_subsystem* spdk_nvmf_subsystem_get_next ( struct spdk_nvmf_subsystem *  subsystem)

Continue iterating over all known subsystems.

If no additional subsystems, return NULL.

Parameters
subsystemPrevious subsystem returned from spdk_nvmf_subsystem_get_first or spdk_nvmf_subsystem_get_next.
Returns
a pointer to the next NVMe-oF subsystem on success, or NULL on failure.

◆ spdk_nvmf_subsystem_get_next_host()

struct spdk_nvmf_host* spdk_nvmf_subsystem_get_next_host ( struct spdk_nvmf_subsystem *  subsystem,
struct spdk_nvmf_host *  prev_host 
)

Get the next allowed host in a subsystem.

Parameters
subsystemSubsystem to query.
prev_hostPrevious host returned from this function.
Returns
next allowed host in this subsystem, or NULL if prev_host was the last host.

◆ spdk_nvmf_subsystem_get_next_listener()

struct spdk_nvmf_subsystem_listener* spdk_nvmf_subsystem_get_next_listener ( struct spdk_nvmf_subsystem *  subsystem,
struct spdk_nvmf_subsystem_listener *  prev_listener 
)

Get the next allowed listen address in a subsystem.

Parameters
subsystemSubsystem to query.
prev_listenerPrevious listen address for this subsystem.
Returns
next allowed listen address in this subsystem, or NULL if prev_listener was the last address.

◆ spdk_nvmf_subsystem_get_next_ns()

struct spdk_nvmf_ns* spdk_nvmf_subsystem_get_next_ns ( struct spdk_nvmf_subsystem *  subsystem,
struct spdk_nvmf_ns *  prev_ns 
)

Get the next allocated namespace in a subsystem.

Parameters
subsystemSubsystem to query.
prev_nsPrevious ns returned from this function.
Returns
next allocated namespace in this subsystem, or NULL if prev_ns was the last namespace.

◆ spdk_nvmf_subsystem_get_nqn()

const char* spdk_nvmf_subsystem_get_nqn ( const struct spdk_nvmf_subsystem *  subsystem)

Get the NQN of the specified subsystem.

Parameters
subsystemSubsystem to query.
Returns
NQN of the specified subsystem.

◆ spdk_nvmf_subsystem_get_ns()

struct spdk_nvmf_ns* spdk_nvmf_subsystem_get_ns ( struct spdk_nvmf_subsystem *  subsystem,
uint32_t  nsid 
)

Get a namespace in a subsystem by NSID.

Parameters
subsystemSubsystem to search.
nsidNamespace ID to find.
Returns
namespace matching nsid, or NULL if nsid was not found.

◆ spdk_nvmf_subsystem_get_sn()

const char* spdk_nvmf_subsystem_get_sn ( const struct spdk_nvmf_subsystem *  subsystem)

Get the serial number of the specified subsystem.

Parameters
subsystemSubsystem to query.
Returns
serial number of the specified subsystem.

◆ spdk_nvmf_subsystem_get_type()

enum spdk_nvmf_subtype spdk_nvmf_subsystem_get_type ( struct spdk_nvmf_subsystem *  subsystem)

Get the type of the specified subsystem.

Parameters
subsystemSubsystem to query.
Returns
the type of the specified subsystem.

◆ spdk_nvmf_subsystem_host_allowed()

bool spdk_nvmf_subsystem_host_allowed ( struct spdk_nvmf_subsystem *  subsystem,
const char *  hostnqn 
)

Check if the given host is allowed to connect to the subsystem.

Parameters
subsystemThe subsystem to query.
hostnqnThe NQN of the host.
Returns
true if allowed, false if not.

◆ spdk_nvmf_subsystem_listener_allowed()

bool spdk_nvmf_subsystem_listener_allowed ( struct spdk_nvmf_subsystem *  subsystem,
const struct spdk_nvme_transport_id trid 
)

Check if connections originated from the given address are allowed to connect to the subsystem.

Parameters
subsystemThe subsystem to query.
tridThe listen address.
Returns
true if allowed, or false if not.

◆ spdk_nvmf_subsystem_listener_get_trid()

const struct spdk_nvme_transport_id* spdk_nvmf_subsystem_listener_get_trid ( struct spdk_nvmf_subsystem_listener *  listener)

Get a listen address' transport ID.

Parameters
listenerThis listener.
Returns
the transport ID for this listener.

◆ spdk_nvmf_subsystem_pause()

int spdk_nvmf_subsystem_pause ( struct spdk_nvmf_subsystem *  subsystem,
spdk_nvmf_subsystem_state_change_done  cb_fn,
void *  cb_arg 
)

Transition an NVMe-oF subsystem from Active to Paused state.

Parameters
subsystemThe NVMe-oF subsystem.
cb_fnA function that will be called once the subsystem has changed state.
cb_argArgument passed to cb_fn.
Returns
0 on success, or negated errno on failure. The callback provided will only be called on success.

◆ spdk_nvmf_subsystem_remove_host()

int spdk_nvmf_subsystem_remove_host ( struct spdk_nvmf_subsystem *  subsystem,
const char *  hostnqn 
)

Remove the given host NQN from the allowed hosts whitelist.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to remove host from.
hostnqnThe NQN for the host.
Returns
0 on success, or negated errno value on failure.

◆ spdk_nvmf_subsystem_remove_listener()

int spdk_nvmf_subsystem_remove_listener ( struct spdk_nvmf_subsystem *  subsystem,
const struct spdk_nvme_transport_id trid 
)

Remove the listener from subsystem.

New connections to the address won't be propagated to the subsystem. However to stop listening at target level one must use the spdk_nvmf_tgt_stop_listen().

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to remove listener from.
tridThe address to no longer accept connections from.
Returns
0 on success, or negated errno value on failure.

◆ spdk_nvmf_subsystem_remove_ns()

int spdk_nvmf_subsystem_remove_ns ( struct spdk_nvmf_subsystem *  subsystem,
uint32_t  nsid 
)

Remove a namespace from a subsytem.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem the namespace belong to.
nsidNamespace ID to be removed.
Returns
0 on success, -1 on failure.

◆ spdk_nvmf_subsystem_resume()

int spdk_nvmf_subsystem_resume ( struct spdk_nvmf_subsystem *  subsystem,
spdk_nvmf_subsystem_state_change_done  cb_fn,
void *  cb_arg 
)

Transition an NVMe-oF subsystem from Paused to Active state.

Parameters
subsystemThe NVMe-oF subsystem.
cb_fnA function that will be called once the subsystem has changed state.
cb_argArgument passed to cb_fn.
Returns
0 on success, or negated errno on failure. The callback provided will only be called on success.

◆ spdk_nvmf_subsystem_set_allow_any_host()

int spdk_nvmf_subsystem_set_allow_any_host ( struct spdk_nvmf_subsystem *  subsystem,
bool  allow_any_host 
)

Set whether a subsystem should allow any host or only hosts in the allowed list.

May only be performed on subsystems in the PAUSED or INACTIVE states.

Parameters
subsystemSubsystem to modify.
allow_any_hosttrue to allow any host to connect to this subsystem, or false to enforce the whitelist configured with spdk_nvmf_subsystem_add_host().
Returns
0 on success, or negated errno value on failure.

◆ spdk_nvmf_subsystem_set_mn()

int spdk_nvmf_subsystem_set_mn ( struct spdk_nvmf_subsystem *  subsystem,
const char *  mn 
)

Set the model number for the specified subsystem.

Parameters
subsystemSubsystem to set for.
mnmodel number to set.
Returns
0 on success, -1 on failure.

◆ spdk_nvmf_subsystem_set_sn()

int spdk_nvmf_subsystem_set_sn ( struct spdk_nvmf_subsystem *  subsystem,
const char *  sn 
)

Set the serial number for the specified subsystem.

Parameters
subsystemSubsystem to set for.
snserial number to set.
Returns
0 on success, -1 on failure.

◆ spdk_nvmf_subsystem_start()

int spdk_nvmf_subsystem_start ( struct spdk_nvmf_subsystem *  subsystem,
spdk_nvmf_subsystem_state_change_done  cb_fn,
void *  cb_arg 
)

Transition an NVMe-oF subsystem from Inactive to Active state.

Parameters
subsystemThe NVMe-oF subsystem.
cb_fnA function that will be called once the subsystem has changed state.
cb_argArgument passed to cb_fn.
Returns
0 on success, or negated errno on failure. The callback provided will only be called on success.

◆ spdk_nvmf_subsystem_stop()

int spdk_nvmf_subsystem_stop ( struct spdk_nvmf_subsystem *  subsystem,
spdk_nvmf_subsystem_state_change_done  cb_fn,
void *  cb_arg 
)

Transition an NVMe-oF subsystem from Active to Inactive state.

Parameters
subsystemThe NVMe-oF subsystem.
cb_fnA function that will be called once the subsystem has changed state.
cb_argArgument passed to cb_fn.
Returns
0 on success, or negated errno on failure. The callback provided will only be called on success.

◆ spdk_nvmf_subsytem_any_listener_allowed()

bool spdk_nvmf_subsytem_any_listener_allowed ( struct spdk_nvmf_subsystem *  subsystem)

Check whether a subsystem allows any listen address or only addresses in the allowed list.

Parameters
subsystemSubsystem to query.
Returns
true if this subsystem allows dynamic management of listen address list, or false if only allows addresses in the whitelist configured during subsystem setup.

◆ spdk_nvmf_tgt_accept()

void spdk_nvmf_tgt_accept ( struct spdk_nvmf_tgt *  tgt,
new_qpair_fn  cb_fn,
void *  cb_arg 
)

Poll the target for incoming connections.

The new_qpair_fn cb_fn will be called for each newly discovered qpair. The user is expected to add that qpair to a poll group to establish the connection.

Parameters
tgtThe target associated with the listen address.
cb_fnCalled for each newly discovered qpair.
cb_argA context argument passed to cb_fn.

◆ spdk_nvmf_tgt_add_transport()

void spdk_nvmf_tgt_add_transport ( struct spdk_nvmf_tgt *  tgt,
struct spdk_nvmf_transport transport,
spdk_nvmf_tgt_add_transport_done_fn  cb_fn,
void *  cb_arg 
)

Add a transport to a target.

Parameters
tgtThe NVMe-oF target
transportThe transport to add
cb_fnA callback that will be called once the transport is created
cb_argA context argument passed to cb_fn.
Returns
void. The callback status argument will be 0 on success or a negated errno on failure.

◆ spdk_nvmf_tgt_create()

struct spdk_nvmf_tgt* spdk_nvmf_tgt_create ( struct spdk_nvmf_target_opts opts)

Construct an NVMe-oF target.

Parameters
optsa pointer to an spdk_nvmf_target_opts structure.
Returns
a pointer to a NVMe-oF target on success, or NULL on failure.

◆ spdk_nvmf_tgt_destroy()

void spdk_nvmf_tgt_destroy ( struct spdk_nvmf_tgt *  tgt,
spdk_nvmf_tgt_destroy_done_fn  cb_fn,
void *  cb_arg 
)

Destroy an NVMe-oF target.

Parameters
tgtThe target to destroy. This releases all resources.
cb_fnA callback that will be called once the target is destroyed
cb_argA context argument passed to cb_fn.

◆ spdk_nvmf_tgt_find_subsystem()

struct spdk_nvmf_subsystem* spdk_nvmf_tgt_find_subsystem ( struct spdk_nvmf_tgt *  tgt,
const char *  subnqn 
)

Search the target for a subsystem with the given NQN.

Parameters
tgtThe NVMe-oF target to search from.
subnqnNQN of the subsystem.
Returns
a pointer to the NVMe-oF subsystem on success, or NULL on failure.

◆ spdk_nvmf_tgt_get_name()

const char* spdk_nvmf_tgt_get_name ( struct spdk_nvmf_tgt *  tgt)

Get the name of an NVMe-oF target.

Parameters
tgtThe target from which to get the name.
Returns
The name of the target as a null terminated string.

◆ spdk_nvmf_tgt_get_transport()

struct spdk_nvmf_transport* spdk_nvmf_tgt_get_transport ( struct spdk_nvmf_tgt *  tgt,
const char *  transport_name 
)

Get an existing transport from the target.

Parameters
tgtThe NVMe-oF target
transport_nameThe name of the transport type to get.
Returns
the transport or NULL if not found

◆ spdk_nvmf_tgt_listen()

int spdk_nvmf_tgt_listen ( struct spdk_nvmf_tgt *  tgt,
struct spdk_nvme_transport_id trid 
)

Begin accepting new connections at the address provided.

The connections will be matched with a subsystem, which may or may not allow the connection based on a subsystem-specific whitelist. See spdk_nvmf_subsystem_add_host() and spdk_nvmf_subsystem_add_listener()

Parameters
tgtThe target associated with this listen address.
tridThe address to listen at.
Returns
0 on success or a negated errno on failure.

◆ spdk_nvmf_tgt_stop_listen()

int spdk_nvmf_tgt_stop_listen ( struct spdk_nvmf_tgt *  tgt,
struct spdk_nvme_transport_id trid 
)

Stop accepting new connections at the provided address.

This is a counterpart to spdk_nvmf_tgt_listen().

Parameters
tgtThe target associated with the listen address.
tridThe address to stop listening at.
Returns
int. 0 on success or a negated errno on failure.

◆ spdk_nvmf_tgt_transport_write_config_json()

void spdk_nvmf_tgt_transport_write_config_json ( struct spdk_json_write_ctx *  w,
struct spdk_nvmf_tgt *  tgt 
)

Write NVMe-oF target's transport configurations into provided JSON context.

Parameters
wJSON write context
tgtThe NVMe-oF target

◆ spdk_nvmf_tgt_write_config_json()

void spdk_nvmf_tgt_write_config_json ( struct spdk_json_write_ctx *  w,
struct spdk_nvmf_tgt *  tgt 
)

Write NVMe-oF target configuration into provided JSON context.

Parameters
wJSON write context
tgtThe NVMe-oF target

◆ spdk_nvmf_transport_create()

struct spdk_nvmf_transport* spdk_nvmf_transport_create ( const char *  transport_name,
struct spdk_nvmf_transport_opts opts 
)

Create a protocol transport.

Parameters
transport_nameThe transport type to create
optsThe transport options (e.g. max_io_size)
Returns
new transport or NULL if create fails

◆ spdk_nvmf_transport_destroy()

int spdk_nvmf_transport_destroy ( struct spdk_nvmf_transport transport)

Destroy a protocol transport.

Parameters
transportThe transport to destory
Returns
0 on success, -1 on failure.

◆ spdk_nvmf_transport_get_first()

struct spdk_nvmf_transport* spdk_nvmf_transport_get_first ( struct spdk_nvmf_tgt *  tgt)

Get the first transport registered with the given target.

Parameters
tgtThe NVMe-oF target
Returns
The first transport registered on the target

◆ spdk_nvmf_transport_get_next()

struct spdk_nvmf_transport* spdk_nvmf_transport_get_next ( struct spdk_nvmf_transport transport)

Get the next transport in a target's list.

Parameters
transportA handle to a transport object
Returns
The next transport associated with the NVMe-oF target

◆ spdk_nvmf_transport_listen()

int spdk_nvmf_transport_listen ( struct spdk_nvmf_transport transport,
const struct spdk_nvme_transport_id trid 
)

Add listener to transport and begin accepting new connections.

Parameters
transportThe transport to add listener to
tridAddress to listen at
Returns
int. 0 if it completed successfully, or negative errno if it failed.

◆ spdk_nvmf_transport_opts_init()

bool spdk_nvmf_transport_opts_init ( const char *  transport_name,
struct spdk_nvmf_transport_opts opts 
)

Initialize transport options.

Parameters
transport_nameThe transport type to create
optsThe transport options (e.g. max_io_size)
Returns
bool. true if successful, false if transport type not found.

◆ spdk_nvmf_transport_poll_group_free_stat()

void spdk_nvmf_transport_poll_group_free_stat ( struct spdk_nvmf_transport transport,
struct spdk_nvmf_transport_poll_group_stat stat 
)

Free statistics memory previously allocated with spdk_nvmf_transport_poll_group_get_stat().

Parameters
transportThe NVMf transport.
statPointer to transport poll group statistics structure.

◆ spdk_nvmf_transport_poll_group_get_stat()

int spdk_nvmf_transport_poll_group_get_stat ( struct spdk_nvmf_tgt *  tgt,
struct spdk_nvmf_transport transport,
struct spdk_nvmf_transport_poll_group_stat **  stat 
)

Get current transport poll group statistics.

This function allocates memory for statistics and returns it in stat parameter. Caller must free this memory with spdk_nvmf_transport_poll_group_free_stat() when it is not needed anymore.

Parameters
tgtThe NVMf target.
transportThe NVMf transport.
statOutput parameter that will contain pointer to allocated statistics structure.
Returns
0 upon success.
-ENOTSUP if transport does not support statistics.
-EINVAL if any of parameters is NULL.
-ENOENT if transport poll group is not found.
-ENOMEM if memory allocation failed.

◆ spdk_nvmf_transport_stop_listen()

int spdk_nvmf_transport_stop_listen ( struct spdk_nvmf_transport transport,
const struct spdk_nvme_transport_id trid 
)

Remove listener from transport and stop accepting new connections.

Parameters
transportThe transport to remove listener from
tridAddress to stop listen at
Returns
int. 0 if it completed successfully, or negative errno if it failed.