From 721f606d4b5fb398a4fe0e2bb51397df75f255d1 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Mon, 14 Nov 2022 11:05:00 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15431 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- module/bdev/crypto/vbdev_crypto.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/module/bdev/crypto/vbdev_crypto.c b/module/bdev/crypto/vbdev_crypto.c index 11b615eee..f42f7fa7b 100644 --- a/module/bdev/crypto/vbdev_crypto.c +++ b/module/bdev/crypto/vbdev_crypto.c @@ -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;