1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef _POWER_ACPI_CPUFREQ_H
6 #define _POWER_ACPI_CPUFREQ_H
10 * RTE Power Management via userspace ACPI cpufreq
13 #include <rte_common.h>
14 #include <rte_byteorder.h>
16 #include <rte_string_fns.h>
17 #include "rte_power.h"
20 * Check if ACPI power management is supported.
25 * - -1 if error, with rte_errno indicating reason for error.
27 int power_acpi_cpufreq_check_supported(void);
30 * Initialize power management for a specific lcore. It will check and set the
31 * governor to userspace for the lcore, get the available frequencies, and
32 * prepare to set new lcore frequency.
39 * - Negative on error.
41 int power_acpi_cpufreq_init(unsigned int lcore_id);
44 * Exit power management on a specific lcore. It will set the governor to which
45 * is before initialized.
52 * - Negative on error.
54 int power_acpi_cpufreq_exit(unsigned int lcore_id);
57 * Get the available frequencies of a specific lcore. The return value will be
58 * the minimal one of the total number of available frequencies and the number
59 * of buffer. The index of available frequencies used in other interfaces
60 * should be in the range of 0 to this return value.
61 * It should be protected outside of this function for threadsafe.
66 * The buffer array to save the frequencies.
68 * The number of frequencies to get.
71 * The number of available frequencies.
73 uint32_t power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
77 * Return the current index of available frequencies of a specific lcore. It
78 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
79 * It should be protected outside of this function for threadsafe.
85 * The current index of available frequencies.
87 uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id);
90 * Set the new frequency for a specific lcore by indicating the index of
91 * available frequencies.
92 * It should be protected outside of this function for threadsafe.
97 * The index of available frequencies.
100 * - 1 on success with frequency changed.
101 * - 0 on success without frequency changed.
102 * - Negative on error.
104 int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
107 * Scale up the frequency of a specific lcore according to the available
109 * It should be protected outside of this function for threadsafe.
115 * - 1 on success with frequency changed.
116 * - 0 on success without frequency changed.
117 * - Negative on error.
119 int power_acpi_cpufreq_freq_up(unsigned int lcore_id);
122 * Scale down the frequency of a specific lcore according to the available
124 * It should be protected outside of this function for threadsafe.
130 * - 1 on success with frequency changed.
131 * - 0 on success without frequency changed.
132 * - Negative on error.
134 int power_acpi_cpufreq_freq_down(unsigned int lcore_id);
137 * Scale up the frequency of a specific lcore to the highest according to the
138 * available frequencies.
139 * It should be protected outside of this function for threadsafe.
145 * - 1 on success with frequency changed.
146 * - 0 on success without frequency changed.
147 * - Negative on error.
149 int power_acpi_cpufreq_freq_max(unsigned int lcore_id);
152 * Scale down the frequency of a specific lcore to the lowest according to the
153 * available frequencies.
154 * It should be protected outside of this function for threadsafe.
160 * - 1 on success with frequency changed.
161 * - 0 on success without frequency changed.
162 * - Negative on error.
164 int power_acpi_cpufreq_freq_min(unsigned int lcore_id);
167 * Get the turbo status of a specific lcore.
168 * It should be protected outside of this function for threadsafe.
174 * - 1 Turbo Boost is enabled on this lcore.
175 * - 0 Turbo Boost is disabled on this lcore.
176 * - Negative on error.
178 int power_acpi_turbo_status(unsigned int lcore_id);
181 * Enable Turbo Boost on a specific lcore.
182 * It should be protected outside of this function for threadsafe.
188 * - 0 Turbo Boost is enabled successfully on this lcore.
189 * - Negative on error.
191 int power_acpi_enable_turbo(unsigned int lcore_id);
194 * Disable Turbo Boost on a specific lcore.
195 * It should be protected outside of this function for threadsafe.
201 * - 0 Turbo Boost disabled successfully on this lcore.
202 * - Negative on error.
204 int power_acpi_disable_turbo(unsigned int lcore_id);
207 * Returns power capabilities for a specific lcore.
212 * pointer to rte_power_core_capabilities object.
216 * - Negative on error.
218 int power_acpi_get_capabilities(unsigned int lcore_id,
219 struct rte_power_core_capabilities *caps);