From 1076008e63830a8f48faa3c251a7099ebddb3a47 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 1 Jun 2021 14:56:44 -0400 Subject: [PATCH] lib/idxd: add support for new opcode to low level library (copy + CRC) Upcoming patches will add support to the accel fw, the idxd engine and the accel_perf tool. Also following will come vectored support and batch versions. Signed-off-by: paul luse Change-Id: Ie0fbd4b8da9f727426000898c0b511587adac65b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8139 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ziye Yang Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk --- CHANGELOG.md | 2 ++ include/spdk/idxd.h | 22 ++++++++++++++++++++++ lib/idxd/idxd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/idxd/spdk_idxd.map | 1 + 4 files changed, 67 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f542624c..3876bec4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Updated DPDK submodule to DPDK 21.02. Remove the probe_cb parameter in spdk_idxd_probe function. And remove the definition of spdk_idxd_probe_cb function pointer. It should be implemented in idxd_user.c. +Added API `spdk_idxd_submit_copy_crc32c` to perform a CRC32C while copying data. + ### util `spdk_crc32c_iov_update` function was added to support calculating the crc32c of the diff --git a/include/spdk/idxd.h b/include/spdk/idxd.h index 4ff0e05d8..b622aad93 100644 --- a/include/spdk/idxd.h +++ b/include/spdk/idxd.h @@ -374,6 +374,28 @@ int spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan, uint32_t *dst, vo uint32_t seed, uint64_t nbytes, spdk_idxd_req_cb cb_fn, void *cb_arg); +/** + * Build and submit a copy combined with CRC32-C request. + * + * This function will build the descriptor for copy plus CRC32-C and then immediately + * submit by writing to the proper device portal. + * + * \param chan IDXD channel to submit request. + * \param dst Destination virtual address. + * \param src Source virtual address. + * \param crc_dst Resulting calculation. + * \param seed Four byte CRC-32C seed value. + * \param nbytes Number of bytes to calculate on. + * \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 cb_arg parameter + * in the completion callback. + * + * \return 0 on success, negative errno on failure. + */ +int spdk_idxd_submit_copy_crc32c(struct spdk_idxd_io_channel *chan, void *dst, void *src, + uint32_t *crc_dst, uint32_t seed, uint64_t nbytes, + spdk_idxd_req_cb cb_fn, void *cb_arg); + /** * Check for completed requests on an IDXD channel. * diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index 7af6564ad..f510be21a 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -637,6 +637,47 @@ spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan, uint32_t *dst, void * return 0; } +int +spdk_idxd_submit_copy_crc32c(struct spdk_idxd_io_channel *chan, void *dst, void *src, + uint32_t *crc_dst, uint32_t seed, uint64_t nbytes, + spdk_idxd_req_cb cb_fn, void *cb_arg) +{ + struct idxd_hw_desc *desc; + struct idxd_comp *comp; + uint64_t src_addr, dst_addr; + int rc; + + /* Common prep. */ + rc = _idxd_prep_command(chan, cb_fn, cb_arg, &desc, &comp); + if (rc) { + return rc; + } + + rc = _vtophys(src, &src_addr, nbytes); + if (rc) { + return rc; + } + + rc = _vtophys(dst, &dst_addr, nbytes); + if (rc) { + return rc; + } + + /* Command specific. */ + desc->opcode = IDXD_OPCODE_COPY_CRC; + desc->dst_addr = dst_addr; + desc->src_addr = src_addr; + desc->flags &= IDXD_CLEAR_CRC_FLAGS; + desc->crc32c.seed = seed; + desc->xfer_size = nbytes; + comp->crc_dst = crc_dst; + + /* Submit operation. */ + movdir64b(chan->portal, desc); + + return 0; +} + uint32_t spdk_idxd_batch_get_max(void) { @@ -1046,6 +1087,7 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) SPDK_DEBUGLOG(idxd, "Complete batch %p\n", comp_ctx->batch); break; case IDXD_OPCODE_CRC32C_GEN: + case IDXD_OPCODE_COPY_CRC: *(uint32_t *)comp_ctx->crc_dst = comp_ctx->hw.crc32c_val; *(uint32_t *)comp_ctx->crc_dst ^= ~0; break; diff --git a/lib/idxd/spdk_idxd.map b/lib/idxd/spdk_idxd.map index 4f9b7c555..1f20f8986 100644 --- a/lib/idxd/spdk_idxd.map +++ b/lib/idxd/spdk_idxd.map @@ -19,6 +19,7 @@ spdk_idxd_set_config; spdk_idxd_submit_compare; spdk_idxd_submit_crc32c; + spdk_idxd_submit_copy_crc32c; spdk_idxd_submit_copy; spdk_idxd_submit_dualcast; spdk_idxd_submit_fill;