examples/pipeline: fix build
[dpdk.git] / lib / cryptodev / rte_cryptodev.h
index 56e3868..585cee2 100644 (file)
@@ -20,9 +20,7 @@ extern "C" {
 
 #include "rte_kvargs.h"
 #include "rte_crypto.h"
-#include "rte_dev.h"
 #include <rte_common.h>
-#include <rte_config.h>
 #include <rte_rcu_qsbr.h>
 
 #include "rte_cryptodev_trace_fp.h"
@@ -102,6 +100,7 @@ struct rte_crypto_param_range {
  */
 #define RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_512_BYTES             RTE_BIT32(0)
 #define RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_4096_BYTES            RTE_BIT32(1)
+#define RTE_CRYPTO_CIPHER_DATA_UNIT_LEN_1_MEGABYTES           RTE_BIT32(2)
 
 /**
  * Symmetric Crypto Capability
@@ -169,7 +168,13 @@ struct rte_cryptodev_asymmetric_xform_capability {
        /**< Transform type: RSA/MODEXP/DH/DSA/MODINV */
 
        uint32_t op_types;
-       /**< bitmask for supported rte_crypto_asym_op_type */
+       /**<
+        * Bitmask for supported rte_crypto_asym_op_type or
+        * rte_crypto_asym_ke_type. Which enum is used is determined
+        * by the rte_crypto_asym_xform_type. For key exchange algorithms
+        * like Diffie-Hellman it is rte_crypto_asym_ke_type, for others
+        * it is rte_crypto_asym_op_type.
+        */
 
        __extension__
        union {
@@ -917,12 +922,6 @@ struct rte_cryptodev_sym_session {
        /**< Driver specific session material, variable size */
 };
 
-/** Cryptodev asymmetric crypto session */
-struct rte_cryptodev_asym_session {
-       __extension__ void *sess_private_data[0];
-       /**< Private asymmetric session material */
-};
-
 /**
  * Create a symmetric session mempool.
  *
@@ -955,6 +954,31 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts,
        uint32_t elt_size, uint32_t cache_size, uint16_t priv_size,
        int socket_id);
 
+/**
+ * Create an asymmetric session mempool.
+ *
+ * @param name
+ *   The unique mempool name.
+ * @param nb_elts
+ *   The number of elements in the mempool.
+ * @param cache_size
+ *   The number of per-lcore cache elements
+ * @param user_data_size
+ *   The size of user data to be placed after session private data.
+ * @param socket_id
+ *   The *socket_id* argument is the socket identifier in the case of
+ *   NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
+ *   constraint for the reserved zone.
+ *
+ * @return
+ *  - On success return mempool
+ *  - On failure returns NULL
+ */
+__rte_experimental
+struct rte_mempool *
+rte_cryptodev_asym_session_pool_create(const char *name, uint32_t nb_elts,
+       uint32_t cache_size, uint16_t user_data_size, int socket_id);
+
 /**
  * Create symmetric crypto session header (generic with no private data)
  *
@@ -968,17 +992,27 @@ struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
 
 /**
- * Create asymmetric crypto session header (generic with no private data)
+ * Create and initialise an asymmetric crypto session structure.
+ * Calls the PMD to configure the private session data.
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   xforms   Asymmetric crypto transform operations to apply on flow
+ *                   processed with this session
+ * @param   mp       mempool to allocate asymmetric session
+ *                   objects from
+ * @param   session  void ** for session to be used
  *
- * @param   mempool    mempool to allocate asymmetric session
- *                     objects from
  * @return
- *  - On success return pointer to asym-session
- *  - On failure returns NULL
+ *  - 0 on success.
+ *  - -EINVAL on invalid arguments.
+ *  - -ENOMEM on memory error for session allocation.
+ *  - -ENOTSUP if device doesn't support session configuration.
  */
 __rte_experimental
-struct rte_cryptodev_asym_session *
-rte_cryptodev_asym_session_create(struct rte_mempool *mempool);
+int
+rte_cryptodev_asym_session_create(uint8_t dev_id,
+               struct rte_crypto_asym_xform *xforms, struct rte_mempool *mp,
+               void **session);
 
 /**
  * Frees symmetric crypto session header, after checking that all
@@ -996,20 +1030,19 @@ int
 rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
 
 /**
- * Frees asymmetric crypto session header, after checking that all
- * the device private data has been freed, returning it
- * to its original mempool.
+ * Clears and frees asymmetric crypto session header and private data,
+ * returning it to its original mempool.
  *
+ * @param   dev_id   ID of device that uses the asymmetric session.
  * @param   sess     Session header to be freed.
  *
  * @return
  *  - 0 if successful.
- *  - -EINVAL if session is NULL.
- *  - -EBUSY if not all device private data has been freed.
+ *  - -EINVAL if device is invalid or session is NULL.
  */
 __rte_experimental
 int
-rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess);
+rte_cryptodev_asym_session_free(uint8_t dev_id, void *sess);
 
 /**
  * Fill out private data for the device id, based on its device type.
@@ -1033,28 +1066,6 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
                        struct rte_crypto_sym_xform *xforms,
                        struct rte_mempool *mempool);
 
-/**
- * Initialize asymmetric session on a device with specific asymmetric xform
- *
- * @param   dev_id   ID of device that we want the session to be used on
- * @param   sess     Session to be set up on a device
- * @param   xforms   Asymmetric crypto transform operations to apply on flow
- *                   processed with this session
- * @param   mempool  Mempool to be used for internal allocation.
- *
- * @return
- *  - On success, zero.
- *  - -EINVAL if input parameters are invalid.
- *  - -ENOTSUP if crypto device does not support the crypto transform.
- *  - -ENOMEM if the private session could not be allocated.
- */
-__rte_experimental
-int
-rte_cryptodev_asym_session_init(uint8_t dev_id,
-                       struct rte_cryptodev_asym_session *sess,
-                       struct rte_crypto_asym_xform *xforms,
-                       struct rte_mempool *mempool);
-
 /**
  * Frees private data for the device id, based on its device type,
  * returning it to its mempool. It is the application's responsibility
@@ -1073,21 +1084,6 @@ int
 rte_cryptodev_sym_session_clear(uint8_t dev_id,
                        struct rte_cryptodev_sym_session *sess);
 
-/**
- * Frees resources held by asymmetric session during rte_cryptodev_session_init
- *
- * @param   dev_id   ID of device that uses the asymmetric session.
- * @param   sess     Asymmetric session setup on device using
- *                                      rte_cryptodev_session_init
- * @return
- *  - 0 if successful.
- *  - -EINVAL if device is invalid or session is NULL.
- */
-__rte_experimental
-int
-rte_cryptodev_asym_session_clear(uint8_t dev_id,
-                       struct rte_cryptodev_asym_session *sess);
-
 /**
  * Get the size of the header session, for all registered drivers excluding
  * the user data size.
@@ -1115,7 +1111,7 @@ 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.
+ * Get the size of the asymmetric session header.
  *
  * @return
  *   Size of the asymmetric header session.
@@ -1217,6 +1213,37 @@ void *
 rte_cryptodev_sym_session_get_user_data(
                                        struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Store user data in an asymmetric session.
+ *
+ * @param      sess            Session pointer allocated by
+ *                             *rte_cryptodev_asym_session_create*.
+ * @param      data            Pointer to the user data.
+ * @param      size            Size of the user data.
+ *
+ * @return
+ *  - On success, zero.
+ *  - -EINVAL if the session pointer is invalid.
+ *  - -ENOMEM if the available user data size is smaller than the size parameter.
+ */
+__rte_experimental
+int
+rte_cryptodev_asym_session_set_user_data(void *sess, void *data, uint16_t size);
+
+/**
+ * Get user data stored in an asymmetric session.
+ *
+ * @param      sess            Session pointer allocated by
+ *                             *rte_cryptodev_asym_session_create*.
+ *
+ * @return
+ *  - On success return pointer to user data.
+ *  - On failure returns NULL.
+ */
+__rte_experimental
+void *
+rte_cryptodev_asym_session_get_user_data(void *sess);
+
 /**
  * Perform actual crypto processing (encrypt/digest or auth/decrypt)
  * on user provided data.
@@ -1248,6 +1275,28 @@ __rte_experimental
 int
 rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id);
 
+/**
+ * Set session event meta data
+ *
+ * @param      dev_id          The device identifier.
+ * @param      sess            Crypto or security session.
+ * @param      op_type         Operation type.
+ * @param      sess_type       Session type.
+ * @param      ev_mdata        Pointer to the event crypto meta data
+ *                             (aka *union rte_event_crypto_metadata*)
+ * @param      size            Size of ev_mdata.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
+       enum rte_crypto_op_type op_type,
+       enum rte_crypto_op_sess_type sess_type,
+       void *ev_mdata, uint16_t size);
+
 /**
  * Union of different crypto session types, including session-less xform
  * pointer.