eventdev: include PCI devices when getting id from name
authorPavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Fri, 15 Jun 2018 03:45:24 +0000 (09:15 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Fri, 6 Jul 2018 04:54:49 +0000 (06:54 +0200)
Currently, rte_event_dev_get_dev_id works only for virtual devices(vdev)
update the function to include devices probed through pci.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
lib/librte_eventdev/rte_eventdev.c

index 7ca9fd1..801810e 100644 (file)
@@ -57,16 +57,21 @@ int
 rte_event_dev_get_dev_id(const char *name)
 {
        int i;
+       uint8_t cmp;
 
        if (!name)
                return -EINVAL;
 
-       for (i = 0; i < rte_eventdev_globals->nb_devs; i++)
-               if ((strcmp(rte_event_devices[i].data->name, name)
-                               == 0) &&
-                               (rte_event_devices[i].attached ==
-                                               RTE_EVENTDEV_ATTACHED))
+       for (i = 0; i < rte_eventdev_globals->nb_devs; i++) {
+               cmp = (strncmp(rte_event_devices[i].data->name, name,
+                               RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
+                       (rte_event_devices[i].dev ? (strncmp(
+                               rte_event_devices[i].dev->driver->name, name,
+                                        RTE_EVENTDEV_NAME_MAX_LEN) == 0) : 0);
+               if (cmp && (rte_event_devices[i].attached ==
+                                       RTE_EVENTDEV_ATTACHED))
                        return i;
+       }
        return -ENODEV;
 }