From db8fe014b73e7424f00d8e6152f6c13d4bb63020 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 28 Apr 2020 18:20:57 -0400 Subject: [PATCH] lib/accel: Add CRC function Add the CRC function at the framework level and implement the software engine back end to use ISAL. The patch series will continue to include an option for accel_perf to test CRC as well as IDXD implementation. Signed-off-by: paul luse Change-Id: I4eff3bbcf98c0bc2928a48272a57031c8b96394e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2072 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Aleksey Marchuk --- CHANGELOG.md | 4 ++++ include/spdk/accel_engine.h | 21 ++++++++++++++++- include/spdk_internal/accel_engine.h | 2 ++ lib/accel/Makefile | 2 +- lib/accel/accel_engine.c | 34 ++++++++++++++++++++++++++- lib/accel/spdk_accel.map | 1 + mk/spdk.lib_deps.mk | 2 +- module/accel/idxd/accel_engine_idxd.c | 3 +-- 8 files changed, 63 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1f1e78a..62e5dc85e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ A new API was added `spdk_accel_get_capabilities` that allows applications to query the capabilities of the currently enabled accel engine back-end. +A new capability, CRC-32C, was added via `spdk_accel_submit_crc32c`. + +The software accel engine implemenation has added support for CRC-32C. + ## v20.04: ### configuration diff --git a/include/spdk/accel_engine.h b/include/spdk/accel_engine.h index 2a74e3fd2..3fde134a0 100644 --- a/include/spdk/accel_engine.h +++ b/include/spdk/accel_engine.h @@ -50,7 +50,7 @@ enum accel_capability { ACCEL_DUALCAST = 1 << 2, ACCEL_COMPARE = 1 << 3, ACCEL_BATCH = 1 << 4, - ACCEL_CRC = 1 << 5, + ACCEL_CRC32C = 1 << 5, ACCEL_DIF = 1 << 6, }; @@ -153,6 +153,25 @@ int spdk_accel_submit_copy(struct spdk_accel_task *accel_req, struct spdk_io_cha int spdk_accel_submit_fill(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, void *dst, uint8_t fill, uint64_t nbytes, spdk_accel_completion_cb cb); +/** + * Submit a CRC-32C calculation request. + * + * This operation will calculate the 4 byte CRC32-C for the given data. + * + * \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 dst Destination to write the CRC-32C to. + * \param src The source address for the data. + * \param seed Four byte seed value. + * \param nbytes Length in bytes. + * \param cb Called when this CRC-32C operation completes. + * + * \return 0 on success, negative errno on failure. + */ +int spdk_accel_submit_crc32c(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, + uint32_t *dst, void *src, uint32_t seed, uint64_t nbytes, spdk_accel_completion_cb cb); + /** * Get the size of an acceleration task. * diff --git a/include/spdk_internal/accel_engine.h b/include/spdk_internal/accel_engine.h index f430779c1..6488b4aed 100644 --- a/include/spdk_internal/accel_engine.h +++ b/include/spdk_internal/accel_engine.h @@ -50,6 +50,8 @@ struct spdk_accel_engine { 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, + uint32_t seed, uint64_t nbytes, spdk_accel_completion_cb cb); struct spdk_io_channel *(*get_io_channel)(void); }; diff --git a/lib/accel/Makefile b/lib/accel/Makefile index d288e4ea1..0cb8679f9 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 := 1 +SO_MINOR := 2 SO_SUFFIX := $(SO_VER).$(SO_MINOR) LIBNAME = accel diff --git a/lib/accel/accel_engine.c b/lib/accel/accel_engine.c index a4cbc6ced..32027a9ec 100644 --- a/lib/accel/accel_engine.c +++ b/lib/accel/accel_engine.c @@ -39,6 +39,7 @@ #include "spdk/event.h" #include "spdk/thread.h" #include "spdk/json.h" +#include "spdk/crc32.h" /* Accelerator Engine Framework: The following provides a top level * generic API for the accelerator functions defined here. Modules, @@ -133,6 +134,21 @@ spdk_accel_submit_fill(struct spdk_accel_task *accel_req, struct spdk_io_channel _accel_engine_done); } +/* Accel framework public API for CRC-32C function */ +int +spdk_accel_submit_crc32c(struct spdk_accel_task *accel_req, struct spdk_io_channel *ch, + uint32_t *dst, void *src, uint32_t seed, uint64_t nbytes, spdk_accel_completion_cb cb) +{ + struct spdk_accel_task *req = accel_req; + struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch); + + req->cb = cb; + return accel_ch->engine->crc32c(req->offload_ctx, accel_ch->ch, dst, src, + seed, nbytes, + _accel_engine_done); +} + + /* Returns the largest context size of the accel modules. */ size_t spdk_accel_task_size(void) @@ -286,7 +302,7 @@ spdk_accel_engine_config_text(FILE *fp) static uint64_t sw_accel_get_capabilities(void) { - return ACCEL_COPY | ACCEL_FILL; + return ACCEL_COPY | ACCEL_FILL | ACCEL_CRC32C; } static int @@ -319,12 +335,28 @@ sw_accel_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_ return 0; } +static int +sw_accel_submit_crc32c(void *cb_arg, struct spdk_io_channel *ch, uint32_t *dst, void *src, + uint32_t seed, uint64_t nbytes, + spdk_accel_completion_cb cb) +{ + struct spdk_accel_task *accel_req; + + *dst = spdk_crc32c_update(src, nbytes, ~seed); + accel_req = (struct spdk_accel_task *)((uintptr_t)cb_arg - + offsetof(struct spdk_accel_task, offload_ctx)); + cb(accel_req, 0); + + return 0; +} + 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, + .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 af490b3d2..992d1faf6 100644 --- a/lib/accel/spdk_accel.map +++ b/lib/accel/spdk_accel.map @@ -10,6 +10,7 @@ spdk_accel_get_capabilities; spdk_accel_submit_copy; spdk_accel_submit_fill; + spdk_accel_submit_crc32c; spdk_accel_task_size; spdk_accel_write_config_json; diff --git a/mk/spdk.lib_deps.mk b/mk/spdk.lib_deps.mk index a8392b2e6..1d37bdd46 100644 --- a/mk/spdk.lib_deps.mk +++ b/mk/spdk.lib_deps.mk @@ -57,7 +57,7 @@ DEPDIRS-reduce := log util DEPDIRS-thread := log util DEPDIRS-blob := log util thread -DEPDIRS-accel := log thread +DEPDIRS-accel := log util thread DEPDIRS-jsonrpc := log util json DEPDIRS-virtio := log util json thread diff --git a/module/accel/idxd/accel_engine_idxd.c b/module/accel/idxd/accel_engine_idxd.c index fee935e52..64d647b8b 100644 --- a/module/accel/idxd/accel_engine_idxd.c +++ b/module/accel/idxd/accel_engine_idxd.c @@ -284,8 +284,7 @@ idxd_submit_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fi static uint64_t idxd_get_capabilities(void) { - return ACCEL_COPY | ACCEL_FILL | ACCEL_DUALCAST | ACCEL_COMPARE | - ACCEL_BATCH | ACCEL_CRC | ACCEL_DIF; + return ACCEL_COPY | ACCEL_FILL; } static struct spdk_accel_engine idxd_accel_engine = {