#include <errno.h>
#include <stdint.h>
#include <inttypes.h>
-#include <netinet/in.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#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;
.nb_devs = 0
};
+/* Public fastpath APIs. */
+struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
+
/* spinlock for crypto device callbacks */
static rte_spinlock_t rte_cryptodev_cb_lock = RTE_SPINLOCK_INITIALIZER;
}
unsigned int
-rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
+rte_cryptodev_is_valid_dev(uint8_t dev_id)
{
struct rte_cryptodev *dev = NULL;
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+ if (!rte_cryptodev_is_valid_dev(dev_id))
return -1;
dev = rte_cryptodev_pmd_get_dev(dev_id);
dev_id = cryptodev->data->dev_id;
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
/* Close device only if device operations have been set */
if (cryptodev->dev_ops) {
ret = rte_cryptodev_close(dev_id);
if (dev->data->queue_pairs == NULL) { /* first time configuration */
dev->data->queue_pairs = rte_zmalloc_socket(
"cryptodev->queue_pairs",
- sizeof(dev->data->queue_pairs[0]) * nb_qpairs,
+ sizeof(dev->data->queue_pairs[0]) *
+ dev_info.max_nb_queue_pairs,
RTE_CACHE_LINE_SIZE, socket_id);
if (dev->data->queue_pairs == NULL) {
ret = (*dev->dev_ops->queue_pair_release)(dev, i);
if (ret < 0)
return ret;
+ qp[i] = NULL;
}
- qp = rte_realloc(qp, sizeof(qp[0]) * nb_qpairs,
- RTE_CACHE_LINE_SIZE);
- if (qp == NULL) {
- CDEV_LOG_ERR("failed to realloc qp meta data,"
- " nb_queues %u", nb_qpairs);
- return -(ENOMEM);
- }
-
- if (nb_qpairs > old_nb_queues) {
- uint16_t new_qs = nb_qpairs - old_nb_queues;
-
- memset(qp + old_nb_queues, 0,
- sizeof(qp[0]) * new_qs);
- }
-
- dev->data->queue_pairs = qp;
-
}
dev->data->nb_queue_pairs = nb_qpairs;
return 0;
struct rte_cryptodev *dev;
int diag;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
CDEV_LOG_DEBUG("Start dev_id=%" PRIu8, dev_id);
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
}
diag = (*dev->dev_ops->dev_start)(dev);
+ /* expose selection of PMD fast-path functions */
+ cryptodev_fp_ops_set(rte_crypto_fp_ops + dev_id, dev);
+
rte_cryptodev_trace_start(dev_id, diag);
if (diag == 0)
dev->data->dev_started = 1;
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return;
}
return;
}
+ /* point fast-path functions to dummy ones */
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + dev_id);
+
(*dev->dev_ops->dev_stop)(dev);
rte_cryptodev_trace_stop(dev_id);
dev->data->dev_started = 0;
struct rte_cryptodev *dev;
int retval;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -1;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
return NULL;
}
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
rte_errno = ENODEV;
return NULL;
return -EINVAL;
}
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
return -ENODEV;
}
return NULL;
}
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
rte_errno = ENODEV;
return NULL;
return -EINVAL;
}
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
return -ENODEV;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
return -ENODEV;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
return;
}
if (!cb_fn)
return -EINVAL;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
if (!cb_fn)
return -EINVAL;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
uint8_t index;
int ret;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
uint8_t index;
int ret;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
struct rte_cryptodev *dev;
uint8_t driver_id;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
return -EINVAL;
}
struct rte_cryptodev *dev;
unsigned int priv_sess_size;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+ if (!rte_cryptodev_is_valid_dev(dev_id))
return 0;
dev = rte_cryptodev_pmd_get_dev(dev_id);
unsigned int header_size = sizeof(void *) * nb_drivers;
unsigned int priv_sess_size;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+ if (!rte_cryptodev_is_valid_dev(dev_id))
return 0;
dev = rte_cryptodev_pmd_get_dev(dev_id);
{
struct rte_cryptodev *dev;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+ if (!rte_cryptodev_is_valid_dev(dev_id)) {
sym_crypto_fill_status(vec, EINVAL);
return 0;
}
int32_t size = sizeof(struct rte_crypto_raw_dp_ctx);
int32_t priv_size;
- if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+ if (!rte_cryptodev_is_valid_dev(dev_id))
return -EINVAL;
dev = rte_cryptodev_pmd_get_dev(dev_id);
return nb_drivers++;
}
+
+RTE_INIT(cryptodev_init_fp_ops)
+{
+ uint32_t i;
+
+ for (i = 0; i != RTE_DIM(rte_crypto_fp_ops); i++)
+ cryptodev_fp_ops_reset(rte_crypto_fp_ops + i);
+}