Hi > -----Original Message----- > From: Akhil Goyal <gak...@marvell.com> > Sent: Thursday, May 30, 2024 4:32 PM > To: Kundapura, Ganapati <ganapati.kundap...@intel.com>; dev@dpdk.org; > Gujjar, Abhinandan S <abhinandan.guj...@intel.com>; ferruh.yi...@amd.com; > tho...@monjalon.net; Richardson, Bruce <bruce.richard...@intel.com>; > fanzhang....@gmail.com; ciara.po...@intel.com; Morten Brørup > <m...@smartsharesystems.com> > Subject: RE: [EXTERNAL] [PATCH v2 1/2] crypto: fix build issues on unsetting > crypto callbacks macro > > ++ Morten for comment on #if vs #ifdef > > > > Subject: [EXTERNAL] [PATCH v2 1/2] crypto: fix build issues on > > > unsetting crypto callbacks macro > > > > > > Crypto callbacks macro is defined with value 1 and being used with > > > ifdef, on config value is changed to 0 to disable, crypto callback > > > changes still being compiled. > > > > > > Used #if instead of #ifdef and also wrapped crypto callback changes > > > under RTE_CRYPTO_CALLBACKS macro to fix build issues when macro is > > > unset. > > > > > > Fixes: 1c3ffb95595e ("cryptodev: add enqueue and dequeue callbacks") > > > Fixes: 5523a75af539 ("test/crypto: add case for enqueue/dequeue > > > callbacks") > > > > > > Signed-off-by: Ganapati Kundapura <ganapati.kundap...@intel.com> > > > --- > > > v2: > > > * Used #if instead of #ifdef and restored macro definition in config > > > * Split callback registration check in a seperate patch > > > > > > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c > > > index 1703ebc..72cf77f 100644 > > > --- a/app/test/test_cryptodev.c > > > +++ b/app/test/test_cryptodev.c > > > @@ -14547,6 +14547,7 @@ test_null_burst_operation(void) > > > return TEST_SUCCESS; > > > } > > > > > > +#if RTE_CRYPTO_CALLBACKS > > > static uint16_t > > > test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op > **ops, > > > uint16_t nb_ops, void *user_param) @@ -14784,6 > +14785,7 @@ > > > test_deq_callback_setup(void) > > > > > > return TEST_SUCCESS; > > > } > > > +#endif /* RTE_CRYPTO_CALLBACKS */ > > > > > > static void > > > generate_gmac_large_plaintext(uint8_t *data) @@ -18069,8 +18071,10 > > > @@ static struct unit_test_suite cryptodev_gen_testsuite = { > > > TEST_CASE_ST(ut_setup, ut_teardown, > > > > test_device_configure_invalid_queue_pair_ids), > > > TEST_CASE_ST(ut_setup, ut_teardown, test_stats), > > > +#if RTE_CRYPTO_CALLBACKS > > > TEST_CASE_ST(ut_setup, ut_teardown, > test_enq_callback_setup), > > > TEST_CASE_ST(ut_setup, ut_teardown, > test_deq_callback_setup), > > > +#endif > > > TEST_CASES_END() /**< NULL terminate unit test array */ > > > } > > > }; > > > > #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.
> > > 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 = > > 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.