From 0c00baf9bc8ba7c06ea7402cd1f1f57ad89a6926 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 15 Aug 2016 16:25:11 -0700 Subject: [PATCH] nvmf: move conf file parsing to nvmf_tgt app Change-Id: Iaf09d39046bceae023739d49e31804e150bb19d4 Signed-off-by: Daniel Verkamp --- app/nvmf_tgt/Makefile | 2 +- {lib/nvmf => app/nvmf_tgt}/conf.c | 5 ++--- {lib/nvmf => app/nvmf_tgt}/conf.h | 0 app/nvmf_tgt/nvmf_tgt.c | 14 ++++++++++++++ lib/nvmf/Makefile | 2 +- lib/nvmf/nvmf.c | 19 ------------------- lib/nvmf/transport.c | 9 +++++---- lib/nvmf/transport.h | 3 +-- 8 files changed, 24 insertions(+), 30 deletions(-) rename {lib/nvmf => app/nvmf_tgt}/conf.c (99%) rename {lib/nvmf => app/nvmf_tgt}/conf.h (100%) diff --git a/app/nvmf_tgt/Makefile b/app/nvmf_tgt/Makefile index d24bd5eeb..a47d7f2fb 100644 --- a/app/nvmf_tgt/Makefile +++ b/app/nvmf_tgt/Makefile @@ -43,7 +43,7 @@ CFLAGS += $(DPDK_INC) # TODO: remove this once NVMf has a public API header CFLAGS += -I$(SPDK_ROOT_DIR)/lib -C_SRCS := nvmf_tgt.c +C_SRCS := conf.c nvmf_tgt.c SPDK_LIBS = \ $(SPDK_ROOT_DIR)/lib/nvmf/libspdk_nvmf.a \ diff --git a/lib/nvmf/conf.c b/app/nvmf_tgt/conf.c similarity index 99% rename from lib/nvmf/conf.c rename to app/nvmf_tgt/conf.c index 2cabcdfaf..c96c79cd4 100644 --- a/lib/nvmf/conf.c +++ b/app/nvmf_tgt/conf.c @@ -40,9 +40,8 @@ #include #include "conf.h" -#include "nvmf_internal.h" -#include "subsystem.h" -#include "transport.h" +#include "nvmf/subsystem.h" +#include "nvmf/transport.h" #include "spdk/conf.h" #include "spdk/log.h" diff --git a/lib/nvmf/conf.h b/app/nvmf_tgt/conf.h similarity index 100% rename from lib/nvmf/conf.h rename to app/nvmf_tgt/conf.h diff --git a/app/nvmf_tgt/nvmf_tgt.c b/app/nvmf_tgt/nvmf_tgt.c index 503ce28ad..ff3f276fb 100644 --- a/app/nvmf_tgt/nvmf_tgt.c +++ b/app/nvmf_tgt/nvmf_tgt.c @@ -42,6 +42,8 @@ #include #include +#include "conf.h" + #include "spdk/event.h" #include "nvmf/transport.h" @@ -95,6 +97,18 @@ spdk_nvmf_startup(spdk_event_t event) { int rc; + rc = spdk_nvmf_parse_conf(); + if (rc < 0) { + SPDK_ERRLOG("spdk_nvmf_parse_conf() failed\n"); + goto initialize_error; + } + + rc = spdk_nvmf_transport_init(); + if (rc <= 0) { + SPDK_ERRLOG("Transport initialization failed\n"); + goto initialize_error; + } + /* start the rdma poller that will listen on all available ports */ rc = spdk_nvmf_acceptor_start(); diff --git a/lib/nvmf/Makefile b/lib/nvmf/Makefile index 4eb8a4bcd..08ae82cbe 100644 --- a/lib/nvmf/Makefile +++ b/lib/nvmf/Makefile @@ -36,7 +36,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk CFLAGS += $(DPDK_INC) LIBNAME = nvmf -C_SRCS = subsystem.c conf.c nvmf.c \ +C_SRCS = subsystem.c nvmf.c \ request.c session.c transport.c \ direct.c diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index b40c4c690..91a03b935 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -39,7 +39,6 @@ #include "spdk/log.h" #include "spdk/conf.h" -#include "conf.h" #include "subsystem.h" #include "transport.h" #include "spdk/trace.h" @@ -151,24 +150,6 @@ nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_queues_per_sess, static int nvmf_tgt_subsystem_initialize(void) { - int rc; - - /* initialize from configuration file */ - rc = spdk_nvmf_parse_conf(); - if (rc < 0) { - SPDK_ERRLOG("spdk_nvmf_parse_conf() failed\n"); - return rc; - } - - /* initialize with the NVMf transport */ - rc = spdk_nvmf_transport_init(g_nvmf_tgt.max_queue_depth, - g_nvmf_tgt.max_io_size, - g_nvmf_tgt.in_capsule_data_size); - if (rc <= 0) { - SPDK_ERRLOG("Transport initialization failed\n"); - return -1; - } - return 0; } diff --git a/lib/nvmf/transport.c b/lib/nvmf/transport.c index 4e1667f8d..e33b552f4 100644 --- a/lib/nvmf/transport.c +++ b/lib/nvmf/transport.c @@ -39,6 +39,8 @@ #include "spdk/log.h" #include "spdk/queue.h" +#include "nvmf_internal.h" + static const struct spdk_nvmf_transport *const g_transports[] = { #ifdef SPDK_CONFIG_RDMA &spdk_nvmf_transport_rdma, @@ -48,15 +50,14 @@ static const struct spdk_nvmf_transport *const g_transports[] = { #define NUM_TRANSPORTS (sizeof(g_transports) / sizeof(*g_transports)) int -spdk_nvmf_transport_init(uint16_t max_queue_depth, uint32_t max_io_size, - uint32_t in_capsule_data_size) +spdk_nvmf_transport_init(void) { size_t i; int count = 0; for (i = 0; i != NUM_TRANSPORTS; i++) { - if (g_transports[i]->transport_init(max_queue_depth, max_io_size, - in_capsule_data_size) < 0) { + if (g_transports[i]->transport_init(g_nvmf_tgt.max_queue_depth, g_nvmf_tgt.max_io_size, + g_nvmf_tgt.in_capsule_data_size) < 0) { SPDK_NOTICELOG("%s transport init failed\n", g_transports[i]->name); } else { count++; diff --git a/lib/nvmf/transport.h b/lib/nvmf/transport.h index 711858152..2bc7a108d 100644 --- a/lib/nvmf/transport.h +++ b/lib/nvmf/transport.h @@ -111,8 +111,7 @@ struct spdk_nvmf_transport { struct spdk_nvmf_discovery_log_page_entry *entry); }; -int spdk_nvmf_transport_init(uint16_t max_queue_depth, uint32_t max_io_size, - uint32_t in_capsule_data_size); +int spdk_nvmf_transport_init(void); int spdk_nvmf_transport_fini(void); const struct spdk_nvmf_transport *spdk_nvmf_transport_get(const char *name);