copy_engine: Support dump config text for IOAT config

IOAT module of copy engine requires config information in the .INI
config file. However dump config text is not supported yet.

Dump config text is legacy feature but this becomes a preparation
for the upcoming JSON config file.

Change-Id: I9b7349cac9c00ca3ce1d944a84cbc445a6f1aec4
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/405845
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-04-02 18:33:10 +09:00 committed by Jim Harris
parent 3f522bfeb0
commit 0fed4e0704
4 changed files with 51 additions and 2 deletions

View File

@ -66,6 +66,13 @@ int spdk_copy_engine_initialize(void);
*/ */
void spdk_copy_engine_finish(spdk_copy_fini_cb cb_fn, void *cb_arg); void spdk_copy_engine_finish(spdk_copy_fini_cb cb_fn, void *cb_arg);
/**
* Get the configuration for the copy engine.
*
* \param fp The pointer to a file that will be written to the configuration.
*/
void spdk_copy_engine_config_text(FILE *fp);
/** /**
* Close the copy engine module and perform any necessary cleanup. * Close the copy engine module and perform any necessary cleanup.
*/ */

View File

@ -285,4 +285,16 @@ spdk_copy_engine_finish(spdk_copy_fini_cb cb_fn, void *cb_arg)
spdk_copy_engine_module_finish(); spdk_copy_engine_module_finish();
} }
void
spdk_copy_engine_config_text(FILE *fp)
{
struct spdk_copy_module_if *copy_engine_module;
TAILQ_FOREACH(copy_engine_module, &spdk_copy_module_list, tailq) {
if (copy_engine_module->config_text) {
copy_engine_module->config_text(fp);
}
}
}
SPDK_COPY_MODULE_REGISTER(copy_engine_mem_init, NULL, NULL, copy_engine_mem_get_ctx_size) SPDK_COPY_MODULE_REGISTER(copy_engine_mem_init, NULL, NULL, copy_engine_mem_get_ctx_size)

View File

@ -116,6 +116,7 @@ struct ioat_task {
static int copy_engine_ioat_init(void); static int copy_engine_ioat_init(void);
static void copy_engine_ioat_exit(void *ctx); static void copy_engine_ioat_exit(void *ctx);
static void copy_engine_ioat_config_text(FILE *fp);
static size_t static size_t
copy_engine_ioat_get_ctx_size(void) copy_engine_ioat_get_ctx_size(void)
@ -123,7 +124,8 @@ copy_engine_ioat_get_ctx_size(void)
return sizeof(struct ioat_task) + sizeof(struct spdk_copy_task); return sizeof(struct ioat_task) + sizeof(struct spdk_copy_task);
} }
SPDK_COPY_MODULE_REGISTER(copy_engine_ioat_init, copy_engine_ioat_exit, NULL, SPDK_COPY_MODULE_REGISTER(copy_engine_ioat_init, copy_engine_ioat_exit,
copy_engine_ioat_config_text,
copy_engine_ioat_get_ctx_size) copy_engine_ioat_get_ctx_size)
static void static void
@ -319,3 +321,31 @@ copy_engine_ioat_init(void)
sizeof(struct ioat_io_channel)); sizeof(struct ioat_io_channel));
return 0; return 0;
} }
#define COPY_ENGINE_IOAT_HEADER_TMPL \
"[Ioat]\n" \
" # Users may not want to use offload even it is available.\n" \
" # Users may use the whitelist to initialize specified devices, IDS\n" \
" # uses BUS:DEVICE.FUNCTION to identify each Ioat channel.\n"
#define COPY_ENGINE_IOAT_DISABLE_TMPL \
" Disable %s\n"
#define COPY_ENGINE_IOAT_WHITELIST_TMPL \
" Whitelist %.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 "\n"
static void
copy_engine_ioat_config_text(FILE *fp)
{
int i;
struct spdk_pci_addr *dev;
fprintf(fp, COPY_ENGINE_IOAT_HEADER_TMPL);
fprintf(fp, COPY_ENGINE_IOAT_DISABLE_TMPL, g_ioat_disable ? "Yes" : "No");
for (i = 0; i < g_probe_ctx.num_whitelist_devices; i++) {
dev = &g_probe_ctx.whitelist[i];
fprintf(fp, COPY_ENGINE_IOAT_WHITELIST_TMPL,
dev->domain, dev->bus, dev->dev, dev->func);
}
}

View File

@ -64,7 +64,7 @@ static struct spdk_subsystem g_spdk_subsystem_copy = {
.name = "copy", .name = "copy",
.init = spdk_copy_engine_subsystem_initialize, .init = spdk_copy_engine_subsystem_initialize,
.fini = spdk_copy_engine_subsystem_finish, .fini = spdk_copy_engine_subsystem_finish,
.config = NULL, .config = spdk_copy_engine_config_text,
}; };
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_copy); SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_copy);