Commit 849d3939 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

accel: expose spdk_accel_get_opcode_name()



The docs already mentioned this function, but it wasn't actually defined
anywhere (only an internal version doing the same was available). Other
than making it public, this patch also slightly changes its signature to
make it a bit less cumbersome to use.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifa6c0ad8c5a7002c89be48f1835cc6b0f36ee906
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20437


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 64b16eda
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -625,7 +625,7 @@ void spdk_accel_put_buf(struct spdk_io_channel *ch, void *buf,
 * Return the name of the module assigned to a specific opcode.
 *
 * \param opcode Accel Framework Opcode enum value. Valid codes can be retrieved using
 * `accel_get_opc_assignments` or `spdk_accel_get_opc_name`.
 * `accel_get_opc_assignments` or `spdk_accel_get_opcode_name`.
 * \param module_name Pointer to update with module name.
 *
 * \return 0 if a valid module name was provided. -EINVAL for invalid opcode
@@ -637,7 +637,7 @@ int spdk_accel_get_opc_module_name(enum spdk_accel_opcode opcode, const char **m
 * Override the assignment of an opcode to an module.
 *
 * \param opcode Accel Framework Opcode enum value. Valid codes can be retrieved using
 * `accel_get_opc_assignments` or `spdk_accel_get_opc_name`.
 * `accel_get_opc_assignments` or `spdk_accel_get_opcode_name`.
 * \param name Name of the module to assign. Valid module names may be retrieved
 * with `spdk_accel_get_opc_module_name`
 *
@@ -746,6 +746,15 @@ struct spdk_accel_operation_exec_ctx {
uint8_t spdk_accel_get_buf_align(enum spdk_accel_opcode opcode,
				 const struct spdk_accel_operation_exec_ctx *ctx);

/**
 * Return the name of an operation based on the opcode.
 *
 * \param opcode Opcode.
 *
 * \return Name of the operation.
 */
const char *spdk_accel_get_opcode_name(enum spdk_accel_opcode opcode);

#ifdef __cplusplus
}
#endif
+4 −9
Original line number Diff line number Diff line
@@ -228,19 +228,14 @@ _accel_for_each_module(struct module_info *info, _accel_for_each_module_fn fn)
	}
}

int
_accel_get_opc_name(enum spdk_accel_opcode opcode, const char **opcode_name)
const char *
spdk_accel_get_opcode_name(enum spdk_accel_opcode opcode)
{
	int rc = 0;

	if (opcode < SPDK_ACCEL_OPC_LAST) {
		*opcode_name = g_opcode_strings[opcode];
	} else {
		/* invalid opcode */
		rc = -EINVAL;
		return g_opcode_strings[opcode];
	}

	return rc;
	return NULL;
}

int
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ struct accel_stats {

typedef void (*_accel_for_each_module_fn)(struct module_info *info);
void _accel_for_each_module(struct module_info *info, _accel_for_each_module_fn fn);
int _accel_get_opc_name(enum spdk_accel_opcode opcode, const char **opcode_name);
void _accel_crypto_key_dump_param(struct spdk_json_write_ctx *w, struct spdk_accel_crypto_key *key);
void _accel_crypto_keys_dump_param(struct spdk_json_write_ctx *w);
typedef void (*accel_get_stats_cb)(struct accel_stats *stats, void *cb_arg);
+8 −10
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@ rpc_accel_get_opc_assignments(struct spdk_jsonrpc_request *request,

	spdk_json_write_object_begin(w);
	for (opcode = 0; opcode < SPDK_ACCEL_OPC_LAST; opcode++) {
		rc = _accel_get_opc_name(opcode, &name);
		if (rc == 0) {
		name = spdk_accel_get_opcode_name(opcode);
		if (name != NULL) {
			rc = spdk_accel_get_opc_module_name(opcode, &module_name);
			if (rc == 0) {
				spdk_json_write_named_string(w, name, module_name);
@@ -62,7 +62,6 @@ rpc_dump_module_info(struct module_info *info)
	struct spdk_json_write_ctx *w = info->w;
	const char *name;
	uint32_t i;
	int rc;

	spdk_json_write_object_begin(w);

@@ -70,8 +69,8 @@ rpc_dump_module_info(struct module_info *info)
	spdk_json_write_named_array_begin(w, "supported ops");

	for (i = 0; i < info->num_ops; i++) {
		rc = _accel_get_opc_name(info->ops[i], &name);
		if (rc == 0) {
		name = spdk_accel_get_opcode_name(info->ops[i]);
		if (name != NULL) {
			spdk_json_write_string(w, name);
		} else {
			/* this should never happen */
@@ -144,8 +143,8 @@ rpc_accel_assign_opc(struct spdk_jsonrpc_request *request,
	}

	for (opcode = 0; opcode < SPDK_ACCEL_OPC_LAST; opcode++) {
		rc = _accel_get_opc_name(opcode, &opcode_str);
		assert(!rc);
		opcode_str = spdk_accel_get_opcode_name(opcode);
		assert(opcode_str != NULL);
		if (strcmp(opcode_str, req.opname) == 0) {
			found = true;
			break;
@@ -417,7 +416,7 @@ rpc_accel_get_stats_done(struct accel_stats *stats, void *cb_arg)
{
	struct spdk_jsonrpc_request *request = cb_arg;
	struct spdk_json_write_ctx *w;
	const char *name, *module_name;
	const char *module_name;
	int i, rc;

	w = spdk_jsonrpc_begin_result(request);
@@ -430,13 +429,12 @@ rpc_accel_get_stats_done(struct accel_stats *stats, void *cb_arg)
		if (stats->operations[i].executed + stats->operations[i].failed == 0) {
			continue;
		}
		_accel_get_opc_name(i, &name);
		rc = spdk_accel_get_opc_module_name(i, &module_name);
		if (rc) {
			continue;
		}
		spdk_json_write_object_begin(w);
		spdk_json_write_named_string(w, "opcode", name);
		spdk_json_write_named_string(w, "opcode", spdk_accel_get_opcode_name(i));
		spdk_json_write_named_string(w, "module_name", module_name);
		spdk_json_write_named_uint64(w, "executed", stats->operations[i].executed);
		spdk_json_write_named_uint64(w, "failed", stats->operations[i].failed);
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
	spdk_accel_get_opts;
	spdk_accel_get_opcode_stats;
	spdk_accel_get_buf_align;
	spdk_accel_get_opcode_name;

	# functions needed by modules
	spdk_accel_module_list_add;