Commit 8cee297c authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

lib/idxd: add batching support for compare command



Also one small bug fix w/compare in accel_perf as a result
of changes made in accel_perf sicne base compare was added.

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


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 8d033472
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -296,6 +296,8 @@ _accel_done(void *arg1)
				worker->xfer_failed++;
			}
			break;
		case ACCEL_COMPARE:
			break;
		default:
			assert(false);
			break;
+22 −1
Original line number Diff line number Diff line
@@ -255,7 +255,28 @@ int spdk_idxd_submit_dualcast(struct spdk_idxd_io_channel *chan,
			      spdk_idxd_req_cb cb_fn, void *cb_arg);

/**
 * Build and submit an idxd memory compare request.
 * Synchronous call to prepare a compare request into a previously initialized batch
 *  created with spdk_idxd_batch_create(). The callback will be called when the compare
 *  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 src1 First source to compare.
 * \param src2 Second source to compare.
 * \param nbytes Number of bytes to compare.
 * \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_compare(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
				 void *src1, void *src2, uint64_t nbytes, spdk_idxd_req_cb cb_fn,
				 void *cb_arg);

/**
 * Build and submit a memory compare request.
 *
 * This function will build the compare descriptor and then immediately submit
 * by writing to the proper device portal.
+24 −0
Original line number Diff line number Diff line
@@ -1072,12 +1072,14 @@ spdk_idxd_batch_prep_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch
			    spdk_idxd_req_cb cb_fn, void *cb_arg)
{
	struct idxd_hw_desc *desc;

	/* Common prep. */
	desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);
	if (desc == NULL) {
		return -EINVAL;
	}

	/* Command specific. */
	desc->opcode = IDXD_OPCODE_CRC32C_GEN;
	desc->dst_addr = (uintptr_t)dst;
	desc->src_addr = (uintptr_t)src;
@@ -1088,6 +1090,28 @@ spdk_idxd_batch_prep_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch
	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,
			     void *cb_arg)
{
	struct idxd_hw_desc *desc;

	/* Common prep. */
	desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);
	if (desc == NULL) {
		return -EINVAL;
	}

	/* Command specific. */
	desc->opcode = IDXD_OPCODE_COMPARE;
	desc->src_addr = (uintptr_t)src1;
	desc->src2_addr = (uintptr_t)src2;
	desc->xfer_size = nbytes;

	return 0;
}

static void
_dump_error_reg(struct spdk_idxd_io_channel *chan)
{
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
	spdk_idxd_batch_prep_dualcast;
	spdk_idxd_batch_prep_fill;
	spdk_idxd_batch_prep_crc32c;
	spdk_idxd_batch_prep_compare;
	spdk_idxd_batch_submit;
	spdk_idxd_batch_create;
	spdk_idxd_batch_get_max;
+15 −0
Original line number Diff line number Diff line
@@ -541,6 +541,20 @@ idxd_batch_prep_crc32c(void *cb_arg, struct spdk_io_channel *ch, struct spdk_acc
					   idxd_task);
}

static int
idxd_batch_prep_compare(void *cb_arg, struct spdk_io_channel *ch, struct spdk_accel_batch *_batch,
			void *src1, void *src2, uint64_t nbytes, spdk_accel_completion_cb cb)
{
	struct idxd_task *idxd_task = (struct idxd_task *)cb_arg;
	struct idxd_io_channel *chan = spdk_io_channel_get_ctx(ch);
	struct idxd_batch *batch = (struct idxd_batch *)_batch;

	idxd_task->cb = cb;

	return spdk_idxd_batch_prep_compare(chan->chan, batch, src1, src2, nbytes, idxd_done,
					    idxd_task);
}

static struct spdk_accel_engine idxd_accel_engine = {
	.get_capabilities	= idxd_get_capabilities,
	.copy			= idxd_submit_copy,
@@ -550,6 +564,7 @@ static struct spdk_accel_engine idxd_accel_engine = {
	.batch_prep_fill	= idxd_batch_prep_fill,
	.batch_prep_dualcast	= idxd_batch_prep_dualcast,
	.batch_prep_crc32c	= idxd_batch_prep_crc32c,
	.batch_prep_compare	= idxd_batch_prep_compare,
	.batch_submit		= idxd_batch_submit,
	.dualcast		= idxd_submit_dualcast,
	.compare		= idxd_submit_compare,