1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _POWER_PSTATE_CPUFREQ_H
6 #define _POWER_PSTATE_CPUFREQ_H
10 * RTE Power Management via Intel Pstate driver
13 #include <rte_common.h>
14 #include <rte_byteorder.h>
16 #include <rte_string_fns.h>
17 #include "rte_power.h"
24 * Initialize power management for a specific lcore. It will check and set the
25 * governor to performance for the lcore, get the available frequencies, and
26 * prepare to set new lcore frequency.
33 * - Negative on error.
35 int power_pstate_cpufreq_init(unsigned int lcore_id);
38 * Exit power management on a specific lcore. It will set the governor to which
39 * is before initialized.
46 * - Negative on error.
48 int power_pstate_cpufreq_exit(unsigned int lcore_id);
51 * Get the available frequencies of a specific lcore. The return value will be
52 * the minimal one of the total number of available frequencies and the number
53 * of buffer. The index of available frequencies used in other interfaces
54 * should be in the range of 0 to this return value.
55 * It should be protected outside of this function for threadsafe.
60 * The buffer array to save the frequencies.
62 * The number of frequencies to get.
65 * The number of available frequencies.
67 uint32_t power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
71 * Return the current index of available frequencies of a specific lcore.
72 * It should be protected outside of this function for threadsafe.
78 * The current index of available frequencies.
79 * If error, it will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)'.
81 uint32_t power_pstate_cpufreq_get_freq(unsigned int lcore_id);
84 * Set the new frequency for a specific lcore by indicating the index of
85 * available frequencies.
86 * It should be protected outside of this function for threadsafe.
91 * The index of available frequencies.
94 * - 1 on success with frequency changed.
95 * - 0 on success without frequency changed.
96 * - Negative on error.
98 int power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
101 * Scale up the frequency of a specific lcore according to the available
103 * It should be protected outside of this function for threadsafe.
109 * - 1 on success with frequency changed.
110 * - 0 on success without frequency changed.
111 * - Negative on error.
113 int power_pstate_cpufreq_freq_up(unsigned int lcore_id);
116 * Scale down the frequency of a specific lcore according to the available
118 * It should be protected outside of this function for threadsafe.
124 * - 1 on success with frequency changed.
125 * - 0 on success without frequency changed.
126 * - Negative on error.
128 int power_pstate_cpufreq_freq_down(unsigned int lcore_id);
131 * Scale up the frequency of a specific lcore to the highest according to the
132 * available frequencies.
133 * It should be protected outside of this function for threadsafe.
139 * - 1 on success with frequency changed.
140 * - 0 on success without frequency changed.
141 * - Negative on error.
143 int power_pstate_cpufreq_freq_max(unsigned int lcore_id);
146 * Scale down the frequency of a specific lcore to the lowest according to the
147 * available frequencies.
148 * It should be protected outside of this function for threadsafe.
154 * - 1 on success with frequency changed.
155 * - 0 on success without frequency changed.
156 * - Negative on error.
158 int power_pstate_cpufreq_freq_min(unsigned int lcore_id);
161 * Get the turbo status of a specific lcore.
162 * It should be protected outside of this function for threadsafe.
168 * - 1 Turbo Boost is enabled on this lcore.
169 * - 0 Turbo Boost is disabled on this lcore.
170 * - Negative on error.
172 int power_pstate_turbo_status(unsigned int lcore_id);
175 * Enable Turbo Boost on a specific lcore.
176 * It should be protected outside of this function for threadsafe.
182 * - 0 Turbo Boost is enabled successfully on this lcore.
183 * - Negative on error.
185 int power_pstate_enable_turbo(unsigned int lcore_id);
188 * Disable Turbo Boost on a specific lcore.
189 * It should be protected outside of this function for threadsafe.
195 * - 0 Turbo Boost disabled successfully on this lcore.
196 * - Negative on error.
198 int power_pstate_disable_turbo(unsigned int lcore_id);
201 * Returns power capabilities for a specific lcore.
206 * pointer to rte_power_core_capabilities object.
210 * - Negative on error.
212 int power_pstate_get_capabilities(unsigned int lcore_id,
213 struct rte_power_core_capabilities *caps);