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 852FFA0579; Thu, 8 Apr 2021 22:51:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C191141287; Thu, 8 Apr 2021 22:50:17 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id A8421141287 for ; Thu, 8 Apr 2021 22:50:15 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from shirik@nvidia.com) with SMTP; 8 Apr 2021 23:50:11 +0300 Received: from nvidia.com (c-236-0-60-063.mtl.labs.mlnx [10.236.0.63]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 138KnAJh028067; Thu, 8 Apr 2021 23:50:11 +0300 From: Shiri Kuzin To: dev@dpdk.org Cc: matan@nvidia.com, gakhil@marvell.com, suanmingm@nvidia.com Date: Thu, 8 Apr 2021 23:48:49 +0300 Message-Id: <20210408204849.9543-25-shirik@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210408204849.9543-1-shirik@nvidia.com> References: <1615447568-260965-1-git-send-email-matan@nvidia.com> <20210408204849.9543-1-shirik@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 24/24] crypto/mlx5: adjust to the multiple data unit API 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 Sender: "dev" In AES-XTS the data to be encrypted\decrypted does not have to be in multiples of 16B size, the unit of data is called data-unit. As a result of patch [1] a new field is added to the cipher capability, called dataunit_set, where the devices can report the range of supported data-unit sizes. The new field enables saving the data-unit size in the session structure to the block size pointer variable in order to support several data-unit sizes. [1] https://www.mail-archive.com/dev@dpdk.org/msg203590.html Signed-off-by: Shiri Kuzin --- drivers/crypto/mlx5/mlx5_crypto.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 25a435a999..8810872aff 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -48,6 +48,11 @@ struct mlx5_crypto_session { * bsf_size, bsf_p_type, encryption_order and encryption standard, * saved in big endian format. */ + uint32_t bsp_res; + /* + * crypto_block_size_pointer and reserved 24 bits saved in big endian + * format. + */ uint32_t iv_offset:16; /* Starting point for Initialisation Vector. */ struct mlx5_crypto_dek *dek; /* Pointer to dek struct. */ @@ -170,6 +175,26 @@ mlx5_crypto_sym_session_configure(struct rte_cryptodev *dev, MLX5_BSF_P_TYPE_CRYPTO << MLX5_BSF_P_TYPE_OFFSET | encryption_order << MLX5_ENCRYPTION_ORDER_OFFSET | MLX5_ENCRYPTION_STANDARD_AES_XTS); + switch (xform->cipher.dataunit_len) { + case RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_512_BYTES: + sess_private_data->bsp_res = rte_cpu_to_be_32 + ((uint32_t)MLX5_BLOCK_SIZE_512B << + MLX5_BLOCK_SIZE_OFFSET); + break; + case RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_4096_BYTES: + sess_private_data->bsp_res = rte_cpu_to_be_32 + ((uint32_t)MLX5_BLOCK_SIZE_4096B << + MLX5_BLOCK_SIZE_OFFSET); + break; + case RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_1M_BYTES: + sess_private_data->bsp_res = rte_cpu_to_be_32 + ((uint32_t)MLX5_BLOCK_SIZE_1MB << + MLX5_BLOCK_SIZE_OFFSET); + break; + default: + DRV_LOG(ERR, "Cipher data unit length is not supported."); + return -ENOTSUP; + } sess_private_data->iv_offset = cipher->iv.offset; set_sym_session_private_data(session, dev->driver_id, sess_private_data); -- 2.21.0