From d2a4223c4c6d3304f00dcf3225fa68e8ebf7787a Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Sun, 2 Jul 2017 06:41:05 +0100 Subject: [PATCH] cryptodev: do not store pointer to op specific params Instead of storing a pointer to operation specific parameters, such as symmetric crypto parameters, use a zero-length array, to mark that these parameters will be stored after the generic crypto operation structure, which was already assumed in the code, reducing the memory footprint of the crypto operation. Besides, it is always expected to have rte_crypto_op and rte_crypto_sym_op (the only operation specific parameters structure right now) to be together, as they are initialized as a single object in the crypto operation pool. Signed-off-by: Pablo de Lara Acked-by: Declan Doherty Acked-by: Akhil Goyal Acked-by: Fiona Trahe --- doc/guides/rel_notes/release_17_08.rst | 1 + examples/ipsec-secgw/ipsec.c | 3 +-- lib/librte_cryptodev/rte_crypto.h | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/doc/guides/rel_notes/release_17_08.rst b/doc/guides/rel_notes/release_17_08.rst index c21119de15..e03333ceba 100644 --- a/doc/guides/rel_notes/release_17_08.rst +++ b/doc/guides/rel_notes/release_17_08.rst @@ -99,6 +99,7 @@ New Features * Enumerations ``rte_crypto_op_status`` and ``rte_crypto_op_type`` have been modified to be uint8_t values. * Removed the field ``opaque_data``. + * Pointer to ``rte_crypto_sym_op`` has been replaced with a zero length array. Resolved Issues diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index edca5f02b5..ecfd4e8fab 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2016 Intel Corporation. All rights reserved. + * Copyright(c) 2016-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,7 +140,6 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, priv->cop.status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; rte_prefetch0(&priv->sym_cop); - priv->cop.sym = &priv->sym_cop; if ((unlikely(sa->crypto_session == NULL)) && create_session(ipsec_ctx, sa)) { diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h index a5655a013d..ae2d48a29a 100644 --- a/lib/librte_cryptodev/rte_crypto.h +++ b/lib/librte_cryptodev/rte_crypto.h @@ -124,7 +124,7 @@ struct rte_crypto_op { RTE_STD_C11 union { - struct rte_crypto_sym_op *sym; + struct rte_crypto_sym_op sym[0]; /**< Symmetric operation parameters */ }; /**< operation specific parameters */ } __rte_cache_aligned; @@ -144,12 +144,6 @@ __rte_crypto_op_reset(struct rte_crypto_op *op, enum rte_crypto_op_type type) switch (type) { case RTE_CRYPTO_OP_TYPE_SYMMETRIC: - /** Symmetric operation structure starts after the end of the - * rte_crypto_op structure. - */ - op->sym = (struct rte_crypto_sym_op *)(op + 1); - op->type = type; - __rte_crypto_sym_op_reset(op->sym); break; default: -- 2.20.1