eventdev: support vdev uninit
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Mon, 6 Feb 2017 05:23:38 +0000 (10:53 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Tue, 4 Apr 2017 17:17:26 +0000 (19:17 +0200)
Added eventdev vdev uninit support to release the resources
allocated in eventdev vdev init.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
lib/librte_eventdev/rte_eventdev.c
lib/librte_eventdev/rte_eventdev_pmd.h
lib/librte_eventdev/rte_eventdev_version.map

index c7452f0..91bd1c9 100644 (file)
@@ -1080,6 +1080,8 @@ int
 rte_event_pmd_release(struct rte_eventdev *eventdev)
 {
        int ret;
+       char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
+       const struct rte_memzone *mz;
 
        if (eventdev == NULL)
                return -EINVAL;
@@ -1090,8 +1092,26 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
 
        eventdev->attached = RTE_EVENTDEV_DETACHED;
        eventdev_globals.nb_devs--;
-       eventdev->data = NULL;
 
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+               rte_free(eventdev->data->dev_private);
+
+               /* Generate memzone name */
+               ret = snprintf(mz_name, sizeof(mz_name), "rte_eventdev_data_%u",
+                               eventdev->data->dev_id);
+               if (ret >= (int)sizeof(mz_name))
+                       return -EINVAL;
+
+               mz = rte_memzone_lookup(mz_name);
+               if (mz == NULL)
+                       return -ENOMEM;
+
+               ret = rte_memzone_free(mz);
+               if (ret)
+                       return ret;
+       }
+
+       eventdev->data = NULL;
        return 0;
 }
 
@@ -1122,6 +1142,24 @@ rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
        return eventdev;
 }
 
+int
+rte_event_pmd_vdev_uninit(const char *name)
+{
+       struct rte_eventdev *eventdev;
+
+       if (name == NULL)
+               return -EINVAL;
+
+       eventdev = rte_event_pmd_get_named_dev(name);
+       if (eventdev == NULL)
+               return -ENODEV;
+
+       /* Free the event device */
+       rte_event_pmd_release(eventdev);
+
+       return 0;
+}
+
 int
 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
                        struct rte_pci_device *pci_dev)
@@ -1212,9 +1250,6 @@ rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
        /* Free event device */
        rte_event_pmd_release(eventdev);
 
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               rte_free(eventdev->data->dev_private);
-
        eventdev->pci_dev = NULL;
        eventdev->driver = NULL;
 
index 82d5e48..828dfce 100644 (file)
@@ -198,7 +198,7 @@ rte_event_pmd_is_valid_dev(uint8_t dev_id)
 {
        struct rte_eventdev *dev;
 
-       if (dev_id >= rte_eventdev_globals->nb_devs)
+       if (dev_id >= RTE_EVENT_MAX_DEVS)
                return 0;
 
        dev = &rte_eventdevs[dev_id];
@@ -496,6 +496,16 @@ struct rte_eventdev *
 rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
                int socket_id);
 
+/**
+ * Destroy the given virtual event device
+ *
+ * @param name
+ *   PMD type name
+ * @return
+ *   - 0 on success, negative on error
+ */
+int
+rte_event_pmd_vdev_uninit(const char *name);
 
 /**
  * Wrapper for use by pci drivers as a .probe function to attach to a event
index f4a39c4..7a6921c 100644 (file)
@@ -32,6 +32,7 @@ DPDK_17.05 {
        rte_event_pmd_allocate;
        rte_event_pmd_release;
        rte_event_pmd_vdev_init;
+       rte_event_pmd_vdev_uninit;
        rte_event_pmd_pci_probe;
        rte_event_pmd_pci_remove;