4 * Copyright(c) 2017 6WIND. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of 6WIND nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _PCI_PRIVATE_H_
35 #define _PCI_PRIVATE_H_
40 #include <rte_bus_pci.h>
42 struct rte_pci_driver;
43 struct rte_pci_device;
56 * Scan the content of the PCI bus, and the devices in the devices
60 * 0 on success, negative on error
62 int rte_pci_scan(void);
65 * Probe the single PCI device.
67 * Scan the content of the PCI bus, and find the pci device specified by pci
68 * address, then call the probe() function for registered driver that has a
69 * matching entry in its id_table for discovered device.
72 * The PCI Bus-Device-Function address to probe.
75 * - Negative on error.
77 int rte_pci_probe_one(const struct rte_pci_addr *addr);
80 * Close the single PCI device.
82 * Scan the content of the PCI bus, and find the pci device specified by pci
83 * address, then call the remove() function for registered driver that has a
84 * matching entry in its id_table for discovered device.
87 * The PCI Bus-Device-Function address to close.
90 * - Negative on error.
92 int rte_pci_detach(const struct rte_pci_addr *addr);
95 * Find the name of a PCI device.
98 pci_name_set(struct rte_pci_device *dev);
101 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
102 * also updates the bus references of the PCI Device (and the generic device
103 * object embedded within.
109 void rte_pci_add_device(struct rte_pci_device *pci_dev);
112 * Insert a PCI device in the PCI Bus at a particular location in the device
113 * list. It also updates the PCI Bus reference of the new devices to be
116 * @param exist_pci_dev
117 * Existing PCI device in PCI Bus
119 * PCI device to be added before exist_pci_dev
122 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
123 struct rte_pci_device *new_pci_dev);
126 * Remove a PCI device from the PCI Bus. This sets to NULL the bus references
127 * in the PCI device object as well as the generic device object.
130 * PCI device to be removed from PCI Bus
133 void rte_pci_remove_device(struct rte_pci_device *pci_device);
136 * Update a pci device object by asking the kernel for the latest information.
138 * This function is private to EAL.
141 * The PCI Bus-Device-Function address to look for
144 * - negative on error.
146 int pci_update_device(const struct rte_pci_addr *addr);
149 * Unbind kernel driver for this device
151 * This function is private to EAL.
154 * 0 on success, negative on error
156 int pci_unbind_kernel_driver(struct rte_pci_device *dev);
159 * Map the PCI resource of a PCI device in virtual memory
161 * This function is private to EAL.
164 * 0 on success, negative on error
166 int pci_uio_map_resource(struct rte_pci_device *dev);
169 * Unmap the PCI resource of a PCI device
171 * This function is private to EAL.
173 void pci_uio_unmap_resource(struct rte_pci_device *dev);
176 * Allocate uio resource for PCI device
178 * This function is private to EAL.
181 * PCI device to allocate uio resource
183 * Pointer to uio resource.
184 * If the function returns 0, the pointer will be filled.
186 * 0 on success, negative on error
188 int pci_uio_alloc_resource(struct rte_pci_device *dev,
189 struct mapped_pci_resource **uio_res);
192 * Free uio resource for PCI device
194 * This function is private to EAL.
197 * PCI device to free uio resource
199 * Pointer to uio resource.
201 void pci_uio_free_resource(struct rte_pci_device *dev,
202 struct mapped_pci_resource *uio_res);
205 * Map device memory to uio resource
207 * This function is private to EAL.
210 * PCI device that has memory information.
212 * Memory resource index of the PCI device.
214 * uio resource that will keep mapping information.
216 * Mapping information index of the uio resource.
218 * 0 on success, negative on error
220 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
221 struct mapped_pci_resource *uio_res, int map_idx);
224 * Match the PCI Driver and Device using the ID Table
227 * PCI driver from which ID table would be extracted
229 * PCI device to match against the driver
231 * 1 for successful match
232 * 0 for unsuccessful match
235 rte_pci_match(const struct rte_pci_driver *pci_drv,
236 const struct rte_pci_device *pci_dev);
239 * Get iommu class of PCI devices on the bus.
240 * And return their preferred iova mapping mode.
243 * - enum rte_iova_mode.
246 rte_pci_get_iommu_class(void);
248 #endif /* _PCI_PRIVATE_H_ */