34 #ifndef _RTE_ETHDEV_PCI_H_
35 #define _RTE_ETHDEV_PCI_H_
53 rte_eth_copy_pci_info(
struct rte_eth_dev *eth_dev,
56 if ((eth_dev == NULL) || (pci_dev == NULL)) {
57 RTE_PMD_DEBUG_TRACE(
"NULL pointer eth_dev=%p pci_dev=%p\n",
64 eth_dev->data->dev_flags = 0;
70 eth_dev->data->kdrv = pci_dev->
kdrv;
89 static inline struct rte_eth_dev *
90 rte_eth_dev_pci_allocate(
struct rte_pci_device *dev,
size_t private_data_size)
92 struct rte_eth_dev *eth_dev;
101 eth_dev = rte_eth_dev_allocate(name);
105 if (private_data_size) {
107 private_data_size, RTE_CACHE_LINE_SIZE,
109 if (!eth_dev->data->dev_private) {
110 rte_eth_dev_release_port(eth_dev);
115 eth_dev = rte_eth_dev_attach_secondary(name);
120 eth_dev->device = &dev->
device;
122 rte_eth_copy_pci_info(eth_dev, dev);
127 rte_eth_dev_pci_release(
struct rte_eth_dev *eth_dev)
130 rte_eth_dev_release_port(eth_dev);
133 rte_free(eth_dev->data->dev_private);
135 eth_dev->data->dev_private = NULL;
141 eth_dev->data->name[0] =
'\0';
143 eth_dev->device = NULL;
144 eth_dev->intr_handle = NULL;
147 typedef int (*eth_dev_pci_callback_t)(
struct rte_eth_dev *eth_dev);
156 size_t private_data_size, eth_dev_pci_callback_t dev_init)
158 struct rte_eth_dev *eth_dev;
161 eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size);
165 RTE_FUNC_PTR_OR_ERR_RET(*dev_init, -EINVAL);
166 ret = dev_init(eth_dev);
168 rte_eth_dev_pci_release(eth_dev);
180 eth_dev_pci_callback_t dev_uninit)
182 struct rte_eth_dev *eth_dev;
185 eth_dev = rte_eth_dev_allocated(pci_dev->
device.
name);
190 ret = dev_uninit(eth_dev);
195 rte_eth_dev_pci_release(eth_dev);