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: Ziye 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: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
5ddf6f7671
commit
90c56d965d
@ -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`
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -873,11 +873,13 @@ nvmf_tcp_qpair_write_pdu(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
pdu->cb_arg = cb_arg;
|
||||
pdu->qpair = tqpair;
|
||||
|
||||
pdu->iov[0].iov_base = &pdu->hdr.raw;
|
||||
pdu->iov[0].iov_len = hlen;
|
||||
|
||||
/* Header Digest */
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && tqpair->host_hdgst_enable) {
|
||||
spdk_accel_submit_crc32c(tqpair->accel_channel, &pdu->header_digest_crc32,
|
||||
&pdu->hdr.raw, 0,
|
||||
hlen, header_crc32_accel_done, pdu);
|
||||
spdk_accel_submit_crc32cv(tqpair->accel_channel, &pdu->header_digest_crc32,
|
||||
pdu->iov, 1, 0, header_crc32_accel_done, pdu);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,10 +227,10 @@ DEFINE_STUB(spdk_accel_engine_get_io_channel,
|
||||
(void),
|
||||
NULL);
|
||||
|
||||
DEFINE_STUB(spdk_accel_submit_crc32c,
|
||||
DEFINE_STUB(spdk_accel_submit_crc32cv,
|
||||
int,
|
||||
(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),
|
||||
(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),
|
||||
0);
|
||||
|
||||
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_nvme_passthru_admin,
|
||||
|
Loading…
Reference in New Issue
Block a user