cryptodev: add missing C++ guards
[dpdk.git] / lib / cryptodev / cryptodev_pmd.h
index 8cc9051..2b1ce2d 100644 (file)
@@ -5,6 +5,10 @@
 #ifndef _CRYPTODEV_PMD_H_
 #define _CRYPTODEV_PMD_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /** @file
  * RTE Crypto PMD APIs
  *
 
 #include <string.h>
 
-#include <rte_config.h>
-#include <rte_dev.h>
 #include <rte_malloc.h>
-#include <rte_mbuf.h>
-#include <rte_mempool.h>
 #include <rte_log.h>
 #include <rte_common.h>
 
@@ -52,6 +52,71 @@ struct rte_cryptodev_pmd_init_params {
        unsigned int max_nb_queue_pairs;
 };
 
+/**
+ * @internal
+ * The data part, with no function pointers, associated with each device.
+ *
+ * This structure is safe to place in shared memory to be common among
+ * different processes in a multi-process configuration.
+ */
+struct rte_cryptodev_data {
+       /** Device ID for this instance */
+       uint8_t dev_id;
+       /** Socket ID where memory is allocated */
+       uint8_t socket_id;
+       /** Unique identifier name */
+       char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+
+       __extension__
+       /** Device state: STARTED(1)/STOPPED(0) */
+       uint8_t dev_started : 1;
+
+       /** Session memory pool */
+       struct rte_mempool *session_pool;
+       /** Array of pointers to queue pairs. */
+       void **queue_pairs;
+       /** Number of device queue pairs. */
+       uint16_t nb_queue_pairs;
+
+       /** PMD-specific private data */
+       void *dev_private;
+} __rte_cache_aligned;
+
+/** @internal The data structure associated with each crypto device. */
+struct rte_cryptodev {
+       /** Pointer to PMD dequeue function. */
+       dequeue_pkt_burst_t dequeue_burst;
+       /** Pointer to PMD enqueue function. */
+       enqueue_pkt_burst_t enqueue_burst;
+
+       /** Pointer to device data */
+       struct rte_cryptodev_data *data;
+       /** Functions exported by PMD */
+       struct rte_cryptodev_ops *dev_ops;
+       /** Feature flags exposes HW/SW features for the given device */
+       uint64_t feature_flags;
+       /** Backing device */
+       struct rte_device *device;
+
+       /** Crypto driver identifier*/
+       uint8_t driver_id;
+
+       /** User application callback for interrupts if present */
+       struct rte_cryptodev_cb_list link_intr_cbs;
+
+       /** Context for security ops */
+       void *security_ctx;
+
+       __extension__
+       /** Flag indicating the device is attached */
+       uint8_t attached : 1;
+
+       /** User application callback for pre enqueue processing */
+       struct rte_cryptodev_cb_rcu *enq_cbs;
+       /** User application callback for post dequeue processing */
+       struct rte_cryptodev_cb_rcu *deq_cbs;
+} __rte_cache_aligned;
+
 /** Global structure used for maintaining state of allocated crypto devices */
 struct rte_cryptodev_global {
        struct rte_cryptodev *devs;     /**< Device information array */
@@ -92,15 +157,9 @@ __rte_internal
 struct rte_cryptodev *
 rte_cryptodev_pmd_get_named_dev(const char *name);
 
-/**
- * The pool of rte_cryptodev structures.
- */
-extern struct rte_cryptodev *rte_cryptodevs;
-
-
 /**
  * Definitions of all functions exported by a driver through the
- * the generic structure of type *crypto_dev_ops* supplied in the
+ * generic structure of type *crypto_dev_ops* supplied in the
  * *rte_cryptodev* structure associated with a device.
  */
 
@@ -260,7 +319,6 @@ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
  * @param      dev             Crypto device pointer
  * @param      xform           Single or chain of crypto xforms
  * @param      session         Pointer to cryptodev's private session structure
- * @param      mp              Mempool where the private session is allocated
  *
  * @return
  *  - Returns 0 if private session structure have been created successfully.
@@ -270,8 +328,7 @@ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
  */
 typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev,
                struct rte_crypto_asym_xform *xform,
-               struct rte_cryptodev_asym_session *session,
-               struct rte_mempool *mp);
+               struct rte_cryptodev_asym_session *session);
 /**
  * Free driver private session data.
  *
@@ -281,12 +338,12 @@ typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev,
 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
                struct rte_cryptodev_sym_session *sess);
 /**
- * Free asymmetric session private data.
+ * Clear asymmetric session private data.
  *
  * @param      dev             Crypto device pointer
  * @param      sess            Cryptodev session structure
  */
-typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev,
+typedef void (*cryptodev_asym_clear_session_t)(struct rte_cryptodev *dev,
                struct rte_cryptodev_asym_session *sess);
 /**
  * Perform actual crypto processing (encrypt/digest or auth/decrypt)
@@ -370,7 +427,7 @@ struct rte_cryptodev_ops {
        /**< Configure asymmetric Crypto session. */
        cryptodev_sym_free_session_t sym_session_clear;
        /**< Clear a Crypto sessions private data. */
-       cryptodev_asym_free_session_t asym_session_clear;
+       cryptodev_asym_clear_session_t asym_session_clear;
        /**< Clear a Crypto sessions private data. */
        union {
                cryptodev_sym_cpu_crypto_process_t sym_cpu_process;
@@ -424,7 +481,7 @@ rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
  * PMD assist function to parse initialisation arguments for crypto driver
  * when creating a new crypto PMD device instance.
  *
- * PMD driver should set default values for that PMD before calling function,
+ * PMD should set default values for that PMD before calling function,
  * these default values will be over-written with successfully parsed values
  * from args string.
  *
@@ -515,6 +572,19 @@ __rte_internal
 uint8_t rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
                const struct rte_driver *drv);
 
+/**
+ * @internal
+ * This is the last step of device probing. It must be called after a
+ * cryptodev is allocated and initialized successfully.
+ *
+ * @param      dev     Pointer to cryptodev struct
+ *
+ * @return
+ *  void
+ */
+__rte_internal
+void
+rte_cryptodev_pmd_probing_finish(struct rte_cryptodev *dev);
 
 #define RTE_PMD_REGISTER_CRYPTO_DRIVER(crypto_drv, drv, driver_id)\
 RTE_INIT(init_ ##driver_id)\
@@ -522,6 +592,17 @@ RTE_INIT(init_ ##driver_id)\
        driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\
 }
 
+/* Reset crypto device fastpath APIs to dummy values. */
+__rte_internal
+void
+cryptodev_fp_ops_reset(struct rte_crypto_fp_ops *fp_ops);
+
+/* Setup crypto device fastpath APIs. */
+__rte_internal
+void
+cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
+                    const struct rte_cryptodev *dev);
+
 static inline void *
 get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
                uint8_t driver_id) {
@@ -544,17 +625,23 @@ set_sym_session_private_data(struct rte_cryptodev_sym_session *sess,
        sess->sess_data[driver_id].data = private_data;
 }
 
-static inline void *
-get_asym_session_private_data(const struct rte_cryptodev_asym_session *sess,
-               uint8_t driver_id) {
-       return sess->sess_private_data[driver_id];
-}
+/**
+ * @internal
+ * Cryptodev asymmetric crypto session.
+ */
+RTE_STD_C11 struct rte_cryptodev_asym_session {
+       uint8_t driver_id;
+       /**< Session driver ID. */
+       uint16_t max_priv_data_sz;
+       /**< Size of private data used when creating mempool */
+       uint16_t user_data_sz;
+       /**< Session user data will be placed after sess_data */
+       uint8_t padding[3];
+       uint8_t sess_private_data[0];
+};
 
-static inline void
-set_asym_session_private_data(struct rte_cryptodev_asym_session *sess,
-               uint8_t driver_id, void *private_data)
-{
-       sess->sess_private_data[driver_id] = private_data;
+#ifdef __cplusplus
 }
+#endif
 
 #endif /* _CRYPTODEV_PMD_H_ */