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

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: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: Ia1013cd884ff71990f898320d6a22e96e16ad2a4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2107


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 7a0274fc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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.
+17 −0
Original line number Diff line number Diff line
@@ -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.
 *
+2 −0
Original line number Diff line number Diff line
@@ -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,
+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 := 2
SO_MINOR := 3
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

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