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>
23 * Initialize power management for a specific lcore. It will check and set the
24 * governor to userspace for the lcore, get the available frequencies, and
25 * prepare to set new lcore frequency.
32 * - Negative on error.
34 int power_acpi_cpufreq_init(unsigned int lcore_id);
37 * Exit power management on a specific lcore. It will set the governor to which
38 * is before initialized.
45 * - Negative on error.
47 int power_acpi_cpufreq_exit(unsigned int lcore_id);
50 * Get the available frequencies of a specific lcore. The return value will be
51 * the minimal one of the total number of available frequencies and the number
52 * of buffer. The index of available frequencies used in other interfaces
53 * should be in the range of 0 to this return value.
54 * It should be protected outside of this function for threadsafe.
59 * The buffer array to save the frequencies.
61 * The number of frequencies to get.
64 * The number of available frequencies.
66 uint32_t power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
70 * Return the current index of available frequencies of a specific lcore. It
71 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
72 * It should be protected outside of this function for threadsafe.
78 * The current index of available frequencies.
80 uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id);
83 * Set the new frequency for a specific lcore by indicating the index of
84 * available frequencies.
85 * It should be protected outside of this function for threadsafe.
90 * The index of available frequencies.
93 * - 1 on success with frequency changed.
94 * - 0 on success without frequency changed.
95 * - Negative on error.
97 int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
100 * Scale up the frequency of a specific lcore according to the available
102 * It should be protected outside of this function for threadsafe.
108 * - 1 on success with frequency changed.
109 * - 0 on success without frequency changed.
110 * - Negative on error.
112 int power_acpi_cpufreq_freq_up(unsigned int lcore_id);
115 * Scale down the frequency of a specific lcore according to the available
117 * It should be protected outside of this function for threadsafe.
123 * - 1 on success with frequency changed.
124 * - 0 on success without frequency changed.
125 * - Negative on error.
127 int power_acpi_cpufreq_freq_down(unsigned int lcore_id);
130 * Scale up the frequency of a specific lcore to the highest according to the
131 * available frequencies.
132 * It should be protected outside of this function for threadsafe.
138 * - 1 on success with frequency changed.
139 * - 0 on success without frequency changed.
140 * - Negative on error.
142 int power_acpi_cpufreq_freq_max(unsigned int lcore_id);
145 * Scale down the frequency of a specific lcore to the lowest according to the
146 * available frequencies.
147 * It should be protected outside of this function for threadsafe.
153 * - 1 on success with frequency changed.
154 * - 0 on success without frequency changed.
155 * - Negative on error.
157 int power_acpi_cpufreq_freq_min(unsigned int lcore_id);
160 * Get the turbo status of a specific lcore.
161 * It should be protected outside of this function for threadsafe.
167 * - 1 Turbo Boost is enabled on this lcore.
168 * - 0 Turbo Boost is disabled on this lcore.
169 * - Negative on error.
171 int power_acpi_turbo_status(unsigned int lcore_id);
174 * Enable Turbo Boost on a specific lcore.
175 * It should be protected outside of this function for threadsafe.
181 * - 0 Turbo Boost is enabled successfully on this lcore.
182 * - Negative on error.
184 int power_acpi_enable_turbo(unsigned int lcore_id);
187 * Disable Turbo Boost on a specific lcore.
188 * It should be protected outside of this function for threadsafe.
194 * - 0 Turbo Boost disabled successfully on this lcore.
195 * - Negative on error.
197 int power_acpi_disable_turbo(unsigned int lcore_id);