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};
26 * Set the default power management implementation. If this is not called prior
27 * to rte_power_init(), then auto-detect of the environment will take place.
28 * It is not thread safe.
31 * env. The environment in which to initialise Power Management for.
35 * - Negative on error.
37 int rte_power_set_env(enum power_management_env env);
40 * Unset the global environment configuration.
41 * This can only be called after all threads have completed.
43 void rte_power_unset_env(void);
46 * Get the default power management implementation.
49 * power_management_env The configured environment.
51 enum power_management_env rte_power_get_env(void);
54 * Initialize power management for a specific lcore. If rte_power_set_env() has
55 * not been called then an auto-detect of the environment will start and
56 * initialise the corresponding resources.
63 * - Negative on error.
65 int rte_power_init(unsigned int lcore_id);
68 * Exit power management on a specific lcore. This will call the environment
69 * dependent exit function.
76 * - Negative on error.
78 int rte_power_exit(unsigned int lcore_id);
81 * Get the available frequencies of a specific lcore.
82 * Function pointer definition. Review each environments
83 * specific documentation for usage.
88 * The buffer array to save the frequencies.
90 * The number of frequencies to get.
93 * The number of available frequencies.
95 typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
98 extern rte_power_freqs_t rte_power_freqs;
101 * Return the current index of available frequencies of a specific lcore.
102 * Function pointer definition. Review each environments
103 * specific documentation for usage.
109 * The current index of available frequencies.
111 typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id);
113 extern rte_power_get_freq_t rte_power_get_freq;
116 * Set the new frequency for a specific lcore by indicating the index of
117 * available frequencies.
118 * Function pointer definition. Review each environments
119 * specific documentation for usage.
124 * The index of available frequencies.
127 * - 1 on success with frequency changed.
128 * - 0 on success without frequency changed.
129 * - Negative on error.
131 typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index);
133 extern rte_power_set_freq_t rte_power_set_freq;
136 * Function pointer definition for generic frequency change functions. Review
137 * each environments specific documentation for usage.
143 * - 1 on success with frequency changed.
144 * - 0 on success without frequency changed.
145 * - Negative on error.
147 typedef int (*rte_power_freq_change_t)(unsigned int lcore_id);
150 * Scale up the frequency of a specific lcore according to the available
152 * Review each environments specific documentation for usage.
158 * - 1 on success with frequency changed.
159 * - 0 on success without frequency changed.
160 * - Negative on error.
162 extern rte_power_freq_change_t rte_power_freq_up;
165 * Scale down the frequency of a specific lcore according to the available
167 * Review each environments specific documentation for usage.
173 * - 1 on success with frequency changed.
174 * - 0 on success without frequency changed.
175 * - Negative on error.
178 extern rte_power_freq_change_t rte_power_freq_down;
181 * Scale up the frequency of a specific lcore to the highest according to the
182 * available frequencies.
183 * Review each environments specific documentation for usage.
189 * - 1 on success with frequency changed.
190 * - 0 on success without frequency changed.
191 * - Negative on error.
193 extern rte_power_freq_change_t rte_power_freq_max;
196 * Scale down the frequency of a specific lcore to the lowest according to the
197 * available frequencies.
198 * Review each environments specific documentation for usage..
204 * - 1 on success with frequency changed.
205 * - 0 on success without frequency changed.
206 * - Negative on error.
208 extern rte_power_freq_change_t rte_power_freq_min;
211 * Query the Turbo Boost status of a specific lcore.
212 * Review each environments specific documentation for usage..
218 * - 1 Turbo Boost is enabled for this lcore.
219 * - 0 Turbo Boost is disabled for this lcore.
220 * - Negative on error.
222 extern rte_power_freq_change_t rte_power_turbo_status;
225 * Enable Turbo Boost for this lcore.
226 * Review each environments specific documentation for usage..
233 * - Negative on error.
235 extern rte_power_freq_change_t rte_power_freq_enable_turbo;
238 * Disable Turbo Boost for this lcore.
239 * Review each environments specific documentation for usage..
246 * - Negative on error.
248 extern rte_power_freq_change_t rte_power_freq_disable_turbo;