From 9e1b82ac9cf1a39ae0ae61bced259f57ec085185 Mon Sep 17 00:00:00 2001 From: paul luse Date: Sat, 8 Feb 2020 18:23:09 +0000 Subject: [PATCH] subsystem/accel: add entry point for .write_config_json Write config json for setting the selected accel module. Signed-off-by: paul luse Change-Id: Ife11d4d4a776254b56fa6d24dc817481beb78c3c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/664 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- include/spdk/accel_engine.h | 9 +++++++++ lib/accel/accel_engine.c | 14 ++++++++++++++ module/event/subsystems/accel/accel.c | 7 +++++++ test/json_config/alias_rpc/conf.json | 2 +- test/json_config/config_filter.py | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/spdk/accel_engine.h b/include/spdk/accel_engine.h index a5bd37e30..0afa78061 100644 --- a/include/spdk/accel_engine.h +++ b/include/spdk/accel_engine.h @@ -140,6 +140,15 @@ int spdk_accel_submit_fill(struct spdk_accel_task *accel_req, struct spdk_io_cha */ size_t spdk_accel_task_size(void); +struct spdk_json_write_ctx; + +/** + * Write Acceleration subsystem configuration into provided JSON context. + * + * \param w JSON write context + */ +void spdk_accel_write_config_json(struct spdk_json_write_ctx *w); + #ifdef __cplusplus } #endif diff --git a/lib/accel/accel_engine.c b/lib/accel/accel_engine.c index d30aedfdd..cd1057c72 100644 --- a/lib/accel/accel_engine.c +++ b/lib/accel/accel_engine.c @@ -39,6 +39,7 @@ #include "spdk/event.h" #include "spdk/log.h" #include "spdk/thread.h" +#include "spdk/json.h" /* Accelerator Engine Framework: The following provides a top level * generic API for the accelerator functions defined here. Modules, @@ -230,6 +231,19 @@ spdk_accel_engine_module_finish_cb(void) g_fini_cb_arg = NULL; } +void +spdk_accel_write_config_json(struct spdk_json_write_ctx *w) +{ + spdk_json_write_array_begin(w); + spdk_json_write_object_begin(w); + spdk_json_write_named_string(w, "method", "accel_set_module"); + spdk_json_write_named_object_begin(w, "params"); + spdk_json_write_named_uint32(w, "module", g_active_accel_module); + spdk_json_write_object_end(w); + spdk_json_write_object_end(w); + spdk_json_write_array_end(w); +} + void spdk_accel_engine_module_finish(void) { diff --git a/module/event/subsystems/accel/accel.c b/module/event/subsystems/accel/accel.c index 27163ee8b..a1819c001 100644 --- a/module/event/subsystems/accel/accel.c +++ b/module/event/subsystems/accel/accel.c @@ -60,11 +60,18 @@ spdk_accel_engine_subsystem_finish(void) spdk_accel_engine_finish(spdk_accel_engine_subsystem_finish_done, NULL); } +static void +spdk_accel_engine_subsystem_write_config_json(struct spdk_json_write_ctx *w) +{ + spdk_accel_write_config_json(w); +} + static struct spdk_subsystem g_spdk_subsystem_accel = { .name = "accel", .init = spdk_accel_engine_subsystem_initialize, .fini = spdk_accel_engine_subsystem_finish, .config = spdk_accel_engine_config_text, + .write_config_json = spdk_accel_engine_subsystem_write_config_json, }; SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_accel); diff --git a/test/json_config/alias_rpc/conf.json b/test/json_config/alias_rpc/conf.json index 54a4b0230..ba3e6b254 100644 --- a/test/json_config/alias_rpc/conf.json +++ b/test/json_config/alias_rpc/conf.json @@ -2,7 +2,7 @@ "subsystems": [ { "subsystem": "accel", - "config": null + "config": [] }, { "subsystem": "interface", diff --git a/test/json_config/config_filter.py b/test/json_config/config_filter.py index 4f81ab077..cd28dcbb5 100755 --- a/test/json_config/config_filter.py +++ b/test/json_config/config_filter.py @@ -23,6 +23,7 @@ def sort_json_object(o): def filter_methods(do_remove_global_rpcs): global_rpcs = [ + 'accel_set_module', 'iscsi_set_options', 'nvmf_set_config', 'nvmf_set_max_subsystems',