From e7485922b0dc0fc3ab25d298ea507bc443d02afe Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 14 Jun 2017 16:08:01 -0700 Subject: [PATCH] net: Move module initialization into event_net This removes the event framework dependency from the net library entirely. Change-Id: I7bc1a6f146437fd3d2dab0289bbd845f0ff61ae8 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/365726 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- include/spdk/net.h | 4 ++-- lib/event/subsystems/net/net.c | 38 +++++++++++++++++++++++++++++++-- lib/net/interface.c | 10 ++++----- lib/net/net_framework_default.c | 6 ++---- lib/net/sock.c | 1 - 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/include/spdk/net.h b/include/spdk/net.h index 77651c2b6..5acf4ee7a 100644 --- a/include/spdk/net.h +++ b/include/spdk/net.h @@ -44,11 +44,11 @@ #define IDLE_INTERVAL_TIME_IN_US 5000 -void spdk_interface_init(void); +int spdk_interface_init(void); int spdk_interface_destroy(void); const char *spdk_net_framework_get_name(void); -void spdk_net_framework_start(void); +int spdk_net_framework_start(void); void spdk_net_framework_clear_socket_association(int sock); int spdk_net_framework_fini(void); int spdk_net_framework_idle_time(void); diff --git a/lib/event/subsystems/net/net.c b/lib/event/subsystems/net/net.c index 32126aa82..65a8b36d9 100644 --- a/lib/event/subsystems/net/net.c +++ b/lib/event/subsystems/net/net.c @@ -37,7 +37,41 @@ #include "spdk_internal/event.h" -SPDK_SUBSYSTEM_REGISTER(interface, spdk_interface_init, spdk_interface_destroy, NULL) +static void +spdk_interface_subsystem_init(void) +{ + int rc; -SPDK_SUBSYSTEM_REGISTER(net_framework, spdk_net_framework_start, spdk_net_framework_fini, NULL) + rc = spdk_interface_init(); + + spdk_subsystem_init_next(rc); +} + +static int +spdk_interface_subsystem_destroy(void) +{ + return spdk_interface_destroy(); +} + +SPDK_SUBSYSTEM_REGISTER(interface, spdk_interface_subsystem_init, + spdk_interface_subsystem_destroy, NULL) + +static void +spdk_net_subsystem_start(void) +{ + int rc; + + rc = spdk_net_framework_start(); + + spdk_subsystem_init_next(rc); +} + +static int +spdk_net_subsystem_fini(void) +{ + return spdk_net_framework_fini(); +} + +SPDK_SUBSYSTEM_REGISTER(net_framework, spdk_net_subsystem_start, + spdk_net_subsystem_fini, NULL) SPDK_SUBSYSTEM_DEPEND(net_framework, interface) diff --git a/lib/net/interface.c b/lib/net/interface.c index 5e2238c8e..08b9dcb1a 100644 --- a/lib/net/interface.c +++ b/lib/net/interface.c @@ -36,8 +36,6 @@ #include "spdk/log.h" #include "spdk/net.h" -#include "spdk_internal/event.h" - #ifdef __linux__ /* Interface management is Linux-specific */ #include @@ -414,14 +412,14 @@ static void spdk_interface_ip_update(void) pthread_mutex_unlock(&interface_lock); } -void +int spdk_interface_init(void) { TAILQ_INIT(&g_interface_head); spdk_prepare_ifc_list(); spdk_get_ifc_ipv4(); - spdk_subsystem_init_next(0); + return 0; } int @@ -463,10 +461,10 @@ void *spdk_interface_get_list(void) #else /* Not Linux */ -void +int spdk_interface_init(void) { - spdk_subsystem_init_next(0); + return 0; } int diff --git a/lib/net/net_framework_default.c b/lib/net/net_framework_default.c index 9072ecd52..a47bf23bb 100644 --- a/lib/net/net_framework_default.c +++ b/lib/net/net_framework_default.c @@ -33,8 +33,6 @@ #include "spdk/net.h" -#include "spdk_internal/event.h" - __attribute__((weak)) const char *spdk_net_framework_get_name(void) { @@ -42,9 +40,9 @@ const char *spdk_net_framework_get_name(void) } __attribute__((weak)) -void spdk_net_framework_start(void) +int spdk_net_framework_start(void) { - spdk_subsystem_init_next(0); + return 0; } __attribute__((weak)) diff --git a/lib/net/sock.c b/lib/net/sock.c index 029a39667..3e0a28833 100644 --- a/lib/net/sock.c +++ b/lib/net/sock.c @@ -33,7 +33,6 @@ #include "spdk/stdinc.h" -#include "spdk/event.h" #include "spdk/log.h" #include "spdk/net.h"