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

lib/accel: DIF verify accel SW implementation



Extend the Accel SW module with DIF Verify operation support.

The DIF Verify operation computes the Data Integrity Field (DIF)
on the source data and compares the computed DIF to the DIF contained
in the source data

Change-Id: I28cc0915ca572da1c6b1f50bdfc74a06120e7d4f
Signed-off-by: default avatarKrzysztof Sprzaczkowski <krzysztof.sprzaczkowski@intel.com>
Signed-off-by: default avatarSlawomir Ptak <slawomir.ptak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19777


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent b0eb3ed8
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@

#include "spdk/stdinc.h"
#include "spdk/dma.h"
#include "spdk/dif.h"

#ifdef __cplusplus
extern "C" {
@@ -44,7 +45,8 @@ enum spdk_accel_opcode {
	SPDK_ACCEL_OPC_ENCRYPT		= 8,
	SPDK_ACCEL_OPC_DECRYPT		= 9,
	SPDK_ACCEL_OPC_XOR		= 10,
	SPDK_ACCEL_OPC_LAST		= 11,
	SPDK_ACCEL_OPC_DIF_VERIFY	= 11,
	SPDK_ACCEL_OPC_LAST		= 12,
};

enum spdk_accel_cipher {
@@ -384,6 +386,34 @@ int spdk_accel_submit_decrypt(struct spdk_io_channel *ch, struct spdk_accel_cryp
			      uint64_t iv, uint32_t block_size, int flags,
			      spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a Data Integrity Field (DIF) verify request.
 *
 * This operation computes the DIF on the data and compares it against the DIF contained
 * in the metadata.
 *
 * \param ch I/O channel associated with this call.
 * \param iovs The io vector array. The total allocated memory size needs to be at least:
 *             num_blocks * block_size (including metadata)
 * \param iovcnt The size of the io vectors array.
 * \param num_blocks Number of data blocks to check.
 * \param ctx DIF context. Contains the DIF configuration values, including the reference
 *            Application Tag value and initial value of the Reference Tag to check
 *            Note: the user must ensure the validity of this pointer throughout the entire operation
 *            because it is not validated along the processing path.
 * \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(struct spdk_io_channel *ch,
				 struct iovec *iovs, size_t 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);

/** Object grouping multiple accel operations to be executed at the same point in time */
struct spdk_accel_sequence;

+5 −0
Original line number Diff line number Diff line
@@ -134,6 +134,11 @@ struct spdk_accel_task {
		uint32_t			seed;
		uint64_t			fill_pattern;
		struct spdk_accel_crypto_key	*crypto_key;
		struct {
			const struct spdk_dif_ctx	*ctx;
			struct spdk_dif_error		*err;
			uint32_t	num_blocks;
		} dif;
	};
	union {
		uint32_t		*crc_dst;
+29 −1
Original line number Diff line number Diff line
@@ -77,7 +77,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"
	"compress", "decompress", "encrypt", "decrypt", "xor", "dif_verify"
};

enum accel_sequence_state {
@@ -834,6 +834,34 @@ spdk_accel_submit_xor(struct spdk_io_channel *ch, void *dst, void **sources, uin
	return accel_submit_task(accel_ch, accel_task);
}

int
spdk_accel_submit_dif_verify(struct spdk_io_channel *ch,
			     struct iovec *iovs, size_t 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 = iovs;
	accel_task->s.iovcnt = 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;
	accel_task->src_domain = NULL;
	accel_task->dst_domain = NULL;
	accel_task->step_cb_fn = 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)
{
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "spdk/crc32.h"
#include "spdk/util.h"
#include "spdk/xor.h"
#include "spdk/dif.h"

#ifdef SPDK_CONFIG_ISAL
#include "../isa-l/include/igzip_lib.h"
@@ -77,6 +78,7 @@ sw_accel_supports_opcode(enum spdk_accel_opcode opc)
	case SPDK_ACCEL_OPC_ENCRYPT:
	case SPDK_ACCEL_OPC_DECRYPT:
	case SPDK_ACCEL_OPC_XOR:
	case SPDK_ACCEL_OPC_DIF_VERIFY:
		return true;
	default:
		return false;
@@ -441,6 +443,16 @@ _sw_accel_xor(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task *accel_t
			    accel_task->d.iovs[0].iov_len);
}

static int
_sw_accel_dif_verify(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task *accel_task)
{
	return spdk_dif_verify(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_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task)
{
@@ -491,6 +503,9 @@ sw_accel_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_
		case SPDK_ACCEL_OPC_DECRYPT:
			rc = _sw_accel_decrypt(sw_ch, accel_task);
			break;
		case SPDK_ACCEL_OPC_DIF_VERIFY:
			rc = _sw_accel_dif_verify(sw_ch, accel_task);
			break;
		default:
			assert(false);
			break;
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
	spdk_accel_submit_encrypt;
	spdk_accel_submit_decrypt;
	spdk_accel_submit_xor;
	spdk_accel_submit_dif_verify;
	spdk_accel_get_opc_module_name;
	spdk_accel_assign_opc;
	spdk_accel_write_config_json;