lib/accel: add RPC to get list of OP codes per module
In prep for upcoming patch that will provide an RPC to override and automatic assignment of an op code to an engine. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: I17d4b962fb376a77f97ce051a513679d0fba698e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12829 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
72285fa540
commit
c6ecddcc1c
@ -34,6 +34,11 @@ Renamed the `raid5` module to `raid5f` to reflect that it is not a traditional
|
||||
RAID5 implementation - only full stripe writes are supported, partial stripe
|
||||
writes (read-modify-write) are not.
|
||||
|
||||
### accel_fw
|
||||
|
||||
Added a new runtime RPC `accel_get_opc_assignments` to get a list of current opcode to engine
|
||||
assignements.
|
||||
|
||||
## v22.05
|
||||
|
||||
### sock
|
||||
|
@ -441,6 +441,7 @@ Example response:
|
||||
"framework_get_subsystems",
|
||||
"framework_monitor_context_switch",
|
||||
"spdk_kill_instance",
|
||||
"accel_get_opc_assignments",
|
||||
"ioat_scan_accel_engine",
|
||||
"dsa_scan_accel_engine",
|
||||
"bdev_virtio_attach_controller",
|
||||
@ -1495,6 +1496,46 @@ Example response:
|
||||
|
||||
## Acceleration Framework Layer {#jsonrpc_components_accel_fw}
|
||||
|
||||
### accel_get_opc_assignments {#rpc_accel_get_opc_assignments}
|
||||
|
||||
Get a list of opcode names and their assigned accel_fw modules.
|
||||
|
||||
#### Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "accel_get_opc_assignments",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": [
|
||||
{
|
||||
"copy": "software",
|
||||
"fill": "software",
|
||||
"dualcast": "software",
|
||||
"compare": "software",
|
||||
"crc32c": "software",
|
||||
"copy_crc32c": "software",
|
||||
"compress": "software",
|
||||
"decompress": "software"
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
### dsa_scan_accel_engine {#rpc_dsa_scan_accel_engine}
|
||||
|
||||
Set config and enable dsa accel engine offload.
|
||||
|
@ -263,6 +263,18 @@ int spdk_accel_submit_decompress(struct spdk_io_channel *ch, void *dst, void *sr
|
||||
uint64_t nbytes_dst, uint64_t nbytes_src, int flags,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Return the name of the engine assigned to a specfic opcode.
|
||||
*
|
||||
* \param opcode Accel Framework Opcode enum value. Valid codes can be retrieved using
|
||||
* `accel_get_opc_assignments` or `spdk_accel_get_opc_name`.
|
||||
* \param engine_name Pointer to update with engine name.
|
||||
*
|
||||
* \return 0 if a valid engine name was provided. -EINVAL for invalid opcode
|
||||
* or -ENOENT no engine was found at this time for the provided opcode.
|
||||
*/
|
||||
int spdk_accel_get_opc_engine_name(enum accel_opcode opcode, const char **engine_name);
|
||||
|
||||
struct spdk_json_write_ctx;
|
||||
|
||||
/**
|
||||
|
@ -7,11 +7,11 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 9
|
||||
SO_MINOR := 0
|
||||
SO_MINOR := 1
|
||||
SO_SUFFIX := $(SO_VER).$(SO_MINOR)
|
||||
|
||||
LIBNAME = accel
|
||||
C_SRCS = accel_engine.c
|
||||
C_SRCS = accel_engine.c accel_engine_rpc.c
|
||||
|
||||
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_accel.map)
|
||||
|
||||
|
@ -49,6 +49,23 @@ static struct spdk_accel_engine *g_engines_opc[ACCEL_OPC_LAST] = {};
|
||||
|
||||
static int sw_accel_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *first_task);
|
||||
|
||||
int
|
||||
spdk_accel_get_opc_engine_name(enum accel_opcode opcode, const char **engine_name)
|
||||
{
|
||||
if (opcode >= ACCEL_OPC_LAST) {
|
||||
/* invalid opcode */
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (g_engines_opc[opcode]) {
|
||||
*engine_name = g_engines_opc[opcode]->name;
|
||||
} else {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spdk_accel_engine *
|
||||
_engine_find_by_name(const char *name)
|
||||
{
|
||||
|
73
lib/accel/accel_engine_rpc.c
Normal file
73
lib/accel/accel_engine_rpc.c
Normal file
@ -0,0 +1,73 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
#include "spdk_internal/accel_engine.h"
|
||||
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/event.h"
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
const char *g_opcode_strings[ACCEL_OPC_LAST] = {
|
||||
"copy", "fill", "dualcast", "compare", "crc32c", "copy_crc32c",
|
||||
"compress", "decompress"
|
||||
};
|
||||
|
||||
static int
|
||||
_get_opc_name(enum accel_opcode opcode, const char **opcode_name)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (opcode < ACCEL_OPC_LAST) {
|
||||
*opcode_name = g_opcode_strings[opcode];
|
||||
} else {
|
||||
/* invalid opcode */
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
rpc_accel_get_opc_assignments(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
enum accel_opcode opcode;
|
||||
const char *name, *engine_name;
|
||||
int rc;
|
||||
|
||||
if (params != NULL) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"accel_get_opc_assignments requires no parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
for (opcode = 0; opcode < ACCEL_OPC_LAST; opcode++) {
|
||||
rc = _get_opc_name(opcode, &name);
|
||||
if (rc == 0) {
|
||||
rc = spdk_accel_get_opc_engine_name(opcode, &engine_name);
|
||||
if (rc != 0) {
|
||||
/* This isn't fatal but throw an informational message if we
|
||||
* cant get an engine name right now */
|
||||
SPDK_NOTICELOG("FYI error (%d) getting engine name.\n", rc);
|
||||
}
|
||||
spdk_json_write_named_string(w, name, engine_name);
|
||||
} else {
|
||||
/* this should never happen */
|
||||
SPDK_ERRLOG("Invalid opcode (%d)).\n", opcode);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("accel_get_opc_assignments", rpc_accel_get_opc_assignments,
|
||||
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
@ -16,6 +16,7 @@
|
||||
spdk_accel_submit_copy_crc32cv;
|
||||
spdk_accel_submit_compress;
|
||||
spdk_accel_submit_decompress;
|
||||
spdk_accel_get_opc_engine_name;
|
||||
spdk_accel_write_config_json;
|
||||
|
||||
# functions needed by modules
|
||||
|
@ -44,7 +44,7 @@ DEPDIRS-nvme += vfio_user
|
||||
endif
|
||||
|
||||
DEPDIRS-blob := log util thread dma
|
||||
DEPDIRS-accel := log util thread json
|
||||
DEPDIRS-accel := log util thread json rpc jsonrpc
|
||||
DEPDIRS-jsonrpc := log util json
|
||||
DEPDIRS-virtio := log util json thread
|
||||
|
||||
|
@ -4,6 +4,7 @@ import sys
|
||||
|
||||
from io import IOBase as io
|
||||
|
||||
from . import accel
|
||||
from . import app
|
||||
from . import bdev
|
||||
from . import blobfs
|
||||
|
4
python/spdk/rpc/accel.py
Normal file
4
python/spdk/rpc/accel.py
Normal file
@ -0,0 +1,4 @@
|
||||
def accel_get_opc_assignments(client):
|
||||
"""Get list of opcode name to engine assignments.
|
||||
"""
|
||||
return client.call('accel_get_opc_assignments')
|
@ -2562,6 +2562,13 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
help='How often the hotplug is processed for insert and remove events', type=int)
|
||||
p.set_defaults(func=bdev_virtio_blk_set_hotplug)
|
||||
|
||||
# accel_fw
|
||||
def accel_get_opc_assignments(args):
|
||||
print_dict(rpc.accel.accel_get_opc_assignments(args.client))
|
||||
|
||||
p = subparsers.add_parser('accel_get_opc_assignments', help='Get list of opcode name to engine assignments.')
|
||||
p.set_defaults(func=accel_get_opc_assignments)
|
||||
|
||||
# ioat
|
||||
def ioat_scan_accel_engine(args):
|
||||
rpc.ioat.ioat_scan_accel_engine(args.client)
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "spdk_cunit.h"
|
||||
#include "spdk_internal/mock.h"
|
||||
#include "spdk_internal/accel_engine.h"
|
||||
#include "thread/thread_internal.h"
|
||||
#include "common/lib/test_env.c"
|
||||
#include "accel/accel_engine.c"
|
||||
|
Loading…
Reference in New Issue
Block a user