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 2CE99A0524; Thu, 4 Feb 2021 15:34:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CD442405BB; Thu, 4 Feb 2021 15:34:32 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id 92AE92405AE for ; Thu, 4 Feb 2021 15:34:30 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@nvidia.com) with SMTP; 4 Feb 2021 16:34:28 +0200 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 114EYSWI030907; Thu, 4 Feb 2021 16:34:28 +0200 From: Matan Azrad To: dev@dpdk.org Cc: akhil.goyal@nxp.com, Declan Doherty , Somalapuram Amaranath , Ruifeng Wang , Ajit Khaparde , Anoob Joseph , Fan Zhang , John Griffin , Pablo de Lara , Michael Shamis , Nagadheeraj Rottela , Ankur Dwivedi , Gagandeep Singh , Jay Zhou Date: Thu, 4 Feb 2021 14:34:12 +0000 Message-Id: <1612449252-395208-1-git-send-email-matan@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] cryptodev: support multiple cipher block sizes 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 cryptography, a block cipher is a deterministic algorithm operating on fixed-length groups of bits, called blocks. A block cipher consists of two paired algorithms, one for encryption and the other for decryption. Both algorithms accept two inputs: an input block of size n bits and a key of size k bits; and both yield an n-bit output block. The decryption algorithm is defined to be the inverse function of the encryption. Some cipher algorithms support multiple block sizes, e.g. AES-XTS supports any block size in range [16B, 2^24B], in this case, A plain-text data, divided into N amount of n-bits blocks, which is encrypted to the same data size, cipher-text, must be decrypted in the same division of N amount of n-bits blocks in order to get the same plain-text data. The current cryptodev API doesn't allow the user to select a specific block size supported by the devices In addition, there is no definition how the IV is detected per block when single operation includes more than one block. That causes applications to use single operation per block even though all the data is continuous in memory what reduces datapath performance. Add a new feature flag to support multiple block sizes, called RTE_CRYPTODEV_FF_CIPHER_MULITPLE_BLOCKS. Add a new field in cipher capability, called bsf - block size flags, where the devices can report the range of the supported block sizes. Add a new cipher transformation field, called block_size, where the user can select one block size from the supported range. All the new fields do not change the size of their structures. Using flags to report the supported block sizes capability allows the devices to report a range simply as same as the user to read it simply. Also, thus sizes are usually common and probably will be shared between the devices. Signed-off-by: Matan Azrad --- lib/librte_cryptodev/rte_crypto_sym.h | 12 ++++++++++++ lib/librte_cryptodev/rte_cryptodev.h | 23 ++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/librte_cryptodev/rte_crypto_sym.h b/lib/librte_cryptodev/rte_crypto_sym.h index 9d572ec..9a1215d 100644 --- a/lib/librte_cryptodev/rte_crypto_sym.h +++ b/lib/librte_cryptodev/rte_crypto_sym.h @@ -265,6 +265,18 @@ struct rte_crypto_cipher_xform { * which can be in the range 7 to 13 inclusive. */ } iv; /**< Initialisation vector parameters */ + + uint32_t block_size; + /**< When RTE_CRYPTODEV_FF_CIPHER_MULITPLE_BLOCKS is reported, this is + * the block size of the algorithm, otherwise or when the value is 0, + * use the default block size provided in the capability. + * The value should be in the range defined by the bsf field in the + * cipher capability. + * + * - For AES-XTS it is the size of data-unit, from IEEE Std 1619-2007. + * For-each data-unit in the operation, the tweak(IV) value is + * assigned consecutively starting from the operation assigned tweak. + */ }; /** Symmetric Authentication / Hash Algorithms diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index ae34f33..60ba839 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -96,6 +96,19 @@ struct rte_crypto_param_range { }; /** + * Crypto device supported block size flags for cipher algorithms + * Each flag represents single or range of supported block sizes + */ +#define RTE_CRYPTO_CIPHER_BSF_ALL 0x1 +/* All the sizes from the algorithm standard */ +#define RTE_CRYPTO_CIPHER_BSF_512_BYTES 0x2 +#define RTE_CRYPTO_CIPHER_BSF_520_BYTES 0x4 +#define RTE_CRYPTO_CIPHER_BSF_4048_BYTES 0x8 +#define RTE_CRYPTO_CIPHER_BSF_4096_BYTES 0x10 +#define RTE_CRYPTO_CIPHER_BSF_4160_BYTES 0x20 +#define RTE_CRYPTO_CIPHER_BSF_1M_BYTES 0x40 + +/** * Symmetric Crypto Capability */ struct rte_cryptodev_symmetric_capability { @@ -122,11 +135,19 @@ struct rte_cryptodev_symmetric_capability { enum rte_crypto_cipher_algorithm algo; /**< cipher algorithm */ uint16_t block_size; - /**< algorithm block size */ + /**< + * algorithm block size + * For algorithms support more than single block size, + * this is the default block size supported by the + * driver, all the supported sizes are reflected in the + * bsf field. + */ struct rte_crypto_param_range key_size; /**< cipher key size range */ struct rte_crypto_param_range iv_size; /**< Initialisation vector data size range */ + uint32_t bsf; + /**< Block size flags */ } cipher; /**< Symmetric Cipher transform capabilities */ struct { -- 1.8.3.1