diff --git a/CHANGELOG.md b/CHANGELOG.md index a41244abd..ed00b7cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. +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 engine support for CRC-32C has been added. diff --git a/include/spdk/accel_engine.h b/include/spdk/accel_engine.h index 3fde134a0..938b57b6a 100644 --- a/include/spdk/accel_engine.h +++ b/include/spdk/accel_engine.h @@ -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, 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. * diff --git a/include/spdk_internal/accel_engine.h b/include/spdk_internal/accel_engine.h index 6488b4aed..f7a24f7df 100644 --- a/include/spdk_internal/accel_engine.h +++ b/include/spdk_internal/accel_engine.h @@ -48,6 +48,8 @@ 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 (*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, uint64_t nbytes, spdk_accel_completion_cb cb); int (*crc32c)(void *cb_arg, struct spdk_io_channel *ch, uint32_t *dst, void *src, diff --git a/lib/accel/Makefile b/lib/accel/Makefile index 0cb8679f9..3d4f648c0 100644 --- a/lib/accel/Makefile +++ b/lib/accel/Makefile @@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk SO_VER := 2 -SO_MINOR := 2 +SO_MINOR := 3 SO_SUFFIX := $(SO_VER).$(SO_MINOR) LIBNAME = accel diff --git a/lib/accel/accel_engine.c b/lib/accel/accel_engine.c index 32027a9ec..c04322747 100644 --- a/lib/accel/accel_engine.c +++ b/lib/accel/accel_engine.c @@ -121,6 +121,18 @@ spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_channel _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 */ int 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 sw_accel_get_capabilities(void) { - return ACCEL_COPY | ACCEL_FILL | ACCEL_CRC32C; + return ACCEL_COPY | ACCEL_FILL | ACCEL_CRC32C | ACCEL_COMPARE; } static int @@ -320,6 +332,23 @@ sw_accel_submit_copy(void *cb_arg, struct spdk_io_channel *ch, void *dst, void * 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 sw_accel_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill, 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 = { .get_capabilities = sw_accel_get_capabilities, .copy = sw_accel_submit_copy, + .compare = sw_accel_submit_compare, .fill = sw_accel_submit_fill, .crc32c = sw_accel_submit_crc32c, .get_io_channel = sw_accel_get_io_channel, diff --git a/lib/accel/spdk_accel.map b/lib/accel/spdk_accel.map index 992d1faf6..fe3fbc4ac 100644 --- a/lib/accel/spdk_accel.map +++ b/lib/accel/spdk_accel.map @@ -9,6 +9,7 @@ spdk_accel_engine_get_io_channel; spdk_accel_get_capabilities; spdk_accel_submit_copy; + spdk_accel_submit_compare; spdk_accel_submit_fill; spdk_accel_submit_crc32c; spdk_accel_task_size;