Commit 44cbea40 authored by paul luse's avatar paul luse Committed by Tomasz Zawadzki
Browse files

lib/accel: Add new RPC to get valid engine info.



The RPC provides a list of initialized engine names along with
that engine's supported operations.

Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I59f9e5cb7aa51a6193f0bd2ec31e543a56c12f17
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13745


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent c6ecddcc
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -1496,6 +1496,57 @@ Example response:

## Acceleration Framework Layer {#jsonrpc_components_accel_fw}

### accel_get_engine_info {#accel_get_engine_info}

Get a list of valid engine names and their supported operations.

#### Parameters

None

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "method": "accel_get_engine_info",
  "id": 1
}
~~~

Example response:

~~~json
[
  {
    "engine": "software",
    "supported ops": [
      "copy",
      "fill",
      "dualcast",
      "compare",
      "crc32c",
      "copy_crc32c",
      "compress",
      "decompress"
    ]
  },
  {
    "engine": "dsa",
    "supported ops": [
      "copy",
      "fill",
      "dualcast",
      "compare",
      "crc32c",
      "copy_crc32c"
    ]
  }
]
~~~

### accel_get_opc_assignments {#rpc_accel_get_opc_assignments}

Get a list of opcode names and their assigned accel_fw modules.
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,16 @@
#include "../isa-l/include/igzip_lib.h"
#endif

struct engine_info {
	struct spdk_json_write_ctx *w;
	const char *name;
	enum accel_opcode ops[ACCEL_OPC_LAST];
	uint32_t num_ops;
};

typedef void (*_accel_for_each_engine_fn)(struct engine_info *info);
void _accel_for_each_engine(struct engine_info *info, _accel_for_each_engine_fn fn);

struct spdk_accel_task;

void spdk_accel_task_complete(struct spdk_accel_task *task, int status);
+21 −0
Original line number Diff line number Diff line
@@ -66,6 +66,27 @@ spdk_accel_get_opc_engine_name(enum accel_opcode opcode, const char **engine_nam
	return 0;
}

void
_accel_for_each_engine(struct engine_info *info, _accel_for_each_engine_fn fn)
{
	struct spdk_accel_engine *accel_engine;
	enum accel_opcode opcode;
	int j = 0;

	TAILQ_FOREACH(accel_engine, &g_engine_list, tailq) {
		for (opcode = 0; opcode < ACCEL_OPC_LAST; opcode++) {
			if (accel_engine->supports_opcode(opcode)) {
				info->ops[j] = opcode;
				j++;
			}
		}
		info->name = accel_engine->name;
		info->num_ops = j;
		fn(info);
		j = 0;
	}
}

static struct spdk_accel_engine *
_engine_find_by_name(const char *name)
{
+51 −0
Original line number Diff line number Diff line
@@ -71,3 +71,54 @@ rpc_accel_get_opc_assignments(struct spdk_jsonrpc_request *request,
}
SPDK_RPC_REGISTER("accel_get_opc_assignments", rpc_accel_get_opc_assignments,
		  SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)

static void
rpc_dump_engine_info(struct engine_info *info)
{
	struct spdk_json_write_ctx *w = info->w;
	const char *name;
	uint32_t i;
	int rc;

	spdk_json_write_object_begin(w);

	spdk_json_write_named_string(w, "engine", info->name);
	spdk_json_write_named_array_begin(w, "suppoerted ops");

	for (i = 0; i < info->num_ops; i++) {
		rc = _get_opc_name(i, &name);
		if (rc == 0) {
			spdk_json_write_string(w, name);
		} else {
			/* this should never happen */
			SPDK_ERRLOG("Invalid opcode (%d)).\n", i);
			assert(0);
		}
	}

	spdk_json_write_array_end(w);
	spdk_json_write_object_end(w);
}

static void
rpc_accel_get_engine_info(struct spdk_jsonrpc_request *request,
			  const struct spdk_json_val *params)
{
	struct engine_info info;

	if (params != NULL) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "accel_get_engine_info requires no parameters");
		return;
	}

	info.w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_array_begin(info.w);

	_accel_for_each_engine(&info, rpc_dump_engine_info);

	spdk_json_write_array_end(info.w);
	spdk_jsonrpc_end_result(request, info.w);
}
SPDK_RPC_REGISTER("accel_get_engine_info", rpc_accel_get_engine_info,
		  SPDK_RPC_RUNTIME)
+6 −0
Original line number Diff line number Diff line
@@ -2,3 +2,9 @@ def accel_get_opc_assignments(client):
    """Get list of opcode name to engine assignments.
    """
    return client.call('accel_get_opc_assignments')


def accel_get_engine_info(client):
    """Get list of valid engine names and their operations.
    """
    return client.call('accel_get_engine_info')
Loading