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 */
33 rte_cpuset_t cpuset; /**< cpu set which the lcore affinity to */
36 extern struct lcore_config lcore_config[RTE_MAX_LCORE];
39 * The global RTE configuration structure.
42 uint32_t master_lcore; /**< Id of the master lcore */
43 uint32_t lcore_count; /**< Number of available logical cores. */
44 uint32_t numa_node_count; /**< Number of detected NUMA nodes. */
45 uint32_t numa_nodes[RTE_MAX_NUMA_NODES]; /**< List of detected NUMA nodes. */
46 uint32_t service_lcore_count;/**< Number of available service cores. */
47 enum rte_lcore_role_t lcore_role[RTE_MAX_LCORE]; /**< State of cores. */
49 /** Primary or secondary configuration */
50 enum rte_proc_type_t process_type;
52 /** PA or VA mapping mode */
53 enum rte_iova_mode iova_mode;
56 * Pointer to memory configuration, which may be shared across multiple
59 struct rte_mem_config *mem_config;
63 * Get the global configuration structure.
66 * A pointer to the global configuration structure.
68 struct rte_config *rte_eal_get_configuration(void);
71 * Initialize the memzone subsystem (private to eal).
77 int rte_eal_memzone_init(void);
80 * Common log initialization function (private to eal). Determines
81 * where log data is written when no call to rte_openlog_stream is
85 * The default log stream to be used.
90 void eal_log_set_default(FILE *default_log);
93 * Fill configuration with number of physical and logical processors
95 * This function is private to EAL.
97 * Parse /proc/cpuinfo to get the number of physical and logical
98 * processors on the machine.
101 * 0 on success, negative on error
103 int rte_eal_cpu_init(void);
106 * Create memseg lists
108 * This function is private to EAL.
110 * Preallocate virtual memory.
113 * 0 on success, negative on error
115 int rte_eal_memseg_init(void);
120 * This function is private to EAL.
122 * Fill configuration structure with these infos, and return 0 on success.
125 * 0 on success, negative on error
127 int rte_eal_memory_init(void);
132 * This function is private to EAL.
134 * Mmap memory areas used by HPET (high precision event timer) that will
135 * provide our time reference, and configure the TSC frequency also for it
136 * to be used as a reference.
139 * 0 on success, negative on error
141 int rte_eal_timer_init(void);
144 * Init the default log stream
146 * This function is private to EAL.
149 * 0 on success, negative on error
151 int rte_eal_log_init(const char *id, int facility);
154 * Save the log regexp for later
156 int rte_log_save_regexp(const char *type, int priority);
157 int rte_log_save_pattern(const char *pattern, int priority);
160 * Init tail queues for non-EAL library structures. This is to allow
161 * the rings, mempools, etc. lists to be shared among multiple processes
163 * This function is private to EAL
166 * 0 on success, negative on error
168 int rte_eal_tailqs_init(void);
171 * Init interrupt handling.
173 * This function is private to EAL.
176 * 0 on success, negative on error
178 int rte_eal_intr_init(void);
181 * Init alarm mechanism. This is to allow a callback be called after
184 * This function is private to EAL.
187 * 0 on success, negative on error
189 int rte_eal_alarm_init(void);
192 * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
196 * The module's name which need to be checked
199 * -1 means some error happens(NULL pointer or open failure)
200 * 0 means the module not loaded
201 * 1 means the module loaded
203 int rte_eal_check_module(const char *module_name);
206 * Get virtual area of specified size from the OS.
208 * This function is private to the EAL.
210 * @param requested_addr
211 * Address where to request address space.
213 * Size of requested area.
215 * Page size on which to align requested virtual area.
217 * EAL_VIRTUAL_AREA_* flags.
219 * Extra flags passed directly to mmap().
222 * Virtual area address if successful.
223 * NULL if unsuccessful.
226 #define EAL_VIRTUAL_AREA_ADDR_IS_HINT (1 << 0)
227 /**< don't fail if cannot get exact requested address. */
228 #define EAL_VIRTUAL_AREA_ALLOW_SHRINK (1 << 1)
229 /**< try getting smaller sized (decrement by page size) virtual areas if cannot
230 * get area of requested size.
232 #define EAL_VIRTUAL_AREA_UNMAP (1 << 2)
233 /**< immediately unmap reserved virtual area. */
235 eal_get_virtual_area(void *requested_addr, size_t *size,
236 size_t page_sz, int flags, int mmap_flags);
241 * This function is private to the EAL.
243 unsigned eal_cpu_core_id(unsigned lcore_id);
246 * Check if cpu is present.
248 * This function is private to the EAL.
250 int eal_cpu_detected(unsigned lcore_id);
253 * Set TSC frequency from precise value or estimation
255 * This function is private to the EAL.
257 void set_tsc_freq(void);
260 * Get precise TSC frequency from system
262 * This function is private to the EAL.
264 uint64_t get_tsc_freq(void);
267 * Get TSC frequency if the architecture supports.
269 * This function is private to the EAL.
272 * The number of TSC cycles in one second.
273 * Returns zero if the architecture support is not available.
275 uint64_t get_tsc_freq_arch(void);
278 * Prepare physical memory mapping
279 * i.e. hugepages on Linux and
282 * This function is private to the EAL.
284 int rte_eal_hugepage_init(void);
287 * Creates memory mapping in secondary process
288 * i.e. hugepages on Linux and
291 * This function is private to the EAL.
293 int rte_eal_hugepage_attach(void);
296 * Find a bus capable of identifying a device.
299 * A device identifier (PCI address, virtual PMD name, ...).
302 * A valid bus handle if found.
303 * NULL if no bus is able to parse this device.
305 struct rte_bus *rte_bus_find_by_device_name(const char *str);
308 * Create the unix channel for primary/secondary communication.
314 int rte_mp_channel_init(void);
317 * Primary/secondary communication cleanup.
319 void rte_mp_channel_cleanup(void);
323 * Parse a device string and store its information in an
324 * rte_devargs structure.
326 * A device description is split by layers of abstraction of the device:
327 * bus, class and driver. Each layer will offer a set of properties that
328 * can be applied either to configure or recognize a device.
330 * This function will parse those properties and prepare the rte_devargs
331 * to be given to each layers for processing.
333 * Note: if the "data" field of the devargs points to devstr,
334 * then no dynamic allocation is performed and the rte_devargs
335 * can be safely discarded.
337 * Otherwise ``data`` will hold a workable copy of devstr, that will be
338 * used by layers descriptors within rte_devargs. In this case,
339 * any rte_devargs should be cleaned-up before being freed.
342 * rte_devargs structure to fill.
349 * Negative errno values on error (rte_errno is set).
352 rte_devargs_layers_parse(struct rte_devargs *devargs,
356 * probe a device at local process.
359 * Device arguments including bus, class and driver properties.
361 * new device be probed as output.
363 * 0 on success, negative on error.
365 int local_dev_probe(const char *devargs, struct rte_device **new_dev);
368 * Hotplug remove a given device from a specific bus at local process.
371 * Data structure of the device to remove.
373 * 0 on success, negative on error.
375 int local_dev_remove(struct rte_device *dev);
378 * Iterate over all buses to find the corresponding bus to handle the sigbus
380 * @param failure_addr
381 * Pointer of the fault address of the sigbus error.
384 * 0 success to handle the sigbus.
385 * -1 failed to handle the sigbus
386 * 1 no bus can handler the sigbus
388 int rte_bus_sigbus_handler(const void *failure_addr);
392 * Register the sigbus handler.
395 * - On success, zero.
396 * - On failure, a negative value.
399 dev_sigbus_handler_register(void);
403 * Unregister the sigbus handler.
406 * - On success, zero.
407 * - On failure, a negative value.
410 dev_sigbus_handler_unregister(void);
413 * Check if the option is registered.
416 * The option to be parsed.
424 rte_option_parse(const char *opt);
427 * Iterate through the registered options and execute the associated
428 * callback if enabled.
431 rte_option_init(void);
434 * Iterate through the registered options and show the associated
438 rte_option_usage(void);
441 * Get OS-specific EAL mapping base address.
444 eal_get_baseaddr(void);
446 #endif /* _EAL_PRIVATE_H_ */