cryptodev: rename functions to get session size
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.h
index fd0e3f1..92ce6d4 100644 (file)
@@ -49,7 +49,7 @@ extern "C" {
 #include "rte_crypto.h"
 #include "rte_dev.h"
 #include <rte_common.h>
-#include <rte_vdev.h>
+#include <rte_config.h>
 
 extern const char **rte_cyptodev_names;
 
@@ -60,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(...) \
@@ -111,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
@@ -351,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 */
 
 
 /**
@@ -371,7 +373,8 @@ struct rte_cryptodev_info {
        uint8_t driver_id;                      /**< Driver identifier */
        struct rte_pci_device *pci_dev;         /**< PCI information. */
 
-       uint64_t feature_flags;                 /**< Feature flags */
+       uint64_t feature_flags;
+       /**< Feature flags exposes HW/SW features for the given device */
 
        const struct rte_cryptodev_capabilities *capabilities;
        /**< Array of devices supported capabilities */
@@ -433,23 +436,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.
  *
@@ -617,6 +603,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
                struct rte_mempool *session_pool);
 
 /**
+ * @deprecated
  * Start a specified queue pair of a device. It is used
  * when deferred_start flag of the specified queue is true.
  *
@@ -630,10 +617,12 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
  *   - -EINVAL: The dev_id or the queue_id out of range.
  *   - -ENOTSUP: The function not supported in PMD driver.
  */
+__rte_deprecated
 extern int
 rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
 
 /**
+ * @deprecated
  * Stop specified queue pair of a device
  *
  * @param      dev_id          The identifier of the device
@@ -646,6 +635,7 @@ rte_cryptodev_queue_pair_start(uint8_t dev_id, uint16_t queue_pair_id);
  *   - -EINVAL: The dev_id or the queue_id out of range.
  *   - -ENOTSUP: The function not supported in PMD driver.
  */
+__rte_deprecated
 extern int
 rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id);
 
@@ -689,6 +679,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);
@@ -759,7 +754,7 @@ struct rte_cryptodev {
        struct rte_cryptodev_ops *dev_ops;
        /**< Functions exported by PMD */
        uint64_t feature_flags;
-       /**< Supported features */
+       /**< Feature flags exposes HW/SW features for the given device */
        struct rte_device *device;
        /**< Backing device */
 
@@ -769,11 +764,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.
@@ -895,7 +896,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 */
@@ -952,7 +956,9 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
 
 /**
  * Frees private data for the device id, based on its device type,
- * returning it to its mempool.
+ * returning it to its mempool. It is the application's responsibility
+ * to ensure that private session data is not cleared while there are
+ * still in-flight operations using it.
  *
  * @param   dev_id   ID of device that uses the session.
  * @param   sess     Session containing the reference to the private data
@@ -966,15 +972,18 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id,
                        struct rte_cryptodev_sym_session *sess);
 
 /**
+ * @deprecated
  * Get the size of the header session, for all registered drivers.
  *
  * @return
  *   Size of the header session.
  */
+__rte_deprecated
 unsigned int
 rte_cryptodev_get_header_session_size(void);
 
 /**
+ * @deprecated
  * Get the size of the private session data for a device.
  *
  * @param      dev_id          The device identifier.
@@ -983,10 +992,35 @@ rte_cryptodev_get_header_session_size(void);
  *   - Size of the private data, if successful
  *   - 0 if device is invalid or does not have private session
  */
+__rte_deprecated
 unsigned int
 rte_cryptodev_get_private_session_size(uint8_t dev_id);
 
 /**
+ * Get the size of the header session, for all registered drivers.
+ *
+ * @return
+ *   Size of the symmetric eader session.
+ */
+unsigned int
+rte_cryptodev_sym_get_header_session_size(void);
+
+/**
+ * Get the size of the private symmetric session data
+ * for a device.
+ *
+ * @param      dev_id          The device identifier.
+ *
+ * @return
+ *   - Size of the private data, if successful
+ *   - 0 if device is invalid or does not have private
+ *   symmetric session
+ */
+unsigned int
+rte_cryptodev_sym_get_private_session_size(uint8_t dev_id);
+
+/**
+ * @deprecated
  * Attach queue pair with sym session.
  *
  * @param      dev_id          Device to which the session will be attached.
@@ -998,11 +1032,13 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id);
  *  - On success, zero.
  *  - On failure, a negative value.
  */
+__rte_deprecated
 int
 rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
                struct rte_cryptodev_sym_session *session);
 
 /**
+ * @deprecated
  * Detach queue pair with sym session.
  *
  * @param      dev_id          Device to which the session is attached.
@@ -1014,6 +1050,7 @@ rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
  *  - On success, zero.
  *  - On failure, a negative value.
  */
+__rte_deprecated
 int
 rte_cryptodev_queue_pair_detach_sym_session(uint8_t dev_id, uint16_t qp_id,
                struct rte_cryptodev_sym_session *session);
@@ -1038,6 +1075,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