bus/fslmc: rename cinh read functions used for ls1088
[dpdk.git] / drivers / bus / pci / private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 6WIND S.A.
3  */
4
5 #ifndef _PCI_PRIVATE_H_
6 #define _PCI_PRIVATE_H_
7
8 #include <stdbool.h>
9 #include <stdio.h>
10 #include <rte_pci.h>
11 #include <rte_bus_pci.h>
12
13 extern struct rte_pci_bus rte_pci_bus;
14
15 struct rte_pci_driver;
16 struct rte_pci_device;
17
18 extern struct rte_pci_bus rte_pci_bus;
19
20 /**
21  * Scan the content of the PCI bus, and the devices in the devices
22  * list
23  *
24  * @return
25  *  0 on success, negative on error
26  */
27 int rte_pci_scan(void);
28
29 /**
30  * Find the name of a PCI device.
31  */
32 void
33 pci_name_set(struct rte_pci_device *dev);
34
35 /**
36  * Validate whether a device with given PCI address should be ignored or not.
37  *
38  * @param pci_addr
39  *      PCI address of device to be validated
40  * @return
41  *      true: if device is to be ignored,
42  *      false: if device is to be scanned,
43  */
44 bool rte_pci_ignore_device(const struct rte_pci_addr *pci_addr);
45
46 /**
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.
50  *
51  * @param pci_dev
52  *      PCI device to add
53  * @return void
54  */
55 void rte_pci_add_device(struct rte_pci_device *pci_dev);
56
57 /**
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
60  * inserted.
61  *
62  * @param exist_pci_dev
63  *      Existing PCI device in PCI Bus
64  * @param new_pci_dev
65  *      PCI device to be added before exist_pci_dev
66  * @return void
67  */
68 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
69                 struct rte_pci_device *new_pci_dev);
70
71 /**
72  * Update a pci device object by asking the kernel for the latest information.
73  *
74  * This function is private to EAL.
75  *
76  * @param addr
77  *      The PCI Bus-Device-Function address to look for
78  * @return
79  *   - 0 on success.
80  *   - negative on error.
81  */
82 int pci_update_device(const struct rte_pci_addr *addr);
83
84 /**
85  * Map the PCI resource of a PCI device in virtual memory
86  *
87  * This function is private to EAL.
88  *
89  * @return
90  *   0 on success, negative on error
91  */
92 int pci_uio_map_resource(struct rte_pci_device *dev);
93
94 /**
95  * Unmap the PCI resource of a PCI device
96  *
97  * This function is private to EAL.
98  */
99 void pci_uio_unmap_resource(struct rte_pci_device *dev);
100
101 /**
102  * Allocate uio resource for PCI device
103  *
104  * This function is private to EAL.
105  *
106  * @param dev
107  *   PCI device to allocate uio resource
108  * @param uio_res
109  *   Pointer to uio resource.
110  *   If the function returns 0, the pointer will be filled.
111  * @return
112  *   0 on success, negative on error
113  */
114 int pci_uio_alloc_resource(struct rte_pci_device *dev,
115                 struct mapped_pci_resource **uio_res);
116
117 /**
118  * Free uio resource for PCI device
119  *
120  * This function is private to EAL.
121  *
122  * @param dev
123  *   PCI device to free uio resource
124  * @param uio_res
125  *   Pointer to uio resource.
126  */
127 void pci_uio_free_resource(struct rte_pci_device *dev,
128                 struct mapped_pci_resource *uio_res);
129
130 /**
131  * Remap the PCI resource of a PCI device in anonymous virtual memory.
132  *
133  * @param dev
134  *   Point to the struct rte pci device.
135  * @return
136  *   - On success, zero.
137  *   - On failure, a negative value.
138  */
139 int
140 pci_uio_remap_resource(struct rte_pci_device *dev);
141
142 /**
143  * Map device memory to uio resource
144  *
145  * This function is private to EAL.
146  *
147  * @param dev
148  *   PCI device that has memory information.
149  * @param res_idx
150  *   Memory resource index of the PCI device.
151  * @param uio_res
152  *  uio resource that will keep mapping information.
153  * @param map_idx
154  *   Mapping information index of the uio resource.
155  * @return
156  *   0 on success, negative on error
157  */
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);
160
161 /*
162  * Match the PCI Driver and Device using the ID Table
163  *
164  * @param pci_drv
165  *      PCI driver from which ID table would be extracted
166  * @param pci_dev
167  *      PCI device to match against the driver
168  * @return
169  *      1 for successful match
170  *      0 for unsuccessful match
171  */
172 int
173 rte_pci_match(const struct rte_pci_driver *pci_drv,
174               const struct rte_pci_device *pci_dev);
175
176 /**
177  * OS specific callbacks for rte_pci_get_iommu_class
178  *
179  */
180 bool
181 pci_device_iommu_support_va(const struct rte_pci_device *dev);
182
183 enum rte_iova_mode
184 pci_device_iova_mode(const struct rte_pci_driver *pci_drv,
185                      const struct rte_pci_device *pci_dev);
186
187 /**
188  * Get iommu class of PCI devices on the bus.
189  * And return their preferred iova mapping mode.
190  *
191  * @return
192  *   - enum rte_iova_mode.
193  */
194 enum rte_iova_mode
195 rte_pci_get_iommu_class(void);
196
197 /*
198  * Iterate over internal devices,
199  * matching any device against the provided
200  * string.
201  *
202  * @param start
203  *   Iteration starting point.
204  *
205  * @param str
206  *   Device string to match against.
207  *
208  * @param it
209  *   (unused) iterator structure.
210  *
211  * @return
212  *   A pointer to the next matching device if any.
213  *   NULL otherwise.
214  */
215 void *
216 rte_pci_dev_iterate(const void *start,
217                     const char *str,
218                     const struct rte_dev_iterator *it);
219
220 #endif /* _PCI_PRIVATE_H_ */