Commit 7b0f452b authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

accel: add iobuf channel to accel channel



It will be used for allocating buffers from accel domain and
allocating bounce buffers to push/pull the data from memory domains for
modules that don't support memory domains.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Idbe4d2129d0aff87d9e517214e9f81e8470c5088
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15745


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d3ac42ca
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -40,3 +40,4 @@ static struct spdk_subsystem g_spdk_subsystem_accel = {
};

SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_accel);
SPDK_SUBSYSTEM_DEPEND(accel, iobuf)
+14 −2
Original line number Diff line number Diff line
@@ -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,8 +1695,14 @@ 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();
	}