accel: add new API to discover an engine's capabilities
This patch also implements the new API for the 3 existing engines. There was also some minor clean in one file, moving a function to eliminate multiple forward declarations (there would have been another one with this new API). The next patch will use this API in the accel perf tool. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: I4ebc9cb3d1c588919235b5080cbeec29189efa21 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2025 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
9d94a8d53a
commit
d5b059dedc
@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
### accel
|
||||
|
||||
A new API was added `spdk_accel_get_capabilities` that allows applications to
|
||||
query the capabilities of the currently enabled accel engine back-end.
|
||||
|
||||
## v20.04: (Upcoming Release)
|
||||
|
||||
### configuration
|
||||
|
@ -44,6 +44,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum accel_capability {
|
||||
ACCEL_COPY = 1 << 0,
|
||||
ACCEL_FILL = 1 << 1,
|
||||
ACCEL_DUALCAST = 1 << 2,
|
||||
ACCEL_COMPARE = 1 << 3,
|
||||
ACCEL_BATCH = 1 << 4,
|
||||
ACCEL_CRC = 1 << 5,
|
||||
ACCEL_DIF = 1 << 6,
|
||||
};
|
||||
|
||||
/**
|
||||
* Acceleration operation callback.
|
||||
*
|
||||
@ -99,6 +109,16 @@ void spdk_accel_engine_module_finish(void);
|
||||
*/
|
||||
struct spdk_io_channel *spdk_accel_engine_get_io_channel(void);
|
||||
|
||||
/**
|
||||
* Retrieve accel engine capabilities.
|
||||
*
|
||||
* \param ch I/O channel to submit request to the accel engine. This channel can
|
||||
* be obtained by the function spdk_accel_engine_get_io_channel().
|
||||
*
|
||||
* \return bitmap of capabilities defined by enum accel_capability.
|
||||
*/
|
||||
uint64_t spdk_accel_get_capabilities(struct spdk_io_channel *ch);
|
||||
|
||||
/**
|
||||
* Submit a copy request.
|
||||
*
|
||||
|
@ -55,10 +55,11 @@ struct spdk_accel_task {
|
||||
};
|
||||
|
||||
struct spdk_accel_engine {
|
||||
int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb);
|
||||
int (*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb);
|
||||
uint64_t (*get_capabilities)(void);
|
||||
int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb);
|
||||
int (*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb);
|
||||
struct spdk_io_channel *(*get_io_channel)(void);
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 2
|
||||
SO_MINOR := 0
|
||||
SO_MINOR := 1
|
||||
SO_SUFFIX := $(SO_VER).$(SO_MINOR)
|
||||
|
||||
LIBNAME = accel
|
||||
|
@ -109,6 +109,14 @@ _accel_engine_done(void *ref, int status)
|
||||
req->cb(req, status);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
spdk_accel_get_capabilities(struct spdk_io_channel *ch)
|
||||
{
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
return accel_ch->engine->get_capabilities();
|
||||
}
|
||||
|
||||
/* Accel framework public API for copy function */
|
||||
int
|
||||
spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch,
|
||||
@ -297,6 +305,12 @@ spdk_accel_engine_config_text(FILE *fp)
|
||||
|
||||
/* The SW Accelerator module is "built in" here (rest of file) */
|
||||
|
||||
static uint64_t
|
||||
sw_accel_get_capabilities(void)
|
||||
{
|
||||
return ACCEL_COPY | ACCEL_FILL;
|
||||
}
|
||||
|
||||
static int
|
||||
sw_accel_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
|
||||
uint64_t nbytes,
|
||||
@ -330,9 +344,10 @@ sw_accel_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_
|
||||
static struct spdk_io_channel *sw_accel_get_io_channel(void);
|
||||
|
||||
static struct spdk_accel_engine sw_accel_engine = {
|
||||
.copy = sw_accel_submit_copy,
|
||||
.fill = sw_accel_submit_fill,
|
||||
.get_io_channel = sw_accel_get_io_channel,
|
||||
.get_capabilities = sw_accel_get_capabilities,
|
||||
.copy = sw_accel_submit_copy,
|
||||
.fill = sw_accel_submit_fill,
|
||||
.get_io_channel = sw_accel_get_io_channel,
|
||||
};
|
||||
|
||||
static int
|
||||
|
@ -7,6 +7,7 @@
|
||||
spdk_accel_engine_config_text;
|
||||
spdk_accel_engine_module_finish;
|
||||
spdk_accel_engine_get_io_channel;
|
||||
spdk_accel_get_capabilities;
|
||||
spdk_accel_submit_copy;
|
||||
spdk_accel_submit_fill;
|
||||
spdk_accel_task_size;
|
||||
|
@ -102,20 +102,9 @@ struct idxd_task {
|
||||
spdk_accel_completion_cb cb;
|
||||
};
|
||||
|
||||
static int accel_engine_idxd_init(void);
|
||||
static void accel_engine_idxd_exit(void *ctx);
|
||||
static struct spdk_io_channel *idxd_get_io_channel(void);
|
||||
static int idxd_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
|
||||
uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb);
|
||||
static int idxd_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb);
|
||||
pthread_mutex_t g_num_channels_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct spdk_accel_engine idxd_accel_engine = {
|
||||
.copy = idxd_submit_copy,
|
||||
.fill = idxd_submit_fill,
|
||||
.get_io_channel = idxd_get_io_channel,
|
||||
};
|
||||
static struct spdk_io_channel *idxd_get_io_channel(void);
|
||||
|
||||
static struct idxd_device *
|
||||
idxd_select_device(void)
|
||||
@ -271,7 +260,19 @@ idxd_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fi
|
||||
return rc;
|
||||
}
|
||||
|
||||
pthread_mutex_t g_num_channels_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static uint64_t
|
||||
idxd_get_capabilities(void)
|
||||
{
|
||||
return ACCEL_COPY | ACCEL_FILL | ACCEL_DUALCAST | ACCEL_COMPARE |
|
||||
ACCEL_BATCH | ACCEL_CRC | ACCEL_DIF;
|
||||
}
|
||||
|
||||
static struct spdk_accel_engine idxd_accel_engine = {
|
||||
.get_capabilities = idxd_get_capabilities,
|
||||
.copy = idxd_submit_copy,
|
||||
.fill = idxd_submit_fill,
|
||||
.get_io_channel = idxd_get_io_channel,
|
||||
};
|
||||
|
||||
/*
|
||||
* Configure the max number of descriptors that a channel is
|
||||
|
@ -191,10 +191,21 @@ ioat_poll(void *arg)
|
||||
|
||||
static struct spdk_io_channel *ioat_get_io_channel(void);
|
||||
|
||||
/*
|
||||
* The IOAT engine has more capabilities than this but these are
|
||||
* the only ones we expose via the accel engine.
|
||||
*/
|
||||
static uint64_t
|
||||
ioat_get_capabilities(void)
|
||||
{
|
||||
return ACCEL_COPY | ACCEL_FILL;
|
||||
}
|
||||
|
||||
static struct spdk_accel_engine ioat_accel_engine = {
|
||||
.copy = ioat_submit_copy,
|
||||
.fill = ioat_submit_fill,
|
||||
.get_io_channel = ioat_get_io_channel,
|
||||
.get_capabilities = ioat_get_capabilities,
|
||||
.copy = ioat_submit_copy,
|
||||
.fill = ioat_submit_fill,
|
||||
.get_io_channel = ioat_get_io_channel,
|
||||
};
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user