diff --git a/lib/accel/accel.c b/lib/accel/accel.c index 42cdc4330..b3af19e10 100644 --- a/lib/accel/accel.c +++ b/lib/accel/accel.c @@ -28,6 +28,8 @@ #define ALIGN_4K 0x1000 #define MAX_TASKS_PER_CHANNEL 0x800 +#define ACCEL_SMALL_CACHE_SIZE 128 +#define ACCEL_LARGE_CACHE_SIZE 16 /* Largest context size for all accel modules */ static size_t g_max_accel_module_size = sizeof(struct spdk_accel_task); @@ -57,6 +59,7 @@ struct accel_io_channel { struct spdk_accel_sequence *seq_pool_base; TAILQ_HEAD(, spdk_accel_task) task_pool; TAILQ_HEAD(, spdk_accel_sequence) seq_pool; + struct spdk_iobuf_channel iobuf; }; TAILQ_HEAD(accel_sequence_tasks, spdk_accel_task); @@ -1002,7 +1005,7 @@ accel_create_channel(void *io_device, void *ctx_buf) struct spdk_accel_task *accel_task; struct spdk_accel_sequence *seq; uint8_t *task_mem; - int i = 0, j; + int i = 0, j, rc; accel_ch->task_pool_base = calloc(MAX_TASKS_PER_CHANNEL, g_max_accel_module_size); if (accel_ch->task_pool_base == NULL) { @@ -1034,6 +1037,13 @@ accel_create_channel(void *io_device, void *ctx_buf) } } + 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; + } + return 0; err: for (j = 0; j < i; j++) { @@ -1051,6 +1061,8 @@ accel_destroy_channel(void *io_device, void *ctx_buf) struct accel_io_channel *accel_ch = ctx_buf; int i; + spdk_iobuf_channel_fini(&accel_ch->iobuf); + for (i = 0; i < ACCEL_OPC_LAST; i++) { assert(accel_ch->module_ch[i] != NULL); spdk_put_io_channel(accel_ch->module_ch[i]); @@ -1132,6 +1144,12 @@ spdk_accel_initialize(void) assert(g_modules_opc[op] != NULL); } #endif + rc = spdk_iobuf_register_module("accel"); + if (rc != 0) { + SPDK_ERRLOG("Failed to register accel iobuf module\n"); + goto error; + } + /* * We need a unique identifier for the accel framework, so use the * spdk_accel_module_list address for this purpose. diff --git a/mk/spdk.lib_deps.mk b/mk/spdk.lib_deps.mk index 915993451..48cbea439 100644 --- a/mk/spdk.lib_deps.mk +++ b/mk/spdk.lib_deps.mk @@ -146,7 +146,7 @@ DEPDIRS-bdev_xnvme := $(BDEV_DEPS_THREAD) # These depdirs include subsystem interdependencies which # are not related to symbols, but are defined directly in # the SPDK event subsystem code. -DEPDIRS-event_accel := init accel +DEPDIRS-event_accel := init accel event_iobuf DEPDIRS-event_vmd := init vmd $(JSON_LIBS) log thread util DEPDIRS-event_bdev := init bdev event_accel event_vmd event_sock event_iobuf diff --git a/module/event/subsystems/Makefile b/module/event/subsystems/Makefile index fe58c887d..882edc242 100644 --- a/module/event/subsystems/Makefile +++ b/module/event/subsystems/Makefile @@ -19,6 +19,7 @@ DIRS-$(CONFIG_VFIO_USER) += vfu_tgt # the subsystem dependency tree defined within the event subsystem C files # themselves. Should that tree change, these dependencies should change # accordingly. +DEPDIRS-accel := iobuf DEPDIRS-bdev := accel vmd sock iobuf DEPDIRS-iscsi := scsi DEPDIRS-nbd := bdev diff --git a/module/event/subsystems/accel/accel.c b/module/event/subsystems/accel/accel.c index 337457966..b2aca4d97 100644 --- a/module/event/subsystems/accel/accel.c +++ b/module/event/subsystems/accel/accel.c @@ -40,3 +40,4 @@ static struct spdk_subsystem g_spdk_subsystem_accel = { }; SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_accel); +SPDK_SUBSYSTEM_DEPEND(accel, iobuf) diff --git a/test/unit/lib/accel/accel.c/accel_ut.c b/test/unit/lib/accel/accel.c/accel_ut.c index 129921282..9fc539431 100644 --- a/test/unit/lib/accel/accel.c/accel_ut.c +++ b/test/unit/lib/accel/accel.c/accel_ut.c @@ -1667,6 +1667,12 @@ test_sequence_setup(void) allocate_threads(1); set_thread(0); + rc = spdk_iobuf_initialize(); + if (rc != 0) { + CU_ASSERT(false); + return -1; + } + rc = spdk_accel_initialize(); if (rc != 0) { CU_ASSERT(false); @@ -1677,7 +1683,7 @@ test_sequence_setup(void) } static void -accel_finish_cb(void *cb_arg) +finish_cb(void *cb_arg) { bool *done = cb_arg; @@ -1689,12 +1695,18 @@ test_sequence_cleanup(void) { bool done = false; - spdk_accel_finish(accel_finish_cb, &done); + spdk_accel_finish(finish_cb, &done); while (!done) { poll_threads(); } + done = false; + spdk_iobuf_finish(finish_cb, &done); + while (!done) { + poll_threads(); + } + free_threads(); free_cores();