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

accel: add driver init/fini callbacks



This allows drivers to allocate/free any resources it requires for
operation.

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatar <eugene.kobyak@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 0a4a5235
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -256,6 +256,12 @@ struct spdk_accel_driver {
	/** Name of the driver. */
	const char *name;

	/** Initializes the driver, called when accel initializes.  Optional. */
	int (*init)(void);

	/** Performs cleanup on resources allocated by the driver.  Optional. */
	void (*fini)(void);

	/**
	 * Executes a sequence of accel operations.  The driver should notify accel about each
	 * completed task using `spdk_accel_task_complete()`.  Once all tasks are completed or the
+14 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "spdk/crc32.h"
#include "spdk/util.h"
#include "spdk/hexlify.h"
#include "spdk/string.h"

/* Accelerator Framework: The following provides a top level
 * generic API for the accelerator functions defined here. Modules,
@@ -2526,6 +2527,15 @@ spdk_accel_initialize(void)
		return rc;
	}

	if (g_accel_driver != NULL && g_accel_driver->init != NULL) {
		rc = g_accel_driver->init();
		if (rc != 0) {
			SPDK_ERRLOG("Failed to initialize driver %s: %s\n", g_accel_driver->name,
				    spdk_strerror(-rc));
			return rc;
		}
	}

	/* The module list is order by priority, with the highest priority modules being at the end
	 * of the list.  The software module should be somewhere at the beginning of the list,
	 * before all HW modules.
@@ -2711,6 +2721,10 @@ spdk_accel_module_finish(void)
	}

	if (!g_accel_module) {
		if (g_accel_driver != NULL && g_accel_driver->fini != NULL) {
			g_accel_driver->fini();
		}

		spdk_spin_destroy(&g_keyring_spin);
		spdk_spin_destroy(&g_stats_lock);
		if (g_accel_domain) {