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 thread safe. New env can be set only in uninitialized state
30 * (thus rte_power_unset_env must be called if different env was already set).
33 * env. The environment in which to initialise Power Management for.
37 * - Negative on error.
39 int rte_power_set_env(enum power_management_env env);
42 * Unset the global environment configuration.
43 * This can only be called after all threads have completed.
45 void rte_power_unset_env(void);
48 * Get the default power management implementation.
51 * power_management_env The configured environment.
53 enum power_management_env rte_power_get_env(void);
56 * Initialize power management for a specific lcore. If rte_power_set_env() has
57 * not been called then an auto-detect of the environment will start and
58 * initialise the corresponding resources.
65 * - Negative on error.
67 int rte_power_init(unsigned int lcore_id);
70 * Exit power management on a specific lcore. This will call the environment
71 * dependent exit function.
78 * - Negative on error.
80 int rte_power_exit(unsigned int lcore_id);
83 * Get the available frequencies of a specific lcore.
84 * Function pointer definition. Review each environments
85 * specific documentation for usage.
90 * The buffer array to save the frequencies.
92 * The number of frequencies to get.
95 * The number of available frequencies.
97 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
100 extern rte_power_freqs_t rte_power_freqs;
103 * Return the current index of available frequencies of a specific lcore.
104 * Function pointer definition. Review each environments
105 * specific documentation for usage.
111 * The current index of available frequencies.
113 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
115 extern rte_power_get_freq_t rte_power_get_freq;
118 * Set the new frequency for a specific lcore by indicating the index of
119 * available frequencies.
120 * Function pointer definition. Review each environments
121 * specific documentation for usage.
126 * The index of available frequencies.
129 * - 1 on success with frequency changed.
130 * - 0 on success without frequency changed.
131 * - Negative on error.
133 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
135 extern rte_power_set_freq_t rte_power_set_freq;
138 * Function pointer definition for generic frequency change functions. Review
139 * each environments specific documentation for usage.
145 * - 1 on success with frequency changed.
146 * - 0 on success without frequency changed.
147 * - Negative on error.
149 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
152 * Scale up the frequency of a specific lcore according to the available
154 * Review each environments specific documentation for usage.
160 * - 1 on success with frequency changed.
161 * - 0 on success without frequency changed.
162 * - Negative on error.
164 extern rte_power_freq_change_t rte_power_freq_up;
167 * Scale down the frequency of a specific lcore according to the available
169 * Review each environments specific documentation for usage.
175 * - 1 on success with frequency changed.
176 * - 0 on success without frequency changed.
177 * - Negative on error.
180 extern rte_power_freq_change_t rte_power_freq_down;
183 * Scale up the frequency of a specific lcore to the highest according to the
184 * available frequencies.
185 * Review each environments specific documentation for usage.
191 * - 1 on success with frequency changed.
192 * - 0 on success without frequency changed.
193 * - Negative on error.
195 extern rte_power_freq_change_t rte_power_freq_max;
198 * Scale down the frequency of a specific lcore to the lowest according to the
199 * available frequencies.
200 * Review each environments specific documentation for usage..
206 * - 1 on success with frequency changed.
207 * - 0 on success without frequency changed.
208 * - Negative on error.
210 extern rte_power_freq_change_t rte_power_freq_min;
213 * Query the Turbo Boost status of a specific lcore.
214 * Review each environments specific documentation for usage..
220 * - 1 Turbo Boost is enabled for this lcore.
221 * - 0 Turbo Boost is disabled for this lcore.
222 * - Negative on error.
224 extern rte_power_freq_change_t rte_power_turbo_status;
227 * Enable Turbo Boost for this lcore.
228 * Review each environments specific documentation for usage..
235 * - Negative on error.
237 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
240 * Disable Turbo Boost for this lcore.
241 * Review each environments specific documentation for usage..
248 * - Negative on error.
250 extern rte_power_freq_change_t rte_power_freq_disable_turbo;
253 * Power capabilities summary.
255 struct rte_power_core_capabilities {
258 uint64_t capabilities;
261 uint64_t turbo:1; /**< Turbo can be enabled. */
262 uint64_t priority:1; /**< SST-BF high freq core */
268 * Returns power capabilities for a specific lcore.
269 * Function pointer definition. Review each environments
270 * specific documentation for usage.
275 * pointer to rte_power_core_capabilities object.
279 * - Negative on error.
281 typedef int (*rte_power_get_capabilities_t)(unsigned int lcore_id,
282 struct rte_power_core_capabilities *caps);
284 extern rte_power_get_capabilities_t rte_power_get_capabilities;