Loading...
Searching...
No Matches
nvme.h File Reference

Nvme block device abstraction layer. More...

Data Structures

struct  spdk_bdev_nvme_ctrlr_opts
 
struct  spdk_bdev_nvme_opts
 

Typedefs

typedef void(* spdk_bdev_nvme_create_cb) (void *ctx, size_t bdev_count, int rc)
 
typedef void(* spdk_bdev_nvme_set_multipath_policy_cb) (void *cb_arg, int rc)
 
typedef void(* spdk_bdev_nvme_delete_cb) (void *ctx, int rc)
 

Enumerations

enum  spdk_bdev_nvme_multipath_policy { SPDK_BDEV_NVME_MULTIPATH_POLICY_ACTIVE_PASSIVE , SPDK_BDEV_NVME_MULTIPATH_POLICY_ACTIVE_ACTIVE }
 
enum  spdk_bdev_nvme_multipath_selector { SPDK_BDEV_NVME_MULTIPATH_SELECTOR_ROUND_ROBIN = 1 , SPDK_BDEV_NVME_MULTIPATH_SELECTOR_QUEUE_DEPTH }
 
enum  spdk_bdev_timeout_action { SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE = 0 , SPDK_BDEV_NVME_TIMEOUT_ACTION_RESET , SPDK_BDEV_NVME_TIMEOUT_ACTION_ABORT }
 

Functions

 SPDK_STATIC_ASSERT (sizeof(struct spdk_bdev_nvme_opts)==136, "Incorrect size")
 
int spdk_bdev_nvme_create (struct spdk_nvme_transport_id *trid, const char *base_name, const char **names, uint32_t count, spdk_bdev_nvme_create_cb cb_fn, void *cb_ctx, struct spdk_nvme_ctrlr_opts *drv_opts, struct spdk_bdev_nvme_ctrlr_opts *bdev_opts)
 Connect to the NVMe controller and populate namespaces as bdevs.
 
int spdk_bdev_nvme_delete (const char *name, const struct spdk_nvme_path_id *path_id, spdk_bdev_nvme_delete_cb delete_cb, void *cb_ctx)
 Delete the specified NVMe controller, or one of its paths.
 
void spdk_bdev_nvme_set_multipath_policy (const char *name, enum spdk_bdev_nvme_multipath_policy policy, enum spdk_bdev_nvme_multipath_selector selector, uint32_t rr_min_io, spdk_bdev_nvme_set_multipath_policy_cb cb_fn, void *cb_arg)
 Set multipath policy of the NVMe bdev.
 
void spdk_bdev_nvme_get_default_ctrlr_opts (struct spdk_bdev_nvme_ctrlr_opts *opts)
 
void spdk_bdev_nvme_get_opts (struct spdk_bdev_nvme_opts *opts, size_t opts_size)
 Get the default value for bdev nvme options.
 
int spdk_bdev_nvme_set_opts (const struct spdk_bdev_nvme_opts *opts)
 Set the bdev nvme options.
 
struct spdk_bdev_nvme_ctrlr * spdk_bdev_nvme_first_bdev_ctrlr (void)
 Get the first bdev_nvme controller group.
 
struct spdk_bdev_nvme_ctrlr * spdk_bdev_nvme_next_bdev_ctrlr (struct spdk_bdev_nvme_ctrlr *prev)
 Get the next bdev_nvme controller group.
 
const char * spdk_bdev_nvme_ctrlr_get_name (struct spdk_bdev_nvme_ctrlr *nbdev_ctrlr)
 Get the name of a bdev_nvme controller group.
 
struct spdk_nvme_ctrlr * spdk_bdev_nvme_ctrlr_first_ctrlr (struct spdk_bdev_nvme_ctrlr *nbdev_ctrlr)
 Get the first NVMe controller within a bdev_nvme controller group.
 
struct spdk_nvme_ctrlr * spdk_bdev_nvme_ctrlr_next_ctrlr (struct spdk_bdev_nvme_ctrlr *nbdev_ctrlr, struct spdk_nvme_ctrlr *prev)
 Get the next NVMe controller within a bdev_nvme controller group.
 
const struct spdk_bdev_nvme_ctrlr_optsspdk_bdev_nvme_ctrlr_get_opts (struct spdk_bdev_nvme_ctrlr *nbdev_ctrlr, struct spdk_nvme_ctrlr *ctrlr)
 Get the controller opts.
 

Detailed Description

Nvme block device abstraction layer.

Function Documentation

◆ spdk_bdev_nvme_create()

int spdk_bdev_nvme_create ( struct spdk_nvme_transport_id * trid,
const char * base_name,
const char ** names,
uint32_t count,
spdk_bdev_nvme_create_cb cb_fn,
void * cb_ctx,
struct spdk_nvme_ctrlr_opts * drv_opts,
struct spdk_bdev_nvme_ctrlr_opts * bdev_opts )

Connect to the NVMe controller and populate namespaces as bdevs.

Parameters
tridTransport ID for nvme controller.
base_nameBase name for the nvme subsystem.
namesPointer to string array to get bdev names.
countMaximum count of the string array 'names'. Restricts the length of 'names' array only, not the count of bdevs created.
cb_fnCallback function to be called after all the bdevs are created or updated if already created.
cb_ctxContext to pass to cb_fn.
drv_optsNVMe driver options.
bdev_optsNVMe bdev options.
Returns
0 on success, negative errno on failure.

◆ spdk_bdev_nvme_ctrlr_first_ctrlr()

struct spdk_nvme_ctrlr * spdk_bdev_nvme_ctrlr_first_ctrlr ( struct spdk_bdev_nvme_ctrlr * nbdev_ctrlr)

Get the first NVMe controller within a bdev_nvme controller group.

Must be called from the app thread.

Warning
The returned pointer is valid only while the controller is attached. Do not hold references across operations that may disconnect controllers.
Parameters
nbdev_ctrlrController group handle.
Returns
Pointer to the first spdk_nvme_ctrlr, or NULL if none.

◆ spdk_bdev_nvme_ctrlr_get_name()

const char * spdk_bdev_nvme_ctrlr_get_name ( struct spdk_bdev_nvme_ctrlr * nbdev_ctrlr)

Get the name of a bdev_nvme controller group.

Must be called from the app thread.

Warning
The returned string is valid only while the controller group exists.
Parameters
nbdev_ctrlrController group handle.
Returns
Name string.

◆ spdk_bdev_nvme_ctrlr_get_opts()

const struct spdk_bdev_nvme_ctrlr_opts * spdk_bdev_nvme_ctrlr_get_opts ( struct spdk_bdev_nvme_ctrlr * nbdev_ctrlr,
struct spdk_nvme_ctrlr * ctrlr )

Get the controller opts.

Returns creation time controller configuration.

Must be called from the app thread.

Warning
The returned pointer is valid only while the controller is attached. Do not hold references across operations that may disconnect controllers.
Parameters
nbdev_ctrlrController group handle.
ctrlrController handle (optional); if not provided opts are retrived from the first.
Returns
Pointer to the options, or NULL if the controller group is invalid.

◆ spdk_bdev_nvme_ctrlr_next_ctrlr()

struct spdk_nvme_ctrlr * spdk_bdev_nvme_ctrlr_next_ctrlr ( struct spdk_bdev_nvme_ctrlr * nbdev_ctrlr,
struct spdk_nvme_ctrlr * prev )

Get the next NVMe controller within a bdev_nvme controller group.

Must be called from the app thread.

Warning
The returned pointer is valid only while the controller is attached. Do not hold references across operations that may disconnect controllers.
Parameters
nbdev_ctrlrController group handle.
prevPrevious spdk_nvme_ctrlr returned by first_ctrlr or next_ctrlr.
Returns
Pointer to the next spdk_nvme_ctrlr, or NULL if no more.

◆ spdk_bdev_nvme_delete()

int spdk_bdev_nvme_delete ( const char * name,
const struct spdk_nvme_path_id * path_id,
spdk_bdev_nvme_delete_cb delete_cb,
void * cb_ctx )

Delete the specified NVMe controller, or one of its paths.

NOTE: When path_id is specified and it is the only path_id associated with NVMe controller the path is removed and the NVMe controller gets deleted. (Optional) callback function gets executed on delete complete in caller's thread. When the (optional) callback is not provided, the control is returned back at the time delete is initiated, not when it is completed. When NVMe controller deletion is already in progress state, this function returns success.

Parameters
nameNVMe controller name.
path_idThe specified path to remove (optional).
delete_cbCallback function on delete complete (optional).
cb_ctxContext passed to callback (optional).
Returns
zero on success, -EINVAL on wrong parameters or -ENODEV if controller is not found or -ENOMEM on no memory

◆ spdk_bdev_nvme_first_bdev_ctrlr()

struct spdk_bdev_nvme_ctrlr * spdk_bdev_nvme_first_bdev_ctrlr ( void )

Get the first bdev_nvme controller group.

Must be called from the app thread.

Warning
The returned handle is valid only while the controller group exists. Do not hold references across operations that may add or remove controller groups.
Returns
Pointer to the first controller group, or NULL if none.

◆ spdk_bdev_nvme_get_opts()

void spdk_bdev_nvme_get_opts ( struct spdk_bdev_nvme_opts * opts,
size_t opts_size )

Get the default value for bdev nvme options.

Parameters
[out]optsBdev nvme options object to be filled with default values.
opts_sizeMust be set to sizeof(struct spdk_bdev_nvme_opts).

◆ spdk_bdev_nvme_next_bdev_ctrlr()

struct spdk_bdev_nvme_ctrlr * spdk_bdev_nvme_next_bdev_ctrlr ( struct spdk_bdev_nvme_ctrlr * prev)

Get the next bdev_nvme controller group.

Must be called from the app thread.

Warning
The returned handle is valid only while the controller group exists. Do not hold references across operations that may add or remove controller groups.
Parameters
prevPrevious controller group returned by first or next.
Returns
Pointer to the next controller group, or NULL if no more.

◆ spdk_bdev_nvme_set_multipath_policy()

void spdk_bdev_nvme_set_multipath_policy ( const char * name,
enum spdk_bdev_nvme_multipath_policy policy,
enum spdk_bdev_nvme_multipath_selector selector,
uint32_t rr_min_io,
spdk_bdev_nvme_set_multipath_policy_cb cb_fn,
void * cb_arg )

Set multipath policy of the NVMe bdev.

Deprecated
Use spdk_bdev_nvme_create() with multipath options instead.

Subsequent calls for the same bdev must wait until the current execution finishes.

Parameters
nameNVMe bdev name.
policyMultipath policy (active-passive or active-active).
selectorMultipath selector (round_robin, queue_depth).
rr_min_ioNumber of IO to route to a path before switching to another for round-robin.
cb_fnFunction to be called back after completion.
cb_argArgument passed to the callback function.

◆ spdk_bdev_nvme_set_opts()

int spdk_bdev_nvme_set_opts ( const struct spdk_bdev_nvme_opts * opts)

Set the bdev nvme options.

Parameters
optsNew value of bdev nvme options to be set.
Returns
0 on success, negative errno on failure.