Commit cfd37e28 authored by paul luse's avatar paul luse Committed by Tomasz Zawadzki
Browse files

lib/idxd: add support for batching copy + crc32c



Upcoming patches will add accel_fw support for batching this cmd
and then vectored versions later along with accel_perf to exercise
them.

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


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent a6c5480f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ 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.

Added API `spdk_idxd_batch_prep_copy_crc32c` to prepare a batch operation to perform
a CRC32C while copying data.

### util

`spdk_crc32c_iov_update` function was added to support calculating the crc32c of the
+23 −0
Original line number Diff line number Diff line
@@ -374,6 +374,29 @@ 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);

/**
 * Synchronous call to prepare a copy combined with crc32c request into a previously
 *  initialized batch created with spdk_idxd_batch_create(). The callback will be called
 *  when the copy + crc32c completes after the batch has been submitted by an asynchronous
 *  call to spdk_idxd_batch_submit().
 *
 * \param chan IDXD channel to submit request.
 * \param batch Handle provided when the batch was started with spdk_idxd_batch_create().
 * \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 arg parameter in
 * the completion callback.
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_idxd_batch_prep_copy_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
				     void *dst, void *src, uint32_t *crc_dst, 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.
 *
+38 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,44 @@ spdk_idxd_batch_prep_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch
	return 0;
}

int
spdk_idxd_batch_prep_copy_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
				 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_batch_cmd(chan, cb_fn, cb_arg, batch, &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;

	return 0;
}

int
spdk_idxd_batch_prep_compare(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
			     void *src1, void *src2, uint64_t nbytes, spdk_idxd_req_cb cb_fn,
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
	spdk_idxd_batch_prep_dualcast;
	spdk_idxd_batch_prep_fill;
	spdk_idxd_batch_prep_crc32c;
	spdk_idxd_batch_prep_copy_crc32c;
	spdk_idxd_batch_prep_compare;
	spdk_idxd_batch_submit;
	spdk_idxd_batch_create;