power: fix link with application
[dpdk.git] / lib / librte_power / rte_power.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 _RTE_POWER_H
35 #define _RTE_POWER_H
36
37 /**
38  * @file
39  * RTE Power Management
40  */
41
42 #include <rte_common.h>
43 #include <rte_byteorder.h>
44 #include <rte_log.h>
45 #include <rte_string_fns.h>
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /* Power Management Environment State */
52 enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM};
53
54 /**
55  * Set the default power management implementation. If this is not called prior
56  * to rte_power_init(), then auto-detect of the environment will take place.
57  * It is not thread safe.
58  *
59  * @param env
60  *  env. The environment in which to initialise Power Management for.
61  *
62  * @return
63  *  - 0 on success.
64  *  - Negative on error.
65  */
66 int rte_power_set_env(enum power_management_env env);
67
68 /**
69  * Unset the global environment configuration.
70  * This can only be called after all threads have completed.
71  *
72  * @param None.
73  *
74  * @return
75  *  None.
76  */
77 void rte_power_unset_env(void);
78
79 /**
80  * Get the default power management implementation.
81  *
82  * @param None.
83  *
84  * @return
85  *  power_management_env The configured environment.
86  */
87 enum power_management_env rte_power_get_env(void);
88
89 /**
90  * Initialize power management for a specific lcore. If rte_power_set_env() has
91  * not been called then an auto-detect of the environment will start and
92  * initialise the corresponding resources.
93  *
94  * @param lcore_id
95  *  lcore id.
96  *
97  * @return
98  *  - 0 on success.
99  *  - Negative on error.
100  */
101 int rte_power_init(unsigned lcore_id);
102
103 /**
104  * Exit power management on a specific lcore. This will call the environment
105  * dependent exit function.
106  *
107  *
108  * @param lcore_id
109  *  lcore id.
110  *
111  * @return
112  *  - 0 on success.
113  *  - Negative on error.
114  */
115 int rte_power_exit(unsigned lcore_id);
116
117 /**
118  * Get the available frequencies of a specific lcore.
119  * Function pointer definition. Review each environments
120  * specific documentation for usage.
121  *
122  * @param lcore_id
123  *  lcore id.
124  * @param freqs
125  *  The buffer array to save the frequencies.
126  * @param num
127  *  The number of frequencies to get.
128  *
129  * @return
130  *  The number of available frequencies.
131  */
132 typedef uint32_t (*rte_power_freqs_t)(unsigned lcore_id, uint32_t *freqs,
133                 uint32_t num);
134
135 extern rte_power_freqs_t rte_power_freqs;
136
137 /**
138  * Return the current index of available frequencies of a specific lcore.
139  * Function pointer definition. Review each environments
140  * specific documentation for usage.
141  *
142  * @param lcore_id
143  *  lcore id.
144  *
145  * @return
146  *  The current index of available frequencies.
147  */
148 typedef uint32_t (*rte_power_get_freq_t)(unsigned lcore_id);
149
150 extern rte_power_get_freq_t rte_power_get_freq;
151
152 /**
153  * Set the new frequency for a specific lcore by indicating the index of
154  * available frequencies.
155  * Function pointer definition. Review each environments
156  * specific documentation for usage.
157  *
158  * @param lcore_id
159  *  lcore id.
160  * @param index
161  *  The index of available frequencies.
162  *
163  * @return
164  *  - 1 on success with frequency changed.
165  *  - 0 on success without frequency changed.
166  *  - Negative on error.
167  */
168 typedef int (*rte_power_set_freq_t)(unsigned lcore_id, uint32_t index);
169
170 extern rte_power_set_freq_t rte_power_set_freq;
171
172 /**
173  * Function pointer definition for generic frequency change functions. Review
174  * each environments specific documentation for usage.
175  *
176  * @param lcore_id
177  *  lcore id.
178  *
179  * @return
180  *  - 1 on success with frequency changed.
181  *  - 0 on success without frequency changed.
182  *  - Negative on error.
183  */
184 typedef int (*rte_power_freq_change_t)(unsigned lcore_id);
185
186 /**
187  * Scale up the frequency of a specific lcore according to the available
188  * frequencies.
189  * Review each environments specific documentation for usage.
190  *
191  * @param lcore_id
192  *  lcore id.
193  *
194  * @return
195  *  - 1 on success with frequency changed.
196  *  - 0 on success without frequency changed.
197  *  - Negative on error.
198  */
199 extern rte_power_freq_change_t rte_power_freq_up;
200
201 /**
202  * Scale down the frequency of a specific lcore according to the available
203  * frequencies.
204  * Review each environments specific documentation for usage.
205  *
206  * @param lcore_id
207  *  lcore id.
208  *
209  * @return
210  *  - 1 on success with frequency changed.
211  *  - 0 on success without frequency changed.
212  *  - Negative on error.
213  */
214
215 extern rte_power_freq_change_t rte_power_freq_down;
216
217 /**
218  * Scale up the frequency of a specific lcore to the highest according to the
219  * available frequencies.
220  * Review each environments specific documentation for usage.
221  *
222  * @param lcore_id
223  *  lcore id.
224  *
225  * @return
226  *  - 1 on success with frequency changed.
227  *  - 0 on success without frequency changed.
228  *  - Negative on error.
229  */
230 extern rte_power_freq_change_t rte_power_freq_max;
231
232 /**
233  * Scale down the frequency of a specific lcore to the lowest according to the
234  * available frequencies.
235  * Review each environments specific documentation for usage..
236  *
237  * @param lcore_id
238  *  lcore id.
239  *
240  * @return
241  *  - 1 on success with frequency changed.
242  *  - 0 on success without frequency changed.
243  *  - Negative on error.
244  */
245 extern rte_power_freq_change_t rte_power_freq_min;
246
247 #ifdef __cplusplus
248 }
249 #endif
250
251 #endif