2016-06-06 21:44:30 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
2019-04-15 09:54:38 +00:00
|
|
|
* Copyright (c) Intel Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
|
2021-03-03 08:48:19 +00:00
|
|
|
* Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
2016-06-06 21:44:30 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NVMF_INTERNAL_H__
|
|
|
|
#define __NVMF_INTERNAL_H__
|
|
|
|
|
2017-05-02 18:18:25 +00:00
|
|
|
#include "spdk/stdinc.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2017-08-18 01:20:49 +00:00
|
|
|
#include "spdk/likely.h"
|
2017-05-31 23:14:01 +00:00
|
|
|
#include "spdk/nvmf.h"
|
2020-01-31 17:13:43 +00:00
|
|
|
#include "spdk/nvmf_cmd.h"
|
2020-01-30 20:34:06 +00:00
|
|
|
#include "spdk/nvmf_transport.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
#include "spdk/nvmf_spec.h"
|
|
|
|
#include "spdk/assert.h"
|
2018-08-06 09:41:38 +00:00
|
|
|
#include "spdk/bdev.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
#include "spdk/queue.h"
|
2017-02-02 17:07:12 +00:00
|
|
|
#include "spdk/util.h"
|
2018-07-13 23:23:23 +00:00
|
|
|
#include "spdk/thread.h"
|
2016-06-06 21:44:30 +00:00
|
|
|
|
2020-05-20 16:20:16 +00:00
|
|
|
#define NVMF_MAX_ASYNC_EVENTS (4)
|
|
|
|
|
2021-04-12 11:01:16 +00:00
|
|
|
/* The spec reserves cntlid values in the range FFF0h to FFFFh. */
|
|
|
|
#define NVMF_MIN_CNTLID 1
|
|
|
|
#define NVMF_MAX_CNTLID 0xFFEF
|
|
|
|
|
2017-12-19 23:39:04 +00:00
|
|
|
enum spdk_nvmf_subsystem_state {
|
|
|
|
SPDK_NVMF_SUBSYSTEM_INACTIVE = 0,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_ACTIVATING,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_ACTIVE,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_PAUSING,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_PAUSED,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_RESUMING,
|
|
|
|
SPDK_NVMF_SUBSYSTEM_DEACTIVATING,
|
2020-07-17 00:36:52 +00:00
|
|
|
SPDK_NVMF_SUBSYSTEM_NUM_STATES,
|
2017-12-19 23:39:04 +00:00
|
|
|
};
|
|
|
|
|
2017-01-19 18:55:56 +00:00
|
|
|
struct spdk_nvmf_tgt {
|
2019-08-15 17:34:12 +00:00
|
|
|
char name[NVMF_TGT_NAME_MAX_LENGTH];
|
|
|
|
|
2020-05-27 21:59:54 +00:00
|
|
|
pthread_mutex_t mutex;
|
|
|
|
|
2017-02-17 01:32:09 +00:00
|
|
|
uint64_t discovery_genctr;
|
2017-08-29 20:03:13 +00:00
|
|
|
|
2020-06-29 17:56:47 +00:00
|
|
|
struct spdk_poller *accept_poller;
|
|
|
|
|
2018-10-19 20:19:09 +00:00
|
|
|
uint32_t max_subsystems;
|
|
|
|
|
2021-08-12 16:01:39 +00:00
|
|
|
enum spdk_nvmf_tgt_discovery_filter discovery_filter;
|
|
|
|
|
2018-05-08 23:05:28 +00:00
|
|
|
/* Array of subsystem pointers of size max_subsystems indexed by sid */
|
2017-08-29 20:03:13 +00:00
|
|
|
struct spdk_nvmf_subsystem **subsystems;
|
|
|
|
|
2017-07-24 23:30:07 +00:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_transport) transports;
|
2020-05-27 21:59:54 +00:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_poll_group) poll_groups;
|
2018-06-05 22:34:04 +00:00
|
|
|
|
2020-06-08 21:38:29 +00:00
|
|
|
/* Used for round-robin assignment of connections to poll groups */
|
|
|
|
struct spdk_nvmf_poll_group *next_poll_group;
|
|
|
|
|
2018-06-05 22:34:04 +00:00
|
|
|
spdk_nvmf_tgt_destroy_done_fn *destroy_cb_fn;
|
|
|
|
void *destroy_cb_arg;
|
2019-08-15 16:52:20 +00:00
|
|
|
|
2021-05-24 04:22:43 +00:00
|
|
|
uint16_t crdt[3];
|
|
|
|
|
2019-08-15 16:52:20 +00:00
|
|
|
TAILQ_ENTRY(spdk_nvmf_tgt) link;
|
2016-06-08 20:19:48 +00:00
|
|
|
};
|
|
|
|
|
2017-08-18 21:08:29 +00:00
|
|
|
struct spdk_nvmf_host {
|
2019-06-28 08:28:24 +00:00
|
|
|
char nqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
2017-08-18 21:08:29 +00:00
|
|
|
TAILQ_ENTRY(spdk_nvmf_host) link;
|
|
|
|
};
|
|
|
|
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener {
|
2020-02-05 21:45:09 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
|
|
|
spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn;
|
|
|
|
void *cb_arg;
|
2020-02-15 06:19:24 +00:00
|
|
|
struct spdk_nvme_transport_id *trid;
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_transport *transport;
|
2021-08-05 22:20:51 +00:00
|
|
|
enum spdk_nvme_ana_state *ana_state;
|
2020-09-13 16:39:59 +00:00
|
|
|
uint64_t ana_state_change_count;
|
2020-02-15 05:47:36 +00:00
|
|
|
TAILQ_ENTRY(spdk_nvmf_subsystem_listener) link;
|
2017-08-18 21:43:15 +00:00
|
|
|
};
|
|
|
|
|
2019-03-15 02:40:19 +00:00
|
|
|
/* Maximum number of registrants supported per namespace */
|
|
|
|
#define SPDK_NVMF_MAX_NUM_REGISTRANTS 16
|
|
|
|
|
2019-06-11 06:44:18 +00:00
|
|
|
struct spdk_nvmf_registrant_info {
|
|
|
|
uint64_t rkey;
|
|
|
|
char host_uuid[SPDK_UUID_STRING_LEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_nvmf_reservation_info {
|
|
|
|
bool ptpl_activated;
|
|
|
|
enum spdk_nvme_reservation_type rtype;
|
|
|
|
uint64_t crkey;
|
|
|
|
char bdev_uuid[SPDK_UUID_STRING_LEN];
|
|
|
|
char holder_uuid[SPDK_UUID_STRING_LEN];
|
|
|
|
uint32_t num_regs;
|
|
|
|
struct spdk_nvmf_registrant_info registrants[SPDK_NVMF_MAX_NUM_REGISTRANTS];
|
|
|
|
};
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
struct spdk_nvmf_subsystem_pg_ns_info {
|
2019-03-01 05:12:55 +00:00
|
|
|
struct spdk_io_channel *channel;
|
2019-06-27 11:24:12 +00:00
|
|
|
struct spdk_uuid uuid;
|
2019-03-01 05:12:55 +00:00
|
|
|
/* current reservation key, no reservation if the value is 0 */
|
|
|
|
uint64_t crkey;
|
|
|
|
/* reservation type */
|
|
|
|
enum spdk_nvme_reservation_type rtype;
|
|
|
|
/* Host ID which holds the reservation */
|
2019-03-15 02:40:19 +00:00
|
|
|
struct spdk_uuid holder_id;
|
|
|
|
/* Host ID for the registrants with the namespace */
|
|
|
|
struct spdk_uuid reg_hostid[SPDK_NVMF_MAX_NUM_REGISTRANTS];
|
2019-09-11 14:47:39 +00:00
|
|
|
uint64_t num_blocks;
|
2020-11-02 17:12:11 +00:00
|
|
|
|
|
|
|
/* I/O outstanding to this namespace */
|
|
|
|
uint64_t io_outstanding;
|
|
|
|
enum spdk_nvmf_subsystem_state state;
|
2019-03-01 04:21:37 +00:00
|
|
|
};
|
|
|
|
|
2019-04-25 14:03:06 +00:00
|
|
|
typedef void(*spdk_nvmf_poll_group_mod_done)(void *cb_arg, int status);
|
|
|
|
|
2017-11-20 16:50:10 +00:00
|
|
|
struct spdk_nvmf_subsystem_poll_group {
|
2019-03-01 04:21:37 +00:00
|
|
|
/* Array of namespace information for each namespace indexed by nsid - 1 */
|
|
|
|
struct spdk_nvmf_subsystem_pg_ns_info *ns_info;
|
|
|
|
uint32_t num_ns;
|
2017-12-19 23:39:04 +00:00
|
|
|
|
2020-11-02 17:12:11 +00:00
|
|
|
/* Number of ADMIN and FABRICS requests outstanding */
|
|
|
|
uint64_t mgmt_io_outstanding;
|
2019-04-25 14:03:06 +00:00
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn;
|
|
|
|
void *cb_arg;
|
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
enum spdk_nvmf_subsystem_state state;
|
2018-04-04 16:16:39 +00:00
|
|
|
|
2019-03-01 04:21:37 +00:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_request) queued;
|
2017-11-20 16:50:10 +00:00
|
|
|
};
|
|
|
|
|
2019-02-28 02:50:03 +00:00
|
|
|
struct spdk_nvmf_registrant {
|
|
|
|
TAILQ_ENTRY(spdk_nvmf_registrant) link;
|
|
|
|
struct spdk_uuid hostid;
|
|
|
|
/* Registration key */
|
|
|
|
uint64_t rkey;
|
|
|
|
};
|
|
|
|
|
2017-08-17 16:01:51 +00:00
|
|
|
struct spdk_nvmf_ns {
|
2019-01-08 06:14:53 +00:00
|
|
|
uint32_t nsid;
|
2021-08-25 02:58:23 +00:00
|
|
|
uint32_t anagrpid;
|
2017-12-14 02:19:57 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem;
|
2017-08-17 16:01:51 +00:00
|
|
|
struct spdk_bdev *bdev;
|
|
|
|
struct spdk_bdev_desc *desc;
|
2017-08-22 15:54:12 +00:00
|
|
|
struct spdk_nvmf_ns_opts opts;
|
2019-01-22 06:33:08 +00:00
|
|
|
/* reservation notificaton mask */
|
|
|
|
uint32_t mask;
|
2019-02-28 02:50:03 +00:00
|
|
|
/* generation code */
|
|
|
|
uint32_t gen;
|
|
|
|
/* registrants head */
|
|
|
|
TAILQ_HEAD(, spdk_nvmf_registrant) registrants;
|
2019-02-28 12:56:04 +00:00
|
|
|
/* current reservation key */
|
|
|
|
uint64_t crkey;
|
|
|
|
/* reservation type */
|
|
|
|
enum spdk_nvme_reservation_type rtype;
|
|
|
|
/* current reservation holder, only valid if reservation type can only have one holder */
|
|
|
|
struct spdk_nvmf_registrant *holder;
|
2019-05-22 05:56:37 +00:00
|
|
|
/* Persist Through Power Loss file which contains the persistent reservation */
|
|
|
|
char *ptpl_file;
|
2019-06-11 06:21:01 +00:00
|
|
|
/* Persist Through Power Loss feature is enabled */
|
|
|
|
bool ptpl_activated;
|
2021-04-13 11:14:50 +00:00
|
|
|
/* ZCOPY supported on bdev device */
|
|
|
|
bool zcopy;
|
2017-08-17 16:01:51 +00:00
|
|
|
};
|
|
|
|
|
2018-03-14 23:46:16 +00:00
|
|
|
struct spdk_nvmf_ctrlr_feat {
|
2018-03-15 00:33:26 +00:00
|
|
|
union spdk_nvme_feat_arbitration arbitration;
|
|
|
|
union spdk_nvme_feat_power_management power_management;
|
|
|
|
union spdk_nvme_feat_error_recovery error_recovery;
|
2018-03-14 23:46:16 +00:00
|
|
|
union spdk_nvme_feat_volatile_write_cache volatile_write_cache;
|
|
|
|
union spdk_nvme_feat_number_of_queues number_of_queues;
|
2021-07-13 15:51:06 +00:00
|
|
|
union spdk_nvme_feat_interrupt_coalescing interrupt_coalescing;
|
|
|
|
union spdk_nvme_feat_interrupt_vector_configuration interrupt_vector_configuration;
|
2018-03-15 00:33:26 +00:00
|
|
|
union spdk_nvme_feat_write_atomicity write_atomicity;
|
2018-03-14 23:46:16 +00:00
|
|
|
union spdk_nvme_feat_async_event_configuration async_event_configuration;
|
|
|
|
union spdk_nvme_feat_keep_alive_timer keep_alive_timer;
|
|
|
|
};
|
|
|
|
|
2019-03-01 08:58:57 +00:00
|
|
|
/*
|
|
|
|
* NVMf reservation notificaton log page.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_reservation_log {
|
|
|
|
struct spdk_nvme_reservation_notification_log log;
|
|
|
|
TAILQ_ENTRY(spdk_nvmf_reservation_log) link;
|
2019-04-02 05:06:51 +00:00
|
|
|
struct spdk_nvmf_ctrlr *ctrlr;
|
2019-03-01 08:58:57 +00:00
|
|
|
};
|
|
|
|
|
2020-11-17 03:09:29 +00:00
|
|
|
/*
|
|
|
|
* NVMf async event completion.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_async_event_completion {
|
|
|
|
union spdk_nvme_async_event_completion event;
|
|
|
|
STAILQ_ENTRY(spdk_nvmf_async_event_completion) link;
|
|
|
|
};
|
|
|
|
|
2017-08-29 20:22:37 +00:00
|
|
|
/*
|
|
|
|
* This structure represents an NVMe-oF controller,
|
|
|
|
* which is like a "session" in networking terms.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_ctrlr {
|
|
|
|
uint16_t cntlid;
|
2019-07-18 08:15:54 +00:00
|
|
|
char hostnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
2018-03-02 19:49:36 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsys;
|
2017-08-29 20:22:37 +00:00
|
|
|
|
2020-06-03 15:15:19 +00:00
|
|
|
struct spdk_nvmf_ctrlr_data cdata;
|
|
|
|
|
2020-02-03 22:12:06 +00:00
|
|
|
struct spdk_nvmf_registers vcprop;
|
2017-08-29 20:22:37 +00:00
|
|
|
|
2018-03-14 23:46:16 +00:00
|
|
|
struct spdk_nvmf_ctrlr_feat feat;
|
|
|
|
|
2018-08-13 17:26:26 +00:00
|
|
|
struct spdk_nvmf_qpair *admin_qpair;
|
|
|
|
struct spdk_thread *thread;
|
2018-06-01 22:10:12 +00:00
|
|
|
struct spdk_bit_array *qpair_mask;
|
2018-06-01 22:00:20 +00:00
|
|
|
|
2020-09-01 13:51:45 +00:00
|
|
|
const struct spdk_nvmf_subsystem_listener *listener;
|
|
|
|
|
2020-05-20 16:20:16 +00:00
|
|
|
struct spdk_nvmf_request *aer_req[NVMF_MAX_ASYNC_EVENTS];
|
2020-11-17 03:09:29 +00:00
|
|
|
STAILQ_HEAD(, spdk_nvmf_async_event_completion) async_events;
|
2020-12-05 11:06:15 +00:00
|
|
|
uint64_t notice_aen_mask;
|
2020-05-20 16:20:16 +00:00
|
|
|
uint8_t nr_aer_reqs;
|
2018-12-06 04:32:26 +00:00
|
|
|
struct spdk_uuid hostid;
|
2017-08-29 20:22:37 +00:00
|
|
|
|
2021-01-22 20:25:32 +00:00
|
|
|
uint32_t association_timeout; /* in milliseconds */
|
2018-03-23 21:20:04 +00:00
|
|
|
uint16_t changed_ns_list_count;
|
|
|
|
struct spdk_nvme_ns_list changed_ns_list;
|
2019-03-01 08:58:57 +00:00
|
|
|
uint64_t log_page_count;
|
|
|
|
uint8_t num_avail_log_pages;
|
|
|
|
TAILQ_HEAD(log_page_head, spdk_nvmf_reservation_log) log_head;
|
2018-03-23 21:20:04 +00:00
|
|
|
|
2019-01-07 10:47:29 +00:00
|
|
|
/* Time to trigger keep-alive--poller_time = now_tick + period */
|
2019-07-10 22:41:54 +00:00
|
|
|
uint64_t last_keep_alive_tick;
|
|
|
|
struct spdk_poller *keep_alive_poller;
|
2019-01-07 10:47:29 +00:00
|
|
|
|
2020-06-21 07:47:34 +00:00
|
|
|
struct spdk_poller *association_timer;
|
|
|
|
|
2021-10-19 10:12:09 +00:00
|
|
|
struct spdk_poller *cc_timer;
|
|
|
|
|
2019-07-10 22:41:54 +00:00
|
|
|
bool dif_insert_or_strip;
|
2020-08-07 01:22:38 +00:00
|
|
|
bool in_destruct;
|
2021-01-22 20:44:05 +00:00
|
|
|
bool disconnect_in_progress;
|
2021-10-19 09:53:40 +00:00
|
|
|
/* valid only when disconnect_in_progress is true */
|
|
|
|
bool disconnect_is_shn;
|
2021-05-16 10:45:11 +00:00
|
|
|
bool acre_enabled;
|
2019-07-10 22:41:54 +00:00
|
|
|
|
|
|
|
TAILQ_ENTRY(spdk_nvmf_ctrlr) link;
|
2017-08-29 20:22:37 +00:00
|
|
|
};
|
|
|
|
|
2017-08-17 16:01:51 +00:00
|
|
|
struct spdk_nvmf_subsystem {
|
2020-10-06 19:02:00 +00:00
|
|
|
struct spdk_thread *thread;
|
2020-10-06 19:10:10 +00:00
|
|
|
|
2020-10-06 19:02:00 +00:00
|
|
|
uint32_t id;
|
2020-10-06 19:10:10 +00:00
|
|
|
|
2020-10-06 19:02:00 +00:00
|
|
|
enum spdk_nvmf_subsystem_state state;
|
|
|
|
enum spdk_nvmf_subtype subtype;
|
2020-10-06 19:10:10 +00:00
|
|
|
|
2020-10-06 19:02:00 +00:00
|
|
|
uint16_t next_cntlid;
|
2020-10-06 19:10:10 +00:00
|
|
|
struct {
|
|
|
|
uint8_t allow_any_host : 1;
|
|
|
|
uint8_t allow_any_listener : 1;
|
|
|
|
uint8_t ana_reporting : 1;
|
|
|
|
uint8_t reserved : 5;
|
|
|
|
} flags;
|
|
|
|
|
|
|
|
/* boolean for state change synchronization */
|
|
|
|
bool changing_state;
|
2017-08-17 16:01:51 +00:00
|
|
|
|
2021-03-03 08:48:19 +00:00
|
|
|
bool destroying;
|
|
|
|
bool async_destroy;
|
|
|
|
|
2020-10-06 19:02:00 +00:00
|
|
|
struct spdk_nvmf_tgt *tgt;
|
2017-08-18 22:26:41 +00:00
|
|
|
|
2018-02-14 21:19:02 +00:00
|
|
|
/* Array of pointers to namespaces of size max_nsid indexed by nsid - 1 */
|
2020-10-06 19:02:00 +00:00
|
|
|
struct spdk_nvmf_ns **ns;
|
|
|
|
uint32_t max_nsid;
|
2017-08-17 16:01:51 +00:00
|
|
|
|
2021-04-12 11:01:16 +00:00
|
|
|
uint16_t min_cntlid;
|
|
|
|
uint16_t max_cntlid;
|
|
|
|
|
2020-02-15 05:47:36 +00:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_ctrlr) ctrlrs;
|
2020-10-06 20:50:37 +00:00
|
|
|
|
2020-10-08 17:28:43 +00:00
|
|
|
/* A mutex used to protect the hosts list and allow_any_host flag. Unlike the namespace
|
2020-10-06 20:50:37 +00:00
|
|
|
* array, this list is not used on the I/O path (it's needed for handling things like
|
|
|
|
* the CONNECT command), so use a mutex to protect it instead of requiring the subsystem
|
|
|
|
* state to be paused. This removes the requirement to pause the subsystem when hosts
|
|
|
|
* are added or removed dynamically. */
|
|
|
|
pthread_mutex_t mutex;
|
2020-02-15 05:47:36 +00:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_host) hosts;
|
|
|
|
TAILQ_HEAD(, spdk_nvmf_subsystem_listener) listeners;
|
2017-08-17 16:01:51 +00:00
|
|
|
|
2020-10-06 19:02:00 +00:00
|
|
|
TAILQ_ENTRY(spdk_nvmf_subsystem) entries;
|
2020-10-06 19:16:19 +00:00
|
|
|
|
2021-03-03 08:48:19 +00:00
|
|
|
nvmf_subsystem_destroy_cb async_destroy_cb;
|
|
|
|
void *async_destroy_cb_arg;
|
|
|
|
|
2020-10-06 19:16:19 +00:00
|
|
|
char sn[SPDK_NVME_CTRLR_SN_LEN + 1];
|
|
|
|
char mn[SPDK_NVME_CTRLR_MN_LEN + 1];
|
|
|
|
char subnqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
2021-08-25 02:58:23 +00:00
|
|
|
|
|
|
|
/* Array of namespace count per ANA group of size max_nsid indexed anagrpid - 1
|
|
|
|
* It will be enough for ANA group to use the same size as namespaces.
|
|
|
|
*/
|
|
|
|
uint32_t *ana_group;
|
2017-08-17 16:01:51 +00:00
|
|
|
};
|
|
|
|
|
2020-05-09 22:57:13 +00:00
|
|
|
int nvmf_poll_group_add_transport(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_transport *transport);
|
|
|
|
int nvmf_poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
int nvmf_poll_group_add_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
|
|
|
|
void nvmf_poll_group_remove_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
|
|
|
|
void nvmf_poll_group_pause_subsystem(struct spdk_nvmf_poll_group *group,
|
2020-11-02 17:12:11 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
uint32_t nsid,
|
|
|
|
spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
|
2020-05-09 22:57:13 +00:00
|
|
|
void nvmf_poll_group_resume_subsystem(struct spdk_nvmf_poll_group *group,
|
|
|
|
struct spdk_nvmf_subsystem *subsystem, spdk_nvmf_poll_group_mod_done cb_fn, void *cb_arg);
|
|
|
|
|
2020-10-26 10:08:32 +00:00
|
|
|
void nvmf_update_discovery_log(struct spdk_nvmf_tgt *tgt, const char *hostnqn);
|
2021-08-12 16:01:39 +00:00
|
|
|
void nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt, const char *hostnqn, struct iovec *iov,
|
|
|
|
uint32_t iovcnt, uint64_t offset, uint32_t length,
|
|
|
|
struct spdk_nvme_transport_id *cmd_source_trid);
|
2020-05-09 22:57:13 +00:00
|
|
|
|
|
|
|
void nvmf_ctrlr_destruct(struct spdk_nvmf_ctrlr *ctrlr);
|
|
|
|
int nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req);
|
|
|
|
bool nvmf_ctrlr_dsm_supported(struct spdk_nvmf_ctrlr *ctrlr);
|
|
|
|
bool nvmf_ctrlr_write_zeroes_supported(struct spdk_nvmf_ctrlr *ctrlr);
|
|
|
|
void nvmf_ctrlr_ns_changed(struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid);
|
2021-04-13 11:14:50 +00:00
|
|
|
bool nvmf_ctrlr_use_zcopy(struct spdk_nvmf_request *req);
|
2020-05-09 22:57:13 +00:00
|
|
|
|
|
|
|
void nvmf_bdev_ctrlr_identify_ns(struct spdk_nvmf_ns *ns, struct spdk_nvme_ns_data *nsdata,
|
|
|
|
bool dif_insert_or_strip);
|
|
|
|
int nvmf_bdev_ctrlr_read_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_write_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_compare_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_compare_and_write_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
2019-12-03 12:08:14 +00:00
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *cmp_req, struct spdk_nvmf_request *write_req);
|
2020-05-09 22:57:13 +00:00
|
|
|
int nvmf_bdev_ctrlr_write_zeroes_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_flush_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
int nvmf_bdev_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
|
|
|
bool nvmf_bdev_ctrlr_get_dif_ctx(struct spdk_bdev *bdev, struct spdk_nvme_cmd *cmd,
|
|
|
|
struct spdk_dif_ctx *dif_ctx);
|
2021-04-13 11:14:50 +00:00
|
|
|
bool nvmf_bdev_zcopy_enabled(struct spdk_bdev *bdev);
|
2020-05-09 22:57:13 +00:00
|
|
|
|
|
|
|
int nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
struct spdk_nvmf_ctrlr *ctrlr);
|
|
|
|
void nvmf_subsystem_remove_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
struct spdk_nvmf_ctrlr *ctrlr);
|
|
|
|
void nvmf_subsystem_remove_all_listeners(struct spdk_nvmf_subsystem *subsystem,
|
2020-01-02 19:00:45 +00:00
|
|
|
bool stop);
|
2020-05-09 22:57:13 +00:00
|
|
|
struct spdk_nvmf_ctrlr *nvmf_subsystem_get_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
2017-09-11 23:50:29 +00:00
|
|
|
uint16_t cntlid);
|
2020-05-09 22:57:13 +00:00
|
|
|
struct spdk_nvmf_subsystem_listener *nvmf_subsystem_find_listener(
|
2020-02-15 05:47:36 +00:00
|
|
|
struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const struct spdk_nvme_transport_id *trid);
|
2020-05-09 22:57:13 +00:00
|
|
|
struct spdk_nvmf_listener *nvmf_transport_find_listener(
|
2020-02-15 06:19:24 +00:00
|
|
|
struct spdk_nvmf_transport *transport,
|
|
|
|
const struct spdk_nvme_transport_id *trid);
|
2021-08-31 13:44:05 +00:00
|
|
|
void nvmf_transport_dump_opts(struct spdk_nvmf_transport *transport, struct spdk_json_write_ctx *w,
|
|
|
|
bool named);
|
2021-09-01 08:28:10 +00:00
|
|
|
void nvmf_transport_listen_dump_opts(struct spdk_nvmf_transport *transport,
|
|
|
|
const struct spdk_nvme_transport_id *trid, struct spdk_json_write_ctx *w);
|
2020-09-13 16:39:59 +00:00
|
|
|
void nvmf_subsystem_set_ana_state(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const struct spdk_nvme_transport_id *trid,
|
2021-08-25 03:00:51 +00:00
|
|
|
enum spdk_nvme_ana_state ana_state, uint32_t anagrpid,
|
2020-09-13 16:39:59 +00:00
|
|
|
spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn, void *cb_arg);
|
2021-08-05 22:13:04 +00:00
|
|
|
bool nvmf_subsystem_get_ana_reporting(struct spdk_nvmf_subsystem *subsystem);
|
2020-01-23 00:10:36 +00:00
|
|
|
|
2021-04-12 11:01:16 +00:00
|
|
|
/**
|
|
|
|
* Sets the controller ID range for a subsystem.
|
|
|
|
* Valid range is [1, 0xFFEF].
|
|
|
|
*
|
|
|
|
* May only be performed on subsystems in the INACTIVE state.
|
|
|
|
*
|
|
|
|
* \param subsystem Subsystem to modify.
|
|
|
|
* \param min_cntlid Minimum controller ID.
|
|
|
|
* \param max_cntlid Maximum controller ID.
|
|
|
|
*
|
|
|
|
* \return 0 on success, or negated errno value on failure.
|
|
|
|
*/
|
|
|
|
int nvmf_subsystem_set_cntlid_range(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
uint16_t min_cntlid, uint16_t max_cntlid);
|
|
|
|
|
2020-05-09 22:57:13 +00:00
|
|
|
int nvmf_ctrlr_async_event_ns_notice(struct spdk_nvmf_ctrlr *ctrlr);
|
2020-09-01 12:00:20 +00:00
|
|
|
int nvmf_ctrlr_async_event_ana_change_notice(struct spdk_nvmf_ctrlr *ctrlr);
|
2020-10-26 10:08:32 +00:00
|
|
|
int nvmf_ctrlr_async_event_discovery_log_change_notice(struct spdk_nvmf_ctrlr *ctrlr);
|
2020-05-09 22:57:13 +00:00
|
|
|
void nvmf_ctrlr_async_event_reservation_notification(struct spdk_nvmf_ctrlr *ctrlr);
|
2021-09-23 08:21:53 +00:00
|
|
|
int nvmf_ctrlr_async_event_error_event(struct spdk_nvmf_ctrlr *ctrlr,
|
|
|
|
union spdk_nvme_async_event_completion event);
|
2020-05-09 22:57:13 +00:00
|
|
|
void nvmf_ns_reservation_request(void *ctx);
|
|
|
|
void nvmf_ctrlr_reservation_notice_log(struct spdk_nvmf_ctrlr *ctrlr,
|
|
|
|
struct spdk_nvmf_ns *ns,
|
|
|
|
enum spdk_nvme_reservation_notification_log_page_type type);
|
2017-08-29 20:22:37 +00:00
|
|
|
|
2018-07-27 17:39:25 +00:00
|
|
|
/*
|
|
|
|
* Abort aer is sent on a per controller basis and sends a completion for the aer to the host.
|
|
|
|
* This function should be called when attempting to recover in error paths when it is OK for
|
|
|
|
* the host to send a subsequent AER.
|
|
|
|
*/
|
2020-05-09 22:57:13 +00:00
|
|
|
void nvmf_ctrlr_abort_aer(struct spdk_nvmf_ctrlr *ctrlr);
|
2018-07-27 17:39:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Free aer simply frees the rdma resources for the aer without informing the host.
|
|
|
|
* This function should be called when deleting a qpair when one wants to make sure
|
|
|
|
* the qpair is completely empty before freeing the request. The reason we free the
|
|
|
|
* AER without sending a completion is to prevent the host from sending another AER.
|
|
|
|
*/
|
2020-05-09 22:57:13 +00:00
|
|
|
void nvmf_qpair_free_aer(struct spdk_nvmf_qpair *qpair);
|
2018-06-24 22:25:31 +00:00
|
|
|
|
2020-07-22 22:29:21 +00:00
|
|
|
int nvmf_ctrlr_abort_request(struct spdk_nvmf_request *req);
|
2020-06-21 12:11:20 +00:00
|
|
|
|
2017-08-18 01:20:49 +00:00
|
|
|
static inline struct spdk_nvmf_ns *
|
2020-05-09 22:57:13 +00:00
|
|
|
_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
|
2017-08-18 01:20:49 +00:00
|
|
|
{
|
|
|
|
/* NOTE: This implicitly also checks for 0, since 0 - 1 wraps around to UINT32_MAX. */
|
|
|
|
if (spdk_unlikely(nsid - 1 >= subsystem->max_nsid)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 21:19:02 +00:00
|
|
|
return subsystem->ns[nsid - 1];
|
2017-08-18 01:20:49 +00:00
|
|
|
}
|
|
|
|
|
2018-02-06 16:16:49 +00:00
|
|
|
static inline bool
|
2020-05-09 22:57:13 +00:00
|
|
|
nvmf_qpair_is_admin_queue(struct spdk_nvmf_qpair *qpair)
|
2018-02-06 16:16:49 +00:00
|
|
|
{
|
|
|
|
return qpair->qid == 0;
|
|
|
|
}
|
|
|
|
|
2021-04-13 11:14:50 +00:00
|
|
|
/**
|
|
|
|
* Initiates a zcopy start operation
|
|
|
|
*
|
|
|
|
* \param bdev The \ref spdk_bdev
|
|
|
|
* \param desc The \ref spdk_bdev_desc
|
|
|
|
* \param ch The \ref spdk_io_channel
|
|
|
|
* \param req The \ref spdk_nvmf_request passed to the bdev for processing
|
|
|
|
*
|
|
|
|
* \return 0 upon success
|
|
|
|
* \return <0 if the zcopy operation could not be started
|
|
|
|
*/
|
|
|
|
int nvmf_bdev_ctrlr_start_zcopy(struct spdk_bdev *bdev,
|
|
|
|
struct spdk_bdev_desc *desc,
|
|
|
|
struct spdk_io_channel *ch,
|
|
|
|
struct spdk_nvmf_request *req);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ends a zcopy operation
|
|
|
|
*
|
|
|
|
* \param req The NVMe-oF request
|
2021-07-26 17:16:54 +00:00
|
|
|
* \param commit Flag indicating whether the buffers shoule be committed
|
2021-04-13 11:14:50 +00:00
|
|
|
*
|
|
|
|
* \return 0 upon success
|
|
|
|
* \return <0 on error
|
|
|
|
*/
|
2021-07-26 17:16:54 +00:00
|
|
|
int nvmf_bdev_ctrlr_end_zcopy(struct spdk_nvmf_request *req, bool commit);
|
2021-04-13 11:14:50 +00:00
|
|
|
|
2016-06-06 21:44:30 +00:00
|
|
|
#endif /* __NVMF_INTERNAL_H__ */
|