lib/accel: add compare function to accel fw

Along with the sw engine back end implementation for it. IDXD
back end will follow, the use in the accel perf tool as part
of verify.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Ia1013cd884ff71990f898320d6a22e96e16ad2a4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2107
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
paul luse 2020-04-29 18:27:23 -04:00 committed by Tomasz Zawadzki
parent 7a0274fc38
commit 3ef64e0c2b
6 changed files with 56 additions and 2 deletions

View File

@ -11,6 +11,10 @@ A new capability, CRC-32C, was added via `spdk_accel_submit_crc32c`.
The software accel engine implemenation has added support for CRC-32C. The software accel engine implemenation has added support for CRC-32C.
A new capability, compare, was added via `spdk_accel_submit_compare`.
The software accel engine implemenation has added support forCRC-32Cc and compare.
### idxd ### idxd
IDXD engine support for CRC-32C has been added. IDXD engine support for CRC-32C has been added.

View File

@ -135,6 +135,23 @@ uint64_t spdk_accel_get_capabilities(struct spdk_io_channel *ch);
int spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, void *dst, int spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, void *dst,
void *src, uint64_t nbytes, spdk_accel_completion_cb cb); void *src, uint64_t nbytes, spdk_accel_completion_cb cb);
/**
* Submit a compare request.
*
* \param accel_req Accel request task.
* \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().
* \param src1 First location to perform compare on.
* \param src2 Second location to perform compare on.
* \param nbytes Length in bytes to compare.
* \param cb Called when this compare operation completes.
*
* \return 0 on success, any other value means there was a miscompare.
*/
int spdk_accel_submit_compare(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch,
void *src1,
void *src2, uint64_t nbytes, spdk_accel_completion_cb cb);
/** /**
* Submit a fill request. * Submit a fill request.
* *

View File

@ -48,6 +48,8 @@ struct spdk_accel_engine {
uint64_t (*get_capabilities)(void); uint64_t (*get_capabilities)(void);
int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src, int (*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
uint64_t nbytes, spdk_accel_completion_cb cb); uint64_t nbytes, spdk_accel_completion_cb cb);
int (*compare)(void *cb_arg, struct spdk_io_channel *ch, void *src1, void *src2,
uint64_t nbytes, spdk_accel_completion_cb cb);
int (*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill, 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 (*crc32c)(void *cb_arg, struct spdk_io_channel *ch, uint32_t *dst, void *src, int (*crc32c)(void *cb_arg, struct spdk_io_channel *ch, uint32_t *dst, void *src,

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 := 2 SO_MINOR := 3
SO_SUFFIX := $(SO_VER).$(SO_MINOR) SO_SUFFIX := $(SO_VER).$(SO_MINOR)
LIBNAME = accel LIBNAME = accel

View File

@ -121,6 +121,18 @@ spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel
_accel_engine_done); _accel_engine_done);
} }
/* Accel framework public API for compare function */
int
spdk_accel_submit_compare(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch,
void *src1, void *src2, uint64_t nbytes, spdk_accel_completion_cb cb)
{
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
accel_req->cb = cb;
return accel_ch->engine->compare(accel_req->offload_ctx, accel_ch->ch, src1, src2, nbytes,
_accel_engine_done);
}
/* Accel framework public API for fill function */ /* Accel framework public API for fill function */
int int
spdk_accel_submit_fill(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, spdk_accel_submit_fill(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch,
@ -302,7 +314,7 @@ spdk_accel_engine_config_text(FILE *fp)
static uint64_t static uint64_t
sw_accel_get_capabilities(void) sw_accel_get_capabilities(void)
{ {
return ACCEL_COPY | ACCEL_FILL | ACCEL_CRC32C; return ACCEL_COPY | ACCEL_FILL | ACCEL_CRC32C | ACCEL_COMPARE;
} }
static int static int
@ -320,6 +332,23 @@ sw_accel_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *
return 0; return 0;
} }
static int
sw_accel_submit_compare(void *cb_arg, struct spdk_io_channel *ch, void *src1, void *src2,
uint64_t nbytes,
spdk_accel_completion_cb cb)
{
struct spdk_accel_task *accel_req;
int result;
result = memcmp(src1, src2, (size_t)nbytes);
accel_req = (struct spdk_accel_task *)((uintptr_t)cb_arg -
offsetof(struct spdk_accel_task, offload_ctx));
cb(accel_req, result);
return 0;
}
static int static int
sw_accel_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill, sw_accel_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
uint64_t nbytes, uint64_t nbytes,
@ -355,6 +384,7 @@ 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 = {
.get_capabilities = sw_accel_get_capabilities, .get_capabilities = sw_accel_get_capabilities,
.copy = sw_accel_submit_copy, .copy = sw_accel_submit_copy,
.compare = sw_accel_submit_compare,
.fill = sw_accel_submit_fill, .fill = sw_accel_submit_fill,
.crc32c = sw_accel_submit_crc32c, .crc32c = sw_accel_submit_crc32c,
.get_io_channel = sw_accel_get_io_channel, .get_io_channel = sw_accel_get_io_channel,

View File

@ -9,6 +9,7 @@
spdk_accel_engine_get_io_channel; spdk_accel_engine_get_io_channel;
spdk_accel_get_capabilities; spdk_accel_get_capabilities;
spdk_accel_submit_copy; spdk_accel_submit_copy;
spdk_accel_submit_compare;
spdk_accel_submit_fill; spdk_accel_submit_fill;
spdk_accel_submit_crc32c; spdk_accel_submit_crc32c;
spdk_accel_task_size; spdk_accel_task_size;