cryptodev: extend data-unit length field

Message ID 20211004063638.1977857-1-matan@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series cryptodev: extend data-unit length field |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Matan Azrad Oct. 4, 2021, 6:36 a.m. UTC
  As described in [1] and as announced in [2], The field ``dataunit_len``
of the ``struct rte_crypto_cipher_xform`` moved to the end of the
structure and extended to ``uint32_t``.

In this way, sizes bigger than 64K bytes can be supported for data-unit
lengths.

[1] commit d014dddb2d69 ("cryptodev: support multiple cipher
data-units")
[2] commit 9a5c09211b3a ("doc: announce extension of crypto data-unit
length")

Signed-off-by: Matan Azrad <matan@nvidia.com>
---
 app/test/test_cryptodev_blockcipher.h  |  2 +-
 doc/guides/rel_notes/deprecation.rst   |  4 ---
 doc/guides/rel_notes/release_21_11.rst |  3 +++
 examples/l2fwd-crypto/main.c           |  6 ++---
 lib/cryptodev/rte_crypto_sym.h         | 36 +++++++++-----------------
 5 files changed, 19 insertions(+), 32 deletions(-)
  

Comments

Akhil Goyal Oct. 16, 2021, 12:36 p.m. UTC | #1
> As described in [1] and as announced in [2], The field ``dataunit_len``
> of the ``struct rte_crypto_cipher_xform`` moved to the end of the
> structure and extended to ``uint32_t``.
> 
> In this way, sizes bigger than 64K bytes can be supported for data-unit
> lengths.
> 
> [1] commit d014dddb2d69 ("cryptodev: support multiple cipher
> data-units")
> [2] commit 9a5c09211b3a ("doc: announce extension of crypto data-unit
> length")
> 
> Signed-off-by: Matan Azrad <matan@nvidia.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  
Akhil Goyal Oct. 16, 2021, 2:47 p.m. UTC | #2
> As described in [1] and as announced in [2], The field ``dataunit_len``
> of the ``struct rte_crypto_cipher_xform`` moved to the end of the
> structure and extended to ``uint32_t``.
> 
> In this way, sizes bigger than 64K bytes can be supported for data-unit
> lengths.
> 
> [1] commit d014dddb2d69 ("cryptodev: support multiple cipher
> data-units")
> [2] commit 9a5c09211b3a ("doc: announce extension of crypto data-unit
> length")
> 
> Signed-off-by: Matan Azrad <matan@nvidia.com>
> ---
Applied to dpdk-next-crypto
  

Patch

diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h
index dcaa08ae22..84f5d57787 100644
--- a/app/test/test_cryptodev_blockcipher.h
+++ b/app/test/test_cryptodev_blockcipher.h
@@ -97,7 +97,7 @@  struct blockcipher_test_data {
 
 	unsigned int cipher_offset;
 	unsigned int auth_offset;
-	uint16_t xts_dataunit_len;
+	uint32_t xts_dataunit_len;
 	bool wrapped_key;
 };
 
diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 05fc2fdee7..8b54088a39 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -202,10 +202,6 @@  Deprecation Notices
 * cryptodev: ``min`` and ``max`` fields of ``rte_crypto_param_range`` structure
   will be renamed in DPDK 21.11 to avoid conflict with Windows Sockets headers.
 
-* cryptodev: The field ``dataunit_len`` of the ``struct rte_crypto_cipher_xform``
-  has a limited size ``uint16_t``.
-  It will be moved and extended as ``uint32_t`` in DPDK 21.11.
-
 * cryptodev: The structure ``rte_crypto_sym_vec`` would be updated to add
   ``dest_sgl`` to support out of place processing.
   This field will be null for inplace processing.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 37dc1a7786..4a9d1dedd8 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -190,6 +190,9 @@  ABI Changes
      Use fixed width quotes for ``function_names`` or ``struct_names``.
      Use the past tense.
 
+* cryptodev: The field ``dataunit_len`` of the ``struct rte_crypto_cipher_xform``
+  moved to the end of the structure and extended to ``uint32_t``.
+
    This section is a comment. Do not overwrite or remove it.
    Also, make sure to start the actual text at the margin.
    =======================================================
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 66d1491bf7..78844cee18 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -182,7 +182,7 @@  struct l2fwd_crypto_params {
 	unsigned digest_length;
 	unsigned block_size;
 
-	uint16_t cipher_dataunit_len;
+	uint32_t cipher_dataunit_len;
 
 	struct l2fwd_iv cipher_iv;
 	struct l2fwd_iv auth_iv;
@@ -1269,9 +1269,9 @@  l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 
 	else if (strcmp(lgopts[option_index].name, "cipher_dataunit_len") == 0) {
 		retval = parse_size(&val, optarg);
-		if (retval == 0 && val >= 0 && val <= UINT16_MAX) {
+		if (retval == 0 && val >= 0) {
 			options->cipher_xform.cipher.dataunit_len =
-								(uint16_t)val;
+								(uint32_t)val;
 			return 0;
 		} else
 			return -1;
diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
index 58c0724743..1106ad6201 100644
--- a/lib/cryptodev/rte_crypto_sym.h
+++ b/lib/cryptodev/rte_crypto_sym.h
@@ -195,9 +195,6 @@  struct rte_crypto_cipher_xform {
 	enum rte_crypto_cipher_algorithm algo;
 	/**< Cipher algorithm */
 
-	RTE_STD_C11
-	union { /* temporary anonymous union for ABI compatibility */
-
 	struct {
 		const uint8_t *data;	/**< pointer to key data */
 		uint16_t length;	/**< key length in bytes */
@@ -233,27 +230,6 @@  struct rte_crypto_cipher_xform {
 	 *  - Each key can be either 128 bits (16 bytes) or 256 bits (32 bytes).
 	 *  - Both keys must have the same size.
 	 **/
-
-	RTE_STD_C11
-	struct { /* temporary anonymous struct for ABI compatibility */
-		const uint8_t *_key_data; /* reserved for key.data union */
-		uint16_t _key_length;     /* reserved for key.length union */
-		/* next field can fill the padding hole */
-
-	uint16_t dataunit_len;
-	/**< When RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS is enabled,
-	 * this is the data-unit length of the algorithm,
-	 * otherwise or when the value is 0, use the operation length.
-	 * The value should be in the range defined by the dataunit_set 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 IV.
-	 */
-
-	}; }; /* temporary struct nested in union for ABI compatibility */
-
 	struct {
 		uint16_t offset;
 		/**< Starting point for Initialisation Vector or Counter,
@@ -297,6 +273,18 @@  struct rte_crypto_cipher_xform {
 		 * which can be in the range 7 to 13 inclusive.
 		 */
 	} iv;	/**< Initialisation vector parameters */
+
+	uint32_t dataunit_len;
+	/**< When RTE_CRYPTODEV_FF_CIPHER_MULTIPLE_DATA_UNITS is enabled,
+	 * this is the data-unit length of the algorithm,
+	 * otherwise or when the value is 0, use the operation length.
+	 * The value should be in the range defined by the dataunit_set 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 IV.
+	 */
 };
 
 /** Symmetric Authentication / Hash Algorithms