Commit c5d5ee90 authored by Krzysztof Sprzaczkowski's avatar Krzysztof Sprzaczkowski Committed by Tomasz Zawadzki
Browse files

lib/accel: DIF verify copy accel SW implementation



Extend the Accel SW module with DIF Verify-copy operation support.

The DIF Verify-copy operation copies memory from the Source
Address to the Destination Address with verifying and removing
the Data Integrity Field (DIF) from the output.

Change-Id: I1575911c97812a1b60f603a3eb8fc061f3f4e84a
Signed-off-by: default avatarKrzysztof Sprzaczkowski <krzysztof.sprzaczkowski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21718


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 9f19acb5
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -46,9 +46,10 @@ enum spdk_accel_opcode {
	SPDK_ACCEL_OPC_DECRYPT			= 9,
	SPDK_ACCEL_OPC_XOR			= 10,
	SPDK_ACCEL_OPC_DIF_VERIFY		= 11,
	SPDK_ACCEL_OPC_DIF_GENERATE		= 12,
	SPDK_ACCEL_OPC_DIF_GENERATE_COPY	= 13,
	SPDK_ACCEL_OPC_LAST			= 14,
	SPDK_ACCEL_OPC_DIF_VERIFY_COPY		= 12,
	SPDK_ACCEL_OPC_DIF_GENERATE		= 13,
	SPDK_ACCEL_OPC_DIF_GENERATE_COPY	= 14,
	SPDK_ACCEL_OPC_LAST			= 15,
};

enum spdk_accel_cipher {
@@ -407,6 +408,36 @@ int spdk_accel_submit_dif_verify(struct spdk_io_channel *ch,
				 const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err,
				 spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a Data Integrity Field (DIF) copy and verify request.
 *
 * This operation copies memory from the source to the destination address and removes
 * the DIF data with its verification according to the flags provided in the context.
 *
 * \param ch I/O channel associated with this call.
 * \param dst_iovs The destination I/O vector array. The total allocated memory size needs
 *		  to be at least: num_blocks * block_size (provided to spdk_dif_ctx_init())
 * \param dst_iovcnt The size of the destination I/O vectors array.
 * \param src_iovs The source I/O vector array. The total allocated memory size needs
 *		  to be at least: num_blocks * (block_size - md_size)
 * \param src_iovcnt The size of the source I/O vectors array.
 * \param num_blocks Number of data blocks to process.
 * \param ctx DIF context. Contains the DIF configuration values, including the reference
 *            Application Tag value and initial value of the Reference Tag to insert.
 * \param err DIF error detailed information.
 *            Note: the user must ensure the validity of this pointer throughout the entire operation
 *            because it is not validated along the processing path.
 * \param cb_fn Called when this operation completes.
 * \param cb_arg Callback argument.
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_submit_dif_verify_copy(struct spdk_io_channel *ch,
				      struct iovec *dst_iovs, size_t dst_iovcnt,
				      struct iovec *src_iovs, size_t src_iovcnt, uint32_t num_blocks,
				      const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err,
				      spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a Data Integrity Field (DIF) generate request.
 *
+31 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static struct spdk_spinlock g_stats_lock;
static const char *g_opcode_strings[SPDK_ACCEL_OPC_LAST] = {
	"copy", "fill", "dualcast", "compare", "crc32c", "copy_crc32c",
	"compress", "decompress", "encrypt", "decrypt", "xor",
	"dif_verify", "dif_generate", "dif_generate_copy"
	"dif_verify", "dif_verify_copy", "dif_generate", "dif_generate_copy"
};

enum accel_sequence_state {
@@ -889,6 +889,36 @@ spdk_accel_submit_dif_generate_copy(struct spdk_io_channel *ch, struct iovec *ds
	return accel_submit_task(accel_ch, accel_task);
}

int
spdk_accel_submit_dif_verify_copy(struct spdk_io_channel *ch,
				  struct iovec *dst_iovs, size_t dst_iovcnt,
				  struct iovec *src_iovs, size_t src_iovcnt, uint32_t num_blocks,
				  const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err,
				  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, cb_fn, cb_arg);
	if (accel_task == NULL) {
		return -ENOMEM;
	}

	accel_task->s.iovs = src_iovs;
	accel_task->s.iovcnt = src_iovcnt;
	accel_task->d.iovs = dst_iovs;
	accel_task->d.iovcnt = dst_iovcnt;
	accel_task->dif.ctx = ctx;
	accel_task->dif.err = err;
	accel_task->dif.num_blocks = num_blocks;
	accel_task->nbytes = num_blocks * ctx->block_size;
	accel_task->op_code = SPDK_ACCEL_OPC_DIF_VERIFY_COPY;
	accel_task->src_domain = NULL;
	accel_task->dst_domain = NULL;

	return accel_submit_task(accel_ch, accel_task);
}

static inline struct accel_buffer *
accel_get_buf(struct accel_io_channel *ch, uint64_t len)
{
+16 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ sw_accel_supports_opcode(enum spdk_accel_opcode opc)
	case SPDK_ACCEL_OPC_DIF_VERIFY:
	case SPDK_ACCEL_OPC_DIF_GENERATE:
	case SPDK_ACCEL_OPC_DIF_GENERATE_COPY:
	case SPDK_ACCEL_OPC_DIF_VERIFY_COPY:
		return true;
	default:
		return false;
@@ -454,6 +455,18 @@ _sw_accel_dif_verify(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task *
			       accel_task->dif.err);
}

static int
_sw_accel_dif_verify_copy(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task *accel_task)
{
	return spdk_dif_verify_copy(accel_task->d.iovs,
				    accel_task->d.iovcnt,
				    accel_task->s.iovs,
				    accel_task->s.iovcnt,
				    accel_task->dif.num_blocks,
				    accel_task->dif.ctx,
				    accel_task->dif.err);
}

static int
_sw_accel_dif_generate(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task *accel_task)
{
@@ -557,6 +570,9 @@ sw_accel_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_
		case SPDK_ACCEL_OPC_DIF_VERIFY:
			rc = _sw_accel_dif_verify(sw_ch, accel_task);
			break;
		case SPDK_ACCEL_OPC_DIF_VERIFY_COPY:
			rc = _sw_accel_dif_verify_copy(sw_ch, accel_task);
			break;
		case SPDK_ACCEL_OPC_DIF_GENERATE:
			rc = _sw_accel_dif_generate(sw_ch, accel_task);
			break;
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
	spdk_accel_submit_decrypt;
	spdk_accel_submit_xor;
	spdk_accel_submit_dif_verify;
	spdk_accel_submit_dif_verify_copy;
	spdk_accel_submit_dif_generate;
	spdk_accel_submit_dif_generate_copy;
	spdk_accel_get_opc_module_name;