4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
39 * RTE Power Management
42 #include <rte_common.h>
43 #include <rte_byteorder.h>
45 #include <rte_string_fns.h>
51 /* Power Management Environment State */
52 enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM};
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.
60 * env. The environment in which to initialise Power Management for.
64 * - Negative on error.
66 int rte_power_set_env(enum power_management_env env);
69 * Unset the global environment configuration.
70 * This can only be called after all threads have completed.
77 void rte_power_unset_env(void);
80 * Get the default power management implementation.
85 * power_management_env The configured environment.
87 enum power_management_env rte_power_get_env(void);
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.
99 * - Negative on error.
101 int rte_power_init(unsigned lcore_id);
104 * Exit power management on a specific lcore. This will call the environment
105 * dependent exit function.
113 * - Negative on error.
115 int rte_power_exit(unsigned lcore_id);
118 * Get the available frequencies of a specific lcore.
119 * Function pointer definition. Review each environments
120 * specific documentation for usage.
125 * The buffer array to save the frequencies.
127 * The number of frequencies to get.
130 * The number of available frequencies.
132 typedef uint32_t (*rte_power_freqs_t)(unsigned lcore_id, uint32_t *freqs,
135 extern rte_power_freqs_t rte_power_freqs;
138 * Return the current index of available frequencies of a specific lcore.
139 * Function pointer definition. Review each environments
140 * specific documentation for usage.
146 * The current index of available frequencies.
148 typedef uint32_t (*rte_power_get_freq_t)(unsigned lcore_id);
150 extern rte_power_get_freq_t rte_power_get_freq;
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.
161 * The index of available frequencies.
164 * - 1 on success with frequency changed.
165 * - 0 on success without frequency changed.
166 * - Negative on error.
168 typedef int (*rte_power_set_freq_t)(unsigned lcore_id, uint32_t index);
170 extern rte_power_set_freq_t rte_power_set_freq;
173 * Function pointer definition for generic frequency change functions. Review
174 * each environments specific documentation for usage.
180 * - 1 on success with frequency changed.
181 * - 0 on success without frequency changed.
182 * - Negative on error.
184 typedef int (*rte_power_freq_change_t)(unsigned lcore_id);
187 * Scale up the frequency of a specific lcore according to the available
189 * Review each environments specific documentation for usage.
195 * - 1 on success with frequency changed.
196 * - 0 on success without frequency changed.
197 * - Negative on error.
199 extern rte_power_freq_change_t rte_power_freq_up;
202 * Scale down the frequency of a specific lcore according to the available
204 * Review each environments specific documentation for usage.
210 * - 1 on success with frequency changed.
211 * - 0 on success without frequency changed.
212 * - Negative on error.
215 extern rte_power_freq_change_t rte_power_freq_down;
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.
226 * - 1 on success with frequency changed.
227 * - 0 on success without frequency changed.
228 * - Negative on error.
230 extern rte_power_freq_change_t rte_power_freq_max;
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..
241 * - 1 on success with frequency changed.
242 * - 0 on success without frequency changed.
243 * - Negative on error.
245 rte_power_freq_change_t rte_power_freq_min;