nvme: Add nvme over fabrics support
Change-Id: I6f6259e77baa5dc5861f31ec4a9034e15297d333 Signed-off-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
parent
af9eca84d6
commit
246c39a7ee
@ -63,6 +63,9 @@ SPDK_LIBS = \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_event.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_app_rpc.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
LIBS += -Wl,--whole-archive $(SPDK_LIBS) -Wl,--no-whole-archive
|
||||
LIBS += -lcrypto $(ENV_LINKER_ARGS)
|
||||
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
|
||||
|
@ -113,6 +113,7 @@ run_test test/nvmf/fio/fio.sh
|
||||
run_test test/nvmf/filesystem/filesystem.sh
|
||||
run_test test/nvmf/discovery/discovery.sh
|
||||
run_test test/nvmf/nvme_cli/nvme_cli.sh
|
||||
run_test test/nvmf/host/identify.sh
|
||||
|
||||
timing_exit nvmf
|
||||
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -48,6 +48,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -36,10 +36,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_config.h>
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
@ -66,6 +68,8 @@ static struct spdk_nvme_intel_marketing_description_page intel_md_page;
|
||||
|
||||
static bool g_hex_dump = false;
|
||||
|
||||
static struct spdk_nvme_discover_info info;
|
||||
|
||||
static void
|
||||
hex_dump(const void *data, size_t size)
|
||||
{
|
||||
@ -845,26 +849,73 @@ usage(const char *program_name)
|
||||
{
|
||||
printf("%s [options]", program_name);
|
||||
printf("\n");
|
||||
printf("\t-x print hex dump of raw data\n");
|
||||
printf("options:\n");
|
||||
printf(" -x print hex dump of raw data\n");
|
||||
printf("\t-a addr address for nvmf target\n");
|
||||
printf("\t-s service service id for nvmf target\n");
|
||||
printf("\t-n nqn nqn for nvmf target\n");
|
||||
|
||||
spdk_tracelog_usage(stdout, "-t");
|
||||
|
||||
printf("\t-v - verbose (enable warnings)\n");
|
||||
printf("\t-H - show this usage\n");
|
||||
}
|
||||
|
||||
static int
|
||||
parse_args(int argc, char **argv)
|
||||
{
|
||||
int op;
|
||||
int op, rc;
|
||||
|
||||
while ((op = getopt(argc, argv, "x")) != -1) {
|
||||
while ((op = getopt(argc, argv, "a:n:s:t:x:H")) != -1) {
|
||||
switch (op) {
|
||||
case 'x':
|
||||
g_hex_dump = true;
|
||||
break;
|
||||
case 't':
|
||||
rc = spdk_log_set_trace_flag(optarg);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "unknown flag\n");
|
||||
usage(argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
|
||||
argv[0]);
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
#endif
|
||||
break;
|
||||
case 'a':
|
||||
info.traddr = optarg;
|
||||
break;
|
||||
case 's':
|
||||
info.trsvcid = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
info.nqn = optarg;
|
||||
break;
|
||||
case 'H':
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!info.traddr || !info.trsvcid || !info.nqn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((strlen(info.traddr) > 255)) {
|
||||
printf("The string len of traddr should <= 255\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((strlen(info.nqn) > 223)) {
|
||||
printf("The string len of nqn should <= 223\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
info.type = SPDK_NVME_TRANSPORT_RDMA;
|
||||
optind = 1;
|
||||
|
||||
return 0;
|
||||
@ -889,6 +940,7 @@ static const char *ealargs[] = {
|
||||
"identify",
|
||||
"-c 0x1",
|
||||
"-n 4",
|
||||
"-m 512",
|
||||
"--proc-type=auto",
|
||||
};
|
||||
|
||||
@ -898,6 +950,7 @@ int main(int argc, char **argv)
|
||||
|
||||
rc = parse_args(argc, argv);
|
||||
if (rc != 0) {
|
||||
printf("parse_args error\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -910,6 +963,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
if (info.type == SPDK_NVME_TRANSPORT_RDMA) {
|
||||
if (spdk_nvme_discover(&info, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (spdk_nvme_probe(NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
rc = 1;
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -86,6 +86,47 @@ struct spdk_nvme_ctrlr_opts {
|
||||
* are sent.
|
||||
*/
|
||||
uint32_t keep_alive_timeout_ms;
|
||||
/**
|
||||
* Specify the retry number when there is issue with the transport
|
||||
*/
|
||||
int transport_retry_count;
|
||||
/**
|
||||
* The queue depth of each NVMe I/O queue.
|
||||
*/
|
||||
int queue_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Define the NVMe transport type
|
||||
*/
|
||||
enum spdk_nvme_transport_type {
|
||||
SPDK_NVME_TRANSPORT_PCIE,
|
||||
SPDK_NVME_TRANSPORT_RDMA,
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* A pointer to this structure will be provided for connecting remote NVMe controller.
|
||||
*/
|
||||
struct spdk_nvme_discover_info {
|
||||
/**
|
||||
* Specify the NVMe transport type;
|
||||
*/
|
||||
enum spdk_nvme_transport_type type;
|
||||
/**
|
||||
* Subsystem NQN to be connected
|
||||
*/
|
||||
const char *nqn;
|
||||
/**
|
||||
* Transport address of the NVMe over fabrics target. For transports which uses IP
|
||||
* addressing (e.g. rdma), this should be an IP-based address.
|
||||
*/
|
||||
const char *traddr;
|
||||
/**
|
||||
* Specifiy the transport service identifier. For transports which uses IP addressing
|
||||
* (e.g. rdma), this field shoud be the port number.
|
||||
*/
|
||||
const char *trsvcid;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -105,6 +146,21 @@ struct spdk_nvme_probe_info {
|
||||
* If not available, each field will be filled with all 0xFs.
|
||||
*/
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
/**
|
||||
* Subsystem NQN which is newly discovered
|
||||
*/
|
||||
const char *nqn;
|
||||
/**
|
||||
* Transport address of the NVMe over fabrics target. For transports which uses IP
|
||||
* addressing (e.g. rdma), this should be an IP-based address.
|
||||
*/
|
||||
const char *traddr;
|
||||
/**
|
||||
* Specifiy the transport service identifier. For transports which uses IP addressing
|
||||
* (e.g. rdma), this field shoud be the port number.
|
||||
*/
|
||||
const char *trsvcid;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -137,6 +193,24 @@ typedef void (*spdk_nvme_attach_cb)(void *cb_ctx, const struct spdk_nvme_probe_i
|
||||
*/
|
||||
typedef void (*spdk_nvme_remove_cb)(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr);
|
||||
|
||||
/**
|
||||
* \brief discover the remote Controller via NVMe over fabrics protocol
|
||||
*
|
||||
* \param cb_ctx Opaque value which will be passed back in cb_ctx parameter of the callbacks.
|
||||
* \param info which specifies the info used to discover the NVMe over fabrics target.
|
||||
* \param probe_cb will be called once per NVMe device found in the system.
|
||||
* \param attach_cb will be called for devices for which probe_cb returned true once that NVMe
|
||||
* controller has been attached to the userspace driver.
|
||||
* \param remove_cb will be called for devices that were attached in a previous spdk_nvme_probe()
|
||||
* call but are no longer attached to the system. Optional; specify NULL if removal notices are not
|
||||
* desired.
|
||||
*
|
||||
*/
|
||||
int spdk_nvme_discover(const struct spdk_nvme_discover_info *info,
|
||||
void *cb_ctx, spdk_nvme_probe_cb probe_cb,
|
||||
spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb);
|
||||
|
||||
/**
|
||||
* \brief Enumerate the NVMe devices attached to the system and attach the userspace NVMe driver
|
||||
* to them if desired.
|
||||
|
@ -46,6 +46,9 @@
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/* Minimum number of admin queue entries defined by NVMe over Fabrics spec */
|
||||
#define SPDK_NVMF_MIN_ADMIN_QUEUE_ENTRIES 32
|
||||
|
||||
struct spdk_nvmf_capsule_cmd {
|
||||
uint8_t opcode;
|
||||
uint8_t reserved1;
|
||||
|
@ -36,6 +36,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS)
|
||||
C_SRCS = nvme_ctrlr_cmd.c nvme_ctrlr.c nvme_ns_cmd.c nvme_ns.c nvme_pcie.c nvme_qpair.c nvme.c nvme_quirks.c nvme_transport.c
|
||||
C_SRCS-$(CONFIG_RDMA) += nvme_rdma.c
|
||||
LIBNAME = nvme
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -31,6 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "spdk/nvmf_spec.h"
|
||||
#include "nvme_internal.h"
|
||||
|
||||
struct nvme_driver _g_nvme_driver = {
|
||||
@ -45,14 +46,11 @@ struct nvme_driver *g_spdk_nvme_driver = &_g_nvme_driver;
|
||||
|
||||
int32_t spdk_nvme_retry_count;
|
||||
|
||||
static struct spdk_nvme_ctrlr *
|
||||
nvme_attach(void *devhandle)
|
||||
struct spdk_nvme_ctrlr *
|
||||
nvme_attach(enum spdk_nvme_transport_type transport, void *devhandle)
|
||||
{
|
||||
enum spdk_nvme_transport transport;
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
|
||||
transport = SPDK_NVME_TRANSPORT_PCIE;
|
||||
|
||||
ctrlr = nvme_transport_ctrlr_construct(transport, devhandle);
|
||||
|
||||
return ctrlr;
|
||||
@ -230,22 +228,12 @@ nvme_mutex_init_shared(pthread_mutex_t *mtx)
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct nvme_enum_ctx {
|
||||
spdk_nvme_probe_cb probe_cb;
|
||||
void *cb_ctx;
|
||||
};
|
||||
|
||||
/* This function must only be called while holding g_spdk_nvme_driver->lock */
|
||||
static int
|
||||
nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
nvme_enum_cb(enum spdk_nvme_transport_type type, struct nvme_enum_usr_ctx *enum_ctx,
|
||||
struct spdk_nvme_probe_info *probe_info, void *devhandle)
|
||||
{
|
||||
struct nvme_enum_ctx *enum_ctx = ctx;
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
struct spdk_nvme_ctrlr_opts opts;
|
||||
struct spdk_nvme_probe_info probe_info;
|
||||
|
||||
probe_info.pci_addr = spdk_pci_device_get_addr(pci_dev);
|
||||
probe_info.pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
/* Verify that this controller is not already attached */
|
||||
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||
@ -253,22 +241,26 @@ nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
* different per each process, we compare by BDF to determine whether it is the
|
||||
* same controller.
|
||||
*/
|
||||
if (spdk_pci_addr_compare(&probe_info.pci_addr, &ctrlr->probe_info.pci_addr) == 0) {
|
||||
return 0;
|
||||
if (type == SPDK_NVME_TRANSPORT_PCIE) {
|
||||
if (spdk_pci_addr_compare(&probe_info->pci_addr, &ctrlr->probe_info.pci_addr) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Todo: need to differentiate the NVMe over fabrics to avoid duplicated connection */
|
||||
}
|
||||
|
||||
spdk_nvme_ctrlr_opts_set_defaults(&opts);
|
||||
|
||||
if (enum_ctx->probe_cb(enum_ctx->cb_ctx, &probe_info, &opts)) {
|
||||
ctrlr = nvme_attach(pci_dev);
|
||||
if (enum_ctx->probe_cb(enum_ctx->cb_ctx, probe_info, &opts)) {
|
||||
ctrlr = nvme_attach(type, devhandle);
|
||||
if (ctrlr == NULL) {
|
||||
SPDK_ERRLOG("nvme_attach() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctrlr->opts = opts;
|
||||
ctrlr->probe_info = probe_info;
|
||||
ctrlr->probe_info = *probe_info;
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||
}
|
||||
@ -276,13 +268,15 @@ nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
static int
|
||||
_spdk_nvme_probe(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
||||
spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
int rc, start_rc;
|
||||
struct nvme_enum_ctx enum_ctx;
|
||||
struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
|
||||
enum spdk_nvme_transport_type type;
|
||||
|
||||
if (!spdk_process_is_primary()) {
|
||||
while (g_spdk_nvme_driver->initialized == false) {
|
||||
@ -302,10 +296,17 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
||||
}
|
||||
}
|
||||
|
||||
enum_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
enum_ctx.usr_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.usr_ctx.cb_ctx = cb_ctx;
|
||||
enum_ctx.enum_cb = nvme_enum_cb;
|
||||
if (!info) {
|
||||
type = SPDK_NVME_TRANSPORT_PCIE;
|
||||
} else {
|
||||
type = info->type;
|
||||
}
|
||||
|
||||
rc = nvme_transport_ctrlr_scan(type, &enum_ctx, (void *)info);
|
||||
|
||||
rc = spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, nvme_enum_cb, &enum_ctx);
|
||||
/*
|
||||
* Keep going even if one or more nvme_attach() calls failed,
|
||||
* but maintain the value of rc to signal errors when we return.
|
||||
@ -368,4 +369,23 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
||||
return rc;
|
||||
}
|
||||
|
||||
int spdk_nvme_discover(const struct spdk_nvme_discover_info *info, void *cb_ctx,
|
||||
spdk_nvme_probe_cb probe_cb,
|
||||
spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
if (!info || !info->traddr || !info->trsvcid || !info->nqn) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _spdk_nvme_probe(info, cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb attach_cb,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
return _spdk_nvme_probe(NULL, cb_ctx, probe_cb, attach_cb, remove_cb);
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_TRACE_FLAG("nvme", SPDK_TRACE_NVME)
|
||||
|
@ -80,6 +80,7 @@ spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts)
|
||||
opts->use_cmb_sqs = false;
|
||||
opts->arb_mechanism = SPDK_NVME_CC_AMS_RR;
|
||||
opts->keep_alive_timeout_ms = 10 * 1000;
|
||||
opts->queue_size = DEFAULT_MAX_QUEUE_SIZE;
|
||||
}
|
||||
|
||||
struct spdk_nvme_qpair *
|
||||
@ -784,7 +785,8 @@ nvme_ctrlr_configure_aer(struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
if (spdk_nvme_cpl_is_error(&status.cpl)) {
|
||||
SPDK_ERRLOG("nvme_ctrlr_cmd_set_async_event_config failed!\n");
|
||||
return -ENXIO;
|
||||
/* change the return value since NVMf target does not suppport aer, should be fixed later*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* aerl is a zero-based value, so we need to add 1 here. */
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "spdk/mmio.h"
|
||||
#include "spdk/pci_ids.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
#include "spdk/nvmf_spec.h"
|
||||
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
@ -91,6 +92,7 @@
|
||||
* try to configure, if available.
|
||||
*/
|
||||
#define DEFAULT_MAX_IO_QUEUES (1024)
|
||||
#define DEFAULT_MAX_QUEUE_SIZE (256)
|
||||
|
||||
enum nvme_payload_type {
|
||||
NVME_PAYLOAD_TYPE_INVALID = 0,
|
||||
@ -218,10 +220,6 @@ struct nvme_request {
|
||||
void *user_buffer;
|
||||
};
|
||||
|
||||
enum spdk_nvme_transport {
|
||||
SPDK_NVME_TRANSPORT_PCIE,
|
||||
};
|
||||
|
||||
struct nvme_completion_poll_status {
|
||||
struct spdk_nvme_cpl cpl;
|
||||
bool done;
|
||||
@ -236,7 +234,7 @@ struct nvme_async_event_request {
|
||||
struct spdk_nvme_qpair {
|
||||
STAILQ_HEAD(, nvme_request) queued_req;
|
||||
|
||||
enum spdk_nvme_transport transport;
|
||||
enum spdk_nvme_transport_type transport;
|
||||
|
||||
uint16_t id;
|
||||
|
||||
@ -325,7 +323,7 @@ struct spdk_nvme_ctrlr {
|
||||
/** Array of namespaces indexed by nsid - 1 */
|
||||
struct spdk_nvme_ns *ns;
|
||||
|
||||
enum spdk_nvme_transport transport;
|
||||
enum spdk_nvme_transport_type transport;
|
||||
|
||||
uint32_t num_ns;
|
||||
|
||||
@ -524,11 +522,27 @@ int nvme_mutex_init_recursive_shared(pthread_mutex_t *mtx);
|
||||
bool nvme_completion_is_retry(const struct spdk_nvme_cpl *cpl);
|
||||
void nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd);
|
||||
void nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cpl *cpl);
|
||||
struct spdk_nvme_ctrlr *nvme_attach(enum spdk_nvme_transport_type transport, void *devhandle);
|
||||
|
||||
struct nvme_enum_usr_ctx {
|
||||
spdk_nvme_probe_cb probe_cb;
|
||||
void *cb_ctx;
|
||||
};
|
||||
|
||||
typedef int (*nvme_ctrlr_enum_cb)(enum spdk_nvme_transport_type type,
|
||||
struct nvme_enum_usr_ctx *enum_usr_ctx,
|
||||
struct spdk_nvme_probe_info *probe_info, void *devhandle);
|
||||
|
||||
struct nvme_enum_ctx {
|
||||
struct nvme_enum_usr_ctx usr_ctx;
|
||||
nvme_ctrlr_enum_cb enum_cb;
|
||||
};
|
||||
|
||||
/* Transport specific functions */
|
||||
#define DECLARE_TRANSPORT(name) \
|
||||
struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport transport, void *devhandle); \
|
||||
struct spdk_nvme_ctrlr *nvme_ ## name ## _ctrlr_construct(enum spdk_nvme_transport_type transport, void *devhandle); \
|
||||
int nvme_ ## name ## _ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr); \
|
||||
int nvme_ ## name ## _ctrlr_scan(enum spdk_nvme_transport_type transport, struct nvme_enum_ctx *enum_ctx, void *devhandle); \
|
||||
int nvme_ ## name ## _ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr); \
|
||||
int nvme_ ## name ## _ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id); \
|
||||
int nvme_ ## name ## _ctrlr_set_reg_4(struct spdk_nvme_ctrlr *ctrlr, uint32_t offset, uint32_t value); \
|
||||
@ -550,6 +564,9 @@ void nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme
|
||||
|
||||
DECLARE_TRANSPORT(transport) /* generic transport dispatch functions */
|
||||
DECLARE_TRANSPORT(pcie)
|
||||
#ifdef SPDK_CONFIG_RDMA
|
||||
DECLARE_TRANSPORT(rdma)
|
||||
#endif
|
||||
|
||||
#undef DECLARE_TRANSPORT
|
||||
|
||||
|
@ -426,7 +426,28 @@ nvme_pcie_ctrlr_construct_admin_qpair(struct spdk_nvme_ctrlr *ctrlr)
|
||||
SPDK_NVME_QPRIO_URGENT);
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
/* This function must only be called while holding g_spdk_nvme_driver->lock */
|
||||
static int
|
||||
pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
{
|
||||
struct spdk_nvme_probe_info probe_info = {};
|
||||
struct nvme_enum_ctx *enum_ctx = ctx;
|
||||
|
||||
probe_info.pci_addr = spdk_pci_device_get_addr(pci_dev);
|
||||
probe_info.pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
return enum_ctx->enum_cb(SPDK_NVME_TRANSPORT_PCIE, &enum_ctx->usr_ctx, &probe_info,
|
||||
(void *)pci_dev);
|
||||
}
|
||||
|
||||
int
|
||||
nvme_pcie_ctrlr_scan(enum spdk_nvme_transport_type transport,
|
||||
struct nvme_enum_ctx *enum_ctx, void *devhandle)
|
||||
{
|
||||
return spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, enum_ctx);
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport_type transport,
|
||||
void *devhandle)
|
||||
{
|
||||
struct spdk_pci_device *pci_dev = devhandle;
|
||||
|
1462
lib/nvme/nvme_rdma.c
Normal file
1462
lib/nvme/nvme_rdma.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
static __attribute__((noreturn)) void
|
||||
nvme_transport_unknown(enum spdk_nvme_transport transport)
|
||||
nvme_transport_unknown(enum spdk_nvme_transport_type transport)
|
||||
{
|
||||
SPDK_ERRLOG("Unknown transport %d\n", (int)transport);
|
||||
abort();
|
||||
@ -50,23 +50,35 @@ nvme_transport_unknown(enum spdk_nvme_transport transport)
|
||||
#endif
|
||||
|
||||
#define TRANSPORT_PCIE(func_name, args) case SPDK_NVME_TRANSPORT_PCIE: return nvme_pcie_ ## func_name args;
|
||||
|
||||
#ifdef SPDK_CONFIG_RDMA
|
||||
#define TRANSPORT_FABRICS_RDMA(func_name, args) case SPDK_NVME_TRANSPORT_RDMA: return nvme_rdma_ ## func_name args;
|
||||
#else
|
||||
#define TRANSPORT_FABRICS_RDMA(func_name, args)
|
||||
#endif
|
||||
#define NVME_TRANSPORT_CALL(transport, func_name, args) \
|
||||
do { \
|
||||
switch (transport) { \
|
||||
TRANSPORT_PCIE(func_name, args) \
|
||||
TRANSPORT_FABRICS_RDMA(func_name, args) \
|
||||
TRANSPORT_DEFAULT(transport) \
|
||||
} \
|
||||
SPDK_UNREACHABLE(); \
|
||||
} while (0)
|
||||
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport_type transport,
|
||||
void *devhandle)
|
||||
{
|
||||
NVME_TRANSPORT_CALL(transport, ctrlr_construct, (transport, devhandle));
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type transport,
|
||||
struct nvme_enum_ctx *enum_ctx, void *devhandle)
|
||||
{
|
||||
NVME_TRANSPORT_CALL(transport, ctrlr_scan, (transport, enum_ctx, devhandle));
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
|
@ -395,8 +395,10 @@ nvmf_prop_set_cc(struct spdk_nvmf_session *session, uint64_t value)
|
||||
session->vcprop.cc.bits.en = 1;
|
||||
session->vcprop.csts.bits.rdy = 1;
|
||||
} else {
|
||||
SPDK_ERRLOG("CC.EN transition from 1 to 0 (reset) not implemented!\n");
|
||||
/* TODO: reset */
|
||||
/* TODO: reset is not really supported here */
|
||||
session->vcprop.cc.bits.en = 0;
|
||||
session->vcprop.csts.bits.rdy = 0;
|
||||
|
||||
}
|
||||
diff.bits.en = 0;
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_bdev.a \
|
||||
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
|
||||
$(COPY_MODULES_LINKER_ARGS)
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS) -lcunit
|
||||
|
||||
all : $(APP)
|
||||
|
@ -55,6 +55,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_bdev.a \
|
||||
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
|
||||
$(COPY_MODULES_LINKER_ARGS)
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
ifeq ($(OS),Linux)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -44,6 +44,10 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/build/lib/libspdk_nvme.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_util.a \
|
||||
$(SPDK_ROOT_DIR)/build/lib/libspdk_log.a \
|
||||
|
||||
ifeq ($(CONFIG_RDMA), y)
|
||||
LIBS += -libverbs -lrdmacm
|
||||
endif
|
||||
|
||||
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
|
||||
|
||||
all : $(APP)
|
||||
|
@ -57,12 +57,19 @@ spdk_pci_device_get_id(struct spdk_pci_device *pci_dev)
|
||||
return pci_id;
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport_type transport,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type transport,
|
||||
struct nvme_enum_ctx *enum_ctx, void *devhandle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nvme_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ struct spdk_nvme_registers g_ut_nvme_regs = {};
|
||||
|
||||
__thread int nvme_thread_ioq_index = -1;
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport_type transport,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -56,7 +56,7 @@ static int nvme_request_next_sge(void *cb_arg, void **address, uint32_t *length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport transport,
|
||||
struct spdk_nvme_ctrlr *nvme_transport_ctrlr_construct(enum spdk_nvme_transport_type transport,
|
||||
void *devhandle)
|
||||
{
|
||||
return NULL;
|
||||
@ -154,6 +154,13 @@ nvme_ctrlr_get_ref_count(struct spdk_nvme_ctrlr *ctrlr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_transport_ctrlr_scan(enum spdk_nvme_transport_type transport,
|
||||
struct nvme_enum_ctx *enum_ctx, void *devhandle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_for_test(struct spdk_nvme_ns *ns, struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct spdk_nvme_qpair *qpair,
|
||||
|
52
test/nvmf/host/identify.sh
Executable file
52
test/nvmf/host/identify.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
testdir=$(readlink -f $(dirname $0))
|
||||
rootdir=$(readlink -f $testdir/../../..)
|
||||
source $rootdir/scripts/autotest_common.sh
|
||||
source $rootdir/test/nvmf/common.sh
|
||||
|
||||
MALLOC_BDEV_SIZE=64
|
||||
MALLOC_BLOCK_SIZE=512
|
||||
|
||||
rpc_py="python $rootdir/scripts/rpc.py"
|
||||
|
||||
set -e
|
||||
|
||||
if ! rdma_nic_available; then
|
||||
echo "no NIC for nvmf test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
timing_enter host
|
||||
|
||||
# Start up the NVMf target in another process
|
||||
$rootdir/app/nvmf_tgt/nvmf_tgt -c $testdir/../nvmf.conf -m 0x2 -p 1 -s 512 -t nvmf &
|
||||
nvmfpid=$!
|
||||
|
||||
trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
||||
|
||||
waitforlisten $nvmfpid ${RPC_PORT}
|
||||
|
||||
bdevs="$bdevs $($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
|
||||
|
||||
modprobe -v nvme-rdma
|
||||
|
||||
if [ -e "/dev/nvme-fabrics" ]; then
|
||||
chmod a+rw /dev/nvme-fabrics
|
||||
fi
|
||||
|
||||
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n "$bdevs"
|
||||
|
||||
$rootdir/examples/nvme/identify/identify -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" -n nqn.2014-08.org.nvmexpress.discovery -t all
|
||||
sync
|
||||
$rpc_py delete_nvmf_subsystem nqn.2016-06.io.spdk:cnode1
|
||||
|
||||
rm -f ./local-job0-0-verify.state
|
||||
rm -f ./local-job1-1-verify.state
|
||||
rm -f ./local-job2-2-verify.state
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
|
||||
nvmfcleanup
|
||||
killprocess $nvmfpid
|
||||
timing_exit host
|
Loading…
x
Reference in New Issue
Block a user