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

lib/accel: Add suport for copy + CRC32C to accel framework



Upcoming patches will add support for the idxd engine and
the accel_perf tool.  Also following will come vectored support and
batch versions.

Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I7223517a844525ad52ed49d65627b04c3cd9fe7c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8141


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 1076008e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@

## v21.07: (Upcoming Release)

### accel_fw

Added API `spdk_accel_submit_copy_crc32c` to perform a CRC32C while copying data.

### bdev

Change `spdk_bdev_read_blocks_with_md` arg offset definiton from int64_t to uint64_t.
+21 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ enum accel_capability {
	ACCEL_COMPARE		= 1 << 3,
	ACCEL_CRC32C		= 1 << 4,
	ACCEL_DIF		= 1 << 5,
	ACCEL_COPY_CRC32C	= 1 << 6,
};

/**
@@ -372,6 +373,26 @@ int spdk_accel_submit_crc32c(struct spdk_io_channel *ch, uint32_t *dst, void *sr
int spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *dst, struct iovec *iovs,
			      uint32_t iovcnt, uint32_t seed, spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a copy with CRC-32C calculation request.
 *
 * This operation will copy data and calculate the 4 byte CRC32-C for the given data.
 *
 * \param ch I/O channel associated with this call.
 * \param dst Destination to write the data to.
 * \param src The source address for the data.
 * \param crc_dst Destination to write the CRC-32C to.
 * \param seed Four byte seed value.
 * \param nbytes Length in bytes.
 * \param cb_fn Called when this CRC-32C operation completes.
 * \param cb_arg Callback argument.
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_submit_copy_crc32c(struct spdk_io_channel *ch, void *dst, void *src,
				  uint32_t *crc_dst, uint32_t seed, uint64_t nbytes,
				  spdk_accel_completion_cb cb_fn, void *cb_arg);

struct spdk_json_write_ctx;

/**
+8 −6
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ enum accel_opcode {
	ACCEL_OPCODE_BATCH		= 3,
	ACCEL_OPCODE_CRC32C		= 4,
	ACCEL_OPCODE_DUALCAST		= 5,
	ACCEL_OPCODE_COPY_CRC32C	= 6,
};

struct spdk_accel_task {
@@ -100,6 +101,7 @@ struct spdk_accel_task {
		uint32_t			seed;
		uint64_t			fill_pattern;
	};
	uint32_t			*crc_dst;
	enum accel_opcode		op_code;
	uint64_t			nbytes;
	TAILQ_ENTRY(spdk_accel_task)	link;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 5
SO_VER := 6
SO_MINOR := 0
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

+32 −0
Original line number Diff line number Diff line
@@ -401,6 +401,38 @@ spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *dst, struct iove
	}
}

/* Accel framework public API for copy with CRC-32C function */
int
spdk_accel_submit_copy_crc32c(struct spdk_io_channel *ch, void *dst, void *src,
			      uint32_t *crc_dst, uint32_t seed, uint64_t nbytes,
			      spdk_accel_completion_cb cb_fn, void *cb_arg)
{
	struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
	struct spdk_accel_task *accel_task;

	accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
	if (accel_task == NULL) {
		return -ENOMEM;
	}

	accel_task->dst = dst;
	accel_task->src = src;
	accel_task->crc_dst = crc_dst;
	accel_task->v.iovcnt = 0;
	accel_task->seed = seed;
	accel_task->nbytes = nbytes;
	accel_task->op_code = ACCEL_OPCODE_COPY_CRC32C;

	if (_is_supported(accel_ch->engine, ACCEL_COPY_CRC32C)) {
		return accel_ch->engine->submit_tasks(accel_ch->engine_ch, accel_task);
	} else {
		_sw_accel_copy(dst, src, nbytes);
		_sw_accel_crc32c(crc_dst, src, seed, nbytes);
		spdk_accel_task_complete(accel_task, 0);
		return 0;
	}
}

/* Accel framework public API for getting max operations for a batch. */
uint32_t
spdk_accel_batch_get_max(struct spdk_io_channel *ch)
Loading