Loading app/nvmf_tgt/conf.c +59 −3 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include "nvmf/transport.h" #include "spdk/conf.h" #include "spdk/log.h" #include "spdk/bdev.h" #define MAX_LISTEN_ADDRESSES 255 #define MAX_HOSTS 255 Loading Loading @@ -314,6 +315,20 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctr } } static int spdk_nvmf_validate_sn(const char *sn) { size_t len; len = strlen(sn); if (len > MAX_SN_LEN) { SPDK_ERRLOG("Invalid sn \"%s\": length %zu > max %d\n", sn, len, MAX_SN_LEN); return -1; } return 0; } static int spdk_nvmf_allocate_lcore(uint64_t mask, uint32_t lcore) { Loading Loading @@ -377,9 +392,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (strcasecmp(mode, "Direct") == 0) { subsystem->mode = NVMF_SUBSYSTEM_MODE_DIRECT; } else if (strcasecmp(mode, "Virtual") == 0) { nvmf_delete_subsystem(subsystem); SPDK_ERRLOG("Virtual Subsystems are not yet supported.\n"); return -1; subsystem->mode = NVMF_SUBSYSTEM_MODE_VIRTUAL; } else { nvmf_delete_subsystem(subsystem); SPDK_ERRLOG("Invalid Subsystem mode: %s\n", mode); Loading Loading @@ -457,6 +470,49 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (spdk_nvme_probe(&ctx, probe_cb, attach_cb, NULL)) { SPDK_ERRLOG("One or more controllers failed in spdk_nvme_probe()\n"); } } else { struct spdk_bdev *bdev; const char *namespace, *sn, *val; sn = spdk_conf_section_get_val(sp, "SN"); if (sn == NULL) { SPDK_ERRLOG("Subsystem %d: missing serial number\n", sp->num); nvmf_delete_subsystem(subsystem); return -1; } if (spdk_nvmf_validate_sn(sn) != 0) { nvmf_delete_subsystem(subsystem); return -1; } namespace = spdk_conf_section_get_val(sp, "Namespace"); if (namespace == NULL) { SPDK_ERRLOG("Subsystem %d: missing Namespace directive\n", sp->num); nvmf_delete_subsystem(subsystem); return -1; } subsystem->ctrlr.dev.virtual.ns_count = 0; snprintf(subsystem->ctrlr.dev.virtual.sn, MAX_SN_LEN, "%s", sn); subsystem->ctrlr.ops = &spdk_nvmf_virtual_ctrlr_ops; for (i = 0; i < MAX_VIRTUAL_NAMESPACE; i++) { val = spdk_conf_section_get_nval(sp, "Namespace", i); if (val == NULL) { break; } namespace = spdk_conf_section_get_nmval(sp, "Namespace", i, 0); if (!namespace) { SPDK_ERRLOG("Namespace %d: missing block device\n", i); nvmf_delete_subsystem(subsystem); return -1; } bdev = spdk_bdev_get_by_name(namespace); if (spdk_nvmf_subsystem_add_ns(subsystem, bdev)) { nvmf_delete_subsystem(subsystem); return -1; } } } return 0; } Loading etc/spdk/nvmf.conf.in +17 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,16 @@ # syslog facility LogFacility "local7" # Users may change this section to create a different number or size of # malloc LUNs. # This will generate 8 LUNs with a malloc-allocated backend. # Each LUN will be size 64MB and these will be named # Malloc0 through Malloc7. Not all LUNs defined here are necessarily # used below. [Malloc] NumberOfLuns 8 LunSizeInMB 64 # Define NVMf protocol global options [Nvmf] # Set the maximum number of submission and completion queues per session. Loading Loading @@ -63,6 +73,8 @@ # - Exactly 1 NVMe directive specifying an NVMe device by PCI BDF. The # PCI domain:bus:device.function can be replaced by "*" to indicate # any PCI device. # Direct controller [Subsystem1] NQN nqn.2016-06.io.spdk:cnode1 Core 0 Loading @@ -72,11 +84,13 @@ NVMe 0000:00:00.0 # Multiple subsystems are allowed. # Virtual controller [Subsystem2] NQN nqn.2016-06.io.spdk:cnode2 Core 0 Mode Direct Mode Virtual Listen RDMA 192.168.2.21:4420 Host nqn.2016-06.io.spdk:init NVMe 0000:01:00.0 SN SPDK00000000000001 Namespace Malloc0 Namespace Malloc1 lib/nvmf/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -36,9 +36,10 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk CFLAGS += $(DPDK_INC) LIBNAME = nvmf C_SRCS = subsystem.c nvmf.c \ request.c session.c transport.c \ direct.c direct.c virtual.c C_SRCS-$(CONFIG_RDMA) += rdma.c Loading lib/nvmf/direct.c +9 −0 Original line number Diff line number Diff line Loading @@ -247,9 +247,18 @@ nvmf_direct_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) return SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS; } static void nvmf_direct_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem) { if (subsystem->ctrlr.dev.direct.ctrlr) { spdk_nvme_detach(subsystem->ctrlr.dev.direct.ctrlr); } } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops = { .ctrlr_get_data = nvmf_direct_ctrlr_get_data, .process_admin_cmd = nvmf_direct_ctrlr_process_admin_cmd, .process_io_cmd = nvmf_direct_ctrlr_process_io_cmd, .poll_for_completions = nvmf_direct_ctrlr_poll_for_completions, .detach = nvmf_direct_ctrlr_detach, }; lib/nvmf/session.c +1 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,7 @@ spdk_nvmf_session_connect(struct spdk_nvmf_conn *conn, } TAILQ_INIT(&session->connections); session->kato = cmd->kato; session->num_connections = 0; session->subsys = subsystem; session->max_connections_allowed = g_nvmf_tgt.max_queues_per_session; Loading Loading
app/nvmf_tgt/conf.c +59 −3 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include "nvmf/transport.h" #include "spdk/conf.h" #include "spdk/log.h" #include "spdk/bdev.h" #define MAX_LISTEN_ADDRESSES 255 #define MAX_HOSTS 255 Loading Loading @@ -314,6 +315,20 @@ attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctr } } static int spdk_nvmf_validate_sn(const char *sn) { size_t len; len = strlen(sn); if (len > MAX_SN_LEN) { SPDK_ERRLOG("Invalid sn \"%s\": length %zu > max %d\n", sn, len, MAX_SN_LEN); return -1; } return 0; } static int spdk_nvmf_allocate_lcore(uint64_t mask, uint32_t lcore) { Loading Loading @@ -377,9 +392,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (strcasecmp(mode, "Direct") == 0) { subsystem->mode = NVMF_SUBSYSTEM_MODE_DIRECT; } else if (strcasecmp(mode, "Virtual") == 0) { nvmf_delete_subsystem(subsystem); SPDK_ERRLOG("Virtual Subsystems are not yet supported.\n"); return -1; subsystem->mode = NVMF_SUBSYSTEM_MODE_VIRTUAL; } else { nvmf_delete_subsystem(subsystem); SPDK_ERRLOG("Invalid Subsystem mode: %s\n", mode); Loading Loading @@ -457,6 +470,49 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (spdk_nvme_probe(&ctx, probe_cb, attach_cb, NULL)) { SPDK_ERRLOG("One or more controllers failed in spdk_nvme_probe()\n"); } } else { struct spdk_bdev *bdev; const char *namespace, *sn, *val; sn = spdk_conf_section_get_val(sp, "SN"); if (sn == NULL) { SPDK_ERRLOG("Subsystem %d: missing serial number\n", sp->num); nvmf_delete_subsystem(subsystem); return -1; } if (spdk_nvmf_validate_sn(sn) != 0) { nvmf_delete_subsystem(subsystem); return -1; } namespace = spdk_conf_section_get_val(sp, "Namespace"); if (namespace == NULL) { SPDK_ERRLOG("Subsystem %d: missing Namespace directive\n", sp->num); nvmf_delete_subsystem(subsystem); return -1; } subsystem->ctrlr.dev.virtual.ns_count = 0; snprintf(subsystem->ctrlr.dev.virtual.sn, MAX_SN_LEN, "%s", sn); subsystem->ctrlr.ops = &spdk_nvmf_virtual_ctrlr_ops; for (i = 0; i < MAX_VIRTUAL_NAMESPACE; i++) { val = spdk_conf_section_get_nval(sp, "Namespace", i); if (val == NULL) { break; } namespace = spdk_conf_section_get_nmval(sp, "Namespace", i, 0); if (!namespace) { SPDK_ERRLOG("Namespace %d: missing block device\n", i); nvmf_delete_subsystem(subsystem); return -1; } bdev = spdk_bdev_get_by_name(namespace); if (spdk_nvmf_subsystem_add_ns(subsystem, bdev)) { nvmf_delete_subsystem(subsystem); return -1; } } } return 0; } Loading
etc/spdk/nvmf.conf.in +17 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,16 @@ # syslog facility LogFacility "local7" # Users may change this section to create a different number or size of # malloc LUNs. # This will generate 8 LUNs with a malloc-allocated backend. # Each LUN will be size 64MB and these will be named # Malloc0 through Malloc7. Not all LUNs defined here are necessarily # used below. [Malloc] NumberOfLuns 8 LunSizeInMB 64 # Define NVMf protocol global options [Nvmf] # Set the maximum number of submission and completion queues per session. Loading Loading @@ -63,6 +73,8 @@ # - Exactly 1 NVMe directive specifying an NVMe device by PCI BDF. The # PCI domain:bus:device.function can be replaced by "*" to indicate # any PCI device. # Direct controller [Subsystem1] NQN nqn.2016-06.io.spdk:cnode1 Core 0 Loading @@ -72,11 +84,13 @@ NVMe 0000:00:00.0 # Multiple subsystems are allowed. # Virtual controller [Subsystem2] NQN nqn.2016-06.io.spdk:cnode2 Core 0 Mode Direct Mode Virtual Listen RDMA 192.168.2.21:4420 Host nqn.2016-06.io.spdk:init NVMe 0000:01:00.0 SN SPDK00000000000001 Namespace Malloc0 Namespace Malloc1
lib/nvmf/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -36,9 +36,10 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk CFLAGS += $(DPDK_INC) LIBNAME = nvmf C_SRCS = subsystem.c nvmf.c \ request.c session.c transport.c \ direct.c direct.c virtual.c C_SRCS-$(CONFIG_RDMA) += rdma.c Loading
lib/nvmf/direct.c +9 −0 Original line number Diff line number Diff line Loading @@ -247,9 +247,18 @@ nvmf_direct_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) return SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS; } static void nvmf_direct_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem) { if (subsystem->ctrlr.dev.direct.ctrlr) { spdk_nvme_detach(subsystem->ctrlr.dev.direct.ctrlr); } } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops = { .ctrlr_get_data = nvmf_direct_ctrlr_get_data, .process_admin_cmd = nvmf_direct_ctrlr_process_admin_cmd, .process_io_cmd = nvmf_direct_ctrlr_process_io_cmd, .poll_for_completions = nvmf_direct_ctrlr_poll_for_completions, .detach = nvmf_direct_ctrlr_detach, };
lib/nvmf/session.c +1 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,7 @@ spdk_nvmf_session_connect(struct spdk_nvmf_conn *conn, } TAILQ_INIT(&session->connections); session->kato = cmd->kato; session->num_connections = 0; session->subsys = subsystem; session->max_connections_allowed = g_nvmf_tgt.max_queues_per_session; Loading