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

accel: add API to cancel a batch sequence



Added to the framework as well as all 3 engines.  Needed by apps
in the event that they have to fail following the creation of a
batch, allows them to tell the framework to forget about the batch
as they have no intent to send it.

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


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 751e2812
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -166,6 +166,17 @@ struct spdk_accel_batch *spdk_accel_batch_create(struct spdk_io_channel *ch);
int spdk_accel_batch_submit(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
			    spdk_accel_completion_cb cb_fn, void *cb_arg);

/**
 * Synchronous call to cancel a batch sequence. In some cases prepared commands will be
 * processed if they cannot be cancelled.
 *
 * \param ch I/O channel associated with this call.
 * \param batch Handle provided when the batch was started with spdk_accel_batch_create().
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_accel_batch_cancel(struct spdk_io_channel *ch, struct spdk_accel_batch *batch);

/**
 * Synchronous call to prepare a copy request into a previously initialized batch
 *  created with spdk_accel_batch_create(). The callback will be called when the copy
+10 −0
Original line number Diff line number Diff line
@@ -172,6 +172,16 @@ struct idxd_batch *spdk_idxd_batch_create(struct spdk_idxd_io_channel *chan);
int spdk_idxd_batch_submit(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
			   spdk_idxd_req_cb cb_fn, void *cb_arg);

/**
 * Cancel a batch sequence.
 *
 * \param chan IDXD channel to submit request.
 * \param batch Handle provided when the batch was started with spdk_idxd_batch_create().
 *
 * \return 0 on success, negative errno on failure.
 */
int spdk_idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch);

/**
 * Synchronous call to prepare a copy request into a previously initialized batch
 *  created with spdk_idxd_batch_create(). The callback will be called when the copy
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ struct spdk_accel_engine {
				 spdk_accel_completion_cb cb_fn, void *cb_arg);
	int (*batch_submit)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
			    spdk_accel_completion_cb cb_fn, void *cb_arg);
	int (*batch_cancel)(struct spdk_io_channel *ch, struct spdk_accel_batch *batch);
	int (*compare)(struct spdk_io_channel *ch, void *src1, void *src2,
		       uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
	int (*fill)(struct spdk_io_channel *ch, void *dst, uint8_t fill,
+33 −0
Original line number Diff line number Diff line
@@ -231,6 +231,17 @@ spdk_accel_batch_get_max(struct spdk_io_channel *ch)
	return accel_ch->engine->batch_get_max();
}

/* Accel framework public API for for when an app is unable to complete a batch sequence,
 * it cancels with this API.
 */
int
spdk_accel_batch_cancel(struct spdk_io_channel *ch, struct spdk_accel_batch *batch)
{
	struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);

	return accel_ch->engine->batch_cancel(accel_ch->ch, batch);
}

/* Accel framework public API for batch prep_copy function. All engines are
 * required to implement this API.
 */
@@ -791,6 +802,27 @@ sw_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch *
	return 0;
}


static int
sw_accel_batch_cancel(struct spdk_io_channel *ch, struct spdk_accel_batch *batch)
{
	struct sw_accel_op *op;
	struct sw_accel_io_channel *sw_ch = spdk_io_channel_get_ctx(ch);

	if ((struct spdk_accel_batch *)&sw_ch->batch != batch) {
		SPDK_ERRLOG("Invalid batch\n");
		return -EINVAL;
	}

	/* Cancel the batch items by moving them back to the op_pool. */
	while ((op = TAILQ_FIRST(&sw_ch->batch))) {
		TAILQ_REMOVE(&sw_ch->batch, op, link);
		TAILQ_INSERT_TAIL(&sw_ch->op_pool, op, link);
	}

	return 0;
}

static int
sw_accel_batch_submit(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
		      spdk_accel_completion_cb cb_fn, void *cb_arg)
@@ -927,6 +959,7 @@ static struct spdk_accel_engine sw_accel_engine = {
	.dualcast		= sw_accel_submit_dualcast,
	.batch_get_max		= sw_accel_batch_get_max,
	.batch_create		= sw_accel_batch_start,
	.batch_cancel		= sw_accel_batch_cancel,
	.batch_prep_copy	= sw_accel_batch_prep_copy,
	.batch_prep_dualcast	= sw_accel_batch_prep_dualcast,
	.batch_prep_compare	= sw_accel_batch_prep_compare,
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
	spdk_accel_batch_prep_fill;
	spdk_accel_batch_prep_crc32c;
	spdk_accel_batch_submit;
	spdk_accel_batch_cancel;
	spdk_accel_submit_copy;
	spdk_accel_submit_dualcast;
	spdk_accel_submit_compare;
Loading