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 extern struct rte_pci_bus rte_pci_bus;
15 struct rte_pci_driver;
16 struct rte_pci_device;
29 * Scan the content of the PCI bus, and the devices in the devices
33 * 0 on success, negative on error
35 int rte_pci_scan(void);
38 * Find the name of a PCI device.
41 pci_name_set(struct rte_pci_device *dev);
44 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
45 * also updates the bus references of the PCI Device (and the generic device
46 * object embedded within.
52 void rte_pci_add_device(struct rte_pci_device *pci_dev);
55 * Insert a PCI device in the PCI Bus at a particular location in the device
56 * list. It also updates the PCI Bus reference of the new devices to be
59 * @param exist_pci_dev
60 * Existing PCI device in PCI Bus
62 * PCI device to be added before exist_pci_dev
65 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
66 struct rte_pci_device *new_pci_dev);
69 * Update a pci device object by asking the kernel for the latest information.
71 * This function is private to EAL.
74 * The PCI Bus-Device-Function address to look for
77 * - negative on error.
79 int pci_update_device(const struct rte_pci_addr *addr);
82 * Map the PCI resource of a PCI device in virtual memory
84 * This function is private to EAL.
87 * 0 on success, negative on error
89 int pci_uio_map_resource(struct rte_pci_device *dev);
92 * Unmap the PCI resource of a PCI device
94 * This function is private to EAL.
96 void pci_uio_unmap_resource(struct rte_pci_device *dev);
99 * Allocate uio resource for PCI device
101 * This function is private to EAL.
104 * PCI device to allocate uio resource
106 * Pointer to uio resource.
107 * If the function returns 0, the pointer will be filled.
109 * 0 on success, negative on error
111 int pci_uio_alloc_resource(struct rte_pci_device *dev,
112 struct mapped_pci_resource **uio_res);
115 * Free uio resource for PCI device
117 * This function is private to EAL.
120 * PCI device to free uio resource
122 * Pointer to uio resource.
124 void pci_uio_free_resource(struct rte_pci_device *dev,
125 struct mapped_pci_resource *uio_res);
128 * Map device memory to uio resource
130 * This function is private to EAL.
133 * PCI device that has memory information.
135 * Memory resource index of the PCI device.
137 * uio resource that will keep mapping information.
139 * Mapping information index of the uio resource.
141 * 0 on success, negative on error
143 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
144 struct mapped_pci_resource *uio_res, int map_idx);
147 * Match the PCI Driver and Device using the ID Table
150 * PCI driver from which ID table would be extracted
152 * PCI device to match against the driver
154 * 1 for successful match
155 * 0 for unsuccessful match
158 rte_pci_match(const struct rte_pci_driver *pci_drv,
159 const struct rte_pci_device *pci_dev);
162 * Get iommu class of PCI devices on the bus.
163 * And return their preferred iova mapping mode.
166 * - enum rte_iova_mode.
169 rte_pci_get_iommu_class(void);
172 * Iterate over internal devices,
173 * matching any device against the provided
177 * Iteration starting point.
180 * Device string to match against.
183 * (unused) iterator structure.
186 * A pointer to the next matching device if any.
190 rte_pci_dev_iterate(const void *start,
192 const struct rte_dev_iterator *it);
194 #endif /* _PCI_PRIVATE_H_ */