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: Yuriy 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: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Yuriy Umanets 2022-01-20 11:32:21 +02:00 committed by Tomasz Zawadzki
parent 706d2c1dc1
commit 03d9c67139

View File

@ -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);