2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2020 Intel Corporation.
|
2022-10-04 18:50:44 +00:00
|
|
|
* Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
2020-02-05 17:10:05 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
#include "spdk_internal/accel_module.h"
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-08-05 19:32:35 +00:00
|
|
|
#include "accel_internal.h"
|
|
|
|
|
2022-10-21 14:09:30 +00:00
|
|
|
#include "spdk/dma.h"
|
2020-02-05 17:10:05 +00:00
|
|
|
#include "spdk/env.h"
|
2020-12-21 12:17:06 +00:00
|
|
|
#include "spdk/likely.h"
|
2020-05-29 01:39:05 +00:00
|
|
|
#include "spdk/log.h"
|
2020-02-05 17:10:05 +00:00
|
|
|
#include "spdk/thread.h"
|
2020-02-08 18:23:09 +00:00
|
|
|
#include "spdk/json.h"
|
2020-04-28 22:20:57 +00:00
|
|
|
#include "spdk/crc32.h"
|
2020-07-28 17:51:20 +00:00
|
|
|
#include "spdk/util.h"
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-08-08 20:51:25 +00:00
|
|
|
/* Accelerator Framework: The following provides a top level
|
2020-02-05 21:31:16 +00:00
|
|
|
* generic API for the accelerator functions defined here. Modules,
|
2021-11-25 01:40:58 +00:00
|
|
|
* such as the one in /module/accel/ioat, supply the implementation
|
|
|
|
* with the exception of the pure software implementation contained
|
2020-02-05 21:31:16 +00:00
|
|
|
* later in this file.
|
|
|
|
*/
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
#define ALIGN_4K 0x1000
|
|
|
|
#define MAX_TASKS_PER_CHANNEL 0x800
|
2022-11-29 11:51:22 +00:00
|
|
|
#define ACCEL_SMALL_CACHE_SIZE 128
|
|
|
|
#define ACCEL_LARGE_CACHE_SIZE 16
|
2022-11-29 11:38:53 +00:00
|
|
|
/* Set MSB, so we don't return NULL pointers as buffers */
|
|
|
|
#define ACCEL_BUFFER_BASE ((void *)(1ull << 63))
|
2020-04-30 15:43:02 +00:00
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Largest context size for all accel modules */
|
2022-08-08 19:48:24 +00:00
|
|
|
static size_t g_max_accel_module_size = sizeof(struct spdk_accel_task);
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
static struct spdk_accel_module_if *g_accel_module = NULL;
|
2020-02-05 21:31:16 +00:00
|
|
|
static spdk_accel_fini_cb g_fini_cb_fn = NULL;
|
|
|
|
static void *g_fini_cb_arg = NULL;
|
2022-08-08 21:43:24 +00:00
|
|
|
static bool g_modules_started = false;
|
2022-10-21 14:09:30 +00:00
|
|
|
static struct spdk_memory_domain *g_accel_domain;
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Global list of registered accelerator modules */
|
2020-02-05 17:10:05 +00:00
|
|
|
static TAILQ_HEAD(, spdk_accel_module_if) spdk_accel_module_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(spdk_accel_module_list);
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
/* Global array mapping capabilities to modules */
|
|
|
|
static struct spdk_accel_module_if *g_modules_opc[ACCEL_OPC_LAST] = {};
|
|
|
|
static char *g_modules_opc_override[ACCEL_OPC_LAST] = {};
|
2022-03-09 22:21:42 +00:00
|
|
|
|
2022-10-04 18:50:44 +00:00
|
|
|
static const char *g_opcode_strings[ACCEL_OPC_LAST] = {
|
|
|
|
"copy", "fill", "dualcast", "compare", "crc32c", "copy_crc32c",
|
|
|
|
"compress", "decompress"
|
|
|
|
};
|
|
|
|
|
2022-11-29 11:38:53 +00:00
|
|
|
struct accel_buffer {
|
|
|
|
uint64_t len;
|
|
|
|
TAILQ_ENTRY(accel_buffer) link;
|
|
|
|
};
|
|
|
|
|
2022-08-08 20:25:48 +00:00
|
|
|
struct accel_io_channel {
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
struct spdk_io_channel *module_ch[ACCEL_OPC_LAST];
|
|
|
|
void *task_pool_base;
|
|
|
|
struct spdk_accel_sequence *seq_pool_base;
|
2022-11-29 11:38:53 +00:00
|
|
|
struct accel_buffer *buf_pool_base;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
TAILQ_HEAD(, spdk_accel_task) task_pool;
|
|
|
|
TAILQ_HEAD(, spdk_accel_sequence) seq_pool;
|
2022-11-29 11:38:53 +00:00
|
|
|
TAILQ_HEAD(, accel_buffer) buf_pool;
|
2022-11-29 11:51:22 +00:00
|
|
|
struct spdk_iobuf_channel iobuf;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(accel_sequence_tasks, spdk_accel_task);
|
|
|
|
|
|
|
|
struct spdk_accel_sequence {
|
|
|
|
struct accel_io_channel *ch;
|
|
|
|
struct accel_sequence_tasks tasks;
|
|
|
|
struct accel_sequence_tasks completed;
|
|
|
|
spdk_accel_completion_cb cb_fn;
|
|
|
|
void *cb_arg;
|
|
|
|
TAILQ_ENTRY(spdk_accel_sequence) link;
|
2022-08-08 20:25:48 +00:00
|
|
|
};
|
|
|
|
|
2022-05-26 23:46:01 +00:00
|
|
|
int
|
2022-08-08 21:43:24 +00:00
|
|
|
spdk_accel_get_opc_module_name(enum accel_opcode opcode, const char **module_name)
|
2022-05-26 23:46:01 +00:00
|
|
|
{
|
|
|
|
if (opcode >= ACCEL_OPC_LAST) {
|
|
|
|
/* invalid opcode */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
if (g_modules_opc[opcode]) {
|
|
|
|
*module_name = g_modules_opc[opcode]->name;
|
2022-05-26 23:46:01 +00:00
|
|
|
} else {
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-21 21:15:09 +00:00
|
|
|
void
|
2022-08-08 21:43:24 +00:00
|
|
|
_accel_for_each_module(struct module_info *info, _accel_for_each_module_fn fn)
|
2022-07-21 21:15:09 +00:00
|
|
|
{
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *accel_module;
|
2022-07-21 21:15:09 +00:00
|
|
|
enum accel_opcode opcode;
|
|
|
|
int j = 0;
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
TAILQ_FOREACH(accel_module, &spdk_accel_module_list, tailq) {
|
2022-07-21 21:15:09 +00:00
|
|
|
for (opcode = 0; opcode < ACCEL_OPC_LAST; opcode++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
if (accel_module->supports_opcode(opcode)) {
|
2022-07-21 21:15:09 +00:00
|
|
|
info->ops[j] = opcode;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2022-08-08 21:43:24 +00:00
|
|
|
info->name = accel_module->name;
|
2022-07-21 21:15:09 +00:00
|
|
|
info->num_ops = j;
|
|
|
|
fn(info);
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-04 18:50:44 +00:00
|
|
|
int
|
|
|
|
_accel_get_opc_name(enum accel_opcode opcode, const char **opcode_name)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (opcode < ACCEL_OPC_LAST) {
|
|
|
|
*opcode_name = g_opcode_strings[opcode];
|
|
|
|
} else {
|
|
|
|
/* invalid opcode */
|
|
|
|
rc = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2022-06-01 00:13:04 +00:00
|
|
|
int
|
|
|
|
spdk_accel_assign_opc(enum accel_opcode opcode, const char *name)
|
|
|
|
{
|
2022-08-08 21:43:24 +00:00
|
|
|
if (g_modules_started == true) {
|
2022-06-01 00:13:04 +00:00
|
|
|
/* we don't allow re-assignment once things have started */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opcode >= ACCEL_OPC_LAST) {
|
|
|
|
/* invalid opcode */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
/* module selection will be validated after the framework starts. */
|
|
|
|
g_modules_opc_override[opcode] = strdup(name);
|
2022-06-01 00:13:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
void
|
|
|
|
spdk_accel_task_complete(struct spdk_accel_task *accel_task, int status)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = accel_task->accel_ch;
|
2020-12-21 12:17:06 +00:00
|
|
|
spdk_accel_completion_cb cb_fn = accel_task->cb_fn;
|
|
|
|
void *cb_arg = accel_task->cb_arg;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2020-12-21 12:17:06 +00:00
|
|
|
/* We should put the accel_task into the list firstly in order to avoid
|
|
|
|
* the accel task list is exhausted when there is recursive call to
|
|
|
|
* allocate accel_task in user's call back function (cb_fn)
|
|
|
|
*/
|
2021-11-11 20:17:01 +00:00
|
|
|
TAILQ_INSERT_HEAD(&accel_ch->task_pool, accel_task, link);
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2020-12-21 12:17:06 +00:00
|
|
|
cb_fn(cb_arg, status);
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 18:17:14 +00:00
|
|
|
inline static struct spdk_accel_task *
|
2021-10-12 22:32:49 +00:00
|
|
|
_get_task(struct accel_io_channel *accel_ch, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2020-08-11 18:17:14 +00:00
|
|
|
{
|
2020-07-28 17:51:20 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
|
|
|
|
|
|
|
accel_task = TAILQ_FIRST(&accel_ch->task_pool);
|
2020-08-11 18:17:14 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-10-12 22:32:49 +00:00
|
|
|
|
2020-08-11 18:17:14 +00:00
|
|
|
TAILQ_REMOVE(&accel_ch->task_pool, accel_task, link);
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->link.tqe_next = NULL;
|
|
|
|
accel_task->link.tqe_prev = NULL;
|
2020-08-11 18:17:14 +00:00
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->cb_fn = cb_fn;
|
2020-08-11 18:17:14 +00:00
|
|
|
accel_task->cb_arg = cb_arg;
|
|
|
|
accel_task->accel_ch = accel_ch;
|
|
|
|
|
|
|
|
return accel_task;
|
|
|
|
}
|
|
|
|
|
2021-08-13 06:12:47 +00:00
|
|
|
|
2021-09-08 21:29:35 +00:00
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Accel framework public API for copy function */
|
2020-02-05 17:10:05 +00:00
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_copy(struct spdk_io_channel *ch, void *dst, void *src,
|
|
|
|
uint64_t nbytes, int flags, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-08-11 18:17:14 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COPY];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COPY];
|
2020-07-03 14:08:47 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-08-11 18:17:14 +00:00
|
|
|
if (accel_task == NULL) {
|
2020-07-03 14:08:47 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->dst = dst;
|
|
|
|
accel_task->src = src;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_COPY;
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->nbytes = nbytes;
|
2021-08-24 21:08:29 +00:00
|
|
|
accel_task->flags = flags;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 15:43:02 +00:00
|
|
|
/* Accel framework public API for dual cast copy function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_dualcast(struct spdk_io_channel *ch, void *dst1,
|
|
|
|
void *dst2, void *src, uint64_t nbytes, int flags,
|
|
|
|
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2020-04-30 15:43:02 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-08-11 18:17:14 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_DUALCAST];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_DUALCAST];
|
2020-04-30 15:43:02 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-08-11 18:17:14 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2020-06-17 20:28:15 +00:00
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->src = src;
|
|
|
|
accel_task->dst = dst1;
|
|
|
|
accel_task->dst2 = dst2;
|
|
|
|
accel_task->nbytes = nbytes;
|
2021-08-24 21:08:29 +00:00
|
|
|
accel_task->flags = flags;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_DUALCAST;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2020-04-30 15:43:02 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
/* Accel framework public API for compare function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
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)
|
2020-05-07 18:45:15 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-07-28 17:51:20 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COMPARE];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COMPARE];
|
2020-05-07 18:45:15 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-07-28 17:51:20 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
accel_task->src = src1;
|
|
|
|
accel_task->src2 = src2;
|
|
|
|
accel_task->nbytes = nbytes;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_COMPARE;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2020-05-07 18:45:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
/* Accel framework public API for fill function */
|
2020-05-07 18:45:15 +00:00
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_fill(struct spdk_io_channel *ch, void *dst,
|
|
|
|
uint8_t fill, uint64_t nbytes, int flags,
|
|
|
|
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2020-05-07 18:45:15 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-08-11 18:17:14 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_FILL];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_FILL];
|
2020-07-03 14:08:47 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-08-11 18:17:14 +00:00
|
|
|
if (accel_task == NULL) {
|
2020-07-03 14:08:47 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->dst = dst;
|
2022-03-15 14:40:24 +00:00
|
|
|
memset(&accel_task->fill_pattern, fill, sizeof(uint64_t));
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->nbytes = nbytes;
|
2021-08-24 21:08:29 +00:00
|
|
|
accel_task->flags = flags;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_FILL;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2020-05-07 18:45:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
/* Accel framework public API for CRC-32C function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_crc32c(struct spdk_io_channel *ch, uint32_t *crc_dst,
|
|
|
|
void *src, uint32_t seed, uint64_t nbytes, spdk_accel_completion_cb cb_fn,
|
|
|
|
void *cb_arg)
|
2020-05-07 18:45:15 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-07-28 17:51:20 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_CRC32C];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_CRC32C];
|
2020-05-07 18:45:15 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-07-28 17:51:20 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2021-06-09 19:15:47 +00:00
|
|
|
accel_task->crc_dst = crc_dst;
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->src = src;
|
2022-07-21 21:57:11 +00:00
|
|
|
accel_task->s.iovcnt = 0;
|
2020-07-28 17:51:20 +00:00
|
|
|
accel_task->seed = seed;
|
|
|
|
accel_task->nbytes = nbytes;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_CRC32C;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-07-28 17:51:20 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2020-05-07 18:45:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-18 16:07:49 +00:00
|
|
|
/* Accel framework public API for chained CRC-32C function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_crc32cv(struct spdk_io_channel *ch, uint32_t *crc_dst,
|
|
|
|
struct iovec *iov, uint32_t iov_cnt, uint32_t seed,
|
|
|
|
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2021-01-18 16:07:49 +00:00
|
|
|
{
|
2022-03-09 22:21:42 +00:00
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2020-12-21 12:17:06 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_CRC32C];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_CRC32C];
|
2020-12-21 12:17:06 +00:00
|
|
|
|
2021-01-18 16:07:49 +00:00
|
|
|
if (iov == NULL) {
|
|
|
|
SPDK_ERRLOG("iov should not be NULL");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-12-21 12:17:06 +00:00
|
|
|
if (!iov_cnt) {
|
|
|
|
SPDK_ERRLOG("iovcnt should not be zero value\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2021-01-18 16:07:49 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2020-12-21 12:17:06 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
SPDK_ERRLOG("no memory\n");
|
|
|
|
assert(0);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-07-21 21:57:11 +00:00
|
|
|
accel_task->s.iovs = iov;
|
|
|
|
accel_task->s.iovcnt = iov_cnt;
|
2021-06-09 19:15:47 +00:00
|
|
|
accel_task->crc_dst = crc_dst;
|
2021-05-03 11:57:53 +00:00
|
|
|
accel_task->seed = seed;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_CRC32C;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2020-12-21 12:17:06 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2021-01-18 16:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-06-01 19:17:50 +00:00
|
|
|
/* Accel framework public API for copy with CRC-32C function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_copy_crc32c(struct spdk_io_channel *ch, void *dst,
|
|
|
|
void *src, uint32_t *crc_dst, uint32_t seed, uint64_t nbytes,
|
|
|
|
int flags, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2021-06-01 19:17:50 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COPY_CRC32C];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COPY_CRC32C];
|
2021-06-01 19:17:50 +00:00
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2021-06-01 19:17:50 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
accel_task->dst = dst;
|
|
|
|
accel_task->src = src;
|
|
|
|
accel_task->crc_dst = crc_dst;
|
2022-07-21 21:57:11 +00:00
|
|
|
accel_task->s.iovcnt = 0;
|
2021-06-01 19:17:50 +00:00
|
|
|
accel_task->seed = seed;
|
|
|
|
accel_task->nbytes = nbytes;
|
2021-08-24 21:08:29 +00:00
|
|
|
accel_task->flags = flags;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_COPY_CRC32C;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2021-06-01 19:17:50 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2021-06-01 19:17:50 +00:00
|
|
|
}
|
|
|
|
|
2021-06-07 20:00:15 +00:00
|
|
|
/* Accel framework public API for chained copy + CRC-32C function */
|
|
|
|
int
|
2022-03-09 22:21:42 +00:00
|
|
|
spdk_accel_submit_copy_crc32cv(struct spdk_io_channel *ch, void *dst,
|
|
|
|
struct iovec *src_iovs, uint32_t iov_cnt, uint32_t *crc_dst,
|
|
|
|
uint32_t seed, int flags, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2021-06-07 20:00:15 +00:00
|
|
|
{
|
2022-03-09 22:21:42 +00:00
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
2021-06-07 20:00:15 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COPY_CRC32C];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COPY_CRC32C];
|
2022-05-10 22:32:18 +00:00
|
|
|
uint64_t nbytes;
|
|
|
|
uint32_t i;
|
2021-06-07 20:00:15 +00:00
|
|
|
|
|
|
|
if (src_iovs == NULL) {
|
|
|
|
SPDK_ERRLOG("iov should not be NULL");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!iov_cnt) {
|
|
|
|
SPDK_ERRLOG("iovcnt should not be zero value\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-10-12 22:32:49 +00:00
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
2021-06-07 20:00:15 +00:00
|
|
|
if (accel_task == NULL) {
|
|
|
|
SPDK_ERRLOG("no memory\n");
|
|
|
|
assert(0);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-05-10 22:32:18 +00:00
|
|
|
nbytes = 0;
|
|
|
|
for (i = 0; i < iov_cnt; i++) {
|
|
|
|
nbytes += src_iovs[i].iov_len;
|
|
|
|
}
|
|
|
|
|
2022-07-21 21:57:11 +00:00
|
|
|
accel_task->s.iovs = src_iovs;
|
|
|
|
accel_task->s.iovcnt = iov_cnt;
|
2021-06-07 20:00:15 +00:00
|
|
|
accel_task->dst = (void *)dst;
|
|
|
|
accel_task->crc_dst = crc_dst;
|
|
|
|
accel_task->seed = seed;
|
2022-05-10 22:32:18 +00:00
|
|
|
accel_task->nbytes = nbytes;
|
2021-08-24 21:08:29 +00:00
|
|
|
accel_task->flags = flags;
|
2022-03-15 17:43:07 +00:00
|
|
|
accel_task->op_code = ACCEL_OPC_COPY_CRC32C;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2021-06-07 20:00:15 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2021-06-07 20:00:15 +00:00
|
|
|
}
|
|
|
|
|
2022-05-20 19:08:38 +00:00
|
|
|
int
|
2022-09-22 19:01:56 +00:00
|
|
|
spdk_accel_submit_compress(struct spdk_io_channel *ch, void *dst, uint64_t nbytes,
|
|
|
|
struct iovec *src_iovs, size_t src_iovcnt, uint32_t *output_size, int flags,
|
2022-05-20 19:08:38 +00:00
|
|
|
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;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_COMPRESS];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_COMPRESS];
|
2022-09-22 19:01:56 +00:00
|
|
|
size_t i, src_len = 0;
|
2022-05-20 19:08:38 +00:00
|
|
|
|
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-09-22 19:01:56 +00:00
|
|
|
for (i = 0; i < src_iovcnt; i++) {
|
|
|
|
src_len += src_iovs[i].iov_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
accel_task->nbytes = src_len;
|
2022-05-20 19:08:38 +00:00
|
|
|
accel_task->output_size = output_size;
|
2022-09-22 19:01:56 +00:00
|
|
|
accel_task->s.iovs = src_iovs;
|
|
|
|
accel_task->s.iovcnt = src_iovcnt;
|
2022-05-20 19:08:38 +00:00
|
|
|
accel_task->dst = dst;
|
2022-09-22 19:01:56 +00:00
|
|
|
accel_task->nbytes_dst = nbytes;
|
2022-05-20 19:08:38 +00:00
|
|
|
accel_task->flags = flags;
|
|
|
|
accel_task->op_code = ACCEL_OPC_COMPRESS;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2022-05-20 19:08:38 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2022-05-20 19:08:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2022-09-22 19:01:56 +00:00
|
|
|
spdk_accel_submit_decompress(struct spdk_io_channel *ch, struct iovec *dst_iovs,
|
|
|
|
size_t dst_iovcnt, struct iovec *src_iovs, size_t src_iovcnt,
|
|
|
|
int flags, spdk_accel_completion_cb cb_fn, void *cb_arg)
|
2022-05-20 19:08:38 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct spdk_accel_task *accel_task;
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *module = g_modules_opc[ACCEL_OPC_DECOMPRESS];
|
|
|
|
struct spdk_io_channel *module_ch = accel_ch->module_ch[ACCEL_OPC_DECOMPRESS];
|
2022-05-20 19:08:38 +00:00
|
|
|
|
|
|
|
accel_task = _get_task(accel_ch, cb_fn, cb_arg);
|
|
|
|
if (accel_task == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-09-22 19:01:56 +00:00
|
|
|
accel_task->s.iovs = src_iovs;
|
|
|
|
accel_task->s.iovcnt = src_iovcnt;
|
|
|
|
accel_task->d.iovs = dst_iovs;
|
|
|
|
accel_task->d.iovcnt = dst_iovcnt;
|
2022-05-20 19:08:38 +00:00
|
|
|
accel_task->flags = flags;
|
|
|
|
accel_task->op_code = ACCEL_OPC_DECOMPRESS;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_task->src_domain = NULL;
|
|
|
|
accel_task->dst_domain = NULL;
|
|
|
|
accel_task->step_cb_fn = NULL;
|
2022-05-20 19:08:38 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
return module->submit_tasks(module_ch, accel_task);
|
2022-05-20 19:08:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-11-29 11:38:53 +00:00
|
|
|
static inline struct accel_buffer *
|
|
|
|
accel_get_buf(struct accel_io_channel *ch, uint64_t len)
|
|
|
|
{
|
|
|
|
struct accel_buffer *buf;
|
|
|
|
|
|
|
|
buf = TAILQ_FIRST(&ch->buf_pool);
|
|
|
|
if (spdk_unlikely(buf == NULL)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TAILQ_REMOVE(&ch->buf_pool, buf, link);
|
|
|
|
buf->len = len;
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
accel_put_buf(struct accel_io_channel *ch, struct accel_buffer *buf)
|
|
|
|
{
|
|
|
|
TAILQ_INSERT_HEAD(&ch->buf_pool, buf, link);
|
|
|
|
}
|
|
|
|
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
static inline struct spdk_accel_sequence *
|
|
|
|
accel_sequence_get(struct accel_io_channel *ch)
|
|
|
|
{
|
|
|
|
struct spdk_accel_sequence *seq;
|
|
|
|
|
|
|
|
seq = TAILQ_FIRST(&ch->seq_pool);
|
|
|
|
if (seq == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TAILQ_REMOVE(&ch->seq_pool, seq, link);
|
|
|
|
|
|
|
|
TAILQ_INIT(&seq->tasks);
|
|
|
|
TAILQ_INIT(&seq->completed);
|
|
|
|
|
|
|
|
seq->ch = ch;
|
|
|
|
|
|
|
|
return seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
accel_sequence_put(struct spdk_accel_sequence *seq)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *ch = seq->ch;
|
|
|
|
|
|
|
|
assert(TAILQ_EMPTY(&seq->tasks));
|
|
|
|
assert(TAILQ_EMPTY(&seq->completed));
|
|
|
|
seq->ch = NULL;
|
|
|
|
|
|
|
|
TAILQ_INSERT_HEAD(&ch->seq_pool, seq, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void accel_sequence_task_cb(void *cb_arg, int status);
|
|
|
|
|
|
|
|
static inline struct spdk_accel_task *
|
|
|
|
accel_sequence_get_task(struct accel_io_channel *ch, struct spdk_accel_sequence *seq,
|
|
|
|
spdk_accel_step_cb cb_fn, void *cb_arg)
|
|
|
|
{
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
|
|
|
|
task = _get_task(ch, accel_sequence_task_cb, seq);
|
|
|
|
if (task == NULL) {
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
|
|
|
|
task->step_cb_fn = cb_fn;
|
|
|
|
task->step_cb_arg = cb_arg;
|
|
|
|
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
spdk_accel_append_copy(struct spdk_accel_sequence **pseq, struct spdk_io_channel *ch,
|
|
|
|
struct iovec *dst_iovs, uint32_t dst_iovcnt,
|
|
|
|
struct spdk_memory_domain *dst_domain, void *dst_domain_ctx,
|
|
|
|
struct iovec *src_iovs, uint32_t src_iovcnt,
|
|
|
|
struct spdk_memory_domain *src_domain, void *src_domain_ctx,
|
|
|
|
int flags, spdk_accel_step_cb cb_fn, void *cb_arg)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
struct spdk_accel_sequence *seq = *pseq;
|
|
|
|
|
|
|
|
if (dst_domain != NULL || src_domain != NULL) {
|
|
|
|
SPDK_ERRLOG("Memory domains are currently unsupported\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
seq = accel_sequence_get(accel_ch);
|
|
|
|
if (spdk_unlikely(seq == NULL)) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(seq->ch == accel_ch);
|
|
|
|
task = accel_sequence_get_task(accel_ch, seq, cb_fn, cb_arg);
|
|
|
|
if (spdk_unlikely(task == NULL)) {
|
|
|
|
if (*pseq == NULL) {
|
|
|
|
accel_sequence_put(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
task->dst_domain = dst_domain;
|
|
|
|
task->dst_domain_ctx = dst_domain_ctx;
|
|
|
|
task->d.iovs = dst_iovs;
|
|
|
|
task->d.iovcnt = dst_iovcnt;
|
|
|
|
task->src_domain = src_domain;
|
|
|
|
task->src_domain_ctx = src_domain_ctx;
|
|
|
|
task->s.iovs = src_iovs;
|
|
|
|
task->s.iovcnt = src_iovcnt;
|
|
|
|
task->flags = flags;
|
|
|
|
task->op_code = ACCEL_OPC_COPY;
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&seq->tasks, task, seq_link);
|
|
|
|
*pseq = seq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
spdk_accel_append_fill(struct spdk_accel_sequence **pseq, struct spdk_io_channel *ch,
|
|
|
|
void *buf, uint64_t len,
|
|
|
|
struct spdk_memory_domain *domain, void *domain_ctx, uint8_t pattern,
|
|
|
|
int flags, spdk_accel_step_cb cb_fn, void *cb_arg)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
struct spdk_accel_sequence *seq = *pseq;
|
|
|
|
|
|
|
|
if (domain != NULL) {
|
|
|
|
SPDK_ERRLOG("Memory domains are currently unsupported\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
seq = accel_sequence_get(accel_ch);
|
|
|
|
if (spdk_unlikely(seq == NULL)) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(seq->ch == accel_ch);
|
|
|
|
task = accel_sequence_get_task(accel_ch, seq, cb_fn, cb_arg);
|
|
|
|
if (spdk_unlikely(task == NULL)) {
|
|
|
|
if (*pseq == NULL) {
|
|
|
|
accel_sequence_put(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&task->fill_pattern, pattern, sizeof(uint64_t));
|
|
|
|
|
|
|
|
task->src_domain = NULL;
|
|
|
|
task->dst_domain = domain;
|
|
|
|
task->dst_domain_ctx = domain_ctx;
|
|
|
|
task->dst = buf;
|
|
|
|
task->nbytes = len;
|
|
|
|
task->flags = flags;
|
|
|
|
task->op_code = ACCEL_OPC_FILL;
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&seq->tasks, task, seq_link);
|
|
|
|
*pseq = seq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-11-22 13:36:09 +00:00
|
|
|
int
|
|
|
|
spdk_accel_append_decompress(struct spdk_accel_sequence **pseq, struct spdk_io_channel *ch,
|
|
|
|
struct iovec *dst_iovs, size_t dst_iovcnt,
|
|
|
|
struct spdk_memory_domain *dst_domain, void *dst_domain_ctx,
|
|
|
|
struct iovec *src_iovs, size_t src_iovcnt,
|
|
|
|
struct spdk_memory_domain *src_domain, void *src_domain_ctx,
|
|
|
|
int flags, spdk_accel_step_cb cb_fn, void *cb_arg)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
struct spdk_accel_sequence *seq = *pseq;
|
|
|
|
|
|
|
|
if (dst_domain != NULL || src_domain != NULL) {
|
|
|
|
SPDK_ERRLOG("Memory domains are currently unsupported\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq == NULL) {
|
|
|
|
seq = accel_sequence_get(accel_ch);
|
|
|
|
if (spdk_unlikely(seq == NULL)) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(seq->ch == accel_ch);
|
|
|
|
task = accel_sequence_get_task(accel_ch, seq, cb_fn, cb_arg);
|
|
|
|
if (spdk_unlikely(task == NULL)) {
|
|
|
|
if (*pseq == NULL) {
|
|
|
|
accel_sequence_put(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
task->dst_domain = dst_domain;
|
|
|
|
task->dst_domain_ctx = dst_domain_ctx;
|
|
|
|
task->d.iovs = dst_iovs;
|
|
|
|
task->d.iovcnt = dst_iovcnt;
|
|
|
|
task->src_domain = src_domain;
|
|
|
|
task->src_domain_ctx = src_domain_ctx;
|
|
|
|
task->s.iovs = src_iovs;
|
|
|
|
task->s.iovcnt = src_iovcnt;
|
|
|
|
task->flags = flags;
|
|
|
|
task->op_code = ACCEL_OPC_DECOMPRESS;
|
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&seq->tasks, task, seq_link);
|
|
|
|
*pseq = seq;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-11-29 11:38:53 +00:00
|
|
|
int
|
|
|
|
spdk_accel_get_buf(struct spdk_io_channel *ch, uint64_t len, void **buf,
|
|
|
|
struct spdk_memory_domain **domain, void **domain_ctx)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct accel_buffer *accel_buf;
|
|
|
|
|
|
|
|
accel_buf = accel_get_buf(accel_ch, len);
|
|
|
|
if (spdk_unlikely(accel_buf == NULL)) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We always return the same pointer and identify the buffers through domain_ctx */
|
|
|
|
*buf = ACCEL_BUFFER_BASE;
|
|
|
|
*domain_ctx = accel_buf;
|
|
|
|
*domain = g_accel_domain;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_accel_put_buf(struct spdk_io_channel *ch, void *buf,
|
|
|
|
struct spdk_memory_domain *domain, void *domain_ctx)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);
|
|
|
|
struct accel_buffer *accel_buf = domain_ctx;
|
|
|
|
|
|
|
|
assert(domain == g_accel_domain);
|
|
|
|
assert(buf == ACCEL_BUFFER_BASE);
|
|
|
|
|
|
|
|
accel_put_buf(accel_ch, accel_buf);
|
|
|
|
}
|
|
|
|
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
static void
|
|
|
|
accel_sequence_complete_tasks(struct spdk_accel_sequence *seq)
|
|
|
|
{
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
struct accel_io_channel *ch = seq->ch;
|
|
|
|
spdk_accel_step_cb cb_fn;
|
|
|
|
void *cb_arg;
|
|
|
|
|
|
|
|
while (!TAILQ_EMPTY(&seq->completed)) {
|
|
|
|
task = TAILQ_FIRST(&seq->completed);
|
|
|
|
TAILQ_REMOVE(&seq->completed, task, seq_link);
|
|
|
|
cb_fn = task->step_cb_fn;
|
|
|
|
cb_arg = task->step_cb_arg;
|
|
|
|
TAILQ_INSERT_HEAD(&ch->task_pool, task, link);
|
|
|
|
if (cb_fn != NULL) {
|
|
|
|
cb_fn(cb_arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!TAILQ_EMPTY(&seq->tasks)) {
|
|
|
|
task = TAILQ_FIRST(&seq->tasks);
|
|
|
|
TAILQ_REMOVE(&seq->tasks, task, seq_link);
|
|
|
|
cb_fn = task->step_cb_fn;
|
|
|
|
cb_arg = task->step_cb_arg;
|
|
|
|
TAILQ_INSERT_HEAD(&ch->task_pool, task, link);
|
|
|
|
if (cb_fn != NULL) {
|
|
|
|
cb_fn(cb_arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
accel_sequence_complete(struct spdk_accel_sequence *seq, int status)
|
|
|
|
{
|
|
|
|
SPDK_DEBUGLOG(accel, "Completed sequence: %p with status: %d\n", seq, status);
|
|
|
|
|
|
|
|
/* First notify all users that appended operations to this sequence */
|
|
|
|
accel_sequence_complete_tasks(seq);
|
|
|
|
|
|
|
|
/* Then notify the user that finished the sequence */
|
|
|
|
seq->cb_fn(seq->cb_arg, status);
|
|
|
|
|
|
|
|
accel_sequence_put(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
accel_process_sequence(struct spdk_accel_sequence *seq)
|
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = seq->ch;
|
|
|
|
struct spdk_accel_module_if *module;
|
|
|
|
struct spdk_io_channel *module_ch;
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
task = TAILQ_FIRST(&seq->tasks);
|
|
|
|
if (task == NULL) {
|
|
|
|
/* We've processed all tasks */
|
|
|
|
accel_sequence_complete(seq, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SPDK_DEBUGLOG(accel, "Executing %s operation, sequence: %p\n",
|
|
|
|
g_opcode_strings[task->op_code], seq);
|
|
|
|
|
|
|
|
module = g_modules_opc[task->op_code];
|
|
|
|
module_ch = accel_ch->module_ch[task->op_code];
|
|
|
|
|
|
|
|
rc = module->submit_tasks(module_ch, task);
|
|
|
|
if (spdk_unlikely(rc != 0)) {
|
|
|
|
SPDK_ERRLOG("Failed to submit %s operation, sequence: %p\n",
|
|
|
|
g_opcode_strings[task->op_code], seq);
|
|
|
|
accel_sequence_complete(seq, rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
accel_sequence_task_cb(void *cb_arg, int status)
|
|
|
|
{
|
|
|
|
struct spdk_accel_sequence *seq = cb_arg;
|
|
|
|
struct spdk_accel_task *task = TAILQ_FIRST(&seq->tasks);
|
|
|
|
struct accel_io_channel *accel_ch = seq->ch;
|
|
|
|
|
|
|
|
/* spdk_accel_task_complete() puts the task back to the task pool, but we don't want to do
|
|
|
|
* that if a task is part of a sequence. Removing the task from that pool here is the
|
|
|
|
* easiest way to prevent this, even though it is a bit hacky.
|
|
|
|
*/
|
|
|
|
assert(task != NULL);
|
|
|
|
TAILQ_REMOVE(&accel_ch->task_pool, task, link);
|
|
|
|
|
|
|
|
TAILQ_REMOVE(&seq->tasks, task, seq_link);
|
|
|
|
TAILQ_INSERT_TAIL(&seq->completed, task, seq_link);
|
|
|
|
|
|
|
|
if (spdk_unlikely(status != 0)) {
|
|
|
|
SPDK_ERRLOG("Failed to execute %s operation, sequence: %p\n",
|
|
|
|
g_opcode_strings[task->op_code], seq);
|
|
|
|
accel_sequence_complete(seq, status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
accel_process_sequence(seq);
|
|
|
|
}
|
|
|
|
|
2022-11-17 17:39:58 +00:00
|
|
|
static bool
|
|
|
|
accel_compare_iovs(struct iovec *iova, uint32_t iovacnt, struct iovec *iovb, uint32_t iovbcnt)
|
|
|
|
{
|
|
|
|
/* For now, just do a dumb check that the iovecs arrays are exactly the same */
|
|
|
|
if (iovacnt != iovbcnt) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return memcmp(iova, iovb, sizeof(*iova) * iovacnt) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
accel_sequence_merge_tasks(struct spdk_accel_sequence *seq, struct spdk_accel_task *task,
|
|
|
|
struct spdk_accel_task **next_task)
|
|
|
|
{
|
|
|
|
struct spdk_accel_task *next = *next_task;
|
|
|
|
|
|
|
|
switch (task->op_code) {
|
|
|
|
case ACCEL_OPC_COPY:
|
|
|
|
/* We only allow changing src of operations that actually have a src, e.g. we never
|
|
|
|
* do it for fill. Theoretically, it is possible, but we'd have to be careful to
|
|
|
|
* change the src of the operation after fill (which in turn could also be a fill).
|
|
|
|
* So, for the sake of simplicity, skip this type of operations for now.
|
|
|
|
*/
|
|
|
|
if (next->op_code != ACCEL_OPC_DECOMPRESS &&
|
|
|
|
next->op_code != ACCEL_OPC_COPY) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (task->dst_domain != next->src_domain) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!accel_compare_iovs(task->d.iovs, task->d.iovcnt,
|
|
|
|
next->s.iovs, next->s.iovcnt)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
next->s.iovs = task->s.iovs;
|
|
|
|
next->s.iovcnt = task->s.iovcnt;
|
|
|
|
next->src_domain = task->src_domain;
|
|
|
|
TAILQ_REMOVE(&seq->tasks, task, seq_link);
|
|
|
|
TAILQ_INSERT_TAIL(&seq->completed, task, seq_link);
|
|
|
|
break;
|
|
|
|
case ACCEL_OPC_DECOMPRESS:
|
|
|
|
/* We can only merge tasks when one of them is a copy */
|
|
|
|
if (next->op_code != ACCEL_OPC_COPY) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (task->dst_domain != next->src_domain) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!accel_compare_iovs(task->d.iovs, task->d.iovcnt,
|
|
|
|
next->s.iovs, next->s.iovcnt)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
task->d.iovs = next->d.iovs;
|
|
|
|
task->d.iovcnt = next->d.iovcnt;
|
|
|
|
task->dst_domain = next->dst_domain;
|
|
|
|
/* We're removing next_task from the tasks queue, so we need to update its pointer,
|
|
|
|
* so that the TAILQ_FOREACH_SAFE() loop below works correctly */
|
|
|
|
*next_task = TAILQ_NEXT(next, seq_link);
|
|
|
|
TAILQ_REMOVE(&seq->tasks, next, seq_link);
|
|
|
|
TAILQ_INSERT_TAIL(&seq->completed, next, seq_link);
|
|
|
|
break;
|
|
|
|
case ACCEL_OPC_FILL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0 && "bad opcode");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
int
|
|
|
|
spdk_accel_sequence_finish(struct spdk_accel_sequence *seq,
|
|
|
|
spdk_accel_completion_cb cb_fn, void *cb_arg)
|
|
|
|
{
|
2022-11-17 17:39:58 +00:00
|
|
|
struct spdk_accel_task *task, *next;
|
|
|
|
|
|
|
|
/* Try to remove any copy operations if possible */
|
|
|
|
TAILQ_FOREACH_SAFE(task, &seq->tasks, seq_link, next) {
|
|
|
|
if (next == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
accel_sequence_merge_tasks(seq, task, &next);
|
|
|
|
}
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
|
|
|
|
/* Since we store copy operations' buffers as iovecs, we need to convert them to scalar
|
|
|
|
* buffers, as that's what accel modules expect
|
|
|
|
*/
|
|
|
|
TAILQ_FOREACH(task, &seq->tasks, seq_link) {
|
|
|
|
if (task->op_code != ACCEL_OPC_COPY) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spdk_unlikely(task->s.iovcnt != 1 || task->d.iovcnt != 1)) {
|
|
|
|
SPDK_ERRLOG("Unable to set buffer of a copy operation due "
|
|
|
|
"to iovcnt!=1\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
task->nbytes = spdk_min(task->s.iovs[0].iov_len,
|
|
|
|
task->d.iovs[0].iov_len);
|
|
|
|
task->src = task->s.iovs[0].iov_base;
|
|
|
|
task->dst = task->d.iovs[0].iov_base;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq->cb_fn = cb_fn;
|
|
|
|
seq->cb_arg = cb_arg;
|
|
|
|
|
|
|
|
accel_process_sequence(seq);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_accel_sequence_reverse(struct spdk_accel_sequence *seq)
|
|
|
|
{
|
2022-11-23 09:36:25 +00:00
|
|
|
struct accel_sequence_tasks tasks = TAILQ_HEAD_INITIALIZER(tasks);
|
|
|
|
struct spdk_accel_task *task;
|
|
|
|
|
|
|
|
assert(TAILQ_EMPTY(&seq->completed));
|
|
|
|
TAILQ_SWAP(&tasks, &seq->tasks, spdk_accel_task, seq_link);
|
|
|
|
|
|
|
|
while (!TAILQ_EMPTY(&tasks)) {
|
|
|
|
task = TAILQ_FIRST(&tasks);
|
|
|
|
TAILQ_REMOVE(&tasks, task, seq_link);
|
|
|
|
TAILQ_INSERT_HEAD(&seq->tasks, task, seq_link);
|
|
|
|
}
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_accel_sequence_abort(struct spdk_accel_sequence *seq)
|
|
|
|
{
|
|
|
|
if (seq == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
accel_sequence_complete_tasks(seq);
|
|
|
|
accel_sequence_put(seq);
|
|
|
|
}
|
2022-08-05 19:25:33 +00:00
|
|
|
|
|
|
|
static struct spdk_accel_module_if *
|
|
|
|
_module_find_by_name(const char *name)
|
|
|
|
{
|
|
|
|
struct spdk_accel_module_if *accel_module = NULL;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(accel_module, &spdk_accel_module_list, tailq) {
|
|
|
|
if (strcmp(name, accel_module->name) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return accel_module;
|
|
|
|
}
|
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Helper function when when accel modules register with the framework. */
|
2022-06-22 21:35:04 +00:00
|
|
|
void
|
|
|
|
spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
2022-08-05 19:25:33 +00:00
|
|
|
if (_module_find_by_name(accel_module->name)) {
|
|
|
|
SPDK_NOTICELOG("Accel module %s already registered\n", accel_module->name);
|
|
|
|
assert(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that the software module is at the head of the list, this
|
|
|
|
* will assure that all opcodes are later assigned to software first and
|
2022-08-08 21:43:24 +00:00
|
|
|
* then udpated to HW modules as they are registered.
|
2022-08-05 19:25:33 +00:00
|
|
|
*/
|
|
|
|
if (strcmp(accel_module->name, "software") == 0) {
|
|
|
|
TAILQ_INSERT_HEAD(&spdk_accel_module_list, accel_module, tailq);
|
|
|
|
} else {
|
|
|
|
TAILQ_INSERT_TAIL(&spdk_accel_module_list, accel_module, tailq);
|
|
|
|
}
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
if (accel_module->get_ctx_size && accel_module->get_ctx_size() > g_max_accel_module_size) {
|
|
|
|
g_max_accel_module_size = accel_module->get_ctx_size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Framework level channel create callback. */
|
2020-02-05 17:10:05 +00:00
|
|
|
static int
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_create_channel(void *io_device, void *ctx_buf)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = ctx_buf;
|
2020-08-11 18:17:14 +00:00
|
|
|
struct spdk_accel_task *accel_task;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
struct spdk_accel_sequence *seq;
|
2022-11-29 11:38:53 +00:00
|
|
|
struct accel_buffer *buf;
|
2020-08-11 18:17:14 +00:00
|
|
|
uint8_t *task_mem;
|
2022-11-29 11:51:22 +00:00
|
|
|
int i = 0, j, rc;
|
2020-08-11 18:17:14 +00:00
|
|
|
|
|
|
|
accel_ch->task_pool_base = calloc(MAX_TASKS_PER_CHANNEL, g_max_accel_module_size);
|
|
|
|
if (accel_ch->task_pool_base == NULL) {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
accel_ch->seq_pool_base = calloc(MAX_TASKS_PER_CHANNEL, sizeof(struct spdk_accel_sequence));
|
|
|
|
if (accel_ch->seq_pool_base == NULL) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2022-11-29 11:38:53 +00:00
|
|
|
accel_ch->buf_pool_base = calloc(MAX_TASKS_PER_CHANNEL, sizeof(struct accel_buffer));
|
|
|
|
if (accel_ch->buf_pool_base == NULL) {
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2020-08-11 18:17:14 +00:00
|
|
|
TAILQ_INIT(&accel_ch->task_pool);
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
TAILQ_INIT(&accel_ch->seq_pool);
|
2022-11-29 11:38:53 +00:00
|
|
|
TAILQ_INIT(&accel_ch->buf_pool);
|
2020-08-11 18:17:14 +00:00
|
|
|
task_mem = accel_ch->task_pool_base;
|
|
|
|
for (i = 0 ; i < MAX_TASKS_PER_CHANNEL; i++) {
|
|
|
|
accel_task = (struct spdk_accel_task *)task_mem;
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
seq = &accel_ch->seq_pool_base[i];
|
2022-11-29 11:38:53 +00:00
|
|
|
buf = &accel_ch->buf_pool_base[i];
|
2020-08-11 18:17:14 +00:00
|
|
|
TAILQ_INSERT_TAIL(&accel_ch->task_pool, accel_task, link);
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
TAILQ_INSERT_TAIL(&accel_ch->seq_pool, seq, link);
|
2022-11-29 11:38:53 +00:00
|
|
|
TAILQ_INSERT_TAIL(&accel_ch->buf_pool, buf, link);
|
2020-08-11 18:17:14 +00:00
|
|
|
task_mem += g_max_accel_module_size;
|
|
|
|
}
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
/* Assign modules and get IO channels for each */
|
2022-03-09 22:21:42 +00:00
|
|
|
for (i = 0; i < ACCEL_OPC_LAST; i++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
accel_ch->module_ch[i] = g_modules_opc[i]->get_io_channel();
|
2022-04-19 22:09:18 +00:00
|
|
|
/* This can happen if idxd runs out of channels. */
|
2022-08-08 21:43:24 +00:00
|
|
|
if (accel_ch->module_ch[i] == NULL) {
|
2022-08-05 19:54:16 +00:00
|
|
|
goto err;
|
2022-03-09 22:21:42 +00:00
|
|
|
}
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-29 11:51:22 +00:00
|
|
|
rc = spdk_iobuf_channel_init(&accel_ch->iobuf, "accel", ACCEL_SMALL_CACHE_SIZE,
|
|
|
|
ACCEL_LARGE_CACHE_SIZE);
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Failed to initialize iobuf accel channel\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
return 0;
|
2022-08-05 19:54:16 +00:00
|
|
|
err:
|
2022-03-09 22:21:42 +00:00
|
|
|
for (j = 0; j < i; j++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
spdk_put_io_channel(accel_ch->module_ch[j]);
|
2022-03-09 22:21:42 +00:00
|
|
|
}
|
2022-04-19 22:09:18 +00:00
|
|
|
free(accel_ch->task_pool_base);
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
free(accel_ch->seq_pool_base);
|
2022-11-29 11:38:53 +00:00
|
|
|
free(accel_ch->buf_pool_base);
|
2022-04-19 22:09:18 +00:00
|
|
|
return -ENOMEM;
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2020-02-05 21:31:16 +00:00
|
|
|
/* Framework level channel destroy callback. */
|
2020-02-05 17:10:05 +00:00
|
|
|
static void
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_destroy_channel(void *io_device, void *ctx_buf)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
|
|
|
struct accel_io_channel *accel_ch = ctx_buf;
|
2022-03-09 22:21:42 +00:00
|
|
|
int i;
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-11-29 11:51:22 +00:00
|
|
|
spdk_iobuf_channel_fini(&accel_ch->iobuf);
|
|
|
|
|
2022-03-09 22:21:42 +00:00
|
|
|
for (i = 0; i < ACCEL_OPC_LAST; i++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
assert(accel_ch->module_ch[i] != NULL);
|
|
|
|
spdk_put_io_channel(accel_ch->module_ch[i]);
|
|
|
|
accel_ch->module_ch[i] = NULL;
|
2021-10-14 20:53:53 +00:00
|
|
|
}
|
2022-03-09 22:21:42 +00:00
|
|
|
|
2020-08-11 18:17:14 +00:00
|
|
|
free(accel_ch->task_pool_base);
|
accel: initial operation chaining support
This patch introduces the concept of chaining multiple accel operations
and executing them all at once in a single step. This means that it
will be possible to schedule accel operations at different layers of the
stack (e.g. copy in NVMe-oF transport, crypto in bdev_crypto), but
execute them all in a single place. Thanks to this, we can take
advantage of hardware accelerators that supports executing multiple
operations as a single operation (e.g. copy + crypto).
This operation group is called spdk_accel_sequence and operations can be
appended to that object via one of the spdk_accel_append_* functions.
New operations are always added at the end of a sequence. Users can
specify a callback to be notified when a particular operation in a
sequence is completed, but they don't receive the status of whether it
was successful or not. This is by design, as they shouldn't care about
the status of an individual operation and should rely on other means to
receive the status of the whole sequence. It's also important to note
that any intermediate steps within a sequence may not produce observable
results. For instance, appending a copy from A to B and then a copy
from B to C, it's indeterminate whether A's data will be in B after a
sequence is executed. It is only guaranteed that A's data will be in C.
A sequence can also be reversed using spdk_accel_sequence_reverse(),
meaning that the first operation becomes last and vice versa. It's
especially useful in read paths, as it makes it possible to build the
sequence during submission, then, once the data is read from storage,
reverse the sequence and execute it.
Finally, there are two ways to terminate a sequence: aborting or
executing. It can be aborted via spdk_accel_sequence_abort() which will
execute individual operations' callbacks and free any allocated
resources. To execute it, one must use spdk_accel_sequence_finish().
For now, each operation is executed one by one and is submitted to the
appropriate accel module. Executing multiple operations as a single one
will be added in the future.
Also, currently, only fill and copy operations can be appended to a
sequence. Support for more operations will be added in subsequent
patches.
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id35d093e14feb59b996f780ef77e000e10bfcd20
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15529
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
2022-11-16 07:22:55 +00:00
|
|
|
free(accel_ch->seq_pool_base);
|
2022-11-29 11:38:53 +00:00
|
|
|
free(accel_ch->buf_pool_base);
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct spdk_io_channel *
|
2022-08-08 20:51:25 +00:00
|
|
|
spdk_accel_get_io_channel(void)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
|
|
|
return spdk_get_io_channel(&spdk_accel_module_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_module_initialize(void)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *accel_module;
|
2020-02-05 17:10:05 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
TAILQ_FOREACH(accel_module, &spdk_accel_module_list, tailq) {
|
|
|
|
accel_module->module_init();
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2022-08-08 20:51:25 +00:00
|
|
|
spdk_accel_initialize(void)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
2022-03-09 22:21:42 +00:00
|
|
|
enum accel_opcode op;
|
2022-08-05 19:25:33 +00:00
|
|
|
struct spdk_accel_module_if *accel_module = NULL;
|
2022-10-21 14:09:30 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = spdk_memory_domain_create(&g_accel_domain, SPDK_DMA_DEVICE_TYPE_ACCEL, NULL,
|
|
|
|
"SPDK_ACCEL_DMA_DEVICE");
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Failed to create accel memory domain\n");
|
|
|
|
return rc;
|
|
|
|
}
|
2022-03-09 22:21:42 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
g_modules_started = true;
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_module_initialize();
|
2020-06-16 13:56:16 +00:00
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
/* Create our priority global map of opcodes to modules, we populate starting
|
|
|
|
* with the software module (guaranteed to be first on the list) and then
|
|
|
|
* updating opcodes with HW modules that have been initilaized.
|
2022-11-02 15:09:36 +00:00
|
|
|
* NOTE: all opcodes must be supported by software in the event that no HW
|
2022-08-08 21:43:24 +00:00
|
|
|
* modules are initilaized to support the operation.
|
2022-03-09 22:21:42 +00:00
|
|
|
*/
|
2022-08-05 19:25:33 +00:00
|
|
|
TAILQ_FOREACH(accel_module, &spdk_accel_module_list, tailq) {
|
2022-03-09 22:21:42 +00:00
|
|
|
for (op = 0; op < ACCEL_OPC_LAST; op++) {
|
2022-08-05 19:25:33 +00:00
|
|
|
if (accel_module->supports_opcode(op)) {
|
2022-08-08 21:43:24 +00:00
|
|
|
g_modules_opc[op] = accel_module;
|
2022-08-05 19:25:33 +00:00
|
|
|
SPDK_DEBUGLOG(accel, "OPC 0x%x now assigned to %s\n", op, accel_module->name);
|
2022-03-09 22:21:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-01 00:13:04 +00:00
|
|
|
|
|
|
|
/* Now lets check for overrides and apply all that exist */
|
|
|
|
for (op = 0; op < ACCEL_OPC_LAST; op++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
if (g_modules_opc_override[op] != NULL) {
|
|
|
|
accel_module = _module_find_by_name(g_modules_opc_override[op]);
|
2022-08-05 19:25:33 +00:00
|
|
|
if (accel_module == NULL) {
|
2022-08-08 21:43:24 +00:00
|
|
|
SPDK_ERRLOG("Invalid module name of %s\n", g_modules_opc_override[op]);
|
2022-10-21 14:09:30 +00:00
|
|
|
rc = -EINVAL;
|
|
|
|
goto error;
|
2022-06-01 00:13:04 +00:00
|
|
|
}
|
2022-08-05 19:25:33 +00:00
|
|
|
if (accel_module->supports_opcode(op) == false) {
|
2022-08-08 21:43:24 +00:00
|
|
|
SPDK_ERRLOG("Module %s does not support op code %d\n", accel_module->name, op);
|
2022-10-21 14:09:30 +00:00
|
|
|
rc = -EINVAL;
|
|
|
|
goto error;
|
2022-06-01 00:13:04 +00:00
|
|
|
}
|
2022-08-08 21:43:24 +00:00
|
|
|
g_modules_opc[op] = accel_module;
|
2022-06-01 00:13:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-09 22:21:42 +00:00
|
|
|
#ifdef DEBUG
|
2022-04-19 22:09:18 +00:00
|
|
|
for (op = 0; op < ACCEL_OPC_LAST; op++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
assert(g_modules_opc[op] != NULL);
|
2022-03-09 22:21:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
2022-11-29 11:51:22 +00:00
|
|
|
rc = spdk_iobuf_register_module("accel");
|
|
|
|
if (rc != 0) {
|
|
|
|
SPDK_ERRLOG("Failed to register accel iobuf module\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
/*
|
2022-08-08 20:51:25 +00:00
|
|
|
* We need a unique identifier for the accel framework, so use the
|
2022-03-09 22:21:42 +00:00
|
|
|
* spdk_accel_module_list address for this purpose.
|
2020-02-05 17:10:05 +00:00
|
|
|
*/
|
2022-08-08 20:51:25 +00:00
|
|
|
spdk_io_device_register(&spdk_accel_module_list, accel_create_channel, accel_destroy_channel,
|
|
|
|
sizeof(struct accel_io_channel), "accel");
|
2020-02-05 17:10:05 +00:00
|
|
|
|
|
|
|
return 0;
|
2022-10-21 14:09:30 +00:00
|
|
|
error:
|
|
|
|
spdk_memory_domain_destroy(g_accel_domain);
|
|
|
|
|
|
|
|
return rc;
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_module_finish_cb(void)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
|
|
|
spdk_accel_fini_cb cb_fn = g_fini_cb_fn;
|
|
|
|
|
2022-10-21 14:09:30 +00:00
|
|
|
spdk_memory_domain_destroy(g_accel_domain);
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
cb_fn(g_fini_cb_arg);
|
|
|
|
g_fini_cb_fn = NULL;
|
|
|
|
g_fini_cb_arg = NULL;
|
|
|
|
}
|
|
|
|
|
2022-10-04 18:50:44 +00:00
|
|
|
static void
|
|
|
|
accel_write_overridden_opc(struct spdk_json_write_ctx *w, const char *opc_str,
|
|
|
|
const char *module_str)
|
|
|
|
{
|
|
|
|
spdk_json_write_object_begin(w);
|
|
|
|
spdk_json_write_named_string(w, "method", "accel_assign_opc");
|
|
|
|
spdk_json_write_named_object_begin(w, "params");
|
|
|
|
spdk_json_write_named_string(w, "opname", opc_str);
|
|
|
|
spdk_json_write_named_string(w, "module", module_str);
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
spdk_json_write_object_end(w);
|
|
|
|
}
|
|
|
|
|
2020-02-08 18:23:09 +00:00
|
|
|
void
|
|
|
|
spdk_accel_write_config_json(struct spdk_json_write_ctx *w)
|
|
|
|
{
|
2022-08-08 21:43:24 +00:00
|
|
|
struct spdk_accel_module_if *accel_module;
|
2022-10-04 18:50:44 +00:00
|
|
|
int i;
|
2020-04-27 15:45:46 +00:00
|
|
|
|
|
|
|
/*
|
2020-07-28 17:51:20 +00:00
|
|
|
* The accel fw has no config, there may be some in
|
2022-08-08 21:43:24 +00:00
|
|
|
* the modules though.
|
2020-04-27 15:45:46 +00:00
|
|
|
*/
|
2020-05-20 11:23:12 +00:00
|
|
|
spdk_json_write_array_begin(w);
|
2022-08-08 21:43:24 +00:00
|
|
|
TAILQ_FOREACH(accel_module, &spdk_accel_module_list, tailq) {
|
|
|
|
if (accel_module->write_config_json) {
|
|
|
|
accel_module->write_config_json(w);
|
2020-04-27 15:45:46 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-04 18:50:44 +00:00
|
|
|
for (i = 0; i < ACCEL_OPC_LAST; i++) {
|
|
|
|
if (g_modules_opc_override[i]) {
|
|
|
|
accel_write_overridden_opc(w, g_opcode_strings[i], g_modules_opc_override[i]);
|
|
|
|
}
|
|
|
|
}
|
2020-05-20 11:23:12 +00:00
|
|
|
spdk_json_write_array_end(w);
|
2020-02-08 18:23:09 +00:00
|
|
|
}
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
void
|
2022-08-08 20:36:34 +00:00
|
|
|
spdk_accel_module_finish(void)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
2022-08-08 21:43:24 +00:00
|
|
|
if (!g_accel_module) {
|
|
|
|
g_accel_module = TAILQ_FIRST(&spdk_accel_module_list);
|
2020-02-05 17:10:05 +00:00
|
|
|
} else {
|
2022-08-08 21:43:24 +00:00
|
|
|
g_accel_module = TAILQ_NEXT(g_accel_module, tailq);
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
if (!g_accel_module) {
|
2022-08-08 20:51:25 +00:00
|
|
|
accel_module_finish_cb();
|
2020-02-05 17:10:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-08 21:43:24 +00:00
|
|
|
if (g_accel_module->module_fini) {
|
|
|
|
spdk_thread_send_msg(spdk_get_thread(), g_accel_module->module_fini, NULL);
|
2020-02-05 17:10:05 +00:00
|
|
|
} else {
|
2022-08-08 20:36:34 +00:00
|
|
|
spdk_accel_module_finish();
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-08-08 20:51:25 +00:00
|
|
|
spdk_accel_finish(spdk_accel_fini_cb cb_fn, void *cb_arg)
|
2020-02-05 17:10:05 +00:00
|
|
|
{
|
2022-06-01 00:13:04 +00:00
|
|
|
enum accel_opcode op;
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
assert(cb_fn != NULL);
|
|
|
|
|
|
|
|
g_fini_cb_fn = cb_fn;
|
|
|
|
g_fini_cb_arg = cb_arg;
|
|
|
|
|
2022-06-01 00:13:04 +00:00
|
|
|
for (op = 0; op < ACCEL_OPC_LAST; op++) {
|
2022-08-08 21:43:24 +00:00
|
|
|
if (g_modules_opc_override[op] != NULL) {
|
|
|
|
free(g_modules_opc_override[op]);
|
|
|
|
g_modules_opc_override[op] = NULL;
|
2022-06-01 00:13:04 +00:00
|
|
|
}
|
2022-08-08 21:43:24 +00:00
|
|
|
g_modules_opc[op] = NULL;
|
2022-06-01 00:13:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-05 17:10:05 +00:00
|
|
|
spdk_io_device_unregister(&spdk_accel_module_list, NULL);
|
2022-08-08 20:36:34 +00:00
|
|
|
spdk_accel_module_finish();
|
2020-02-05 17:10:05 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 17:51:20 +00:00
|
|
|
SPDK_LOG_REGISTER_COMPONENT(accel)
|