From 8ecf8dfcd7b53b468122e17366a0b2e42f3f28e8 Mon Sep 17 00:00:00 2001 From: Yuriy Umanets Date: Thu, 20 Jan 2022 11:07:52 +0200 Subject: [PATCH] bdev/crypto: Continue init after AESNI_MB failure - Continue init of the other crypto devices (mlx5) after failure of rte_vdev_init(AESNI_MB) in vbdev_crypto_init_crypto_drivers(). It simply may not be enabled in DPDK because it requires IPSec_MB>=1.0 installed in the system. Reproduces with --with-dpdk=dpdk/install option used, when the target DPDK is built without control of IPSec version from the SPDK side. - Updated crypto_ut to test the new behavior of error handling from rte_vdev_init(AESNI_MB) in vbdev_crypto_init_crypto_drivers(). Signed-off-by: Yuriy Umanets Change-Id: Icd4db8877afe87db8166c40d6e7b414cd43c9c25 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11624 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk Tested-by: SPDK CI Jenkins --- module/bdev/crypto/vbdev_crypto.c | 7 ++++--- test/unit/lib/bdev/crypto.c/crypto_ut.c | 27 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/module/bdev/crypto/vbdev_crypto.c b/module/bdev/crypto/vbdev_crypto.c index b24912193..bdfccb780 100644 --- a/module/bdev/crypto/vbdev_crypto.c +++ b/module/bdev/crypto/vbdev_crypto.c @@ -395,7 +395,7 @@ vbdev_crypto_init_crypto_drivers(void) { uint8_t cdev_count; uint8_t cdev_id; - int i, rc = 0; + int i, rc; struct vbdev_dev *device; struct vbdev_dev *tmp_dev; struct device_qp *dev_qp; @@ -412,8 +412,9 @@ vbdev_crypto_init_crypto_drivers(void) snprintf(aesni_args, sizeof(aesni_args), "max_nb_queue_pairs=%d", AESNI_MB_NUM_QP); rc = rte_vdev_init(AESNI_MB, aesni_args); if (rc) { - SPDK_ERRLOG("error creating virtual PMD %s\n", AESNI_MB); - return -EINVAL; + SPDK_NOTICELOG("Failed to create virtual PMD %s: error %d. " + "Possibly %s is not supported by DPDK library. " + "Keep going...\n", AESNI_MB, rc, AESNI_MB); } /* If we have no crypto devices, there's no reason to continue. */ diff --git a/test/unit/lib/bdev/crypto.c/crypto_ut.c b/test/unit/lib/bdev/crypto.c/crypto_ut.c index 8cb667f39..7288722ae 100644 --- a/test/unit/lib/bdev/crypto.c/crypto_ut.c +++ b/test/unit/lib/bdev/crypto.c/crypto_ut.c @@ -874,17 +874,8 @@ test_initdrivers(void) CU_ASSERT(g_session_mp == NULL); CU_ASSERT(g_session_mp_priv == NULL); - /* Test failure of DPDK dev init. */ - MOCK_SET(rte_cryptodev_count, 2); - MOCK_SET(rte_vdev_init, -1); - rc = vbdev_crypto_init_crypto_drivers(); - CU_ASSERT(rc == -EINVAL); - CU_ASSERT(g_mbuf_mp == NULL); - CU_ASSERT(g_session_mp == NULL); - CU_ASSERT(g_session_mp_priv == NULL); - MOCK_SET(rte_vdev_init, 0); - /* Can't create session pool. */ + MOCK_SET(rte_cryptodev_count, 2); MOCK_SET(spdk_mempool_create, NULL); rc = vbdev_crypto_init_crypto_drivers(); CU_ASSERT(rc == -ENOMEM); @@ -964,6 +955,22 @@ test_initdrivers(void) init_cleanup(); CU_ASSERT(rc == 0); + /* Test failure of DPDK dev init. By now it is not longer an error + * situation for entire crypto framework. */ + MOCK_SET(rte_cryptodev_count, 2); + MOCK_SET(rte_cryptodev_device_count_by_driver, 2); + MOCK_SET(rte_vdev_init, -1); + MOCK_CLEARED_ASSERT(spdk_mempool_create); + MOCK_SET(rte_cryptodev_info_get, MOCK_INFO_GET_1QP_QAT); + rc = vbdev_crypto_init_crypto_drivers(); + CU_ASSERT(rc == 0); + CU_ASSERT(g_mbuf_mp != NULL); + CU_ASSERT(g_session_mp != NULL); + CU_ASSERT(g_session_mp_priv != NULL); + init_cleanup(); + MOCK_SET(rte_vdev_init, 0); + MOCK_CLEAR(rte_cryptodev_device_count_by_driver); + /* restore our initial values. */ g_mbuf_mp = orig_mbuf_mp; g_session_mp = orig_session_mp;