eventdev: support vdev uninit

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>
This commit is contained in:
Jerin Jacob 2017-02-06 10:53:38 +05:30
parent 7b37f6f7ad
commit 8b78c1991d
3 changed files with 51 additions and 5 deletions

View 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;

View 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

View 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;