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.
72 void rte_power_unset_env(void);
75 * Get the default power management implementation.
78 * power_management_env The configured environment.
80 enum power_management_env rte_power_get_env(void);
83 * Initialize power management for a specific lcore. If rte_power_set_env() has
84 * not been called then an auto-detect of the environment will start and
85 * initialise the corresponding resources.
92 * - Negative on error.
94 int rte_power_init(unsigned lcore_id);
97 * Exit power management on a specific lcore. This will call the environment
98 * dependent exit function.
105 * - Negative on error.
107 int rte_power_exit(unsigned lcore_id);
110 * Get the available frequencies of a specific lcore.
111 * Function pointer definition. Review each environments
112 * specific documentation for usage.
117 * The buffer array to save the frequencies.
119 * The number of frequencies to get.
122 * The number of available frequencies.
124 typedef uint32_t (*rte_power_freqs_t)(unsigned lcore_id, uint32_t *freqs,
127 extern rte_power_freqs_t rte_power_freqs;
130 * Return the current index of available frequencies of a specific lcore.
131 * Function pointer definition. Review each environments
132 * specific documentation for usage.
138 * The current index of available frequencies.
140 typedef uint32_t (*rte_power_get_freq_t)(unsigned lcore_id);
142 extern rte_power_get_freq_t rte_power_get_freq;
145 * Set the new frequency for a specific lcore by indicating the index of
146 * available frequencies.
147 * Function pointer definition. Review each environments
148 * specific documentation for usage.
153 * The index of available frequencies.
156 * - 1 on success with frequency changed.
157 * - 0 on success without frequency changed.
158 * - Negative on error.
160 typedef int (*rte_power_set_freq_t)(unsigned lcore_id, uint32_t index);
162 extern rte_power_set_freq_t rte_power_set_freq;
165 * Function pointer definition for generic frequency change functions. Review
166 * each environments specific documentation for usage.
172 * - 1 on success with frequency changed.
173 * - 0 on success without frequency changed.
174 * - Negative on error.
176 typedef int (*rte_power_freq_change_t)(unsigned lcore_id);
179 * Scale up the frequency of a specific lcore according to the available
181 * Review each environments specific documentation for usage.
187 * - 1 on success with frequency changed.
188 * - 0 on success without frequency changed.
189 * - Negative on error.
191 extern rte_power_freq_change_t rte_power_freq_up;
194 * Scale down the frequency of a specific lcore according to the available
196 * Review each environments specific documentation for usage.
202 * - 1 on success with frequency changed.
203 * - 0 on success without frequency changed.
204 * - Negative on error.
207 extern rte_power_freq_change_t rte_power_freq_down;
210 * Scale up the frequency of a specific lcore to the highest according to the
211 * available frequencies.
212 * Review each environments specific documentation for usage.
218 * - 1 on success with frequency changed.
219 * - 0 on success without frequency changed.
220 * - Negative on error.
222 extern rte_power_freq_change_t rte_power_freq_max;
225 * Scale down the frequency of a specific lcore to the lowest according to the
226 * available frequencies.
227 * Review each environments specific documentation for usage..
233 * - 1 on success with frequency changed.
234 * - 0 on success without frequency changed.
235 * - Negative on error.
237 extern rte_power_freq_change_t rte_power_freq_min;