eventdev: restructure release function
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Fri, 9 Jun 2017 08:37:27 +0000 (14:07 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Wed, 21 Jun 2017 13:33:23 +0000 (15:33 +0200)
Remove rte_event_dev_close() from rte_event_pmd_release() function so
that rte_event_pmd_release() can be used in stateless way. This will
enable rte_event_pmd_vdev_uninit() function to avoid using
eventdev_globals global variable and the need for exposing the a
global variable to PMD.

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

index fd04067..74a2614 100644 (file)
@@ -1171,10 +1171,6 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
        if (eventdev == NULL)
                return -EINVAL;
 
-       ret = rte_event_dev_close(eventdev->data->dev_id);
-       if (ret < 0)
-               return ret;
-
        eventdev->attached = RTE_EVENTDEV_DETACHED;
        eventdev_globals.nb_devs--;
 
@@ -1230,6 +1226,7 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
 int
 rte_event_pmd_vdev_uninit(const char *name)
 {
+       int ret;
        struct rte_eventdev *eventdev;
 
        if (name == NULL)
@@ -1239,6 +1236,10 @@ rte_event_pmd_vdev_uninit(const char *name)
        if (eventdev == NULL)
                return -ENODEV;
 
+       ret = rte_event_dev_close(eventdev->data->dev_id);
+       if (ret < 0)
+               return ret;
+
        /* Free the event device */
        rte_event_pmd_release(eventdev);
 
@@ -1293,11 +1294,7 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
                        (unsigned int) pci_dev->id.vendor_id,
                        (unsigned int) pci_dev->id.device_id);
 
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               rte_free(eventdev->data->dev_private);
-
-       eventdev->attached = RTE_EVENTDEV_DETACHED;
-       eventdev_globals.nb_devs--;
+       rte_event_pmd_release(eventdev);
 
        return -ENXIO;
 }
@@ -1320,6 +1317,10 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
        if (eventdev == NULL)
                return -ENODEV;
 
+       ret = rte_event_dev_close(eventdev->data->dev_id);
+       if (ret < 0)
+               return ret;
+
        /* Invoke PMD device un-init function */
        if (devuninit)
                ret = devuninit(eventdev);