1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Cavium, Inc
5 #ifndef _RTE_EVENTDEV_PMD_PCI_H_
6 #define _RTE_EVENTDEV_PMD_PCI_H_
9 * RTE Eventdev PCI PMD APIs
12 * These API are from event PCI PMD only and user applications should not call
23 #include <rte_config.h>
25 #include <rte_lcore.h>
27 #include <rte_bus_pci.h>
29 #include "eventdev_pmd.h"
31 typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
35 * Wrapper for use by pci drivers as a .probe function to attach to an event
36 * interface. Same as rte_event_pmd_pci_probe, except caller can specify
41 rte_event_pmd_pci_probe_named(struct rte_pci_driver *pci_drv,
42 struct rte_pci_device *pci_dev,
43 size_t private_data_size,
44 eventdev_pmd_pci_callback_t devinit,
47 struct rte_eventdev *eventdev;
53 eventdev = rte_event_pmd_allocate(name,
54 pci_dev->device.numa_node);
58 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
59 eventdev->data->dev_private =
61 "eventdev private structure",
66 if (eventdev->data->dev_private == NULL)
67 rte_panic("Cannot allocate memzone for private "
71 eventdev->dev = &pci_dev->device;
73 /* Invoke PMD device initialization function */
74 retval = devinit(eventdev);
78 RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
79 " failed", pci_drv->driver.name,
80 (unsigned int) pci_dev->id.vendor_id,
81 (unsigned int) pci_dev->id.device_id);
83 rte_event_pmd_release(eventdev);
90 * Wrapper for use by pci drivers as a .probe function to attach to a event
94 rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
95 struct rte_pci_device *pci_dev,
96 size_t private_data_size,
97 eventdev_pmd_pci_callback_t devinit)
99 char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
101 rte_pci_device_name(&pci_dev->addr, eventdev_name,
102 sizeof(eventdev_name));
104 return rte_event_pmd_pci_probe_named(pci_drv,
113 * Wrapper for use by pci drivers as a .remove function to detach a event
117 rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
118 eventdev_pmd_pci_callback_t devuninit)
120 struct rte_eventdev *eventdev;
121 char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
127 rte_pci_device_name(&pci_dev->addr, eventdev_name,
128 sizeof(eventdev_name));
130 eventdev = rte_event_pmd_get_named_dev(eventdev_name);
131 if (eventdev == NULL)
134 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
135 ret = rte_event_dev_close(eventdev->data->dev_id);
140 /* Invoke PMD device un-init function */
142 ret = devuninit(eventdev);
146 /* Free event device */
147 rte_event_pmd_release(eventdev);
149 eventdev->dev = NULL;
158 #endif /* _RTE_EVENTDEV_PMD_PCI_H_ */