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};
28 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
30 * Check if a specific power management environment type is supported on a
31 * currently running system.
34 * The environment type to check support for.
39 * - -1 if error, with rte_errno indicating reason for error.
42 int rte_power_check_env_supported(enum power_management_env env);
45 * Set the default power management implementation. If this is not called prior
46 * to rte_power_init(), then auto-detect of the environment will take place.
47 * It is thread safe. New env can be set only in uninitialized state
48 * (thus rte_power_unset_env must be called if different env was already set).
51 * env. The environment in which to initialise Power Management for.
55 * - Negative on error.
57 int rte_power_set_env(enum power_management_env env);
60 * Unset the global environment configuration.
61 * This can only be called after all threads have completed.
63 void rte_power_unset_env(void);
66 * Get the default power management implementation.
69 * power_management_env The configured environment.
71 enum power_management_env rte_power_get_env(void);
74 * Initialize power management for a specific lcore. If rte_power_set_env() has
75 * not been called then an auto-detect of the environment will start and
76 * initialise the corresponding resources.
83 * - Negative on error.
85 int rte_power_init(unsigned int lcore_id);
88 * Exit power management on a specific lcore. This will call the environment
89 * dependent exit function.
96 * - Negative on error.
98 int rte_power_exit(unsigned int lcore_id);
101 * Get the available frequencies of a specific lcore.
102 * Function pointer definition. Review each environments
103 * specific documentation for usage.
108 * The buffer array to save the frequencies.
110 * The number of frequencies to get.
113 * The number of available frequencies.
115 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
118 extern rte_power_freqs_t rte_power_freqs;
121 * Return the current index of available frequencies of a specific lcore.
122 * Function pointer definition. Review each environments
123 * specific documentation for usage.
129 * The current index of available frequencies.
131 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
133 extern rte_power_get_freq_t rte_power_get_freq;
136 * Set the new frequency for a specific lcore by indicating the index of
137 * available frequencies.
138 * Function pointer definition. Review each environments
139 * specific documentation for usage.
144 * The index of available frequencies.
147 * - 1 on success with frequency changed.
148 * - 0 on success without frequency changed.
149 * - Negative on error.
151 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
153 extern rte_power_set_freq_t rte_power_set_freq;
156 * Function pointer definition for generic frequency change functions. Review
157 * each environments specific documentation for usage.
163 * - 1 on success with frequency changed.
164 * - 0 on success without frequency changed.
165 * - Negative on error.
167 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
170 * Scale up the frequency of a specific lcore according to the available
172 * Review each environments specific documentation for usage.
178 * - 1 on success with frequency changed.
179 * - 0 on success without frequency changed.
180 * - Negative on error.
182 extern rte_power_freq_change_t rte_power_freq_up;
185 * Scale down the frequency of a specific lcore according to the available
187 * Review each environments specific documentation for usage.
193 * - 1 on success with frequency changed.
194 * - 0 on success without frequency changed.
195 * - Negative on error.
198 extern rte_power_freq_change_t rte_power_freq_down;
201 * Scale up the frequency of a specific lcore to the highest according to the
202 * available frequencies.
203 * Review each environments specific documentation for usage.
209 * - 1 on success with frequency changed.
210 * - 0 on success without frequency changed.
211 * - Negative on error.
213 extern rte_power_freq_change_t rte_power_freq_max;
216 * Scale down the frequency of a specific lcore to the lowest according to the
217 * available frequencies.
218 * Review each environments specific documentation for usage..
224 * - 1 on success with frequency changed.
225 * - 0 on success without frequency changed.
226 * - Negative on error.
228 extern rte_power_freq_change_t rte_power_freq_min;
231 * Query the Turbo Boost status of a specific lcore.
232 * Review each environments specific documentation for usage..
238 * - 1 Turbo Boost is enabled for this lcore.
239 * - 0 Turbo Boost is disabled for this lcore.
240 * - Negative on error.
242 extern rte_power_freq_change_t rte_power_turbo_status;
245 * Enable Turbo Boost for this lcore.
246 * Review each environments specific documentation for usage..
253 * - Negative on error.
255 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
258 * Disable Turbo Boost for this lcore.
259 * Review each environments specific documentation for usage..
266 * - Negative on error.
268 extern rte_power_freq_change_t rte_power_freq_disable_turbo;
271 * Power capabilities summary.
273 struct rte_power_core_capabilities {
276 uint64_t capabilities;
279 uint64_t turbo:1; /**< Turbo can be enabled. */
280 uint64_t priority:1; /**< SST-BF high freq core */
286 * Returns power capabilities for a specific lcore.
287 * Function pointer definition. Review each environments
288 * specific documentation for usage.
293 * pointer to rte_power_core_capabilities object.
297 * - Negative on error.
299 typedef int (*rte_power_get_capabilities_t)(unsigned int lcore_id,
300 struct rte_power_core_capabilities *caps);
302 extern rte_power_get_capabilities_t rte_power_get_capabilities;