From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 638221BC56 for ; Fri, 13 Apr 2018 11:00:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2018 02:00:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,444,1517904000"; d="scan'208";a="33988681" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by orsmga006.jf.intel.com with ESMTP; 13 Apr 2018 02:00:28 -0700 From: Reshma Pattan To: pablo.de.lara.guarch@intel.com, dev@dpdk.org Cc: jananeex.m.parthasarathy@intel.com Date: Fri, 13 Apr 2018 10:00:26 +0100 Message-Id: <1523610026-24227-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1523362560-6262-1-git-send-email-reshma.pattan@intel.com> References: <1523362560-6262-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH v3] app/test: enhance cryptodev scheduler unit tests 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: , X-List-Received-Date: Fri, 13 Apr 2018 09:00:32 -0000 Unit Test Cases for MultiCore mode, Failover mode, Packet Distribution mode are added to improve code coverage Signed-off-by: Jananee Parthasarathy --- v3: Pass on socket id to cryptodev sched vdev arg to increase the code coverage. --- test/test/test_cryptodev.c | 131 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 105 insertions(+), 26 deletions(-) diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c index d1d7925..963037b 100644 --- a/test/test/test_cryptodev.c +++ b/test/test/test_cryptodev.c @@ -21,6 +21,8 @@ #include #endif +#include + #include "test.h" #include "test_cryptodev.h" @@ -36,6 +38,8 @@ #include "test_cryptodev_aead_test_vectors.h" #include "test_cryptodev_hmac_test_vectors.h" +#define VDEV_ARGS_SIZE 100 + static int gbl_driver_id; struct crypto_testsuite_params { @@ -144,6 +148,11 @@ struct crypto_unittest_params { uint32_t i = 0, nb_devs, dev_id; int ret; uint16_t qp_id; + char vdev_args[VDEV_ARGS_SIZE] = {""}; + char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core," + "ordering=enable,name=cryptodev_test_scheduler,corelist="}; + uint16_t slave_core_count = 0; + uint16_t socket_id = 0; memset(ts_params, 0, sizeof(*ts_params)); @@ -359,14 +368,35 @@ struct crypto_unittest_params { if (gbl_driver_id == rte_cryptodev_driver_id_get( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) { + /* Identify the Slave Cores + * Use 2 slave cores for the device args + */ + RTE_LCORE_FOREACH_SLAVE(i) { + if (slave_core_count > 1) + break; + snprintf(vdev_args, sizeof(vdev_args), + "%s%d", temp_str, i); + strcpy(temp_str, vdev_args); + strcat(temp_str, ";"); + slave_core_count++; + socket_id = lcore_config[i].socket_id; + } + if (slave_core_count != 2) { + RTE_LOG(ERR, USER1, "Cryptodev scheduler test require atleast" + " two slave cores to run. Please use the correct coremask.\n"); + return TEST_FAILED; + } + strcpy(temp_str, vdev_args); + snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", + temp_str, socket_id); + RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args); nb_devs = rte_cryptodev_device_count_by_driver( rte_cryptodev_driver_id_get( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))); if (nb_devs < 1) { ret = rte_vdev_init( RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD), - NULL); - + vdev_args); TEST_ASSERT(ret == 0, "Failed to create instance %u of" " pmd : %s", @@ -8540,33 +8570,47 @@ struct test_crypto_vector { } static int -test_scheduler_mode_op(void) +test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode) { struct crypto_testsuite_params *ts_params = &testsuite_params; uint8_t sched_id = ts_params->valid_devs[0]; - struct rte_cryptodev_scheduler_ops op = {0}; - struct rte_cryptodev_scheduler dummy_scheduler = { - .description = "dummy scheduler to test mode", - .name = "dummy scheduler", - .mode = CDEV_SCHED_MODE_USERDEFINED, - .ops = &op - }; - int ret; + /* set mode */ + return rte_cryptodev_scheduler_mode_set(sched_id, + scheduler_mode); +} + +static int +test_scheduler_mode_roundrobin_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) == + 0, "Failed to set roundrobin mode"); + return 0; + +} + +static int +test_scheduler_mode_multicore_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) == + 0, "Failed to set multicore mode"); + + return 0; +} + +static int +test_scheduler_mode_failover_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) == + 0, "Failed to set failover mode"); - /* set user defined mode */ - ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id, - &dummy_scheduler); - TEST_ASSERT(ret == 0, - "Failed to set cdev %u to user defined mode", sched_id); - - /* set round robin mode */ - ret = rte_cryptodev_scheduler_mode_set(sched_id, - CDEV_SCHED_MODE_ROUNDROBIN); - TEST_ASSERT(ret == 0, - "Failed to set cdev %u to round-robin mode", sched_id); - TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) == - CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode " - "not match"); + return 0; +} + +static int +test_scheduler_mode_pkt_size_distr_op(void) +{ + TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) == + 0, "Failed to set pktsize mode"); return 0; } @@ -8576,8 +8620,20 @@ struct test_crypto_vector { .setup = testsuite_setup, .teardown = testsuite_teardown, .unit_test_cases = { + /* Multi Core */ TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), - TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* Round Robin */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op), TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_scheduler_all), TEST_CASE_ST(ut_setup, ut_teardown, @@ -8585,6 +8641,29 @@ struct test_crypto_vector { TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_scheduler_all), TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* Fail over */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + + /* PKT SIZE */ + TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), + TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_chain_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_AES_cipheronly_scheduler_all), + TEST_CASE_ST(ut_setup, ut_teardown, + test_authonly_scheduler_all), + TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 1.7.12.2