aboutsummaryrefslogtreecommitdiffstats
path: root/lib/librte_cryptodev/rte_cryptodev_pmd.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_cryptodev/rte_cryptodev_pmd.h')
-rw-r--r--lib/librte_cryptodev/rte_cryptodev_pmd.h156
1 files changed, 28 insertions, 128 deletions
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 17ef37c7..c983eb21 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -47,7 +47,6 @@ extern "C" {
#include <string.h>
#include <rte_dev.h>
-#include <rte_pci.h>
#include <rte_malloc.h>
#include <rte_mbuf.h>
#include <rte_mempool.h>
@@ -57,80 +56,6 @@ extern "C" {
#include "rte_crypto.h"
#include "rte_cryptodev.h"
-struct rte_cryptodev_session {
- RTE_STD_C11
- struct {
- uint8_t dev_id;
- enum rte_cryptodev_type type;
- struct rte_mempool *mp;
- } __rte_aligned(8);
-
- __extension__ char _private[0];
-};
-
-struct rte_cryptodev_driver;
-
-/**
- * Initialisation function of a crypto driver invoked for each matching
- * crypto PCI device detected during the PCI probing phase.
- *
- * @param drv The pointer to the [matching] crypto driver structure
- * supplied by the PMD when it registered itself.
- * @param dev The dev pointer is the address of the *rte_cryptodev*
- * structure associated with the matching device and which
- * has been [automatically] allocated in the
- * *rte_crypto_devices* array.
- *
- * @return
- * - 0: Success, the device is properly initialised by the driver.
- * In particular, the driver MUST have set up the *dev_ops* pointer
- * of the *dev* structure.
- * - <0: Error code of the device initialisation failure.
- */
-typedef int (*cryptodev_init_t)(struct rte_cryptodev_driver *drv,
- struct rte_cryptodev *dev);
-
-/**
- * Finalisation function of a driver invoked for each matching
- * PCI device detected during the PCI closing phase.
- *
- * @param drv The pointer to the [matching] driver structure supplied
- * by the PMD when it registered itself.
- * @param dev The dev pointer is the address of the *rte_cryptodev*
- * structure associated with the matching device and which
- * has been [automatically] allocated in the
- * *rte_crypto_devices* array.
- *
- * * @return
- * - 0: Success, the device is properly finalised by the driver.
- * In particular, the driver MUST free the *dev_ops* pointer
- * of the *dev* structure.
- * - <0: Error code of the device initialisation failure.
- */
-typedef int (*cryptodev_uninit_t)(const struct rte_cryptodev_driver *drv,
- struct rte_cryptodev *dev);
-
-/**
- * The structure associated with a PMD driver.
- *
- * Each driver acts as a PCI driver and is represented by a generic
- * *crypto_driver* structure that holds:
- *
- * - An *rte_pci_driver* structure (which must be the first field).
- *
- * - The *cryptodev_init* function invoked for each matching PCI device.
- *
- * - The size of the private data to allocate for each matching device.
- */
-struct rte_cryptodev_driver {
- struct rte_pci_driver pci_drv; /**< The PMD is also a PCI driver. */
- unsigned dev_private_size; /**< Size of device private data. */
-
- cryptodev_init_t cryptodev_init; /**< Device init function. */
- cryptodev_uninit_t cryptodev_uninit; /**< Device uninit function. */
-};
-
-
/** Global structure used for maintaining state of allocated crypto devices */
struct rte_cryptodev_global {
struct rte_cryptodev *devs; /**< Device information array */
@@ -282,12 +207,13 @@ typedef int (*cryptodev_queue_pair_stop_t)(struct rte_cryptodev *dev,
* @param qp_id Queue Pair Index
* @param qp_conf Queue configuration structure
* @param socket_id Socket Index
+ * @param session_pool Pointer to device session mempool
*
* @return Returns 0 on success.
*/
typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev,
uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf,
- int socket_id);
+ int socket_id, struct rte_mempool *session_pool);
/**
* Release memory resources allocated by given queue pair.
@@ -341,39 +267,32 @@ typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
struct rte_cryptodev *dev);
/**
- * Initialize a Crypto session on a device.
+ * Configure a Crypto session on a device.
*
* @param dev Crypto device pointer
* @param xform Single or chain of crypto xforms
* @param priv_sess Pointer to cryptodev's private session structure
+ * @param mp Mempool where the private session is allocated
*
* @return
- * - Returns private session structure on success.
- * - Returns NULL on failure.
+ * - Returns 0 if private session structure have been created successfully.
+ * - Returns -EINVAL if input parameters are invalid.
+ * - Returns -ENOTSUP if crypto device does not support the crypto transform.
+ * - Returns -ENOMEM if the private session could not be allocated.
*/
-typedef void (*cryptodev_sym_initialize_session_t)(struct rte_mempool *mempool,
- void *session_private);
+typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
+ struct rte_crypto_sym_xform *xform,
+ struct rte_cryptodev_sym_session *session,
+ struct rte_mempool *mp);
/**
- * Configure a Crypto session on a device.
+ * Free driver private session data.
*
* @param dev Crypto device pointer
- * @param xform Single or chain of crypto xforms
- * @param priv_sess Pointer to cryptodev's private session structure
- *
- * @return
- * - Returns private session structure on success.
- * - Returns NULL on failure.
- */
-typedef void * (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
- struct rte_crypto_sym_xform *xform, void *session_private);
-
-/**
- * Free Crypto session.
- * @param session Cryptodev session structure to free
+ * @param sess Cryptodev session structure
*/
typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
- void *session_private);
+ struct rte_cryptodev_sym_session *sess);
/**
* Optional API for drivers to attach sessions with queue pair.
@@ -428,8 +347,6 @@ struct rte_cryptodev_ops {
cryptodev_sym_get_session_private_size_t session_get_size;
/**< Return private session. */
- cryptodev_sym_initialize_session_t session_initialize;
- /**< Initialization function for private session data */
cryptodev_sym_configure_session_t session_configure;
/**< Configure a Crypto session. */
cryptodev_sym_free_session_t session_clear;
@@ -456,23 +373,6 @@ struct rte_cryptodev *
rte_cryptodev_pmd_allocate(const char *name, int socket_id);
/**
- * Creates a new virtual crypto device and returns the pointer
- * to that device.
- *
- * @param name PMD type name
- * @param dev_private_size Size of crypto PMDs private data
- * @param socket_id Socket to allocate resources on.
- *
- * @return
- * - Cryptodev pointer if device is successfully created.
- * - NULL if device cannot be created.
- */
-struct rte_cryptodev *
-rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
- int socket_id);
-
-
-/**
* Function for internal use by dummy drivers primarily, e.g. ring-based
* driver.
* Release the specified cryptodev device.
@@ -499,25 +399,25 @@ void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
enum rte_cryptodev_event_type event);
/**
- * Wrapper for use by pci drivers as a .probe function to attach to a crypto
- * interface.
- */
-int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
- struct rte_pci_device *pci_dev);
-
-/**
- * Wrapper for use by pci drivers as a .remove function to detach a crypto
- * interface.
- */
-int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);
-
-/**
* @internal
* Create unique device name
*/
int
rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
+static inline void *
+get_session_private_data(const struct rte_cryptodev_sym_session *sess,
+ uint8_t driver_id) {
+ return sess->sess_private_data[driver_id];
+}
+
+static inline void
+set_session_private_data(struct rte_cryptodev_sym_session *sess,
+ uint8_t driver_id, void *private_data)
+{
+ sess->sess_private_data[driver_id] = private_data;
+}
+
#ifdef __cplusplus
}
#endif