1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 6WIND S.A.
5 #ifndef _PCI_PRIVATE_H_
6 #define _PCI_PRIVATE_H_
11 #include <rte_bus_pci.h>
13 struct rte_pci_driver;
14 struct rte_pci_device;
27 * Scan the content of the PCI bus, and the devices in the devices
31 * 0 on success, negative on error
33 int rte_pci_scan(void);
36 * Probe the single PCI device.
38 * Scan the content of the PCI bus, and find the pci device specified by pci
39 * address, then call the probe() function for registered driver that has a
40 * matching entry in its id_table for discovered device.
43 * The PCI Bus-Device-Function address to probe.
46 * - Negative on error.
48 int rte_pci_probe_one(const struct rte_pci_addr *addr);
51 * Close the single PCI device.
53 * Scan the content of the PCI bus, and find the pci device specified by pci
54 * address, then call the remove() function for registered driver that has a
55 * matching entry in its id_table for discovered device.
58 * The PCI Bus-Device-Function address to close.
61 * - Negative on error.
63 int rte_pci_detach(const struct rte_pci_addr *addr);
66 * Find the name of a PCI device.
69 pci_name_set(struct rte_pci_device *dev);
72 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
73 * also updates the bus references of the PCI Device (and the generic device
74 * object embedded within.
80 void rte_pci_add_device(struct rte_pci_device *pci_dev);
83 * Insert a PCI device in the PCI Bus at a particular location in the device
84 * list. It also updates the PCI Bus reference of the new devices to be
87 * @param exist_pci_dev
88 * Existing PCI device in PCI Bus
90 * PCI device to be added before exist_pci_dev
93 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
94 struct rte_pci_device *new_pci_dev);
97 * Remove a PCI device from the PCI Bus. This sets to NULL the bus references
98 * in the PCI device object as well as the generic device object.
101 * PCI device to be removed from PCI Bus
104 void rte_pci_remove_device(struct rte_pci_device *pci_device);
107 * Update a pci device object by asking the kernel for the latest information.
109 * This function is private to EAL.
112 * The PCI Bus-Device-Function address to look for
115 * - negative on error.
117 int pci_update_device(const struct rte_pci_addr *addr);
120 * Unbind kernel driver for this device
122 * This function is private to EAL.
125 * 0 on success, negative on error
127 int pci_unbind_kernel_driver(struct rte_pci_device *dev);
130 * Map the PCI resource of a PCI device in virtual memory
132 * This function is private to EAL.
135 * 0 on success, negative on error
137 int pci_uio_map_resource(struct rte_pci_device *dev);
140 * Unmap the PCI resource of a PCI device
142 * This function is private to EAL.
144 void pci_uio_unmap_resource(struct rte_pci_device *dev);
147 * Allocate uio resource for PCI device
149 * This function is private to EAL.
152 * PCI device to allocate uio resource
154 * Pointer to uio resource.
155 * If the function returns 0, the pointer will be filled.
157 * 0 on success, negative on error
159 int pci_uio_alloc_resource(struct rte_pci_device *dev,
160 struct mapped_pci_resource **uio_res);
163 * Free uio resource for PCI device
165 * This function is private to EAL.
168 * PCI device to free uio resource
170 * Pointer to uio resource.
172 void pci_uio_free_resource(struct rte_pci_device *dev,
173 struct mapped_pci_resource *uio_res);
176 * Map device memory to uio resource
178 * This function is private to EAL.
181 * PCI device that has memory information.
183 * Memory resource index of the PCI device.
185 * uio resource that will keep mapping information.
187 * Mapping information index of the uio resource.
189 * 0 on success, negative on error
191 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
192 struct mapped_pci_resource *uio_res, int map_idx);
195 * Match the PCI Driver and Device using the ID Table
198 * PCI driver from which ID table would be extracted
200 * PCI device to match against the driver
202 * 1 for successful match
203 * 0 for unsuccessful match
206 rte_pci_match(const struct rte_pci_driver *pci_drv,
207 const struct rte_pci_device *pci_dev);
210 * Get iommu class of PCI devices on the bus.
211 * And return their preferred iova mapping mode.
214 * - enum rte_iova_mode.
217 rte_pci_get_iommu_class(void);
219 #endif /* _PCI_PRIVATE_H_ */