[dpdk-dev] [v2 2/2] test: add testcase for crypto enqueue callback
Gujjar, Abhinandan S
abhinandan.gujjar at intel.com
Wed Sep 9 18:21:26 CEST 2020
+Konstantin & Honnappa
> -----Original Message-----
> From: Gujjar, Abhinandan S <abhinandan.gujjar at intel.com>
> Sent: Tuesday, September 8, 2020 12:41 PM
> To: dev at dpdk.org
> Cc: Doherty, Declan <declan.doherty at intel.com>; jerinj at marvell.com;
> akhil.goyal at nxp.com; Vangati, Narender <narender.vangati at intel.com>;
> Gujjar, Abhinandan S <abhinandan.gujjar at intel.com>
> Subject: [v2 2/2] test: add testcase for crypto enqueue callback
>
> The purpose of this testcase is to showcase the cryptodev enqueue callback
> usage with RCU support.
>
> Signed-off-by: Abhinandan Gujjar <abhinandan.gujjar at intel.com>
> ---
> app/test/test_cryptodev.c | 123
> +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 122 insertions(+), 1 deletion(-)
>
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index
> 70bf6fe..735f501 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -17,6 +17,7 @@
> #include <rte_cryptodev.h>
> #include <rte_cryptodev_pmd.h>
> #include <rte_string_fns.h>
> +#include <rte_rcu_qsbr.h>
>
> #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
> #include <rte_cryptodev_scheduler.h>
> @@ -11889,6 +11890,123 @@ struct test_crypto_vector {
> return 0;
> }
>
> +#ifdef RTE_CRYPTODEV_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) {
> + RTE_SET_USED(dev_id);
> + RTE_SET_USED(qp_id);
> + RTE_SET_USED(ops);
> + RTE_SET_USED(user_param);
> +
> + return nb_ops;
> +}
> +
> +/*
> + * Thread using enqueue callback with RCU.
> + */
> +static int
> +test_enq_callback_rcu_thread(void *arg) {
> + uint16_t thread_id = 1;
> + struct rte_rcu_qsbr *qsbr = arg;
> +
> + /* Register this thread to report quiescent state */
> + rte_rcu_qsbr_thread_register(qsbr, thread_id);
> + rte_rcu_qsbr_thread_online(qsbr, thread_id);
> +
> +
> + /* DP thread calls rte_cryptodev_enqueue_burst() and
> + * invokes enqueue callback.
> + */
> + test_null_burst_operation();
> +
> + /* Update quiescent state */
> + rte_rcu_qsbr_quiescent(qsbr, thread_id);
> +
> + rte_rcu_qsbr_thread_offline(qsbr, thread_id);
> + rte_rcu_qsbr_thread_unregister(qsbr, thread_id);
> +
> + return 0;
> +}
> +
> +static int
> +test_enq_callback_setup(void)
> +{
> + struct crypto_testsuite_params *ts_params = &testsuite_params;
> + struct rte_cryptodev_info dev_info;
> + struct rte_cryptodev_qp_conf qp_conf = {
> + .nb_descriptors = MAX_NUM_OPS_INFLIGHT
> + };
> +
> + struct rte_cryptodev_enq_callback *cb;
> + uint16_t max_threads = 2;
> + uint16_t qp_id = 0;
> + struct rte_rcu_qsbr *qsbr;
> + size_t size;
> +
> + /* Stop the device in case it's started so it can be configured */
> + rte_cryptodev_stop(ts_params->valid_devs[0]);
> +
> + rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
> +
> + TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params-
> >valid_devs[0],
> + &ts_params->conf),
> + "Failed to configure cryptodev %u",
> + ts_params->valid_devs[0]);
> +
> + qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
> + qp_conf.mp_session = ts_params->session_mpool;
> + qp_conf.mp_session_private = ts_params->session_priv_mpool;
> +
> + TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
> + ts_params->valid_devs[0], qp_id, &qp_conf,
> + rte_cryptodev_socket_id(ts_params-
> >valid_devs[0])),
> + "Failed test for "
> + "rte_cryptodev_queue_pair_setup: num_inflights "
> + "%u on qp %u on cryptodev %u",
> + qp_conf.nb_descriptors, qp_id,
> + ts_params->valid_devs[0]);
> +
> + cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
> + qp_id, test_enq_callback, NULL);
> + TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
> + "qp %u on cryptodev %u",
> + qp_id, ts_params->valid_devs[0]);
> +
> + /* Create RCU QSBR variable */
> + size = rte_rcu_qsbr_get_memsize(max_threads);
> + qsbr = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, size,
> + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
> + TEST_ASSERT_NOT_NULL(qsbr, "Failed to allocate memory for
> qsbr");
> +
> + /* Assign QSBR to cryptodev */
> + TEST_ASSERT_SUCCESS(rte_cryptodev_rcu_qsbr_add(
> + ts_params->valid_devs[0], qsbr),
> + "Failed to setup RCU QSBR for cryptodev %u",
> + ts_params->valid_devs[0]);
> +
> + TEST_ASSERT_SUCCESS(rte_rcu_qsbr_init(qsbr, max_threads),
> + "RCU QSBR init failed");
> +
> + /* Launch a thread */
> + rte_eal_remote_launch(test_enq_callback_rcu_thread, qsbr,
> + rte_get_next_lcore(-1, 1, 0));
> +
> + /* Wait until reader exited. */
> + rte_eal_mp_wait_lcore();
> +
> + TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
> + ts_params->valid_devs[0], qp_id, cb),
> + "Failed test to remove callback on "
> + "qp %u on cryptodev %u",
> + qp_id, ts_params->valid_devs[0]);
> +
> + return TEST_SUCCESS;
> +}
> +#endif
> +
> static struct unit_test_suite cryptodev_scheduler_testsuite = {
> .suite_name = "Crypto Device Scheduler Unit Test Suite",
> .setup = testsuite_setup,
> @@ -11943,7 +12061,10 @@ struct test_crypto_vector {
> test_queue_pair_descriptor_setup),
> TEST_CASE_ST(ut_setup, ut_teardown,
>
> test_device_configure_invalid_queue_pair_ids),
> -
> +#ifdef RTE_CRYPTODEV_CALLBACKS
> + TEST_CASE_ST(ut_setup, ut_teardown,
> + test_enq_callback_setup),
> +#endif
> TEST_CASE_ST(ut_setup, ut_teardown,
> test_multi_session),
> TEST_CASE_ST(ut_setup, ut_teardown,
> --
> 1.9.1
More information about the dev
mailing list