cryptodev: support session private data setting
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.h
index b74bbdd..261a359 100644 (file)
@@ -49,6 +49,7 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_dev.h"
 #include <rte_common.h>
+#include <rte_config.h>
 
 extern const char **rte_cyptodev_names;
 
@@ -59,10 +60,10 @@ extern const char **rte_cyptodev_names;
                RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
                        __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
 
-#define CDEV_PMD_LOG_ERR(dev, ...) \
-       RTE_LOG(ERR, CRYPTODEV, \
-               RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
-                       dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,)))
+#define CDEV_LOG_INFO(...) \
+       RTE_LOG(INFO, CRYPTODEV, \
+               RTE_FMT(RTE_FMT_HEAD(__VA_ARGS__,) "\n", \
+                       RTE_FMT_TAIL(__VA_ARGS__,)))
 
 #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG
 #define CDEV_LOG_DEBUG(...) \
@@ -110,7 +111,7 @@ extern const char **rte_cyptodev_names;
  *   to calculate address from.
  */
 #define rte_crypto_op_ctophys_offset(c, o)     \
-       (phys_addr_t)((c)->phys_addr + (o))
+       (rte_iova_t)((c)->phys_addr + (o))
 
 /**
  * Crypto parameters range description
@@ -350,6 +351,8 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
 /**< Utilises CPU NEON instructions */
 #define        RTE_CRYPTODEV_FF_CPU_ARM_CE             (1ULL << 11)
 /**< Utilises ARM CPU Cryptographic Extensions */
+#define        RTE_CRYPTODEV_FF_SECURITY               (1ULL << 12)
+/**< Support Security Protocol Processing */
 
 
 /**
@@ -432,23 +435,6 @@ struct rte_cryptodev_stats {
 #define RTE_CRYPTODEV_NAME_MAX_LEN     (64)
 /**< Max length of name of crypto PMD */
 
-/**
- * @deprecated
- *
- * Create a virtual crypto device
- *
- * @param      name    Cryptodev PMD name of device to be created.
- * @param      args    Options arguments for device.
- *
- * @return
- * - On successful creation of the cryptodev the device index is returned,
- *   which will be between 0 and rte_cryptodev_count().
- * - In the case of a failure, returns -1.
- */
-__rte_deprecated
-extern int
-rte_cryptodev_create_vdev(const char *name, const char *args);
-
 /**
  * Get the device identifier for the named crypto device.
  *
@@ -688,6 +674,11 @@ rte_cryptodev_stats_reset(uint8_t dev_id);
  * @param      dev_info        A pointer to a structure of type
  *                             *rte_cryptodev_info* to be filled with the
  *                             contextual information of the device.
+ *
+ * @note The capabilities field of dev_info is set to point to the first
+ * element of an array of struct rte_cryptodev_capabilities. The element after
+ * the last valid element has it's op field set to
+ * RTE_CRYPTO_OP_TYPE_UNDEFINED.
  */
 extern void
 rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
@@ -768,11 +759,17 @@ struct rte_cryptodev {
        struct rte_cryptodev_cb_list link_intr_cbs;
        /**< User application callback for interrupts if present */
 
+       void *security_ctx;
+       /**< Context for security ops */
+
        __extension__
        uint8_t attached : 1;
        /**< Flag indicating the device is attached */
 } __rte_cache_aligned;
 
+void *
+rte_cryptodev_get_sec_ctx(uint8_t dev_id);
+
 /**
  *
  * The data part, with no function pointers, associated with each device.
@@ -894,7 +891,10 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 }
 
 
-/** Cryptodev symmetric crypto session */
+/** Cryptodev symmetric crypto session
+ * Each session is derived from a fixed xform chain. Therefore each session
+ * has a fixed algo, key, op-type, digest_len etc.
+ */
 struct rte_cryptodev_sym_session {
        __extension__ void *sess_private_data[0];
        /**< Private session material */
@@ -1037,6 +1037,38 @@ int rte_cryptodev_driver_id_get(const char *name);
  */
 const char *rte_cryptodev_driver_name_get(uint8_t driver_id);
 
+/**
+ * Set private data for a session.
+ *
+ * @param      sess            Session pointer allocated by
+ *                             *rte_cryptodev_sym_session_create*.
+ * @param      data            Pointer to the private data.
+ * @param      size            Size of the private data.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+int __rte_experimental
+rte_cryptodev_sym_session_set_private_data(
+                                       struct rte_cryptodev_sym_session *sess,
+                                       void *data,
+                                       uint16_t size);
+
+/**
+ * Get private data of a session.
+ *
+ * @param      sess            Session pointer allocated by
+ *                             *rte_cryptodev_sym_session_create*.
+ *
+ * @return
+ *  - On success return pointer to private data.
+ *  - On failure returns NULL.
+ */
+void * __rte_experimental
+rte_cryptodev_sym_session_get_private_data(
+                                       struct rte_cryptodev_sym_session *sess);
+
 #ifdef __cplusplus
 }
 #endif