From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30DB345502; Thu, 27 Jun 2024 12:08:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6332740BA0; Thu, 27 Jun 2024 12:08:03 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mails.dpdk.org (Postfix) with ESMTP id CF7BD402C6 for ; Thu, 27 Jun 2024 12:06:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719482790; x=1751018790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n6IVu1KJLaJU1FQ3CRcpyAUuLEgvCZ7eaxU39esaDhc=; b=MZzt1qHzvSmbukM9EFLTxMQb+m8cQ80lXnhqk+8wdwYZfx93nMvP9qri CBMLYDfX6r1mrm+QQM8wegBYZqgVzNEwNQQUZ/1v9vCiIgvjqdfj2x4tp PEAHWSkYjs7+x0mk7bxdAU+va1agR+5zoEm0t1qoZXaSxVBF/e8Oud4fF Qncz0Evz+lhPJSw1/IACcVKR2Iiufqd3szCzi3ML/gewGCHn0GRpkwKZM BDylksNZryKoru5J9igwyMIdf1nI1K1iKx0DNB2d3SYfU71cE/PuLcHcg 5z6aWBENWpPXpjXT1KHWXxl23TZyfn9q5VbV8HxgJyZCE3gbl3DczOjXL A==; X-CSE-ConnectionGUID: euX/rXK5Q7Goiz1nuTErCQ== X-CSE-MsgGUID: P9Ftnw6lQoup1KV05R1L1Q== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="27221035" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="27221035" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2024 03:06:29 -0700 X-CSE-ConnectionGUID: /zq84RqfTlqGRq8PeRgQtA== X-CSE-MsgGUID: xMZV1xZAQjm04S9Lo16whA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="48685632" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by fmviesa003.fm.intel.com with ESMTP; 27 Jun 2024 03:06:28 -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 v4 1/2] cryptodev: fix crypto callbacks on unsetting callbacks macro Date: Thu, 27 Jun 2024 05:06:25 -0500 Message-Id: <20240627100626.2430162-1-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20240626220028.2260003-1-ganapati.kundapura@intel.com> References: <20240626220028.2260003-1-ganapati.kundapura@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- v4: * replaced ifdef with ifndef in APIs implementation * Removed TEST_SKIP macro * checked for ENOTSUP for first usage only 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..6d57ea1 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -14794,6 +14794,12 @@ 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); + if (rte_errno == ENOTSUP) { + RTE_LOG(ERR, USER1, "%s line %d: " + "rte_cryptodev_add_enq_callback() " + "Not supported, skipped\n", __func__, __LINE__); + return TEST_SKIPPED; + } TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, RTE_CRYPTO_MAX_DEVS); @@ -14909,6 +14915,12 @@ 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); + if (rte_errno == ENOTSUP) { + RTE_LOG(ERR, USER1, "%s line %d: " + "rte_cryptodev_add_deq_callback() " + "Not supported, skipped\n", __func__, __LINE__); + return TEST_SKIPPED; + } TEST_ASSERT_NULL(cb, "Add callback on qp %u on " "cryptodev %u did not fail", qp_id, RTE_CRYPTO_MAX_DEVS); diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 886eb7a..682c9f4 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) { +#ifndef 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) { +#ifndef 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) { +#ifndef 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) { +#ifndef RTE_CRYPTO_CALLBACKS + return -ENOTSUP; +#endif struct rte_cryptodev *dev; RTE_ATOMIC(struct rte_cryptodev_cb *) *prev_cb; struct rte_cryptodev_cb *curr_cb; -- 2.6.4