lib/accel: remove batching from the framework and plug-in modules
Batching will be made available for DSA specifically through the new idxd_perf tool. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: Ic51d9ad3692074805b1ffa705cea8be35737c778 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9846 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
689d50c037
commit
dba1727dd5
@ -2,6 +2,11 @@
|
||||
|
||||
## v22.01: (Upcoming Release)
|
||||
|
||||
### accel
|
||||
|
||||
The batching capability was removed. Batching is now considered an implementation
|
||||
detail of the low level drivers.
|
||||
|
||||
### nvme
|
||||
|
||||
API `spdk_nvme_trtype_is_fabrics` was added to return existing transport type
|
||||
|
@ -122,91 +122,6 @@ uint64_t spdk_accel_get_capabilities(struct spdk_io_channel *ch);
|
||||
int spdk_accel_submit_copy(struct spdk_io_channel *ch, void *dst, void *src, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to get batch size. This is the maximum number of
|
||||
* descriptors that a batch can contain. Once this limit is reached the batch
|
||||
* should be processed with spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
*
|
||||
* \return max number of descriptors per batch.
|
||||
*/
|
||||
uint32_t spdk_accel_batch_get_max(struct spdk_io_channel *ch);
|
||||
|
||||
/**
|
||||
* Synchronous call to create a batch sequence.
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
*
|
||||
* \return handle to use for subsequent batch requests, NULL on failure.
|
||||
*/
|
||||
struct spdk_accel_batch *spdk_accel_batch_create(struct spdk_io_channel *ch);
|
||||
|
||||
/**
|
||||
* Asynchronous call to submit a batch sequence.
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
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
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param dst Destination to copy to.
|
||||
* \param src Source to copy from.
|
||||
* \param nbytes Length in bytes to copy.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_copy(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst, void *src, uint64_t nbytes, spdk_accel_completion_cb cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a dualcast request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the dualcast
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param dst1 First destination to copy to (must be 4K aligned).
|
||||
* \param dst2 Second destination to copy to (must be 4K aligned).
|
||||
* \param src Source to copy from.
|
||||
* \param nbytes Length in bytes to copy.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_dualcast(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst1, void *dst2, void *src, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Submit a dual cast copy request.
|
||||
*
|
||||
@ -223,26 +138,6 @@ int spdk_accel_batch_prep_dualcast(struct spdk_io_channel *ch, struct spdk_accel
|
||||
int spdk_accel_submit_dualcast(struct spdk_io_channel *ch, void *dst1, void *dst2, void *src,
|
||||
uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a compare request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the compare
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param src1 First location to perform compare on.
|
||||
* \param src2 Second location to perform compare on.
|
||||
* \param nbytes Length in bytes to compare.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_compare(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *src1, void *src2, uint64_t nbytes, spdk_accel_completion_cb cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
/**
|
||||
* Submit a compare request.
|
||||
*
|
||||
@ -258,26 +153,6 @@ int spdk_accel_batch_prep_compare(struct spdk_io_channel *ch, struct spdk_accel_
|
||||
int spdk_accel_submit_compare(struct spdk_io_channel *ch, void *src1, void *src2, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a fill request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the fill
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param dst Destination to fill.
|
||||
* \param fill Constant byte to fill to the destination.
|
||||
* \param nbytes Length in bytes to fill.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_fill(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst, uint8_t fill, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Submit a fill request.
|
||||
*
|
||||
@ -295,70 +170,6 @@ int spdk_accel_batch_prep_fill(struct spdk_io_channel *ch, struct spdk_accel_bat
|
||||
int spdk_accel_submit_fill(struct spdk_io_channel *ch, void *dst, uint8_t fill, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a crc32c request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the crc32c
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param crc_dst Destination to write the CRC-32C to.
|
||||
* \param src The source address for the data.
|
||||
* \param seed Four byte seed value.
|
||||
* \param nbytes Length in bytes.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
uint32_t *crc_dst, void *src, uint32_t seed, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a chained crc32c request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the crc32c
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param crc_dst Destination to write the CRC-32C to.
|
||||
* \param iovs The io vector array which stores the src data and len.
|
||||
* \param iovcnt The size of the iov.
|
||||
* \param seed Four byte seed value.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_crc32cv(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
uint32_t *crc_dst, struct iovec *iovs, uint32_t iovcnt, uint32_t seed,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Synchronous call to prepare a copy + crc32c request into a previously initialized batch
|
||||
* created with spdk_accel_batch_create(). The callback will be called when the operation
|
||||
* completes after the batch has been submitted by an asynchronous call to
|
||||
* spdk_accel_batch_submit().
|
||||
*
|
||||
* \param ch I/O channel associated with this call.
|
||||
* \param batch Handle provided when the batch was started with spdk_accel_batch_create().
|
||||
* \param dst Destination to write the data to.
|
||||
* \param src The source address for the data.
|
||||
* \param crc_dst Destination to write the CRC-32C to.
|
||||
* \param seed Four byte seed value.
|
||||
* \param nbytes Length in bytes.
|
||||
* \param cb_fn Called when this operation completes.
|
||||
* \param cb_arg Callback argument.
|
||||
*
|
||||
* \return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int spdk_accel_batch_prep_copy_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst, void *src, uint32_t *crc_dst, uint32_t seed, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Submit a CRC-32C calculation request.
|
||||
*
|
||||
|
@ -49,9 +49,6 @@ struct accel_io_channel {
|
||||
struct spdk_io_channel *sw_engine_ch;
|
||||
void *task_pool_base;
|
||||
TAILQ_HEAD(, spdk_accel_task) task_pool;
|
||||
void *batch_pool_base;
|
||||
TAILQ_HEAD(, spdk_accel_batch) batch_pool;
|
||||
TAILQ_HEAD(, spdk_accel_batch) batches;
|
||||
};
|
||||
|
||||
struct sw_accel_io_channel {
|
||||
@ -59,19 +56,6 @@ struct sw_accel_io_channel {
|
||||
TAILQ_HEAD(, spdk_accel_task) tasks_to_complete;
|
||||
};
|
||||
|
||||
struct spdk_accel_batch {
|
||||
/* Lists of commands in the batch. */
|
||||
TAILQ_HEAD(, spdk_accel_task) hw_tasks;
|
||||
TAILQ_HEAD(, spdk_accel_task) sw_tasks;
|
||||
/* Specific to the batch task itself. */
|
||||
int status;
|
||||
uint32_t count;
|
||||
spdk_accel_completion_cb cb_fn;
|
||||
void *cb_arg;
|
||||
struct accel_io_channel *accel_ch;
|
||||
TAILQ_ENTRY(spdk_accel_batch) link;
|
||||
};
|
||||
|
||||
enum accel_opcode {
|
||||
ACCEL_OPCODE_MEMMOVE = 0,
|
||||
ACCEL_OPCODE_MEMFILL = 1,
|
||||
@ -83,18 +67,17 @@ enum accel_opcode {
|
||||
};
|
||||
|
||||
struct spdk_accel_task {
|
||||
struct accel_io_channel *accel_ch;
|
||||
struct spdk_accel_batch *batch;
|
||||
spdk_accel_completion_cb cb_fn;
|
||||
void *cb_arg;
|
||||
struct accel_io_channel *accel_ch;
|
||||
spdk_accel_completion_cb cb_fn;
|
||||
void *cb_arg;
|
||||
struct {
|
||||
spdk_accel_completion_cb cb_fn;
|
||||
void *cb_arg;
|
||||
} chained;
|
||||
union {
|
||||
struct {
|
||||
struct iovec *iovs; /* iovs passed by the caller */
|
||||
uint32_t iovcnt; /* iovcnt passed by the caller */
|
||||
struct iovec *iovs; /* iovs passed by the caller */
|
||||
uint32_t iovcnt; /* iovcnt passed by the caller */
|
||||
} v;
|
||||
void *src;
|
||||
};
|
||||
@ -118,7 +101,6 @@ struct spdk_accel_engine {
|
||||
uint64_t capabilities;
|
||||
uint64_t (*get_capabilities)(void);
|
||||
struct spdk_io_channel *(*get_io_channel)(void);
|
||||
uint32_t (*batch_get_max)(struct spdk_io_channel *ch);
|
||||
int (*submit_tasks)(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task);
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
SO_VER := 7
|
||||
SO_VER := 8
|
||||
SO_MINOR := 0
|
||||
SO_SUFFIX := $(SO_VER).$(SO_MINOR)
|
||||
|
||||
|
@ -52,8 +52,6 @@
|
||||
|
||||
#define ALIGN_4K 0x1000
|
||||
#define MAX_TASKS_PER_CHANNEL 0x800
|
||||
#define MAX_BATCH_SIZE 0x10
|
||||
#define MAX_NUM_BATCHES_PER_CHANNEL (MAX_TASKS_PER_CHANNEL / MAX_BATCH_SIZE)
|
||||
|
||||
/* Largest context size for all accel modules */
|
||||
static size_t g_max_accel_module_size = 0;
|
||||
@ -114,7 +112,6 @@ void
|
||||
spdk_accel_task_complete(struct spdk_accel_task *accel_task, int status)
|
||||
{
|
||||
struct accel_io_channel *accel_ch = accel_task->accel_ch;
|
||||
struct spdk_accel_batch *batch = accel_task->batch;
|
||||
spdk_accel_completion_cb cb_fn = accel_task->cb_fn;
|
||||
void *cb_arg = accel_task->cb_arg;
|
||||
|
||||
@ -125,19 +122,6 @@ spdk_accel_task_complete(struct spdk_accel_task *accel_task, int status)
|
||||
TAILQ_INSERT_HEAD(&accel_ch->task_pool, accel_task, link);
|
||||
|
||||
cb_fn(cb_arg, status);
|
||||
/* If this task is part of a batch, check for completion of the batch. */
|
||||
if (batch) {
|
||||
assert(batch->count > 0);
|
||||
batch->count--;
|
||||
if (batch->count == 0) {
|
||||
SPDK_DEBUGLOG(accel, "Batch %p count %d\n", batch, batch->count);
|
||||
if (batch->cb_fn) {
|
||||
batch->cb_fn(batch->cb_arg, batch->status);
|
||||
}
|
||||
TAILQ_REMOVE(&accel_ch->batches, batch, link);
|
||||
TAILQ_INSERT_TAIL(&accel_ch->batch_pool, batch, link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Accel framework public API for discovering current engine capabilities. */
|
||||
@ -149,27 +133,16 @@ spdk_accel_get_capabilities(struct spdk_io_channel *ch)
|
||||
return accel_ch->engine->capabilities;
|
||||
}
|
||||
|
||||
inline static bool
|
||||
_is_batch_valid(struct spdk_accel_batch *batch, struct accel_io_channel *accel_ch)
|
||||
{
|
||||
return (batch->accel_ch == accel_ch);
|
||||
}
|
||||
|
||||
inline static struct spdk_accel_task *
|
||||
_get_task(struct accel_io_channel *accel_ch, struct spdk_accel_batch *batch,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
_get_task(struct accel_io_channel *accel_ch, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
if (batch && _is_batch_valid(batch, accel_ch) == false) {
|
||||
SPDK_ERRLOG("Attempt to access an invalid batch.\n.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
accel_task = TAILQ_FIRST(&accel_ch->task_pool);
|
||||
if (accel_task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&accel_ch->task_pool, accel_task, link);
|
||||
accel_task->link.tqe_next = NULL;
|
||||
accel_task->link.tqe_prev = NULL;
|
||||
@ -177,10 +150,6 @@ _get_task(struct accel_io_channel *accel_ch, struct spdk_accel_batch *batch,
|
||||
accel_task->cb_fn = cb_fn;
|
||||
accel_task->cb_arg = cb_arg;
|
||||
accel_task->accel_ch = accel_ch;
|
||||
accel_task->batch = batch;
|
||||
if (batch) {
|
||||
batch->count++;
|
||||
}
|
||||
|
||||
return accel_task;
|
||||
}
|
||||
@ -204,7 +173,7 @@ spdk_accel_submit_copy(struct spdk_io_channel *ch, void *dst, void *src, uint64_
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -236,7 +205,7 @@ spdk_accel_submit_dualcast(struct spdk_io_channel *ch, void *dst1, void *dst2, v
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -265,7 +234,7 @@ spdk_accel_submit_compare(struct spdk_io_channel *ch, void *src1, void *src2, ui
|
||||
struct spdk_accel_task *accel_task;
|
||||
int rc;
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -292,7 +261,7 @@ spdk_accel_submit_fill(struct spdk_io_channel *ch, void *dst, uint8_t fill, uint
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -319,7 +288,7 @@ spdk_accel_submit_crc32c(struct spdk_io_channel *ch, uint32_t *crc_dst, void *sr
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -393,7 +362,7 @@ spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *crc_dst, struct
|
||||
}
|
||||
|
||||
accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
SPDK_ERRLOG("no memory\n");
|
||||
assert(0);
|
||||
@ -431,7 +400,7 @@ spdk_accel_submit_copy_crc32c(struct spdk_io_channel *ch, void *dst, void *src,
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -479,7 +448,7 @@ spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst, struct iov
|
||||
}
|
||||
|
||||
accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
accel_task = _get_task(accel_ch, NULL, cb_fn, cb_arg);
|
||||
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
SPDK_ERRLOG("no memory\n");
|
||||
assert(0);
|
||||
@ -510,408 +479,6 @@ spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst, struct iov
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Accel framework public API for getting max operations for a batch. */
|
||||
uint32_t
|
||||
spdk_accel_batch_get_max(struct spdk_io_channel *ch)
|
||||
{
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
/* Use the smaller of the currently selected engine or pure SW implementation. */
|
||||
return spdk_min(accel_ch->engine->batch_get_max(accel_ch->engine_ch),
|
||||
MAX_BATCH_SIZE);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_copy(struct spdk_io_channel *ch, struct spdk_accel_batch *batch, void *dst,
|
||||
void *src, uint64_t nbytes, 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;
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->src = src;
|
||||
accel_task->dst = dst;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_MEMMOVE;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_COPY)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_dualcast(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst1, void *dst2, void *src, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
if ((uintptr_t)dst1 & (ALIGN_4K - 1) || (uintptr_t)dst2 & (ALIGN_4K - 1)) {
|
||||
SPDK_ERRLOG("Dualcast requires 4K alignment on dst addresses\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->src = src;
|
||||
accel_task->dst = dst1;
|
||||
accel_task->dst2 = dst2;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_DUALCAST;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_DUALCAST)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_compare(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *src1, void *src2, uint64_t nbytes, spdk_accel_completion_cb cb_fn,
|
||||
void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->src = src1;
|
||||
accel_task->src2 = src2;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_COMPARE;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_COMPARE)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_fill(struct spdk_io_channel *ch, struct spdk_accel_batch *batch, void *dst,
|
||||
uint8_t fill, uint64_t nbytes, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->dst = dst;
|
||||
accel_task->fill_pattern = fill;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_MEMFILL;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_FILL)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
uint32_t *crc_dst, void *src, uint32_t seed, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->crc_dst = crc_dst;
|
||||
accel_task->src = src;
|
||||
accel_task->v.iovcnt = 0;
|
||||
accel_task->seed = seed;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_CRC32C;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_CRC32C)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
batched_crc32cv_done(void *cb_arg, int status)
|
||||
{
|
||||
struct spdk_accel_task *accel_task = cb_arg;
|
||||
struct spdk_io_channel *ch = spdk_io_channel_from_ctx(accel_task->accel_ch);
|
||||
struct spdk_accel_batch *batch;
|
||||
|
||||
batch = accel_task->batch;
|
||||
assert(batch != NULL);
|
||||
assert(accel_task->chained.cb_fn != NULL);
|
||||
assert(accel_task->chained.cb_arg != NULL);
|
||||
|
||||
if (spdk_likely(!status)) {
|
||||
status = spdk_accel_batch_prep_crc32cv(ch, batch, accel_task->crc_dst,
|
||||
++accel_task->v.iovs, accel_task->v.iovcnt - 1,
|
||||
~(*((uint32_t *)accel_task->crc_dst)),
|
||||
accel_task->chained.cb_fn, accel_task->chained.cb_arg);
|
||||
if (spdk_likely(!status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
accel_task->chained.cb_fn(accel_task->chained.cb_arg, status);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_crc32cv(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
uint32_t *crc_dst, struct iovec *iovs, uint32_t iov_cnt, uint32_t seed,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct accel_io_channel *accel_ch;
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
if (iovs == NULL) {
|
||||
SPDK_ERRLOG("iovs should not be NULL\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (iov_cnt == 0) {
|
||||
SPDK_ERRLOG("iovcnt should not be zero value\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (iov_cnt == 1) {
|
||||
return spdk_accel_batch_prep_crc32c(ch, batch, crc_dst, iovs[0].iov_base, seed, iovs[0].iov_len,
|
||||
cb_fn,
|
||||
cb_arg);
|
||||
}
|
||||
|
||||
accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->v.iovs = iovs;
|
||||
accel_task->v.iovcnt = iov_cnt;
|
||||
accel_task->crc_dst = crc_dst;
|
||||
accel_task->seed = seed;
|
||||
accel_task->op_code = ACCEL_OPCODE_CRC32C;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_CRC32C)) {
|
||||
accel_task->cb_arg = accel_task;
|
||||
accel_task->cb_fn = batched_crc32cv_done;
|
||||
accel_task->cb_arg = accel_task;
|
||||
accel_task->chained.cb_fn = cb_fn;
|
||||
accel_task->chained.cb_arg = cb_arg;
|
||||
|
||||
accel_task->nbytes = iovs[0].iov_len;
|
||||
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_accel_batch_prep_copy_crc32c(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
void *dst, void *src, uint32_t *crc_dst, uint32_t seed, uint64_t nbytes,
|
||||
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_accel_task *accel_task;
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
accel_task = _get_task(accel_ch, batch, cb_fn, cb_arg);
|
||||
if (accel_task == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
accel_task->dst = dst;
|
||||
accel_task->src = src;
|
||||
accel_task->crc_dst = crc_dst;
|
||||
accel_task->v.iovcnt = 0;
|
||||
accel_task->seed = seed;
|
||||
accel_task->nbytes = nbytes;
|
||||
accel_task->op_code = ACCEL_OPCODE_COPY_CRC32C;
|
||||
|
||||
if (_is_supported(accel_ch->engine, ACCEL_COPY_CRC32C)) {
|
||||
TAILQ_INSERT_TAIL(&batch->hw_tasks, accel_task, link);
|
||||
} else {
|
||||
TAILQ_INSERT_TAIL(&batch->sw_tasks, accel_task, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Accel framework public API for batch_create function. */
|
||||
struct spdk_accel_batch *
|
||||
spdk_accel_batch_create(struct spdk_io_channel *ch)
|
||||
{
|
||||
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct spdk_accel_batch *batch;
|
||||
|
||||
batch = TAILQ_FIRST(&accel_ch->batch_pool);
|
||||
if (batch == NULL) {
|
||||
/* The application needs to handle this case (no batches available) */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&accel_ch->batch_pool, batch, link);
|
||||
TAILQ_INIT(&batch->hw_tasks);
|
||||
TAILQ_INIT(&batch->sw_tasks);
|
||||
batch->count = batch->status = 0;
|
||||
batch->accel_ch = accel_ch;
|
||||
TAILQ_INSERT_TAIL(&accel_ch->batches, batch, link);
|
||||
SPDK_DEBUGLOG(accel, "Create batch %p\n", batch);
|
||||
|
||||
return (struct spdk_accel_batch *)batch;
|
||||
}
|
||||
|
||||
/* Accel framework public API for batch_submit function. */
|
||||
int
|
||||
spdk_accel_batch_submit(struct spdk_io_channel *ch, struct spdk_accel_batch *batch,
|
||||
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, *next_task;
|
||||
int rc = 0;
|
||||
|
||||
if (_is_batch_valid(batch, accel_ch) == false) {
|
||||
SPDK_ERRLOG("Attempt to access an invalid batch.\n.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
batch->cb_fn = cb_fn;
|
||||
batch->cb_arg = cb_arg;
|
||||
|
||||
/* Process any HW commands. */
|
||||
if (!TAILQ_EMPTY(&batch->hw_tasks)) {
|
||||
accel_task = TAILQ_FIRST(&batch->hw_tasks);
|
||||
|
||||
/* Clear the hw_tasks list but leave the tasks linked. */
|
||||
TAILQ_INIT(&batch->hw_tasks);
|
||||
|
||||
/* The submit_tasks function will always return success and use the
|
||||
* task callbacks to report errors.
|
||||
*/
|
||||
accel_ch->engine->submit_tasks(accel_ch->engine_ch, accel_task);
|
||||
}
|
||||
|
||||
/* Process any SW commands. */
|
||||
accel_task = TAILQ_FIRST(&batch->sw_tasks);
|
||||
|
||||
/* Clear the hw_tasks list but leave the tasks linked. */
|
||||
TAILQ_INIT(&batch->sw_tasks);
|
||||
|
||||
while (accel_task) {
|
||||
/* Grab the next task now before it's returned to the pool in the cb_fn. */
|
||||
next_task = TAILQ_NEXT(accel_task, link);
|
||||
|
||||
switch (accel_task->op_code) {
|
||||
case ACCEL_OPCODE_MEMMOVE:
|
||||
_sw_accel_copy(accel_task->dst, accel_task->src, accel_task->nbytes);
|
||||
_add_to_comp_list(accel_ch, accel_task, 0);
|
||||
break;
|
||||
case ACCEL_OPCODE_MEMFILL:
|
||||
_sw_accel_fill(accel_task->dst, accel_task->fill_pattern, accel_task->nbytes);
|
||||
_add_to_comp_list(accel_ch, accel_task, 0);
|
||||
break;
|
||||
case ACCEL_OPCODE_COMPARE:
|
||||
rc = _sw_accel_compare(accel_task->src, accel_task->src2, accel_task->nbytes);
|
||||
_add_to_comp_list(accel_ch, accel_task, rc);
|
||||
batch->status |= rc;
|
||||
break;
|
||||
case ACCEL_OPCODE_CRC32C:
|
||||
if (accel_task->v.iovcnt == 0) {
|
||||
_sw_accel_crc32c(accel_task->crc_dst, accel_task->src, accel_task->seed,
|
||||
accel_task->nbytes);
|
||||
} else {
|
||||
_sw_accel_crc32cv(accel_task->crc_dst, accel_task->v.iovs, accel_task->v.iovcnt, accel_task->seed);
|
||||
}
|
||||
_add_to_comp_list(accel_ch, accel_task, 0);
|
||||
break;
|
||||
case ACCEL_OPCODE_COPY_CRC32C:
|
||||
if (accel_task->v.iovcnt == 0) {
|
||||
_sw_accel_copy(accel_task->dst, accel_task->src, accel_task->nbytes);
|
||||
_sw_accel_crc32c(accel_task->crc_dst, accel_task->src, accel_task->seed, accel_task->nbytes);
|
||||
} else {
|
||||
_sw_accel_copyv(accel_task->dst, accel_task->v.iovs, accel_task->v.iovcnt);
|
||||
_sw_accel_crc32cv(accel_task->crc_dst, accel_task->v.iovs, accel_task->v.iovcnt, accel_task->seed);
|
||||
}
|
||||
_add_to_comp_list(accel_ch, accel_task, 0);
|
||||
break;
|
||||
case ACCEL_OPCODE_DUALCAST:
|
||||
_sw_accel_dualcast(accel_task->dst, accel_task->dst2, accel_task->src,
|
||||
accel_task->nbytes);
|
||||
_add_to_comp_list(accel_ch, accel_task, 0);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
accel_task = next_task;
|
||||
};
|
||||
|
||||
/* There are no submission errors possible at this point. Any possible errors will
|
||||
* happen in the task cb_fn calls and OR'd into the batch->status.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Accel framework public API for batch cancel function. If the engine does
|
||||
* not support batching it is done here at the accel_fw level.
|
||||
*/
|
||||
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);
|
||||
struct spdk_accel_task *accel_task;
|
||||
|
||||
/* Cancel anything currently outstanding for this batch. */
|
||||
while ((batch = TAILQ_FIRST(&accel_ch->batches))) {
|
||||
TAILQ_REMOVE(&accel_ch->batches, batch, link);
|
||||
while ((accel_task = TAILQ_FIRST(&batch->hw_tasks))) {
|
||||
TAILQ_REMOVE(&batch->hw_tasks, accel_task, link);
|
||||
TAILQ_INSERT_TAIL(&accel_ch->task_pool, accel_task, link);
|
||||
}
|
||||
while ((accel_task = TAILQ_FIRST(&batch->sw_tasks))) {
|
||||
TAILQ_REMOVE(&batch->sw_tasks, accel_task, link);
|
||||
TAILQ_INSERT_TAIL(&accel_ch->task_pool, accel_task, link);
|
||||
}
|
||||
TAILQ_INSERT_TAIL(&accel_ch->batch_pool, batch, link);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper function when when accel modules register with the framework. */
|
||||
void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module)
|
||||
{
|
||||
@ -928,7 +495,6 @@ accel_engine_create_cb(void *io_device, void *ctx_buf)
|
||||
struct accel_io_channel *accel_ch = ctx_buf;
|
||||
struct spdk_accel_task *accel_task;
|
||||
uint8_t *task_mem;
|
||||
struct spdk_accel_batch *batch;
|
||||
int i;
|
||||
|
||||
accel_ch->task_pool_base = calloc(MAX_TASKS_PER_CHANNEL, g_max_accel_module_size);
|
||||
@ -944,20 +510,6 @@ accel_engine_create_cb(void *io_device, void *ctx_buf)
|
||||
task_mem += g_max_accel_module_size;
|
||||
}
|
||||
|
||||
TAILQ_INIT(&accel_ch->batch_pool);
|
||||
TAILQ_INIT(&accel_ch->batches);
|
||||
accel_ch->batch_pool_base = calloc(MAX_NUM_BATCHES_PER_CHANNEL, sizeof(struct spdk_accel_batch));
|
||||
if (accel_ch->batch_pool_base == NULL) {
|
||||
free(accel_ch->task_pool_base);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
batch = (struct spdk_accel_batch *)accel_ch->batch_pool_base;
|
||||
for (i = 0 ; i < MAX_NUM_BATCHES_PER_CHANNEL; i++) {
|
||||
TAILQ_INSERT_TAIL(&accel_ch->batch_pool, batch, link);
|
||||
batch++;
|
||||
}
|
||||
|
||||
/* Set sw engine channel for operations where hw engine does not support. */
|
||||
accel_ch->sw_engine_ch = g_sw_accel_engine->get_io_channel();
|
||||
assert(accel_ch->sw_engine_ch != NULL);
|
||||
@ -982,7 +534,6 @@ accel_engine_destroy_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct accel_io_channel *accel_ch = ctx_buf;
|
||||
|
||||
free(accel_ch->batch_pool_base);
|
||||
if (accel_ch->sw_engine_ch != accel_ch->engine_ch) {
|
||||
spdk_put_io_channel(accel_ch->sw_engine_ch);
|
||||
}
|
||||
@ -1144,16 +695,10 @@ _sw_accel_crc32cv(uint32_t *crc_dst, struct iovec *iov, uint32_t iovcnt, uint32_
|
||||
|
||||
static struct spdk_io_channel *sw_accel_get_io_channel(void);
|
||||
|
||||
static uint32_t
|
||||
sw_accel_batch_get_max(struct spdk_io_channel *ch)
|
||||
{
|
||||
return MAX_BATCH_SIZE;
|
||||
}
|
||||
|
||||
static struct spdk_accel_engine sw_accel_engine = {
|
||||
.get_capabilities = sw_accel_get_capabilities,
|
||||
.get_io_channel = sw_accel_get_io_channel,
|
||||
.batch_get_max = sw_accel_batch_get_max,
|
||||
};
|
||||
|
||||
static int
|
||||
|
@ -7,17 +7,6 @@
|
||||
spdk_accel_engine_module_finish;
|
||||
spdk_accel_engine_get_io_channel;
|
||||
spdk_accel_get_capabilities;
|
||||
spdk_accel_batch_get_max;
|
||||
spdk_accel_batch_create;
|
||||
spdk_accel_batch_prep_copy;
|
||||
spdk_accel_batch_prep_dualcast;
|
||||
spdk_accel_batch_prep_compare;
|
||||
spdk_accel_batch_prep_fill;
|
||||
spdk_accel_batch_prep_crc32c;
|
||||
spdk_accel_batch_prep_crc32cv;
|
||||
spdk_accel_batch_prep_copy_crc32c;
|
||||
spdk_accel_batch_submit;
|
||||
spdk_accel_batch_cancel;
|
||||
spdk_accel_submit_copy;
|
||||
spdk_accel_submit_dualcast;
|
||||
spdk_accel_submit_compare;
|
||||
|
@ -51,7 +51,6 @@
|
||||
static bool g_idxd_enable = false;
|
||||
static bool g_kernel_mode = false;
|
||||
uint32_t g_config_number;
|
||||
static uint32_t g_batch_max;
|
||||
|
||||
enum channel_state {
|
||||
IDXD_CHANNEL_ACTIVE,
|
||||
@ -285,16 +284,9 @@ idxd_get_capabilities(void)
|
||||
ACCEL_DUALCAST | ACCEL_COPY_CRC32C;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
idxd_batch_get_max(struct spdk_io_channel *ch)
|
||||
{
|
||||
return spdk_idxd_batch_get_max();
|
||||
}
|
||||
|
||||
static struct spdk_accel_engine idxd_accel_engine = {
|
||||
.get_capabilities = idxd_get_capabilities,
|
||||
.get_io_channel = idxd_get_io_channel,
|
||||
.batch_get_max = idxd_batch_get_max,
|
||||
.submit_tasks = idxd_submit_tasks,
|
||||
};
|
||||
|
||||
@ -396,7 +388,6 @@ accel_engine_idxd_init(void)
|
||||
}
|
||||
|
||||
g_idxd_initialized = true;
|
||||
g_batch_max = spdk_idxd_batch_get_max();
|
||||
SPDK_NOTICELOG("Accel engine updated to use IDXD DSA engine.\n");
|
||||
spdk_accel_hw_engine_register(&idxd_accel_engine);
|
||||
spdk_io_device_register(&idxd_accel_engine, idxd_create_cb, idxd_destroy_cb,
|
||||
|
@ -132,14 +132,6 @@ ioat_get_capabilities(void)
|
||||
return ACCEL_COPY | ACCEL_FILL;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
ioat_batch_get_max(struct spdk_io_channel *ch)
|
||||
{
|
||||
struct ioat_io_channel *ioat_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
return spdk_ioat_get_max_descriptors(ioat_ch->ioat_dev->ioat);
|
||||
}
|
||||
|
||||
static int
|
||||
ioat_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task)
|
||||
{
|
||||
@ -180,7 +172,6 @@ ioat_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task
|
||||
static struct spdk_accel_engine ioat_accel_engine = {
|
||||
.get_capabilities = ioat_get_capabilities,
|
||||
.get_io_channel = ioat_get_io_channel,
|
||||
.batch_get_max = ioat_batch_get_max,
|
||||
.submit_tasks = ioat_submit_tasks,
|
||||
};
|
||||
|
||||
|
@ -134,22 +134,11 @@ dummy_cb_fn(void *cb_arg, int status)
|
||||
g_dummy_cb_called = true;
|
||||
}
|
||||
|
||||
static bool g_dummy_batch_cb_called = false;
|
||||
static void
|
||||
dummy_batch_cb_fn(void *cb_arg, int status)
|
||||
{
|
||||
CU_ASSERT(*(uint32_t *)cb_arg == DUMMY_ARG);
|
||||
CU_ASSERT(status == 0);
|
||||
g_dummy_batch_cb_called = true;
|
||||
}
|
||||
|
||||
static void
|
||||
test_spdk_accel_task_complete(void)
|
||||
{
|
||||
struct spdk_accel_task accel_task = {};
|
||||
struct spdk_accel_task *expected_accel_task = NULL;
|
||||
struct spdk_accel_batch batch = {};
|
||||
struct spdk_accel_batch *expected_batch = NULL;
|
||||
uint32_t cb_arg = DUMMY_ARG;
|
||||
int status = 0;
|
||||
|
||||
@ -158,49 +147,12 @@ test_spdk_accel_task_complete(void)
|
||||
accel_task.cb_arg = &cb_arg;
|
||||
TAILQ_INIT(&g_accel_ch->task_pool);
|
||||
|
||||
/* W/o batch, confirm cb is called and task added to list. */
|
||||
/* Confirm cb is called and task added to list. */
|
||||
spdk_accel_task_complete(&accel_task, status);
|
||||
CU_ASSERT(g_dummy_cb_called == true);
|
||||
expected_accel_task = TAILQ_FIRST(&g_accel_ch->task_pool);
|
||||
TAILQ_REMOVE(&g_accel_ch->task_pool, expected_accel_task, link);
|
||||
CU_ASSERT(expected_accel_task == &accel_task);
|
||||
|
||||
TAILQ_INIT(&g_accel_ch->task_pool);
|
||||
TAILQ_INIT(&g_accel_ch->batches);
|
||||
TAILQ_INIT(&g_accel_ch->batch_pool);
|
||||
batch.count = 2;
|
||||
batch.cb_fn = dummy_batch_cb_fn;
|
||||
batch.cb_arg = &cb_arg;
|
||||
accel_task.batch = &batch;
|
||||
|
||||
/* W/batch, confirm task cb is called and task added to list.
|
||||
* but batch not completed yet. */
|
||||
spdk_accel_task_complete(&accel_task, status);
|
||||
CU_ASSERT(batch.count == 1);
|
||||
CU_ASSERT(false == g_dummy_batch_cb_called);
|
||||
|
||||
expected_accel_task = TAILQ_FIRST(&g_accel_ch->task_pool);
|
||||
TAILQ_REMOVE(&g_accel_ch->task_pool, expected_accel_task, link);
|
||||
CU_ASSERT(expected_accel_task == &accel_task);
|
||||
CU_ASSERT(true == TAILQ_EMPTY(&g_accel_ch->batch_pool));
|
||||
CU_ASSERT(true == TAILQ_EMPTY(&g_accel_ch->batches));
|
||||
|
||||
TAILQ_INIT(&g_accel_ch->task_pool);
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->batches, &batch, link);
|
||||
|
||||
/* Call it again and the batch should complete and lists updated accordingly. */
|
||||
spdk_accel_task_complete(&accel_task, status);
|
||||
CU_ASSERT(batch.count == 0);
|
||||
CU_ASSERT(true == g_dummy_batch_cb_called);
|
||||
CU_ASSERT(true == TAILQ_EMPTY(&g_accel_ch->batches));
|
||||
|
||||
expected_accel_task = TAILQ_FIRST(&g_accel_ch->task_pool);
|
||||
TAILQ_REMOVE(&g_accel_ch->task_pool, expected_accel_task, link);
|
||||
CU_ASSERT(expected_accel_task == &accel_task);
|
||||
|
||||
expected_batch = TAILQ_FIRST(&g_accel_ch->batch_pool);
|
||||
TAILQ_REMOVE(&g_accel_ch->batch_pool, expected_batch, link);
|
||||
CU_ASSERT(expected_batch == &batch);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -217,59 +169,31 @@ test_spdk_accel_get_capabilities(void)
|
||||
CU_ASSERT(cap == expected_cap);
|
||||
}
|
||||
|
||||
static void
|
||||
test_is_batch_valid(void)
|
||||
{
|
||||
struct spdk_accel_batch batch = {};
|
||||
bool rc;
|
||||
|
||||
/* This batch doesn't go with this channel. */
|
||||
batch.accel_ch = (struct accel_io_channel *)0xDEADBEEF;
|
||||
rc = _is_batch_valid(&batch, g_accel_ch);
|
||||
CU_ASSERT(rc == false);
|
||||
|
||||
/* This one does. */
|
||||
batch.accel_ch = g_accel_ch;
|
||||
rc = _is_batch_valid(&batch, g_accel_ch);
|
||||
CU_ASSERT(rc == true);
|
||||
}
|
||||
|
||||
static void
|
||||
test_get_task(void)
|
||||
{
|
||||
struct spdk_accel_batch batch = {};
|
||||
struct spdk_accel_task *task;
|
||||
struct spdk_accel_task _task;
|
||||
void *cb_arg = NULL;
|
||||
|
||||
/* NULL batch should return NULL task. */
|
||||
task = _get_task(g_accel_ch, NULL, dummy_cb_fn, cb_arg);
|
||||
CU_ASSERT(task == NULL);
|
||||
|
||||
/* valid batch with bogus accel_ch should return NULL task. */
|
||||
task = _get_task(g_accel_ch, &batch, dummy_cb_fn, cb_arg);
|
||||
CU_ASSERT(task == NULL);
|
||||
|
||||
TAILQ_INIT(&g_accel_ch->task_pool);
|
||||
batch.accel_ch = g_accel_ch;
|
||||
|
||||
/* no tasks left, return NULL. */
|
||||
task = _get_task(g_accel_ch, &batch, dummy_cb_fn, cb_arg);
|
||||
task = _get_task(g_accel_ch, dummy_cb_fn, cb_arg);
|
||||
CU_ASSERT(task == NULL);
|
||||
|
||||
_task.cb_fn = dummy_cb_fn;
|
||||
_task.cb_arg = cb_arg;
|
||||
_task.accel_ch = g_accel_ch;
|
||||
_task.batch = &batch;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &_task, link);
|
||||
|
||||
/* Get a valid task. */
|
||||
task = _get_task(g_accel_ch, &batch, dummy_cb_fn, cb_arg);
|
||||
task = _get_task(g_accel_ch, dummy_cb_fn, cb_arg);
|
||||
CU_ASSERT(task == &_task);
|
||||
CU_ASSERT(_task.cb_fn == dummy_cb_fn);
|
||||
CU_ASSERT(_task.cb_arg == cb_arg);
|
||||
CU_ASSERT(_task.accel_ch == g_accel_ch);
|
||||
CU_ASSERT(_task.batch->count == 1);
|
||||
}
|
||||
|
||||
static bool g_dummy_submit_called = false;
|
||||
@ -309,7 +233,6 @@ test_spdk_accel_submit_copy(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -395,7 +318,6 @@ test_spdk_accel_submit_dualcast(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -474,7 +396,6 @@ test_spdk_accel_submit_compare(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -545,7 +466,6 @@ test_spdk_accel_submit_fill(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -607,7 +527,6 @@ test_spdk_accel_submit_crc32c(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -670,7 +589,6 @@ test_spdk_accel_submit_crc32c_hw_engine_unsupported(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -719,7 +637,6 @@ test_spdk_accel_submit_crc32cv(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
task.nbytes = TEST_SUBMIT_SIZE;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
@ -792,7 +709,6 @@ test_spdk_accel_submit_copy_crc32c(void)
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
@ -858,7 +774,6 @@ int main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, test_is_supported);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_task_complete);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_get_capabilities);
|
||||
CU_ADD_TEST(suite, test_is_batch_valid);
|
||||
CU_ADD_TEST(suite, test_get_task);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_submit_copy);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_submit_dualcast);
|
||||
|
Loading…
Reference in New Issue
Block a user