Commit 844e4602 authored by Seth Howell's avatar Seth Howell Committed by Tomasz Zawadzki
Browse files

lib/event: add subsystem iterator functions.



This allows us to hide the implementations of
g_subsystems and s_subsystems_deps within the
libraries themselves.

Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Change-Id: I60716b9465b58d6cdb3a43262a7ded844bd80eda
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1786


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent d02d16ff
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -129,10 +129,9 @@ struct spdk_subsystem {
	TAILQ_ENTRY(spdk_subsystem) tailq;
};

TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem);
extern struct spdk_subsystem_list g_subsystems;

struct spdk_subsystem *spdk_subsystem_find(const char *name);
struct spdk_subsystem *spdk_subsystem_get_first(void);
struct spdk_subsystem *spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem);

struct spdk_subsystem_depend {
	const char *name;
@@ -140,8 +139,9 @@ struct spdk_subsystem_depend {
	TAILQ_ENTRY(spdk_subsystem_depend) tailq;
};

TAILQ_HEAD(spdk_subsystem_depend_list, spdk_subsystem_depend);
extern struct spdk_subsystem_depend_list g_subsystems_deps;
struct spdk_subsystem_depend *spdk_subsystem_get_first_depend(void);
struct spdk_subsystem_depend *spdk_subsystem_get_next_depend(struct spdk_subsystem_depend
		*cur_depend);

void spdk_add_subsystem(struct spdk_subsystem *subsystem);
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);
+4 −4
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@
	spdk_reactor_get;
	spdk_for_each_reactor;
	spdk_subsystem_find;
	spdk_subsystem_get_first;
	spdk_subsystem_get_next;
	spdk_subsystem_get_first_depend;
	spdk_subsystem_get_next_depend;
	spdk_add_subsystem;
	spdk_add_subsystem_depend;
	spdk_subsystem_init;
@@ -38,9 +42,5 @@
	spdk_rpc_initialize;
	spdk_rpc_finish;

	# Macros and variables
	g_subsystems;
	g_subsystems_deps;

	local: *;
};
+28 −0
Original line number Diff line number Diff line
@@ -39,7 +39,10 @@
#include "spdk_internal/event.h"
#include "spdk/env.h"

TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem);
struct spdk_subsystem_list g_subsystems = TAILQ_HEAD_INITIALIZER(g_subsystems);

TAILQ_HEAD(spdk_subsystem_depend_list, spdk_subsystem_depend);
struct spdk_subsystem_depend_list g_subsystems_deps = TAILQ_HEAD_INITIALIZER(g_subsystems_deps);
static struct spdk_subsystem *g_next_subsystem;
static bool g_subsystems_initialized = false;
@@ -82,6 +85,31 @@ spdk_subsystem_find(const char *name)
	return _subsystem_find(&g_subsystems, name);
}

struct spdk_subsystem *
spdk_subsystem_get_first(void)
{
	return TAILQ_FIRST(&g_subsystems);
}

struct spdk_subsystem *
spdk_subsystem_get_next(struct spdk_subsystem *cur_subsystem)
{
	return TAILQ_NEXT(cur_subsystem, tailq);
}


struct spdk_subsystem_depend *
spdk_subsystem_get_first_depend(void)
{
	return TAILQ_FIRST(&g_subsystems_deps);
}

struct spdk_subsystem_depend *
spdk_subsystem_get_next_depend(struct spdk_subsystem_depend *cur_depend)
{
	return TAILQ_NEXT(cur_depend, tailq);
}

static void
subsystem_sort(void)
{
+6 −3
Original line number Diff line number Diff line
@@ -53,19 +53,22 @@ spdk_rpc_framework_get_subsystems(struct spdk_jsonrpc_request *request,

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_array_begin(w);
	TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
	subsystem = spdk_subsystem_get_first();
	while (subsystem != NULL) {
		spdk_json_write_object_begin(w);

		spdk_json_write_named_string(w, "subsystem", subsystem->name);
		spdk_json_write_named_array_begin(w, "depends_on");
		TAILQ_FOREACH(deps, &g_subsystems_deps, tailq) {
		deps = spdk_subsystem_get_first_depend();
		while (deps != NULL) {
			if (strcmp(subsystem->name, deps->name) == 0) {
				spdk_json_write_string(w, deps->depends_on);
			}
			deps = spdk_subsystem_get_next_depend(deps);
		}
		spdk_json_write_array_end(w);

		spdk_json_write_object_end(w);
		subsystem = spdk_subsystem_get_next(subsystem);
	}
	spdk_json_write_array_end(w);
	spdk_jsonrpc_end_result(request, w);
+0 −2
Original line number Diff line number Diff line
@@ -5,8 +5,6 @@
	rte_vhost_*;
	virt*;
	SPDK_LOG*;
	g_subsystems;
	g_subsystems_deps;
	g_spdk_iscsi_opts;
	_spdk_trace_record;
	g_trace_histories;