New upstream version 18.02
[deb_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 /**
13  * Initialize the memzone subsystem (private to eal).
14  *
15  * @return
16  *   - 0 on success
17  *   - Negative on error
18  */
19 int rte_eal_memzone_init(void);
20
21 /**
22  * Common log initialization function (private to eal).  Determines
23  * where log data is written when no call to rte_openlog_stream is
24  * in effect.
25  *
26  * @param default_log
27  *   The default log stream to be used.
28  * @return
29  *   - 0 on success
30  *   - Negative on error
31  */
32 void eal_log_set_default(FILE *default_log);
33
34 /**
35  * Fill configuration with number of physical and logical processors
36  *
37  * This function is private to EAL.
38  *
39  * Parse /proc/cpuinfo to get the number of physical and logical
40  * processors on the machine.
41  *
42  * @return
43  *   0 on success, negative on error
44  */
45 int rte_eal_cpu_init(void);
46
47 /**
48  * Map memory
49  *
50  * This function is private to EAL.
51  *
52  * Fill configuration structure with these infos, and return 0 on success.
53  *
54  * @return
55  *   0 on success, negative on error
56  */
57 int rte_eal_memory_init(void);
58
59 /**
60  * Configure timers
61  *
62  * This function is private to EAL.
63  *
64  * Mmap memory areas used by HPET (high precision event timer) that will
65  * provide our time reference, and configure the TSC frequency also for it
66  * to be used as a reference.
67  *
68  * @return
69  *   0 on success, negative on error
70  */
71 int rte_eal_timer_init(void);
72
73 /**
74  * Init the default log stream
75  *
76  * This function is private to EAL.
77  *
78  * @return
79  *   0 on success, negative on error
80  */
81 int rte_eal_log_init(const char *id, int facility);
82
83 /**
84  * Init tail queues for non-EAL library structures. This is to allow
85  * the rings, mempools, etc. lists to be shared among multiple processes
86  *
87  * This function is private to EAL
88  *
89  * @return
90  *    0 on success, negative on error
91  */
92 int rte_eal_tailqs_init(void);
93
94 /**
95  * Init interrupt handling.
96  *
97  * This function is private to EAL.
98  *
99  * @return
100  *  0 on success, negative on error
101  */
102 int rte_eal_intr_init(void);
103
104 /**
105  * Init alarm mechanism. This is to allow a callback be called after
106  * specific time.
107  *
108  * This function is private to EAL.
109  *
110  * @return
111  *  0 on success, negative on error
112  */
113 int rte_eal_alarm_init(void);
114
115 /**
116  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
117  * etc.) loaded.
118  *
119  * @param module_name
120  *      The module's name which need to be checked
121  *
122  * @return
123  *      -1 means some error happens(NULL pointer or open failure)
124  *      0  means the module not loaded
125  *      1  means the module loaded
126  */
127 int rte_eal_check_module(const char *module_name);
128
129 /**
130  * Get cpu core_id.
131  *
132  * This function is private to the EAL.
133  */
134 unsigned eal_cpu_core_id(unsigned lcore_id);
135
136 /**
137  * Check if cpu is present.
138  *
139  * This function is private to the EAL.
140  */
141 int eal_cpu_detected(unsigned lcore_id);
142
143 /**
144  * Set TSC frequency from precise value or estimation
145  *
146  * This function is private to the EAL.
147  */
148 void set_tsc_freq(void);
149
150 /**
151  * Get precise TSC frequency from system
152  *
153  * This function is private to the EAL.
154  */
155 uint64_t get_tsc_freq(void);
156
157 /**
158  * Get TSC frequency if the architecture supports.
159  *
160  * This function is private to the EAL.
161  *
162  * @return
163  *   The number of TSC cycles in one second.
164  *   Returns zero if the architecture support is not available.
165  */
166 uint64_t get_tsc_freq_arch(void);
167
168 /**
169  * Prepare physical memory mapping
170  * i.e. hugepages on Linux and
171  *      contigmem on BSD.
172  *
173  * This function is private to the EAL.
174  */
175 int rte_eal_hugepage_init(void);
176
177 /**
178  * Creates memory mapping in secondary process
179  * i.e. hugepages on Linux and
180  *      contigmem on BSD.
181  *
182  * This function is private to the EAL.
183  */
184 int rte_eal_hugepage_attach(void);
185
186 /**
187  * Find a bus capable of identifying a device.
188  *
189  * @param str
190  *   A device identifier (PCI address, virtual PMD name, ...).
191  *
192  * @return
193  *   A valid bus handle if found.
194  *   NULL if no bus is able to parse this device.
195  */
196 struct rte_bus *rte_bus_find_by_device_name(const char *str);
197
198 /**
199  * Create the unix channel for primary/secondary communication.
200  *
201  * @return
202  *   0 on success;
203  *   (<0) on failure.
204  */
205
206 int rte_mp_channel_init(void);
207
208 #endif /* _EAL_PRIVATE_H_ */