From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0055.outbound.protection.outlook.com [104.47.36.55]) by dpdk.org (Postfix) with ESMTP id E469111D4 for ; Tue, 29 Aug 2017 09:01:00 +0200 (CEST) Received: from BN6PR03CA0022.namprd03.prod.outlook.com (10.168.230.160) by MWHPR03MB3325.namprd03.prod.outlook.com (10.174.249.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Tue, 29 Aug 2017 07:00:59 +0000 Received: from BY2FFO11FD042.protection.gbl (2a01:111:f400:7c0c::116) by BN6PR03CA0022.outlook.office365.com (2603:10b6:404:23::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9 via Frontend Transport; Tue, 29 Aug 2017 07:00:58 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD042.mail.protection.outlook.com (10.1.14.227) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Tue, 29 Aug 2017 07:00:58 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7T70o0P001223; Tue, 29 Aug 2017 00:00:55 -0700 From: Akhil Goyal To: , CC: , , Akhil Goyal Date: Tue, 29 Aug 2017 12:28:49 +0530 Message-ID: <20170829065849.11424-2-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170829065849.11424-1-akhil.goyal@nxp.com> References: <20170728110738.28922-3-akhil.goyal@nxp.com> <20170829065849.11424-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131484636585462685; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(76176999)(106466001)(498600001)(1076002)(86362001)(5003940100001)(50466002)(53936002)(77096006)(33646002)(50986999)(48376002)(356003)(8936002)(47776003)(6666003)(50226002)(8656003)(189998001)(54906002)(36756003)(305945005)(8676002)(2906002)(105606002)(2950100002)(81156014)(97736004)(81166006)(104016004)(5660300001)(4326008)(626005)(68736007)(85426001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB3325; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD042; 1:rqFhtfoE0VrXFTOUSuOV7BGNGPGaE9z1cIjG6JQ0Lio52by9m6Ay+Fpm1cC2gyC9KvP6zGhdKM0mOCrZgB66D/cI0cQ3VfOQOP6cP/mnScUYpqEFgbXJAhX9zhYUdXDT MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 072a6b82-b4bf-4692-9f34-08d4eeabb37a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR03MB3325; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB3325; 3:DlSUDkv+gQ7Wt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atv/vGRHtoyH03XP0WvzlahzHP2B1QPkgYghDa1lVASqsHwYM+aI/1d457PvwdASh08IZ92AqsBj7/30U01ddHR77YqkstX3dyuxvNgbqjaDHAoGXDh04K4y1XDCWIaXxVDmbuGRkGNsCI0lsdMsBFtilL3JDOxep2ohXYAU0+q2lQpTKZUIcpzmKiFHzL5AN1+Lne18T6yjo/IjCLyrtHtxNWWGC0o/Cy3JLXKD8= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(8121501046)(13018025)(13016025)(5005006)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6096035)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123556025)(20161123561025)(20161123565025)(20161123563025)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR03MB3325; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR03MB3325; X-Forefront-PRVS: 0414DF926F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB3325; 23:8sM0QvlDV368GwAs8ZoPfwLpIdOiOGQwNfCQLwSUp?= =?us-ascii?Q?tkj2OFFByVAYynhV7ny3rSSGwpqeNyplz+YVXuEQl139+YgLUpbaF9FvcitY?= =?us-ascii?Q?CczDxdC6lZccVXYu6Xeb1TdVpk76yMap4iDvw7M4smiAtNXP2/n50d77lFSG?= =?us-ascii?Q?LDxnFSX9mm9wgxjCXZVhwTd0Ud3Sy8aL03LI8dMaowAvqpq18H5z952XTc8u?= =?us-ascii?Q?9hrvUr05lt9zAR5EGMv+zuUTrLKb7YFut+xoIPSAhgAqznrmHSP+7g+mWcaB?= =?us-ascii?Q?eEdD0MVbJq92XQCPnJrkH76VUqrrF9tobLu2ynnj7CnNX1jS54Diy3c5C52k?= =?us-ascii?Q?e5HGE06/5/z6teqHQzv3BpuMVpV9QvZoqIgf6HmX1dCQzQBr7Oq599zzV7Ca?= =?us-ascii?Q?gQRbgcmweVI8/JvsD5TxZw2N4LoZ8pp4AXWC286p5MyPMJ+QV8V37pco5A15?= =?us-ascii?Q?BlaoAtsRc50i6DOZdgBIks6v/Ji8j8rj51cHiX3gR038W0a55fnF+CU1PBQ/?= =?us-ascii?Q?ZuliyZcuKzcEIFzw1wCKBnASB9q2dcAPuHLQq48gbFCh229a8oG+QFpQJXDB?= =?us-ascii?Q?DTyzofttHjcGFRlEVq/io3sdOKWfufwemewXFiriSgdAiCP7K/LtIah5K98C?= =?us-ascii?Q?O46Kd+d7pNMLxc6GMqGkBQLggKtcQ6FC5D/hPxlp9t9zkgk61uNat1meRmdz?= =?us-ascii?Q?Z95KJGHDO+Oxh4gVkUWrpGEA8FUVsOk3GrdIQfWn8jykAHvYqnhZdCIFTVtu?= =?us-ascii?Q?Gn/hicmrwjV0evfAoUm/TLuoFIKfLzze1yHAbX8CdlcFxUK4I2dNuBYMzWvX?= =?us-ascii?Q?IWtBamJCEKekAjDfx1xlZrIXbuGvxwednUuv0B6aF7x4B+ECC+0rW6uaEAdE?= =?us-ascii?Q?QBhB3z6i4/8KnGYAqDjwyvyGDh5541ugblDj/N70oOexvDlk0LeEHl78ZGdl?= =?us-ascii?Q?nrgmra8oWI5eKJgs9Vsz8ySobBQiyNNcgCZK9567j0wVW5MnhYr84OHbGwGn?= =?us-ascii?Q?9hEn2kD+Cp9H9jJNeME0MQ262FeNGUfzWM40fhA6j/aVZWbAdSNqDTrfDG0M?= =?us-ascii?Q?gJ28dKxB77ZVbSrRtYq/t05S1fvDrxqNOX3rszEZO9CsDom3A=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB3325; 6:sSTqcRFWRPssrZgzF+1U+LuhL/fY64uDbtpt7nmrtoZndRP2QuqdzWvrjVfFPN6/Gd+V0iaz/nxchPadPZW4LgkNZsrY9RSbz5EWxo/v/5D0xOkzBTEYMRDvBTahIo1GFAAUq2vqlBio8siiZ44nWGz/z9naSvvNW+0xZuhlpNx6lM51vy9kyTjPSc+BMWTiW9w4WC6+U+S0e8/pWMWGOGioBWM3fyBSqMmgun7Tcibmdkg787RcSUHioGkGKwUhlfNoMSCUuKrs6dQJxzgr+PtWJ7P3eKN+RWqs3sMzN/QfcZRN5WZv+J63ixZBDALogCEemMdn5Jz7Kii8NGuZ+g==; 5:mOHioqsMNlSqewf6cEDV930s3V1sdYh5M1vOXZ1FCq8Pc5Up5N48sHq8ClKLaGEgWkgXy5hX4fW/IaCpzJPv/87K5tKcAjY5x9HG9jFbg7HFoUgCJvAXaFzFNBagnLxsthf3LtoF2jDoT85pbUL8IA==; 24:Q6XKuSC8Rsk2XEeu6jrTl5KJtSMq7HYw3TiWwc9oaVc0ZFFbUuIGP+x9juDa6Tkdc7YUc6wr0IKV98NNKk2uxUZ/8dUsLLMqv0wtmXZ6KPg=; 7:UMtfoIgOGoqgqpLeUce21vWRJed5Bl0RnjE2I+MkduVwrYI8YMszJYV1e26cQTAKXz0uGY4r58TdyBTEfP6D9FaGB0aNu8wOnYdJajA5mpZ6nqgUrotIbp9B91YjTeMdRv3NGqp+7qM7pNZx4TkdeI7C+eVLWl9babAy7BMYtIsi+1ra6U2Tpe+naKauL1pvi/Q6wRCccOucP77Z6OeQk+LoVXP6DKhNEdjXlBIIIZQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 07:00:58.2030 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB3325 Subject: [dpdk-dev] [PATCH v2 2/2] crypto/openssl: performance improvements 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: Tue, 29 Aug 2017 07:01:01 -0000 key and algo are added in the openssl ctx during session initialization instead of adding it for each packet. Signed-off-by: Akhil Goyal --- drivers/crypto/openssl/rte_openssl_pmd.c | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 889d632..b11a7fb 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -308,6 +308,22 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, get_cipher_key(xform->cipher.key.data, sess->cipher.key.length, sess->cipher.key.data); + if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) { + if (EVP_EncryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } else if (sess->cipher.direction == + RTE_CRYPTO_CIPHER_OP_DECRYPT) { + if (EVP_DecryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } break; @@ -334,6 +350,23 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, get_cipher_key(xform->cipher.key.data, sess->cipher.key.length, sess->cipher.key.data); + if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) { + if (EVP_EncryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } else if (sess->cipher.direction == + RTE_CRYPTO_CIPHER_OP_DECRYPT) { + if (EVP_DecryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } + break; default: sess->cipher.algo = RTE_CRYPTO_CIPHER_NULL; @@ -698,12 +731,11 @@ process_openssl_decryption_update(struct rte_mbuf *mbuf_src, int offset, /** Process standard openssl cipher encryption */ static int process_openssl_cipher_encrypt(struct rte_mbuf *mbuf_src, uint8_t *dst, - int offset, uint8_t *iv, uint8_t *key, int srclen, - EVP_CIPHER_CTX *ctx, const EVP_CIPHER *algo) + int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { int totlen; - if (EVP_EncryptInit_ex(ctx, algo, NULL, key, iv) <= 0) + if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) goto process_cipher_encrypt_err; EVP_CIPHER_CTX_set_padding(ctx, 0); @@ -748,12 +780,11 @@ process_openssl_cipher_bpi_encrypt(uint8_t *src, uint8_t *dst, /** Process standard openssl cipher decryption */ static int process_openssl_cipher_decrypt(struct rte_mbuf *mbuf_src, uint8_t *dst, - int offset, uint8_t *iv, uint8_t *key, int srclen, - EVP_CIPHER_CTX *ctx, const EVP_CIPHER *algo) + int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { int totlen; - if (EVP_DecryptInit_ex(ctx, algo, NULL, key, iv) <= 0) + if (EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) goto process_cipher_decrypt_err; EVP_CIPHER_CTX_set_padding(ctx, 0); @@ -1126,15 +1157,11 @@ process_openssl_cipher_op if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) status = process_openssl_cipher_encrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); else status = process_openssl_cipher_decrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); else status = process_openssl_cipher_des3ctr(mbuf_src, dst, op->sym->cipher.data.offset, iv, @@ -1178,8 +1205,7 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op, /* Encrypt with the block aligned stream with CBC mode */ status = process_openssl_cipher_encrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, sess->cipher.evp_algo); + srclen, sess->cipher.ctx); if (last_block_len) { /* Point at last block */ dst += srclen; @@ -1229,9 +1255,7 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op, /* Decrypt with CBC mode */ status |= process_openssl_cipher_decrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); } } -- 2.9.3