From d439f4408af937fc20ee50a5253ae9349680d3ac Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Wed, 20 Jul 2016 17:54:53 +0800 Subject: [PATCH] nvmf: Add subsystem modes Change-Id: I74f69eb10e4d8807a323f463775f4953fe0baee0 Signed-off-by: Cunyin Chang --- etc/spdk/nvmf.conf.in | 9 +++++++++ lib/nvmf/conf.c | 21 ++++++++++++++++++++- lib/nvmf/subsystem.h | 6 ++++++ test/nvmf/nvmf.conf | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/etc/spdk/nvmf.conf.in b/etc/spdk/nvmf.conf.in index 24824a21d..e3f74d931 100644 --- a/etc/spdk/nvmf.conf.in +++ b/etc/spdk/nvmf.conf.in @@ -49,6 +49,13 @@ # Define an NVMf Subsystem. # - NQN is required and must be unique. +# - Mode may be either "Direct" or "Virtual". Direct means that physical +# devices attached to the target will be presented to hosts as if they +# were directly attached to the host. No software emulation or command +# validation is performed. Virtual means that an NVMe controller is +# emulated in software and the namespaces it contains map to block devices +# on the target system. These block devices do not need to be NVMe devices. +# Only Direct mode is currently supported. # - Between 1 and 255 Listen directives are allowed. This defines # the addresses on which new connections may be accepted. The format # is Listen
where type currently can only be RDMA. @@ -58,6 +65,7 @@ # - Exactly 1 Controller directive. [Subsystem1] NQN nqn.2016-06.io.spdk:cnode1 + Mode Direct Listen RDMA 15.15.15.2:4420 Host nqn.2016-06.io.spdk:init Controller Nvme0 @@ -65,6 +73,7 @@ # Multiple subsystems are allowed. [Subsystem2] NQN nqn.2016-06.io.spdk:cnode2 + Mode Direct Listen RDMA 192.168.2.21:4420 Host nqn.2016-06.io.spdk:init Controller Nvme1 diff --git a/lib/nvmf/conf.c b/lib/nvmf/conf.c index 7d3deaa2e..185b3ab2b 100644 --- a/lib/nvmf/conf.c +++ b/lib/nvmf/conf.c @@ -310,7 +310,7 @@ spdk_nvmf_allocate_lcore(uint64_t mask, uint32_t lcore) static int spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) { - const char *val, *nqn; + const char *val, *nqn, *mode; struct spdk_nvmf_subsystem *subsystem; struct spdk_nvmf_ctrlr *nvmf_ctrlr; int i, ret; @@ -341,6 +341,25 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) return -1; } + mode = spdk_conf_section_get_val(sp, "Mode"); + if (mode == NULL) { + nvmf_delete_subsystem(subsystem); + SPDK_ERRLOG("No Mode specified for Subsystem %d\n", sp->num); + return -1; + } + + 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; + } else { + nvmf_delete_subsystem(subsystem); + SPDK_ERRLOG("Invalid Subsystem mode: %s\n", mode); + return -1; + } + /* Parse Listen sections */ for (i = 0; i < MAX_LISTEN_ADDRESSES; i++) { char *transport_name, *listen_addr; diff --git a/lib/nvmf/subsystem.h b/lib/nvmf/subsystem.h index e97562a4d..127a7cd74 100644 --- a/lib/nvmf/subsystem.h +++ b/lib/nvmf/subsystem.h @@ -42,6 +42,11 @@ struct spdk_nvmf_conn; #define MAX_NQN_SIZE 255 +enum spdk_nvmf_subsystem_mode { + NVMF_SUBSYSTEM_MODE_DIRECT = 0, + NVMF_SUBSYSTEM_MODE_VIRTUAL = 1, +}; + struct spdk_nvmf_listen_addr { char *traddr; char *trsvc; /* TODO: Change to trsvcid */ @@ -62,6 +67,7 @@ struct spdk_nvmf_host { struct spdk_nvmf_subsystem { uint16_t num; char subnqn[MAX_NQN_SIZE]; + enum spdk_nvmf_subsystem_mode mode; enum spdk_nvmf_subtype subtype; struct nvmf_session *session; struct spdk_nvme_ctrlr *ctrlr; diff --git a/test/nvmf/nvmf.conf b/test/nvmf/nvmf.conf index 9a0d01359..4bbf30940 100644 --- a/test/nvmf/nvmf.conf +++ b/test/nvmf/nvmf.conf @@ -11,5 +11,6 @@ [Subsystem1] NQN "nqn.2016-06.io.spdk:cnode1" + Mode Direct Listen RDMA 192.168.100.8:4420 Controller Nvme0