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>
17 #include <rte_power_guest_channel.h>
23 /* Power Management Environment State */
24 enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM,
25 PM_ENV_PSTATE_CPUFREQ};
29 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
31 * Check if a specific power management environment type is supported on a
32 * currently running system.
35 * The environment type to check support for.
40 * - -1 if error, with rte_errno indicating reason for error.
43 int rte_power_check_env_supported(enum power_management_env env);
46 * Set the default power management implementation. If this is not called prior
47 * to rte_power_init(), then auto-detect of the environment will take place.
48 * It is thread safe. New env can be set only in uninitialized state
49 * (thus rte_power_unset_env must be called if different env was already set).
52 * env. The environment in which to initialise Power Management for.
56 * - Negative on error.
58 int rte_power_set_env(enum power_management_env env);
61 * Unset the global environment configuration.
62 * This can only be called after all threads have completed.
64 void rte_power_unset_env(void);
67 * Get the default power management implementation.
70 * power_management_env The configured environment.
72 enum power_management_env rte_power_get_env(void);
75 * Initialize power management for a specific lcore. If rte_power_set_env() has
76 * not been called then an auto-detect of the environment will start and
77 * initialise the corresponding resources.
84 * - Negative on error.
86 int rte_power_init(unsigned int lcore_id);
89 * Exit power management on a specific lcore. This will call the environment
90 * dependent exit function.
97 * - Negative on error.
99 int rte_power_exit(unsigned int lcore_id);
102 * Get the available frequencies of a specific lcore.
103 * Function pointer definition. Review each environments
104 * specific documentation for usage.
109 * The buffer array to save the frequencies.
111 * The number of frequencies to get.
114 * The number of available frequencies.
116 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
119 extern rte_power_freqs_t rte_power_freqs;
122 * Return the current index of available frequencies of a specific lcore.
123 * Function pointer definition. Review each environments
124 * specific documentation for usage.
130 * The current index of available frequencies.
132 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
134 extern rte_power_get_freq_t rte_power_get_freq;
137 * Set the new frequency for a specific lcore by indicating the index of
138 * available frequencies.
139 * Function pointer definition. Review each environments
140 * specific documentation for usage.
145 * The index of available frequencies.
148 * - 1 on success with frequency changed.
149 * - 0 on success without frequency changed.
150 * - Negative on error.
152 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
154 extern rte_power_set_freq_t rte_power_set_freq;
157 * Function pointer definition for generic frequency change functions. Review
158 * each environments specific documentation for usage.
164 * - 1 on success with frequency changed.
165 * - 0 on success without frequency changed.
166 * - Negative on error.
168 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
171 * Scale up the frequency of a specific lcore according to the available
173 * Review each environments specific documentation for usage.
179 * - 1 on success with frequency changed.
180 * - 0 on success without frequency changed.
181 * - Negative on error.
183 extern rte_power_freq_change_t rte_power_freq_up;
186 * Scale down the frequency of a specific lcore according to the available
188 * Review each environments specific documentation for usage.
194 * - 1 on success with frequency changed.
195 * - 0 on success without frequency changed.
196 * - Negative on error.
199 extern rte_power_freq_change_t rte_power_freq_down;
202 * Scale up the frequency of a specific lcore to the highest according to the
203 * available frequencies.
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.
214 extern rte_power_freq_change_t rte_power_freq_max;
217 * Scale down the frequency of a specific lcore to the lowest according to the
218 * available frequencies.
219 * Review each environments specific documentation for usage..
225 * - 1 on success with frequency changed.
226 * - 0 on success without frequency changed.
227 * - Negative on error.
229 extern rte_power_freq_change_t rte_power_freq_min;
232 * Query the Turbo Boost status of a specific lcore.
233 * Review each environments specific documentation for usage..
239 * - 1 Turbo Boost is enabled for this lcore.
240 * - 0 Turbo Boost is disabled for this lcore.
241 * - Negative on error.
243 extern rte_power_freq_change_t rte_power_turbo_status;
246 * Enable Turbo Boost for this lcore.
247 * Review each environments specific documentation for usage..
254 * - Negative on error.
256 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
259 * Disable Turbo Boost for this lcore.
260 * Review each environments specific documentation for usage..
267 * - Negative on error.
269 extern rte_power_freq_change_t rte_power_freq_disable_turbo;
272 * Power capabilities summary.
274 struct rte_power_core_capabilities {
277 uint64_t capabilities;
280 uint64_t turbo:1; /**< Turbo can be enabled. */
281 uint64_t priority:1; /**< SST-BF high freq core */
287 * Returns power capabilities for a specific lcore.
288 * Function pointer definition. Review each environments
289 * specific documentation for usage.
294 * pointer to rte_power_core_capabilities object.
298 * - Negative on error.
300 typedef int (*rte_power_get_capabilities_t)(unsigned int lcore_id,
301 struct rte_power_core_capabilities *caps);
303 extern rte_power_get_capabilities_t rte_power_get_capabilities;