log: add ability to match log type with globbing
[dpdk.git] / lib / librte_eal / common / eal_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2018 Intel Corporation
3  */
4
5 #ifndef _EAL_PRIVATE_H_
6 #define _EAL_PRIVATE_H_
7
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdio.h>
11
12 #include <rte_dev.h>
13
14 /**
15  * Initialize the memzone subsystem (private to eal).
16  *
17  * @return
18  *   - 0 on success
19  *   - Negative on error
20  */
21 int 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  */
34 void 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  */
47 int rte_eal_cpu_init(void);
48
49 /**
50  * Map memory
51  *
52  * This function is private to EAL.
53  *
54  * Fill configuration structure with these infos, and return 0 on success.
55  *
56  * @return
57  *   0 on success, negative on error
58  */
59 int rte_eal_memory_init(void);
60
61 /**
62  * Configure timers
63  *
64  * This function is private to EAL.
65  *
66  * Mmap memory areas used by HPET (high precision event timer) that will
67  * provide our time reference, and configure the TSC frequency also for it
68  * to be used as a reference.
69  *
70  * @return
71  *   0 on success, negative on error
72  */
73 int rte_eal_timer_init(void);
74
75 /**
76  * Init the default log stream
77  *
78  * This function is private to EAL.
79  *
80  * @return
81  *   0 on success, negative on error
82  */
83 int rte_eal_log_init(const char *id, int facility);
84
85 /**
86  * Save the log regexp for later
87  */
88 int rte_log_save_regexp(const char *type, int priority);
89 int rte_log_save_pattern(const char *pattern, int priority);
90
91 /**
92  * Init tail queues for non-EAL library structures. This is to allow
93  * the rings, mempools, etc. lists to be shared among multiple processes
94  *
95  * This function is private to EAL
96  *
97  * @return
98  *    0 on success, negative on error
99  */
100 int rte_eal_tailqs_init(void);
101
102 /**
103  * Init interrupt handling.
104  *
105  * This function is private to EAL.
106  *
107  * @return
108  *  0 on success, negative on error
109  */
110 int rte_eal_intr_init(void);
111
112 /**
113  * Init alarm mechanism. This is to allow a callback be called after
114  * specific time.
115  *
116  * This function is private to EAL.
117  *
118  * @return
119  *  0 on success, negative on error
120  */
121 int rte_eal_alarm_init(void);
122
123 /**
124  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
125  * etc.) loaded.
126  *
127  * @param module_name
128  *      The module's name which need to be checked
129  *
130  * @return
131  *      -1 means some error happens(NULL pointer or open failure)
132  *      0  means the module not loaded
133  *      1  means the module loaded
134  */
135 int rte_eal_check_module(const char *module_name);
136
137 /**
138  * Get virtual area of specified size from the OS.
139  *
140  * This function is private to the EAL.
141  *
142  * @param requested_addr
143  *   Address where to request address space.
144  * @param size
145  *   Size of requested area.
146  * @param page_sz
147  *   Page size on which to align requested virtual area.
148  * @param flags
149  *   EAL_VIRTUAL_AREA_* flags.
150  * @param mmap_flags
151  *   Extra flags passed directly to mmap().
152  *
153  * @return
154  *   Virtual area address if successful.
155  *   NULL if unsuccessful.
156  */
157
158 #define EAL_VIRTUAL_AREA_ADDR_IS_HINT (1 << 0)
159 /**< don't fail if cannot get exact requested address. */
160 #define EAL_VIRTUAL_AREA_ALLOW_SHRINK (1 << 1)
161 /**< try getting smaller sized (decrement by page size) virtual areas if cannot
162  * get area of requested size.
163  */
164 #define EAL_VIRTUAL_AREA_UNMAP (1 << 2)
165 /**< immediately unmap reserved virtual area. */
166 void *
167 eal_get_virtual_area(void *requested_addr, size_t *size,
168                 size_t page_sz, int flags, int mmap_flags);
169
170 /**
171  * Get cpu core_id.
172  *
173  * This function is private to the EAL.
174  */
175 unsigned eal_cpu_core_id(unsigned lcore_id);
176
177 /**
178  * Check if cpu is present.
179  *
180  * This function is private to the EAL.
181  */
182 int eal_cpu_detected(unsigned lcore_id);
183
184 /**
185  * Set TSC frequency from precise value or estimation
186  *
187  * This function is private to the EAL.
188  */
189 void set_tsc_freq(void);
190
191 /**
192  * Get precise TSC frequency from system
193  *
194  * This function is private to the EAL.
195  */
196 uint64_t get_tsc_freq(void);
197
198 /**
199  * Get TSC frequency if the architecture supports.
200  *
201  * This function is private to the EAL.
202  *
203  * @return
204  *   The number of TSC cycles in one second.
205  *   Returns zero if the architecture support is not available.
206  */
207 uint64_t get_tsc_freq_arch(void);
208
209 /**
210  * Prepare physical memory mapping
211  * i.e. hugepages on Linux and
212  *      contigmem on BSD.
213  *
214  * This function is private to the EAL.
215  */
216 int rte_eal_hugepage_init(void);
217
218 /**
219  * Creates memory mapping in secondary process
220  * i.e. hugepages on Linux and
221  *      contigmem on BSD.
222  *
223  * This function is private to the EAL.
224  */
225 int rte_eal_hugepage_attach(void);
226
227 /**
228  * Find a bus capable of identifying a device.
229  *
230  * @param str
231  *   A device identifier (PCI address, virtual PMD name, ...).
232  *
233  * @return
234  *   A valid bus handle if found.
235  *   NULL if no bus is able to parse this device.
236  */
237 struct rte_bus *rte_bus_find_by_device_name(const char *str);
238
239 /**
240  * Create the unix channel for primary/secondary communication.
241  *
242  * @return
243  *   0 on success;
244  *   (<0) on failure.
245  */
246
247 int rte_mp_channel_init(void);
248
249 /**
250  * Internal Executes all the user application registered callbacks for
251  * the specific device. It is for DPDK internal user only. User
252  * application should not call it directly.
253  *
254  * @param device_name
255  *  The device name.
256  * @param event
257  *  the device event type.
258  */
259 void dev_callback_process(char *device_name, enum rte_dev_event_type event);
260
261 #endif /* _EAL_PRIVATE_H_ */