]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/lib/librte_eal/common/eal_private.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / eal_private.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
7c673cae
FG
3 */
4
5#ifndef _EAL_PRIVATE_H_
6#define _EAL_PRIVATE_H_
7
11fdf7f2
TL
8#include <stdbool.h>
9#include <stdint.h>
7c673cae 10#include <stdio.h>
11fdf7f2
TL
11
12#include <rte_dev.h>
7c673cae
FG
13
14/**
15 * Initialize the memzone subsystem (private to eal).
16 *
17 * @return
18 * - 0 on success
19 * - Negative on error
20 */
21int rte_eal_memzone_init(void);
22
23/**
24 * Common log initialization function (private to eal). Determines
25 * where log data is written when no call to rte_openlog_stream is
26 * in effect.
27 *
28 * @param default_log
29 * The default log stream to be used.
30 * @return
31 * - 0 on success
32 * - Negative on error
33 */
34void eal_log_set_default(FILE *default_log);
35
36/**
37 * Fill configuration with number of physical and logical processors
38 *
39 * This function is private to EAL.
40 *
41 * Parse /proc/cpuinfo to get the number of physical and logical
42 * processors on the machine.
43 *
44 * @return
45 * 0 on success, negative on error
46 */
47int rte_eal_cpu_init(void);
48
11fdf7f2
TL
49/**
50 * Create memseg lists
51 *
52 * This function is private to EAL.
53 *
54 * Preallocate virtual memory.
55 *
56 * @return
57 * 0 on success, negative on error
58 */
59int rte_eal_memseg_init(void);
60
7c673cae
FG
61/**
62 * Map memory
63 *
64 * This function is private to EAL.
65 *
66 * Fill configuration structure with these infos, and return 0 on success.
67 *
68 * @return
69 * 0 on success, negative on error
70 */
71int rte_eal_memory_init(void);
72
73/**
74 * Configure timers
75 *
76 * This function is private to EAL.
77 *
78 * Mmap memory areas used by HPET (high precision event timer) that will
79 * provide our time reference, and configure the TSC frequency also for it
80 * to be used as a reference.
81 *
82 * @return
83 * 0 on success, negative on error
84 */
85int rte_eal_timer_init(void);
86
87/**
88 * Init the default log stream
89 *
90 * This function is private to EAL.
91 *
92 * @return
93 * 0 on success, negative on error
94 */
95int rte_eal_log_init(const char *id, int facility);
96
97/**
11fdf7f2 98 * Save the log regexp for later
7c673cae 99 */
11fdf7f2
TL
100int rte_log_save_regexp(const char *type, int priority);
101int rte_log_save_pattern(const char *pattern, int priority);
7c673cae
FG
102
103/**
104 * Init tail queues for non-EAL library structures. This is to allow
105 * the rings, mempools, etc. lists to be shared among multiple processes
106 *
107 * This function is private to EAL
108 *
109 * @return
110 * 0 on success, negative on error
111 */
112int rte_eal_tailqs_init(void);
113
114/**
115 * Init interrupt handling.
116 *
117 * This function is private to EAL.
118 *
119 * @return
120 * 0 on success, negative on error
121 */
122int rte_eal_intr_init(void);
123
124/**
125 * Init alarm mechanism. This is to allow a callback be called after
126 * specific time.
127 *
128 * This function is private to EAL.
129 *
130 * @return
131 * 0 on success, negative on error
132 */
133int rte_eal_alarm_init(void);
134
135/**
136 * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
137 * etc.) loaded.
138 *
139 * @param module_name
140 * The module's name which need to be checked
141 *
142 * @return
143 * -1 means some error happens(NULL pointer or open failure)
144 * 0 means the module not loaded
145 * 1 means the module loaded
146 */
147int rte_eal_check_module(const char *module_name);
148
11fdf7f2
TL
149/**
150 * Get virtual area of specified size from the OS.
151 *
152 * This function is private to the EAL.
153 *
154 * @param requested_addr
155 * Address where to request address space.
156 * @param size
157 * Size of requested area.
158 * @param page_sz
159 * Page size on which to align requested virtual area.
160 * @param flags
161 * EAL_VIRTUAL_AREA_* flags.
162 * @param mmap_flags
163 * Extra flags passed directly to mmap().
164 *
165 * @return
166 * Virtual area address if successful.
167 * NULL if unsuccessful.
168 */
169
170#define EAL_VIRTUAL_AREA_ADDR_IS_HINT (1 << 0)
171/**< don't fail if cannot get exact requested address. */
172#define EAL_VIRTUAL_AREA_ALLOW_SHRINK (1 << 1)
173/**< try getting smaller sized (decrement by page size) virtual areas if cannot
174 * get area of requested size.
175 */
176#define EAL_VIRTUAL_AREA_UNMAP (1 << 2)
177/**< immediately unmap reserved virtual area. */
178void *
179eal_get_virtual_area(void *requested_addr, size_t *size,
180 size_t page_sz, int flags, int mmap_flags);
181
7c673cae
FG
182/**
183 * Get cpu core_id.
184 *
185 * This function is private to the EAL.
186 */
187unsigned eal_cpu_core_id(unsigned lcore_id);
188
189/**
190 * Check if cpu is present.
191 *
192 * This function is private to the EAL.
193 */
194int eal_cpu_detected(unsigned lcore_id);
195
196/**
197 * Set TSC frequency from precise value or estimation
198 *
199 * This function is private to the EAL.
200 */
201void set_tsc_freq(void);
202
203/**
204 * Get precise TSC frequency from system
205 *
206 * This function is private to the EAL.
207 */
208uint64_t get_tsc_freq(void);
209
11fdf7f2
TL
210/**
211 * Get TSC frequency if the architecture supports.
212 *
213 * This function is private to the EAL.
214 *
215 * @return
216 * The number of TSC cycles in one second.
217 * Returns zero if the architecture support is not available.
218 */
219uint64_t get_tsc_freq_arch(void);
220
7c673cae
FG
221/**
222 * Prepare physical memory mapping
223 * i.e. hugepages on Linux and
224 * contigmem on BSD.
225 *
226 * This function is private to the EAL.
227 */
228int rte_eal_hugepage_init(void);
229
230/**
231 * Creates memory mapping in secondary process
232 * i.e. hugepages on Linux and
233 * contigmem on BSD.
234 *
235 * This function is private to the EAL.
236 */
237int rte_eal_hugepage_attach(void);
238
11fdf7f2
TL
239/**
240 * Find a bus capable of identifying a device.
241 *
242 * @param str
243 * A device identifier (PCI address, virtual PMD name, ...).
244 *
245 * @return
246 * A valid bus handle if found.
247 * NULL if no bus is able to parse this device.
248 */
249struct rte_bus *rte_bus_find_by_device_name(const char *str);
250
251/**
252 * Create the unix channel for primary/secondary communication.
253 *
254 * @return
255 * 0 on success;
256 * (<0) on failure.
257 */
11fdf7f2
TL
258int rte_mp_channel_init(void);
259
260/**
9f95a23c 261 * Primary/secondary communication cleanup.
11fdf7f2 262 */
9f95a23c 263void rte_mp_channel_cleanup(void);
11fdf7f2
TL
264
265/**
266 * @internal
267 * Parse a device string and store its information in an
268 * rte_devargs structure.
269 *
270 * A device description is split by layers of abstraction of the device:
271 * bus, class and driver. Each layer will offer a set of properties that
272 * can be applied either to configure or recognize a device.
273 *
274 * This function will parse those properties and prepare the rte_devargs
275 * to be given to each layers for processing.
276 *
277 * Note: if the "data" field of the devargs points to devstr,
278 * then no dynamic allocation is performed and the rte_devargs
279 * can be safely discarded.
280 *
281 * Otherwise ``data`` will hold a workable copy of devstr, that will be
282 * used by layers descriptors within rte_devargs. In this case,
283 * any rte_devargs should be cleaned-up before being freed.
284 *
285 * @param da
286 * rte_devargs structure to fill.
287 *
288 * @param devstr
289 * Device string.
290 *
291 * @return
292 * 0 on success.
293 * Negative errno values on error (rte_errno is set).
294 */
295int
296rte_devargs_layers_parse(struct rte_devargs *devargs,
297 const char *devstr);
298
9f95a23c
TL
299/*
300 * probe a device at local process.
301 *
302 * @param devargs
303 * Device arguments including bus, class and driver properties.
304 * @param new_dev
305 * new device be probed as output.
306 * @return
307 * 0 on success, negative on error.
308 */
309int local_dev_probe(const char *devargs, struct rte_device **new_dev);
310
311/**
312 * Hotplug remove a given device from a specific bus at local process.
313 *
314 * @param dev
315 * Data structure of the device to remove.
316 * @return
317 * 0 on success, negative on error.
318 */
319int local_dev_remove(struct rte_device *dev);
320
321/**
322 * Iterate over all buses to find the corresponding bus to handle the sigbus
323 * error.
324 * @param failure_addr
325 * Pointer of the fault address of the sigbus error.
326 *
327 * @return
328 * 0 success to handle the sigbus.
329 * -1 failed to handle the sigbus
330 * 1 no bus can handler the sigbus
331 */
332int rte_bus_sigbus_handler(const void *failure_addr);
333
334/**
335 * @internal
336 * Register the sigbus handler.
337 *
338 * @return
339 * - On success, zero.
340 * - On failure, a negative value.
341 */
342int
343dev_sigbus_handler_register(void);
344
345/**
346 * @internal
347 * Unregister the sigbus handler.
348 *
349 * @return
350 * - On success, zero.
351 * - On failure, a negative value.
352 */
353int
354dev_sigbus_handler_unregister(void);
355
356/**
357 * Check if the option is registered.
358 *
359 * @param option
360 * The option to be parsed.
361 *
362 * @return
363 * 0 on success
364 * @return
365 * -1 on fail
366 */
367int
368rte_option_parse(const char *opt);
369
370/**
371 * Iterate through the registered options and execute the associated
372 * callback if enabled.
373 */
374void
375rte_option_init(void);
376
377/**
378 * Iterate through the registered options and show the associated
379 * usage string.
380 */
381void
382rte_option_usage(void);
383
7c673cae 384#endif /* _EAL_PRIVATE_H_ */