lib: remove unneeded header includes
[dpdk.git] / lib / power / power_acpi_cpufreq.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _POWER_ACPI_CPUFREQ_H
6 #define _POWER_ACPI_CPUFREQ_H
7
8 /**
9  * @file
10  * RTE Power Management via userspace ACPI cpufreq
11  */
12
13 #include "rte_power.h"
14
15 /**
16  * Check if ACPI power management is supported.
17  *
18  * @return
19  *   - 1 if supported
20  *   - 0 if unsupported
21  *   - -1 if error, with rte_errno indicating reason for error.
22  */
23 int power_acpi_cpufreq_check_supported(void);
24
25 /**
26  * Initialize power management for a specific lcore. It will check and set the
27  * governor to userspace for the lcore, get the available frequencies, and
28  * prepare to set new lcore frequency.
29  *
30  * @param lcore_id
31  *  lcore id.
32  *
33  * @return
34  *  - 0 on success.
35  *  - Negative on error.
36  */
37 int power_acpi_cpufreq_init(unsigned int lcore_id);
38
39 /**
40  * Exit power management on a specific lcore. It will set the governor to which
41  * is before initialized.
42  *
43  * @param lcore_id
44  *  lcore id.
45  *
46  * @return
47  *  - 0 on success.
48  *  - Negative on error.
49  */
50 int power_acpi_cpufreq_exit(unsigned int lcore_id);
51
52 /**
53  * Get the available frequencies of a specific lcore. The return value will be
54  * the minimal one of the total number of available frequencies and the number
55  * of buffer. The index of available frequencies used in other interfaces
56  * should be in the range of 0 to this return value.
57  * It should be protected outside of this function for threadsafe.
58  *
59  * @param lcore_id
60  *  lcore id.
61  * @param freqs
62  *  The buffer array to save the frequencies.
63  * @param num
64  *  The number of frequencies to get.
65  *
66  * @return
67  *  The number of available frequencies.
68  */
69 uint32_t power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs,
70                 uint32_t num);
71
72 /**
73  * Return the current index of available frequencies of a specific lcore. It
74  * will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)' if error.
75  * It should be protected outside of this function for threadsafe.
76  *
77  * @param lcore_id
78  *  lcore id.
79  *
80  * @return
81  *  The current index of available frequencies.
82  */
83 uint32_t power_acpi_cpufreq_get_freq(unsigned int lcore_id);
84
85 /**
86  * Set the new frequency for a specific lcore by indicating the index of
87  * available frequencies.
88  * It should be protected outside of this function for threadsafe.
89  *
90  * @param lcore_id
91  *  lcore id.
92  * @param index
93  *  The index of available frequencies.
94  *
95  * @return
96  *  - 1 on success with frequency changed.
97  *  - 0 on success without frequency changed.
98  *  - Negative on error.
99  */
100 int power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index);
101
102 /**
103  * Scale up the frequency of a specific lcore according to the available
104  * frequencies.
105  * It should be protected outside of this function for threadsafe.
106  *
107  * @param lcore_id
108  *  lcore id.
109  *
110  * @return
111  *  - 1 on success with frequency changed.
112  *  - 0 on success without frequency changed.
113  *  - Negative on error.
114  */
115 int power_acpi_cpufreq_freq_up(unsigned int lcore_id);
116
117 /**
118  * Scale down the frequency of a specific lcore according to the available
119  * frequencies.
120  * It should be protected outside of this function for threadsafe.
121  *
122  * @param lcore_id
123  *  lcore id.
124  *
125  * @return
126  *  - 1 on success with frequency changed.
127  *  - 0 on success without frequency changed.
128  *  - Negative on error.
129  */
130 int power_acpi_cpufreq_freq_down(unsigned int lcore_id);
131
132 /**
133  * Scale up the frequency of a specific lcore to the highest according to the
134  * available frequencies.
135  * It should be protected outside of this function for threadsafe.
136  *
137  * @param lcore_id
138  *  lcore id.
139  *
140  * @return
141  *  - 1 on success with frequency changed.
142  *  - 0 on success without frequency changed.
143  *  - Negative on error.
144  */
145 int power_acpi_cpufreq_freq_max(unsigned int lcore_id);
146
147 /**
148  * Scale down the frequency of a specific lcore to the lowest according to the
149  * available frequencies.
150  * It should be protected outside of this function for threadsafe.
151  *
152  * @param lcore_id
153  *  lcore id.
154  *
155  * @return
156  *  - 1 on success with frequency changed.
157  *  - 0 on success without frequency changed.
158  *  - Negative on error.
159  */
160 int power_acpi_cpufreq_freq_min(unsigned int lcore_id);
161
162 /**
163  * Get the turbo status of a specific lcore.
164  * It should be protected outside of this function for threadsafe.
165  *
166  * @param lcore_id
167  *  lcore id.
168  *
169  * @return
170  *  - 1 Turbo Boost is enabled on this lcore.
171  *  - 0 Turbo Boost is disabled on this lcore.
172  *  - Negative on error.
173  */
174 int power_acpi_turbo_status(unsigned int lcore_id);
175
176 /**
177  * Enable Turbo Boost on a specific lcore.
178  * It should be protected outside of this function for threadsafe.
179  *
180  * @param lcore_id
181  *  lcore id.
182  *
183  * @return
184  *  - 0 Turbo Boost is enabled successfully on this lcore.
185  *  - Negative on error.
186  */
187 int power_acpi_enable_turbo(unsigned int lcore_id);
188
189 /**
190  * Disable Turbo Boost on a specific lcore.
191  * It should be protected outside of this function for threadsafe.
192  *
193  * @param lcore_id
194  *  lcore id.
195  *
196  * @return
197  *  - 0 Turbo Boost disabled successfully on this lcore.
198  *  - Negative on error.
199  */
200 int power_acpi_disable_turbo(unsigned int lcore_id);
201
202 /**
203  * Returns power capabilities for a specific lcore.
204  *
205  * @param lcore_id
206  *  lcore id.
207  * @param caps
208  *  pointer to rte_power_core_capabilities object.
209  *
210  * @return
211  *  - 0 on success.
212  *  - Negative on error.
213  */
214 int power_acpi_get_capabilities(unsigned int lcore_id,
215                 struct rte_power_core_capabilities *caps);
216
217 #endif