cryptodev: add sym session header size function
authorFan Zhang <roy.fan.zhang@intel.com>
Thu, 10 Jan 2019 14:50:18 +0000 (14:50 +0000)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 10 Jan 2019 15:57:22 +0000 (16:57 +0100)
This patch adds a new API in Cryptodev Framework. The API is used
to get the header size for the created symmetric Cryptodev session.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
25 files changed:
drivers/crypto/aesni_gcm/Makefile
drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
drivers/crypto/aesni_gcm/meson.build
drivers/crypto/aesni_mb/Makefile
drivers/crypto/aesni_mb/meson.build
drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
drivers/crypto/aesni_mb/rte_aesni_mb_pmd_compat.c
drivers/crypto/armv8/Makefile
drivers/crypto/armv8/rte_armv8_pmd.c
drivers/crypto/kasumi/Makefile
drivers/crypto/kasumi/meson.build
drivers/crypto/kasumi/rte_kasumi_pmd.c
drivers/crypto/openssl/Makefile
drivers/crypto/openssl/meson.build
drivers/crypto/openssl/rte_openssl_pmd.c
drivers/crypto/snow3g/Makefile
drivers/crypto/snow3g/rte_snow3g_pmd.c
drivers/crypto/zuc/Makefile
drivers/crypto/zuc/meson.build
drivers/crypto/zuc/rte_zuc_pmd.c
lib/librte_cryptodev/Makefile
lib/librte_cryptodev/meson.build
lib/librte_cryptodev/rte_cryptodev.c
lib/librte_cryptodev/rte_cryptodev.h
lib/librte_cryptodev/rte_cryptodev_version.map

index 0a5c1a8..9241ad7 100644 (file)
@@ -8,6 +8,7 @@ LIB = librte_pmd_aesni_gcm.a
 
 # build flags
 CFLAGS += -O3
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # library version
index abc7a6d..948ff07 100644 (file)
@@ -419,7 +419,8 @@ handle_completed_gcm_crypto_op(struct aesni_gcm_qp *qp,
        if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                memset(sess, 0, sizeof(struct aesni_gcm_session));
                memset(op->sym->session, 0,
-                               rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               op->sym->session));
                rte_mempool_put(qp->sess_mp_priv, sess);
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
index a02da1e..70f57ad 100644 (file)
@@ -8,5 +8,6 @@ else
        ext_deps += lib
 endif
 
+allow_experimental_apis = true
 sources = files('aesni_gcm_pmd.c', 'aesni_gcm_pmd_ops.c')
 deps += ['bus_vdev']
index c2bda58..7ef290d 100644 (file)
@@ -9,6 +9,7 @@ LIB = librte_pmd_aesni_mb.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # library version
 LIBABIVER := 1
index ee76d37..6313c4b 100644 (file)
@@ -24,4 +24,5 @@ else
 
 endif
 
+allow_experimental_apis = true
 deps += ['bus_vdev']
index 2699e41..48d6ac0 100644 (file)
@@ -1025,7 +1025,8 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
        if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                memset(sess, 0, sizeof(struct aesni_mb_session));
                memset(op->sym->session, 0,
-                               rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               op->sym->session));
                rte_mempool_put(qp->sess_mp_priv, sess);
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
index b46942e..8020f68 100644 (file)
@@ -1023,7 +1023,8 @@ post_process_mb_job(struct aesni_mb_qp *qp, JOB_AES_HMAC *job)
        if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                memset(sess, 0, sizeof(struct aesni_mb_session));
                memset(op->sym->session, 0,
-                               rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               op->sym->session));
                rte_mempool_put(qp->sess_mp_priv, sess);
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
index e862af7..f71f6b1 100644 (file)
@@ -28,6 +28,7 @@ EXPORT_MAP := rte_pmd_armv8_version.map
 # external library dependencies
 CFLAGS += -I$(ARMV8_CRYPTO_LIB_PATH)
 CFLAGS += -I$(ARMV8_CRYPTO_LIB_PATH)/asm/include
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDLIBS += -L$(ARMV8_CRYPTO_LIB_PATH) -larmv8_crypto
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_cryptodev
index 3b2d7fb..0d4649a 100644 (file)
@@ -655,7 +655,8 @@ process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
        if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                memset(sess, 0, sizeof(struct armv8_crypto_session));
                memset(op->sym->session, 0,
-                               rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               op->sym->session));
                rte_mempool_put(qp->sess_mp, sess);
                rte_mempool_put(qp->sess_mp_priv, op->sym->session);
                op->sym->session = NULL;
index cafe949..3de2f97 100644 (file)
@@ -15,6 +15,7 @@ LIB = librte_pmd_kasumi.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # library version
 LIBABIVER := 1
index a09b0e2..80f13cd 100644 (file)
@@ -8,5 +8,6 @@ else
        ext_deps += lib
 endif
 
+allow_experimental_apis = true
 sources = files('rte_kasumi_pmd.c', 'rte_kasumi_pmd_ops.c')
 deps += ['bus_vdev']
index 6df645a..3abdb01 100644 (file)
@@ -325,7 +325,8 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session,
                if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                        memset(session, 0, sizeof(struct kasumi_session));
                        memset(ops[i]->sym->session, 0,
-                                       rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                                       ops[i]->sym->session));
                        rte_mempool_put(qp->sess_mp_priv, session);
                        rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
                        ops[i]->sym->session = NULL;
index 8fe086b..ae6c3bc 100644 (file)
@@ -9,6 +9,7 @@ LIB = librte_pmd_openssl.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # library version
 LIBABIVER := 1
index c2a0dd8..77a6596 100644 (file)
@@ -5,6 +5,7 @@ dep = dependency('libcrypto', required: false)
 if not dep.found()
        build = false
 endif
+allow_experimental_apis = true
 deps += 'bus_vdev'
 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
 ext_deps += dep
index a193af6..ea5aac6 100644 (file)
@@ -2020,7 +2020,8 @@ process_op(struct openssl_qp *qp, struct rte_crypto_op *op,
                openssl_reset_session(sess);
                memset(sess, 0, sizeof(struct openssl_session));
                memset(op->sym->session, 0,
-                               rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                               op->sym->session));
                rte_mempool_put(qp->sess_mp_priv, sess);
                rte_mempool_put(qp->sess_mp, op->sym->session);
                op->sym->session = NULL;
index ee5027d..37f77db 100644 (file)
@@ -15,6 +15,7 @@ LIB = librte_pmd_snow3g.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # library version
 LIBABIVER := 1
index 7d131f7..5fd94b6 100644 (file)
@@ -340,7 +340,8 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session,
                if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                        memset(session, 0, sizeof(struct snow3g_session));
                        memset(ops[i]->sym->session, 0,
-                                       rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                                       ops[i]->sym->session));
                        rte_mempool_put(qp->sess_mp_priv, session);
                        rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
                        ops[i]->sym->session = NULL;
index 68d84ee..8d625aa 100644 (file)
@@ -15,6 +15,7 @@ LIB = librte_pmd_zuc.a
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 # library version
 LIBABIVER := 1
index b8ca710..63f2a52 100644 (file)
@@ -8,5 +8,6 @@ else
        ext_deps += lib
 endif
 
+allow_experimental_apis = true
 sources = files('rte_zuc_pmd.c', 'rte_zuc_pmd_ops.c')
 deps += ['bus_vdev']
index 997c209..637994d 100644 (file)
@@ -327,7 +327,8 @@ process_ops(struct rte_crypto_op **ops, enum zuc_operation op_type,
                if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
                        memset(sessions[i], 0, sizeof(struct zuc_session));
                        memset(ops[i]->sym->session, 0,
-                                       rte_cryptodev_sym_get_header_session_size());
+                       rte_cryptodev_sym_get_existing_header_session_size(
+                                       ops[i]->sym->session));
                        rte_mempool_put(qp->sess_mp_priv, sessions[i]);
                        rte_mempool_put(qp->sess_mp, ops[i]->sym->session);
                        ops[i]->sym->session = NULL;
index e380181..859c4f0 100644 (file)
@@ -12,6 +12,7 @@ LIBABIVER := 6
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf
 LDLIBS += -lrte_kvargs
 
index 44bd832..bcd9694 100644 (file)
@@ -2,6 +2,7 @@
 # Copyright(c) 2017-2019 Intel Corporation
 
 version = 6
+allow_experimental_apis = true
 sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c')
 headers = files('rte_cryptodev.h',
        'rte_cryptodev_pmd.h',
index ccc4c21..4a105b0 100644 (file)
@@ -1407,6 +1407,16 @@ rte_cryptodev_sym_get_header_session_size(void)
        return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t));
 }
 
+unsigned int __rte_experimental
+rte_cryptodev_sym_get_existing_header_session_size(
+               struct rte_cryptodev_sym_session *sess)
+{
+       if (!sess)
+               return 0;
+       else
+               return rte_cryptodev_sym_get_header_session_size();
+}
+
 unsigned int __rte_experimental
 rte_cryptodev_asym_get_header_session_size(void)
 {
index 9ed173d..d0eaf00 100644 (file)
@@ -1132,6 +1132,21 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id,
 unsigned int
 rte_cryptodev_sym_get_header_session_size(void);
 
+/**
+ * Get the size of the header session from created session.
+ *
+ * @param sess
+ *   The sym cryptodev session pointer
+ *
+ * @return
+ *   - If sess is not NULL, return the size of the header session including
+ *   the private data size defined within sess.
+ *   - If sess is NULL, return 0.
+ */
+unsigned int __rte_experimental
+rte_cryptodev_sym_get_existing_header_session_size(
+               struct rte_cryptodev_sym_session *sess);
+
 /**
  * Get the size of the asymmetric session header, for all registered drivers.
  *
index 5609da0..3deb265 100644 (file)
@@ -101,6 +101,7 @@ EXPERIMENTAL {
        rte_cryptodev_asym_session_init;
        rte_cryptodev_asym_xform_capability_check_modlen;
        rte_cryptodev_asym_xform_capability_check_optype;
+       rte_cryptodev_sym_get_existing_header_session_size;
        rte_cryptodev_sym_session_get_user_data;
        rte_cryptodev_sym_session_pool_create;
        rte_cryptodev_sym_session_set_user_data;