2016-06-06 14:44:30 -07:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-07-06 10:50:44 -07:00
|
|
|
#ifndef SPDK_NVMF_SUBSYSTEM_H
|
|
|
|
#define SPDK_NVMF_SUBSYSTEM_H
|
2016-06-06 14:44:30 -07:00
|
|
|
|
2016-07-21 11:24:17 -07:00
|
|
|
#include "nvmf_internal.h"
|
|
|
|
|
2016-06-06 14:44:30 -07:00
|
|
|
#include "spdk/nvme.h"
|
|
|
|
#include "spdk/queue.h"
|
2016-07-22 12:06:25 +08:00
|
|
|
#include "spdk/bdev.h"
|
2016-06-06 14:44:30 -07:00
|
|
|
|
|
|
|
struct spdk_nvmf_conn;
|
2016-07-22 12:06:25 +08:00
|
|
|
struct spdk_nvmf_subsystem;
|
2016-08-01 14:02:59 +08:00
|
|
|
struct spdk_nvmf_request;
|
|
|
|
struct nvmf_session;
|
2016-06-06 14:44:30 -07:00
|
|
|
|
|
|
|
#define MAX_NQN_SIZE 255
|
2016-07-22 12:06:25 +08:00
|
|
|
#define MAX_VIRTUAL_NAMESPACE 16
|
2016-06-06 14:44:30 -07:00
|
|
|
|
2016-07-20 17:54:53 +08:00
|
|
|
enum spdk_nvmf_subsystem_mode {
|
|
|
|
NVMF_SUBSYSTEM_MODE_DIRECT = 0,
|
|
|
|
NVMF_SUBSYSTEM_MODE_VIRTUAL = 1,
|
|
|
|
};
|
|
|
|
|
2016-07-15 14:16:59 -07:00
|
|
|
struct spdk_nvmf_listen_addr {
|
|
|
|
char *traddr;
|
|
|
|
char *trsvc; /* TODO: Change to trsvcid */
|
|
|
|
const struct spdk_nvmf_transport *transport;
|
|
|
|
TAILQ_ENTRY(spdk_nvmf_listen_addr) link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_nvmf_host {
|
|
|
|
char *nqn;
|
|
|
|
TAILQ_ENTRY(spdk_nvmf_host) link;
|
2016-07-11 13:31:46 -07:00
|
|
|
};
|
|
|
|
|
2016-07-22 12:06:25 +08:00
|
|
|
struct spdk_nvmf_ns {
|
|
|
|
uint32_t nsid;
|
|
|
|
struct spdk_bdev *bdev;
|
|
|
|
};
|
|
|
|
|
2016-08-01 14:02:59 +08:00
|
|
|
struct spdk_nvmf_ctrlr_ops {
|
|
|
|
/**
|
|
|
|
* Get NVMe identify controller data.
|
|
|
|
*/
|
|
|
|
void (*ctrlr_get_data)(struct nvmf_session *session);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process admin command.
|
|
|
|
*/
|
|
|
|
int (*process_admin_cmd)(struct spdk_nvmf_request *req);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process IO command.
|
|
|
|
*/
|
|
|
|
int (*process_io_cmd)(struct spdk_nvmf_request *req);
|
|
|
|
|
|
|
|
/**
|
2016-08-15 15:42:12 -07:00
|
|
|
* Poll for completions.
|
2016-08-01 14:02:59 +08:00
|
|
|
*/
|
2016-08-15 15:42:12 -07:00
|
|
|
void (*poll_for_completions)(struct nvmf_session *session);
|
2016-08-01 14:02:59 +08:00
|
|
|
};
|
2016-07-22 12:06:25 +08:00
|
|
|
|
2016-08-01 14:02:59 +08:00
|
|
|
struct spdk_nvmf_controller {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct nvmf_session *session;
|
|
|
|
struct spdk_nvme_ctrlr *ctrlr;
|
|
|
|
struct spdk_nvme_qpair *io_qpair;
|
|
|
|
} direct;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct nvmf_session *session;
|
|
|
|
struct spdk_nvmf_ns *ns_list[MAX_VIRTUAL_NAMESPACE];
|
|
|
|
uint16_t ns_count;
|
|
|
|
} virtual;
|
|
|
|
} dev;
|
|
|
|
|
|
|
|
const struct spdk_nvmf_ctrlr_ops *ops;
|
2016-07-22 12:06:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-06-06 14:44:30 -07:00
|
|
|
/*
|
|
|
|
* The NVMf subsystem, as indicated in the specification, is a collection
|
|
|
|
* of virtual controller sessions. Any individual controller session has
|
|
|
|
* access to all the NVMe device/namespaces maintained by the subsystem.
|
|
|
|
*/
|
|
|
|
struct spdk_nvmf_subsystem {
|
|
|
|
uint16_t num;
|
2016-08-11 16:00:45 -07:00
|
|
|
uint32_t lcore;
|
2016-06-06 14:44:30 -07:00
|
|
|
char subnqn[MAX_NQN_SIZE];
|
2016-07-20 17:54:53 +08:00
|
|
|
enum spdk_nvmf_subsystem_mode mode;
|
2016-07-15 13:10:33 -07:00
|
|
|
enum spdk_nvmf_subtype subtype;
|
2016-07-07 16:32:26 -07:00
|
|
|
struct nvmf_session *session;
|
2016-08-01 14:02:59 +08:00
|
|
|
struct spdk_nvmf_controller ctrlr;
|
2016-07-15 11:34:11 -07:00
|
|
|
|
2016-08-11 16:00:45 -07:00
|
|
|
struct spdk_poller *poller;
|
2016-06-06 14:44:30 -07:00
|
|
|
|
2016-07-15 14:16:59 -07:00
|
|
|
TAILQ_HEAD(, spdk_nvmf_listen_addr) listen_addrs;
|
|
|
|
uint32_t num_listen_addrs;
|
|
|
|
|
|
|
|
TAILQ_HEAD(, spdk_nvmf_host) hosts;
|
|
|
|
uint32_t num_hosts;
|
2016-06-06 14:44:30 -07:00
|
|
|
|
2016-07-11 13:31:46 -07:00
|
|
|
TAILQ_ENTRY(spdk_nvmf_subsystem) entries;
|
2016-06-06 14:44:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct spdk_nvmf_subsystem *
|
2016-07-15 10:42:46 -07:00
|
|
|
nvmf_create_subsystem(int num, const char *name,
|
2016-07-15 13:10:33 -07:00
|
|
|
enum spdk_nvmf_subtype subtype,
|
2016-07-15 10:42:46 -07:00
|
|
|
uint32_t lcore);
|
2016-06-06 14:44:30 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
|
|
|
struct spdk_nvmf_subsystem *
|
2016-07-15 14:16:59 -07:00
|
|
|
nvmf_find_subsystem(const char *subnqn, const char *hostnqn);
|
2016-06-06 14:44:30 -07:00
|
|
|
|
|
|
|
int
|
2016-07-15 14:16:59 -07:00
|
|
|
spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
const struct spdk_nvmf_transport *transport,
|
|
|
|
char *traddr, char *trsvc);
|
2016-07-11 15:12:11 -07:00
|
|
|
|
|
|
|
int
|
2016-07-15 14:16:59 -07:00
|
|
|
spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
char *host_nqn);
|
|
|
|
|
|
|
|
int
|
|
|
|
nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
|
|
|
struct spdk_nvme_ctrlr *ctrlr);
|
2016-06-06 14:44:30 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
spdk_shutdown_nvmf_subsystems(void);
|
|
|
|
|
2016-06-23 07:23:36 +08:00
|
|
|
void
|
|
|
|
spdk_format_discovery_log(struct spdk_nvmf_discovery_log_page *disc_log, uint32_t length);
|
|
|
|
|
2016-08-16 10:43:50 -07:00
|
|
|
void spdk_nvmf_subsystem_poll(struct spdk_nvmf_subsystem *subsystem);
|
|
|
|
|
2016-08-01 14:02:59 +08:00
|
|
|
extern const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops;
|
2016-07-06 10:50:44 -07:00
|
|
|
#endif /* SPDK_NVMF_SUBSYSTEM_H */
|