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 03858455AD for ; Mon, 15 Jul 2024 17:28:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2AF9406B4; Mon, 15 Jul 2024 17:28:04 +0200 (CEST) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mails.dpdk.org (Postfix) with ESMTP id 29515402DD for ; Mon, 15 Jul 2024 17:28:03 +0200 (CEST) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52ed741fe46so1168018e87.0 for ; Mon, 15 Jul 2024 08:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057282; x=1721662082; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jFn8DtrGum29Uq6FpI3+s+FEV4JEiT86w+z25Ihp6/Q=; b=TQ7sqxZvfU7tVpRYopLdka3SIfWdbr52VDMeCiq53zlOFUOIYWovVrw7DU3KtF4aWQ AjkqoOcyBzxXQyH2p9NWzKFk8Xe2nq2qqZoLzzbyLRJG7tybq6Y9IxqRQT6sCOiQJZtv pEYo6MBl1TXKjZ1ycwRFmdlIk65tyPB8qxQ5pgTYsDqd5DGK6VcIrw0koJVW2RTjIK2B RwFr/vhR3V0etpCldueUNbwOq7F3Tn6CZIkKluEyEsu2dDFCeAQYztCjIiuasTqA1uXY kPvBtxizYfQ/T9odcRKGj2EA9QGMZ1D07KiCtqr9LrHeSFYMoDDapeB+xGFptntJ0uJb iyTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057282; x=1721662082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jFn8DtrGum29Uq6FpI3+s+FEV4JEiT86w+z25Ihp6/Q=; b=ZgVBETCJJN1u9P1eEFS4vo769+j1mEe2aIsWubaWMvO5xGHAErlsn6Z05RHtgRvnH/ EZOWE3ivpZqLh1sxc4GuRQLYN6zphIZK9c8R18h4BLAMnzdO1nw5gWZ4idGgUJ2ob3pr bOz3d/Zd1EQwLu+W6ojl6BndF51ZyOfBXR13dPTWO/0nwdDNNuUCHDbT9lZPdLP1m1Fr bDnE56sUFWyKWXg01BEXo8EGEdtoGZTNNOwclJrMwgkRL11Qa5yfe23Gt7EpQXss2qfS avKG+8qD6ocH5HBPQzvhGiUL6JNsV9WUIIQlLknayPfn/0Y7788unz+GgOIuoqNSbKL6 zsqA== X-Forwarded-Encrypted: i=1; AJvYcCWCeKOELPadsqdVR87+wanVizwgu0Uc9gaICDVBCph2JrQIsp2K3drd/Nw9zwI2XQ/fj1tXaT/WkVSFrUKM5PQ= X-Gm-Message-State: AOJu0YxQNkVuSiz6ditu8dD8cTzg6X1OUuIEfMBYeCNsfohcNWggJmOW AV1wdyuKl7h1JdKSaZUfwC1+5pDEQrY2OdbiDQdk3DpLS2GTNjVj1bAWOR6X X-Google-Smtp-Source: AGHT+IH9sb6Zps2A1DZ1pm4ekpIxGipAdys8H3A8y6cFIfzf/7CS7qKW+tkN/SShA2wcbXfOyzztFw== X-Received: by 2002:a05:6512:3ba6:b0:52c:d657:8322 with SMTP id 2adb3069b0e04-52eb999437cmr12970196e87.23.1721057282523; Mon, 15 Jul 2024 08:28:02 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dabef75sm6790145f8f.36.2024.07.15.08.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:28:02 -0700 (PDT) From: luca.boccassi@gmail.com To: Jack Bond-Preston Cc: Kai Ji , Wathsala Vithanage , dpdk stable Subject: patch 'crypto/openssl: optimize 3DES-CTR context init' has been queued to stable release 22.11.6 Date: Mon, 15 Jul 2024 16:25:56 +0100 Message-Id: <20240715152704.2229503-18-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240715152704.2229503-1-luca.boccassi@gmail.com> References: <20240624235907.885628-81-luca.boccassi@gmail.com> <20240715152704.2229503-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/17/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/8e32c3a94a8b8d312acb1170ee601cafc7475f4f Thanks. Luca Boccassi --- >From 8e32c3a94a8b8d312acb1170ee601cafc7475f4f Mon Sep 17 00:00:00 2001 From: Jack Bond-Preston Date: Wed, 3 Jul 2024 13:45:48 +0000 Subject: [PATCH] crypto/openssl: optimize 3DES-CTR context init [ upstream commit 08917edd8b110f9819301ee4f9b152de7c79ddd4 ] 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 Acked-by: Kai Ji 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/openssl/rte_openssl_pmd.c index bf9a546f48..bfdcda8841 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -552,6 +552,15 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, sess->cipher.key.length, sess->cipher.key.data) != 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) != 1) + return -EINVAL; + break; case RTE_CRYPTO_CIPHER_DES_CBC: @@ -1171,8 +1180,7 @@ process_cipher_decrypt_err: /** 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; @@ -1190,12 +1198,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, src = rte_pktmbuf_mtod_offset(m, uint8_t *, offset); l = 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) <= 0) - goto process_cipher_des3ctr_err; - memcpy(ctr, iv, 8); for (n = 0; n < srclen; n++) { @@ -1739,8 +1741,7 @@ process_openssl_cipher_op srclen, ctx_copy, inplace); else status = 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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-15 16:19:35.700839877 +0100 +++ 0018-crypto-openssl-optimize-3DES-CTR-context-init.patch 2024-07-15 16:19:34.480204585 +0100 @@ -1 +1 @@ -From 08917edd8b110f9819301ee4f9b152de7c79ddd4 Mon Sep 17 00:00:00 2001 +From 8e32c3a94a8b8d312acb1170ee601cafc7475f4f Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 08917edd8b110f9819301ee4f9b152de7c79ddd4 ] + @@ -33,2 +34,0 @@ -Cc: stable@dpdk.org - @@ -43 +43 @@ -index 3e547c2039..bd09d58d88 100644 +index bf9a546f48..bfdcda8841 100644 @@ -46 +46 @@ -@@ -553,6 +553,15 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, +@@ -552,6 +552,15 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, @@ -62 +62 @@ -@@ -1172,8 +1181,7 @@ process_cipher_decrypt_err: +@@ -1171,8 +1180,7 @@ process_cipher_decrypt_err: @@ -72 +72 @@ -@@ -1191,12 +1199,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, +@@ -1190,12 +1198,6 @@ process_openssl_cipher_des3ctr(struct rte_mbuf *mbuf_src, uint8_t *dst, @@ -85 +85 @@ -@@ -1740,8 +1742,7 @@ process_openssl_cipher_op +@@ -1739,8 +1741,7 @@ process_openssl_cipher_op