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