From: Jerin Jacob Date: Mon, 6 Feb 2017 05:23:38 +0000 (+0530) Subject: eventdev: support vdev uninit X-Git-Tag: spdx-start~3868 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8b78c1991d3088ef30da3cf19c70ed04cb8b5340;p=dpdk.git eventdev: support vdev uninit Added eventdev vdev uninit support to release the resources allocated in eventdev vdev init. Signed-off-by: Jerin Jacob Acked-by: Harry van Haaren --- diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index c7452f0e26..91bd1c9437 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -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; diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h index 82d5e48296..828dfce01a 100644 --- a/lib/librte_eventdev/rte_eventdev_pmd.h +++ b/lib/librte_eventdev/rte_eventdev_pmd.h @@ -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 diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index f4a39c4433..7a6921c28a 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -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;