Commit 1f88c365 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/accel: fallback when no devices during module_init()



Related to #3266

During discussion in issue above, it came up that if
dpdk_compressdev and dpdk_cryptodev detects no devices
they are still assigned to the relevant accel ops.

Rather than explicitly failing just due to lack of
the devices, each accel module can report -ENODEV.
In such case the module will not be used, but that
error is not propagated to accel framework init.

As a result accel ops assignment will not use such module,
and fallback to available modules.

Reported-by: default avatarliuqinfei <lucas.liuqinfei@huawei.com>
Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ib52dfcb6dc6a1a93b8493b98ffb028f9d9419d6d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22026


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 98d67bf9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -173,6 +173,10 @@ struct spdk_accel_module_if {
	/**
	 * Initialization function for the module.  Called by the application during startup.
	 *
	 * Return 0 on success or negative error code. If -ENODEV is returned - the module
	 * will not be used to handle any operation, but the error will not stop framework
	 * initialization.
	 *
	 * Modules are required to define this function.
	 */
	int	(*module_init)(void);
+5 −2
Original line number Diff line number Diff line
@@ -2679,11 +2679,14 @@ accel_module_initialize(void)
	TAILQ_FOREACH_SAFE(accel_module, &spdk_accel_module_list, tailq, tmp_module) {
		module_rc = accel_module->module_init();
		if (module_rc) {
			SPDK_ERRLOG("Module %s initialization failed with %d\n", accel_module->name, module_rc);
			TAILQ_REMOVE(&spdk_accel_module_list, accel_module, tailq);
			if (!rc) {
			if (module_rc == -ENODEV) {
				SPDK_NOTICELOG("No devices for module %s, skipping\n", accel_module->name);
			} else if (!rc) {
				SPDK_ERRLOG("Module %s initialization failed with %d\n", accel_module->name, module_rc);
				rc = module_rc;
			}
			continue;
		}

		SPDK_DEBUGLOG(accel, "Module %s initialized.\n", accel_module->name);
+3 −4
Original line number Diff line number Diff line
@@ -252,10 +252,10 @@ accel_init_compress_drivers(void)
	struct compress_dev *device;
	int rc;

	/* If we have no compression devices, there's no reason to continue. */
	/* If we have no compression devices, report error to fallback on other modules. */
	cdev_count = rte_compressdev_count();
	if (cdev_count == 0) {
		return 0;
		return -ENODEV;
	}
	if (cdev_count > RTE_COMPRESS_MAX_DEVS) {
		SPDK_ERRLOG("invalid device count from rte_compressdev_count()\n");
@@ -706,8 +706,7 @@ accel_compress_init(void)
	rc = accel_init_compress_drivers();
	if (rc) {
		assert(TAILQ_EMPTY(&g_compress_devs));
		SPDK_NOTICELOG("no available compression devices\n");
		return -EINVAL;
		return rc;
	}

	g_compressdev_initialized = true;
+3 −3
Original line number Diff line number Diff line
@@ -1153,12 +1153,12 @@ accel_dpdk_cryptodev_init(void)
			       "Keep going...\n", ACCEL_DPDK_CRYPTODEV_AESNI_MB, rc, ACCEL_DPDK_CRYPTODEV_AESNI_MB);
	}

	/* If we have no crypto devices, there's no reason to continue. */
	/* If we have no crypto devices, report error to fallback on other modules. */
	cdev_count = rte_cryptodev_count();
	SPDK_NOTICELOG("Found crypto devices: %d\n", (int)cdev_count);
	if (cdev_count == 0) {
		return 0;
		return -ENODEV;
	}
	SPDK_NOTICELOG("Found crypto devices: %d\n", (int)cdev_count);

	g_mbuf_offset = rte_mbuf_dynfield_register(&rte_mbuf_dynfield_io_context);
	if (g_mbuf_offset < 0) {
+1 −2
Original line number Diff line number Diff line
@@ -441,8 +441,7 @@ accel_dsa_init(void)
	}

	if (TAILQ_EMPTY(&g_dsa_devices)) {
		SPDK_NOTICELOG("no available dsa devices\n");
		return -EINVAL;
		return -ENODEV;
	}

	g_dsa_initialized = true;
Loading