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"
25 * Check if CPPC power management is supported.
30 * - -1 if error, with rte_errno indicating reason for error.
32 int power_cppc_cpufreq_check_supported(void);
35 * Initialize power management for a specific lcore. It will check and set the
36 * governor to userspace for the lcore, get the available frequencies, and
37 * prepare to set new lcore frequency.
44 * - Negative on error.
46 int power_cppc_cpufreq_init(unsigned int lcore_id);
49 * Exit power management on a specific lcore. It will set the governor to which
50 * is before initialized.
57 * - Negative on error.
59 int power_cppc_cpufreq_exit(unsigned int lcore_id);
62 * Get the available frequencies of a specific lcore. The return value will be
63 * the minimal one of the total number of available frequencies and the number
64 * of buffer. The index of available frequencies used in other interfaces
65 * should be in the range of 0 to this return value.
66 * It should be protected outside of this function for threadsafe.
71 * The buffer array to save the frequencies.
73 * The number of frequencies to get.
76 * The number of available frequencies.
78 uint32_t power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
82 * Return the current index of available frequencies of a specific lcore. It
83 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
84 * It should be protected outside of this function for threadsafe.
90 * The current index of available frequencies.
92 uint32_t power_cppc_cpufreq_get_freq(unsigned int lcore_id);
95 * Set the new frequency for a specific lcore by indicating the index of
96 * available frequencies.
97 * It should be protected outside of this function for threadsafe.
102 * The index of available frequencies.
105 * - 1 on success with frequency changed.
106 * - 0 on success without frequency changed.
107 * - Negative on error.
109 int power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
112 * Scale up the frequency of a specific lcore according to the available
114 * It should be protected outside of this function for threadsafe.
120 * - 1 on success with frequency changed.
121 * - 0 on success without frequency changed.
122 * - Negative on error.
124 int power_cppc_cpufreq_freq_up(unsigned int lcore_id);
127 * Scale down the frequency of a specific lcore according to the available
129 * It should be protected outside of this function for threadsafe.
135 * - 1 on success with frequency changed.
136 * - 0 on success without frequency changed.
137 * - Negative on error.
139 int power_cppc_cpufreq_freq_down(unsigned int lcore_id);
142 * Scale up the frequency of a specific lcore to the highest according to the
143 * available frequencies.
144 * It should be protected outside of this function for threadsafe.
150 * - 1 on success with frequency changed.
151 * - 0 on success without frequency changed.
152 * - Negative on error.
154 int power_cppc_cpufreq_freq_max(unsigned int lcore_id);
157 * Scale down the frequency of a specific lcore to the lowest according to the
158 * available frequencies.
159 * It should be protected outside of this function for threadsafe.
165 * - 1 on success with frequency changed.
166 * - 0 on success without frequency changed.
167 * - Negative on error.
169 int power_cppc_cpufreq_freq_min(unsigned int lcore_id);
172 * Get the turbo status of a specific lcore.
173 * It should be protected outside of this function for threadsafe.
179 * - 1 Turbo Boost is enabled on this lcore.
180 * - 0 Turbo Boost is disabled on this lcore.
181 * - Negative on error.
183 int power_cppc_turbo_status(unsigned int lcore_id);
186 * Enable Turbo Boost on a specific lcore.
187 * It should be protected outside of this function for threadsafe.
193 * - 0 Turbo Boost is enabled successfully on this lcore.
194 * - Negative on error.
196 int power_cppc_enable_turbo(unsigned int lcore_id);
199 * Disable Turbo Boost on a specific lcore.
200 * It should be protected outside of this function for threadsafe.
206 * - 0 Turbo Boost disabled successfully on this lcore.
207 * - Negative on error.
209 int power_cppc_disable_turbo(unsigned int lcore_id);
212 * Returns power capabilities for a specific lcore.
217 * pointer to rte_power_core_capabilities object.
221 * - Negative on error.
223 int power_cppc_get_capabilities(unsigned int lcore_id,
224 struct rte_power_core_capabilities *caps);
230 #endif /* _POWER_CPPC_CPUFREQ_H */