From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0065.outbound.protection.outlook.com [104.47.33.65]) by dpdk.org (Postfix) with ESMTP id EABCF5588 for ; Sun, 4 Dec 2016 03:34:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+NpyewsGUbYU4iAJDVfGxpf8z9klF8MHUVmQ/mLKgTo=; b=nxKLxZWK8/XxlE1d5U259ZGwchJC7Wj4fXFvrCiTo4DWaOKivjWpgVvrJjQhvjRSU7vBY+saYfRZX9TDOXLeFTPCshDfdxbX85WKFN3ZEVas6qrzIvovc9bFjb+EeXvbvz5pGdQxlav85sQAK23A46GuAUi851yH2F2x/ciIoXQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Zbigniew.Bodek@cavium.com; Received: from localhost.localdomain (31.172.191.173) by CO2PR07MB554.namprd07.prod.outlook.com (10.141.199.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Sun, 4 Dec 2016 02:34:34 +0000 From: To: , CC: , Zbigniew Bodek Date: Sun, 4 Dec 2016 03:33:39 -0800 Message-ID: <1480851219-45071-4-git-send-email-zbigniew.bodek@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480851219-45071-1-git-send-email-zbigniew.bodek@caviumnetworks.com> References: <1480851219-45071-1-git-send-email-zbigniew.bodek@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [31.172.191.173] X-ClientProxiedBy: HE1PR03CA0013.eurprd03.prod.outlook.com (10.163.170.151) To CO2PR07MB554.namprd07.prod.outlook.com (10.141.199.150) X-MS-Office365-Filtering-Correlation-Id: bbbc9661-99bf-409d-3c9b-08d41bee16ac X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CO2PR07MB554; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 3:3hpYfSvH3Ht7i+DgBbGNaihK36/SQIBrX/R13g7Eu9+nlGK+EP54taXRtAiA6ocfKtNET8O9crp1XbticmnYbd4j0NsSTFjRPdNY9fM81aRDBjMo0gEiRL7yZZfutPPlQNWI+JfVAsprkKx4oR62sG1RwJ5BFGHAe4+7L1SWtdlftJsj1RG2ysDAUOsOdxVB7zqpsqusDwNX3oKqEHHlEA2VJGeC9P2H51bV5ozKxc5FhgOZnSRj0Iw2Ou+bU+l0UeC7KVzDxml+M7ouCQiQbQ== X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 25:DW8XFtKP7bMkmC4LGB7enYs2wEB0e4C/BdjwAgMUdHoFxnrQ80whcnf2jEb9iqm6u/VwiKiVAkxUF9D5sc8bd2qgl4548pHmp0GPpOl11xTJtqMc8jNpQZXO5ejCJRoo32oBVSiAD0FnBVQv/FZuWUM4ZdL0V7SkFFBwNQjmS5THS6LYreEQ556w1WsWSKBHi/O+Ri6BggX3HksWubfH7OFH8RTgIOBucNXadutP2O58ixahLwyjgx9hnUY62ApuX0AhP/VJbVZ4Ygmco+YDbnxt/ipfdUOCQXveZxbs2Mpd4zx/+//2iiaEe4JZYQln+SfDEdFc+AlUuB8KiUrFfpns1/ZzIWM87hKVaVDIInxhcPFUCoRH295wFccGwlmJ6AVCCZqbxDY+BLSpJOtUXbZcxfqFC0PiL44hxbu4MlSXARF2v3F46zY5MeJVxCevcNGDwuc0o96DZxigQ1Ia5NYUlK3s8U2X5JzO9gKOvrTl6Z9Xu6Zi8US6UtgqJSeDvHHe00hXq02KhCuYf28CWxmjCeJIrVwu3X1aPok8PFQX4tuxd9twoDuGLGzi1yKV4hzAsYEDgdErcGKwIH0h1abUSOAFw+3adNGDQo8lSjq1n+keNX+MHyl4HG62znIfa+QMbU3YUV+LC9WOThH0E62MLLFME3xqheXeU/EoPR1hhZXquV1+o37P22XR0CEY814p3jXq8eYjjb6IqQFgnzeQRFUl51Z2n8GEAtkgWeKDZSNCyM0PRnaBn+nGCWwfMDRfSv5gZp3on18muYkZqUwAxtDW2wwFna3cUchzzIg= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 31:eOrazGF17SK1oRBXCTsWwQsDjig/FsJnOWFG5xFa9pzTjKJKMkjj40YBPDSV/hUEca8Xrp4tXPrSGJwCMMscHQsnBURRKo4b/Z6CzzYyCMSCaP/AlNaYz1gdp8HJiNYwX1aiPIob71SACnXeqtFyxlvpUkcrICeWpLjTnxbrqMTGiwoQJrP6xlORtPvcJ+/DGT5webySgbLyrkoaaFY7H+hK6HSX7EPeZM57zLyijeiEwHw8aoR1I5mJY9CUqX1h; 20:icPgPnnrcWlD6Qhj1BPZgDp99lzQSX7kMa0hRPFucwLf/TDAo3rABXQAP5SFeMhMUt9NmiGcBuWH8E6BQVFVs0ku3NjQ/D3w3ZzlrzdjQ9+0yNsxo00WdnHL8N5xIjst6lzSeitHnrNw9Q5q25kB+ZhXh5pklZMrys/SZYwFkCtCDixG1OZo+/ThySpw0WxcMk6AAsJeUdhXXu3BrLyM4YPExTVObT6oZWLN/Cva1vklpEQ8dFqrEI6+quH7LYXbJQtcHJb+CzfXka+zcilifP8ilPr5WNSgloKlGYDMZAnj4GyOojGN0tEhcogU3Bd6NwIug/lvmMFuVeOVX2yhozMS95isId+tkEb3zY56u1JRmoHI6wnoTtYFMwRg/Kvi48HqdYwyQYb6jZg4+PxSVf3VmHdVwYga1xnQ7DljT0QkqoQSdHjDNoqXOWsDrwqQpkNDGvbZrkNlLSFDilYRmTxe8/f7VGPl1tQe5GSg4Ib+Sp9DAudNZpYv9r7EHhHEm9XlnH3/eKGpDW9KWoLBlbUoAqzjdNIq6HbnuqZFnY/6x2JJvyo9Rtszq6Lr3y1YbPDZ1kDEOng9cwHMPUECL+/9CymGKgEQXKmXWU7H4P4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6042181)(6072148); SRVR:CO2PR07MB554; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB554; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 4:VEBu4YC/fYNmJTGKJwSMbL/C0+1caN+uyR+lGMPS4ShKSQmnizOD7wnNUUC5flSR1+hDxeKgrUTZAu/fPXX8EPA6kzUg1TyIWW3Ra73801E6Ub9rU6xXD9TXia4Ilg1xy0LUr99HlCYYfUCztb2abCW4ODQfvFJMLZVeqvl5QHN2yK/ilV/yQaF1V4CwsYeesLna/nLYfFB70jbXEYni6I8CfGqFd5z8lGz3qzvBmaQgh6JfYdL28TSM27L1g2BkP4jsNUYLgY65HKDatCHun4gsF0+Xm3ePafUV/jKQT6xpr9LIcmCDXnMF1lHlm9n+jg1IQD6r/Bmqmil4DCAkhwItWBBD2KDoDNOeP+xZZ4KfFv1FLpCuJscBDIM0ca7FGUVvXAZ9ld7F6G3821LNNKJKnmaxxZrgz87Iu7eHpiG1faAl65UeKB0w4OM/+HktYuuJ0f9mPo639FXK07gj87sxadN9deCzyFfbJUKSuFRD0WOrxcGDXCHEODkfNhSY6MBa8nv2edBXQrAMFcmqSa1dhVCJ6ytS7w49Q3HafIQkMapY/ngb15xQX8wH6Iu7ma/LxW/jfkDdUW+gRb+3rAj+t5tDDR8MpSg8Fiqh7oc= X-Forefront-PRVS: 014617085B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(4326007)(36756003)(50226002)(86152002)(81156014)(81166006)(8676002)(2906002)(6486002)(733004)(6636002)(305945005)(575784001)(33646002)(6512006)(2876002)(5890100001)(4001430100002)(7736002)(7846002)(6506006)(107886002)(101416001)(189998001)(5660300001)(97736004)(5001770100001)(68736007)(92566002)(50986999)(50466002)(42186005)(48376002)(2950100002)(38730400001)(105586002)(42882006)(3846002)(6862003)(106356001)(6116002)(76176999)(66066001)(5003940100001)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB554; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB554; 23:GwUfBearlIF62ThVWykI36N3WMFzcCv6WOLeN1UCd9?= =?us-ascii?Q?QUuQJ6kRBszfTtzfWovCDv1/BQ2GxEXCUqxXkSMJcvLupkDqDLTW3lUpQTyf?= =?us-ascii?Q?nyPLGfS5ObV1NLy+u5/3RJXll37Es/1FTJWfQJU9d8Uwukc8GgYJikZKZCh3?= =?us-ascii?Q?WlhvKeT/CN990d/XQYv/lm2eDnvxFIkfpP0snULswNkG1p9crDLSTNyT1SNG?= =?us-ascii?Q?nFYfNwRcvtxVN3vodgG8aX4WqXHeLAh3tanhLyLxWUYbcxQQKzSg/iG6Gkea?= =?us-ascii?Q?c7kxaLy/D9Hs2LUeBlhG+kv4bs4aDd/BVQJC7/SpRFDaAaLNofOd0Z9gLTUP?= =?us-ascii?Q?/ekxaEXVdWtddKxIvsJGAPfDNN3qSaTljyul98xEJ6uoUAWCNkUZLGWuKZPg?= =?us-ascii?Q?XVexZNyDGaSeKYIlVwNh0TgELsQCVSBPh37T0WGwgeiVakKgPJvE/FMD4tEb?= =?us-ascii?Q?x1R84WhwPNUNkAyjVfP6d+sw1YXaYKglmXc8ZT8rICduqmSYXrNmz+sABMfh?= =?us-ascii?Q?GzUUYOHL2jacpXf1TIpT1LfYkFdEGDDRi62SFF7P18qifs4W/7gkZYz0Pj55?= =?us-ascii?Q?gbFernTGaWmucmDIyeHRvSyKgw8Pdlefn8HcX6cBmuyGtjPcmcEMqSzVcmf0?= =?us-ascii?Q?fDHqP8KtXwvasQtoAs8b9JXTtv08sClIjBTo/G08UZQ2Z/q367e1sylvvVtg?= =?us-ascii?Q?icc00qbajrIdL0Q37qf69DiJGxVhkC71dp1uebLiA7Cd6grJF9KgaYW4AZep?= =?us-ascii?Q?hA5xoeLZXYLWEhh4rA7C0VF28cWtpPFMBFvfBeTN0u+a8ucVOYybI5to8H12?= =?us-ascii?Q?XgvpwVrpH0VWHDNdfYQahhtt8r7HKwLAu9fSdmn+CblGUIwWFE5TiMu5H1Vp?= =?us-ascii?Q?NKnZAGUIJKuRZWhA2rPa1GKSnJgGXoctyxMSuJrLP+lW92xasFaWRqCKEiEY?= =?us-ascii?Q?HnDiwZkKpZ3LIqQtaIZ3sCSkNz42cLPj/+cVIPhfsgZVzVDZiU6Gl82r0/dz?= =?us-ascii?Q?O84iN+xsILk8qD3uTK1OdoXNNdIRZ6uAnlFvil1CsX1IaXxUSOSLltHR9AFD?= =?us-ascii?Q?LVAdvSGMzp2O80/qY3zbFfIq6GNbYH8hjzMKv/ALASKjltmjuFob5z4WRTuj?= =?us-ascii?Q?2BMS42HLxi2vUSru7kBSiGyaUYoNw+C/Yruo8jblrqa+/C9f/SHquRyVZPHw?= =?us-ascii?Q?ykD4L24/EzwvgQ1aD05ReNFxliwXqReX75uIdwssgUiiWMFFeccSFqiw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 6:jbTuRdUlAJ4HQtN10tptVZrR/2AmjgStMTevP6bbGJTWZNEYTmAhJ2e+byrKc3dqXUL31L5Wk6UhWK7MHMuMiGLiF3iqiu3CYmcr7EY6/cG5aSM8uDlY4w8mELxsHnbgaXhe9lhIetQXDyL35W0qs1GBoHpXFkZhLetzoaQz6lNZVSoMQi6RuQxdwD2T+NBinYs2wedE4PKnf4uEo6R9LQflFRFtKF3QKndxCuvQJg+uMxiHOe/oLtlyvjKd8lR1HPHr9kPk7dgLjDm/8D3RgN6uC7oZTFlINJ4SKdK9BQA27Du98H7rwIupcwBrhseust/zgjBE9tPxBJQ7WpMIJQ+kFOppUkFGGX2rWz5FVJ827Ou+u1dB2Jc6Wjz8Kwr87usX4lp6ge9dQO6WxQxmvChr0w/pGnONhSQDA6mDGzKNl4rgZJmARTB/aIp3RkcJBFFXayBAiuVsmihAR7B77g==; 5:W/Q5cYJco2Tepqy4EeS3AjxIq1/bYjVHZMuIymn10dweU+Ew7qeVqGYyLfhGsBxr359VX/1Be1QZtCYiDaCiflC3U1nkKzc0pBeXNbwR8+k/iCBGfOCl9MID7PJgkx2X4yov1aXR4Zz7OgRiSn8FgkQD/GIhNlMokqpBvYqN6Vg=; 24:vq89Z2FZCP6aNLq7ulKkg57jhOz5E5O0Gl5hHXzAeTS6blS+P5JaTtkyTFUQJjDF/PKUeQy8/hmvie5+qhGF+Ox8g6FVUpEVL+MiPkOWGFo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB554; 7:gyyEKdmAuZfOehnfpOT6EJbsMDB5sxe+FwFqTuuiGEGjNPc4ZuE+t9gpk1UFaZjtYCOXW+b67TlAy0cC+aaUjYfSvxHtmX81zmG2rqyUWcQQ0N3es4EzLix1lDNFgjXZkG+UCodaPwv/f6byijPmnWr1MDi9XdYmImQUoJI/pB47EdreRUcL05nzxw+QGlpQ+AXsciPI9yHxxafF/iYzIEecFL6+BRUhk4kUTDhe37Rvi6GinKZsaCS2A1Z9ibPa9g3bt5y/ospRZCI0FA32W0h0pTpcsnz1Z+FQ667qkzdAaPKb0vFlnORYsfrshiO5W2PVkm+4Dj8kdzVBEMdk788owTM7MeQixbqu/tqN/tHXK2aW21sUXxxhSFfyQX1UgF2/gshmslnJ7ddl4CIDgJdEo2cMbFFC5E35DADQwgamPIwPzjxg2XDwx4TwnXrmSPJ3j7gjd7/V4zaEUH/kCQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2016 02:34:34.8896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB554 Subject: [dpdk-dev] [PATCH 3/3] app/test: add ARMv8 crypto tests and test vectors 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: Sun, 04 Dec 2016 02:34:41 -0000 From: Zbigniew Bodek Introduce unit tests for ARMv8 crypto PMD. Add test vectors for short cases such as 160 bytes. These test cases are ARMv8 specific since the code provides different processing paths for different input data sizes. Add test vectors for cipher + SHA256 MAC generation. User can validate correctness of algorithms' implementation using: * cryptodev_sw_armv8_autotest For performance test one can use: * cryptodev_sw_armv8_perftest Signed-off-by: Zbigniew Bodek --- app/test/test_cryptodev.c | 63 ++++ app/test/test_cryptodev_aes_test_vectors.h | 211 +++++++++++- app/test/test_cryptodev_blockcipher.c | 4 + app/test/test_cryptodev_blockcipher.h | 1 + app/test/test_cryptodev_perf.c | 508 +++++++++++++++++++++++++++++ 5 files changed, 779 insertions(+), 8 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 872f8b4..a0540d6 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -348,6 +348,27 @@ struct crypto_unittest_params { } } + /* Create 2 ARMv8 devices if required */ + if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) { +#ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO + RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be" + " enabled in config file to run this testsuite.\n"); + return TEST_FAILED; +#endif + nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ARMV8_PMD); + if (nb_devs < 2) { + for (i = nb_devs; i < 2; i++) { + ret = rte_eal_vdev_init( + RTE_STR(CRYPTODEV_NAME_ARMV8_PMD), + NULL); + + TEST_ASSERT(ret == 0, "Failed to create " + "instance %u of pmd : %s", i, + RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)); + } + } + } + #ifndef RTE_LIBRTE_PMD_QAT if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) { RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled " @@ -1545,6 +1566,22 @@ struct crypto_unittest_params { return TEST_SUCCESS; } +static int +test_AES_chain_armv8_all(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + int status; + + status = test_blockcipher_all_tests(ts_params->mbuf_pool, + ts_params->op_mpool, ts_params->valid_devs[0], + RTE_CRYPTODEV_ARMV8_PMD, + BLKCIPHER_AES_CHAIN_TYPE); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return TEST_SUCCESS; +} + /* ***** SNOW 3G Tests ***** */ static int create_wireless_algo_hash_session(uint8_t dev_id, @@ -6504,6 +6541,23 @@ struct test_crypto_vector { } }; +static struct unit_test_suite cryptodev_armv8_testsuite = { + .suite_name = "Crypto Device ARMv8 Unit Test Suite", + .setup = testsuite_setup, + .teardown = testsuite_teardown, + .unit_test_cases = { + TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all), + + /** Negative tests */ + TEST_CASE_ST(ut_setup, ut_teardown, + auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), + TEST_CASE_ST(ut_setup, ut_teardown, + auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), + + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + static int test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) { @@ -6567,6 +6621,14 @@ struct test_crypto_vector { return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite); } +static int +test_cryptodev_armv8(void) +{ + gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD; + + return unit_test_suite_runner(&cryptodev_armv8_testsuite); +} + REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat); REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb); REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl); @@ -6575,3 +6637,4 @@ struct test_crypto_vector { REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g); REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi); REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc); +REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8); diff --git a/app/test/test_cryptodev_aes_test_vectors.h b/app/test/test_cryptodev_aes_test_vectors.h index 1c68f93..470c2d9 100644 --- a/app/test/test_cryptodev_aes_test_vectors.h +++ b/app/test/test_cryptodev_aes_test_vectors.h @@ -825,6 +825,136 @@ } }; +/** AES-128-CBC SHA256 MAC test vector */ +static const struct blockcipher_test_data aes_test_data_12 = { + .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key = { + .data = { + 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, + 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A + }, + .len = 16 + }, + .iv = { + .data = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F + }, + .len = 16 + }, + .plaintext = { + .data = plaintext_aes_common, + .len = 512 + }, + .ciphertext = { + .data = ciphertext512_aes128cbc, + .len = 512 + }, + .auth_algo = RTE_CRYPTO_AUTH_SHA256, + .digest = { + .data = { + 0xA8, 0xBC, 0xDB, 0x99, 0xAA, 0x45, 0x91, 0xA3, + 0x2D, 0x75, 0x41, 0x92, 0x28, 0x01, 0x87, 0x5D, + 0x45, 0xED, 0x49, 0x05, 0xD3, 0xAE, 0x32, 0x57, + 0xB7, 0x79, 0x65, 0xFC, 0xFA, 0x6C, 0xFA, 0xDF + }, + .len = 32, + .truncated_len = 16 + } +}; + +/** AES-128-CBC SHA256 HMAC test vector (160 bytes) */ +static const struct blockcipher_test_data aes_test_data_13 = { + .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key = { + .data = { + 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, + 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A + }, + .len = 16 + }, + .iv = { + .data = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F + }, + .len = 16 + }, + .plaintext = { + .data = plaintext_aes_common, + .len = 160 + }, + .ciphertext = { + .data = ciphertext512_aes128cbc, + .len = 160 + }, + .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC, + .auth_key = { + .data = { + 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, + 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, + 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76, + 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60 + }, + .len = 32 + }, + .digest = { + .data = { + 0x92, 0xEC, 0x65, 0x9A, 0x52, 0xCC, 0x50, 0xA5, + 0xEE, 0x0E, 0xDF, 0x1E, 0xA4, 0xC9, 0xC1, 0x04, + 0xD5, 0xDC, 0x78, 0x90, 0xF4, 0xE3, 0x35, 0x62, + 0xAD, 0x95, 0x45, 0x28, 0x5C, 0xF8, 0x8C, 0x0B + }, + .len = 32, + .truncated_len = 16 + } +}; + +/** AES-128-CBC SHA1 HMAC test vector (160 bytes) */ +static const struct blockcipher_test_data aes_test_data_14 = { + .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key = { + .data = { + 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, + 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A + }, + .len = 16 + }, + .iv = { + .data = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F + }, + .len = 16 + }, + .plaintext = { + .data = plaintext_aes_common, + .len = 160 + }, + .ciphertext = { + .data = ciphertext512_aes128cbc, + .len = 160 + }, + .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, + .auth_key = { + .data = { + 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, + 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, + 0xDE, 0xF4, 0xDE, 0xAD + }, + .len = 20 + }, + .digest = { + .data = { + 0x4F, 0x16, 0xEA, 0xF7, 0x4A, 0x88, 0xD3, 0xE0, + 0x0E, 0x12, 0x8B, 0xE7, 0x05, 0xD0, 0x86, 0x48, + 0x22, 0x43, 0x30, 0xA7 + }, + .len = 20, + .truncated_len = 12 + } +}; + static const struct blockcipher_test_case aes_chain_test_cases[] = { { .test_descr = "AES-128-CTR HMAC-SHA1 Encryption Digest", @@ -878,37 +1008,69 @@ .test_descr = "AES-128-CBC HMAC-SHA1 Encryption Digest", .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_MB | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT }, { + .test_descr = "AES-128-CBC HMAC-SHA1 Encryption Digest " + "(short buffers)", + .test_data = &aes_test_data_14, + .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { .test_descr = "AES-128-CBC HMAC-SHA1 Decryption Digest " "Verify", .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_MB | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT }, { + .test_descr = "AES-128-CBC HMAC-SHA1 Decryption Digest " + "Verify (short buffers)", + .test_data = &aes_test_data_14, + .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { .test_descr = "AES-128-CBC HMAC-SHA256 Encryption Digest", .test_data = &aes_test_data_5, .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_MB | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT }, { + .test_descr = "AES-128-CBC HMAC-SHA256 Encryption Digest " + "(short buffers)", + .test_data = &aes_test_data_13, + .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { .test_descr = "AES-128-CBC HMAC-SHA256 Decryption Digest " "Verify", .test_data = &aes_test_data_5, .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_MB | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_MB | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL | BLOCKCIPHER_TEST_TARGET_PMD_QAT }, { + .test_descr = "AES-128-CBC HMAC-SHA256 Decryption Digest " + "Verify (short buffers)", + .test_data = &aes_test_data_13, + .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { .test_descr = "AES-128-CBC HMAC-SHA512 Encryption Digest", .test_data = &aes_test_data_6, .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, @@ -954,7 +1116,8 @@ .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_QAT | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL }, { @@ -963,7 +1126,8 @@ .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT | + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_QAT | BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL }, { @@ -1006,7 +1170,8 @@ .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, .feature_mask = BLOCKCIPHER_TEST_FEATURE_SESSIONLESS, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL }, { .test_descr = @@ -1015,7 +1180,37 @@ .test_data = &aes_test_data_4, .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, .feature_mask = BLOCKCIPHER_TEST_FEATURE_SESSIONLESS, - .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 | + BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL + }, + { + .test_descr = "AES-128-CBC MAC-SHA256 Encryption Digest", + .test_data = &aes_test_data_12, + .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { + .test_descr = "AES-128-CBC MAC-SHA256 Decryption Digest " + "Verify", + .test_data = &aes_test_data_12, + .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { + .test_descr = "AES-128-CBC MAC-SHA256 Encryption Digest " + "Sessionless", + .test_data = &aes_test_data_12, + .op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN, + .feature_mask = BLOCKCIPHER_TEST_FEATURE_SESSIONLESS, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 + }, + { + .test_descr = "AES-128-CBC MAC-SHA256 Decryption Digest " + "Verify Sessionless", + .test_data = &aes_test_data_12, + .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC, + .feature_mask = BLOCKCIPHER_TEST_FEATURE_SESSIONLESS, + .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 }, }; diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 37b10cf..6963241 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -82,6 +82,7 @@ switch (cryptodev_type) { case RTE_CRYPTODEV_QAT_SYM_PMD: case RTE_CRYPTODEV_OPENSSL_PMD: + case RTE_CRYPTODEV_ARMV8_PMD: /* Fall through */ digest_len = tdata->digest.len; break; case RTE_CRYPTODEV_AESNI_MB_PMD: @@ -508,6 +509,9 @@ case RTE_CRYPTODEV_OPENSSL_PMD: target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL; break; + case RTE_CRYPTODEV_ARMV8_PMD: + target_pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_ARMV8; + break; default: TEST_ASSERT(0, "Unrecognized cryptodev type"); break; diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h index 04ff1ee..bd362c7 100644 --- a/app/test/test_cryptodev_blockcipher.h +++ b/app/test/test_cryptodev_blockcipher.h @@ -49,6 +49,7 @@ #define BLOCKCIPHER_TEST_TARGET_PMD_MB 0x0001 /* Multi-buffer flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_QAT 0x0002 /* QAT flag */ #define BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL 0x0004 /* SW OPENSSL flag */ +#define BLOCKCIPHER_TEST_TARGET_PMD_ARMV8 0x0008 /* ARMv8 flag */ #define BLOCKCIPHER_TEST_OP_CIPHER (BLOCKCIPHER_TEST_OP_ENCRYPT | \ BLOCKCIPHER_TEST_OP_DECRYPT) diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c index 59a6891..3598edf 100644 --- a/app/test/test_cryptodev_perf.c +++ b/app/test/test_cryptodev_perf.c @@ -157,6 +157,12 @@ struct crypto_unittest_params { enum rte_crypto_cipher_algorithm cipher_algo, unsigned int cipher_key_len, enum rte_crypto_auth_algorithm auth_algo); +static struct rte_cryptodev_sym_session * +test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain, + enum rte_crypto_cipher_algorithm cipher_algo, + unsigned cipher_key_len, + enum rte_crypto_auth_algorithm auth_algo); + static struct rte_mbuf * test_perf_create_pktmbuf(struct rte_mempool *mpool, unsigned buf_sz); static inline struct rte_crypto_op * @@ -397,6 +403,27 @@ static const char *auth_algo_name(enum rte_crypto_auth_algorithm auth_algo) } } + /* Create 2 ARMv8 devices if required */ + if (gbl_cryptodev_perftest_devtype == RTE_CRYPTODEV_ARMV8_PMD) { +#ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO + RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be" + " enabled in config file to run this testsuite.\n"); + return TEST_FAILED; +#endif + nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ARMV8_PMD); + if (nb_devs < 2) { + for (i = nb_devs; i < 2; i++) { + ret = rte_eal_vdev_init( + RTE_STR(CRYPTODEV_NAME_ARMV8_PMD), + NULL); + + TEST_ASSERT(ret == 0, "Failed to create " + "instance %u of pmd : %s", i, + RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)); + } + } + } + #ifndef RTE_LIBRTE_PMD_QAT if (gbl_cryptodev_perftest_devtype == RTE_CRYPTODEV_QAT_SYM_PMD) { RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled " @@ -2422,6 +2449,136 @@ struct crypto_data_params aes_cbc_hmac_sha256_output[MAX_PACKET_SIZE_INDEX] = { return TEST_SUCCESS; } +static int +test_perf_armv8_optimise_cyclecount(struct perf_test_params *pparams) +{ + uint32_t num_to_submit = pparams->total_operations; + struct rte_crypto_op *c_ops[num_to_submit]; + struct rte_crypto_op *proc_ops[num_to_submit]; + uint64_t failed_polls, retries, start_cycles, end_cycles, + total_cycles = 0; + uint32_t burst_sent = 0, burst_received = 0; + uint32_t i, burst_size, num_sent, num_ops_received; + + struct crypto_testsuite_params *ts_params = &testsuite_params; + + static struct rte_cryptodev_sym_session *sess; + + unsigned int digest_length = get_auth_digest_length(pparams->auth_algo); + + if (rte_cryptodev_count() == 0) { + printf("\nNo crypto devices found. Is PMD build configured?\n"); + return TEST_FAILED; + } + + /* Create Crypto session*/ + sess = test_perf_create_armv8_session(ts_params->dev_id, + pparams->chain, pparams->cipher_algo, + pparams->cipher_key_length, pparams->auth_algo); + TEST_ASSERT_NOT_NULL(sess, "Session creation failed"); + + /* Generate Crypto op data structure(s)*/ + for (i = 0; i < num_to_submit ; i++) { + struct rte_mbuf *m = test_perf_create_pktmbuf( + ts_params->mbuf_mp, + pparams->buf_size); + TEST_ASSERT_NOT_NULL(m, "Failed to allocate tx_buf"); + + struct rte_crypto_op *op = + rte_crypto_op_alloc(ts_params->op_mpool, + RTE_CRYPTO_OP_TYPE_SYMMETRIC); + TEST_ASSERT_NOT_NULL(op, "Failed to allocate op"); + + op = test_perf_set_crypto_op_aes(op, m, sess, pparams->buf_size, + digest_length); + TEST_ASSERT_NOT_NULL(op, "Failed to attach op to session"); + + c_ops[i] = op; + } + + printf("\nOn %s dev%u qp%u, %s, cipher algo:%s, cipher key length:%u, " + "auth_algo:%s, Packet Size %u bytes", + pmd_name(gbl_cryptodev_perftest_devtype), + ts_params->dev_id, 0, + chain_mode_name(pparams->chain), + cipher_algo_name(pparams->cipher_algo), + pparams->cipher_key_length, + auth_algo_name(pparams->auth_algo), + pparams->buf_size); + printf("\nOps Tx\tOps Rx\tOps/burst "); + printf("Retries " + "EmptyPolls\tIACycles/CyOp\tIACycles/Burst\tIACycles/Byte"); + + for (i = 2; i <= 128 ; i *= 2) { + num_sent = 0; + num_ops_received = 0; + retries = 0; + failed_polls = 0; + burst_size = i; + total_cycles = 0; + while (num_sent < num_to_submit) { + start_cycles = rte_rdtsc_precise(); + burst_sent = rte_cryptodev_enqueue_burst( + ts_params->dev_id, + 0, &c_ops[num_sent], + ((num_to_submit - num_sent) < burst_size) ? + num_to_submit - num_sent : burst_size); + end_cycles = rte_rdtsc_precise(); + if (burst_sent == 0) + retries++; + num_sent += burst_sent; + total_cycles += (end_cycles - start_cycles); + + /* Wait until requests have been sent. */ + rte_delay_ms(1); + + start_cycles = rte_rdtsc_precise(); + burst_received = rte_cryptodev_dequeue_burst( + ts_params->dev_id, 0, proc_ops, + burst_size); + end_cycles = rte_rdtsc_precise(); + if (burst_received < burst_sent) + failed_polls++; + num_ops_received += burst_received; + + total_cycles += end_cycles - start_cycles; + } + + while (num_ops_received != num_to_submit) { + /* Sending 0 length burst to flush sw crypto device */ + rte_cryptodev_enqueue_burst( + ts_params->dev_id, 0, NULL, 0); + + start_cycles = rte_rdtsc_precise(); + burst_received = rte_cryptodev_dequeue_burst( + ts_params->dev_id, 0, proc_ops, burst_size); + end_cycles = rte_rdtsc_precise(); + + total_cycles += end_cycles - start_cycles; + if (burst_received == 0) + failed_polls++; + num_ops_received += burst_received; + } + + printf("\n%u\t%u\t%u", num_sent, num_ops_received, burst_size); + printf("\t\t%"PRIu64, retries); + printf("\t%"PRIu64, failed_polls); + printf("\t\t%"PRIu64, total_cycles/num_ops_received); + printf("\t\t%"PRIu64, + (total_cycles/num_ops_received)*burst_size); + printf("\t\t%"PRIu64, + total_cycles/(num_ops_received*pparams->buf_size)); + } + printf("\n"); + + for (i = 0; i < num_to_submit ; i++) { + rte_pktmbuf_free(c_ops[i]->sym->m_src); + rte_crypto_op_free(c_ops[i]); + } + + return TEST_SUCCESS; +} + static uint32_t get_auth_key_max_length(enum rte_crypto_auth_algorithm algo) { switch (algo) { @@ -2683,6 +2840,56 @@ static uint32_t get_auth_digest_length(enum rte_crypto_auth_algorithm algo) } } +static struct rte_cryptodev_sym_session * +test_perf_create_armv8_session(uint8_t dev_id, enum chain_mode chain, + enum rte_crypto_cipher_algorithm cipher_algo, + unsigned int cipher_key_len, + enum rte_crypto_auth_algorithm auth_algo) +{ + struct rte_crypto_sym_xform cipher_xform = { 0 }; + struct rte_crypto_sym_xform auth_xform = { 0 }; + + /* Setup Cipher Parameters */ + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; + cipher_xform.cipher.algo = cipher_algo; + + switch (cipher_algo) { + case RTE_CRYPTO_CIPHER_AES_CBC: + cipher_xform.cipher.key.data = aes_cbc_128_key; + break; + default: + return NULL; + } + + cipher_xform.cipher.key.length = cipher_key_len; + + /* Setup Auth Parameters */ + auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; + auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; + auth_xform.auth.algo = auth_algo; + + auth_xform.auth.digest_length = get_auth_digest_length(auth_algo); + + switch (chain) { + case CIPHER_HASH: + cipher_xform.next = &auth_xform; + auth_xform.next = NULL; + /* Encrypt and hash the result */ + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; + /* Create Crypto session*/ + return rte_cryptodev_sym_session_create(dev_id, &cipher_xform); + case HASH_CIPHER: + auth_xform.next = &cipher_xform; + cipher_xform.next = NULL; + /* Hash encrypted message and decrypt */ + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT; + /* Create Crypto session*/ + return rte_cryptodev_sym_session_create(dev_id, &auth_xform); + default: + return NULL; + } +} + #define AES_BLOCK_SIZE 16 #define AES_CIPHER_IV_LENGTH 16 @@ -3356,6 +3563,138 @@ static uint32_t get_auth_digest_length(enum rte_crypto_auth_algorithm algo) return TEST_SUCCESS; } +static int +test_perf_armv8(uint8_t dev_id, uint16_t queue_id, + struct perf_test_params *pparams) +{ + uint16_t i, k, l, m; + uint16_t j = 0; + uint16_t ops_unused = 0; + uint16_t burst_size; + uint16_t ops_needed; + + uint64_t burst_enqueued = 0, total_enqueued = 0, burst_dequeued = 0; + uint64_t processed = 0, failed_polls = 0, retries = 0; + uint64_t tsc_start = 0, tsc_end = 0; + + unsigned int digest_length = get_auth_digest_length(pparams->auth_algo); + + struct rte_crypto_op *ops[pparams->burst_size]; + struct rte_crypto_op *proc_ops[pparams->burst_size]; + + struct rte_mbuf *mbufs[pparams->burst_size * NUM_MBUF_SETS]; + + struct crypto_testsuite_params *ts_params = &testsuite_params; + + static struct rte_cryptodev_sym_session *sess; + + if (rte_cryptodev_count() == 0) { + printf("\nNo crypto devices found. Is PMD build configured?\n"); + return TEST_FAILED; + } + + /* Create Crypto session*/ + sess = test_perf_create_armv8_session(ts_params->dev_id, + pparams->chain, pparams->cipher_algo, + pparams->cipher_key_length, pparams->auth_algo); + TEST_ASSERT_NOT_NULL(sess, "Session creation failed"); + + /* Generate a burst of crypto operations */ + for (i = 0; i < (pparams->burst_size * NUM_MBUF_SETS); i++) { + mbufs[i] = test_perf_create_pktmbuf( + ts_params->mbuf_mp, + pparams->buf_size); + + if (mbufs[i] == NULL) { + printf("\nFailed to get mbuf - freeing the rest.\n"); + for (k = 0; k < i; k++) + rte_pktmbuf_free(mbufs[k]); + return -1; + } + } + + tsc_start = rte_rdtsc_precise(); + + while (total_enqueued < pparams->total_operations) { + if ((total_enqueued + pparams->burst_size) <= + pparams->total_operations) + burst_size = pparams->burst_size; + else + burst_size = pparams->total_operations - total_enqueued; + + ops_needed = burst_size - ops_unused; + + if (ops_needed != rte_crypto_op_bulk_alloc(ts_params->op_mpool, + RTE_CRYPTO_OP_TYPE_SYMMETRIC, ops, ops_needed)){ + printf("\nFailed to alloc enough ops, finish dequeuing " + "and free ops below."); + } else { + for (i = 0; i < ops_needed; i++) + ops[i] = test_perf_set_crypto_op_aes(ops[i], + mbufs[i + (pparams->burst_size * + (j % NUM_MBUF_SETS))], + sess, pparams->buf_size, digest_length); + + /* enqueue burst */ + burst_enqueued = rte_cryptodev_enqueue_burst(dev_id, + queue_id, ops, burst_size); + + if (burst_enqueued < burst_size) + retries++; + + ops_unused = burst_size - burst_enqueued; + total_enqueued += burst_enqueued; + } + + /* dequeue burst */ + burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id, + proc_ops, pparams->burst_size); + if (burst_dequeued == 0) + failed_polls++; + else { + processed += burst_dequeued; + + for (l = 0; l < burst_dequeued; l++) + rte_crypto_op_free(proc_ops[l]); + } + j++; + } + + /* Dequeue any operations still in the crypto device */ + while (processed < pparams->total_operations) { + /* Sending 0 length burst to flush sw crypto device */ + rte_cryptodev_enqueue_burst(dev_id, queue_id, NULL, 0); + + /* dequeue burst */ + burst_dequeued = rte_cryptodev_dequeue_burst(dev_id, queue_id, + proc_ops, pparams->burst_size); + if (burst_dequeued == 0) + failed_polls++; + else { + processed += burst_dequeued; + + for (m = 0; m < burst_dequeued; m++) + rte_crypto_op_free(proc_ops[m]); + } + } + + tsc_end = rte_rdtsc_precise(); + + double ops_s = ((double)processed / (tsc_end - tsc_start)) + * rte_get_tsc_hz(); + double throughput = (ops_s * pparams->buf_size * NUM_MBUF_SETS) + / 1000000000; + + printf("\t%u\t%6.2f\t%10.2f\t%8"PRIu64"\t%8"PRIu64, pparams->buf_size, + ops_s / 1000000, throughput, retries, failed_polls); + + for (i = 0; i < pparams->burst_size * NUM_MBUF_SETS; i++) + rte_pktmbuf_free(mbufs[i]); + + printf("\n"); + return TEST_SUCCESS; +} + /* perf_test_aes_sha("avx2", HASH_CIPHER, 16, CBC, SHA1); @@ -3664,6 +4003,153 @@ static uint32_t get_auth_digest_length(enum rte_crypto_auth_algorithm algo) } static int +test_perf_armv8_vary_pkt_size(void) +{ + unsigned int total_operations = 100000; + unsigned int burst_size = { 64 }; + unsigned int buf_lengths[] = { 64, 128, 256, 512, 768, 1024, 1280, 1536, + 1792, 2048 }; + uint8_t i, j; + + struct perf_test_params params_set[] = { + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256 + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256 + }, + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC + }, + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC + }, + }; + + for (i = 0; i < RTE_DIM(params_set); i++) { + params_set[i].total_operations = total_operations; + params_set[i].burst_size = burst_size; + printf("\n%s. cipher algo: %s auth algo: %s cipher key size=%u." + " burst_size: %d ops\n", + chain_mode_name(params_set[i].chain), + cipher_algo_name(params_set[i].cipher_algo), + auth_algo_name(params_set[i].auth_algo), + params_set[i].cipher_key_length, + burst_size); + printf("\nBuffer Size(B)\tOPS(M)\tThroughput(Gbps)\tRetries\t" + "EmptyPolls\n"); + for (j = 0; j < RTE_DIM(buf_lengths); j++) { + params_set[i].buf_size = buf_lengths[j]; + test_perf_armv8(testsuite_params.dev_id, 0, + ¶ms_set[i]); + } + } + + return 0; +} + +static int +test_perf_armv8_vary_burst_size(void) +{ + unsigned int total_operations = 4096; + uint16_t buf_lengths[] = { 64 }; + uint8_t i, j; + + struct perf_test_params params_set[] = { + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256 + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256 + }, + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC + }, + { + .chain = CIPHER_HASH, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC + }, + { + .chain = HASH_CIPHER, + + .cipher_algo = RTE_CRYPTO_CIPHER_AES_CBC, + .cipher_key_length = 16, + .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC + }, + }; + + printf("\n\nStart %s.", __func__); + printf("\nThis Test measures the average IA cycle cost using a " + "constant request(packet) size. "); + printf("Cycle cost is only valid when indicators show device is " + "not busy, i.e. Retries and EmptyPolls = 0"); + + for (i = 0; i < RTE_DIM(params_set); i++) { + printf("\n"); + params_set[i].total_operations = total_operations; + + for (j = 0; j < RTE_DIM(buf_lengths); j++) { + params_set[i].buf_size = buf_lengths[j]; + test_perf_armv8_optimise_cyclecount(¶ms_set[i]); + } + } + + return 0; +} + +static int test_perf_aes_cbc_vary_burst_size(void) { return test_perf_crypto_qp_vary_burst_size(testsuite_params.dev_id); @@ -4214,6 +4700,19 @@ static int test_continual_perf_AES_GCM(void) } }; +static struct unit_test_suite cryptodev_armv8_testsuite = { + .suite_name = "Crypto Device ARMv8 Unit Test Suite", + .setup = testsuite_setup, + .teardown = testsuite_teardown, + .unit_test_cases = { + TEST_CASE_ST(ut_setup, ut_teardown, + test_perf_armv8_vary_pkt_size), + TEST_CASE_ST(ut_setup, ut_teardown, + test_perf_armv8_vary_burst_size), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + static int perftest_aesni_gcm_cryptodev(void) { @@ -4270,6 +4769,14 @@ static int test_continual_perf_AES_GCM(void) return unit_test_suite_runner(&cryptodev_qat_continual_testsuite); } +static int +perftest_sw_armv8_cryptodev(void /*argv __rte_unused, int argc __rte_unused*/) +{ + gbl_cryptodev_perftest_devtype = RTE_CRYPTODEV_ARMV8_PMD; + + return unit_test_suite_runner(&cryptodev_armv8_testsuite); +} + REGISTER_TEST_COMMAND(cryptodev_aesni_mb_perftest, perftest_aesni_mb_cryptodev); REGISTER_TEST_COMMAND(cryptodev_qat_perftest, perftest_qat_cryptodev); REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_perftest, perftest_sw_snow3g_cryptodev); @@ -4279,3 +4786,4 @@ static int test_continual_perf_AES_GCM(void) perftest_openssl_cryptodev); REGISTER_TEST_COMMAND(cryptodev_qat_continual_perftest, perftest_qat_continual_cryptodev); +REGISTER_TEST_COMMAND(cryptodev_sw_armv8_perftest, perftest_sw_armv8_cryptodev); -- 1.9.1