static struct rte_cryptodev_global cryptodev_globals = {
.devs = rte_crypto_devices,
.data = { NULL },
- .nb_devs = 0,
- .max_devs = RTE_CRYPTO_MAX_DEVS
+ .nb_devs = 0
};
/* spinlock for crypto device callbacks */
if (name == NULL)
return NULL;
- for (i = 0; i < cryptodev_globals.max_devs; i++) {
+ for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
dev = &cryptodev_globals.devs[i];
if ((dev->attached == RTE_CRYPTODEV_ATTACHED) &&
return NULL;
}
+static inline uint8_t
+rte_cryptodev_is_valid_device_data(uint8_t dev_id)
+{
+ if (rte_crypto_devices[dev_id].data == NULL)
+ return 0;
+
+ return 1;
+}
+
unsigned int
rte_cryptodev_pmd_is_valid_dev(uint8_t dev_id)
{
struct rte_cryptodev *dev = NULL;
- if (dev_id >= cryptodev_globals.nb_devs)
+ if (!rte_cryptodev_is_valid_device_data(dev_id))
return 0;
dev = rte_cryptodev_pmd_get_dev(dev_id);
if (name == NULL)
return -1;
- for (i = 0; i < cryptodev_globals.nb_devs; i++)
+ for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
+ if (!rte_cryptodev_is_valid_device_data(i))
+ continue;
if ((strcmp(cryptodev_globals.devs[i].data->name, name)
== 0) &&
(cryptodev_globals.devs[i].attached ==
RTE_CRYPTODEV_ATTACHED))
return i;
+ }
return -1;
}
{
uint8_t i, dev_count = 0;
- for (i = 0; i < cryptodev_globals.max_devs; i++)
+ for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++)
if (cryptodev_globals.devs[i].driver_id == driver_id &&
cryptodev_globals.devs[i].attached ==
RTE_CRYPTODEV_ATTACHED)
{
uint8_t i, count = 0;
struct rte_cryptodev *devs = cryptodev_globals.devs;
- uint8_t max_devs = cryptodev_globals.max_devs;
- for (i = 0; i < max_devs && count < nb_devices; i++) {
+ for (i = 0; i < RTE_CRYPTO_MAX_DEVS && count < nb_devices; i++) {
+ if (!rte_cryptodev_is_valid_device_data(i))
+ continue;
if (devs[i].attached == RTE_CRYPTODEV_ATTACHED) {
int cmp;
{
struct rte_cryptodev *dev;
- if (dev_id >= cryptodev_globals.nb_devs) {
+ if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
CDEV_LOG_ERR("Invalid dev_id=%d", dev_id);
return;
}