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