cryptodev: support security APIs
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.h
index 1d975e5..a0d3a12 100644 (file)
@@ -49,7 +49,6 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_dev.h"
 #include <rte_common.h>
-#include <rte_vdev.h>
 
 extern const char **rte_cyptodev_names;
 
@@ -60,10 +59,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(...) \
@@ -238,7 +237,6 @@ rte_cryptodev_sym_capability_check_cipher(
  * @param      capability      Description of the symmetric crypto capability.
  * @param      key_size        Auth key size.
  * @param      digest_size     Auth digest size.
- * @param      aad_size        Auth aad size.
  * @param      iv_size         Auth initial vector size.
  *
  * @return
@@ -248,8 +246,7 @@ rte_cryptodev_sym_capability_check_cipher(
 int
 rte_cryptodev_sym_capability_check_auth(
                const struct rte_cryptodev_symmetric_capability *capability,
-               uint16_t key_size, uint16_t digest_size, uint16_t aad_size,
-               uint16_t iv_size);
+               uint16_t key_size, uint16_t digest_size, uint16_t iv_size);
 
 /**
  * Check if key, digest, AAD and initial vector sizes are supported
@@ -353,6 +350,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 */
 
 
 /**
@@ -436,6 +435,8 @@ struct rte_cryptodev_stats {
 /**< Max length of name of crypto PMD */
 
 /**
+ * @deprecated
+ *
  * Create a virtual crypto device
  *
  * @param      name    Cryptodev PMD name of device to be created.
@@ -446,6 +447,7 @@ struct rte_cryptodev_stats {
  *   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);
 
@@ -461,6 +463,19 @@ rte_cryptodev_create_vdev(const char *name, const char *args);
 extern int
 rte_cryptodev_get_dev_id(const char *name);
 
+/**
+ * Get the crypto device name given a device identifier.
+ *
+ * @param dev_id
+ *   The identifier of the device
+ *
+ * @return
+ *   - Returns crypto device name.
+ *   - Returns NULL if crypto device is not present.
+ */
+extern const char *
+rte_cryptodev_name_get(uint8_t dev_id);
+
 /**
  * Get the total number of crypto devices that have been successfully
  * initialised.
@@ -675,6 +690,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);
@@ -755,11 +775,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.
@@ -926,7 +952,9 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
  *
  * @return
  *  - On success, zero.
- *  - On failure, a negative value.
+ *  - -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.
  */
 int
 rte_cryptodev_sym_session_init(uint8_t dev_id,
@@ -1022,26 +1050,6 @@ int rte_cryptodev_driver_id_get(const char *name);
  */
 const char *rte_cryptodev_driver_name_get(uint8_t driver_id);
 
-/**
- * @internal
- * Allocate Cryptodev driver.
- *
- * @param driver
- *   Pointer to rte_driver.
- * @return
- *  The driver type identifier
- */
-uint8_t rte_cryptodev_allocate_driver(const struct rte_driver *driver);
-
-
-#define RTE_PMD_REGISTER_CRYPTO_DRIVER(drv, driver_id)\
-RTE_INIT(init_ ##driver_id);\
-static void init_ ##driver_id(void)\
-{\
-       driver_id = rte_cryptodev_allocate_driver(&(drv).driver);\
-}
-
-
 #ifdef __cplusplus
 }
 #endif