Commit d58a2f6c authored by paul luse's avatar paul luse Committed by Tomasz Zawadzki
Browse files

lib/accel: support multiple accel modules (aka engines) at once



We enable multiple engines by:

* getting rid of the globals that point to the one available HW
and one available SW engine

* adding a submit_tasks() entry point for the SW engine so that
it is treated like any other engine allowing us to just call
submit_tasks() to the assigned engine for the opcode instead of
checking what is supported

* changing the definition of engine capabilities from
"HW accelerated" to simply "supported"

* during init, use a global (g_engines_opc) that contains engines
and is indexed by opcode so we know what the best engine is for each
op code

* future patches will add RPC's to override engine priorities or
specifically assign an opcode(s) to an engine.

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


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
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>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 8f9b9775
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@ struct spdk_accel_task;
void spdk_accel_task_complete(struct spdk_accel_task *task, int status);

struct accel_io_channel {
	struct spdk_accel_engine	*engine;
	struct spdk_io_channel		*engine_ch;
	struct spdk_io_channel		*sw_engine_ch;
	struct spdk_io_channel		*engine_ch[ACCEL_OPC_LAST];
	void				*task_pool_base;
	TAILQ_HEAD(, spdk_accel_task)	task_pool;
};
@@ -85,9 +83,11 @@ struct spdk_accel_task {
};

struct spdk_accel_engine {
	const char *name;
	bool (*supports_opcode)(enum accel_opcode);
	struct spdk_io_channel *(*get_io_channel)(void);
	int (*submit_tasks)(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task);
	TAILQ_ENTRY(spdk_accel_engine) tailq;
};

struct spdk_accel_module_if {
@@ -118,7 +118,7 @@ struct spdk_accel_module_if {
	TAILQ_ENTRY(spdk_accel_module_if)	tailq;
};

void spdk_accel_hw_engine_register(struct spdk_accel_engine *accel_engine);
void spdk_accel_engine_register(struct spdk_accel_engine *accel_engine);
void spdk_accel_module_list_add(struct spdk_accel_module_if *accel_module);

#define SPDK_ACCEL_MODULE_REGISTER(init_fn, fini_fn, config_json, ctx_size_fn)				\
+226 −165

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
	spdk_accel_write_config_json;

	# functions needed by modules
	spdk_accel_hw_engine_register;
	spdk_accel_engine_register;
	spdk_accel_module_list_add;
	spdk_accel_task_complete;

+7 −4
Original line number Diff line number Diff line
@@ -130,7 +130,9 @@ static void
idxd_done(void *cb_arg, int status)
{
	struct spdk_accel_task *accel_task = cb_arg;
	struct idxd_io_channel *chan = spdk_io_channel_get_ctx(accel_task->accel_ch->engine_ch);
	struct idxd_io_channel *chan;

	chan = spdk_io_channel_get_ctx(accel_task->accel_ch->engine_ch[accel_task->op_code]);

	assert(chan->num_outstanding > 0);
	spdk_trace_record(TRACE_IDXD_OP_COMPLETE, 0, 0, 0, chan->num_outstanding - 1);
@@ -302,7 +304,7 @@ idxd_poll(void *arg)

			TAILQ_INIT(&chan->queued_tasks);

			idxd_submit_tasks(task->accel_ch->engine_ch, task);
			idxd_submit_tasks(task->accel_ch->engine_ch[task->op_code], task);
		}
	}

@@ -332,6 +334,7 @@ idxd_supports_opcode(enum accel_opcode opc)
}

static struct spdk_accel_engine idxd_accel_engine = {
	.name			= "idxd",
	.supports_opcode	= idxd_supports_opcode,
	.get_io_channel		= idxd_get_io_channel,
	.submit_tasks		= idxd_submit_tasks,
@@ -419,8 +422,8 @@ accel_engine_idxd_init(void)
	}

	g_idxd_initialized = true;
	SPDK_NOTICELOG("Accel engine updated to use IDXD DSA engine.\n");
	spdk_accel_hw_engine_register(&idxd_accel_engine);
	SPDK_NOTICELOG("Accel framework IDXD engine initialized.\n");
	spdk_accel_engine_register(&idxd_accel_engine);
	spdk_io_device_register(&idxd_accel_engine, idxd_create_cb, idxd_destroy_cb,
				sizeof(struct idxd_io_channel), "idxd_accel_engine");
	return 0;
+3 −2
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ ioat_submit_tasks(struct spdk_io_channel *ch, struct spdk_accel_task *accel_task
}

static struct spdk_accel_engine ioat_accel_engine = {
	.name			= "ioat",
	.supports_opcode	= ioat_supports_opcode,
	.get_io_channel		= ioat_get_io_channel,
	.submit_tasks		= ioat_submit_tasks,
@@ -289,8 +290,8 @@ accel_engine_ioat_init(void)
	}

	g_ioat_initialized = true;
	SPDK_NOTICELOG("Accel engine updated to use IOAT engine.\n");
	spdk_accel_hw_engine_register(&ioat_accel_engine);
	SPDK_NOTICELOG("Accel framework IOAT engine initialized.\n");
	spdk_accel_engine_register(&ioat_accel_engine);
	spdk_io_device_register(&ioat_accel_engine, ioat_create_cb, ioat_destroy_cb,
				sizeof(struct ioat_io_channel), "ioat_accel_engine");
	return 0;
Loading