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:
paul luse 2020-04-24 12:47:55 -04:00 committed by Tomasz Zawadzki
parent 9d94a8d53a
commit d5b059dedc
8 changed files with 79 additions and 25 deletions

View File

@ -1,5 +1,10 @@
# Changelog # 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) ## v20.04: (Upcoming Release)
### configuration ### configuration

View File

@ -44,6 +44,16 @@
extern "C" { extern "C" {
#endif #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. * 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); 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. * Submit a copy request.
* *

View File

@ -55,10 +55,11 @@ struct spdk_accel_task {
}; };
struct spdk_accel_engine { struct spdk_accel_engine {
int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src, uint64_t (*get_capabilities)(void);
uint64_t nbytes, spdk_accel_completion_cb cb); int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
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 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); struct spdk_io_channel *(*get_io_channel)(void);
}; };

View File

@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
SO_VER := 2 SO_VER := 2
SO_MINOR := 0 SO_MINOR := 1
SO_SUFFIX := $(SO_VER).$(SO_MINOR) SO_SUFFIX := $(SO_VER).$(SO_MINOR)
LIBNAME = accel LIBNAME = accel

View File

@ -109,6 +109,14 @@ _accel_engine_done(void *ref, int status)
req->cb(req, 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 */ /* Accel framework public API for copy function */
int int
spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, 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) */ /* 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 static int
sw_accel_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src, sw_accel_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
uint64_t nbytes, 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_io_channel *sw_accel_get_io_channel(void);
static struct spdk_accel_engine sw_accel_engine = { static struct spdk_accel_engine sw_accel_engine = {
.copy = sw_accel_submit_copy, .get_capabilities = sw_accel_get_capabilities,
.fill = sw_accel_submit_fill, .copy = sw_accel_submit_copy,
.get_io_channel = sw_accel_get_io_channel, .fill = sw_accel_submit_fill,
.get_io_channel = sw_accel_get_io_channel,
}; };
static int static int

View File

@ -7,6 +7,7 @@
spdk_accel_engine_config_text; spdk_accel_engine_config_text;
spdk_accel_engine_module_finish; spdk_accel_engine_module_finish;
spdk_accel_engine_get_io_channel; spdk_accel_engine_get_io_channel;
spdk_accel_get_capabilities;
spdk_accel_submit_copy; spdk_accel_submit_copy;
spdk_accel_submit_fill; spdk_accel_submit_fill;
spdk_accel_task_size; spdk_accel_task_size;

View File

@ -102,20 +102,9 @@ struct idxd_task {
spdk_accel_completion_cb cb; spdk_accel_completion_cb cb;
}; };
static int accel_engine_idxd_init(void); pthread_mutex_t g_num_channels_lock = PTHREAD_MUTEX_INITIALIZER;
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);
static struct spdk_accel_engine idxd_accel_engine = { static struct spdk_io_channel *idxd_get_io_channel(void);
.copy = idxd_submit_copy,
.fill = idxd_submit_fill,
.get_io_channel = idxd_get_io_channel,
};
static struct idxd_device * static struct idxd_device *
idxd_select_device(void) 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; 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 * Configure the max number of descriptors that a channel is

View File

@ -191,10 +191,21 @@ ioat_poll(void *arg)
static struct spdk_io_channel *ioat_get_io_channel(void); 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 = { static struct spdk_accel_engine ioat_accel_engine = {
.copy = ioat_submit_copy, .get_capabilities = ioat_get_capabilities,
.fill = ioat_submit_fill, .copy = ioat_submit_copy,
.get_io_channel = ioat_get_io_channel, .fill = ioat_submit_fill,
.get_io_channel = ioat_get_io_channel,
}; };
static int static int