Commit d1ae714b authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

bdev/crypto: set required_alignment based on accel's buf align



Only some modules require buffers to be aligned to a block size, so we
will now report more accurate values for modules that don't have such
requirements.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Iac76460435582eb39a6690fe83f08cd38718cfac
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19765


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@gmail.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9f17bf3c
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -745,6 +745,7 @@ vbdev_crypto_claim(const char *bdev_name)
	struct vbdev_crypto *vbdev;
	struct spdk_bdev *bdev;
	struct spdk_iobuf_opts iobuf_opts;
	struct spdk_accel_operation_exec_ctx opctx = {};
	struct spdk_uuid ns_uuid;
	int rc = 0;

@@ -797,14 +798,14 @@ vbdev_crypto_claim(const char *bdev_name)
			vbdev->crypto_bdev.optimal_io_boundary = (iobuf_opts.large_bufsize / bdev->blocklen);
		}
		vbdev->crypto_bdev.split_on_optimal_io_boundary = true;
		if (bdev->required_alignment > 0) {
			vbdev->crypto_bdev.required_alignment = bdev->required_alignment;
		} else {
			/* Some accel modules may not support SGL input or output, if this module works with physical
			 * addresses, unaligned buffer may cross huge page boundary which leads to scattered payload.
			 * To avoid such cases, set required_alignment to the block size */
			vbdev->crypto_bdev.required_alignment = spdk_u32log2(bdev->blocklen);
		}

		opctx.size = SPDK_SIZEOF(&opctx, block_size);
		opctx.block_size = bdev->blocklen;
		vbdev->crypto_bdev.required_alignment =
			spdk_max(bdev->required_alignment,
				 spdk_max(spdk_accel_get_buf_align(SPDK_ACCEL_OPC_ENCRYPT, &opctx),
					  spdk_accel_get_buf_align(SPDK_ACCEL_OPC_DECRYPT, &opctx)));

		vbdev->crypto_bdev.blocklen = bdev->blocklen;
		vbdev->crypto_bdev.blockcnt = bdev->blockcnt;

+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ DEFINE_STUB_V(spdk_accel_put_buf, (struct spdk_io_channel *ch, void *buf,
DEFINE_STUB(spdk_bdev_get_memory_domains, int,
	    (struct spdk_bdev *bdev, struct spdk_memory_domain **domains, int sz), 0);
DEFINE_STUB(spdk_accel_get_memory_domain, struct spdk_memory_domain *, (void), (void *)0xdeadbeef);
DEFINE_STUB(spdk_accel_get_buf_align, uint8_t,
	    (enum spdk_accel_opcode opcode, const struct spdk_accel_operation_exec_ctx *ctx), 0);

/* global vars and setup/cleanup functions used for all test functions */
struct spdk_bdev_io *g_bdev_io;