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

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: default avatarpaul 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 9d94a8d5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# 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
+20 −0
Original line number Diff line number Diff line
@@ -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.
 *
+5 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ struct spdk_accel_task {
};

struct spdk_accel_engine {
	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,
+1 −1
Original line number Diff line number Diff line
@@ -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
+18 −3
Original line number Diff line number Diff line
@@ -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,6 +344,7 @@ 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 = {
	.get_capabilities	= sw_accel_get_capabilities,
	.copy			= sw_accel_submit_copy,
	.fill			= sw_accel_submit_fill,
	.get_io_channel		= sw_accel_get_io_channel,
Loading