2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2016 Intel Corporation. All rights reserved.
|
2020-12-02 16:46:09 +00:00
|
|
|
* Copyright (c) 2018-2021 Mellanox Technologies LTD. All rights reserved.
|
2021-03-03 08:48:19 +00:00
|
|
|
* Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
2016-09-19 17:01:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* NVMe over Fabrics target public API
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_NVMF_H
|
|
|
|
#define SPDK_NVMF_H
|
|
|
|
|
2017-05-01 20:22:48 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2016-10-31 22:43:02 +00:00
|
|
|
#include "spdk/env.h"
|
2017-07-13 19:36:44 +00:00
|
|
|
#include "spdk/nvme.h"
|
2016-09-19 17:01:52 +00:00
|
|
|
#include "spdk/nvmf_spec.h"
|
|
|
|
#include "spdk/queue.h"
|
2018-02-22 00:09:56 +00:00
|
|
|
#include "spdk/uuid.h"
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2017-12-07 20:25:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-08-15 17:34:12 +00:00
|
|
|
#define NVMF_TGT_NAME_MAX_LENGTH 256
|
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
struct spdk_nvmf_tgt;
|
2017-11-29 20:46:00 +00:00
|
|
|
struct spdk_nvmf_subsystem;
|
|
|
|
struct spdk_nvmf_ctrlr;
|
|
|
|
struct spdk_nvmf_qpair;
|
|
|
|
struct spdk_nvmf_request;
|
|
|
|
struct spdk_bdev;
|
|
|
|
struct spdk_nvmf_request;
|
|
|
|
struct spdk_nvmf_host;
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener;
|
2017-11-29 20:46:00 +00:00
|
|
|
struct spdk_nvmf_poll_group;
|
2018-05-07 18:26:13 +00:00
|
|
|
struct spdk_json_write_ctx;
|
2020-06-03 14:03:03 +00:00
|
|
|
struct spdk_json_val;
|
2018-08-22 23:04:16 +00:00
|
|
|
struct spdk_nvmf_transport;
|
2017-08-18 22:38:33 +00:00
|
|
|
|
2021-08-12 16:01:39 +00:00
|
|
|
/**
|
|
|
|
* Specify filter rules which are applied during discovery log generation.
|
|
|
|
*/
|
|
|
|
enum spdk_nvmf_tgt_discovery_filter {
|
|
|
|
/** Log all listeners in discovery log page */
|
|
|
|
SPDK_NVMF_TGT_DISCOVERY_MATCH_ANY = 0,
|
|
|
|
/** Only log listeners with the same transport type on which the DISCOVERY command was received */
|
|
|
|
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_TYPE = 1u << 0u,
|
|
|
|
/** Only log listeners with the same transport address on which the DISCOVERY command was received */
|
|
|
|
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_ADDRESS = 1u << 1u,
|
|
|
|
/** Only log listeners with the same transport svcid on which the DISCOVERY command was received */
|
|
|
|
SPDK_NVMF_TGT_DISCOVERY_MATCH_TRANSPORT_SVCID = 1u << 2u
|
|
|
|
};
|
|
|
|
|
2019-08-15 16:12:46 +00:00
|
|
|
struct spdk_nvmf_target_opts {
|
2019-08-15 17:34:12 +00:00
|
|
|
char name[NVMF_TGT_NAME_MAX_LENGTH];
|
2019-08-15 16:12:46 +00:00
|
|
|
uint32_t max_subsystems;
|
2021-05-24 04:22:43 +00:00
|
|
|
uint16_t crdt[3];
|
2021-08-12 16:01:39 +00:00
|
|
|
enum spdk_nvmf_tgt_discovery_filter discovery_filter;
|
2019-08-15 16:12:46 +00:00
|
|
|
};
|
|
|
|
|
2018-08-22 23:04:16 +00:00
|
|
|
struct spdk_nvmf_transport_opts {
|
2019-04-26 21:25:20 +00:00
|
|
|
uint16_t max_queue_depth;
|
|
|
|
uint16_t max_qpairs_per_ctrlr;
|
|
|
|
uint32_t in_capsule_data_size;
|
2021-02-10 14:44:21 +00:00
|
|
|
/* used to calculate mdts */
|
2019-04-26 21:25:20 +00:00
|
|
|
uint32_t max_io_size;
|
|
|
|
uint32_t io_unit_size;
|
|
|
|
uint32_t max_aq_depth;
|
|
|
|
uint32_t num_shared_buffers;
|
|
|
|
uint32_t buf_cache_size;
|
2019-06-26 07:45:25 +00:00
|
|
|
bool dif_insert_or_strip;
|
2020-06-03 14:03:03 +00:00
|
|
|
|
2022-08-17 22:24:28 +00:00
|
|
|
/* Hole at bytes 29-31. */
|
|
|
|
uint8_t reserved29[3];
|
|
|
|
|
2020-07-09 01:50:03 +00:00
|
|
|
uint32_t abort_timeout_sec;
|
2020-08-20 05:54:03 +00:00
|
|
|
/* ms */
|
2020-06-21 07:47:34 +00:00
|
|
|
uint32_t association_timeout;
|
2020-06-03 14:03:03 +00:00
|
|
|
|
|
|
|
const struct spdk_json_val *transport_specific;
|
2020-11-26 16:48:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The size of spdk_nvmf_transport_opts according to the caller of this library is used for ABI
|
|
|
|
* compatibility. The library uses this field to know how many fields in this
|
|
|
|
* structure are valid. And the library will populate any remaining fields with default values.
|
2020-12-18 16:53:03 +00:00
|
|
|
* New added fields should be put at the end of the struct.
|
2020-11-26 16:48:10 +00:00
|
|
|
*/
|
|
|
|
size_t opts_size;
|
2021-11-25 22:08:12 +00:00
|
|
|
uint32_t acceptor_poll_rate;
|
2021-11-24 14:42:24 +00:00
|
|
|
/* Use zero-copy operations if the underlying bdev supports them */
|
|
|
|
bool zcopy;
|
2022-08-17 22:24:28 +00:00
|
|
|
|
|
|
|
/* Hole at bytes 61-63. */
|
|
|
|
uint8_t reserved61[3];
|
|
|
|
} __attribute__((packed));
|
2022-08-17 20:09:55 +00:00
|
|
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_transport_opts) == 64, "Incorrect size");
|
2018-08-22 23:04:16 +00:00
|
|
|
|
2020-12-18 19:12:49 +00:00
|
|
|
struct spdk_nvmf_listen_opts {
|
|
|
|
/**
|
|
|
|
* The size of spdk_nvmf_listen_opts according to the caller of this library is used for ABI
|
|
|
|
* compatibility. The library uses this field to know how many fields in this
|
|
|
|
* structure are valid. And the library will populate any remaining fields with default values.
|
|
|
|
* New added fields should be put at the end of the struct.
|
|
|
|
*/
|
|
|
|
size_t opts_size;
|
|
|
|
|
|
|
|
const struct spdk_json_val *transport_specific;
|
2022-08-17 22:24:28 +00:00
|
|
|
} __attribute__((packed));
|
2022-08-17 20:09:55 +00:00
|
|
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_listen_opts) == 16, "Incorrect size");
|
2020-12-18 19:12:49 +00:00
|
|
|
|
2020-12-21 13:07:39 +00:00
|
|
|
/**
|
|
|
|
* Initialize listen options
|
|
|
|
*
|
|
|
|
* \param opts Listener options.
|
|
|
|
* \param opts_size Must be set to sizeof(struct spdk_nvmf_listen_opts).
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_listen_opts_init(struct spdk_nvmf_listen_opts *opts, size_t opts_size);
|
|
|
|
|
2019-04-15 09:54:38 +00:00
|
|
|
struct spdk_nvmf_poll_group_stat {
|
2021-05-20 01:44:00 +00:00
|
|
|
/* cumulative admin qpair count */
|
2019-05-22 19:12:35 +00:00
|
|
|
uint32_t admin_qpairs;
|
2021-05-20 01:44:00 +00:00
|
|
|
/* cumulative io qpair count */
|
2019-05-22 19:12:35 +00:00
|
|
|
uint32_t io_qpairs;
|
2021-05-20 01:44:00 +00:00
|
|
|
/* current admin qpair count */
|
|
|
|
uint32_t current_admin_qpairs;
|
|
|
|
/* current io qpair count */
|
|
|
|
uint32_t current_io_qpairs;
|
2019-05-22 19:25:34 +00:00
|
|
|
uint64_t pending_bdev_io;
|
2022-12-13 23:13:12 +00:00
|
|
|
/* NVMe IO commands completed (excludes admin commands) */
|
|
|
|
uint64_t completed_nvme_io;
|
2019-04-15 09:54:38 +00:00
|
|
|
};
|
|
|
|
|
2020-02-05 21:17:40 +00:00
|
|
|
/**
|
2020-07-09 21:57:37 +00:00
|
|
|
* Function to be called once asynchronous listen add and remove
|
|
|
|
* operations are completed. See spdk_nvmf_subsystem_add_listener()
|
|
|
|
* and spdk_nvmf_transport_stop_listen_async().
|
2020-02-05 21:17:40 +00:00
|
|
|
*
|
|
|
|
* \param ctx Context argument passed to this function.
|
|
|
|
* \param status 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
typedef void (*spdk_nvmf_tgt_subsystem_listen_done_fn)(void *ctx, int status);
|
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Construct an NVMe-oF target.
|
|
|
|
*
|
2019-08-15 20:51:08 +00:00
|
|
|
* \param opts a pointer to an spdk_nvmf_target_opts structure.
|
2017-08-18 22:38:33 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return a pointer to a NVMe-oF target on success, or NULL on failure.
|
2017-08-18 22:38:33 +00:00
|
|
|
*/
|
2019-08-15 20:51:08 +00:00
|
|
|
struct spdk_nvmf_tgt *spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts);
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2018-06-05 22:34:04 +00:00
|
|
|
typedef void (spdk_nvmf_tgt_destroy_done_fn)(void *ctx, int status);
|
|
|
|
|
2017-08-18 22:38:33 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Destroy an NVMe-oF target.
|
2017-08-18 22:38:33 +00:00
|
|
|
*
|
|
|
|
* \param tgt The target to destroy. This releases all resources.
|
2018-06-18 14:39:39 +00:00
|
|
|
* \param cb_fn A callback that will be called once the target is destroyed
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
2017-08-18 22:38:33 +00:00
|
|
|
*/
|
2018-06-05 22:34:04 +00:00
|
|
|
void spdk_nvmf_tgt_destroy(struct spdk_nvmf_tgt *tgt,
|
|
|
|
spdk_nvmf_tgt_destroy_done_fn cb_fn,
|
|
|
|
void *cb_arg);
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2019-09-13 18:09:07 +00:00
|
|
|
/**
|
|
|
|
* Get the name of an NVMe-oF target.
|
|
|
|
*
|
|
|
|
* \param tgt The target from which to get the name.
|
|
|
|
*
|
|
|
|
* \return The name of the target as a null terminated string.
|
|
|
|
*/
|
|
|
|
const char *spdk_nvmf_tgt_get_name(struct spdk_nvmf_tgt *tgt);
|
|
|
|
|
2019-08-15 18:32:11 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* \param name The name provided when the target was created.
|
|
|
|
*
|
|
|
|
* \return The target with the given name, or NULL if no match was found.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_tgt *spdk_nvmf_get_tgt(const char *name);
|
|
|
|
|
2019-09-13 18:09:07 +00:00
|
|
|
/**
|
|
|
|
* Get the pointer to the first NVMe-oF target.
|
|
|
|
*
|
|
|
|
* Combined with spdk_nvmf_get_next_tgt to iterate over all available targets.
|
|
|
|
*
|
|
|
|
* \return The first NVMe-oF target.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_tgt *spdk_nvmf_get_first_tgt(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the pointer to the first NVMe-oF target.
|
|
|
|
*
|
|
|
|
* Combined with spdk_nvmf_get_first_tgt to iterate over all available targets.
|
|
|
|
*
|
|
|
|
* \param prev A pointer to the last NVMe-oF target.
|
|
|
|
*
|
|
|
|
* \return The first NVMe-oF target.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_tgt *spdk_nvmf_get_next_tgt(struct spdk_nvmf_tgt *prev);
|
|
|
|
|
2018-05-07 18:26:13 +00:00
|
|
|
/**
|
|
|
|
* Write NVMe-oF target configuration into provided JSON context.
|
|
|
|
* \param w JSON write context
|
|
|
|
* \param tgt The NVMe-oF target
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_tgt_write_config_json(struct spdk_json_write_ctx *w, struct spdk_nvmf_tgt *tgt);
|
|
|
|
|
2020-12-18 19:12:49 +00:00
|
|
|
/**
|
|
|
|
* 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 list of allowed hosts. See
|
|
|
|
* spdk_nvmf_subsystem_add_host() and spdk_nvmf_subsystem_add_listener()
|
|
|
|
*
|
|
|
|
* \param tgt The target associated with this listen address.
|
|
|
|
* \param trid The address to listen at.
|
|
|
|
* \param opts Listener options.
|
|
|
|
*
|
|
|
|
* \return 0 on success or a negated errno on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_tgt_listen_ext(struct spdk_nvmf_tgt *tgt, const struct spdk_nvme_transport_id *trid,
|
|
|
|
struct spdk_nvmf_listen_opts *opts);
|
|
|
|
|
2020-01-02 19:00:45 +00:00
|
|
|
/**
|
|
|
|
* Stop accepting new connections at the provided address.
|
|
|
|
*
|
2021-03-02 13:53:06 +00:00
|
|
|
* This is a counterpart to spdk_nvmf_tgt_listen_ext().
|
2020-01-02 19:00:45 +00:00
|
|
|
*
|
|
|
|
* \param tgt The target associated with the listen address.
|
|
|
|
* \param trid The address to stop listening at.
|
|
|
|
*
|
|
|
|
* \return int. 0 on success or a negated errno on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_tgt_stop_listen(struct spdk_nvmf_tgt *tgt,
|
|
|
|
struct spdk_nvme_transport_id *trid);
|
|
|
|
|
2017-09-25 22:27:01 +00:00
|
|
|
/**
|
|
|
|
* Create a poll group.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \param tgt The target to create a poll group.
|
|
|
|
*
|
|
|
|
* \return a poll group on success, or NULL on failure.
|
2017-09-25 22:27:01 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_poll_group *spdk_nvmf_poll_group_create(struct spdk_nvmf_tgt *tgt);
|
|
|
|
|
2019-05-15 12:40:12 +00:00
|
|
|
/**
|
|
|
|
* Get optimal nvmf poll group for the qpair.
|
|
|
|
*
|
|
|
|
* \param qpair Requested qpair
|
|
|
|
*
|
|
|
|
* \return a poll group on success, or NULL on failure.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_poll_group *spdk_nvmf_get_optimal_poll_group(struct spdk_nvmf_qpair *qpair);
|
|
|
|
|
2020-02-13 10:03:16 +00:00
|
|
|
typedef void(*spdk_nvmf_poll_group_destroy_done_fn)(void *cb_arg, int status);
|
|
|
|
|
2017-09-25 22:27:01 +00:00
|
|
|
/**
|
|
|
|
* Destroy a poll group.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \param group The poll group to destroy.
|
2020-02-13 10:03:16 +00:00
|
|
|
* \param cb_fn A callback that will be called once the poll group is destroyed.
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
2017-09-25 22:27:01 +00:00
|
|
|
*/
|
2020-02-13 10:03:16 +00:00
|
|
|
void spdk_nvmf_poll_group_destroy(struct spdk_nvmf_poll_group *group,
|
|
|
|
spdk_nvmf_poll_group_destroy_done_fn cb_fn,
|
|
|
|
void *cb_arg);
|
2017-09-25 22:27:01 +00:00
|
|
|
|
2017-11-29 20:49:30 +00:00
|
|
|
/**
|
|
|
|
* Add the given qpair to the poll group.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \param group The group to add qpair to.
|
|
|
|
* \param qpair The qpair to add.
|
|
|
|
*
|
|
|
|
* \return 0 on success, -1 on failure.
|
2017-11-29 20:49:30 +00:00
|
|
|
*/
|
|
|
|
int spdk_nvmf_poll_group_add(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_qpair *qpair);
|
|
|
|
|
2018-06-29 19:09:47 +00:00
|
|
|
typedef void (*nvmf_qpair_disconnect_cb)(void *ctx);
|
|
|
|
|
2018-06-14 17:34:04 +00:00
|
|
|
/**
|
|
|
|
* Disconnect an NVMe-oF qpair
|
|
|
|
*
|
|
|
|
* \param qpair The NVMe-oF qpair to disconnect.
|
2018-06-29 19:09:47 +00:00
|
|
|
* \param cb_fn The function to call upon completion of the disconnect.
|
|
|
|
* \param ctx The context to pass to the callback function.
|
|
|
|
*
|
|
|
|
* \return 0 upon success.
|
|
|
|
* \return -ENOMEM if the function specific context could not be allocated.
|
2018-06-14 17:34:04 +00:00
|
|
|
*/
|
2018-06-29 19:09:47 +00:00
|
|
|
int spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn,
|
|
|
|
void *ctx);
|
2018-06-14 17:34:04 +00:00
|
|
|
|
2018-08-02 22:08:12 +00:00
|
|
|
/**
|
|
|
|
* Get the peer's transport ID for this queue pair.
|
|
|
|
*
|
|
|
|
* \param qpair The NVMe-oF qpair
|
|
|
|
* \param trid Output parameter that will contain the transport id.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -EINVAL if the qpair is not connected.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_qpair_get_peer_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid);
|
|
|
|
|
2018-09-10 21:28:04 +00:00
|
|
|
/**
|
|
|
|
* Get the local transport ID for this queue pair.
|
|
|
|
*
|
|
|
|
* \param qpair The NVMe-oF qpair
|
|
|
|
* \param trid Output parameter that will contain the transport id.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -EINVAL if the qpair is not connected.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_qpair_get_local_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid);
|
|
|
|
|
2018-09-07 20:41:41 +00:00
|
|
|
/**
|
|
|
|
* Get the associated listener transport ID for this queue pair.
|
|
|
|
*
|
|
|
|
* \param qpair The NVMe-oF qpair
|
|
|
|
* \param trid Output parameter that will contain the transport id.
|
|
|
|
*
|
|
|
|
* \return 0 for success.
|
|
|
|
* \return -EINVAL if the qpair is not connected.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_qpair_get_listen_trid(struct spdk_nvmf_qpair *qpair,
|
|
|
|
struct spdk_nvme_transport_id *trid);
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target that will own this subsystem.
|
|
|
|
* \param nqn The NVMe qualified name of this subsystem.
|
|
|
|
* \param type Whether this subsystem is an I/O subsystem or a Discovery subsystem.
|
2020-10-22 22:23:21 +00:00
|
|
|
* \param num_ns The maximum number of namespaces this subsystem may contain.
|
2017-12-19 23:39:04 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return a pointer to a NVMe-oF subsystem on success, or NULL on failure.
|
2016-09-19 17:01:52 +00:00
|
|
|
*/
|
2017-12-19 23:39:04 +00:00
|
|
|
struct spdk_nvmf_subsystem *spdk_nvmf_subsystem_create(struct spdk_nvmf_tgt *tgt,
|
2017-08-18 22:57:03 +00:00
|
|
|
const char *nqn,
|
2016-10-10 17:25:01 +00:00
|
|
|
enum spdk_nvmf_subtype type,
|
2017-08-28 21:21:41 +00:00
|
|
|
uint32_t num_ns);
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2021-03-03 08:48:19 +00:00
|
|
|
typedef void (*nvmf_subsystem_destroy_cb)(void *cb_arg);
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
/**
|
|
|
|
* Destroy an NVMe-oF subsystem. A subsystem may only be destroyed when in
|
2021-03-03 08:48:19 +00:00
|
|
|
* the Inactive state. See spdk_nvmf_subsystem_stop(). A subsystem may be
|
|
|
|
* destroyed asynchronously, in that case \b cpl_cb will be called
|
2017-12-19 23:39:04 +00:00
|
|
|
*
|
|
|
|
* \param subsystem The NVMe-oF subsystem to destroy.
|
2021-03-03 08:48:19 +00:00
|
|
|
* \param cpl_cb Optional callback to be called if the subsystem is destroyed asynchronously, only called if
|
|
|
|
* return value is -EINPROGRESS
|
|
|
|
* \param cpl_cb_arg Optional user context to be passed to \b cpl_cb
|
|
|
|
*
|
2021-11-25 01:40:58 +00:00
|
|
|
* \retval 0 if subsystem is destroyed, \b cpl_cb is not called is that case
|
2021-03-03 08:48:19 +00:00
|
|
|
* \retval -EINVAl if \b subsystem is a NULL pointer
|
|
|
|
* \retval -EAGAIN if \b subsystem is not in INACTIVE state
|
|
|
|
* \retval -EALREADY if subsystem destruction is already started
|
2021-11-25 01:40:58 +00:00
|
|
|
* \retval -EINPROGRESS if subsystem is destroyed asynchronously, cpl_cb will be called in that case
|
2017-12-19 23:39:04 +00:00
|
|
|
*/
|
2021-03-03 08:48:19 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_subsystem_destroy(struct spdk_nvmf_subsystem *subsystem, nvmf_subsystem_destroy_cb cpl_cb,
|
|
|
|
void *cpl_cb_arg);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
2018-04-16 08:43:19 +00:00
|
|
|
/**
|
|
|
|
* Function to be called once the subsystem has changed state.
|
|
|
|
*
|
2021-03-29 15:50:05 +00:00
|
|
|
* \param subsystem NVMe-oF subsystem that has changed state.
|
2018-04-16 08:43:19 +00:00
|
|
|
* \param cb_arg Argument passed to callback function.
|
|
|
|
* \param status 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
2017-12-19 23:39:04 +00:00
|
|
|
typedef void (*spdk_nvmf_subsystem_state_change_done)(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
void *cb_arg, int status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transition an NVMe-oF subsystem from Inactive to Active state.
|
|
|
|
*
|
|
|
|
* \param subsystem The NVMe-oF subsystem.
|
|
|
|
* \param cb_fn A function that will be called once the subsystem has changed state.
|
|
|
|
* \param cb_arg Argument passed to cb_fn.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return 0 on success, or negated errno on failure. The callback provided will only
|
|
|
|
* be called on success.
|
2017-12-19 23:39:04 +00:00
|
|
|
*/
|
2018-01-10 21:03:24 +00:00
|
|
|
int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_subsystem_state_change_done cb_fn,
|
|
|
|
void *cb_arg);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transition an NVMe-oF subsystem from Active to Inactive state.
|
|
|
|
*
|
|
|
|
* \param subsystem The NVMe-oF subsystem.
|
|
|
|
* \param cb_fn A function that will be called once the subsystem has changed state.
|
|
|
|
* \param cb_arg Argument passed to cb_fn.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return 0 on success, or negated errno on failure. The callback provided will only
|
|
|
|
* be called on success.
|
2017-12-19 23:39:04 +00:00
|
|
|
*/
|
2018-01-10 21:03:24 +00:00
|
|
|
int spdk_nvmf_subsystem_stop(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_subsystem_state_change_done cb_fn,
|
|
|
|
void *cb_arg);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transition an NVMe-oF subsystem from Active to Paused state.
|
|
|
|
*
|
2020-11-02 17:12:11 +00:00
|
|
|
* In a paused state, all admin queues are frozen across the whole subsystem. If
|
|
|
|
* a namespace ID is provided, all commands to that namespace are quiesced and incoming
|
|
|
|
* commands for that namespace are queued until the subsystem is resumed.
|
|
|
|
*
|
2017-12-19 23:39:04 +00:00
|
|
|
* \param subsystem The NVMe-oF subsystem.
|
2020-11-02 17:12:11 +00:00
|
|
|
* \param nsid The namespace to pause. If 0, pause no namespaces.
|
2017-12-19 23:39:04 +00:00
|
|
|
* \param cb_fn A function that will be called once the subsystem has changed state.
|
|
|
|
* \param cb_arg Argument passed to cb_fn.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return 0 on success, or negated errno on failure. The callback provided will only
|
|
|
|
* be called on success.
|
2017-12-19 23:39:04 +00:00
|
|
|
*/
|
2018-01-10 21:03:24 +00:00
|
|
|
int spdk_nvmf_subsystem_pause(struct spdk_nvmf_subsystem *subsystem,
|
2020-11-02 17:12:11 +00:00
|
|
|
uint32_t nsid,
|
2018-01-10 21:03:24 +00:00
|
|
|
spdk_nvmf_subsystem_state_change_done cb_fn,
|
|
|
|
void *cb_arg);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transition an NVMe-oF subsystem from Paused to Active state.
|
|
|
|
*
|
2020-11-02 17:12:11 +00:00
|
|
|
* This resumes the entire subsystem, including any paused namespaces.
|
|
|
|
*
|
2017-12-19 23:39:04 +00:00
|
|
|
* \param subsystem The NVMe-oF subsystem.
|
|
|
|
* \param cb_fn A function that will be called once the subsystem has changed state.
|
|
|
|
* \param cb_arg Argument passed to cb_fn.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return 0 on success, or negated errno on failure. The callback provided will only
|
|
|
|
* be called on success.
|
2017-12-19 23:39:04 +00:00
|
|
|
*/
|
2018-01-10 21:03:24 +00:00
|
|
|
int spdk_nvmf_subsystem_resume(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_subsystem_state_change_done cb_fn,
|
|
|
|
void *cb_arg);
|
2017-12-19 23:39:04 +00:00
|
|
|
|
2017-08-18 23:05:13 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Search the target for a subsystem with the given NQN.
|
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target to search from.
|
|
|
|
* \param subnqn NQN of the subsystem.
|
|
|
|
*
|
|
|
|
* \return a pointer to the NVMe-oF subsystem on success, or NULL on failure.
|
2017-08-18 23:05:13 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_subsystem *spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt,
|
|
|
|
const char *subnqn);
|
|
|
|
|
2017-11-20 18:16:06 +00:00
|
|
|
/**
|
|
|
|
* Begin iterating over all known subsystems. If no subsystems are present, return NULL.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target to iterate.
|
|
|
|
*
|
2018-06-18 14:39:39 +00:00
|
|
|
* \return a pointer to the first NVMe-oF subsystem on success, or NULL on failure.
|
2017-11-20 18:16:06 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_subsystem *spdk_nvmf_subsystem_get_first(struct spdk_nvmf_tgt *tgt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Continue iterating over all known subsystems. If no additional subsystems, return NULL.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
2018-06-18 14:39:39 +00:00
|
|
|
* \param subsystem Previous subsystem returned from \ref spdk_nvmf_subsystem_get_first or
|
|
|
|
* \ref spdk_nvmf_subsystem_get_next.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
2018-06-18 14:39:39 +00:00
|
|
|
* \return a pointer to the next NVMe-oF subsystem on success, or NULL on failure.
|
2017-11-20 18:16:06 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_subsystem *spdk_nvmf_subsystem_get_next(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2017-08-18 21:08:29 +00:00
|
|
|
/**
|
|
|
|
* Allow the given host NQN to connect to the given subsystem.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem Subsystem to add host to.
|
2018-06-18 14:39:39 +00:00
|
|
|
* \param hostnqn The NQN for the host.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
2017-08-18 21:08:29 +00:00
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const char *hostnqn);
|
|
|
|
|
2018-01-23 22:03:38 +00:00
|
|
|
/**
|
2020-10-06 20:50:37 +00:00
|
|
|
* Remove the given host NQN from the list of allowed hosts.
|
2018-01-23 22:03:38 +00:00
|
|
|
*
|
2020-10-06 20:50:37 +00:00
|
|
|
* This call only removes the host from the allowed list of hosts.
|
|
|
|
* If a host with the given NQN is already connected it will not be disconnected,
|
|
|
|
* but it will not be able to create new connections.
|
2018-01-23 22:03:38 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem Subsystem to remove host from.
|
2018-06-18 14:39:39 +00:00
|
|
|
* \param hostnqn The NQN for the host.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
2018-01-23 22:03:38 +00:00
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_remove_host(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn);
|
|
|
|
|
2020-10-07 15:48:47 +00:00
|
|
|
/**
|
|
|
|
* Disconnect all connections originating from the provided hostnqn
|
|
|
|
*
|
|
|
|
* To disconnect and block all new connections from a host, first call
|
|
|
|
* spdk_nvmf_subsystem_remove_host() to remove it from the list of allowed hosts, then
|
|
|
|
* call spdk_nvmf_subsystem_disconnect_host() to close any remaining connections.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to operate on
|
|
|
|
* \param hostnqn The NQN for the host
|
|
|
|
* \param cb_fn The function to call on completion.
|
|
|
|
* \param cb_arg The argument to pass to the cb_fn.
|
|
|
|
*
|
|
|
|
* \return int. 0 when the asynchronous process starts successfully or a negated errno on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_disconnect_host(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const char *hostnqn,
|
|
|
|
spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn,
|
|
|
|
void *cb_arg);
|
|
|
|
|
2017-08-30 20:21:12 +00:00
|
|
|
/**
|
|
|
|
* Set whether a subsystem should allow any host or only hosts in the allowed list.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to modify.
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param allow_any_host true to allow any host to connect to this subsystem,
|
2020-11-25 22:27:55 +00:00
|
|
|
* or false to enforce the list configured with spdk_nvmf_subsystem_add_host().
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
2017-08-30 20:21:12 +00:00
|
|
|
*/
|
2018-01-17 22:33:27 +00:00
|
|
|
int spdk_nvmf_subsystem_set_allow_any_host(struct spdk_nvmf_subsystem *subsystem,
|
2017-08-30 20:21:12 +00:00
|
|
|
bool allow_any_host);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a subsystem should allow any host or only hosts in the allowed list.
|
|
|
|
*
|
2019-10-16 05:06:30 +00:00
|
|
|
* \param subsystem Subsystem to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return true if any host is allowed to connect to this subsystem, or false if
|
2020-11-25 22:27:55 +00:00
|
|
|
* connecting hosts must be in the list configured with spdk_nvmf_subsystem_add_host().
|
2017-08-30 20:21:12 +00:00
|
|
|
*/
|
|
|
|
bool spdk_nvmf_subsystem_get_allow_any_host(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2017-08-18 21:08:29 +00:00
|
|
|
/**
|
|
|
|
* Check if the given host is allowed to connect to the subsystem.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem The subsystem to query.
|
|
|
|
* \param hostnqn The NQN of the host.
|
|
|
|
*
|
2017-08-18 21:08:29 +00:00
|
|
|
* \return true if allowed, false if not.
|
|
|
|
*/
|
2016-11-23 17:32:07 +00:00
|
|
|
bool spdk_nvmf_subsystem_host_allowed(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn);
|
|
|
|
|
2017-08-18 21:08:29 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the first allowed host in a subsystem.
|
2017-08-18 21:08:29 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return first allowed host in this subsystem, or NULL if none allowed.
|
2017-08-18 21:08:29 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_host *spdk_nvmf_subsystem_get_first_host(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the next allowed host in a subsystem.
|
2017-08-18 21:08:29 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
* \param prev_host Previous host returned from this function.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return next allowed host in this subsystem, or NULL if prev_host was the last host.
|
2017-08-18 21:08:29 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_host *spdk_nvmf_subsystem_get_next_host(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
struct spdk_nvmf_host *prev_host);
|
|
|
|
|
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get a host's NQN.
|
2017-08-18 21:08:29 +00:00
|
|
|
*
|
|
|
|
* \param host Host to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
2017-08-18 21:08:29 +00:00
|
|
|
* \return NQN of host.
|
|
|
|
*/
|
2020-02-25 17:45:04 +00:00
|
|
|
const char *spdk_nvmf_host_get_nqn(const struct spdk_nvmf_host *host);
|
2017-08-18 21:08:29 +00:00
|
|
|
|
2017-08-18 21:43:15 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Accept new connections on the address provided.
|
2017-08-18 21:43:15 +00:00
|
|
|
*
|
2021-03-02 13:53:06 +00:00
|
|
|
* This does not start the listener. Use spdk_nvmf_tgt_listen_ext() for that.
|
2020-01-02 19:00:45 +00:00
|
|
|
*
|
2018-01-17 22:33:27 +00:00
|
|
|
* May only be performed on subsystems in the PAUSED or INACTIVE states.
|
2020-11-02 17:12:11 +00:00
|
|
|
* No namespaces are required to be paused.
|
2018-01-17 22:33:27 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem Subsystem to add listener to.
|
|
|
|
* \param trid The address to accept connections from.
|
2020-02-05 21:17:40 +00:00
|
|
|
* \param cb_fn A callback that will be called once the association is complete.
|
|
|
|
* \param cb_arg Argument passed to cb_fn.
|
2017-08-18 21:43:15 +00:00
|
|
|
*/
|
2020-02-05 21:17:40 +00:00
|
|
|
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);
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2018-02-06 16:00:03 +00:00
|
|
|
/**
|
2020-01-02 19:00:45 +00:00
|
|
|
* 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().
|
2018-02-06 16:00:03 +00:00
|
|
|
*
|
|
|
|
* May only be performed on subsystems in the PAUSED or INACTIVE states.
|
2020-11-02 17:12:11 +00:00
|
|
|
* No namespaces are required to be paused.
|
2018-02-06 16:00:03 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem Subsystem to remove listener from.
|
|
|
|
* \param trid The address to no longer accept connections from.
|
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
2018-02-06 16:00:03 +00:00
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_remove_listener(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const struct spdk_nvme_transport_id *trid);
|
|
|
|
|
2017-08-18 21:43:15 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Check if connections originated from the given address are allowed to connect
|
|
|
|
* to the subsystem.
|
2017-08-18 21:43:15 +00:00
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param subsystem The subsystem to query.
|
|
|
|
* \param trid The listen address.
|
|
|
|
*
|
|
|
|
* \return true if allowed, or false if not.
|
2017-08-18 21:43:15 +00:00
|
|
|
*/
|
2017-05-31 23:17:50 +00:00
|
|
|
bool spdk_nvmf_subsystem_listener_allowed(struct spdk_nvmf_subsystem *subsystem,
|
2020-02-15 05:57:06 +00:00
|
|
|
const struct spdk_nvme_transport_id *trid);
|
2017-05-31 23:17:50 +00:00
|
|
|
|
2017-08-18 21:43:15 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the first allowed listen address in the subsystem.
|
2017-08-18 21:43:15 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return first allowed listen address in this subsystem, or NULL if none allowed.
|
2017-08-18 21:43:15 +00:00
|
|
|
*/
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener *spdk_nvmf_subsystem_get_first_listener(
|
2017-08-18 21:43:15 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem);
|
2017-08-18 21:08:29 +00:00
|
|
|
|
2017-08-18 21:43:15 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the next allowed listen address in a subsystem.
|
2017-08-18 21:43:15 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param prev_listener Previous listen address for this subsystem.
|
|
|
|
*
|
|
|
|
* \return next allowed listen address in this subsystem, or NULL if prev_listener
|
|
|
|
* was the last address.
|
2017-08-18 21:43:15 +00:00
|
|
|
*/
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener *spdk_nvmf_subsystem_get_next_listener(
|
2017-08-18 21:43:15 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener *prev_listener);
|
2017-08-18 21:43:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a listen address' transport ID
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param listener This listener.
|
|
|
|
*
|
|
|
|
* \return the transport ID for this listener.
|
2017-08-18 21:43:15 +00:00
|
|
|
*/
|
2020-02-15 05:47:36 +00:00
|
|
|
const struct spdk_nvme_transport_id *spdk_nvmf_subsystem_listener_get_trid(
|
|
|
|
struct spdk_nvmf_subsystem_listener *listener);
|
2016-09-19 17:01:52 +00:00
|
|
|
|
2019-10-11 07:12:43 +00:00
|
|
|
/**
|
|
|
|
* Set whether a subsystem should allow any listen address or only addresses in the allowed list.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to allow dynamic listener assignment.
|
|
|
|
* \param allow_any_listener true to allow dynamic listener assignment for
|
2020-11-25 22:27:55 +00:00
|
|
|
* this subsystem, or false to enforce the list configured during
|
2019-10-11 07:12:43 +00:00
|
|
|
* subsystem setup.
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_subsystem_allow_any_listener(
|
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
bool allow_any_listener);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a subsystem allows any listen address or only addresses in the allowed list.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return true if this subsystem allows dynamic management of listen address list,
|
2020-11-25 22:27:55 +00:00
|
|
|
* or false if only allows addresses in the list configured during subsystem setup.
|
2019-10-11 07:12:43 +00:00
|
|
|
*/
|
|
|
|
bool spdk_nvmf_subsytem_any_listener_allowed(
|
|
|
|
struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2020-08-19 04:51:54 +00:00
|
|
|
/**
|
|
|
|
* Set whether a subsystem supports Asymmetric Namespace Access (ANA)
|
|
|
|
* reporting.
|
|
|
|
*
|
|
|
|
* May only be performed on subsystems in the INACTIVE state.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to modify.
|
|
|
|
* \param ana_reporting true to support or false not to support ANA reporting.
|
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_set_ana_reporting(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
bool ana_reporting);
|
|
|
|
|
2017-08-22 15:54:12 +00:00
|
|
|
/** NVMe-oF target namespace creation options */
|
|
|
|
struct spdk_nvmf_ns_opts {
|
|
|
|
/**
|
|
|
|
* Namespace ID
|
|
|
|
*
|
|
|
|
* Set to 0 to automatically assign a free NSID.
|
|
|
|
*/
|
|
|
|
uint32_t nsid;
|
2018-02-13 00:03:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespace Globally Unique Identifier
|
|
|
|
*
|
|
|
|
* Fill with 0s if not specified.
|
|
|
|
*/
|
|
|
|
uint8_t nguid[16];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IEEE Extended Unique Identifier
|
|
|
|
*
|
|
|
|
* Fill with 0s if not specified.
|
|
|
|
*/
|
|
|
|
uint8_t eui64[8];
|
2018-02-22 00:09:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Namespace UUID
|
|
|
|
*
|
|
|
|
* Fill with 0s if not specified.
|
|
|
|
*/
|
|
|
|
struct spdk_uuid uuid;
|
2021-08-25 02:57:31 +00:00
|
|
|
|
2022-08-17 22:24:28 +00:00
|
|
|
/* Hole at bytes 44-47. */
|
|
|
|
uint8_t reserved44[4];
|
|
|
|
|
2021-08-25 02:57:31 +00:00
|
|
|
/**
|
|
|
|
* The size of spdk_nvmf_ns_opts according to the caller of this library is used for ABI
|
|
|
|
* compatibility. The library uses this field to know how many fields in this structure
|
|
|
|
* are valid. And the library will populate any remaining fields with default values.
|
|
|
|
* New added fields should be put at the end of the struct.
|
|
|
|
*/
|
|
|
|
size_t opts_size;
|
2021-08-25 02:58:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ANA group ID
|
|
|
|
*
|
|
|
|
* Set to be equal with the NSID if not specified.
|
|
|
|
*/
|
|
|
|
uint32_t anagrpid;
|
2022-08-17 22:24:28 +00:00
|
|
|
|
|
|
|
/* Hole at bytes 60-63. */
|
|
|
|
uint8_t reserved60[4];
|
|
|
|
} __attribute__((packed));
|
2022-08-17 20:09:55 +00:00
|
|
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_ns_opts) == 64, "Incorrect size");
|
2017-08-22 15:54:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get default namespace creation options.
|
|
|
|
*
|
|
|
|
* \param opts Namespace options to fill with defaults.
|
|
|
|
* \param opts_size sizeof(struct spdk_nvmf_ns_opts)
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_ns_opts_get_defaults(struct spdk_nvmf_ns_opts *opts, size_t opts_size);
|
|
|
|
|
2020-09-30 19:22:21 +00:00
|
|
|
/**
|
|
|
|
* Add a namespace to a subsystems in the PAUSED or INACTIVE states.
|
|
|
|
*
|
|
|
|
* May only be performed on subsystems in the PAUSED or INACTIVE states.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to add namespace to.
|
|
|
|
* \param bdev_name Block device name to add as a namespace.
|
|
|
|
* \param opts Namespace options, or NULL to use defaults.
|
|
|
|
* \param opts_size sizeof(*opts)
|
|
|
|
* \param ptpl_file Persist through power loss file path.
|
|
|
|
*
|
|
|
|
* \return newly added NSID on success, or 0 on failure.
|
|
|
|
*/
|
|
|
|
uint32_t spdk_nvmf_subsystem_add_ns_ext(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const char *bdev_name,
|
|
|
|
const struct spdk_nvmf_ns_opts *opts, size_t opts_size,
|
|
|
|
const char *ptpl_file);
|
|
|
|
|
2017-12-14 02:38:18 +00:00
|
|
|
/**
|
2021-11-25 01:40:58 +00:00
|
|
|
* Remove a namespace from a subsystem.
|
2017-12-14 02:38:18 +00:00
|
|
|
*
|
2018-01-17 22:33:27 +00:00
|
|
|
* May only be performed on subsystems in the PAUSED or INACTIVE states.
|
2020-11-02 17:12:11 +00:00
|
|
|
* Additionally, the namespace must be paused.
|
2018-01-17 22:33:27 +00:00
|
|
|
*
|
2017-12-14 02:38:18 +00:00
|
|
|
* \param subsystem Subsystem the namespace belong to.
|
|
|
|
* \param nsid Namespace ID to be removed.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \return 0 on success, -1 on failure.
|
2017-12-14 02:38:18 +00:00
|
|
|
*/
|
2019-06-27 11:46:42 +00:00
|
|
|
int spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid);
|
2017-12-14 02:38:18 +00:00
|
|
|
|
2017-08-18 01:20:49 +00:00
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the first allocated namespace in a subsystem.
|
2017-08-18 01:20:49 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return first allocated namespace in this subsystem, or NULL if this subsystem
|
|
|
|
* has no namespaces.
|
2017-08-18 01:20:49 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_ns *spdk_nvmf_subsystem_get_first_ns(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
|
|
|
/**
|
2018-02-28 06:27:31 +00:00
|
|
|
* Get the next allocated namespace in a subsystem.
|
2017-08-18 01:20:49 +00:00
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
* \param prev_ns Previous ns returned from this function.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return next allocated namespace in this subsystem, or NULL if prev_ns was the
|
|
|
|
* last namespace.
|
2017-08-18 01:20:49 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_ns *spdk_nvmf_subsystem_get_next_ns(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
struct spdk_nvmf_ns *prev_ns);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a namespace in a subsystem by NSID.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to search.
|
|
|
|
* \param nsid Namespace ID to find.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
|
|
|
* \return namespace matching nsid, or NULL if nsid was not found.
|
2017-08-18 01:20:49 +00:00
|
|
|
*/
|
|
|
|
struct spdk_nvmf_ns *spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
uint32_t nsid);
|
|
|
|
|
2018-06-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Get the maximum number of namespaces allowed in a subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return Maximum number of namespaces allowed in the subsystem, or 0 for unlimited.
|
|
|
|
*/
|
|
|
|
uint32_t spdk_nvmf_subsystem_get_max_namespaces(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2021-04-12 11:01:16 +00:00
|
|
|
/**
|
|
|
|
* Get the minimum controller ID allowed in a subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return Minimum controller ID allowed in the subsystem.
|
|
|
|
*/
|
|
|
|
uint16_t spdk_nvmf_subsystem_get_min_cntlid(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the maximum controller ID allowed in a subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return Maximum controller ID allowed in the subsystem.
|
|
|
|
*/
|
|
|
|
uint16_t spdk_nvmf_subsystem_get_max_cntlid(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2017-08-18 01:20:49 +00:00
|
|
|
/**
|
|
|
|
* Get a namespace's NSID.
|
|
|
|
*
|
|
|
|
* \param ns Namespace to query.
|
2018-02-28 06:27:31 +00:00
|
|
|
*
|
2017-08-18 01:20:49 +00:00
|
|
|
* \return NSID of ns.
|
|
|
|
*/
|
|
|
|
uint32_t spdk_nvmf_ns_get_id(const struct spdk_nvmf_ns *ns);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a namespace's associated bdev.
|
|
|
|
*
|
2018-02-28 06:27:31 +00:00
|
|
|
* \param ns Namespace to query.
|
|
|
|
*
|
|
|
|
* \return backing bdev of ns.
|
2017-08-18 01:20:49 +00:00
|
|
|
*/
|
|
|
|
struct spdk_bdev *spdk_nvmf_ns_get_bdev(struct spdk_nvmf_ns *ns);
|
|
|
|
|
2017-08-22 15:54:12 +00:00
|
|
|
/**
|
|
|
|
* Get the options specified for a namespace.
|
|
|
|
*
|
|
|
|
* \param ns Namespace to query.
|
|
|
|
* \param opts Output parameter for options.
|
|
|
|
* \param opts_size sizeof(*opts)
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_ns_get_opts(const struct spdk_nvmf_ns *ns, struct spdk_nvmf_ns_opts *opts,
|
|
|
|
size_t opts_size);
|
|
|
|
|
2018-02-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the serial number of the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return serial number of the specified subsystem.
|
|
|
|
*/
|
2017-06-01 00:01:00 +00:00
|
|
|
const char *spdk_nvmf_subsystem_get_sn(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2018-02-28 06:27:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the serial number for the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to set for.
|
|
|
|
* \param sn serial number to set.
|
|
|
|
*
|
|
|
|
* \return 0 on success, -1 on failure.
|
|
|
|
*/
|
2016-09-19 17:01:52 +00:00
|
|
|
int spdk_nvmf_subsystem_set_sn(struct spdk_nvmf_subsystem *subsystem, const char *sn);
|
|
|
|
|
2018-12-29 19:39:48 +00:00
|
|
|
/**
|
|
|
|
* Get the model number of the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return model number of the specified subsystem.
|
|
|
|
*/
|
|
|
|
const char *spdk_nvmf_subsystem_get_mn(const struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the model number for the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to set for.
|
|
|
|
* \param mn model number to set.
|
|
|
|
*
|
|
|
|
* \return 0 on success, -1 on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_subsystem_set_mn(struct spdk_nvmf_subsystem *subsystem, const char *mn);
|
|
|
|
|
2018-02-28 06:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the NQN of the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return NQN of the specified subsystem.
|
|
|
|
*/
|
2020-02-25 17:45:04 +00:00
|
|
|
const char *spdk_nvmf_subsystem_get_nqn(const struct spdk_nvmf_subsystem *subsystem);
|
2018-02-28 06:27:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the type of the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return the type of the specified subsystem.
|
|
|
|
*/
|
2016-10-10 17:25:01 +00:00
|
|
|
enum spdk_nvmf_subtype spdk_nvmf_subsystem_get_type(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2020-01-02 22:59:33 +00:00
|
|
|
/**
|
|
|
|
* Get maximum namespace id of the specified subsystem.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to query.
|
|
|
|
*
|
|
|
|
* \return maximum namespace id
|
|
|
|
*/
|
|
|
|
uint32_t spdk_nvmf_subsystem_get_max_nsid(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
/**
|
|
|
|
* Initialize transport options
|
|
|
|
*
|
2019-12-23 23:27:35 +00:00
|
|
|
* \param transport_name The transport type to create
|
2018-08-27 22:27:47 +00:00
|
|
|
* \param opts The transport options (e.g. max_io_size)
|
2020-11-26 16:48:10 +00:00
|
|
|
* \param opts_size Must be set to sizeof(struct spdk_nvmf_transport_opts).
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
|
|
|
* \return bool. true if successful, false if transport type
|
|
|
|
* not found.
|
|
|
|
*/
|
|
|
|
bool
|
2019-12-23 23:27:35 +00:00
|
|
|
spdk_nvmf_transport_opts_init(const char *transport_name,
|
2020-11-26 16:48:10 +00:00
|
|
|
struct spdk_nvmf_transport_opts *opts, size_t opts_size);
|
2018-08-27 22:27:47 +00:00
|
|
|
|
|
|
|
/**
|
2023-01-25 10:20:12 +00:00
|
|
|
* Create a protocol transport - deprecated, please use \ref spdk_nvmf_transport_create_async.
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
2019-12-23 23:27:35 +00:00
|
|
|
* \param transport_name The transport type to create
|
2020-11-26 16:48:10 +00:00
|
|
|
* \param opts The transport options (e.g. max_io_size). It should not be NULL, and opts_size
|
|
|
|
* pointed in this structure should not be zero value.
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
|
|
|
* \return new transport or NULL if create fails
|
|
|
|
*/
|
2019-12-23 23:27:35 +00:00
|
|
|
struct spdk_nvmf_transport *spdk_nvmf_transport_create(const char *transport_name,
|
2018-08-27 22:27:47 +00:00
|
|
|
struct spdk_nvmf_transport_opts *opts);
|
|
|
|
|
2023-01-25 10:20:12 +00:00
|
|
|
typedef void (*spdk_nvmf_transport_create_done_cb)(void *cb_arg,
|
|
|
|
struct spdk_nvmf_transport *transport);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a protocol transport
|
|
|
|
*
|
|
|
|
* The callback will be executed asynchronously - i.e. spdk_nvmf_transport_create_async will always return
|
|
|
|
* prior to `cb_fn` being called.
|
|
|
|
*
|
|
|
|
* \param transport_name The transport type to create
|
|
|
|
* \param opts The transport options (e.g. max_io_size). It should not be NULL, and opts_size
|
|
|
|
* pointed in this structure should not be zero value.
|
|
|
|
* \param cb_fn A callback that will be called once the transport is created
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
|
|
|
*
|
|
|
|
* \return 0 on success, or negative errno on failure (`cb_fn` will not be executed then).
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_transport_create_async(const char *transport_name,
|
|
|
|
struct spdk_nvmf_transport_opts *opts,
|
|
|
|
spdk_nvmf_transport_create_done_cb cb_fn, void *cb_arg);
|
|
|
|
|
2020-11-20 05:50:52 +00:00
|
|
|
typedef void (*spdk_nvmf_transport_destroy_done_cb)(void *cb_arg);
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
/**
|
|
|
|
* Destroy a protocol transport
|
|
|
|
*
|
2021-11-25 01:40:58 +00:00
|
|
|
* \param transport The transport to destroy
|
2020-11-20 05:50:52 +00:00
|
|
|
* \param cb_fn A callback that will be called once the transport is destroyed
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success, -1 on failure.
|
|
|
|
*/
|
2020-11-20 05:50:52 +00:00
|
|
|
int spdk_nvmf_transport_destroy(struct spdk_nvmf_transport *transport,
|
|
|
|
spdk_nvmf_transport_destroy_done_cb cb_fn, void *cb_arg);
|
2018-08-27 22:27:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an existing transport from the target
|
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target
|
2020-01-07 17:36:40 +00:00
|
|
|
* \param transport_name The name of the transport type to get.
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
|
|
|
* \return the transport or NULL if not found
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_transport *spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt,
|
2020-01-07 17:36:40 +00:00
|
|
|
const char *transport_name);
|
2018-08-27 22:27:47 +00:00
|
|
|
|
2018-10-23 21:37:22 +00:00
|
|
|
/**
|
|
|
|
* Get the first transport registered with the given target
|
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target
|
|
|
|
*
|
|
|
|
* \return The first transport registered on the target
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_transport *spdk_nvmf_transport_get_first(struct spdk_nvmf_tgt *tgt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next transport in a target's list.
|
|
|
|
*
|
|
|
|
* \param transport A handle to a transport object
|
|
|
|
*
|
|
|
|
* \return The next transport associated with the NVMe-oF target
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_transport *spdk_nvmf_transport_get_next(struct spdk_nvmf_transport *transport);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the opts for a given transport.
|
|
|
|
*
|
|
|
|
* \param transport The transport to query
|
|
|
|
*
|
|
|
|
* \return The opts associated with the given transport
|
|
|
|
*/
|
|
|
|
const struct spdk_nvmf_transport_opts *spdk_nvmf_get_transport_opts(struct spdk_nvmf_transport
|
|
|
|
*transport);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the transport type for a given transport.
|
|
|
|
*
|
|
|
|
* \param transport The transport to query
|
|
|
|
*
|
|
|
|
* \return the transport type for the given transport
|
|
|
|
*/
|
|
|
|
spdk_nvme_transport_type_t spdk_nvmf_get_transport_type(struct spdk_nvmf_transport *transport);
|
|
|
|
|
2020-01-17 11:20:29 +00:00
|
|
|
/**
|
|
|
|
* Get the transport name for a given transport.
|
|
|
|
*
|
|
|
|
* \param transport The transport to query
|
|
|
|
*
|
|
|
|
* \return the transport name for the given transport
|
|
|
|
*/
|
|
|
|
const char *spdk_nvmf_get_transport_name(struct spdk_nvmf_transport *transport);
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
/**
|
|
|
|
* Function to be called once transport add is complete
|
|
|
|
*
|
|
|
|
* \param cb_arg Callback argument passed to this function.
|
|
|
|
* \param status 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
typedef void (*spdk_nvmf_tgt_add_transport_done_fn)(void *cb_arg, int status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a transport to a target
|
|
|
|
*
|
|
|
|
* \param tgt The NVMe-oF target
|
|
|
|
* \param transport The transport to add
|
|
|
|
* \param cb_fn A callback that will be called once the transport is created
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
2022-12-13 14:16:32 +00:00
|
|
|
/**
|
|
|
|
* Function to be called once target pause is complete.
|
|
|
|
*
|
|
|
|
* \param cb_arg Callback argument passed to this function.
|
|
|
|
* \param status 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
typedef void (*spdk_nvmf_tgt_pause_polling_cb_fn)(void *cb_arg, int status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pause polling on the given target.
|
|
|
|
*
|
|
|
|
* \param tgt The target to pause
|
|
|
|
* \param cb_fn A callback that will be called once the target is paused
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
|
|
|
*
|
|
|
|
* \return 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_tgt_pause_polling(struct spdk_nvmf_tgt *tgt, spdk_nvmf_tgt_pause_polling_cb_fn cb_fn,
|
|
|
|
void *cb_arg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to be called once target resume is complete.
|
|
|
|
*
|
|
|
|
* \param cb_arg Callback argument passed to this function.
|
|
|
|
* \param status 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
typedef void (*spdk_nvmf_tgt_resume_polling_cb_fn)(void *cb_arg, int status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resume polling on the given target.
|
|
|
|
*
|
|
|
|
* \param tgt The target to resume
|
|
|
|
* \param cb_fn A callback that will be called once the target is resumed
|
|
|
|
* \param cb_arg A context argument passed to cb_fn.
|
|
|
|
*
|
|
|
|
* \return 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_tgt_resume_polling(struct spdk_nvmf_tgt *tgt,
|
|
|
|
spdk_nvmf_tgt_resume_polling_cb_fn cb_fn, void *cb_arg);
|
|
|
|
|
2018-08-27 22:27:47 +00:00
|
|
|
/**
|
|
|
|
* Add listener to transport and begin accepting new connections.
|
|
|
|
*
|
2020-12-18 19:12:49 +00:00
|
|
|
* \param transport The transport to add listener to.
|
|
|
|
* \param trid The address to listen at.
|
|
|
|
* \param opts Listener options.
|
2018-08-27 22:27:47 +00:00
|
|
|
*
|
|
|
|
* \return int. 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
2020-02-15 05:30:46 +00:00
|
|
|
int
|
|
|
|
spdk_nvmf_transport_listen(struct spdk_nvmf_transport *transport,
|
2020-12-18 19:12:49 +00:00
|
|
|
const struct spdk_nvme_transport_id *trid, struct spdk_nvmf_listen_opts *opts);
|
2018-08-27 22:27:47 +00:00
|
|
|
|
2020-02-15 05:30:46 +00:00
|
|
|
/**
|
|
|
|
* Remove listener from transport and stop accepting new connections.
|
|
|
|
*
|
|
|
|
* \param transport The transport to remove listener from
|
|
|
|
* \param trid Address to stop listen at
|
|
|
|
*
|
|
|
|
* \return int. 0 if it completed successfully, or negative errno if it failed.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
spdk_nvmf_transport_stop_listen(struct spdk_nvmf_transport *transport,
|
|
|
|
const struct spdk_nvme_transport_id *trid);
|
2018-08-27 22:27:47 +00:00
|
|
|
|
2020-07-09 21:57:37 +00:00
|
|
|
/**
|
|
|
|
* Stop accepting new connections at the provided address.
|
|
|
|
*
|
2021-03-02 13:53:06 +00:00
|
|
|
* This is a counterpart to spdk_nvmf_tgt_listen_ext(). It differs
|
2021-12-08 10:22:24 +00:00
|
|
|
* from spdk_nvmf_transport_stop_listen() in that it also destroys
|
2020-07-09 21:57:37 +00:00
|
|
|
* qpairs that are connected to the specified listener. Because
|
|
|
|
* this function disconnects the qpairs, it has to be asynchronous.
|
|
|
|
*
|
|
|
|
* \param transport The transport associated with the listen address.
|
|
|
|
* \param trid The address to stop listening at.
|
2021-12-08 10:22:24 +00:00
|
|
|
* \param subsystem The subsystem to match for qpairs with the specified
|
|
|
|
* trid. If NULL, it will disconnect all qpairs with the
|
|
|
|
* specified trid.
|
2020-07-09 21:57:37 +00:00
|
|
|
* \param cb_fn The function to call on completion.
|
|
|
|
* \param cb_arg The argument to pass to the cb_fn.
|
|
|
|
*
|
|
|
|
* \return int. 0 when the asynchronous process starts successfully or a negated errno on failure.
|
|
|
|
*/
|
|
|
|
int spdk_nvmf_transport_stop_listen_async(struct spdk_nvmf_transport *transport,
|
|
|
|
const struct spdk_nvme_transport_id *trid,
|
2021-12-08 10:22:24 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
2020-07-09 21:57:37 +00:00
|
|
|
spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn,
|
|
|
|
void *cb_arg);
|
|
|
|
|
2021-03-03 15:36:02 +00:00
|
|
|
/**
|
|
|
|
* Dump poll group statistics into JSON.
|
|
|
|
*
|
|
|
|
* \param group The group which statistics should be dumped.
|
|
|
|
* \param w The JSON write context to which statistics should be dumped.
|
|
|
|
*/
|
|
|
|
void spdk_nvmf_poll_group_dump_stat(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_json_write_ctx *w);
|
|
|
|
|
2018-11-20 05:25:48 +00:00
|
|
|
/**
|
|
|
|
* \brief 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.
|
|
|
|
*
|
|
|
|
* \param hooks for initializing global hooks
|
|
|
|
*/
|
2019-07-25 22:20:47 +00:00
|
|
|
void spdk_nvmf_rdma_init_hooks(struct spdk_nvme_rdma_hooks *hooks);
|
2018-11-20 05:25:48 +00:00
|
|
|
|
2017-12-07 20:25:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-19 17:01:52 +00:00
|
|
|
#endif
|