From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9D80C25B74 for ; Thu, 30 May 2024 14:49:25 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9CAF40A6D; Thu, 30 May 2024 16:49:24 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id AC73D40691 for ; Thu, 30 May 2024 16:49:23 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id A2C4F219DB; Thu, 30 May 2024 16:49:22 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [EXTERNAL] [PATCH v2 1/2] crypto: fix build issues on unsetting crypto callbacks macro X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Thu, 30 May 2024 16:49:19 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F4DC@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [EXTERNAL] [PATCH v2 1/2] crypto: fix build issues on unsetting crypto callbacks macro Thread-Index: AQHasdY+VQlBT0PFPEGB76JakVCKkLGvbqWAgAAvM4CAAAlH0IAAA0yAgAAm7yCAAAfO0A== References: <20240416081222.3002268-1-ganapati.kundapura@intel.com> <20240529144025.4089318-1-ganapati.kundapura@intel.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Kundapura, Ganapati" , "Akhil Goyal" , , "Gujjar, Abhinandan S" , , , "Richardson, Bruce" , 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 > From: Kundapura, Ganapati [mailto:ganapati.kundapura@intel.com] > Sent: Thursday, 30 May 2024 16.22 >=20 > Hi, >=20 > > From: Akhil Goyal > > Sent: Thursday, May 30, 2024 5:17 PM > > > > > > > #if may not be needed in application. > > > > > Test should be skipped if API is not available/supported. > > > > > > > > It's needed otherwise application developer has to check the > > > implementation for supported/not supported or else run the = application > > > to get to know whether api is supported or not. > > > > > > > Application is always required to check the return value or else it = will > miss the > > other errors that the API can return. > Currently RTE_CRYPTO_CALLBACKS is enabled by default and test = application > checks the > return value of the APIs. This patch fixes build issues on compiling = the DPDK > with unsetting > RTE_CRYPTO_CALLBACKS. > > > > > > > > diff --git a/lib/cryptodev/rte_cryptodev.c > > > > > > b/lib/cryptodev/rte_cryptodev.c index 886eb7a..2e0890f = 100644 > > > > > > --- a/lib/cryptodev/rte_cryptodev.c > > > > > > +++ b/lib/cryptodev/rte_cryptodev.c > > > > > > @@ -628,6 +628,7 @@ > > > > rte_cryptodev_asym_xform_capability_check_hash( > > > > > > return ret; > > > > > > } > > > > > > > > > > > > +#if RTE_CRYPTO_CALLBACKS > > > > > > /* spinlock for crypto device enq callbacks */ static > > > > > > rte_spinlock_t rte_cryptodev_callback_lock =3D > > > > > RTE_SPINLOCK_INITIALIZER; > > > > > > > > > > > > @@ -744,6 +745,7 @@ cryptodev_cb_init(struct rte_cryptodev = *dev) > > > > > > cryptodev_cb_cleanup(dev); > > > > > > return -ENOMEM; > > > > > > } > > > > > > +#endif /* RTE_CRYPTO_CALLBACKS */ > > > > > > > > > > > > > > > > @@ -1485,6 +1491,7 @@ rte_cryptodev_queue_pair_setup(uint8_t > > > > dev_id, > > > > > > uint16_t queue_pair_id, > > > > > > socket_id); > > > > > > } > > > > > > > > > > > > +#if RTE_CRYPTO_CALLBACKS > > > > > > struct rte_cryptodev_cb * > > > > > > rte_cryptodev_add_enq_callback(uint8_t dev_id, > > > > > > uint16_t qp_id, > > > > > > @@ -1763,6 +1770,7 @@ > > rte_cryptodev_remove_deq_callback(uint8_t > > > > dev_id, > > > > > > rte_spinlock_unlock(&rte_cryptodev_callback_lock); > > > > > > return ret; > > > > > > } > > > > > > +#endif /* RTE_CRYPTO_CALLBACKS */ > > > > > > > > > > There is an issue here. > > > > > The APIs are visible in .h file and are available for = application to > use. > > > > > But the API implementation is compiled out. > > > > > Rather, you should add a return ENOTSUP from the beginning of = the > > > > > APIs if RTE_CRYPTO_CALLBACKS is enabled. > > > > > With this approach application will not need to put #if in its = code. > > > API declarations wrapped under the macro changes in next patch. > > > > No, that is not the correct way. Application should check the return = value. > > And we cannot force it to add ifdefs. > Test application is indeed checking the return value. Ifdefs are added = to > avoid build issues on compiling with RTE_CRYPTO_CALLBACKS is turned = off > Which is on by default. The test application should be able to build and run, regardless if the = DPDK library was built with RTE_CRYPTO_CALLBACKS defined or not. The test application should not assume that the DPDK library was built = with the same RTE_CRYPTO_CALLBACKS configuration (i.e. defined or not) = as the test application. > Even ethdev callbacks also doesn't return -ENOTSUP > on setting/unsetting RTE_ETHDEV_RXTX_CALLBACKS config. That would be a bug in the ethdev library. I just checked the ethdev source code (/source/lib/ethdev/rte_ethdev.c), = and all the add/remove rx/tx callback functions fail with ENOTSUP if = RTE_ETHDEV_RXTX_CALLBACKS is not defined. Please note that some ethdev callbacks are not rx/tx callbacks, and thus = are not gated by RTE_ETHDEV_RXTX_CALLBACKS.