4 * Copyright(c) 2010-2014 Intel Corporation. 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 Intel Corporation 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 _EAL_PRIVATE_H_
35 #define _EAL_PRIVATE_H_
43 * Initialize the memzone subsystem (private to eal).
49 int rte_eal_memzone_init(void);
52 * Common log initialization function (private to eal). Determines
53 * where log data is written when no call to rte_openlog_stream is
57 * The default log stream to be used.
62 void eal_log_set_default(FILE *default_log);
65 * Fill configuration with number of physical and logical processors
67 * This function is private to EAL.
69 * Parse /proc/cpuinfo to get the number of physical and logical
70 * processors on the machine.
73 * 0 on success, negative on error
75 int rte_eal_cpu_init(void);
80 * This function is private to EAL.
82 * Fill configuration structure with these infos, and return 0 on success.
85 * 0 on success, negative on error
87 int rte_eal_memory_init(void);
92 * This function is private to EAL.
94 * Mmap memory areas used by HPET (high precision event timer) that will
95 * provide our time reference, and configure the TSC frequency also for it
96 * to be used as a reference.
99 * 0 on success, negative on error
101 int rte_eal_timer_init(void);
104 * Init the default log stream
106 * This function is private to EAL.
109 * 0 on success, negative on error
111 int rte_eal_log_init(const char *id, int facility);
113 struct rte_pci_driver;
114 struct rte_pci_device;
127 * Scan the content of the PCI bus, and the devices in the devices
131 * 0 on success, negative on error
133 int rte_pci_scan(void);
136 * Probe the single PCI device.
138 * Scan the content of the PCI bus, and find the pci device specified by pci
139 * address, then call the probe() function for registered driver that has a
140 * matching entry in its id_table for discovered device.
143 * The PCI Bus-Device-Function address to probe.
146 * - Negative on error.
148 int rte_pci_probe_one(const struct rte_pci_addr *addr);
151 * Close the single PCI device.
153 * Scan the content of the PCI bus, and find the pci device specified by pci
154 * address, then call the remove() function for registered driver that has a
155 * matching entry in its id_table for discovered device.
158 * The PCI Bus-Device-Function address to close.
161 * - Negative on error.
163 int rte_pci_detach(const struct rte_pci_addr *addr);
166 * Find the name of a PCI device.
168 void pci_name_set(struct rte_pci_device *dev);
171 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
172 * also updates the bus references of the PCI Device (and the generic device
173 * object embedded within.
179 void rte_pci_add_device(struct rte_pci_device *pci_dev);
182 * Insert a PCI device in the PCI Bus at a particular location in the device
183 * list. It also updates the PCI Bus reference of the new devices to be
186 * @param exist_pci_dev
187 * Existing PCI device in PCI Bus
189 * PCI device to be added before exist_pci_dev
192 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
193 struct rte_pci_device *new_pci_dev);
196 * Remove a PCI device from the PCI Bus. This sets to NULL the bus references
197 * in the PCI device object as well as the generic device object.
200 * PCI device to be removed from PCI Bus
203 void rte_pci_remove_device(struct rte_pci_device *pci_device);
206 * Update a pci device object by asking the kernel for the latest information.
208 * This function is private to EAL.
211 * The PCI Bus-Device-Function address to look for
214 * - negative on error.
216 int pci_update_device(const struct rte_pci_addr *addr);
219 * Unbind kernel driver for this device
221 * This function is private to EAL.
224 * 0 on success, negative on error
226 int pci_unbind_kernel_driver(struct rte_pci_device *dev);
229 * Map the PCI resource of a PCI device in virtual memory
231 * This function is private to EAL.
234 * 0 on success, negative on error
236 int pci_uio_map_resource(struct rte_pci_device *dev);
239 * Unmap the PCI resource of a PCI device
241 * This function is private to EAL.
243 void pci_uio_unmap_resource(struct rte_pci_device *dev);
246 * Allocate uio resource for PCI device
248 * This function is private to EAL.
251 * PCI device to allocate uio resource
253 * Pointer to uio resource.
254 * If the function returns 0, the pointer will be filled.
256 * 0 on success, negative on error
258 int pci_uio_alloc_resource(struct rte_pci_device *dev,
259 struct mapped_pci_resource **uio_res);
262 * Free uio resource for PCI device
264 * This function is private to EAL.
267 * PCI device to free uio resource
269 * Pointer to uio resource.
271 void pci_uio_free_resource(struct rte_pci_device *dev,
272 struct mapped_pci_resource *uio_res);
275 * Map device memory to uio resource
277 * This function is private to EAL.
280 * PCI device that has memory information.
282 * Memory resource index of the PCI device.
284 * uio resource that will keep mapping information.
286 * Mapping information index of the uio resource.
288 * 0 on success, negative on error
290 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
291 struct mapped_pci_resource *uio_res, int map_idx);
294 * Match the PCI Driver and Device using the ID Table
297 * PCI driver from which ID table would be extracted
299 * PCI device to match against the driver
301 * 1 for successful match
302 * 0 for unsuccessful match
305 rte_pci_match(const struct rte_pci_driver *pci_drv,
306 const struct rte_pci_device *pci_dev);
309 * Get iommu class of PCI devices on the bus.
310 * And return their preferred iova mapping mode.
313 * - enum rte_iova_mode.
316 rte_pci_get_iommu_class(void);
319 * Init tail queues for non-EAL library structures. This is to allow
320 * the rings, mempools, etc. lists to be shared among multiple processes
322 * This function is private to EAL
325 * 0 on success, negative on error
327 int rte_eal_tailqs_init(void);
330 * Init interrupt handling.
332 * This function is private to EAL.
335 * 0 on success, negative on error
337 int rte_eal_intr_init(void);
340 * Init alarm mechanism. This is to allow a callback be called after
343 * This function is private to EAL.
346 * 0 on success, negative on error
348 int rte_eal_alarm_init(void);
351 * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
355 * The module's name which need to be checked
358 * -1 means some error happens(NULL pointer or open failure)
359 * 0 means the module not loaded
360 * 1 means the module loaded
362 int rte_eal_check_module(const char *module_name);
367 * This function is private to the EAL.
369 unsigned eal_cpu_core_id(unsigned lcore_id);
372 * Check if cpu is present.
374 * This function is private to the EAL.
376 int eal_cpu_detected(unsigned lcore_id);
379 * Set TSC frequency from precise value or estimation
381 * This function is private to the EAL.
383 void set_tsc_freq(void);
386 * Get precise TSC frequency from system
388 * This function is private to the EAL.
390 uint64_t get_tsc_freq(void);
393 * Get TSC frequency if the architecture supports.
395 * This function is private to the EAL.
398 * The number of TSC cycles in one second.
399 * Returns zero if the architecture support is not available.
401 uint64_t get_tsc_freq_arch(void);
404 * Prepare physical memory mapping
405 * i.e. hugepages on Linux and
408 * This function is private to the EAL.
410 int rte_eal_hugepage_init(void);
413 * Creates memory mapping in secondary process
414 * i.e. hugepages on Linux and
417 * This function is private to the EAL.
419 int rte_eal_hugepage_attach(void);
422 * Find a bus capable of identifying a device.
425 * A device identifier (PCI address, virtual PMD name, ...).
428 * A valid bus handle if found.
429 * NULL if no bus is able to parse this device.
431 struct rte_bus *rte_bus_find_by_device_name(const char *str);
433 #endif /* _EAL_PRIVATE_H_ */