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;
117 * Find the name of a PCI device.
119 void pci_name_set(struct rte_pci_device *dev);
122 * Add a PCI device to the PCI Bus (append to PCI Device list). This function
123 * also updates the bus references of the PCI Device (and the generic device
124 * object embedded within.
130 void rte_pci_add_device(struct rte_pci_device *pci_dev);
133 * Insert a PCI device in the PCI Bus at a particular location in the device
134 * list. It also updates the PCI Bus reference of the new devices to be
137 * @param exist_pci_dev
138 * Existing PCI device in PCI Bus
140 * PCI device to be added before exist_pci_dev
143 void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
144 struct rte_pci_device *new_pci_dev);
147 * Remove a PCI device from the PCI Bus. This sets to NULL the bus references
148 * in the PCI device object as well as the generic device object.
151 * PCI device to be removed from PCI Bus
154 void rte_pci_remove_device(struct rte_pci_device *pci_device);
157 * Update a pci device object by asking the kernel for the latest information.
159 * This function is private to EAL.
162 * The PCI Bus-Device-Function address to look for
165 * - negative on error.
167 int pci_update_device(const struct rte_pci_addr *addr);
170 * Unbind kernel driver for this device
172 * This function is private to EAL.
175 * 0 on success, negative on error
177 int pci_unbind_kernel_driver(struct rte_pci_device *dev);
180 * Map the PCI resource of a PCI device in virtual memory
182 * This function is private to EAL.
185 * 0 on success, negative on error
187 int pci_uio_map_resource(struct rte_pci_device *dev);
190 * Unmap the PCI resource of a PCI device
192 * This function is private to EAL.
194 void pci_uio_unmap_resource(struct rte_pci_device *dev);
197 * Allocate uio resource for PCI device
199 * This function is private to EAL.
202 * PCI device to allocate uio resource
204 * Pointer to uio resource.
205 * If the function returns 0, the pointer will be filled.
207 * 0 on success, negative on error
209 int pci_uio_alloc_resource(struct rte_pci_device *dev,
210 struct mapped_pci_resource **uio_res);
213 * Free uio resource for PCI device
215 * This function is private to EAL.
218 * PCI device to free uio resource
220 * Pointer to uio resource.
222 void pci_uio_free_resource(struct rte_pci_device *dev,
223 struct mapped_pci_resource *uio_res);
226 * Map device memory to uio resource
228 * This function is private to EAL.
231 * PCI device that has memory information.
233 * Memory resource index of the PCI device.
235 * uio resource that will keep mapping information.
237 * Mapping information index of the uio resource.
239 * 0 on success, negative on error
241 int pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
242 struct mapped_pci_resource *uio_res, int map_idx);
245 * Init tail queues for non-EAL library structures. This is to allow
246 * the rings, mempools, etc. lists to be shared among multiple processes
248 * This function is private to EAL
251 * 0 on success, negative on error
253 int rte_eal_tailqs_init(void);
256 * Init interrupt handling.
258 * This function is private to EAL.
261 * 0 on success, negative on error
263 int rte_eal_intr_init(void);
266 * Init alarm mechanism. This is to allow a callback be called after
269 * This function is private to EAL.
272 * 0 on success, negative on error
274 int rte_eal_alarm_init(void);
277 * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
281 * The module's name which need to be checked
284 * -1 means some error happens(NULL pointer or open failure)
285 * 0 means the module not loaded
286 * 1 means the module loaded
288 int rte_eal_check_module(const char *module_name);
293 * This function is private to the EAL.
295 unsigned eal_cpu_core_id(unsigned lcore_id);
298 * Check if cpu is present.
300 * This function is private to the EAL.
302 int eal_cpu_detected(unsigned lcore_id);
305 * Set TSC frequency from precise value or estimation
307 * This function is private to the EAL.
309 void set_tsc_freq(void);
312 * Get precise TSC frequency from system
314 * This function is private to the EAL.
316 uint64_t get_tsc_freq(void);
319 * Get TSC frequency if the architecture supports.
321 * This function is private to the EAL.
324 * The number of TSC cycles in one second.
325 * Returns zero if the architecture support is not available.
327 uint64_t get_tsc_freq_arch(void);
330 * Prepare physical memory mapping
331 * i.e. hugepages on Linux and
334 * This function is private to the EAL.
336 int rte_eal_hugepage_init(void);
339 * Creates memory mapping in secondary process
340 * i.e. hugepages on Linux and
343 * This function is private to the EAL.
345 int rte_eal_hugepage_attach(void);
348 * Returns true if the system is able to obtain
349 * physical addresses. Return false if using DMA
350 * addresses through an IOMMU.
352 * Drivers based on uio will not load unless physical
353 * addresses are obtainable. It is only possible to get
354 * physical addresses when running as a privileged user.
356 bool rte_eal_using_phys_addrs(void);
359 * Find a bus capable of identifying a device.
362 * A device identifier (PCI address, virtual PMD name, ...).
365 * A valid bus handle if found.
366 * NULL if no bus is able to parse this device.
368 struct rte_bus *rte_bus_find_by_device_name(const char *str);
370 #endif /* _EAL_PRIVATE_H_ */