Commit bd4ecea5 authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Jim Harris
Browse files

subsystem: add per module configuration dump



Change-Id: I5c4e51cd9cd97b05ab9a95cbe084ff2741f6ef58
Signed-off-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/402323


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 15ce3262
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "spdk/stdinc.h"

#include "spdk/event.h"
#include "spdk/json.h"

struct spdk_event {
	uint32_t		lcore;
@@ -57,12 +58,15 @@ struct spdk_subsystem {
	void (*init)(void);
	void (*fini)(void);
	void (*config)(FILE *fp);
	int (*write_config_json)(struct spdk_json_write_ctx *w);
	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(struct spdk_subsystem_list *list, const char *name);

struct spdk_subsystem_depend {
	const char *name;
	const char *depends_on;
@@ -81,6 +85,15 @@ void spdk_subsystem_init_next(int rc);
void spdk_subsystem_fini_next(void);
void spdk_subsystem_config(FILE *fp);

/**
 * Save pointed subsystem configuration to the JSON write context. In case of
 * error \c null is written to the JSON context.
 *
 * \param w JSON write context
 * \param subsystem the subsystem to query
 */
void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem);

void spdk_rpc_initialize(const char *listen_addr);
void spdk_rpc_finish(void);

+43 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@

#include "spdk_internal/event.h"
#include "spdk/rpc.h"
#include "spdk/string.h"
#include "spdk/util.h"

static void
spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
@@ -73,3 +75,44 @@ spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
}

SPDK_RPC_REGISTER("get_subsystems", spdk_rpc_get_subsystems)

struct rpc_get_subsystem_config {
	char *name;
};

static const struct spdk_json_object_decoder rpc_get_subsystem_config[] = {
	{"name", offsetof(struct rpc_get_subsystem_config, name), spdk_json_decode_string},
};

static void
spdk_rpc_get_subsystem_config(struct spdk_jsonrpc_request *request,
			      const struct spdk_json_val *params)
{
	struct rpc_get_subsystem_config req = {};
	struct spdk_json_write_ctx *w;
	struct spdk_subsystem *subsystem;

	if (spdk_json_decode_object(params, rpc_get_subsystem_config,
				    SPDK_COUNTOF(rpc_get_subsystem_config), &req)) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid arguments");
		return;
	}

	subsystem = spdk_subsystem_find(&g_subsystems, req.name);
	if (!subsystem) {
		spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						     "Subsystem '%s' not found", req.name);
		goto out;
	}

	w = spdk_jsonrpc_begin_result(request);
	if (w) {
		spdk_subsystem_config_json(w, subsystem);
		spdk_jsonrpc_end_result(request, w);
	}

out:
	free(req.name);
}

SPDK_RPC_REGISTER("get_subsystem_config", spdk_rpc_get_subsystem_config)
+11 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend)
	TAILQ_INSERT_TAIL(&g_subsystems_deps, depend, tailq);
}

static struct spdk_subsystem *
struct spdk_subsystem *
spdk_subsystem_find(struct spdk_subsystem_list *list, const char *name)
{
	struct spdk_subsystem *iter;
@@ -242,3 +242,13 @@ spdk_subsystem_config(FILE *fp)
		}
	}
}

void
spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem)
{
	if (subsystem && subsystem->write_config_json) {
		subsystem->write_config_json(w);
	} else {
		spdk_json_write_null(w);
	}
}
+4 −0
Original line number Diff line number Diff line
@@ -437,6 +437,10 @@ if __name__ == "__main__":
    entry contain (unsorted) array of subsystems it depends on.""")
    p.set_defaults(func=rpc.subsystem.get_subsystems)

    p = subparsers.add_parser('get_subsystem_config', help=""""Print subsystem configuration""")
    p.add_argument('name', help='Name of subsystem to query')
    p.set_defaults(func=rpc.subsystem.get_subsystem_config)

    # vhost
    p = subparsers.add_parser('set_vhost_controller_coalescing', help='Set vhost controller coalescing')
    p.add_argument('ctrlr', help='controller name')
+5 −0
Original line number Diff line number Diff line
@@ -3,3 +3,8 @@ from client import print_dict, print_array, int_arg

def get_subsystems(args):
    print_dict(args.client.call('get_subsystems'))


def get_subsystem_config(args):
    params = {'name': args.name}
    print_dict(args.client.call('get_subsystem_config', params))
Loading