-
-struct rte_eventdev *
-rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
- int socket_id)
-{
- struct rte_eventdev *eventdev;
-
- /* Allocate device structure */
- eventdev = rte_event_pmd_allocate(name, socket_id);
- if (eventdev == NULL)
- return NULL;
-
- /* Allocate private device structure */
- if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- eventdev->data->dev_private =
- rte_zmalloc_socket("eventdev device private",
- dev_private_size,
- RTE_CACHE_LINE_SIZE,
- socket_id);
-
- if (eventdev->data->dev_private == NULL)
- rte_panic("Cannot allocate memzone for private device"
- " data");
- }
-
- 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)
-{
- struct rte_eventdev_driver *eventdrv;
- struct rte_eventdev *eventdev;
-
- char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
-
- int retval;
-
- eventdrv = (struct rte_eventdev_driver *)pci_drv;
- if (eventdrv == NULL)
- return -ENODEV;
-
- rte_eal_pci_device_name(&pci_dev->addr, eventdev_name,
- sizeof(eventdev_name));
-
- eventdev = rte_event_pmd_allocate(eventdev_name,
- pci_dev->device.numa_node);
- if (eventdev == NULL)
- return -ENOMEM;
-
- if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- eventdev->data->dev_private =
- rte_zmalloc_socket(
- "eventdev private structure",
- eventdrv->dev_private_size,
- RTE_CACHE_LINE_SIZE,
- rte_socket_id());
-
- if (eventdev->data->dev_private == NULL)
- rte_panic("Cannot allocate memzone for private "
- "device data");
- }
-
- eventdev->dev = &pci_dev->device;
- eventdev->driver = eventdrv;
-
- /* Invoke PMD device initialization function */
- retval = (*eventdrv->eventdev_init)(eventdev);
- if (retval == 0)
- return 0;
-
- RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
- " failed", pci_drv->driver.name,
- (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--;
-
- return -ENXIO;
-}
-
-int
-rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev)
-{
- const struct rte_eventdev_driver *eventdrv;
- struct rte_eventdev *eventdev;
- char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
- int ret;
-
- if (pci_dev == NULL)
- return -EINVAL;
-
- rte_eal_pci_device_name(&pci_dev->addr, eventdev_name,
- sizeof(eventdev_name));
-
- eventdev = rte_event_pmd_get_named_dev(eventdev_name);
- if (eventdev == NULL)
- return -ENODEV;
-
- eventdrv = (const struct rte_eventdev_driver *)pci_dev->driver;
- if (eventdrv == NULL)
- return -ENODEV;
-
- /* Invoke PMD device un-init function */
- if (*eventdrv->eventdev_uninit) {
- ret = (*eventdrv->eventdev_uninit)(eventdev);
- if (ret)
- return ret;
- }
-
- /* Free event device */
- rte_event_pmd_release(eventdev);
-
- eventdev->dev = NULL;
- eventdev->driver = NULL;
-
- return 0;
-}