From patchwork Thu Jun 27 10:06:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kundapura, Ganapati" X-Patchwork-Id: 141948 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 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 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 Acked-by: Akhil Goyal --- 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; From patchwork Thu Jun 27 10:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kundapura, Ganapati" X-Patchwork-Id: 141949 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 2CD8445502; Thu, 27 Jun 2024 12:08:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D1B540DDC; Thu, 27 Jun 2024 12:08:04 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by mails.dpdk.org (Postfix) with ESMTP id 76694402C6 for ; Thu, 27 Jun 2024 12:06:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719482791; x=1751018791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B52G3ckGxgjSEUH7pB9NTdtTmtMSOLyo945GHr7Tuv4=; b=fRWjtTGbkN4E3zqgoPkkZUbTi1qXsGvyblaBd4T+n1WbQzsAhuVEWSdT QP3L3RPAiWlsMP6xATs92d0vRbPXzx8c/lPRtLv+KtXOuRcULsuiQDXQJ DVacYrJo1EDLGC24DKKVovm6EgJhEwUN099Gw/WKraIu9yXiGdYLmuILo NGgBjk/ACr2oLfCQ6WsVJ9j3znDcMTK8vsqdXsB9pKAozm4pWQl5zQYe0 1Zm9v0J1XVASr2gwgRInMDgPAMUkcNqvn81Ao3piDTQ7QBsIV7POJhU7M 35OiLnjjqWCfVLAppxOeC+S/+KOPbSAjXtHuQN9Pe0QjqAx0xCTVGIcxl w==; X-CSE-ConnectionGUID: ItHfJtYsSk2v6jiqy9AzEQ== X-CSE-MsgGUID: QZTc6R7fSJCAX7L6T1RRsQ== X-IronPort-AV: E=McAfee;i="6700,10204,11115"; a="27221042" X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="27221042" 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: nqTC+cLlS9uG3wdz01RDJA== X-CSE-MsgGUID: 8dnhZiypSa2St3LXyleS2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,269,1712646000"; d="scan'208";a="48685639" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by fmviesa003.fm.intel.com with ESMTP; 27 Jun 2024 03:06:29 -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: Thu, 27 Jun 2024 05:06:26 -0500 Message-Id: <20240627100626.2430162-2-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20240627100626.2430162-1-ganapati.kundapura@intel.com> References: <20240626220028.2260003-1-ganapati.kundapura@intel.com> <20240627100626.2430162-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;