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;
18 extern struct rte_pci_bus rte_pci_bus;
21 * Scan the content of the PCI bus, and the devices in the devices
25 * 0 on success, negative on error
27 int rte_pci_scan(void);
30 * Find the name of a PCI device.
33 pci_name_set(struct rte_pci_device *dev);
36 * Validate whether a device with given PCI address should be ignored or not.
39 * PCI address of device to be validated
41 * true: if device is to be ignored,
42 * false: if device is to be scanned,
44 bool rte_pci_ignore_device(const struct rte_pci_addr *pci_addr);
47 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
48 * also updates the bus references of the PCI Device (and the generic device
49 * object embedded within.
55 void rte_pci_add_device(struct rte_pci_device *pci_dev);
58 * Insert a PCI device in the PCI Bus at a particular location in the device
59 * list. It also updates the PCI Bus reference of the new devices to be
62 * @param exist_pci_dev
63 * Existing PCI device in PCI Bus
65 * PCI device to be added before exist_pci_dev
68 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
69 struct rte_pci_device *new_pci_dev);
72 * Update a pci device object by asking the kernel for the latest information.
74 * This function is private to EAL.
77 * The PCI Bus-Device-Function address to look for
80 * - negative on error.
82 int pci_update_device(const struct rte_pci_addr *addr);
85 * Map the PCI resource of a PCI device in virtual memory
87 * This function is private to EAL.
90 * 0 on success, negative on error
92 int pci_uio_map_resource(struct rte_pci_device *dev);
95 * Unmap the PCI resource of a PCI device
97 * This function is private to EAL.
99 void pci_uio_unmap_resource(struct rte_pci_device *dev);
102 * Allocate uio resource for PCI device
104 * This function is private to EAL.
107 * PCI device to allocate uio resource
109 * Pointer to uio resource.
110 * If the function returns 0, the pointer will be filled.
112 * 0 on success, negative on error
114 int pci_uio_alloc_resource(struct rte_pci_device *dev,
115 struct mapped_pci_resource **uio_res);
118 * Free uio resource for PCI device
120 * This function is private to EAL.
123 * PCI device to free uio resource
125 * Pointer to uio resource.
127 void pci_uio_free_resource(struct rte_pci_device *dev,
128 struct mapped_pci_resource *uio_res);
131 * Remap the PCI resource of a PCI device in anonymous virtual memory.
134 * Point to the struct rte pci device.
136 * - On success, zero.
137 * - On failure, a negative value.
140 pci_uio_remap_resource(struct rte_pci_device *dev);
143 * Map device memory to uio resource
145 * This function is private to EAL.
148 * PCI device that has memory information.
150 * Memory resource index of the PCI device.
152 * uio resource that will keep mapping information.
154 * Mapping information index of the uio resource.
156 * 0 on success, negative on error
158 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
159 struct mapped_pci_resource *uio_res, int map_idx);
162 * Match the PCI Driver and Device using the ID Table
165 * PCI driver from which ID table would be extracted
167 * PCI device to match against the driver
169 * 1 for successful match
170 * 0 for unsuccessful match
173 rte_pci_match(const struct rte_pci_driver *pci_drv,
174 const struct rte_pci_device *pci_dev);
177 * OS specific callbacks for rte_pci_get_iommu_class
181 pci_device_iommu_support_va(const struct rte_pci_device *dev);
184 pci_device_iova_mode(const struct rte_pci_driver *pci_drv,
185 const struct rte_pci_device *pci_dev);
188 * Get iommu class of PCI devices on the bus.
189 * And return their preferred iova mapping mode.
192 * - enum rte_iova_mode.
195 rte_pci_get_iommu_class(void);
198 * Iterate over internal devices,
199 * matching any device against the provided
203 * Iteration starting point.
206 * Device string to match against.
209 * (unused) iterator structure.
212 * A pointer to the next matching device if any.
216 rte_pci_dev_iterate(const void *start,
218 const struct rte_dev_iterator *it);
220 #endif /* _PCI_PRIVATE_H_ */