1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 * RTE Power Management
13 #include <rte_common.h>
14 #include <rte_byteorder.h>
16 #include <rte_string_fns.h>
22 /* Power Management Environment State */
23 enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM,
24 PM_ENV_PSTATE_CPUFREQ};
27 * Set the default power management implementation. If this is not called prior
28 * to rte_power_init(), then auto-detect of the environment will take place.
29 * It is not thread safe.
32 * env. The environment in which to initialise Power Management for.
36 * - Negative on error.
38 int rte_power_set_env(enum power_management_env env);
41 * Unset the global environment configuration.
42 * This can only be called after all threads have completed.
44 void rte_power_unset_env(void);
47 * Get the default power management implementation.
50 * power_management_env The configured environment.
52 enum power_management_env rte_power_get_env(void);
55 * Initialize power management for a specific lcore. If rte_power_set_env() has
56 * not been called then an auto-detect of the environment will start and
57 * initialise the corresponding resources.
64 * - Negative on error.
66 int rte_power_init(unsigned int lcore_id);
69 * Exit power management on a specific lcore. This will call the environment
70 * dependent exit function.
77 * - Negative on error.
79 int rte_power_exit(unsigned int lcore_id);
82 * Get the available frequencies of a specific lcore.
83 * Function pointer definition. Review each environments
84 * specific documentation for usage.
89 * The buffer array to save the frequencies.
91 * The number of frequencies to get.
94 * The number of available frequencies.
96 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
99 extern rte_power_freqs_t rte_power_freqs;
102 * Return the current index of available frequencies of a specific lcore.
103 * Function pointer definition. Review each environments
104 * specific documentation for usage.
110 * The current index of available frequencies.
112 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
114 extern rte_power_get_freq_t rte_power_get_freq;
117 * Set the new frequency for a specific lcore by indicating the index of
118 * available frequencies.
119 * Function pointer definition. Review each environments
120 * specific documentation for usage.
125 * The index of available frequencies.
128 * - 1 on success with frequency changed.
129 * - 0 on success without frequency changed.
130 * - Negative on error.
132 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
134 extern rte_power_set_freq_t rte_power_set_freq;
137 * Function pointer definition for generic frequency change functions. Review
138 * each environments specific documentation for usage.
144 * - 1 on success with frequency changed.
145 * - 0 on success without frequency changed.
146 * - Negative on error.
148 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
151 * Scale up the frequency of a specific lcore according to the available
153 * Review each environments specific documentation for usage.
159 * - 1 on success with frequency changed.
160 * - 0 on success without frequency changed.
161 * - Negative on error.
163 extern rte_power_freq_change_t rte_power_freq_up;
166 * Scale down the frequency of a specific lcore according to the available
168 * Review each environments specific documentation for usage.
174 * - 1 on success with frequency changed.
175 * - 0 on success without frequency changed.
176 * - Negative on error.
179 extern rte_power_freq_change_t rte_power_freq_down;
182 * Scale up the frequency of a specific lcore to the highest according to the
183 * available frequencies.
184 * Review each environments specific documentation for usage.
190 * - 1 on success with frequency changed.
191 * - 0 on success without frequency changed.
192 * - Negative on error.
194 extern rte_power_freq_change_t rte_power_freq_max;
197 * Scale down the frequency of a specific lcore to the lowest according to the
198 * available frequencies.
199 * Review each environments specific documentation for usage..
205 * - 1 on success with frequency changed.
206 * - 0 on success without frequency changed.
207 * - Negative on error.
209 extern rte_power_freq_change_t rte_power_freq_min;
212 * Query the Turbo Boost status of a specific lcore.
213 * Review each environments specific documentation for usage..
219 * - 1 Turbo Boost is enabled for this lcore.
220 * - 0 Turbo Boost is disabled for this lcore.
221 * - Negative on error.
223 extern rte_power_freq_change_t rte_power_turbo_status;
226 * Enable Turbo Boost for this lcore.
227 * Review each environments specific documentation for usage..
234 * - Negative on error.
236 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
239 * Disable Turbo Boost for this lcore.
240 * Review each environments specific documentation for usage..
247 * - Negative on error.
249 extern rte_power_freq_change_t rte_power_freq_disable_turbo;
252 * Power capabilities summary.
254 struct rte_power_core_capabilities {
257 uint64_t capabilities;
260 uint64_t turbo:1; /**< Turbo can be enabled. */
261 uint64_t priority:1; /**< Priority core */
267 * Returns power capabilities for a specific lcore.
268 * Function pointer definition. Review each environments
269 * specific documentation for usage.
274 * pointer to rte_power_core_capabilities object.
278 * - Negative on error.
280 typedef int (*rte_power_get_capabilities_t)(unsigned int lcore_id,
281 struct rte_power_core_capabilities *caps);
283 extern rte_power_get_capabilities_t rte_power_get_capabilities;