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_power.h"
17 * Check if CPPC power management is supported.
22 * - -1 if error, with rte_errno indicating reason for error.
24 int power_cppc_cpufreq_check_supported(void);
27 * Initialize power management for a specific lcore. It will check and set the
28 * governor to userspace for the lcore, get the available frequencies, and
29 * prepare to set new lcore frequency.
36 * - Negative on error.
38 int power_cppc_cpufreq_init(unsigned int lcore_id);
41 * Exit power management on a specific lcore. It will set the governor to which
42 * is before initialized.
49 * - Negative on error.
51 int power_cppc_cpufreq_exit(unsigned int lcore_id);
54 * Get the available frequencies of a specific lcore. The return value will be
55 * the minimal one of the total number of available frequencies and the number
56 * of buffer. The index of available frequencies used in other interfaces
57 * should be in the range of 0 to this return value.
58 * It should be protected outside of this function for threadsafe.
63 * The buffer array to save the frequencies.
65 * The number of frequencies to get.
68 * The number of available frequencies.
70 uint32_t power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
74 * Return the current index of available frequencies of a specific lcore. It
75 * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
76 * It should be protected outside of this function for threadsafe.
82 * The current index of available frequencies.
84 uint32_t power_cppc_cpufreq_get_freq(unsigned int lcore_id);
87 * Set the new frequency for a specific lcore by indicating the index of
88 * available frequencies.
89 * It should be protected outside of this function for threadsafe.
94 * The index of available frequencies.
97 * - 1 on success with frequency changed.
98 * - 0 on success without frequency changed.
99 * - Negative on error.
101 int power_cppc_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
104 * Scale up the frequency of a specific lcore according to the available
106 * It should be protected outside of this function for threadsafe.
112 * - 1 on success with frequency changed.
113 * - 0 on success without frequency changed.
114 * - Negative on error.
116 int power_cppc_cpufreq_freq_up(unsigned int lcore_id);
119 * Scale down the frequency of a specific lcore according to the available
121 * It should be protected outside of this function for threadsafe.
127 * - 1 on success with frequency changed.
128 * - 0 on success without frequency changed.
129 * - Negative on error.
131 int power_cppc_cpufreq_freq_down(unsigned int lcore_id);
134 * Scale up the frequency of a specific lcore to the highest according to the
135 * available frequencies.
136 * It should be protected outside of this function for threadsafe.
142 * - 1 on success with frequency changed.
143 * - 0 on success without frequency changed.
144 * - Negative on error.
146 int power_cppc_cpufreq_freq_max(unsigned int lcore_id);
149 * Scale down the frequency of a specific lcore to the lowest according to the
150 * available frequencies.
151 * It should be protected outside of this function for threadsafe.
157 * - 1 on success with frequency changed.
158 * - 0 on success without frequency changed.
159 * - Negative on error.
161 int power_cppc_cpufreq_freq_min(unsigned int lcore_id);
164 * Get the turbo status of a specific lcore.
165 * It should be protected outside of this function for threadsafe.
171 * - 1 Turbo Boost is enabled on this lcore.
172 * - 0 Turbo Boost is disabled on this lcore.
173 * - Negative on error.
175 int power_cppc_turbo_status(unsigned int lcore_id);
178 * Enable Turbo Boost on a specific lcore.
179 * It should be protected outside of this function for threadsafe.
185 * - 0 Turbo Boost is enabled successfully on this lcore.
186 * - Negative on error.
188 int power_cppc_enable_turbo(unsigned int lcore_id);
191 * Disable Turbo Boost on a specific lcore.
192 * It should be protected outside of this function for threadsafe.
198 * - 0 Turbo Boost disabled successfully on this lcore.
199 * - Negative on error.
201 int power_cppc_disable_turbo(unsigned int lcore_id);
204 * Returns power capabilities for a specific lcore.
209 * pointer to rte_power_core_capabilities object.
213 * - Negative on error.
215 int power_cppc_get_capabilities(unsigned int lcore_id,
216 struct rte_power_core_capabilities *caps);
218 #endif /* _POWER_CPPC_CPUFREQ_H */