From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6841745538; Mon, 1 Jul 2024 14:55:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02769427C6; Mon, 1 Jul 2024 14:55:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id EFC8E427BE for ; Mon, 1 Jul 2024 14:55:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719838536; x=1751374536; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=9oQtuKTWppuy3Y6k0gmXngM4KEQWmTc2SddbmksU2Vc=; b=RsnbEkv/3c7XBFREMWeUk2KalSOSLkow7lugjtuwBqx3kmnR+EEQhY8D fmBP79A1zVnujkB9lKs800kW55sWGK7+2okgLmCVF5o6T4oxg1w7bMeYs riacVoGXJml6UOwyml5OZ9pEvz9fmNg5c+yPC+HGRdE1QrSmTztz7p1R4 Rs9+KKNYhR0CSiJQcihot3vArJE/bbjj4+vSUdGnq9c+JChvj8xYK67I1 0CDLCT9fCY12kOYwe3mdrYf/wo0AaVDmST5mxw/r5Q1KJFVayv6f8zfMD i68GiGPMKNnyQi/d7Gg8Cdw6eK/3hnsTCHN2ZiC5J6Hkf2BDoaonGJBi1 g==; X-CSE-ConnectionGUID: DKzlbpIERX+W4sUG/lTSng== X-CSE-MsgGUID: MtGVYvaDSwq/K7Dr9CT+UA== X-IronPort-AV: E=McAfee;i="6700,10204,11120"; a="16691689" X-IronPort-AV: E=Sophos;i="6.09,176,1716274800"; d="scan'208,217";a="16691689" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2024 05:55:28 -0700 X-CSE-ConnectionGUID: f0AaZE+oSe6i6PPBWS/FQQ== X-CSE-MsgGUID: 053axqP6QRWA8Cs9/Khomw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,176,1716274800"; d="scan'208,217";a="76234183" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Jul 2024 05:55:28 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 05:55:27 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 1 Jul 2024 05:55:27 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Mon, 1 Jul 2024 05:55:27 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.49) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 1 Jul 2024 05:55:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acZqicYSEqEheyFFX7PMMWi2BQDyyFZqz+Zd3ozKEl+50HTQ7g7dr0HrcL5EQBfN3mYcxv/xwidLL/zcyY+1anqYnHgoVKpsvejBo/wAcIQInCJZcUU2fVOIOFOGf6A4hAt4JFHwgt73Dohh72hqThvCgUroe5cPPfl7rWlHTpCsMPbiz3I7aWK7moavcVTA+uHIVkcDTWHskkupnXJcpxKbEwCFPAmc0RiwlgH/GWVPUxnK7l8KaRQUeLnwhXzgT5YpvgwCfrT39HgacyANwbGcFgkgjeOH8GHUsDe5kWzhw7GpjeHX6B5QDM5abFOLV46LChIOmIsBdVaKnfMaPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jXDbLNQPMDmVKMrUuoVgzy/WyWUHGBdAVRAdHOPYnXg=; b=RuvsjyKiLJW96lMZyZBUP+r4KmbmFMQPWAoXYF4yqv6kX3tHqJBC7Hhlhnt0oYKfKR8mC8Qeq5D/qiIJV5TaptntBFZAZ6ZASOPOdc4iOUX8hs5o9aEiZxvOaZhgHw0yklZ/G61nelYTgiQxoILbhztOXvQ9QrK+W5QMdOBvJ9g6M6kYOEGWEeiMI1sG3RdfYDVLzLaIr8K3M+EbNv5MzF3JwyvIzFBgXAjtFF7e/C8E6Ibnmeu4Wc8jJlaD3UFecpV90faMGayt9g56CYPwSl/dL1NvKrkeMZE83miSv07ZkNAUiMRP4B4RkPEAAir1KWGyrNEjnEUxWdFYZI/gKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DS0PR11MB7458.namprd11.prod.outlook.com (2603:10b6:8:145::13) by DM4PR11MB6408.namprd11.prod.outlook.com (2603:10b6:8:b7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.32; Mon, 1 Jul 2024 12:55:25 +0000 Received: from DS0PR11MB7458.namprd11.prod.outlook.com ([fe80::1a9e:53a6:9603:8f79]) by DS0PR11MB7458.namprd11.prod.outlook.com ([fe80::1a9e:53a6:9603:8f79%5]) with mapi id 15.20.7719.028; Mon, 1 Jul 2024 12:55:25 +0000 From: "Ji, Kai" To: Jack Bond-Preston CC: "dev@dpdk.org" , Wathsala Vithanage Subject: Re: [PATCH v4 2/5] crypto/openssl: only init 3DES-CTR key + impl once Thread-Topic: [PATCH v4 2/5] crypto/openssl: only init 3DES-CTR key + impl once Thread-Index: AQHauNj4H2/jK6z05kC8tDDX+fat6bHh+iC8 Date: Mon, 1 Jul 2024 12:55:25 +0000 Message-ID: References: <20240603160119.1279476-1-jack.bond-preston@foss.arm.com> <20240607124756.3968704-1-jack.bond-preston@foss.arm.com> <20240607124756.3968704-3-jack.bond-preston@foss.arm.com> In-Reply-To: <20240607124756.3968704-3-jack.bond-preston@foss.arm.com> Accept-Language: en-GB, en-US, en-IE Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR11MB7458:EE_|DM4PR11MB6408:EE_ x-ms-office365-filtering-correlation-id: 25610d76-0c54-4f9e-1abb-08dc99cd13aa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?eFQ/wqQ5KFUUa7DYvlYqSnfYVVqOCNZvxLnXqiL2aRjnt9m4y0pm7J2RzVpa?= =?us-ascii?Q?z5hrO5ktRRZUIT9NoNuiHVjCkjdQouEG0pOAQT/O7i2yKvjAAnnAVwAvqAEZ?= =?us-ascii?Q?odFjgE9CDlzqfIqHip8uR0gK4FchifhDmhAujA8VNncIhvLqkmYjw5Hl9sRv?= =?us-ascii?Q?kwbyIdrnICaGyFeturmdTcK7aBq3SYIwC1hTMX2UMJo8WA86JS+eL3g/otus?= =?us-ascii?Q?w/roJ46ms3J1aL9lVgjxZmxgYbgZpMDfP4fRFrK2utEk63ikldKyDJ5vlLQV?= =?us-ascii?Q?E24JbYQ4i2RoILIWUNKmHlX9UnEuyBGsxqtjVmtUuQV1/tErsnHv0IRsrbPP?= =?us-ascii?Q?yfUfFLvv7CJk8ugibvyK7aayIqz7/3P2pW1+rXJT0NzinXycs0K4Ld+RWWx1?= =?us-ascii?Q?p0yHApBkZstH2Zp0ozspd9con8h8E0ntGVJ+qHHepiDg72eLE9naJNA0h51P?= =?us-ascii?Q?u8A3pRus0bt/Uv4YNLsqr1riE0fJL1kKC0z3OyAcil9Myqhtz888QiHBENMq?= =?us-ascii?Q?GsonGXjtBN20DZb4V6A40ZLb2DhFzH8vmmIfxXW+KlG6g14c9qlBPZF/sXAt?= =?us-ascii?Q?JaO2EHrf32oTBisBlWds+vm3J+GfEaf9zblgWTGcv05j+P6sGVRl3KQYdfqG?= =?us-ascii?Q?wuatDQEYFvSH03ryNyEnltV3X9vnZtjUP10wl8K2zvd2GDoV4dxmufmpuj8A?= =?us-ascii?Q?WV0EqqtnYPazXpoY0Y7glotn7CpXtthEqUBGWGmH4lWaqNOoK7v/QU6qQY18?= =?us-ascii?Q?Xc7UxlU4KgwjSYn0I4v04MeFtOccfpFg945oPJWh1egjOaFAvXnUJgjovo+i?= =?us-ascii?Q?8cbfTSrzQJD2vKpbkPhhEtCRTiQgpdoUjYQxsmp1H40aohqe2xkE5uhdU2ld?= =?us-ascii?Q?db4+CoOwARtMGz6T1rqEBowAMIuQRZmVc0J7mI7CQ7QVtQnOKYppcyf5mLzJ?= =?us-ascii?Q?EwPGWuAZe+gIEosKOOu1EHbG/C8WTMI9xhCkRpP8/zDBF7EPMaUu/K01AFsI?= =?us-ascii?Q?T5YvSyjD5ESmPnl0r7dZcX84q0dklsSnnbYMr7tgNkWEnAt8l6uUdZIokLyl?= =?us-ascii?Q?VVCDQl6lCa2gzeTe59q8krLWzUHi1IlEp9cbRAF8+DA87dkgTp7euFDiERI3?= =?us-ascii?Q?sp9tEQSd5PHI9kJKliLsT9np1GGzE61vALmbl/3pw/8iQIV0Psg17Bu1SiBv?= =?us-ascii?Q?Fm1nDKQr2glX9+7jsycpmfluhSxtG0ZU1ymBOOMoihxc6PJxSvhZXYVOcUCA?= =?us-ascii?Q?VI3K+H/J86PPFj5oyLpioUXzc7y8ICEoPc9RVDpyc79bM05vkWi8wwNlKuoz?= =?us-ascii?Q?Q5vShFL/iiDanTzFfN7ZxkfCdhvvNDWXsbbE+VVtu5KhDaR2LTYr4id82ZQr?= =?us-ascii?Q?7xv+iUWAsMtunc3+SAUHqUfMfc98PB2Kxff8EX/Gsd0j2IGRlw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7458.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ElyKtlNv5uQA9yPe2uXv28xp95Eobc0KNW0hYXssituYo4UNE4ZTbtzJJjYr?= =?us-ascii?Q?Vr/NbOKeMQjnmL1PcroktWXVtXB6n79EqXYFFBKfgDJna4qLSZKqM05aouWa?= =?us-ascii?Q?HrWyg5Ca9qZGdO18A0ZNNradDVV+bTYQ/HuZPtkt+bbHtst49/CtDCdtNoKW?= =?us-ascii?Q?1tYG25Lg4e6jI+W1yHWRaIrTDYIUfRog5utk0yqEIQS8nsUwq4MY2SG3NpQD?= =?us-ascii?Q?f31ecn/WAnPLg+YVbP774gcfYRHmOA7YUo1bxPIOeGyljjOUUZeUYy1XRC6w?= =?us-ascii?Q?RTzIdtr44MtRxFEE+lZAJDV9IL4nXGbZ+V74HrM8/1zx4XoN7VKrRPRgAgqA?= =?us-ascii?Q?jwQD4sTuzcqyiqikqRHebuJeyWbeJbrKqQvB/P6ohgEpdGh9HnSKBdkhhvHh?= =?us-ascii?Q?Td8hTJSsjx3PZjbBu1AUANbBIXqbkvXrn9LY1Y4EjIZ7nBNV2h99mDuFJBZQ?= =?us-ascii?Q?DmQOcjbNWQDwoBesGjb2eF+oCPaVgvrwnkq88mzUaoYDYorA29FU2mN1TPPH?= =?us-ascii?Q?vDrsL6MdcVyaBsAlVjgdKJXiVRyFs796pwtTVG17KSSghI34pSQBcrzEfsHP?= =?us-ascii?Q?18OpeD/sqSOuU5JkWc7HNaObU9pLm6RdcMjT1yDqXzcrYsF/ksAfcnBw/w9G?= =?us-ascii?Q?chtl6VgSXDKjL0PxTW6kv2D4jrie8jYb+YDq+a3pCugOvgmpDr0T8/7xi/li?= =?us-ascii?Q?3LS0twSTbDYozFyUGIfivayvLbAmwUtC0MavHfNeO5Hx9Lp/5civ7MNwC60S?= =?us-ascii?Q?JpPuzgVoy23fis7SlJ5dbwVcxxQQlNfr9X19aSyN1d6amsPLYNldbkM7qRje?= =?us-ascii?Q?IdUlsMbNlTpCmdGMUFyzmLEyn3lZUKByABR3aSHkTNJtIK5PN2+RM4i3n/UU?= =?us-ascii?Q?uYlE8028o2jvQqCinh+3cRqpUKMU//FTdKCmUczIRx9soMFiLNuw4S6vVVGv?= =?us-ascii?Q?oN5kGylpTV1OqP249SRHKn52a648bX17G9GI0L66cDfXDNQJV6Feeyf33aOw?= =?us-ascii?Q?E0ouhAuZcST9fTOXARHXBnGk89ACI8cZYryVxfhGfH43e2JGfN36j61Mu2ph?= =?us-ascii?Q?vDmp6+fcN7dTftZVhYfM7HCWl8GYbloTnV46vj1JGtg14+T80s2XLRp+BLu2?= =?us-ascii?Q?1nvpouolFcdNooLEsg9iSYjT2Ln97JmB4vmhVPvmwDBbruJeqOB732JuE+NA?= =?us-ascii?Q?VjyVbqqhVHA5eoX1p071yih+vWbogutp0+g7IwIr8+F+UELiZ83r2blJiZQ5?= =?us-ascii?Q?KIYYv0lZ0uYiIVyQ+3gbCBCvDdB+ob3TBiZn0YSwuA03inshvRc/Hg0xRJ67?= =?us-ascii?Q?31753sgLFuB5HCwL1AaqR56aC5Ax/Z0rHzVc5tvDJQ5I/gVo9yQ/xllJvJPD?= =?us-ascii?Q?5WxfIKILv+8RtKYr1eICBFuKcRTRAfVJVwq1WSawMeMWLG6Lw1tmODo2/mkF?= =?us-ascii?Q?cgz4A2WEVsrw/JroKFE6Zgxm8aGqpSs5mN/WkUM/kMGvOSCYT9Pq+Bad/RJ6?= =?us-ascii?Q?pGMovekhqgQXW2PlePwlaKt+Bk1K2bRzKk8Kf/EYWaPW3LwiYZbDEyf7V7q2?= =?us-ascii?Q?fDXSjD0rNDuXoJlCTlM=3D?= Content-Type: multipart/alternative; boundary="_000_DS0PR11MB7458670EDF23199343AF822081D32DS0PR11MB7458namp_" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7458.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25610d76-0c54-4f9e-1abb-08dc99cd13aa X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jul 2024 12:55:25.6653 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: neY6HzWw3ysXF0g8YrKh6qYo4CyVIaFq/6W0SH6mo5EBLhKynSacFKgkZ2HAl2IFBzpVyHMDbzxlyN9Iij4e+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6408 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --_000_DS0PR11MB7458670EDF23199343AF822081D32DS0PR11MB7458namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Kai Ji ________________________________ From: Jack Bond-Preston Sent: 07 June 2024 13:47 To: Ji, Kai Cc: dev@dpdk.org ; Wathsala Vithanage Subject: [PATCH v4 2/5] crypto/openssl: only init 3DES-CTR key + impl once Currently the 3DES-CTR cipher context is initialised for every buffer, setting the cipher implementation and key - even though for every buffer in the session these values will be the same. Change to initialising the cipher context once, before any buffers are processed, instead. Throughput performance uplift measurements for 3DES-CTR encrypt on Ampere Altra Max platform: 1 worker lcore | buffer sz (B) | prev (Gbps) | optimised (Gbps) | uplift | |-----------------+---------------+--------------------+----------| | 64 | 0.16 | 0.21 | 35.3% | | 256 | 0.20 | 0.22 | 9.4% | | 1024 | 0.22 | 0.23 | 2.3% | | 2048 | 0.22 | 0.23 | 0.9% | | 4096 | 0.22 | 0.23 | 0.9% | 8 worker lcores | buffer sz (B) | prev (Gbps) | optimised (Gbps) | uplift | |-----------------+---------------+--------------------+----------| | 64 | 1.01 | 1.34 | 32.9% | | 256 | 1.51 | 1.66 | 9.9% | | 1024 | 1.72 | 1.77 | 2.6% | | 2048 | 1.76 | 1.78 | 1.1% | | 4096 | 1.79 | 1.80 | 0.6% | Signed-off-by: Jack Bond-Preston Reviewed-by: Wathsala Vithanage --- drivers/crypto/openssl/rte_openssl_pmd.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/open= ssl/rte_openssl_pmd.c index 3f7f4d8c37..70f2069985 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -553,6 +553,15 @@ openssl_set_session_cipher_parameters(struct openssl_s= ession *sess, sess->cipher.key.length, sess->cipher.key.data) !=3D 0) return -EINVAL; + + + /* We use 3DES encryption also for decryption. + * IV is not important for 3DES ECB. + */ + if (EVP_EncryptInit_ex(sess->cipher.ctx, EVP_des_ede3_ecb()= , + NULL, sess->cipher.key.data, NULL) !=3D 1) + return -EINVAL; + break; case RTE_CRYPTO_CIPHER_DES_CBC: @@ -1172,8 +1181,7 @@ process_openssl_cipher_decrypt(struct rte_mbuf *mbuf_= src, uint8_t *dst, /** Process cipher des 3 ctr encryption, decryption algorithm */ static int process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, - int offset, uint8_t *iv, uint8_t *key, int srclen, - EVP_CIPHER_CTX *ctx) + int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { uint8_t ebuf[8], ctr[8]; int unused, n; @@ -1191,12 +1199,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf= _src, uint8_t *dst, src =3D rte_pktmbuf_mtod_offset(m, uint8_t *, offset); l =3D rte_pktmbuf_data_len(m) - offset; - /* We use 3DES encryption also for decryption. - * IV is not important for 3DES ecb - */ - if (EVP_EncryptInit_ex(ctx, EVP_des_ede3_ecb(), NULL, key, NULL) <= =3D 0) - goto process_cipher_des3ctr_err; - memcpy(ctr, iv, 8); for (n =3D 0; n < srclen; n++) { @@ -1740,8 +1742,7 @@ process_openssl_cipher_op srclen, ctx_copy, inplace); else status =3D process_openssl_cipher_des3ctr(mbuf_src, dst, - op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, + op->sym->cipher.data.offset, iv, srclen, ctx_copy); EVP_CIPHER_CTX_free(ctx_copy); -- 2.34.1 --_000_DS0PR11MB7458670EDF23199343AF822081D32DS0PR11MB7458namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Acked-by: Kai Ji <kai.ji@intel.com>

From: Jack Bond-Preston <= ;jack.bond-preston@foss.arm.com>
Sent: 07 June 2024 13:47
To: Ji, Kai <kai.ji@intel.com>
Cc: dev@dpdk.org <dev@dpdk.org>; Wathsala Vithanage <wathsa= la.vithanage@arm.com>
Subject: [PATCH v4 2/5] crypto/openssl: only init 3DES-CTR key + imp= l once
 
Currently the 3DES-CTR cipher context is initialis= ed for every buffer,
setting the cipher implementation and key - even though for every
buffer in the session these values will be the same.

Change to initialising the cipher context once, before any buffers are
processed, instead.

Throughput performance uplift measurements for 3DES-CTR encrypt on
Ampere Altra Max platform:
1 worker lcore
|   buffer sz (B) |   prev (Gbps) |   optimis= ed (Gbps) |   uplift |
|-----------------+---------------+--------------------+----------|
|            &n= bsp; 64 |          0.16 | = ;            &n= bsp; 0.21 |    35.3% |
|             2= 56 |          0.20 | &nbs= p;             = 0.22 |     9.4% |
|            1024 |&= nbsp;         0.22 |  &nb= sp;            0.23 = |     2.3% |
|            2048 |&= nbsp;         0.22 |  &nb= sp;            0.23 = |     0.9% |
|            4096 |&= nbsp;         0.22 |  &nb= sp;            0.23 = |     0.9% |

8 worker lcores
|   buffer sz (B) |   prev (Gbps) |   optimis= ed (Gbps) |   uplift |
|-----------------+---------------+--------------------+----------|
|            &n= bsp; 64 |          1.01 | = ;            &n= bsp; 1.34 |    32.9% |
|             2= 56 |          1.51 | &nbs= p;             = 1.66 |     9.9% |
|            1024 |&= nbsp;         1.72 |  &nb= sp;            1.77 = |     2.6% |
|            2048 |&= nbsp;         1.76 |  &nb= sp;            1.78 = |     1.1% |
|            4096 |&= nbsp;         1.79 |  &nb= sp;            1.80 = |     0.6% |

Signed-off-by: Jack Bond-Preston <jack.bond-preston@foss.arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 21 +++++++++++----------  1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/open= ssl/rte_openssl_pmd.c
index 3f7f4d8c37..70f2069985 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -553,6 +553,15 @@ openssl_set_session_cipher_parameters(struct openssl_s= ession *sess,
            &nb= sp;            =         sess->cipher.key.length,
            &nb= sp;            =         sess->cipher.key.data) !=3D 0= )
            &nb= sp;            retur= n -EINVAL;
+
+
+            &n= bsp;  /* We use 3DES encryption also for decryption.
+            &n= bsp;   * IV is not important for 3DES ECB.
+            &n= bsp;   */
+            &n= bsp;  if (EVP_EncryptInit_ex(sess->cipher.ctx, EVP_des_ede3_ecb(),<= br> +            &n= bsp;            = ;      NULL, sess->cipher.key.data,  NULL)= !=3D 1)
+            &n= bsp;          return -EINVAL;<= br> +
            &nb= sp;    break;
 
         case RTE_CRYPTO_CIPHER_DES= _CBC:
@@ -1172,8 +1181,7 @@ process_openssl_cipher_decrypt(struct rte_mbuf *mbuf_= src, uint8_t *dst,
 /** Process cipher des 3 ctr encryption, decryption algorithm */
 static int
 process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *ds= t,
-            &n= bsp;  int offset, uint8_t *iv, uint8_t *key, int srclen,
-            &n= bsp;  EVP_CIPHER_CTX *ctx)
+            &n= bsp;  int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx)
 {
         uint8_t ebuf[8], ctr[8];          int unused, n;
@@ -1191,12 +1199,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf= _src, uint8_t *dst,
         src =3D rte_pktmbuf_mtod_o= ffset(m, uint8_t *, offset);
         l =3D rte_pktmbuf_data_len= (m) - offset;
 
-       /* We use 3DES encryption also for de= cryption.
-        * IV is not important for 3DES = ecb
-        */
-       if (EVP_EncryptInit_ex(ctx, EVP_des_e= de3_ecb(), NULL, key, NULL) <=3D 0)
-            &n= bsp;  goto process_cipher_des3ctr_err;
-
         memcpy(ctr, iv, 8);
 
         for (n =3D 0; n < srcle= n; n++) {
@@ -1740,8 +1742,7 @@ process_openssl_cipher_op
            &nb= sp;            =             &nb= sp;   srclen, ctx_copy, inplace);
         else
            &nb= sp;    status =3D process_openssl_cipher_des3ctr(mbuf_src, d= st,
-            &n= bsp;            = ;      op->sym->cipher.data.offset, iv,
-            &n= bsp;            = ;      sess->cipher.key.data, srclen,
+            &n= bsp;            = ;      op->sym->cipher.data.offset, iv, srcl= en,
            &nb= sp;            =         ctx_copy);
 
         EVP_CIPHER_CTX_free(ctx_co= py);
--
2.34.1

--_000_DS0PR11MB7458670EDF23199343AF822081D32DS0PR11MB7458namp_--