bdev/crypto: separate out search for vbdev_dev

This patch is first in series that updates bdev crypto
to support DPDK 22.11. See changelog entry from DPDK:
* cryptodev: The structure ``rte_cryptodev_sym_session`` was made internal.
  The API ``rte_cryptodev_sym_session_init`` and
``rte_cryptodev_sym_session_clear``
  were removed and user would only need to call
``rte_cryptodev_sym_session_create``
  and ``rte_cryptodev_sym_session_free`` to create/destroy sessions.
  The API ``rte_cryptodev_sym_session_create`` was updated to take a single
mempool
  with element size big enough to hold session data and session private
data.

So this patch abstracts out lookup for vbdev_dev as it will be used from
multiple places later in the series.

Change-Id: Ibd9ca3456b297c84f8cec162fae27f4ef064cd42
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15431
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Tomasz Zawadzki 2022-11-14 11:05:00 +01:00 committed by Jim Harris
parent ec3ac8b823
commit 721f606d4b

View File

@ -1364,6 +1364,19 @@ vbdev_crypto_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
}
}
static struct vbdev_dev *
_vdev_dev_get(struct vbdev_crypto *vbdev)
{
struct vbdev_dev *device;
TAILQ_FOREACH(device, &g_vbdev_devs, link) {
if (strcmp(device->cdev_info.driver_name, vbdev->opts->drv_name) == 0) {
return device;
}
}
return NULL;
}
/* Callback for unregistering the IO device. */
static void
_device_unregister_cb(void *io_device)
@ -1849,7 +1862,6 @@ vbdev_crypto_claim(const char *bdev_name)
struct vbdev_crypto *vbdev;
struct vbdev_dev *device;
struct spdk_bdev *bdev;
bool found = false;
uint8_t key_size;
int rc = 0;
@ -1956,13 +1968,8 @@ vbdev_crypto_claim(const char *bdev_name)
}
/* To init the session we have to get the cryptoDev device ID for this vbdev */
TAILQ_FOREACH(device, &g_vbdev_devs, link) {
if (strcmp(device->cdev_info.driver_name, vbdev->opts->drv_name) == 0) {
found = true;
break;
}
}
if (found == false) {
device = _vdev_dev_get(vbdev);
if (!device) {
SPDK_ERRLOG("Failed to match crypto device driver to crypto vbdev.\n");
rc = -EINVAL;
goto error_cant_find_devid;