From 91f3063b1400b53905090cc2e59755ec825a2e83 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 20 Dec 2022 07:36:43 -0700 Subject: [PATCH] lib/accel: add output_size to decompress API We had it for compress but simply didn't think of a use case for decompress. During the develpoment of the compressdev accel_fw module it was discovered that compressdev does indeed provide the uncompressed length on completion of decompress and the reducelib uses it. So, add it here. Signed-off-by: paul luse Change-Id: I2f6a8bbbe3ef8ebe0b50d6434845f405afa7d37d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16035 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- examples/accel/perf/accel_perf.c | 2 +- include/spdk/accel.h | 5 +++-- lib/accel/accel.c | 6 +++++- lib/accel/accel_sw.c | 6 ++++++ module/accel/dpdk_compressdev/accel_dpdk_compressdev.c | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/accel/perf/accel_perf.c b/examples/accel/perf/accel_perf.c index fadb5a841..6faea1dde 100644 --- a/examples/accel/perf/accel_perf.c +++ b/examples/accel/perf/accel_perf.c @@ -457,7 +457,7 @@ _submit_single(struct worker_thread *worker, struct ap_task *task) task->src_iovs = task->cur_seg->compressed_iovs; task->src_iovcnt = task->cur_seg->compressed_iovcnt; rc = spdk_accel_submit_decompress(worker->ch, task->dst_iovs, task->dst_iovcnt, task->src_iovs, - task->src_iovcnt, flags, accel_done, task); + task->src_iovcnt, NULL, flags, accel_done, task); break; default: assert(false); diff --git a/include/spdk/accel.h b/include/spdk/accel.h index 052e4afb1..dd90c6465 100644 --- a/include/spdk/accel.h +++ b/include/spdk/accel.h @@ -262,7 +262,7 @@ int spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst, struct * \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 output_size The size of the compressed data (may be NULL if not desired) * \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 @@ -285,6 +285,7 @@ int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, * \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 output_size The size of the compressed data (may be NULL if not desired) * \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 @@ -294,7 +295,7 @@ int spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, */ 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, + size_t src_iovcnt, uint32_t *output_size, int flags, spdk_accel_completion_cb cb_fn, void *cb_arg); /** Object grouping multiple accel operations to be executed at the same point in time */ diff --git a/lib/accel/accel.c b/lib/accel/accel.c index e458d1d5f..e2da91a15 100644 --- a/lib/accel/accel.c +++ b/lib/accel/accel.c @@ -597,7 +597,8 @@ spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, uint64_t nbyte 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) + 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; @@ -609,6 +610,7 @@ spdk_accel_submit_decompress(struct spdk_io_channel *ch, struct iovec *dst_iovs, return -ENOMEM; } + accel_task->output_size = output_size; accel_task->s.iovs = src_iovs; accel_task->s.iovcnt = src_iovcnt; accel_task->d.iovs = dst_iovs; @@ -902,6 +904,8 @@ spdk_accel_append_decompress(struct spdk_accel_sequence **pseq, struct spdk_io_c return -ENOMEM; } + /* TODO: support output_size for chaining */ + task->output_size = NULL; task->dst_domain = dst_domain; task->dst_domain_ctx = dst_domain_ctx; task->d.iovs = dst_iovs; diff --git a/lib/accel/accel_sw.c b/lib/accel/accel_sw.c index 0f8df09e8..d11ce64b5 100644 --- a/lib/accel/accel_sw.c +++ b/lib/accel/accel_sw.c @@ -358,6 +358,12 @@ _sw_accel_decompress(struct sw_accel_io_channel *sw_ch, struct spdk_accel_task * } while (sw_ch->state.block_state < ISAL_BLOCK_FINISH); assert(sw_ch->state.avail_in == 0); + /* Get our total output size */ + if (accel_task->output_size != NULL) { + assert(sw_ch->state.total_out > 0); + *accel_task->output_size = sw_ch->state.total_out; + } + return rc; #else SPDK_ERRLOG("ISAL option is required to use software decompression.\n"); diff --git a/module/accel/dpdk_compressdev/accel_dpdk_compressdev.c b/module/accel/dpdk_compressdev/accel_dpdk_compressdev.c index 9e48fb9b9..53335b5c6 100644 --- a/module/accel/dpdk_compressdev/accel_dpdk_compressdev.c +++ b/module/accel/dpdk_compressdev/accel_dpdk_compressdev.c @@ -584,7 +584,7 @@ comp_dev_poller(void *args) status = deq_ops[i]->status; if (spdk_likely(status == RTE_COMP_OP_STATUS_SUCCESS)) { - if (task->op_code == ACCEL_OPC_COMPRESS) { + if (task->output_size != NULL) { *task->output_size = deq_ops[i]->produced; } } else {