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"
24 * Check if ACPI power management is supported.
29 * - -1 if error, with rte_errno indicating reason for error.
31 int power_acpi_cpufreq_check_supported(void);
34 * Initialize power management for a specific lcore. It will check and set the
35 * governor to userspace for the lcore, get the available frequencies, and
36 * prepare to set new lcore frequency.
43 * - Negative on error.
45 int power_acpi_cpufreq_init(unsigned int lcore_id);
48 * Exit power management on a specific lcore. It will set the governor to which
49 * is before initialized.
56 * - Negative on error.
58 int power_acpi_cpufreq_exit(unsigned int lcore_id);
61 * Get the available frequencies of a specific lcore. The return value will be
62 * the minimal one of the total number of available frequencies and the number
63 * of buffer. The index of available frequencies used in other interfaces
64 * should be in the range of 0 to this return value.
65 * It should be protected outside of this function for threadsafe.
70 * The buffer array to save the frequencies.
72 * The number of frequencies to get.
75 * The number of available frequencies.
77 uint32_t power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
81 * Return the current index of available frequencies of a specific lcore. It
82 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
83 * It should be protected outside of this function for threadsafe.
89 * The current index of available frequencies.
91 uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id);
94 * Set the new frequency for a specific lcore by indicating the index of
95 * available frequencies.
96 * It should be protected outside of this function for threadsafe.
101 * The index of available frequencies.
104 * - 1 on success with frequency changed.
105 * - 0 on success without frequency changed.
106 * - Negative on error.
108 int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
111 * Scale up the frequency of a specific lcore according to the available
113 * It should be protected outside of this function for threadsafe.
119 * - 1 on success with frequency changed.
120 * - 0 on success without frequency changed.
121 * - Negative on error.
123 int power_acpi_cpufreq_freq_up(unsigned int lcore_id);
126 * Scale down the frequency of a specific lcore according to the available
128 * It should be protected outside of this function for threadsafe.
134 * - 1 on success with frequency changed.
135 * - 0 on success without frequency changed.
136 * - Negative on error.
138 int power_acpi_cpufreq_freq_down(unsigned int lcore_id);
141 * Scale up the frequency of a specific lcore to the highest according to the
142 * available frequencies.
143 * It should be protected outside of this function for threadsafe.
149 * - 1 on success with frequency changed.
150 * - 0 on success without frequency changed.
151 * - Negative on error.
153 int power_acpi_cpufreq_freq_max(unsigned int lcore_id);
156 * Scale down the frequency of a specific lcore to the lowest according to the
157 * available frequencies.
158 * It should be protected outside of this function for threadsafe.
164 * - 1 on success with frequency changed.
165 * - 0 on success without frequency changed.
166 * - Negative on error.
168 int power_acpi_cpufreq_freq_min(unsigned int lcore_id);
171 * Get the turbo status of a specific lcore.
172 * It should be protected outside of this function for threadsafe.
178 * - 1 Turbo Boost is enabled on this lcore.
179 * - 0 Turbo Boost is disabled on this lcore.
180 * - Negative on error.
182 int power_acpi_turbo_status(unsigned int lcore_id);
185 * Enable Turbo Boost on a specific lcore.
186 * It should be protected outside of this function for threadsafe.
192 * - 0 Turbo Boost is enabled successfully on this lcore.
193 * - Negative on error.
195 int power_acpi_enable_turbo(unsigned int lcore_id);
198 * Disable Turbo Boost on a specific lcore.
199 * It should be protected outside of this function for threadsafe.
205 * - 0 Turbo Boost disabled successfully on this lcore.
206 * - Negative on error.
208 int power_acpi_disable_turbo(unsigned int lcore_id);
211 * Returns power capabilities for a specific lcore.
216 * pointer to rte_power_core_capabilities object.
220 * - Negative on error.
222 int power_acpi_get_capabilities(unsigned int lcore_id,
223 struct rte_power_core_capabilities *caps);