[v1,2/2] examples/l2fwd-crypto: add callback handlers

Message ID 20190610050352.83349-2-vipin.varghese@intel.com (mailing list archive)
State Superseded, archived
Headers
Series [v1,1/2] lib/crypto: add callback handlers for crypto |

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Varghese, Vipin June 10, 2019, 5:03 a.m. UTC
  Register user callback handlers for pre-enqueue and pst-dequeue
for crypto device instance 0 with port 0.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---
 examples/l2fwd-crypto/main.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
  

Patch

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index e282cb7bf..db2ac2624 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -255,6 +255,20 @@  struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS];
 /* default period is 10 seconds */
 static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000;
 
+static uint16_t dump_crypto(__rte_unused uint8_t dev_id,
+		__rte_unused uint8_t qp_id,
+		__rte_unused struct rte_crypto_op **ops,
+		__rte_unused uint16_t nb_ops,
+		__rte_unused void *cb_arg)
+{
+	if (nb_ops)
+		RTE_LOG(DEBUG, L2FWD, " dev_id (%u) qp_id (%u)"
+				" ops (%p) nb_ops (%u)\n",
+				dev_id, qp_id, ops, nb_ops);
+
+	return nb_ops;
+}
+
 /* Print out statistics on packets dropped */
 static void
 print_stats(void)
@@ -2783,6 +2797,18 @@  main(int argc, char **argv)
 				(unsigned)cdev_id);
 	}
 
+#ifdef RTE_CRYPTODEV_ENQDEQ_CALLBACKS
+	ret = rte_cryptodev_preenq_callback_register(0, 0, dump_crypto, NULL);
+	if (ret != 0)
+		RTE_LOG(ERR, L2FWD, " failed to preenq callback register\n");
+	RTE_LOG(INFO, L2FWD, " preenq callback register success\n");
+
+	ret = rte_cryptodev_pstdeq_callback_register(0, 0, dump_crypto, NULL);
+	if (ret != 0)
+		RTE_LOG(ERR, L2FWD, " failed to pstdeq callback register\n");
+	RTE_LOG(INFO, L2FWD, " pstdeq callback register success\n");
+#endif
+
 	/* launch per-lcore init on every lcore */
 	rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, (void *)&options,
 			CALL_MASTER);
@@ -2791,5 +2817,15 @@  main(int argc, char **argv)
 			return -1;
 	}
 
+#ifdef RTE_CRYPTODEV_ENQDEQ_CALLBACKS
+	ret = rte_cryptodev_preenq_callback_unregister(0, 0, dump_crypto, NULL);
+	if (ret != 0)
+		printf(" faield rte_cryptodev_preenq_callback_unregister\n");
+
+	ret = rte_cryptodev_pstdeq_callback_unregister(0, 0, dump_crypto, NULL);
+	if (ret != 0)
+		printf(" failed rte_cryptodev_pstdeq_callback_unregister\n");
+#endif
+
 	return 0;
 }