#include <stdlib.h>
#include <stdio.h>
#include "cryptodev.h"
static struct cryptodev_list cryptodev_list;
int
cryptodev_init(void)
{
TAILQ_INIT(&cryptodev_list);
return 0;
}
struct cryptodev *
cryptodev_find(const char *name)
{
struct cryptodev *cryptodev;
if (name == NULL)
return NULL;
TAILQ_FOREACH(cryptodev, &cryptodev_list, node)
if (strcmp(cryptodev->name, name) == 0)
return cryptodev;
return NULL;
}
struct cryptodev *
cryptodev_next(struct cryptodev *cryptodev)
{
return (cryptodev == NULL) ?
TAILQ_FIRST(&cryptodev_list) :
TAILQ_NEXT(cryptodev, node);
}
struct cryptodev *
cryptodev_create(const char *name, struct cryptodev_params *params)
{
struct cryptodev *cryptodev;
uint32_t dev_id, i;
uint32_t socket_id;
int status;
if ((name == NULL) ||
cryptodev_find(name) ||
(params->n_queues == 0) ||
(params->queue_size == 0))
return NULL;
if (params->dev_name) {
if (status == -1)
return NULL;
dev_id = (uint32_t)status;
} else {
return NULL;
dev_id = params->dev_id;
}
socket_id = rte_cryptodev_socket_id(dev_id);
if (dev_info.max_nb_queue_pairs < params->n_queues)
return NULL;
return NULL;
dev_conf.socket_id = socket_id;
dev_conf.nb_queue_pairs = params->n_queues;
if (status < 0)
return NULL;
queue_conf.nb_descriptors = params->queue_size;
for (i = 0; i < params->n_queues; i++) {
&queue_conf, socket_id, NULL);
if (status < 0)
return NULL;
}
return NULL;
cryptodev = calloc(1, sizeof(struct cryptodev));
if (cryptodev == NULL) {
return NULL;
}
strlcpy(cryptodev->name, name, sizeof(cryptodev->name));
cryptodev->dev_id = dev_id;
cryptodev->n_queues = params->n_queues;
TAILQ_INSERT_TAIL(&cryptodev_list, cryptodev, node);
return cryptodev;
}