From patchwork Wed Jun 26 22:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kundapura, Ganapati" X-Patchwork-Id: 141914 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCF6A454FC; Thu, 27 Jun 2024 00:00:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CAD7A4027F; Thu, 27 Jun 2024 00:00:35 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id D4E0540272 for ; Thu, 27 Jun 2024 00:00:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719439234; x=1750975234; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JO2CT1hs8UEm8luj+/3CGR5GjMVQrMPi631Z0WqW3Kk=; b=e1D5jI+d+vIfKIdGOKyoyC8X5Tn0Yld3tXmMTnhtcPN207a04WZ7hxEL 3wda+MdzTqfkUXFwGWYsq+L4sz/GjEimCuFxHyTCxVWHxjqBdMYv26x7+ rmQTzVcQ2cma/IGDp+QeGluzCgiP7biqO8fXRa3EWARuYwOzo6S1Q5JvW wpeEW+iCsObNWhur3hB8AEXIVvcWs7/oVSEQnFMpjCY8QlHz8twUJ0pH7 TvP9+NboYI2ilhxmokApBZJRZxpCL2bpnBAUvbvz7cPh3aUMgQZ4rGj29 sqpSFx/Xpr2awre/iZhnYtI+ET0NDKvDl1dN/8gNWOI7ggbAcg1isQeFE w==; X-CSE-ConnectionGUID: dNBIEqrJR9Wj0GYEiKQ8Ag== X-CSE-MsgGUID: 8mFQ4nwHQbeL+f93vzyaFA== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="16282528" X-IronPort-AV: E=Sophos;i="6.08,268,1712646000"; d="scan'208";a="16282528" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 15:00:33 -0700 X-CSE-ConnectionGUID: R6GGkwovQ1C6uqw8SxzbFA== X-CSE-MsgGUID: MqjsMokkT5WJ4gozNRrOZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,268,1712646000"; d="scan'208";a="74912229" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orviesa002.jf.intel.com with ESMTP; 26 Jun 2024 15:00:31 -0700 From: Ganapati Kundapura To: dev@dpdk.org, gakhil@marvell.com, abhinandan.gujjar@intel.com, john.mcnamara@intel.com, bruce.richardson@intel.com Cc: mb@smartsharesystems.com, ferruh.yigit@amd.com, fanzhang.oss@gmail.com, thomas@monjalon.net, bala.senthil@intel.com Subject: [PATCH v3 1/2] cryptodev: fix crypto callbacks on unsetting callbacks macro Date: Wed, 26 Jun 2024 17:00:27 -0500 Message-Id: <20240626220028.2260003-1-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20240529144025.4089318-1-ganapati.kundapura@intel.com> References: <20240529144025.4089318-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Crypto callbacks APIs are available in header files but when the macro RTE_CRYPTO_CALLBACKS unset, test application need to put #ifdef in its code. The test application should be able to build and run, regardless DPDK library is built with RTE_CRYPTO_CALLBACKS defined or not. Added ENOTSUP from the beginning of the APIs implementation if RTE_CRYPTO_CALLBACKS macro is unset/undefined. Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks") Fixes: 5523a75af539 ("test/crypto: add case for enqueue/dequeue callbacks") Signed-off-by: Ganapati Kundapura --- v3: * Added NOTSUP from the beginning of the APIs diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 94438c5..7dca2c9 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -118,6 +118,18 @@ struct crypto_unittest_params { for (j = index; j < index + num_blk_types; j++) \ free_blockcipher_test_suite(parent_ts.unit_test_suites[j]) +#define TEST_SKIP_LOG(cond, msg, ...) do { \ + if ((cond)) { \ + RTE_LOG(ERR, CRYPTODEV, "%s line %d: " \ + msg "\n", __func__, __LINE__, ##__VA_ARGS__); \ + RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__); \ + return TEST_SKIPPED; \ + } \ +} while (0) + +#define TEST_SKIP(a, b, msg, ...) \ + TEST_SKIP_LOG(a == b, msg, ##__VA_ARGS__) + /* * Forward declarations. */ @@ -14754,7 +14766,7 @@ test_enq_callback_setup(void) struct rte_cryptodev_cb *cb; uint16_t qp_id = 0; - int j = 0; + int j = 0, ret; /* Verify the crypto capabilities for which enqueue/dequeue is done. */ cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; @@ -14794,6 +14806,7 @@ test_enq_callback_setup(void) /* Test with invalid crypto device */ cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS, qp_id, test_enq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, RTE_CRYPTO_MAX_DEVS); @@ -14802,6 +14815,7 @@ test_enq_callback_setup(void) cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0], dev_info.max_nb_queue_pairs + 1, test_enq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", dev_info.max_nb_queue_pairs + 1, @@ -14810,6 +14824,7 @@ test_enq_callback_setup(void) /* Test with NULL callback */ cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0], qp_id, NULL, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, ts_params->valid_devs[0]); @@ -14817,6 +14832,7 @@ test_enq_callback_setup(void) /* Test with valid configuration */ cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0], qp_id, test_enq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on " "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); @@ -14830,24 +14846,35 @@ test_enq_callback_setup(void) rte_delay_ms(10); /* Test with invalid crypto device */ - TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback( - RTE_CRYPTO_MAX_DEVS, qp_id, cb), + ret = rte_cryptodev_remove_enq_callback(RTE_CRYPTO_MAX_DEVS, + qp_id, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_FAIL(ret, "Expected call to fail as crypto device is invalid"); /* Test with invalid queue pair */ - TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback( - ts_params->valid_devs[0], - dev_info.max_nb_queue_pairs + 1, cb), + ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0], + dev_info.max_nb_queue_pairs + 1, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_FAIL(ret, "Expected call to fail as queue pair is invalid"); /* Test with NULL callback */ - TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback( - ts_params->valid_devs[0], qp_id, NULL), + ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0], + qp_id, + NULL); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_FAIL(ret, "Expected call to fail as callback is NULL"); /* Test with valid configuration */ - TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback( - ts_params->valid_devs[0], qp_id, cb), + ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0], + qp_id, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_SUCCESS(ret, "Failed test to remove callback on " "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); @@ -14869,7 +14896,7 @@ test_deq_callback_setup(void) struct rte_cryptodev_cb *cb; uint16_t qp_id = 0; - int j = 0; + int j = 0, ret; /* Verify the crypto capabilities for which enqueue/dequeue is done. */ cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; @@ -14909,6 +14936,7 @@ test_deq_callback_setup(void) /* Test with invalid crypto device */ cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS, qp_id, test_deq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, RTE_CRYPTO_MAX_DEVS); @@ -14917,6 +14945,7 @@ test_deq_callback_setup(void) cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0], dev_info.max_nb_queue_pairs + 1, test_deq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", dev_info.max_nb_queue_pairs + 1, @@ -14925,6 +14954,7 @@ test_deq_callback_setup(void) /* Test with NULL callback */ cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0], qp_id, NULL, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, ts_params->valid_devs[0]); @@ -14932,6 +14962,7 @@ test_deq_callback_setup(void) /* Test with valid configuration */ cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0], qp_id, test_deq_callback, NULL); + TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped"); TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on " "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); @@ -14945,24 +14976,36 @@ test_deq_callback_setup(void) rte_delay_ms(10); /* Test with invalid crypto device */ + ret = rte_cryptodev_remove_deq_callback(RTE_CRYPTO_MAX_DEVS, + qp_id, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback( RTE_CRYPTO_MAX_DEVS, qp_id, cb), "Expected call to fail as crypto device is invalid"); /* Test with invalid queue pair */ - TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback( - ts_params->valid_devs[0], - dev_info.max_nb_queue_pairs + 1, cb), + ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0], + dev_info.max_nb_queue_pairs + 1, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_FAIL(ret, "Expected call to fail as queue pair is invalid"); /* Test with NULL callback */ - TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback( - ts_params->valid_devs[0], qp_id, NULL), + ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0], + qp_id, + NULL); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_FAIL(ret, "Expected call to fail as callback is NULL"); /* Test with valid configuration */ - TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback( - ts_params->valid_devs[0], qp_id, cb), + ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0], + qp_id, + cb); + TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped"); + TEST_ASSERT_SUCCESS(ret, "Failed test to remove callback on " "qp %u on cryptodev %u", qp_id, ts_params->valid_devs[0]); diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 886eb7a..8a45ad7 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -1491,6 +1491,10 @@ rte_cryptodev_add_enq_callback(uint8_t dev_id, rte_cryptodev_callback_fn cb_fn, void *cb_arg) { +#ifdef RTE_CRYPTO_CALLBACKS + rte_errno = ENOTSUP; + return NULL; +#endif struct rte_cryptodev *dev; struct rte_cryptodev_cb_rcu *list; struct rte_cryptodev_cb *cb, *tail; @@ -1556,6 +1560,9 @@ rte_cryptodev_remove_enq_callback(uint8_t dev_id, uint16_t qp_id, struct rte_cryptodev_cb *cb) { +#ifdef RTE_CRYPTO_CALLBACKS + return -ENOTSUP; +#endif struct rte_cryptodev *dev; RTE_ATOMIC(struct rte_cryptodev_cb *) *prev_cb; struct rte_cryptodev_cb *curr_cb; @@ -1630,6 +1637,10 @@ rte_cryptodev_add_deq_callback(uint8_t dev_id, rte_cryptodev_callback_fn cb_fn, void *cb_arg) { +#ifdef RTE_CRYPTO_CALLBACKS + rte_errno = ENOTSUP; + return NULL; +#endif struct rte_cryptodev *dev; struct rte_cryptodev_cb_rcu *list; struct rte_cryptodev_cb *cb, *tail; @@ -1696,6 +1707,9 @@ rte_cryptodev_remove_deq_callback(uint8_t dev_id, uint16_t qp_id, struct rte_cryptodev_cb *cb) { +#ifdef RTE_CRYPTO_CALLBACKS + return -ENOTSUP; +#endif struct rte_cryptodev *dev; RTE_ATOMIC(struct rte_cryptodev_cb *) *prev_cb; struct rte_cryptodev_cb *curr_cb; From patchwork Wed Jun 26 22:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kundapura, Ganapati" X-Patchwork-Id: 141915 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F6F9454FC; Thu, 27 Jun 2024 00:00:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8BC640665; Thu, 27 Jun 2024 00:00:36 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id BA2F140272 for ; Thu, 27 Jun 2024 00:00:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719439235; x=1750975235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B52G3ckGxgjSEUH7pB9NTdtTmtMSOLyo945GHr7Tuv4=; b=YPa4BO/X13IosFddd8kucM3u33J3GCIStafYFX8zfxuwdekqemFKn43D qMBLnU7Qej5MapXoRw4f4NU7+/0dQRHyeX0Sj5jnuMfZOg/8J+Kw6d2qa kfgNzw6XwrHQu7YTCS9Xkf4b3RXIzZ/8qOii5zn3CKsOsa5K2dmirXAnb N8ROtEdymXFbptfSyXtWLybm17jRTPgEr9r8k4Bvx6QPpngIuAXyQTJDD qaw+TOlcR96psv5nOiIGzHVgu6y7a2sLELHvq1aan2FpW3Sy4QegF48sp xi94hwPJVCrfPhbXixWOv/6QN5vjAaJDZ9iS7pYzJGvpVg5+Prk+8N7B0 A==; X-CSE-ConnectionGUID: eRaQP21dSY+F+26pfmZFIA== X-CSE-MsgGUID: 9rR/1c8KTQysLZ8ntrzisQ== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="16282538" X-IronPort-AV: E=Sophos;i="6.08,268,1712646000"; d="scan'208";a="16282538" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 15:00:33 -0700 X-CSE-ConnectionGUID: puGJXELWRtmtDKYwawUKkA== X-CSE-MsgGUID: dtxKgeRFR9udtZXHIneMNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,268,1712646000"; d="scan'208";a="74912236" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orviesa002.jf.intel.com with ESMTP; 26 Jun 2024 15:00:32 -0700 From: Ganapati Kundapura To: dev@dpdk.org, gakhil@marvell.com, abhinandan.gujjar@intel.com, john.mcnamara@intel.com, bruce.richardson@intel.com Cc: mb@smartsharesystems.com, ferruh.yigit@amd.com, fanzhang.oss@gmail.com, thomas@monjalon.net, bala.senthil@intel.com Subject: [PATCH v3 2/2] cryptodev: validate crypto callbacks from next node Date: Wed, 26 Jun 2024 17:00:28 -0500 Message-Id: <20240626220028.2260003-2-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20240626220028.2260003-1-ganapati.kundapura@intel.com> References: <20240529144025.4089318-1-ganapati.kundapura@intel.com> <20240626220028.2260003-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Crypto callbacks are invoked on checking from head node which is always valid pointer. This patch checks next node from the head node if callbacks registered before invoking callbacks. Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks") Signed-off-by: Ganapati Kundapura --- v3: retained ifdef diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index c946f74..bec947f 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -1910,7 +1910,7 @@ rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id, nb_ops = fp_ops->dequeue_burst(qp, ops, nb_ops); #ifdef RTE_CRYPTO_CALLBACKS - if (unlikely(fp_ops->qp.deq_cb != NULL)) { + if (unlikely(fp_ops->qp.deq_cb[qp_id].next != NULL)) { struct rte_cryptodev_cb_rcu *list; struct rte_cryptodev_cb *cb; @@ -1977,7 +1977,7 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, fp_ops = &rte_crypto_fp_ops[dev_id]; qp = fp_ops->qp.data[qp_id]; #ifdef RTE_CRYPTO_CALLBACKS - if (unlikely(fp_ops->qp.enq_cb != NULL)) { + if (unlikely(fp_ops->qp.enq_cb[qp_id].next != NULL)) { struct rte_cryptodev_cb_rcu *list; struct rte_cryptodev_cb *cb;