Commit 79daf868 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Konrad Sztyber
Browse files

dif: Add SPDK_DIF_FLAGS_NVME_PRACT for dif_generate/verify_copy()



Add a macro constant SPDK_DIF_FLAGS_NVME_PRACT which is the same value
as the PRACT bit in the NVMe specification.

spdk_dif_generate/verify_copy() works if NVME_PRACT is not set or
metadata size is equal with PI size, or return -ENOTSUP otherwise.

The following patch will support the ENOTSUP cases.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Ie0113521572aa405f26c8c197f5ffb14ca0503ff
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23687


Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Community-CI: Mellanox Build Bot
parent 431baf1b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ extern "C" {
#define SPDK_DIF_FLAGS_REFTAG_CHECK	(1U << 26)
#define SPDK_DIF_FLAGS_APPTAG_CHECK	(1U << 27)
#define SPDK_DIF_FLAGS_GUARD_CHECK	(1U << 28)
#define SPDK_DIF_FLAGS_NVME_PRACT	(1U << 29)

#define SPDK_DIF_REFTAG_ERROR	0x1
#define SPDK_DIF_APPTAG_ERROR	0x2
+12 −2
Original line number Diff line number Diff line
@@ -1305,7 +1305,12 @@ spdk_dif_generate_copy(struct iovec *iovs, int iovcnt, struct iovec *bounce_iovs
	_dif_sgl_init(&src_sgl, iovs, iovcnt);
	_dif_sgl_init(&dst_sgl, bounce_iovs, bounce_iovcnt);

	if (!(ctx->dif_flags & SPDK_DIF_FLAGS_NVME_PRACT) ||
	    ctx->md_size == _dif_size(ctx->dif_pi_format)) {
		return _spdk_dif_insert_copy(&src_sgl, &dst_sgl, num_blocks, ctx);
	} else {
		return -ENOTSUP;
	}
}

static int
@@ -1480,7 +1485,12 @@ spdk_dif_verify_copy(struct iovec *iovs, int iovcnt, struct iovec *bounce_iovs,
	_dif_sgl_init(&src_sgl, bounce_iovs, bounce_iovcnt);
	_dif_sgl_init(&dst_sgl, iovs, iovcnt);

	if (!(ctx->dif_flags & SPDK_DIF_FLAGS_NVME_PRACT) ||
	    ctx->md_size == _dif_size(ctx->dif_pi_format)) {
		return _spdk_dif_strip_copy(&src_sgl, &dst_sgl, num_blocks, ctx, err_blk);
	} else {
		return -ENOTSUP;
	}
}

static void