accel: add write_config json for accel modules
Add both the plumbing in the engine to call module entry points if they exist as well as the json write config for idxd (the only module with config info at this time). Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: I91376d3fc60227cd79fae17b164722619eafb9e5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2052 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3044bd27d0
commit
fad052b0cb
@ -74,19 +74,29 @@ struct spdk_accel_module_if {
|
|||||||
*/
|
*/
|
||||||
void (*config_text)(FILE *fp);
|
void (*config_text)(FILE *fp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Acceleration module configuration into provided JSON context.
|
||||||
|
*/
|
||||||
|
void (*write_config_json)(struct spdk_json_write_ctx *w);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the allocation size required for the modules to use for context.
|
||||||
|
*/
|
||||||
size_t (*get_ctx_size)(void);
|
size_t (*get_ctx_size)(void);
|
||||||
|
|
||||||
TAILQ_ENTRY(spdk_accel_module_if) tailq;
|
TAILQ_ENTRY(spdk_accel_module_if) tailq;
|
||||||
};
|
};
|
||||||
|
|
||||||
void spdk_accel_hw_engine_register(struct spdk_accel_engine *accel_engine);
|
void spdk_accel_hw_engine_register(struct spdk_accel_engine *accel_engine);
|
||||||
void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module);
|
void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module);
|
||||||
|
|
||||||
#define SPDK_ACCEL_MODULE_REGISTER(init_fn, fini_fn, config_fn, ctx_size_fn) \
|
#define SPDK_ACCEL_MODULE_REGISTER(init_fn, fini_fn, config_fn, config_json, ctx_size_fn) \
|
||||||
static struct spdk_accel_module_if init_fn ## _if = { \
|
static struct spdk_accel_module_if init_fn ## _if = { \
|
||||||
.module_init = init_fn, \
|
.module_init = init_fn, \
|
||||||
.module_fini = fini_fn, \
|
.module_fini = fini_fn, \
|
||||||
.config_text = config_fn, \
|
.config_text = config_fn, \
|
||||||
.get_ctx_size = ctx_size_fn, \
|
.write_config_json = config_json, \
|
||||||
|
.get_ctx_size = ctx_size_fn, \
|
||||||
}; \
|
}; \
|
||||||
__attribute__((constructor)) static void init_fn ## _init(void) \
|
__attribute__((constructor)) static void init_fn ## _init(void) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -223,11 +223,17 @@ spdk_accel_engine_module_finish_cb(void)
|
|||||||
void
|
void
|
||||||
spdk_accel_write_config_json(struct spdk_json_write_ctx *w)
|
spdk_accel_write_config_json(struct spdk_json_write_ctx *w)
|
||||||
{
|
{
|
||||||
/* TODO: call engine config_json entry points. */
|
struct spdk_accel_module_if *accel_engine_module;
|
||||||
spdk_json_write_array_begin(w);
|
|
||||||
spdk_json_write_object_begin(w);
|
/*
|
||||||
spdk_json_write_object_end(w);
|
* The accel engine has no config, there may be some in
|
||||||
spdk_json_write_array_end(w);
|
* the modules though.
|
||||||
|
*/
|
||||||
|
TAILQ_FOREACH(accel_engine_module, &spdk_accel_module_list, tailq) {
|
||||||
|
if (accel_engine_module->write_config_json) {
|
||||||
|
accel_engine_module->write_config_json(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -364,4 +370,4 @@ sw_accel_engine_fini(void *ctxt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPDK_ACCEL_MODULE_REGISTER(sw_accel_engine_init, sw_accel_engine_fini,
|
SPDK_ACCEL_MODULE_REGISTER(sw_accel_engine_init, sw_accel_engine_fini,
|
||||||
NULL, sw_accel_engine_get_ctx_size)
|
NULL, NULL, sw_accel_engine_get_ctx_size)
|
||||||
|
@ -57,7 +57,7 @@ DEPDIRS-reduce := log util
|
|||||||
DEPDIRS-thread := log util
|
DEPDIRS-thread := log util
|
||||||
|
|
||||||
DEPDIRS-blob := log util thread
|
DEPDIRS-blob := log util thread
|
||||||
DEPDIRS-accel := log json thread
|
DEPDIRS-accel := log thread
|
||||||
DEPDIRS-jsonrpc := log util json
|
DEPDIRS-jsonrpc := log util json
|
||||||
DEPDIRS-virtio := log util json thread
|
DEPDIRS-virtio := log util json thread
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "spdk/thread.h"
|
#include "spdk/thread.h"
|
||||||
#include "spdk/idxd.h"
|
#include "spdk/idxd.h"
|
||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
|
#include "spdk/json.h"
|
||||||
|
|
||||||
/* Undefine this to require an RPC to enable IDXD. */
|
/* Undefine this to require an RPC to enable IDXD. */
|
||||||
#undef DEVELOPER_DEBUG_MODE
|
#undef DEVELOPER_DEBUG_MODE
|
||||||
@ -55,6 +56,8 @@ static bool g_idxd_enable = true;
|
|||||||
static bool g_idxd_enable = false;
|
static bool g_idxd_enable = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t g_config_number;
|
||||||
|
|
||||||
enum channel_state {
|
enum channel_state {
|
||||||
IDXD_CHANNEL_ACTIVE,
|
IDXD_CHANNEL_ACTIVE,
|
||||||
IDXD_CHANNEL_PAUSED,
|
IDXD_CHANNEL_PAUSED,
|
||||||
@ -470,8 +473,9 @@ accel_engine_idxd_enable_probe(uint32_t config_number)
|
|||||||
config_number = 0;
|
config_number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_config_number = config_number;
|
||||||
g_idxd_enable = true;
|
g_idxd_enable = true;
|
||||||
spdk_idxd_set_config(config_number);
|
spdk_idxd_set_config(g_config_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -521,8 +525,25 @@ accel_engine_idxd_exit(void *ctx)
|
|||||||
spdk_accel_engine_module_finish();
|
spdk_accel_engine_module_finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
accel_engine_idxd_write_config_json(struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
spdk_json_write_array_begin(w);
|
||||||
|
|
||||||
|
if (g_idxd_enable) {
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
|
spdk_json_write_named_string(w, "method", "idxd_scan_accel_engine");
|
||||||
|
spdk_json_write_named_object_begin(w, "params");
|
||||||
|
spdk_json_write_named_uint32(w, "config_number", g_config_number);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_json_write_array_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
SPDK_ACCEL_MODULE_REGISTER(accel_engine_idxd_init, accel_engine_idxd_exit,
|
SPDK_ACCEL_MODULE_REGISTER(accel_engine_idxd_init, accel_engine_idxd_exit,
|
||||||
NULL,
|
NULL, accel_engine_idxd_write_config_json,
|
||||||
accel_engine_idxd_get_ctx_size)
|
accel_engine_idxd_get_ctx_size)
|
||||||
|
|
||||||
SPDK_LOG_REGISTER_COMPONENT("accel_idxd", SPDK_LOG_ACCEL_IDXD)
|
SPDK_LOG_REGISTER_COMPONENT("accel_idxd", SPDK_LOG_ACCEL_IDXD)
|
||||||
|
@ -134,7 +134,7 @@ accel_engine_ioat_get_ctx_size(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPDK_ACCEL_MODULE_REGISTER(accel_engine_ioat_init, accel_engine_ioat_exit,
|
SPDK_ACCEL_MODULE_REGISTER(accel_engine_ioat_init, accel_engine_ioat_exit,
|
||||||
accel_engine_ioat_config_text,
|
accel_engine_ioat_config_text, NULL,
|
||||||
accel_engine_ioat_get_ctx_size)
|
accel_engine_ioat_get_ctx_size)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -65,7 +65,7 @@ static struct spdk_subsystem g_spdk_subsystem_accel = {
|
|||||||
.init = spdk_accel_engine_subsystem_initialize,
|
.init = spdk_accel_engine_subsystem_initialize,
|
||||||
.fini = spdk_accel_engine_subsystem_finish,
|
.fini = spdk_accel_engine_subsystem_finish,
|
||||||
.config = spdk_accel_engine_config_text,
|
.config = spdk_accel_engine_config_text,
|
||||||
.write_config_json = NULL,
|
.write_config_json = spdk_accel_write_config_json,
|
||||||
};
|
};
|
||||||
|
|
||||||
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_accel);
|
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_accel);
|
||||||
|
@ -23,6 +23,7 @@ def sort_json_object(o):
|
|||||||
|
|
||||||
def filter_methods(do_remove_global_rpcs):
|
def filter_methods(do_remove_global_rpcs):
|
||||||
global_rpcs = [
|
global_rpcs = [
|
||||||
|
'idxd_scan_accel_engine',
|
||||||
'iscsi_set_options',
|
'iscsi_set_options',
|
||||||
'nvmf_set_config',
|
'nvmf_set_config',
|
||||||
'nvmf_set_max_subsystems',
|
'nvmf_set_max_subsystems',
|
||||||
|
Loading…
Reference in New Issue
Block a user