1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 * RTE Power Management
13 #include <rte_common.h>
15 #include <rte_power_guest_channel.h>
21 /* Power Management Environment State */
22 enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM,
23 PM_ENV_PSTATE_CPUFREQ, PM_ENV_CPPC_CPUFREQ};
27 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
29 * Check if a specific power management environment type is supported on a
30 * currently running system.
33 * The environment type to check support for.
38 * - -1 if error, with rte_errno indicating reason for error.
41 int rte_power_check_env_supported(enum power_management_env env);
44 * Set the default power management implementation. If this is not called prior
45 * to rte_power_init(), then auto-detect of the environment will take place.
46 * It is thread safe. New env can be set only in uninitialized state
47 * (thus rte_power_unset_env must be called if different env was already set).
50 * env. The environment in which to initialise Power Management for.
54 * - Negative on error.
56 int rte_power_set_env(enum power_management_env env);
59 * Unset the global environment configuration.
60 * This can only be called after all threads have completed.
62 void rte_power_unset_env(void);
65 * Get the default power management implementation.
68 * power_management_env The configured environment.
70 enum power_management_env rte_power_get_env(void);
73 * Initialize power management for a specific lcore. If rte_power_set_env() has
74 * not been called then an auto-detect of the environment will start and
75 * initialise the corresponding resources.
82 * - Negative on error.
84 int rte_power_init(unsigned int lcore_id);
87 * Exit power management on a specific lcore. This will call the environment
88 * dependent exit function.
95 * - Negative on error.
97 int rte_power_exit(unsigned int lcore_id);
100 * Get the available frequencies of a specific lcore.
101 * Function pointer definition. Review each environments
102 * specific documentation for usage.
107 * The buffer array to save the frequencies.
109 * The number of frequencies to get.
112 * The number of available frequencies.
114 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
117 extern rte_power_freqs_t rte_power_freqs;
120 * Return the current index of available frequencies of a specific lcore.
121 * Function pointer definition. Review each environments
122 * specific documentation for usage.
128 * The current index of available frequencies.
130 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
132 extern rte_power_get_freq_t rte_power_get_freq;
135 * Set the new frequency for a specific lcore by indicating the index of
136 * available frequencies.
137 * Function pointer definition. Review each environments
138 * specific documentation for usage.
143 * The index of available frequencies.
146 * - 1 on success with frequency changed.
147 * - 0 on success without frequency changed.
148 * - Negative on error.
150 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
152 extern rte_power_set_freq_t rte_power_set_freq;
155 * Function pointer definition for generic frequency change functions. Review
156 * each environments specific documentation for usage.
162 * - 1 on success with frequency changed.
163 * - 0 on success without frequency changed.
164 * - Negative on error.
166 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
169 * Scale up the frequency of a specific lcore according to the available
171 * Review each environments specific documentation for usage.
177 * - 1 on success with frequency changed.
178 * - 0 on success without frequency changed.
179 * - Negative on error.
181 extern rte_power_freq_change_t rte_power_freq_up;
184 * Scale down the frequency of a specific lcore according to the available
186 * Review each environments specific documentation for usage.
192 * - 1 on success with frequency changed.
193 * - 0 on success without frequency changed.
194 * - Negative on error.
197 extern rte_power_freq_change_t rte_power_freq_down;
200 * Scale up the frequency of a specific lcore to the highest according to the
201 * available frequencies.
202 * Review each environments specific documentation for usage.
208 * - 1 on success with frequency changed.
209 * - 0 on success without frequency changed.
210 * - Negative on error.
212 extern rte_power_freq_change_t rte_power_freq_max;
215 * Scale down the frequency of a specific lcore to the lowest according to the
216 * available frequencies.
217 * Review each environments specific documentation for usage..
223 * - 1 on success with frequency changed.
224 * - 0 on success without frequency changed.
225 * - Negative on error.
227 extern rte_power_freq_change_t rte_power_freq_min;
230 * Query the Turbo Boost status of a specific lcore.
231 * Review each environments specific documentation for usage..
237 * - 1 Turbo Boost is enabled for this lcore.
238 * - 0 Turbo Boost is disabled for this lcore.
239 * - Negative on error.
241 extern rte_power_freq_change_t rte_power_turbo_status;
244 * Enable Turbo Boost for this lcore.
245 * Review each environments specific documentation for usage..
252 * - Negative on error.
254 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
257 * Disable Turbo Boost for this lcore.
258 * Review each environments specific documentation for usage..
265 * - Negative on error.
267 extern rte_power_freq_change_t rte_power_freq_disable_turbo;
270 * Power capabilities summary.
272 struct rte_power_core_capabilities {
275 uint64_t capabilities;
278 uint64_t turbo:1; /**< Turbo can be enabled. */
279 uint64_t priority:1; /**< SST-BF high freq core */
285 * Returns power capabilities for a specific lcore.
286 * Function pointer definition. Review each environments
287 * specific documentation for usage.
292 * pointer to rte_power_core_capabilities object.
296 * - Negative on error.
298 typedef int (*rte_power_get_capabilities_t)(unsigned int lcore_id,
299 struct rte_power_core_capabilities *caps);
301 extern rte_power_get_capabilities_t rte_power_get_capabilities;