session and the private data of session. An opaque pointer can be exposed
directly to application which can be attached to the ``rte_crypto_op``.
-* cryptodev: The interface between library and drivers will be marked
- as internal in DPDK 21.11.
-
* security: Hide structure ``rte_security_session`` and expose an opaque
pointer for the private data to the application which can be attached
to the packet while enqueuing.
rte_cryptodev_is_valid_dev as it can be used by the application as
well as PMD to check whether the device is valid or not.
+* cryptodev: The rte_cryptodev_pmd.* files are renamed as cryptodev_pmd.*
+ as it is for drivers only and should be private to DPDK, and not
+ installed for app use.
+
ABI Changes
-----------
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "aesni_gcm_pmd_private.h"
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_ether.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "aesni_mb_pmd_private.h"
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "armv8_pmd_private.h"
#include <rte_dev.h>
#include <rte_errno.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "bcmfs_device.h"
#include "bcmfs_logs.h"
#include <stdbool.h>
#include <rte_crypto.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "bcmfs_sym_defs.h"
#include "bcmfs_sym_req.h"
#include <rte_byteorder.h>
#include <rte_common.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
#include <rte_bus_vdev.h>
#include <rte_memory.h>
#include <rte_spinlock.h>
#include <rte_string_fns.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "ccp_dev.h"
#include "ccp_crypto.h"
#include <string.h>
#include <rte_common.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_malloc.h>
#include "ccp_pmd_private.h"
#include <rte_bus_vdev.h>
#include <rte_common.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_pci.h>
#include <rte_dev.h>
#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_dev.h>
#include <rte_pci.h>
*/
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_event_crypto_adapter.h>
#include <rte_ip.h>
#define _CN10K_CRYPTODEV_OPS_H_
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
extern struct rte_cryptodev_ops cn10k_cpt_ops;
#include <rte_common.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_dev.h>
#include <rte_pci.h>
*/
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_event_crypto_adapter.h>
#include <rte_ip.h>
#include <rte_vect.h>
#ifndef _CN9K_CRYPTODEV_OPS_H_
#define _CN9K_CRYPTODEV_OPS_H_
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
extern struct rte_cryptodev_ops cn9k_cpt_ops;
*/
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_errno.h>
#include "roc_cpt.h"
#include <rte_cycles.h>
#include <rte_kvargs.h>
#include <rte_dev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_common.h>
#include <rte_fslmc.h>
#include <fslmc_vfio.h>
#include <rte_byteorder.h>
#include <rte_common.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
#ifdef RTE_LIB_SECURITY
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "kasumi_pmd_private.h"
#include <stdbool.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <mlx5_common_utils.h>
#include <mlx5_common_devx.h>
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_security_driver.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_security_driver.h>
#include "mrvl_pmd_private.h"
#include <stdbool.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_crypto.h>
#include "nitrox_sym.h"
*/
#include <rte_common.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "null_crypto_pmd_private.h"
#include <rte_bus_pci.h>
#include <rte_common.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_log.h>
#include <rte_pci.h>
#include <rte_alarm.h>
#include <rte_bus_pci.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_eventdev.h>
#include <rte_event_crypto_adapter.h>
#include <rte_errno.h>
#include <rte_common.h>
#include <rte_crypto.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_dev.h>
#include <rte_errno.h>
#include <rte_mempool.h>
#include <unistd.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_event_crypto_adapter.h>
#ifndef _OTX2_CRYPTODEV_OPS_H_
#define _OTX2_CRYPTODEV_OPS_H_
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#define OTX2_CPT_MIN_HEADROOM_REQ 24
#define OTX2_CPT_MIN_TAILROOM_REQ 8
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "openssl_pmd_private.h"
#include "compat.h"
#ifndef _QAT_ASYM_H_
#define _QAT_ASYM_H_
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_crypto_asym.h>
#include "icp_qat_fw_pke.h"
#include "qat_common.h"
* Copyright(c) 2019 Intel Corporation
*/
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "qat_logs.h"
#ifndef _QAT_SYM_H_
#define _QAT_SYM_H_
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#ifdef RTE_LIB_SECURITY
#include <rte_net_crc.h>
#endif
* Copyright(c) 2020 Intel Corporation
*/
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "adf_transport_access_macros.h"
#include "icp_qat_fw.h"
#include <rte_dev.h>
#include <rte_malloc.h>
#include <rte_pci.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#ifdef RTE_LIB_SECURITY
#include <rte_security_driver.h>
#endif
#define _QAT_SYM_SESSION_H_
#include <rte_crypto.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#ifdef RTE_LIB_SECURITY
#include <rte_security.h>
#endif
#include <rte_string_fns.h>
#include <rte_reorder.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_malloc.h>
#include "rte_cryptodev_scheduler.h"
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_malloc.h>
#include <rte_dev.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_reorder.h>
#include "scheduler_pmd_private.h"
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "snow3g_pmd_private.h"
#include <rte_pci.h>
#include <rte_bus_pci.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_eal.h>
#include "virtio_cryptodev.h"
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
*/
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "virtqueue.h"
#include "virtio_cryptodev.h"
#include <rte_common.h>
#include <rte_hexdump.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_bus_vdev.h>
#include <rte_malloc.h>
#include <rte_cpuflags.h>
#include <rte_common.h>
#include <rte_malloc.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "zuc_pmd_private.h"
#define _OTX2_EVDEV_CRYPTO_ADPTR_RX_H_
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_eventdev.h>
#include "cpt_pmd_logs.h"
#define _OTX2_EVDEV_CRYPTO_ADPTR_TX_H_
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_event_crypto_adapter.h>
#include <rte_eventdev.h>
#include <stdio.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_string_fns.h>
#include "rte_eth_softnic_internals.h"
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017 Intel Corporation
+ */
+
+#include <rte_string_fns.h>
+#include <rte_malloc.h>
+
+#include "cryptodev_pmd.h"
+
+/**
+ * Parse name from argument
+ */
+static int
+rte_cryptodev_pmd_parse_name_arg(const char *key __rte_unused,
+ const char *value, void *extra_args)
+{
+ struct rte_cryptodev_pmd_init_params *params = extra_args;
+ int n;
+
+ n = strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
+ if (n >= RTE_CRYPTODEV_NAME_MAX_LEN)
+ return -EINVAL;
+
+ return 0;
+}
+
+/**
+ * Parse unsigned integer from argument
+ */
+static int
+rte_cryptodev_pmd_parse_uint_arg(const char *key __rte_unused,
+ const char *value, void *extra_args)
+{
+ int i;
+ char *end;
+ errno = 0;
+
+ i = strtol(value, &end, 10);
+ if (*end != 0 || errno != 0 || i < 0)
+ return -EINVAL;
+
+ *((uint32_t *)extra_args) = i;
+ return 0;
+}
+
+int
+rte_cryptodev_pmd_parse_input_args(
+ struct rte_cryptodev_pmd_init_params *params,
+ const char *args)
+{
+ struct rte_kvargs *kvlist = NULL;
+ int ret = 0;
+
+ if (params == NULL)
+ return -EINVAL;
+
+ if (args) {
+ kvlist = rte_kvargs_parse(args, cryptodev_pmd_valid_params);
+ if (kvlist == NULL)
+ return -EINVAL;
+
+ ret = rte_kvargs_process(kvlist,
+ RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
+ &rte_cryptodev_pmd_parse_uint_arg,
+ ¶ms->max_nb_queue_pairs);
+ if (ret < 0)
+ goto free_kvlist;
+
+ ret = rte_kvargs_process(kvlist,
+ RTE_CRYPTODEV_PMD_SOCKET_ID_ARG,
+ &rte_cryptodev_pmd_parse_uint_arg,
+ ¶ms->socket_id);
+ if (ret < 0)
+ goto free_kvlist;
+
+ ret = rte_kvargs_process(kvlist,
+ RTE_CRYPTODEV_PMD_NAME_ARG,
+ &rte_cryptodev_pmd_parse_name_arg,
+ params);
+ if (ret < 0)
+ goto free_kvlist;
+ }
+
+free_kvlist:
+ rte_kvargs_free(kvlist);
+ return ret;
+}
+
+struct rte_cryptodev *
+rte_cryptodev_pmd_create(const char *name,
+ struct rte_device *device,
+ struct rte_cryptodev_pmd_init_params *params)
+{
+ struct rte_cryptodev *cryptodev;
+
+ if (params->name[0] != '\0') {
+ CDEV_LOG_INFO("User specified device name = %s\n", params->name);
+ name = params->name;
+ }
+
+ CDEV_LOG_INFO("Creating cryptodev %s\n", name);
+
+ CDEV_LOG_INFO("Initialisation parameters - name: %s,"
+ "socket id: %d, max queue pairs: %u",
+ name, params->socket_id, params->max_nb_queue_pairs);
+
+ /* allocate device structure */
+ cryptodev = rte_cryptodev_pmd_allocate(name, params->socket_id);
+ if (cryptodev == NULL) {
+ CDEV_LOG_ERR("Failed to allocate crypto device for %s", name);
+ return NULL;
+ }
+
+ /* allocate private device structure */
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ cryptodev->data->dev_private =
+ rte_zmalloc_socket("cryptodev device private",
+ params->private_data_size,
+ RTE_CACHE_LINE_SIZE,
+ params->socket_id);
+
+ if (cryptodev->data->dev_private == NULL) {
+ CDEV_LOG_ERR("Cannot allocate memory for cryptodev %s"
+ " private data", name);
+
+ rte_cryptodev_pmd_release_device(cryptodev);
+ return NULL;
+ }
+ }
+
+ cryptodev->device = device;
+
+ /* initialise user call-back tail queue */
+ TAILQ_INIT(&(cryptodev->link_intr_cbs));
+
+ return cryptodev;
+}
+
+int
+rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev)
+{
+ int retval;
+ void *dev_priv = cryptodev->data->dev_private;
+
+ CDEV_LOG_INFO("Closing crypto device %s", cryptodev->device->name);
+
+ /* free crypto device */
+ retval = rte_cryptodev_pmd_release_device(cryptodev);
+ if (retval)
+ return retval;
+
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ rte_free(dev_priv);
+
+
+ cryptodev->device = NULL;
+ cryptodev->data = NULL;
+
+ return 0;
+}
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2015-2020 Intel Corporation.
+ */
+
+#ifndef _CRYPTODEV_PMD_H_
+#define _CRYPTODEV_PMD_H_
+
+/** @file
+ * RTE Crypto PMD APIs
+ *
+ * @note
+ * These API are from crypto PMD only and user applications should not call
+ * them directly.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#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>
+
+#include "rte_crypto.h"
+#include "rte_cryptodev.h"
+
+
+#define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
+
+#define RTE_CRYPTODEV_PMD_NAME_ARG ("name")
+#define RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG ("max_nb_queue_pairs")
+#define RTE_CRYPTODEV_PMD_SOCKET_ID_ARG ("socket_id")
+
+
+static const char * const cryptodev_pmd_valid_params[] = {
+ RTE_CRYPTODEV_PMD_NAME_ARG,
+ RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
+ RTE_CRYPTODEV_PMD_SOCKET_ID_ARG,
+ NULL
+};
+
+/**
+ * @internal
+ * Initialisation parameters for crypto devices
+ */
+struct rte_cryptodev_pmd_init_params {
+ char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+ size_t private_data_size;
+ int socket_id;
+ unsigned int max_nb_queue_pairs;
+};
+
+/** Global structure used for maintaining state of allocated crypto devices */
+struct rte_cryptodev_global {
+ struct rte_cryptodev *devs; /**< Device information array */
+ struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
+ /**< Device private data */
+ uint8_t nb_devs; /**< Number of devices found */
+};
+
+/* Cryptodev driver, containing the driver ID */
+struct cryptodev_driver {
+ TAILQ_ENTRY(cryptodev_driver) next; /**< Next in list. */
+ const struct rte_driver *driver;
+ uint8_t id;
+};
+
+/**
+ * Get the rte_cryptodev structure device pointer for the device. Assumes a
+ * valid device index.
+ *
+ * @param dev_id Device ID value to select the device structure.
+ *
+ * @return
+ * - The rte_cryptodev structure pointer for the given device ID.
+ */
+__rte_internal
+struct rte_cryptodev *
+rte_cryptodev_pmd_get_dev(uint8_t dev_id);
+
+/**
+ * Get the rte_cryptodev structure device pointer for the named device.
+ *
+ * @param name device name to select the device structure.
+ *
+ * @return
+ * - The rte_cryptodev structure pointer for the given device ID.
+ */
+__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
+ * *rte_cryptodev* structure associated with a device.
+ */
+
+/**
+ * Function used to configure device.
+ *
+ * @param dev Crypto device pointer
+ * @param config Crypto device configurations
+ *
+ * @return Returns 0 on success
+ */
+typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
+ struct rte_cryptodev_config *config);
+
+/**
+ * Function used to start a configured device.
+ *
+ * @param dev Crypto device pointer
+ *
+ * @return Returns 0 on success
+ */
+typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
+
+/**
+ * Function used to stop a configured device.
+ *
+ * @param dev Crypto device pointer
+ */
+typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
+
+/**
+ * Function used to close a configured device.
+ *
+ * @param dev Crypto device pointer
+ * @return
+ * - 0 on success.
+ * - EAGAIN if can't close as device is busy
+ */
+typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
+
+
+/**
+ * Function used to get statistics of a device.
+ *
+ * @param dev Crypto device pointer
+ * @param stats Pointer to crypto device stats structure to populate
+ */
+typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
+ struct rte_cryptodev_stats *stats);
+
+
+/**
+ * Function used to reset statistics of a device.
+ *
+ * @param dev Crypto device pointer
+ */
+typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
+
+
+/**
+ * Function used to get specific information of a device.
+ *
+ * @param dev Crypto device pointer
+ * @param dev_info Pointer to infos structure to populate
+ */
+typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
+ struct rte_cryptodev_info *dev_info);
+
+/**
+ * Setup a queue pair for a device.
+ *
+ * @param dev Crypto device pointer
+ * @param qp_id Queue Pair Index
+ * @param qp_conf Queue configuration structure
+ * @param socket_id Socket Index
+ *
+ * @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);
+
+/**
+ * Release memory resources allocated by given queue pair.
+ *
+ * @param dev Crypto device pointer
+ * @param qp_id Queue Pair Index
+ *
+ * @return
+ * - 0 on success.
+ * - EAGAIN if can't close as device is busy
+ */
+typedef int (*cryptodev_queue_pair_release_t)(struct rte_cryptodev *dev,
+ uint16_t qp_id);
+
+/**
+ * Create a session mempool to allocate sessions from
+ *
+ * @param dev Crypto device pointer
+ * @param nb_objs number of sessions objects in mempool
+ * @param obj_cache_size l-core object cache size, see *rte_ring_create*
+ * @param socket_id Socket Id to allocate mempool on.
+ *
+ * @return
+ * - On success returns a pointer to a rte_mempool
+ * - On failure returns a NULL pointer
+ */
+typedef int (*cryptodev_sym_create_session_pool_t)(
+ struct rte_cryptodev *dev, unsigned nb_objs,
+ unsigned obj_cache_size, int socket_id);
+
+
+/**
+ * Get the size of a cryptodev session
+ *
+ * @param dev Crypto device pointer
+ *
+ * @return
+ * - On success returns the size of the session structure for device
+ * - On failure returns 0
+ */
+typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
+ struct rte_cryptodev *dev);
+/**
+ * Get the size of a asymmetric cryptodev session
+ *
+ * @param dev Crypto device pointer
+ *
+ * @return
+ * - On success returns the size of the session structure for device
+ * - On failure returns 0
+ */
+typedef unsigned int (*cryptodev_asym_get_session_private_size_t)(
+ struct rte_cryptodev *dev);
+
+/**
+ * Configure a Crypto session on a device.
+ *
+ * @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.
+ * - 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 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 asymmetric session on a device.
+ *
+ * @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.
+ * - 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 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);
+/**
+ * Free driver private session data.
+ *
+ * @param dev Crypto device pointer
+ * @param sess Cryptodev session structure
+ */
+typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
+ struct rte_cryptodev_sym_session *sess);
+/**
+ * Free 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,
+ struct rte_cryptodev_asym_session *sess);
+/**
+ * Perform actual crypto processing (encrypt/digest or auth/decrypt)
+ * on user provided data.
+ *
+ * @param dev Crypto device pointer
+ * @param sess Cryptodev session structure
+ * @param ofs Start and stop offsets for auth and cipher operations
+ * @param vec Vectorized operation descriptor
+ *
+ * @return
+ * - Returns number of successfully processed packets.
+ *
+ */
+typedef uint32_t (*cryptodev_sym_cpu_crypto_process_t)
+ (struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess,
+ union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec);
+
+/**
+ * Typedef that the driver provided to get service context private date size.
+ *
+ * @param dev Crypto device pointer.
+ *
+ * @return
+ * - On success return the size of the device's service context private data.
+ * - On failure return negative integer.
+ */
+typedef int (*cryptodev_sym_get_raw_dp_ctx_size_t)(struct rte_cryptodev *dev);
+
+/**
+ * Typedef that the driver provided to configure raw data-path context.
+ *
+ * @param dev Crypto device pointer.
+ * @param qp_id Crypto device queue pair index.
+ * @param ctx The raw data-path context data.
+ * @param sess_type session type.
+ * @param session_ctx Session context data. If NULL the driver
+ * shall only configure the drv_ctx_data in
+ * ctx buffer. Otherwise the driver shall only
+ * parse the session_ctx to set appropriate
+ * function pointers in ctx.
+ * @param is_update Set 0 if it is to initialize the ctx.
+ * Set 1 if ctx is initialized and only to update
+ * session context data.
+ * @return
+ * - On success return 0.
+ * - On failure return negative integer.
+ */
+typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
+ struct rte_cryptodev *dev, uint16_t qp_id,
+ struct rte_crypto_raw_dp_ctx *ctx,
+ enum rte_crypto_op_sess_type sess_type,
+ union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
+
+/** Crypto device operations function pointer table */
+struct rte_cryptodev_ops {
+ cryptodev_configure_t dev_configure; /**< Configure device. */
+ cryptodev_start_t dev_start; /**< Start device. */
+ cryptodev_stop_t dev_stop; /**< Stop device. */
+ cryptodev_close_t dev_close; /**< Close device. */
+
+ cryptodev_info_get_t dev_infos_get; /**< Get device info. */
+
+ cryptodev_stats_get_t stats_get;
+ /**< Get device statistics. */
+ cryptodev_stats_reset_t stats_reset;
+ /**< Reset device statistics. */
+
+ cryptodev_queue_pair_setup_t queue_pair_setup;
+ /**< Set up a device queue pair. */
+ cryptodev_queue_pair_release_t queue_pair_release;
+ /**< Release a queue pair. */
+
+ cryptodev_sym_get_session_private_size_t sym_session_get_size;
+ /**< Return private session. */
+ cryptodev_asym_get_session_private_size_t asym_session_get_size;
+ /**< Return asym session private size. */
+ cryptodev_sym_configure_session_t sym_session_configure;
+ /**< Configure a Crypto session. */
+ cryptodev_asym_configure_session_t asym_session_configure;
+ /**< 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;
+ /**< Clear a Crypto sessions private data. */
+ union {
+ cryptodev_sym_cpu_crypto_process_t sym_cpu_process;
+ /**< process input data synchronously (cpu-crypto). */
+ __extension__
+ struct {
+ cryptodev_sym_get_raw_dp_ctx_size_t
+ sym_get_raw_dp_ctx_size;
+ /**< Get raw data path service context data size. */
+ cryptodev_sym_configure_raw_dp_ctx_t
+ sym_configure_raw_dp_ctx;
+ /**< Initialize raw data path context data. */
+ };
+ };
+};
+
+
+/**
+ * Function for internal use by dummy drivers primarily, e.g. ring-based
+ * driver.
+ * Allocates a new cryptodev slot for an crypto device and returns the pointer
+ * to that slot for the driver to use.
+ *
+ * @param name Unique identifier name for each device
+ * @param socket_id Socket to allocate resources on.
+ * @return
+ * - Slot in the rte_dev_devices array for a new device;
+ */
+__rte_internal
+struct rte_cryptodev *
+rte_cryptodev_pmd_allocate(const char *name, int socket_id);
+
+/**
+ * Function for internal use by dummy drivers primarily, e.g. ring-based
+ * driver.
+ * Release the specified cryptodev device.
+ *
+ * @param cryptodev
+ * The *cryptodev* pointer is the address of the *rte_cryptodev* structure.
+ * @return
+ * - 0 on success, negative on error
+ */
+__rte_internal
+extern int
+rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
+
+
+/**
+ * @internal
+ *
+ * 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,
+ * these default values will be over-written with successfully parsed values
+ * from args string.
+ *
+ * @param params parsed PMD initialisation parameters
+ * @param args input argument string to parse
+ *
+ * @return
+ * - 0 on success
+ * - errno on failure
+ */
+__rte_internal
+int
+rte_cryptodev_pmd_parse_input_args(
+ struct rte_cryptodev_pmd_init_params *params,
+ const char *args);
+
+/**
+ * @internal
+ *
+ * PMD assist function to provide boiler plate code for crypto driver to create
+ * and allocate resources for a new crypto PMD device instance.
+ *
+ * @param name crypto device name.
+ * @param device base device instance
+ * @param params PMD initialisation parameters
+ *
+ * @return
+ * - crypto device instance on success
+ * - NULL on creation failure
+ */
+__rte_internal
+struct rte_cryptodev *
+rte_cryptodev_pmd_create(const char *name,
+ struct rte_device *device,
+ struct rte_cryptodev_pmd_init_params *params);
+
+/**
+ * @internal
+ *
+ * PMD assist function to provide boiler plate code for crypto driver to
+ * destroy and free resources associated with a crypto PMD device instance.
+ *
+ * @param cryptodev crypto device handle.
+ *
+ * @return
+ * - 0 on success
+ * - errno on failure
+ */
+__rte_internal
+int
+rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev);
+
+/**
+ * Executes all the user application registered callbacks for the specific
+ * device.
+ * *
+ * @param dev Pointer to cryptodev struct
+ * @param event Crypto device interrupt event type.
+ *
+ * @return
+ * void
+ */
+__rte_internal
+void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
+ enum rte_cryptodev_event_type event);
+
+/**
+ * @internal
+ * Create unique device name
+ */
+__rte_internal
+int
+rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
+
+/**
+ * @internal
+ * Allocate Cryptodev driver.
+ *
+ * @param crypto_drv
+ * Pointer to cryptodev_driver.
+ * @param drv
+ * Pointer to rte_driver.
+ *
+ * @return
+ * The driver type identifier
+ */
+__rte_internal
+uint8_t rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
+ const struct rte_driver *drv);
+
+
+#define RTE_PMD_REGISTER_CRYPTO_DRIVER(crypto_drv, drv, driver_id)\
+RTE_INIT(init_ ##driver_id)\
+{\
+ driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\
+}
+
+static inline void *
+get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
+ uint8_t driver_id) {
+ if (unlikely(sess->nb_drivers <= driver_id))
+ return NULL;
+
+ return sess->sess_data[driver_id].data;
+}
+
+static inline void
+set_sym_session_private_data(struct rte_cryptodev_sym_session *sess,
+ uint8_t driver_id, void *private_data)
+{
+ if (unlikely(sess->nb_drivers <= driver_id)) {
+ CDEV_LOG_ERR("Set private data for driver %u not allowed\n",
+ driver_id);
+ return;
+ }
+
+ 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];
+}
+
+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_ */
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation
-sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c', 'cryptodev_trace_points.c')
-headers = files('rte_cryptodev.h',
- 'rte_cryptodev_pmd.h',
+sources = files(
+ 'cryptodev_pmd.c',
+ 'cryptodev_trace_points.c',
+ 'rte_cryptodev.c',
+)
+headers = files(
+ 'rte_cryptodev.h',
'rte_cryptodev_trace.h',
'rte_cryptodev_trace_fp.h',
'rte_crypto.h',
'rte_crypto_sym.h',
- 'rte_crypto_asym.h')
+ 'rte_crypto_asym.h',
+)
+
+driver_sdk_headers += files(
+ 'cryptodev_pmd.h',
+)
+
deps += ['kvargs', 'mbuf', 'rcu']
#include "rte_crypto.h"
#include "rte_cryptodev.h"
-#include "rte_cryptodev_pmd.h"
+#include "cryptodev_pmd.h"
#include "rte_cryptodev_trace.h"
static uint8_t nb_drivers;
+++ /dev/null
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017 Intel Corporation
- */
-
-#include <rte_string_fns.h>
-#include <rte_malloc.h>
-
-#include "rte_cryptodev_pmd.h"
-
-/**
- * Parse name from argument
- */
-static int
-rte_cryptodev_pmd_parse_name_arg(const char *key __rte_unused,
- const char *value, void *extra_args)
-{
- struct rte_cryptodev_pmd_init_params *params = extra_args;
- int n;
-
- n = strlcpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN);
- if (n >= RTE_CRYPTODEV_NAME_MAX_LEN)
- return -EINVAL;
-
- return 0;
-}
-
-/**
- * Parse unsigned integer from argument
- */
-static int
-rte_cryptodev_pmd_parse_uint_arg(const char *key __rte_unused,
- const char *value, void *extra_args)
-{
- int i;
- char *end;
- errno = 0;
-
- i = strtol(value, &end, 10);
- if (*end != 0 || errno != 0 || i < 0)
- return -EINVAL;
-
- *((uint32_t *)extra_args) = i;
- return 0;
-}
-
-int
-rte_cryptodev_pmd_parse_input_args(
- struct rte_cryptodev_pmd_init_params *params,
- const char *args)
-{
- struct rte_kvargs *kvlist = NULL;
- int ret = 0;
-
- if (params == NULL)
- return -EINVAL;
-
- if (args) {
- kvlist = rte_kvargs_parse(args, cryptodev_pmd_valid_params);
- if (kvlist == NULL)
- return -EINVAL;
-
- ret = rte_kvargs_process(kvlist,
- RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
- &rte_cryptodev_pmd_parse_uint_arg,
- ¶ms->max_nb_queue_pairs);
- if (ret < 0)
- goto free_kvlist;
-
- ret = rte_kvargs_process(kvlist,
- RTE_CRYPTODEV_PMD_SOCKET_ID_ARG,
- &rte_cryptodev_pmd_parse_uint_arg,
- ¶ms->socket_id);
- if (ret < 0)
- goto free_kvlist;
-
- ret = rte_kvargs_process(kvlist,
- RTE_CRYPTODEV_PMD_NAME_ARG,
- &rte_cryptodev_pmd_parse_name_arg,
- params);
- if (ret < 0)
- goto free_kvlist;
- }
-
-free_kvlist:
- rte_kvargs_free(kvlist);
- return ret;
-}
-
-struct rte_cryptodev *
-rte_cryptodev_pmd_create(const char *name,
- struct rte_device *device,
- struct rte_cryptodev_pmd_init_params *params)
-{
- struct rte_cryptodev *cryptodev;
-
- if (params->name[0] != '\0') {
- CDEV_LOG_INFO("User specified device name = %s\n", params->name);
- name = params->name;
- }
-
- CDEV_LOG_INFO("Creating cryptodev %s\n", name);
-
- CDEV_LOG_INFO("Initialisation parameters - name: %s,"
- "socket id: %d, max queue pairs: %u",
- name, params->socket_id, params->max_nb_queue_pairs);
-
- /* allocate device structure */
- cryptodev = rte_cryptodev_pmd_allocate(name, params->socket_id);
- if (cryptodev == NULL) {
- CDEV_LOG_ERR("Failed to allocate crypto device for %s", name);
- return NULL;
- }
-
- /* allocate private device structure */
- if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- cryptodev->data->dev_private =
- rte_zmalloc_socket("cryptodev device private",
- params->private_data_size,
- RTE_CACHE_LINE_SIZE,
- params->socket_id);
-
- if (cryptodev->data->dev_private == NULL) {
- CDEV_LOG_ERR("Cannot allocate memory for cryptodev %s"
- " private data", name);
-
- rte_cryptodev_pmd_release_device(cryptodev);
- return NULL;
- }
- }
-
- cryptodev->device = device;
-
- /* initialise user call-back tail queue */
- TAILQ_INIT(&(cryptodev->link_intr_cbs));
-
- return cryptodev;
-}
-
-int
-rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev)
-{
- int retval;
- void *dev_priv = cryptodev->data->dev_private;
-
- CDEV_LOG_INFO("Closing crypto device %s", cryptodev->device->name);
-
- /* free crypto device */
- retval = rte_cryptodev_pmd_release_device(cryptodev);
- if (retval)
- return retval;
-
- if (rte_eal_process_type() == RTE_PROC_PRIMARY)
- rte_free(dev_priv);
-
-
- cryptodev->device = NULL;
- cryptodev->data = NULL;
-
- return 0;
-}
+++ /dev/null
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2015-2020 Intel Corporation.
- */
-
-#ifndef _RTE_CRYPTODEV_PMD_H_
-#define _RTE_CRYPTODEV_PMD_H_
-
-/** @file
- * RTE Crypto PMD APIs
- *
- * @note
- * These API are from crypto PMD only and user applications should not call
- * them directly.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#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>
-
-#include "rte_crypto.h"
-#include "rte_cryptodev.h"
-
-
-#define RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS 8
-
-#define RTE_CRYPTODEV_PMD_NAME_ARG ("name")
-#define RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG ("max_nb_queue_pairs")
-#define RTE_CRYPTODEV_PMD_SOCKET_ID_ARG ("socket_id")
-
-
-static const char * const cryptodev_pmd_valid_params[] = {
- RTE_CRYPTODEV_PMD_NAME_ARG,
- RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG,
- RTE_CRYPTODEV_PMD_SOCKET_ID_ARG,
- NULL
-};
-
-/**
- * @internal
- * Initialisation parameters for crypto devices
- */
-struct rte_cryptodev_pmd_init_params {
- char name[RTE_CRYPTODEV_NAME_MAX_LEN];
- size_t private_data_size;
- int socket_id;
- unsigned int max_nb_queue_pairs;
-};
-
-/** Global structure used for maintaining state of allocated crypto devices */
-struct rte_cryptodev_global {
- struct rte_cryptodev *devs; /**< Device information array */
- struct rte_cryptodev_data *data[RTE_CRYPTO_MAX_DEVS];
- /**< Device private data */
- uint8_t nb_devs; /**< Number of devices found */
-};
-
-/* Cryptodev driver, containing the driver ID */
-struct cryptodev_driver {
- TAILQ_ENTRY(cryptodev_driver) next; /**< Next in list. */
- const struct rte_driver *driver;
- uint8_t id;
-};
-
-/**
- * Get the rte_cryptodev structure device pointer for the device. Assumes a
- * valid device index.
- *
- * @param dev_id Device ID value to select the device structure.
- *
- * @return
- * - The rte_cryptodev structure pointer for the given device ID.
- */
-struct rte_cryptodev *
-rte_cryptodev_pmd_get_dev(uint8_t dev_id);
-
-/**
- * Get the rte_cryptodev structure device pointer for the named device.
- *
- * @param name device name to select the device structure.
- *
- * @return
- * - The rte_cryptodev structure pointer for the given device ID.
- */
-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
- * *rte_cryptodev* structure associated with a device.
- */
-
-/**
- * Function used to configure device.
- *
- * @param dev Crypto device pointer
- * @param config Crypto device configurations
- *
- * @return Returns 0 on success
- */
-typedef int (*cryptodev_configure_t)(struct rte_cryptodev *dev,
- struct rte_cryptodev_config *config);
-
-/**
- * Function used to start a configured device.
- *
- * @param dev Crypto device pointer
- *
- * @return Returns 0 on success
- */
-typedef int (*cryptodev_start_t)(struct rte_cryptodev *dev);
-
-/**
- * Function used to stop a configured device.
- *
- * @param dev Crypto device pointer
- */
-typedef void (*cryptodev_stop_t)(struct rte_cryptodev *dev);
-
-/**
- * Function used to close a configured device.
- *
- * @param dev Crypto device pointer
- * @return
- * - 0 on success.
- * - EAGAIN if can't close as device is busy
- */
-typedef int (*cryptodev_close_t)(struct rte_cryptodev *dev);
-
-
-/**
- * Function used to get statistics of a device.
- *
- * @param dev Crypto device pointer
- * @param stats Pointer to crypto device stats structure to populate
- */
-typedef void (*cryptodev_stats_get_t)(struct rte_cryptodev *dev,
- struct rte_cryptodev_stats *stats);
-
-
-/**
- * Function used to reset statistics of a device.
- *
- * @param dev Crypto device pointer
- */
-typedef void (*cryptodev_stats_reset_t)(struct rte_cryptodev *dev);
-
-
-/**
- * Function used to get specific information of a device.
- *
- * @param dev Crypto device pointer
- * @param dev_info Pointer to infos structure to populate
- */
-typedef void (*cryptodev_info_get_t)(struct rte_cryptodev *dev,
- struct rte_cryptodev_info *dev_info);
-
-/**
- * Setup a queue pair for a device.
- *
- * @param dev Crypto device pointer
- * @param qp_id Queue Pair Index
- * @param qp_conf Queue configuration structure
- * @param socket_id Socket Index
- *
- * @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);
-
-/**
- * Release memory resources allocated by given queue pair.
- *
- * @param dev Crypto device pointer
- * @param qp_id Queue Pair Index
- *
- * @return
- * - 0 on success.
- * - EAGAIN if can't close as device is busy
- */
-typedef int (*cryptodev_queue_pair_release_t)(struct rte_cryptodev *dev,
- uint16_t qp_id);
-
-/**
- * Create a session mempool to allocate sessions from
- *
- * @param dev Crypto device pointer
- * @param nb_objs number of sessions objects in mempool
- * @param obj_cache_size l-core object cache size, see *rte_ring_create*
- * @param socket_id Socket Id to allocate mempool on.
- *
- * @return
- * - On success returns a pointer to a rte_mempool
- * - On failure returns a NULL pointer
- */
-typedef int (*cryptodev_sym_create_session_pool_t)(
- struct rte_cryptodev *dev, unsigned nb_objs,
- unsigned obj_cache_size, int socket_id);
-
-
-/**
- * Get the size of a cryptodev session
- *
- * @param dev Crypto device pointer
- *
- * @return
- * - On success returns the size of the session structure for device
- * - On failure returns 0
- */
-typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
- struct rte_cryptodev *dev);
-/**
- * Get the size of a asymmetric cryptodev session
- *
- * @param dev Crypto device pointer
- *
- * @return
- * - On success returns the size of the session structure for device
- * - On failure returns 0
- */
-typedef unsigned int (*cryptodev_asym_get_session_private_size_t)(
- struct rte_cryptodev *dev);
-
-/**
- * Configure a Crypto session on a device.
- *
- * @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.
- * - 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 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 asymmetric session on a device.
- *
- * @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.
- * - 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 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);
-/**
- * Free driver private session data.
- *
- * @param dev Crypto device pointer
- * @param sess Cryptodev session structure
- */
-typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
- struct rte_cryptodev_sym_session *sess);
-/**
- * Free 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,
- struct rte_cryptodev_asym_session *sess);
-/**
- * Perform actual crypto processing (encrypt/digest or auth/decrypt)
- * on user provided data.
- *
- * @param dev Crypto device pointer
- * @param sess Cryptodev session structure
- * @param ofs Start and stop offsets for auth and cipher operations
- * @param vec Vectorized operation descriptor
- *
- * @return
- * - Returns number of successfully processed packets.
- *
- */
-typedef uint32_t (*cryptodev_sym_cpu_crypto_process_t)
- (struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess,
- union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec);
-
-/**
- * Typedef that the driver provided to get service context private date size.
- *
- * @param dev Crypto device pointer.
- *
- * @return
- * - On success return the size of the device's service context private data.
- * - On failure return negative integer.
- */
-typedef int (*cryptodev_sym_get_raw_dp_ctx_size_t)(struct rte_cryptodev *dev);
-
-/**
- * Typedef that the driver provided to configure raw data-path context.
- *
- * @param dev Crypto device pointer.
- * @param qp_id Crypto device queue pair index.
- * @param ctx The raw data-path context data.
- * @param sess_type session type.
- * @param session_ctx Session context data. If NULL the driver
- * shall only configure the drv_ctx_data in
- * ctx buffer. Otherwise the driver shall only
- * parse the session_ctx to set appropriate
- * function pointers in ctx.
- * @param is_update Set 0 if it is to initialize the ctx.
- * Set 1 if ctx is initialized and only to update
- * session context data.
- * @return
- * - On success return 0.
- * - On failure return negative integer.
- */
-typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)(
- struct rte_cryptodev *dev, uint16_t qp_id,
- struct rte_crypto_raw_dp_ctx *ctx,
- enum rte_crypto_op_sess_type sess_type,
- union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
-
-/** Crypto device operations function pointer table */
-struct rte_cryptodev_ops {
- cryptodev_configure_t dev_configure; /**< Configure device. */
- cryptodev_start_t dev_start; /**< Start device. */
- cryptodev_stop_t dev_stop; /**< Stop device. */
- cryptodev_close_t dev_close; /**< Close device. */
-
- cryptodev_info_get_t dev_infos_get; /**< Get device info. */
-
- cryptodev_stats_get_t stats_get;
- /**< Get device statistics. */
- cryptodev_stats_reset_t stats_reset;
- /**< Reset device statistics. */
-
- cryptodev_queue_pair_setup_t queue_pair_setup;
- /**< Set up a device queue pair. */
- cryptodev_queue_pair_release_t queue_pair_release;
- /**< Release a queue pair. */
-
- cryptodev_sym_get_session_private_size_t sym_session_get_size;
- /**< Return private session. */
- cryptodev_asym_get_session_private_size_t asym_session_get_size;
- /**< Return asym session private size. */
- cryptodev_sym_configure_session_t sym_session_configure;
- /**< Configure a Crypto session. */
- cryptodev_asym_configure_session_t asym_session_configure;
- /**< 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;
- /**< Clear a Crypto sessions private data. */
- union {
- cryptodev_sym_cpu_crypto_process_t sym_cpu_process;
- /**< process input data synchronously (cpu-crypto). */
- __extension__
- struct {
- cryptodev_sym_get_raw_dp_ctx_size_t
- sym_get_raw_dp_ctx_size;
- /**< Get raw data path service context data size. */
- cryptodev_sym_configure_raw_dp_ctx_t
- sym_configure_raw_dp_ctx;
- /**< Initialize raw data path context data. */
- };
- };
-};
-
-
-/**
- * Function for internal use by dummy drivers primarily, e.g. ring-based
- * driver.
- * Allocates a new cryptodev slot for an crypto device and returns the pointer
- * to that slot for the driver to use.
- *
- * @param name Unique identifier name for each device
- * @param socket_id Socket to allocate resources on.
- * @return
- * - Slot in the rte_dev_devices array for a new device;
- */
-struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, int socket_id);
-
-/**
- * Function for internal use by dummy drivers primarily, e.g. ring-based
- * driver.
- * Release the specified cryptodev device.
- *
- * @param cryptodev
- * The *cryptodev* pointer is the address of the *rte_cryptodev* structure.
- * @return
- * - 0 on success, negative on error
- */
-extern int
-rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
-
-
-/**
- * @internal
- *
- * 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,
- * these default values will be over-written with successfully parsed values
- * from args string.
- *
- * @param params parsed PMD initialisation parameters
- * @param args input argument string to parse
- *
- * @return
- * - 0 on success
- * - errno on failure
- */
-int
-rte_cryptodev_pmd_parse_input_args(
- struct rte_cryptodev_pmd_init_params *params,
- const char *args);
-
-/**
- * @internal
- *
- * PMD assist function to provide boiler plate code for crypto driver to create
- * and allocate resources for a new crypto PMD device instance.
- *
- * @param name crypto device name.
- * @param device base device instance
- * @param params PMD initialisation parameters
- *
- * @return
- * - crypto device instance on success
- * - NULL on creation failure
- */
-struct rte_cryptodev *
-rte_cryptodev_pmd_create(const char *name,
- struct rte_device *device,
- struct rte_cryptodev_pmd_init_params *params);
-
-/**
- * @internal
- *
- * PMD assist function to provide boiler plate code for crypto driver to
- * destroy and free resources associated with a crypto PMD device instance.
- *
- * @param cryptodev crypto device handle.
- *
- * @return
- * - 0 on success
- * - errno on failure
- */
-int
-rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev);
-
-/**
- * Executes all the user application registered callbacks for the specific
- * device.
- * *
- * @param dev Pointer to cryptodev struct
- * @param event Crypto device interrupt event type.
- *
- * @return
- * void
- */
-void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
- enum rte_cryptodev_event_type event);
-
-/**
- * @internal
- * Create unique device name
- */
-int
-rte_cryptodev_pmd_create_dev_name(char *name, const char *dev_name_prefix);
-
-/**
- * @internal
- * Allocate Cryptodev driver.
- *
- * @param crypto_drv
- * Pointer to cryptodev_driver.
- * @param drv
- * Pointer to rte_driver.
- *
- * @return
- * The driver type identifier
- */
-uint8_t rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
- const struct rte_driver *drv);
-
-
-#define RTE_PMD_REGISTER_CRYPTO_DRIVER(crypto_drv, drv, driver_id)\
-RTE_INIT(init_ ##driver_id)\
-{\
- driver_id = rte_cryptodev_allocate_driver(&crypto_drv, &(drv));\
-}
-
-static inline void *
-get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess,
- uint8_t driver_id) {
- if (unlikely(sess->nb_drivers <= driver_id))
- return NULL;
-
- return sess->sess_data[driver_id].data;
-}
-
-static inline void
-set_sym_session_private_data(struct rte_cryptodev_sym_session *sess,
- uint8_t driver_id, void *private_data)
-{
- if (unlikely(sess->nb_drivers <= driver_id)) {
- CDEV_LOG_ERR("Set private data for driver %u not allowed\n",
- driver_id);
- return;
- }
-
- 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];
-}
-
-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 /* _RTE_CRYPTODEV_PMD_H_ */
rte_crypto_cipher_algorithm_strings;
rte_crypto_cipher_operation_strings;
rte_crypto_op_pool_create;
- rte_cryptodev_allocate_driver;
rte_cryptodev_callback_register;
rte_cryptodev_callback_unregister;
rte_cryptodev_close;
rte_cryptodev_info_get;
rte_cryptodev_is_valid_dev;
rte_cryptodev_name_get;
- rte_cryptodev_pmd_allocate;
- rte_cryptodev_pmd_callback_process;
- rte_cryptodev_pmd_create;
- rte_cryptodev_pmd_create_dev_name;
- rte_cryptodev_pmd_destroy;
- rte_cryptodev_pmd_get_dev;
- rte_cryptodev_pmd_get_named_dev;
- rte_cryptodev_pmd_parse_input_args;
- rte_cryptodev_pmd_release_device;
rte_cryptodev_queue_pair_count;
rte_cryptodev_queue_pair_setup;
rte_cryptodev_socket_id;
rte_cryptodev_remove_enq_callback;
};
+
+INTERNAL {
+ global:
+
+ rte_cryptodev_allocate_driver;
+ rte_cryptodev_pmd_allocate;
+ rte_cryptodev_pmd_callback_process;
+ rte_cryptodev_pmd_create;
+ rte_cryptodev_pmd_create_dev_name;
+ rte_cryptodev_pmd_destroy;
+ rte_cryptodev_pmd_get_dev;
+ rte_cryptodev_pmd_get_named_dev;
+ rte_cryptodev_pmd_parse_input_args;
+ rte_cryptodev_pmd_release_device;
+};
#include <rte_dev.h>
#include <rte_errno.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_service_component.h>
#include <rte_errno.h>
#include <rte_ethdev.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include <rte_telemetry.h>
#include "rte_eventdev.h"
#include <rte_udp.h>
#include <rte_vxlan.h>
#include <rte_cryptodev.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
#include "rte_table_action.h"