eal: add device event monitor framework
[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  * Init tail queues for non-EAL library structures. This is to allow
87  * the rings, mempools, etc. lists to be shared among multiple processes
88  *
89  * This function is private to EAL
90  *
91  * @return
92  *    0 on success, negative on error
93  */
94 int rte_eal_tailqs_init(void);
95
96 /**
97  * Init interrupt handling.
98  *
99  * This function is private to EAL.
100  *
101  * @return
102  *  0 on success, negative on error
103  */
104 int rte_eal_intr_init(void);
105
106 /**
107  * Init alarm mechanism. This is to allow a callback be called after
108  * specific time.
109  *
110  * This function is private to EAL.
111  *
112  * @return
113  *  0 on success, negative on error
114  */
115 int rte_eal_alarm_init(void);
116
117 /**
118  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
119  * etc.) loaded.
120  *
121  * @param module_name
122  *      The module's name which need to be checked
123  *
124  * @return
125  *      -1 means some error happens(NULL pointer or open failure)
126  *      0  means the module not loaded
127  *      1  means the module loaded
128  */
129 int rte_eal_check_module(const char *module_name);
130
131 /**
132  * Get virtual area of specified size from the OS.
133  *
134  * This function is private to the EAL.
135  *
136  * @param requested_addr
137  *   Address where to request address space.
138  * @param size
139  *   Size of requested area.
140  * @param page_sz
141  *   Page size on which to align requested virtual area.
142  * @param flags
143  *   EAL_VIRTUAL_AREA_* flags.
144  * @param mmap_flags
145  *   Extra flags passed directly to mmap().
146  *
147  * @return
148  *   Virtual area address if successful.
149  *   NULL if unsuccessful.
150  */
151
152 #define EAL_VIRTUAL_AREA_ADDR_IS_HINT (1 << 0)
153 /**< don't fail if cannot get exact requested address. */
154 #define EAL_VIRTUAL_AREA_ALLOW_SHRINK (1 << 1)
155 /**< try getting smaller sized (decrement by page size) virtual areas if cannot
156  * get area of requested size.
157  */
158 #define EAL_VIRTUAL_AREA_UNMAP (1 << 2)
159 /**< immediately unmap reserved virtual area. */
160 void *
161 eal_get_virtual_area(void *requested_addr, size_t *size,
162                 size_t page_sz, int flags, int mmap_flags);
163
164 /**
165  * Get cpu core_id.
166  *
167  * This function is private to the EAL.
168  */
169 unsigned eal_cpu_core_id(unsigned lcore_id);
170
171 /**
172  * Check if cpu is present.
173  *
174  * This function is private to the EAL.
175  */
176 int eal_cpu_detected(unsigned lcore_id);
177
178 /**
179  * Set TSC frequency from precise value or estimation
180  *
181  * This function is private to the EAL.
182  */
183 void set_tsc_freq(void);
184
185 /**
186  * Get precise TSC frequency from system
187  *
188  * This function is private to the EAL.
189  */
190 uint64_t get_tsc_freq(void);
191
192 /**
193  * Get TSC frequency if the architecture supports.
194  *
195  * This function is private to the EAL.
196  *
197  * @return
198  *   The number of TSC cycles in one second.
199  *   Returns zero if the architecture support is not available.
200  */
201 uint64_t get_tsc_freq_arch(void);
202
203 /**
204  * Prepare physical memory mapping
205  * i.e. hugepages on Linux and
206  *      contigmem on BSD.
207  *
208  * This function is private to the EAL.
209  */
210 int rte_eal_hugepage_init(void);
211
212 /**
213  * Creates memory mapping in secondary process
214  * i.e. hugepages on Linux and
215  *      contigmem on BSD.
216  *
217  * This function is private to the EAL.
218  */
219 int rte_eal_hugepage_attach(void);
220
221 /**
222  * Find a bus capable of identifying a device.
223  *
224  * @param str
225  *   A device identifier (PCI address, virtual PMD name, ...).
226  *
227  * @return
228  *   A valid bus handle if found.
229  *   NULL if no bus is able to parse this device.
230  */
231 struct rte_bus *rte_bus_find_by_device_name(const char *str);
232
233 /**
234  * Create the unix channel for primary/secondary communication.
235  *
236  * @return
237  *   0 on success;
238  *   (<0) on failure.
239  */
240
241 int rte_mp_channel_init(void);
242
243 /**
244  * Internal Executes all the user application registered callbacks for
245  * the specific device. It is for DPDK internal user only. User
246  * application should not call it directly.
247  *
248  * @param device_name
249  *  The device name.
250  * @param event
251  *  the device event type.
252  */
253 void dev_callback_process(char *device_name, enum rte_dev_event_type event);
254
255 #endif /* _EAL_PRIVATE_H_ */