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 <paul.e.luse@intel.com> 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 <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
2234bb665d
commit
db8fe014b7
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user