DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ganapati Kundapura <ganapati.kundapura@intel.com>
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 1/2] cryptodev: fix crypto callbacks on unsetting callbacks macro
Date: Wed, 26 Jun 2024 17:00:27 -0500	[thread overview]
Message-ID: <20240626220028.2260003-1-ganapati.kundapura@intel.com> (raw)
In-Reply-To: <20240529144025.4089318-1-ganapati.kundapura@intel.com>

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 <ganapati.kundapura@intel.com>

---
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..7dca2c9 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -118,6 +118,18 @@ struct crypto_unittest_params {
 	for (j = index; j < index + num_blk_types; j++)				\
 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
 
+#define TEST_SKIP_LOG(cond, msg, ...) do {				\
+	if ((cond)) {							\
+		RTE_LOG(ERR, CRYPTODEV, "%s line %d: "			\
+			msg "\n", __func__, __LINE__, ##__VA_ARGS__);	\
+		RTE_TEST_TRACE_FAILURE(__FILE__, __LINE__, __func__);	\
+		return TEST_SKIPPED;					\
+	}								\
+} while (0)
+
+#define TEST_SKIP(a, b, msg, ...) \
+	TEST_SKIP_LOG(a == b, msg, ##__VA_ARGS__)
+
 /*
  * Forward declarations.
  */
@@ -14754,7 +14766,7 @@ test_enq_callback_setup(void)
 
 	struct rte_cryptodev_cb *cb;
 	uint16_t qp_id = 0;
-	int j = 0;
+	int j = 0, ret;
 
 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
@@ -14794,6 +14806,7 @@ 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);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			qp_id, RTE_CRYPTO_MAX_DEVS);
@@ -14802,6 +14815,7 @@ test_enq_callback_setup(void)
 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
 			dev_info.max_nb_queue_pairs + 1,
 			test_enq_callback, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			dev_info.max_nb_queue_pairs + 1,
@@ -14810,6 +14824,7 @@ test_enq_callback_setup(void)
 	/* Test with NULL callback */
 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
 			qp_id, NULL, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			qp_id, ts_params->valid_devs[0]);
@@ -14817,6 +14832,7 @@ test_enq_callback_setup(void)
 	/* Test with valid configuration */
 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
 			qp_id, test_enq_callback, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
 			"qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -14830,24 +14846,35 @@ test_enq_callback_setup(void)
 		rte_delay_ms(10);
 
 	/* Test with invalid crypto device */
-	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
-			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
+	ret = rte_cryptodev_remove_enq_callback(RTE_CRYPTO_MAX_DEVS,
+					qp_id,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_FAIL(ret,
 			"Expected call to fail as crypto device is invalid");
 
 	/* Test with invalid queue pair */
-	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
-			ts_params->valid_devs[0],
-			dev_info.max_nb_queue_pairs + 1, cb),
+	ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0],
+					dev_info.max_nb_queue_pairs + 1,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_FAIL(ret,
 			"Expected call to fail as queue pair is invalid");
 
 	/* Test with NULL callback */
-	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
-			ts_params->valid_devs[0], qp_id, NULL),
+	ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0],
+					qp_id,
+					NULL);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_FAIL(ret,
 			"Expected call to fail as callback is NULL");
 
 	/* Test with valid configuration */
-	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
-			ts_params->valid_devs[0], qp_id, cb),
+	ret = rte_cryptodev_remove_enq_callback(ts_params->valid_devs[0],
+					qp_id,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_SUCCESS(ret,
 			"Failed test to remove callback on "
 			"qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -14869,7 +14896,7 @@ test_deq_callback_setup(void)
 
 	struct rte_cryptodev_cb *cb;
 	uint16_t qp_id = 0;
-	int j = 0;
+	int j = 0, ret;
 
 	/* Verify the crypto capabilities for which enqueue/dequeue is done. */
 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
@@ -14909,6 +14936,7 @@ 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);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			qp_id, RTE_CRYPTO_MAX_DEVS);
@@ -14917,6 +14945,7 @@ test_deq_callback_setup(void)
 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
 			dev_info.max_nb_queue_pairs + 1,
 			test_deq_callback, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			dev_info.max_nb_queue_pairs + 1,
@@ -14925,6 +14954,7 @@ test_deq_callback_setup(void)
 	/* Test with NULL callback */
 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
 			qp_id, NULL, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
 			"cryptodev %u did not fail",
 			qp_id, ts_params->valid_devs[0]);
@@ -14932,6 +14962,7 @@ test_deq_callback_setup(void)
 	/* Test with valid configuration */
 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
 			qp_id, test_deq_callback, NULL);
+	TEST_SKIP(rte_errno, ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
 			"qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
@@ -14945,24 +14976,36 @@ test_deq_callback_setup(void)
 		rte_delay_ms(10);
 
 	/* Test with invalid crypto device */
+	ret = rte_cryptodev_remove_deq_callback(RTE_CRYPTO_MAX_DEVS,
+					qp_id,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
 			"Expected call to fail as crypto device is invalid");
 
 	/* Test with invalid queue pair */
-	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
-			ts_params->valid_devs[0],
-			dev_info.max_nb_queue_pairs + 1, cb),
+	ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0],
+					dev_info.max_nb_queue_pairs + 1,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_FAIL(ret,
 			"Expected call to fail as queue pair is invalid");
 
 	/* Test with NULL callback */
-	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
-			ts_params->valid_devs[0], qp_id, NULL),
+	ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0],
+					qp_id,
+					NULL);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_FAIL(ret,
 			"Expected call to fail as callback is NULL");
 
 	/* Test with valid configuration */
-	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
-			ts_params->valid_devs[0], qp_id, cb),
+	ret = rte_cryptodev_remove_deq_callback(ts_params->valid_devs[0],
+					qp_id,
+					cb);
+	TEST_SKIP(ret, -ENOTSUP, "Not supported, skipped");
+	TEST_ASSERT_SUCCESS(ret,
 			"Failed test to remove callback on "
 			"qp %u on cryptodev %u",
 			qp_id, ts_params->valid_devs[0]);
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 886eb7a..8a45ad7 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)
 {
+#ifdef 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)
 {
+#ifdef 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)
 {
+#ifdef 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)
 {
+#ifdef 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


  parent reply	other threads:[~2024-06-26 22:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Ganapati Kundapura [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240626220028.2260003-1-ganapati.kundapura@intel.com \
    --to=ganapati.kundapura@intel.com \
    --cc=abhinandan.gujjar@intel.com \
    --cc=bala.senthil@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=ferruh.yigit@amd.com \
    --cc=gakhil@marvell.com \
    --cc=john.mcnamara@intel.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).