Commit 90c56d96 authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

lib/accel: Two crc32c APIs are added to provide the chained crc32 operation support



This patch provides two new accelerated crc32c function interface.
And the next patch will be used to add the real support of chained crc32c feature.

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: I3f8dd55c3da636e29e5fb02fc229b51f05653cd6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6456


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 5ddf6f76
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -12,6 +12,12 @@ Only one OCSSD bdev can be created for one OCSSD namespace.
Added spdk_pci_device_allow API to allow applications to add PCI addresses to
the allowed list after the application has started.

### accel

Two new accelerated crc32 functions 'spdk_accel_submit_crc32cv' and
'spdk_accel_batch_prep_crc32cv' are added in order to provide the
chained accelerated CRC32 computation support.

### nvme

Added `spdk_nvme_qpair_get_optimal_poll_group` function and `qpair_get_optimal_poll_group`
+8 −5
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ struct display_info {

struct ap_task {
	void			*src;
	struct iovec		iov;
	void			*dst;
	void			*dst2;
	struct worker_thread	*worker;
@@ -243,6 +244,8 @@ _get_task_data_bufs(struct ap_task *task)
		return -ENOMEM;
	}
	memset(task->src, DATA_PATTERN, g_xfer_size_bytes);
	task->iov.iov_base = task->src;
	task->iov.iov_len = g_xfer_size_bytes;

	task->dst = spdk_dma_zmalloc(g_xfer_size_bytes, align, NULL);
	if (task->dst == NULL) {
@@ -312,9 +315,9 @@ _submit_single(struct worker_thread *worker, struct ap_task *task)
					    g_xfer_size_bytes, accel_done, task);
		break;
	case ACCEL_CRC32C:
		rc = spdk_accel_submit_crc32c(worker->ch, (uint32_t *)task->dst,
					      task->src, g_crc32c_seed,
					      g_xfer_size_bytes, accel_done, task);
		rc = spdk_accel_submit_crc32cv(worker->ch, (uint32_t *)task->dst,
					       &task->iov, 1, g_crc32c_seed,
					       accel_done, task);
		break;
	case ACCEL_COMPARE:
		random_num = rand() % 100;
@@ -372,8 +375,8 @@ _batch_prep_cmd(struct worker_thread *worker, struct ap_task *task,
						g_xfer_size_bytes, accel_done, task);
		break;
	case ACCEL_CRC32C:
		rc = spdk_accel_batch_prep_crc32c(worker->ch, batch, (uint32_t *)task->dst,
						  task->src, g_crc32c_seed, g_xfer_size_bytes, accel_done, task);
		rc = spdk_accel_batch_prep_crc32cv(worker->ch, batch, (uint32_t *)task->dst,
						   &task->iov, 1, g_crc32c_seed, accel_done, task);
		break;
	default:
		assert(false);
+39 −0
Original line number Diff line number Diff line
@@ -315,6 +315,27 @@ int spdk_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_b
				 uint32_t *dst, void *src, uint32_t seed, uint64_t nbytes,
				 spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Synchronous call to prepare a chained crc32c request into a previously initialized batch
 *  created with spdk_accel_batch_create(). The callback will be called when the crc32c
 *  completes after the batch has been submitted by an asynchronous call to
 *  spdk_accel_batch_submit().
 *
 * \param ch I/O channel associated with this call.
 * \param batch Handle provided when the batch was started with spdk_accel_batch_create().
 * \param dst Destination to write the CRC-32C to.
 * \param iovs The io vector array which stores the src data and len.
 * \param iovcnt The size of the iov.
 * \param seed Four byte seed value.
 * \param cb_fn Called when this operation completes.
 * \param cb_arg Callback argument.
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_batch_prep_crc32cv(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
				  uint32_t *dst, struct iovec *iovs, uint32_t iovcnt, uint32_t seed,
				  spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a CRC-32C calculation request.
 *
@@ -333,6 +354,24 @@ int spdk_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_b
int spdk_accel_submit_crc32c(struct spdk_io_channel *ch, uint32_t *dst, void *src, uint32_t seed,
			     uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Submit a chained CRC-32C calculation request.
 *
 * This operation will calculate the 4 byte CRC32-C for the given data.
 *
 * \param ch I/O channel associated with this call.
 * \param dst Destination to write the CRC-32C to.
 * \param iovs The io vector array which stores the src data and len.
 * \param iovcnt The size of the iov.
 * \param seed Four byte seed value.
 * \param cb_fn Called when this CRC-32C operation completes.
 * \param cb_arg Callback argument.
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *dst, struct iovec *iovs,
			      uint32_t iovcnt, uint32_t seed, spdk_accel_completion_cb cb_fn, void *cb_arg);

struct spdk_json_write_ctx;

/**
+32 −0
Original line number Diff line number Diff line
@@ -321,6 +321,21 @@ spdk_accel_submit_crc32c(struct spdk_io_channel *ch, uint32_t *dst, void *src, u
	}
}

/* Accel framework public API for chained CRC-32C function */
int
spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *dst, struct iovec *iov,
			  uint32_t iov_cnt, uint32_t seed, spdk_accel_completion_cb cb_fn, void *cb_arg)
{
	if (iov == NULL) {
		SPDK_ERRLOG("iov should not be NULL");
		return -EINVAL;
	}

	assert(iov_cnt == 1);

	return spdk_accel_submit_crc32c(ch, dst, iov[0].iov_base, seed, iov[0].iov_len, cb_fn, cb_arg);
}

/* Accel framework public API for getting max operations for a batch. */
uint32_t
spdk_accel_batch_get_max(struct spdk_io_channel *ch)
@@ -472,6 +487,23 @@ spdk_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch
	return 0;
}

int
spdk_accel_batch_prep_crc32cv(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
			      uint32_t *dst, struct iovec *iovs, uint32_t iov_cnt, uint32_t seed,
			      spdk_accel_completion_cb cb_fn, void *cb_arg)
{
	if (iovs == NULL) {
		SPDK_ERRLOG("iovs should not be NULL\n");
		return -EINVAL;
	}

	assert(iov_cnt == 1);

	return spdk_accel_batch_prep_crc32c(ch, batch, dst, iovs[0].iov_base, seed, iovs[0].iov_len, cb_fn,
					    cb_arg);

}

/* Accel framework public API for batch_create function. */
struct spdk_accel_batch *
spdk_accel_batch_create(struct spdk_io_channel *ch)
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
	spdk_accel_batch_prep_compare;
	spdk_accel_batch_prep_fill;
	spdk_accel_batch_prep_crc32c;
	spdk_accel_batch_prep_crc32cv;
	spdk_accel_batch_submit;
	spdk_accel_batch_cancel;
	spdk_accel_submit_copy;
@@ -21,6 +22,7 @@
	spdk_accel_submit_compare;
	spdk_accel_submit_fill;
	spdk_accel_submit_crc32c;
	spdk_accel_submit_crc32cv;
	spdk_accel_write_config_json;

	# functions needed by modules
Loading