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

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: default avatarpaul 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 2234bb66
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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
+20 −1
Original line number Diff line number Diff line
@@ -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.
 *
+2 −0
Original line number Diff line number Diff line
@@ -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);
};

+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 := 1
SO_MINOR := 2
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

LIBNAME = accel
+33 −1
Original line number Diff line number Diff line
@@ -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,
};

Loading