diff --git a/include/spdk/event.h b/include/spdk/event.h index d65c29172..74c946728 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -44,6 +44,7 @@ #include "spdk/stdinc.h" #include "spdk/cpuset.h" +#include "spdk/init.h" #include "spdk/queue.h" #include "spdk/log.h" #include "spdk/thread.h" @@ -82,8 +83,6 @@ typedef void (*spdk_app_shutdown_cb)(void); */ typedef void (*spdk_sighandler_t)(int signal); -#define SPDK_DEFAULT_RPC_ADDR "/var/tmp/spdk.sock" - /** * \brief Event framework initialization options */ diff --git a/include/spdk/init.h b/include/spdk/init.h index 46e199966..339c8900c 100644 --- a/include/spdk/init.h +++ b/include/spdk/init.h @@ -45,6 +45,23 @@ extern "C" { #endif +#define SPDK_DEFAULT_RPC_ADDR "/var/tmp/spdk.sock" + +/** + * Create the SPDK JSON-RPC server and listen at the provided address. The RPC server is optional and is + * independent of subsystem initialization. The RPC server can be started and stopped at any time. + * + * \param listen_addr Path to a unix domain socket to listen on + * + * \return Negated errno on failure. 0 on success. + */ +int spdk_rpc_initialize(const char *listen_addr); + +/** + * Shut down the SPDK JSON-RPC target + */ +void spdk_rpc_finish(void); + typedef void (*spdk_subsystem_init_fn)(int rc, void *ctx); /** diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index 2e65798b0..0a923b03a 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -170,9 +170,6 @@ void spdk_app_json_config_load(const char *json_config_file, const char *rpc_add spdk_app_init_fn cb_fn, void *cb_arg, bool stop_on_error); -int spdk_rpc_initialize(const char *listen_addr); -void spdk_rpc_finish(void); - struct spdk_governor_capabilities { bool freq_change; bool freq_getset; diff --git a/lib/event/Makefile b/lib/event/Makefile index 5cd155870..6077e3d6e 100644 --- a/lib/event/Makefile +++ b/lib/event/Makefile @@ -40,7 +40,7 @@ SO_MINOR := 0 CFLAGS += $(ENV_CFLAGS) LIBNAME = event -C_SRCS = app.c reactor.c rpc.c json_config.c log_rpc.c \ +C_SRCS = app.c reactor.c json_config.c log_rpc.c \ app_rpc.c scheduler_static.c # Do not compile schedulers and governors based on DPDK env diff --git a/lib/event/spdk_event.map b/lib/event/spdk_event.map index 146dc29c4..206670d5c 100644 --- a/lib/event/spdk_event.map +++ b/lib/event/spdk_event.map @@ -26,8 +26,6 @@ spdk_for_each_reactor; spdk_reactor_set_interrupt_mode; spdk_app_json_config_load; - spdk_rpc_initialize; - spdk_rpc_finish; local: *; }; diff --git a/lib/init/Makefile b/lib/init/Makefile index 8cd598c06..8f00ca240 100644 --- a/lib/init/Makefile +++ b/lib/init/Makefile @@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk SO_VER := 1 SO_MINOR := 0 -C_SRCS = subsystem.c subsystem_rpc.c +C_SRCS = subsystem.c subsystem_rpc.c rpc.c LIBNAME = init SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_init.map) diff --git a/lib/event/rpc.c b/lib/init/rpc.c similarity index 98% rename from lib/event/rpc.c rename to lib/init/rpc.c index 62c8d5bb2..2adaf8bde 100644 --- a/lib/event/rpc.c +++ b/lib/init/rpc.c @@ -34,12 +34,11 @@ #include "spdk/stdinc.h" #include "spdk/env.h" +#include "spdk/init.h" #include "spdk/thread.h" #include "spdk/log.h" #include "spdk/rpc.h" -#include "spdk_internal/event.h" - #define RPC_SELECT_INTERVAL 4000 /* 4ms */ static struct spdk_poller *g_rpc_poller = NULL; diff --git a/lib/init/spdk_init.map b/lib/init/spdk_init.map index 72088d6dd..5a6d694f7 100644 --- a/lib/init/spdk_init.map +++ b/lib/init/spdk_init.map @@ -9,5 +9,8 @@ spdk_subsystem_init_next; spdk_subsystem_fini_next; + spdk_rpc_initialize; + spdk_rpc_finish; + local: *; };