Commit 03d9c671 authored by Yuriy Umanets's avatar Yuriy Umanets Committed by Tomasz Zawadzki
Browse files

bdev/crypto: Error handling in create_vbdev_dev()



- Properly rte_cryptodev_stop() and rte_cryptodev_close() device on
  errors in create_vbdev_dev().
- Check for device id before removing its qp from the qp list.
- Maintain correct g_qat_total_qp counter if qat qp is removed on
  errors.

Signed-off-by: default avatarYuriy Umanets <yumanets@nvidia.com>
Change-Id: I088d7057eebff89ff0d995adcc2a05c724c3323b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11622


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 706d2c1d
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ create_vbdev_dev(uint8_t index, uint16_t num_lcores)
			SPDK_ERRLOG("Failed to setup queue pair %u on "
				    "cryptodev %u\n", j, cdev_id);
			rc = -EINVAL;
			goto err;
			goto err_qp_setup;
		}
	}

@@ -318,7 +318,7 @@ create_vbdev_dev(uint8_t index, uint16_t num_lcores)
		SPDK_ERRLOG("Failed to start device %u: error %d\n",
			    cdev_id, rc);
		rc = -EINVAL;
		goto err;
		goto err_dev_start;
	}

	/* Select the right device/qp list based on driver name
@@ -329,8 +329,10 @@ create_vbdev_dev(uint8_t index, uint16_t num_lcores)
	} else if (strcmp(device->cdev_info.driver_name, AESNI_MB) == 0) {
		dev_qp_head = (struct device_qps *)&g_device_qp_aesni_mb;
	} else {
		SPDK_ERRLOG("Failed to start device %u. Invalid driver name \"%s\"\n",
			    cdev_id, device->cdev_info.driver_name);
		rc = -EINVAL;
		goto err;
		goto err_invalid_drv_name;
	}

	/* Build up lists of device/qp combinations per PMD */
@@ -355,9 +357,20 @@ create_vbdev_dev(uint8_t index, uint16_t num_lcores)
	return 0;
err_qp_alloc:
	TAILQ_FOREACH_SAFE(dev_qp, dev_qp_head, link, tmp_qp) {
		if (dev_qp->device->cdev_id != device->cdev_id) {
			continue;
		}
		TAILQ_REMOVE(dev_qp_head, dev_qp, link);
		if (dev_qp_head == (struct device_qps *)&g_device_qp_qat) {
			g_qat_total_qp--;
		}
		free(dev_qp);
	}
err_invalid_drv_name:
	rte_cryptodev_stop(cdev_id);
err_dev_start:
err_qp_setup:
	rte_cryptodev_close(cdev_id);
err:
	free(device);