Commit 850cd900 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

accel/idxd/iaa: Convert to use iovecs



In prep for upcoming iovec based compression/decompression patches.

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


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 28886ac3
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ static int g_allocate_depth = 0;
static int g_threads_per_core = 1;
static int g_time_in_sec = 5;
static uint32_t g_crc32c_seed = 0;
static uint32_t g_crc32c_chained_count = 1;
static uint32_t g_chained_count = 1;
static int g_fail_percent_goal = 0;
static uint8_t g_fill_pattern = 255;
static bool g_verify = false;
@@ -51,6 +51,8 @@ struct ap_task {
	void			*src;
	struct iovec		*src_iovs;
	uint32_t		src_iovcnt;
	struct iovec		*dst_iovs;
	uint32_t		dst_iovcnt;
	void			*dst;
	void			*dst2;
	uint32_t		crc_dst;
@@ -94,7 +96,6 @@ dump_user_config(void)
	printf("Workload Type:  %s\n", g_workload_type);
	if (g_workload_selection == ACCEL_OPC_CRC32C || g_workload_selection == ACCEL_OPC_COPY_CRC32C) {
		printf("CRC-32C seed:   %u\n", g_crc32c_seed);
		printf("vector count    %u\n", g_crc32c_chained_count);
	} else if (g_workload_selection == ACCEL_OPC_FILL) {
		printf("Fill pattern:   0x%x\n", g_fill_pattern);
	} else if ((g_workload_selection == ACCEL_OPC_COMPARE) && g_fail_percent_goal > 0) {
@@ -102,10 +103,11 @@ dump_user_config(void)
	}
	if (g_workload_selection == ACCEL_OPC_COPY_CRC32C) {
		printf("Vector size:    %u bytes\n", g_xfer_size_bytes);
		printf("Transfer size:  %u bytes\n", g_xfer_size_bytes * g_crc32c_chained_count);
		printf("Transfer size:  %u bytes\n", g_xfer_size_bytes * g_chained_count);
	} else {
		printf("Transfer size:  %u bytes\n", g_xfer_size_bytes);
	}
	printf("vector count    %u\n", g_chained_count);
	printf("Module:         %s\n", module_name);
	printf("Queue depth:    %u\n", g_queue_depth);
	printf("Allocate depth: %u\n", g_allocate_depth);
@@ -120,7 +122,7 @@ usage(void)
	printf("accel_perf options:\n");
	printf("\t[-h help message]\n");
	printf("\t[-q queue depth per core]\n");
	printf("\t[-C for crc32c workload, use this value to configure the io vector size to test (default 1)\n");
	printf("\t[-C for supported workloads, use this value to configure the io vector size to test (default 1)\n");
	printf("\t[-T number of threads per core\n");
	printf("\t[-n number of channels]\n");
	printf("\t[-o transfer size in bytes]\n");
@@ -165,7 +167,7 @@ parse_args(int argc, char *argv)
		g_allocate_depth = argval;
		break;
	case 'C':
		g_crc32c_chained_count = argval;
		g_chained_count = argval;
		break;
	case 'f':
		g_fill_pattern = (uint8_t)argval;
@@ -251,8 +253,8 @@ _get_task_data_bufs(struct ap_task *task)
	}

	if (g_workload_selection == ACCEL_OPC_CRC32C || g_workload_selection == ACCEL_OPC_COPY_CRC32C) {
		assert(g_crc32c_chained_count > 0);
		task->src_iovcnt = g_crc32c_chained_count;
		assert(g_chained_count > 0);
		task->src_iovcnt = g_chained_count;
		task->src_iovs = calloc(task->src_iovcnt, sizeof(struct iovec));
		if (!task->src_iovs) {
			fprintf(stderr, "cannot allocated task->src_iovs fot task=%p\n", task);
@@ -260,7 +262,7 @@ _get_task_data_bufs(struct ap_task *task)
		}

		if (g_workload_selection == ACCEL_OPC_COPY_CRC32C) {
			dst_buff_len = g_xfer_size_bytes * g_crc32c_chained_count;
			dst_buff_len = g_xfer_size_bytes * g_chained_count;
		}

		for (i = 0; i < task->src_iovcnt; i++) {
@@ -750,7 +752,7 @@ main(int argc, char **argv)
	}

	if ((g_workload_selection == ACCEL_OPC_CRC32C || g_workload_selection == ACCEL_OPC_COPY_CRC32C) &&
	    g_crc32c_chained_count == 0) {
	    g_chained_count == 0) {
		usage();
		g_rc = -1;
		goto cleanup;
+15 −13
Original line number Diff line number Diff line
@@ -221,10 +221,10 @@ int spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst, struct
 * This function will build the compress descriptor and submit it.
 *
 * \param ch I/O channel associated with this call
 * \param dst Destination to compress to.
 * \param src Source to read from.
 * \param nbytes_dst Length in bytes of output buffer.
 * \param nbytes_src Length in bytes of input buffer.
 * \param dst Destination to write the data to.
 * \param nbytes Length in bytes.
 * \param src_iovs The io vector array which stores the src data and len.
 * \param src_iovcnt The size of the src io vectors.
 * \param output_size The size of the compressed data
 * \param flags Flags, optional flags that can vary per operation.
 * \param cb_fn Callback function which will be called when the request is complete.
@@ -233,9 +233,10 @@ int spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst, struct
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, void *src,
			       uint64_t nbytes_dst, uint64_t nbytes_src, uint32_t *output_size,
			       int flags, spdk_accel_completion_cb cb_fn, void *cb_arg);
int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst,
			       uint64_t nbytes, struct iovec *src_iovs,
			       size_t src_iovcnt, uint32_t *output_size, int flags,
			       spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Build and submit a memory decompress request.
@@ -243,10 +244,10 @@ int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, void *src,
 * This function will build the decompress descriptor and submit it.
 *
 * \param ch I/O channel associated with this call
 * \param dst Destination. Must be large enough to hold decompressed data.
 * \param src Source to read from.
 * \param nbytes_dst Length in bytes of output buffer.
 * \param nbytes_src Length in bytes of input buffer.
 * \param dst_iovs The io vector array which stores the dst data and len.
 * \param dst_iovcnt The size of the dst io vectors.
 * \param src_iovs The io vector array which stores the src data and len.
 * \param src_iovcnt The size of the src io vectors.
 * \param flags Flags, optional flags that can vary per operation.
 * \param cb_fn Callback function which will be called when the request is complete.
 * \param cb_arg Opaque value which will be passed back as the arg parameter in
@@ -254,8 +255,9 @@ int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, void *src,
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_submit_decompress(struct spdk_io_channel *ch, void *dst, void *src,
				 uint64_t nbytes_dst, uint64_t nbytes_src, int flags,
int spdk_accel_submit_decompress(struct spdk_io_channel *ch, struct iovec *dst_iovs,
				 size_t dst_iovcnt, struct iovec *src_iovs,
				 size_t src_iovcnt, int flags,
				 spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
+3 −3
Original line number Diff line number Diff line
@@ -265,8 +265,8 @@ int spdk_idxd_submit_copy_crc32c(struct spdk_idxd_io_channel *chan,
 * by writing to the proper device portal.
 *
 * \param chan IDXD channel to submit request.
 * \param diov Destination iovec. diov with diovcnt must be large enough to hold compressed data.
 * \param diovcnt Number of elements in diov for decompress buffer.
 * \param dst Destination to write the compressed data to.
 * \param nbytes Length in bytes. The dst buffer should be large enough to hold the compressed data.
 * \param siov Source iovec
 * \param siovcnt Number of elements in siov
 * \param output_size The size of the compressed data
@@ -278,7 +278,7 @@ int spdk_idxd_submit_copy_crc32c(struct spdk_idxd_io_channel *chan,
 * \return 0 on success, negative errno on failure.
 */
int spdk_idxd_submit_compress(struct spdk_idxd_io_channel *chan,
			      struct iovec *diov, uint32_t diovcnt,
			      void *dst, uint64_t nbytes,
			      struct iovec *siov, uint32_t siovcnt, uint32_t *output_size,
			      int flags, spdk_idxd_req_cb cb_fn, void *cb_arg);

+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ struct spdk_accel_task {
		void				*src;
	};
	union {
		struct {
			struct iovec		*iovs; /* iovs passed by the caller */
			uint32_t		iovcnt; /* iovcnt passed by the caller */
		} d;
		void			*dst;
		void			*src2;
	};
+18 −11
Original line number Diff line number Diff line
@@ -388,25 +388,31 @@ spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst,
}

int
spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, void *src, uint64_t nbytes_dst,
			   uint64_t nbytes_src, uint32_t *output_size, int flags,
spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, uint64_t nbytes,
			   struct iovec *src_iovs, size_t src_iovcnt, uint32_t *output_size, int flags,
			   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;
	struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COMPRESS];
	struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COMPRESS];
	size_t i, src_len = 0;

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

	for (i = 0; i < src_iovcnt; i++) {
		src_len +=  src_iovs[i].iov_len;
	}

	accel_task->nbytes = src_len;
	accel_task->output_size = output_size;
	accel_task->src = src;
	accel_task->s.iovs = src_iovs;
	accel_task->s.iovcnt = src_iovcnt;
	accel_task->dst = dst;
	accel_task->nbytes = nbytes_src;
	accel_task->nbytes_dst = nbytes_dst;
	accel_task->nbytes_dst = nbytes;
	accel_task->flags = flags;
	accel_task->op_code = ACCEL_OPC_COMPRESS;

@@ -416,8 +422,9 @@ spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, void *src, uin
}

int
spdk_accel_submit_decompress(struct spdk_io_channel *ch, void *dst, void *src, uint64_t nbytes_dst,
			     uint64_t nbytes_src, int flags, spdk_accel_completion_cb cb_fn, void *cb_arg)
spdk_accel_submit_decompress(struct spdk_io_channel *ch, struct iovec *dst_iovs,
			     size_t dst_iovcnt, struct iovec *src_iovs, size_t src_iovcnt,
			     int flags, 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;
@@ -429,10 +436,10 @@ spdk_accel_submit_decompress(struct spdk_io_channel *ch, void *dst, void *src, u
		return -ENOMEM;
	}

	accel_task->src = src;
	accel_task->dst = dst;
	accel_task->nbytes = nbytes_src;
	accel_task->nbytes_dst = nbytes_dst;
	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->flags = flags;
	accel_task->op_code = ACCEL_OPC_DECOMPRESS;

Loading