1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2021 Intel Corporation
3 * Copyright(c) 2021 Arm Limited
6 #ifndef _POWER_CPPC_CPUFREQ_H
7 #define _POWER_CPPC_CPUFREQ_H
11 * RTE Power Management via userspace CPPC cpufreq
14 #include <rte_common.h>
15 #include <rte_byteorder.h>
17 #include <rte_string_fns.h>
18 #include "rte_power.h"
21 * Check if CPPC power management is supported.
26 * - -1 if error, with rte_errno indicating reason for error.
28 int power_cppc_cpufreq_check_supported(void);
31 * Initialize power management for a specific lcore. It will check and set the
32 * governor to userspace for the lcore, get the available frequencies, and
33 * prepare to set new lcore frequency.
40 * - Negative on error.
42 int power_cppc_cpufreq_init(unsigned int lcore_id);
45 * Exit power management on a specific lcore. It will set the governor to which
46 * is before initialized.
53 * - Negative on error.
55 int power_cppc_cpufreq_exit(unsigned int lcore_id);
58 * Get the available frequencies of a specific lcore. The return value will be
59 * the minimal one of the total number of available frequencies and the number
60 * of buffer. The index of available frequencies used in other interfaces
61 * should be in the range of 0 to this return value.
62 * It should be protected outside of this function for threadsafe.
67 * The buffer array to save the frequencies.
69 * The number of frequencies to get.
72 * The number of available frequencies.
74 uint32_t power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
78 * Return the current index of available frequencies of a specific lcore. It
79 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
80 * It should be protected outside of this function for threadsafe.
86 * The current index of available frequencies.
88 uint32_t power_cppc_cpufreq_get_freq(unsigned int lcore_id);
91 * Set the new frequency for a specific lcore by indicating the index of
92 * available frequencies.
93 * It should be protected outside of this function for threadsafe.
98 * The index of available frequencies.
101 * - 1 on success with frequency changed.
102 * - 0 on success without frequency changed.
103 * - Negative on error.
105 int power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
108 * Scale up the frequency of a specific lcore according to the available
110 * It should be protected outside of this function for threadsafe.
116 * - 1 on success with frequency changed.
117 * - 0 on success without frequency changed.
118 * - Negative on error.
120 int power_cppc_cpufreq_freq_up(unsigned int lcore_id);
123 * Scale down the frequency of a specific lcore according to the available
125 * It should be protected outside of this function for threadsafe.
131 * - 1 on success with frequency changed.
132 * - 0 on success without frequency changed.
133 * - Negative on error.
135 int power_cppc_cpufreq_freq_down(unsigned int lcore_id);
138 * Scale up the frequency of a specific lcore to the highest according to the
139 * available frequencies.
140 * It should be protected outside of this function for threadsafe.
146 * - 1 on success with frequency changed.
147 * - 0 on success without frequency changed.
148 * - Negative on error.
150 int power_cppc_cpufreq_freq_max(unsigned int lcore_id);
153 * Scale down the frequency of a specific lcore to the lowest according to the
154 * available frequencies.
155 * It should be protected outside of this function for threadsafe.
161 * - 1 on success with frequency changed.
162 * - 0 on success without frequency changed.
163 * - Negative on error.
165 int power_cppc_cpufreq_freq_min(unsigned int lcore_id);
168 * Get the turbo status of a specific lcore.
169 * It should be protected outside of this function for threadsafe.
175 * - 1 Turbo Boost is enabled on this lcore.
176 * - 0 Turbo Boost is disabled on this lcore.
177 * - Negative on error.
179 int power_cppc_turbo_status(unsigned int lcore_id);
182 * Enable Turbo Boost on a specific lcore.
183 * It should be protected outside of this function for threadsafe.
189 * - 0 Turbo Boost is enabled successfully on this lcore.
190 * - Negative on error.
192 int power_cppc_enable_turbo(unsigned int lcore_id);
195 * Disable Turbo Boost on a specific lcore.
196 * It should be protected outside of this function for threadsafe.
202 * - 0 Turbo Boost disabled successfully on this lcore.
203 * - Negative on error.
205 int power_cppc_disable_turbo(unsigned int lcore_id);
208 * Returns power capabilities for a specific lcore.
213 * pointer to rte_power_core_capabilities object.
217 * - Negative on error.
219 int power_cppc_get_capabilities(unsigned int lcore_id,
220 struct rte_power_core_capabilities *caps);
222 #endif /* _POWER_CPPC_CPUFREQ_H */