DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] crypto: fix build issues on crypto callbacks macro undefined
@ 2024-04-16  8:12 Ganapati Kundapura
  2024-04-16  9:16 ` Gujjar, Abhinandan S
                   ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Ganapati Kundapura @ 2024-04-16  8:12 UTC (permalink / raw)
  To: dev; +Cc: abhinandan.gujjar, ciara.power, gakhil, fanzhang.oss

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.

Defined crypto callbacks macro without value, undef to disable

Wrapped crypto callback changes with RTE_CRYPTO_CALLBACKS macro
to fix build issues when macro is undefined.

As callback head nodes have valid pointer, this patch checks the next
node from the head if callbacks registered.

Fixes: 1c3ffb9 ("cryptodev: add enqueue and dequeue callbacks")
Fixes: 5523a75 ("test/crypto: add case for enqueue/dequeue callbacks")

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 1703ebccf1..1a592f2302 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;
 }
 
+#ifdef 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),
+#ifdef 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 */
 	}
 };
diff --git a/config/rte_config.h b/config/rte_config.h
index dd7bb0d35b..b647a69ba8 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -72,7 +72,7 @@
 /* cryptodev defines */
 #define RTE_CRYPTO_MAX_DEVS 64
 #define RTE_CRYPTODEV_NAME_LEN 64
-#define RTE_CRYPTO_CALLBACKS 1
+#define RTE_CRYPTO_CALLBACKS	/* No Value, undef/comment out to disable */
 
 /* compressdev defines */
 #define RTE_COMPRESS_MAX_DEVS 64
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 886eb7adc4..5f3b17a517 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;
 }
 
+#ifdef 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 */
 
 const char *
 rte_cryptodev_get_feature_name(uint64_t flag)
@@ -1244,9 +1246,11 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 	if (*dev->dev_ops->dev_configure == NULL)
 		return -ENOTSUP;
 
+#ifdef RTE_CRYPTO_CALLBACKS
 	rte_spinlock_lock(&rte_cryptodev_callback_lock);
 	cryptodev_cb_cleanup(dev);
 	rte_spinlock_unlock(&rte_cryptodev_callback_lock);
+#endif
 
 	/* Setup new number of queue pairs and reconfigure device. */
 	diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
@@ -1257,6 +1261,7 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		return diag;
 	}
 
+#ifdef RTE_CRYPTO_CALLBACKS
 	rte_spinlock_lock(&rte_cryptodev_callback_lock);
 	diag = cryptodev_cb_init(dev);
 	rte_spinlock_unlock(&rte_cryptodev_callback_lock);
@@ -1264,6 +1269,7 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
 		CDEV_LOG_ERR("Callback init failed for dev_id=%d", dev_id);
 		return diag;
 	}
+#endif
 
 	rte_cryptodev_trace_configure(dev_id, config);
 	return (*dev->dev_ops->dev_configure)(dev, config);
@@ -1485,6 +1491,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 			socket_id);
 }
 
+#ifdef 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 */
 
 int
 rte_cryptodev_stats_get(uint8_t dev_id, struct rte_cryptodev_stats *stats)
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 00ba6a234a..b811b458d5 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;
 
-- 
2.23.0


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2024-07-02 15:24 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16  8:12 [PATCH v1] crypto: fix build issues on crypto callbacks macro undefined Ganapati Kundapura
2024-04-16  9:16 ` Gujjar, Abhinandan S
2024-04-17 11:40 ` Power, Ciara
2024-05-22  8:51   ` Kundapura, Ganapati
2024-05-22  8:55     ` Akhil Goyal
2024-05-22 13:51       ` Akhil Goyal
2024-05-22 14:45         ` Kundapura, Ganapati
2024-05-22 18:36           ` Akhil Goyal
2024-05-23  8:54             ` Kundapura, Ganapati
2024-05-29  8:35 ` [EXTERNAL] " Akhil Goyal
2024-05-29  9:57   ` Kundapura, Ganapati
2024-05-29 11:40     ` Akhil Goyal
2024-05-29 14:40 ` [PATCH v2 1/2] crypto: fix build issues on unsetting crypto callbacks macro Ganapati Kundapura
2024-05-29 14:40   ` [PATCH v2 2/2] crypto: validate crypto callbacks from next node Ganapati Kundapura
2024-05-30  8:13     ` [EXTERNAL] " Akhil Goyal
2024-05-30  8:12   ` [EXTERNAL] [PATCH v2 1/2] crypto: fix build issues on unsetting crypto callbacks macro Akhil Goyal
2024-05-30 11:01     ` Akhil Goyal
2024-05-30 11:13       ` Morten Brørup
2024-05-30 11:41         ` Kundapura, Ganapati
2024-05-30 11:45           ` Morten Brørup
2024-05-30 11:40       ` Kundapura, Ganapati
2024-05-30 11:46         ` Akhil Goyal
2024-05-30 11:52           ` Morten Brørup
2024-05-30 14:22           ` Kundapura, Ganapati
2024-05-30 14:49             ` Morten Brørup
2024-06-06  9:44               ` Akhil Goyal
2024-06-13 18:03                 ` Akhil Goyal
2024-06-20 14:34                   ` Kundapura, Ganapati
2024-06-26  6:02                     ` Akhil Goyal
2024-06-26 22:04                       ` Kundapura, Ganapati
2024-06-26 22:00   ` [PATCH v3 1/2] cryptodev: fix crypto callbacks on unsetting " Ganapati Kundapura
2024-06-26 22:00     ` [PATCH v3 2/2] cryptodev: validate crypto callbacks from next node Ganapati Kundapura
2024-06-27  6:20     ` [EXTERNAL] [PATCH v3 1/2] cryptodev: fix crypto callbacks on unsetting callbacks macro Akhil Goyal
2024-06-27 10:15       ` Kundapura, Ganapati
2024-06-27 10:06     ` [PATCH v4 " Ganapati Kundapura
2024-06-27 10:06       ` [PATCH v3 2/2] cryptodev: validate crypto callbacks from next node Ganapati Kundapura
2024-07-02 15:24       ` [EXTERNAL] [PATCH v4 1/2] cryptodev: fix crypto callbacks on unsetting callbacks macro Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).