Skip to content

Commit

Permalink
accel/error: add support for write_config_json
Browse files Browse the repository at this point in the history
Signed-off-by: Konrad Sztyber <[email protected]>
Change-Id: I838fffd89a6302eb09850b697b10a04feac088db
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20439
Reviewed-by: Jim Harris <[email protected]>
Reviewed-by: Aleksey Marchuk <[email protected]>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <[email protected]>
  • Loading branch information
ksztyber authored and tomzawadzki committed Nov 14, 2023
1 parent 8625cc1 commit 38a1f6b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions module/accel/error/accel_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "accel_error.h"
#include "spdk/accel.h"
#include "spdk/accel_module.h"
#include "spdk/json.h"
#include "spdk/thread.h"

struct accel_error_inject_info {
Expand Down Expand Up @@ -188,6 +189,28 @@ accel_error_get_type_name(enum accel_error_inject_type type)
return typenames[type];
}

static void
accel_error_write_config_json(struct spdk_json_write_ctx *w)
{
struct accel_error_inject_opts *opts;
int opcode;

for (opcode = 0; opcode < SPDK_ACCEL_OPC_LAST; ++opcode) {
opts = &g_injects[opcode];
if (opts->type == ACCEL_ERROR_INJECT_DISABLE) {
continue;
}
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "accel_error_inject_error");
spdk_json_write_named_object_begin(w, "params");
spdk_json_write_named_string(w, "opcode", spdk_accel_get_opcode_name(opcode));
spdk_json_write_named_string(w, "type", accel_error_get_type_name(opts->type));
spdk_json_write_named_uint64(w, "count", opts->count);
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
}
}

static struct spdk_accel_module_if g_accel_error_module = {
.name = "error",
.priority = INT_MIN,
Expand All @@ -197,5 +220,6 @@ static struct spdk_accel_module_if g_accel_error_module = {
.get_ctx_size = accel_error_get_ctx_size,
.get_io_channel = accel_error_get_io_channel,
.submit_tasks = accel_error_submit_tasks,
.write_config_json = accel_error_write_config_json,
};
SPDK_ACCEL_MODULE_REGISTER(error, &g_accel_error_module)

0 comments on commit 38a1f6b

Please sign in to comment.