From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9AA8AA04DD; Mon, 26 Oct 2020 19:52:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C1EED2BA3; Mon, 26 Oct 2020 19:52:09 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 207542BA3 for ; Mon, 26 Oct 2020 19:52:06 +0100 (CET) IronPort-SDR: h3dWqrfKvBVX1+5cD98ZCScW2l5BJf+VXBRmKKyVDGxl09UkmQZlGGr/ZIgVGROaZhA3um/o2P ZB52UQjChDEA== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="147255847" X-IronPort-AV: E=Sophos;i="5.77,420,1596524400"; d="scan'208";a="147255847" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 11:52:06 -0700 IronPort-SDR: 9szFkB1FLoKdRgCUYXMoppgt4LQiXz66YjMk3tGBemdrJNcGXHJSuhSU1usbUoFVA15uCQykU3 4k8CmgMYkVuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,420,1596524400"; d="scan'208";a="303501288" Received: from unknown (HELO localhost.localdomain) ([10.190.210.98]) by fmsmga008.fm.intel.com with ESMTP; 26 Oct 2020 11:52:03 -0700 From: Abhinandan Gujjar To: dev@dpdk.org, declan.doherty@intel.com, akhil.goyal@nxp.com, Honnappa.Nagarahalli@arm.com, konstantin.ananyev@intel.com Cc: narender.vangati@intel.com, jerinj@marvell.com, abhinandan.gujjar@intel.com Date: Sun, 25 Oct 2020 15:14:49 +0530 Message-Id: <1603619090-118652-3-git-send-email-abhinandan.gujjar@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1603619090-118652-1-git-send-email-abhinandan.gujjar@intel.com> References: <1603619090-118652-1-git-send-email-abhinandan.gujjar@intel.com> Subject: [dpdk-dev] [v4 2/3] test: add testcase for crypto enqueue callback X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Abhinandan Gujjar --- app/test/test_cryptodev.c | 133 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 1d4c46f..a083612 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -10640,6 +10640,133 @@ struct multi_session_params { 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) +{ + RTE_SET_USED(dev_id); + RTE_SET_USED(qp_id); + RTE_SET_USED(ops); + RTE_SET_USED(user_param); + + printf("crypto enqueue callback called\n"); + return nb_ops; +} + +/* + * Thread using enqueue callback with RCU. + */ +static int +test_enq_callback_rcu_thread(void *arg) +{ + RTE_SET_USED(arg); + /* DP thread calls rte_cryptodev_enqueue_burst() and + * invokes enqueue callback. + */ + test_null_burst_operation(); + 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_cb *cb; + uint16_t qp_id = 0; + + /* 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]); + + /* Test with invalid crypto device */ + cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS, + qp_id, test_enq_callback, NULL); + TEST_ASSERT_NULL(cb, "Add callback on qp %u on " + "cryptodev %u did not fail", + qp_id, RTE_CRYPTO_MAX_DEVS); + + /* Test with invalid queue pair */ + cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0], + dev_info.max_nb_queue_pairs + 1, + test_enq_callback, NULL); + TEST_ASSERT_NULL(cb, "Add callback on qp %u on " + "cryptodev %u did not fail", + dev_info.max_nb_queue_pairs + 1, + ts_params->valid_devs[0]); + + /* Test with NULL callback */ + cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0], + qp_id, NULL, NULL); + TEST_ASSERT_NULL(cb, "Add callback on qp %u on " + "cryptodev %u did not fail", + qp_id, ts_params->valid_devs[0]); + + /* Test with valid configuration */ + 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]); + + /* Launch a thread */ + rte_eal_remote_launch(test_enq_callback_rcu_thread, NULL, + rte_get_next_lcore(-1, 1, 0)); + + /* Wait until reader exited. */ + rte_eal_mp_wait_lcore(); + + /* Test with invalid crypto device */ + TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_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_enq_callback( + ts_params->valid_devs[0], + dev_info.max_nb_queue_pairs + 1, cb), + "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), + "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), + "Failed test to remove callback on " + "qp %u on cryptodev %u", + qp_id, ts_params->valid_devs[0]); + + return TEST_SUCCESS; +} +#endif + static void generate_gmac_large_plaintext(uint8_t *data) { @@ -12960,7 +13087,6 @@ struct test_crypto_vector { test_queue_pair_descriptor_setup), TEST_CASE_ST(ut_setup, ut_teardown, test_device_configure_invalid_queue_pair_ids), - TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), TEST_CASE_ST(ut_setup, ut_teardown, @@ -12969,7 +13095,6 @@ struct test_crypto_vector { TEST_CASE_ST(ut_setup, ut_teardown, test_null_invalid_operation), TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation), - TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all), TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all), @@ -13583,6 +13708,10 @@ struct test_crypto_vector { TEST_CASE_ST(ut_setup_security, ut_teardown, test_DOCSIS_PROTO_all), #endif + +#ifdef RTE_CRYPTO_CALLBACKS + TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup), +#endif TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 1.9.1