34 #ifndef _RTE_ETHDEV_PCI_H_
35 #define _RTE_ETHDEV_PCI_H_
50 rte_eth_copy_pci_info(
struct rte_eth_dev *eth_dev,
53 if ((eth_dev == NULL) || (pci_dev == NULL)) {
54 RTE_PMD_DEBUG_TRACE(
"NULL pointer eth_dev=%p pci_dev=%p\n",
61 eth_dev->data->dev_flags = 0;
67 eth_dev->data->kdrv = pci_dev->
kdrv;
85 static inline struct rte_eth_dev *
86 rte_eth_dev_pci_allocate(
struct rte_pci_device *dev,
size_t private_data_size)
88 struct rte_eth_dev *eth_dev;
97 eth_dev = rte_eth_dev_allocate(name);
101 if (private_data_size) {
103 private_data_size, RTE_CACHE_LINE_SIZE,
105 if (!eth_dev->data->dev_private) {
106 rte_eth_dev_release_port(eth_dev);
111 eth_dev = rte_eth_dev_attach_secondary(name);
116 eth_dev->device = &dev->
device;
117 rte_eth_copy_pci_info(eth_dev, dev);
122 rte_eth_dev_pci_release(
struct rte_eth_dev *eth_dev)
125 rte_eth_dev_release_port(eth_dev);
128 rte_free(eth_dev->data->dev_private);
130 eth_dev->data->dev_private = NULL;
136 eth_dev->data->name[0] =
'\0';
138 eth_dev->device = NULL;
139 eth_dev->intr_handle = NULL;
142 typedef int (*eth_dev_pci_callback_t)(
struct rte_eth_dev *eth_dev);
151 size_t private_data_size, eth_dev_pci_callback_t dev_init)
153 struct rte_eth_dev *eth_dev;
156 eth_dev = rte_eth_dev_pci_allocate(pci_dev, private_data_size);
160 RTE_FUNC_PTR_OR_ERR_RET(*dev_init, -EINVAL);
161 ret = dev_init(eth_dev);
163 rte_eth_dev_pci_release(eth_dev);
175 eth_dev_pci_callback_t dev_uninit)
177 struct rte_eth_dev *eth_dev;
180 eth_dev = rte_eth_dev_allocated(pci_dev->
device.
name);
185 ret = dev_uninit(eth_dev);
190 rte_eth_dev_pci_release(eth_dev);