4acf5a0f89b9a8f12c9bdc7ea1b06e4857248bf0
[dpdk.git] / lib / librte_eal / common / eal_private.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _EAL_PRIVATE_H_
35 #define _EAL_PRIVATE_H_
36
37 #include <stdio.h>
38
39 /**
40  * Initialize the memzone subsystem (private to eal).
41  *
42  * @return
43  *   - 0 on success
44  *   - Negative on error
45  */
46 int rte_eal_memzone_init(void);
47
48 /**
49  * Common log initialization function (private to eal).
50  *
51  * Called by environment-specific log initialization function to initialize
52  * log history.
53  *
54  * @param default_log
55  *   The default log stream to be used.
56  * @return
57  *   - 0 on success
58  *   - Negative on error
59  */
60 int rte_eal_common_log_init(FILE *default_log);
61
62 /**
63  * Fill configuration with number of physical and logical processors
64  *
65  * This function is private to EAL.
66  *
67  * Parse /proc/cpuinfo to get the number of physical and logical
68  * processors on the machine.
69  *
70  * @return
71  *   0 on success, negative on error
72  */
73 int rte_eal_cpu_init(void);
74
75 /**
76  * Map memory
77  *
78  * This function is private to EAL.
79  *
80  * Fill configuration structure with these infos, and return 0 on success.
81  *
82  * @return
83  *   0 on success, negative on error
84  */
85 int rte_eal_memory_init(void);
86
87 /**
88  * Configure timers
89  *
90  * This function is private to EAL.
91  *
92  * Mmap memory areas used by HPET (high precision event timer) that will
93  * provide our time reference, and configure the TSC frequency also for it
94  * to be used as a reference.
95  *
96  * @return
97  *   0 on success, negative on error
98  */
99 int rte_eal_timer_init(void);
100
101 /**
102  * Init early logs
103  *
104  * This function is private to EAL.
105  *
106  * @return
107  *   0 on success, negative on error
108  */
109 int rte_eal_log_early_init(void);
110
111 /**
112  * Init the default log stream
113  *
114  * This function is private to EAL.
115  *
116  * @return
117  *   0 on success, negative on error
118  */
119 int rte_eal_log_init(const char *id, int facility);
120
121 /**
122  * Init the default log stream
123  *
124  * This function is private to EAL.
125  *
126  * @return
127  *   0 on success, negative on error
128  */
129 int rte_eal_pci_init(void);
130
131 #ifdef RTE_LIBRTE_IVSHMEM
132 /**
133  * Init the memory from IVSHMEM devices
134  *
135  * This function is private to EAL.
136  *
137  * @return
138  *  0 on success, negative on error
139  */
140 int rte_eal_ivshmem_init(void);
141
142 /**
143  * Init objects in IVSHMEM devices
144  *
145  * This function is private to EAL.
146  *
147  * @return
148  *  0 on success, negative on error
149  */
150 int rte_eal_ivshmem_obj_init(void);
151 #endif
152
153 struct rte_pci_driver;
154 struct rte_pci_device;
155
156 /**
157  * Mmap memory for single PCI device
158  *
159  * This function is private to EAL.
160  *
161  * @return
162  *   0 on success, negative on error
163  */
164 int rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,
165                 struct rte_pci_device *dev);
166
167 /**
168  * Munmap memory for single PCI device
169  *
170  * This function is private to EAL.
171  *
172  * @param       dr
173  *  The pointer to the pci driver structure
174  * @param       dev
175  *  The pointer to the pci device structure
176  * @return
177  *   0 on success, negative on error
178  */
179 int rte_eal_pci_close_one_driver(struct rte_pci_driver *dr,
180                 struct rte_pci_device *dev);
181
182 /**
183  * Init tail queues for non-EAL library structures. This is to allow
184  * the rings, mempools, etc. lists to be shared among multiple processes
185  *
186  * This function is private to EAL
187  *
188  * @return
189  *    0 on success, negative on error
190  */
191 int rte_eal_tailqs_init(void);
192
193 /**
194  * Init interrupt handling.
195  *
196  * This function is private to EAL.
197  *
198  * @return
199  *  0 on success, negative on error
200  */
201 int rte_eal_intr_init(void);
202
203 /**
204  * Init alarm mechanism. This is to allow a callback be called after
205  * specific time.
206  *
207  * This function is private to EAL.
208  *
209  * @return
210  *  0 on success, negative on error
211  */
212 int rte_eal_alarm_init(void);
213
214 /**
215  * This function initialises any virtual devices
216  *
217  * This function is private to the EAL.
218  */
219 int rte_eal_dev_init(void);
220
221 /**
222  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
223  * etc.) loaded.
224  *
225  * @param module_name
226  *      The module's name which need to be checked
227  *
228  * @return
229  *      -1 means some error happens(NULL pointer or open failure)
230  *      0  means the module not loaded
231  *      1  means the module loaded
232  */
233 int rte_eal_check_module(const char *module_name);
234
235 #endif /* _EAL_PRIVATE_H_ */