1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
5 #ifndef _EAL_PRIVATE_H_
6 #define _EAL_PRIVATE_H_
13 #include <rte_lcore.h>
16 * Structure storing internal configuration (per-lcore)
19 pthread_t thread_id; /**< pthread identifier */
20 int pipe_master2slave[2]; /**< communication pipe with master */
21 int pipe_slave2master[2]; /**< communication pipe with master */
23 lcore_function_t * volatile f; /**< function to call */
24 void * volatile arg; /**< argument of function */
25 volatile int ret; /**< return value of function */
27 volatile enum rte_lcore_state_t state; /**< lcore state */
28 unsigned int socket_id; /**< physical socket id for this lcore */
29 unsigned int core_id; /**< core number on socket for this lcore */
30 int core_index; /**< relative index, starting from 0 */
31 uint8_t core_role; /**< role of core eg: OFF, RTE, SERVICE */
32 uint8_t detected; /**< true if lcore was detected */
34 rte_cpuset_t cpuset; /**< cpu set which the lcore affinity to */
37 extern struct lcore_config lcore_config[RTE_MAX_LCORE];
40 * Initialize the memzone subsystem (private to eal).
46 int rte_eal_memzone_init(void);
49 * Common log initialization function (private to eal). Determines
50 * where log data is written when no call to rte_openlog_stream is
54 * The default log stream to be used.
59 void eal_log_set_default(FILE *default_log);
62 * Fill configuration with number of physical and logical processors
64 * This function is private to EAL.
66 * Parse /proc/cpuinfo to get the number of physical and logical
67 * processors on the machine.
70 * 0 on success, negative on error
72 int rte_eal_cpu_init(void);
77 * This function is private to EAL.
79 * Preallocate virtual memory.
82 * 0 on success, negative on error
84 int rte_eal_memseg_init(void);
89 * This function is private to EAL.
91 * Fill configuration structure with these infos, and return 0 on success.
94 * 0 on success, negative on error
96 int rte_eal_memory_init(void);
101 * This function is private to EAL.
103 * Mmap memory areas used by HPET (high precision event timer) that will
104 * provide our time reference, and configure the TSC frequency also for it
105 * to be used as a reference.
108 * 0 on success, negative on error
110 int rte_eal_timer_init(void);
113 * Init the default log stream
115 * This function is private to EAL.
118 * 0 on success, negative on error
120 int rte_eal_log_init(const char *id, int facility);
123 * Save the log regexp for later
125 int rte_log_save_regexp(const char *type, int priority);
126 int rte_log_save_pattern(const char *pattern, int priority);
129 * Init tail queues for non-EAL library structures. This is to allow
130 * the rings, mempools, etc. lists to be shared among multiple processes
132 * This function is private to EAL
135 * 0 on success, negative on error
137 int rte_eal_tailqs_init(void);
140 * Init interrupt handling.
142 * This function is private to EAL.
145 * 0 on success, negative on error
147 int rte_eal_intr_init(void);
150 * Init alarm mechanism. This is to allow a callback be called after
153 * This function is private to EAL.
156 * 0 on success, negative on error
158 int rte_eal_alarm_init(void);
161 * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
165 * The module's name which need to be checked
168 * -1 means some error happens(NULL pointer or open failure)
169 * 0 means the module not loaded
170 * 1 means the module loaded
172 int rte_eal_check_module(const char *module_name);
175 * Get virtual area of specified size from the OS.
177 * This function is private to the EAL.
179 * @param requested_addr
180 * Address where to request address space.
182 * Size of requested area.
184 * Page size on which to align requested virtual area.
186 * EAL_VIRTUAL_AREA_* flags.
188 * Extra flags passed directly to mmap().
191 * Virtual area address if successful.
192 * NULL if unsuccessful.
195 #define EAL_VIRTUAL_AREA_ADDR_IS_HINT (1 << 0)
196 /**< don't fail if cannot get exact requested address. */
197 #define EAL_VIRTUAL_AREA_ALLOW_SHRINK (1 << 1)
198 /**< try getting smaller sized (decrement by page size) virtual areas if cannot
199 * get area of requested size.
201 #define EAL_VIRTUAL_AREA_UNMAP (1 << 2)
202 /**< immediately unmap reserved virtual area. */
204 eal_get_virtual_area(void *requested_addr, size_t *size,
205 size_t page_sz, int flags, int mmap_flags);
210 * This function is private to the EAL.
212 unsigned eal_cpu_core_id(unsigned lcore_id);
215 * Check if cpu is present.
217 * This function is private to the EAL.
219 int eal_cpu_detected(unsigned lcore_id);
222 * Set TSC frequency from precise value or estimation
224 * This function is private to the EAL.
226 void set_tsc_freq(void);
229 * Get precise TSC frequency from system
231 * This function is private to the EAL.
233 uint64_t get_tsc_freq(void);
236 * Get TSC frequency if the architecture supports.
238 * This function is private to the EAL.
241 * The number of TSC cycles in one second.
242 * Returns zero if the architecture support is not available.
244 uint64_t get_tsc_freq_arch(void);
247 * Prepare physical memory mapping
248 * i.e. hugepages on Linux and
251 * This function is private to the EAL.
253 int rte_eal_hugepage_init(void);
256 * Creates memory mapping in secondary process
257 * i.e. hugepages on Linux and
260 * This function is private to the EAL.
262 int rte_eal_hugepage_attach(void);
265 * Find a bus capable of identifying a device.
268 * A device identifier (PCI address, virtual PMD name, ...).
271 * A valid bus handle if found.
272 * NULL if no bus is able to parse this device.
274 struct rte_bus *rte_bus_find_by_device_name(const char *str);
277 * Create the unix channel for primary/secondary communication.
283 int rte_mp_channel_init(void);
286 * Primary/secondary communication cleanup.
288 void rte_mp_channel_cleanup(void);
292 * Parse a device string and store its information in an
293 * rte_devargs structure.
295 * A device description is split by layers of abstraction of the device:
296 * bus, class and driver. Each layer will offer a set of properties that
297 * can be applied either to configure or recognize a device.
299 * This function will parse those properties and prepare the rte_devargs
300 * to be given to each layers for processing.
302 * Note: if the "data" field of the devargs points to devstr,
303 * then no dynamic allocation is performed and the rte_devargs
304 * can be safely discarded.
306 * Otherwise ``data`` will hold a workable copy of devstr, that will be
307 * used by layers descriptors within rte_devargs. In this case,
308 * any rte_devargs should be cleaned-up before being freed.
311 * rte_devargs structure to fill.
318 * Negative errno values on error (rte_errno is set).
321 rte_devargs_layers_parse(struct rte_devargs *devargs,
325 * probe a device at local process.
328 * Device arguments including bus, class and driver properties.
330 * new device be probed as output.
332 * 0 on success, negative on error.
334 int local_dev_probe(const char *devargs, struct rte_device **new_dev);
337 * Hotplug remove a given device from a specific bus at local process.
340 * Data structure of the device to remove.
342 * 0 on success, negative on error.
344 int local_dev_remove(struct rte_device *dev);
347 * Iterate over all buses to find the corresponding bus to handle the sigbus
349 * @param failure_addr
350 * Pointer of the fault address of the sigbus error.
353 * 0 success to handle the sigbus.
354 * -1 failed to handle the sigbus
355 * 1 no bus can handler the sigbus
357 int rte_bus_sigbus_handler(const void *failure_addr);
361 * Register the sigbus handler.
364 * - On success, zero.
365 * - On failure, a negative value.
368 dev_sigbus_handler_register(void);
372 * Unregister the sigbus handler.
375 * - On success, zero.
376 * - On failure, a negative value.
379 dev_sigbus_handler_unregister(void);
382 * Check if the option is registered.
385 * The option to be parsed.
393 rte_option_parse(const char *opt);
396 * Iterate through the registered options and execute the associated
397 * callback if enabled.
400 rte_option_init(void);
403 * Iterate through the registered options and show the associated
407 rte_option_usage(void);
410 * Get OS-specific EAL mapping base address.
413 eal_get_baseaddr(void);
415 #endif /* _EAL_PRIVATE_H_ */