New upstream version 18.02
[deb_dpdk.git] / examples / vm_power_manager / power_manager.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef POWER_MANAGER_H_
6 #define POWER_MANAGER_H_
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /* Maximum number of CPUS to manage */
13 #define POWER_MGR_MAX_CPUS 64
14 /**
15  * Initialize power management.
16  * Initializes resources and verifies the number of CPUs on the system.
17  * Wraps librte_power int rte_power_init(unsigned lcore_id);
18  *
19  * @return
20  *  - 0 on success.
21  *  - Negative on error.
22  */
23 int power_manager_init(void);
24
25 /**
26  * Exit power management. Must be called prior to exiting the application.
27  *
28  * @return
29  *  - 0 on success.
30  *  - Negative on error.
31  */
32 int power_manager_exit(void);
33
34 /**
35  * Scale up the frequency of the cores specified in core_mask.
36  * It is thread-safe.
37  *
38  * @param core_mask
39  *  The uint64_t bit-mask of cores to change frequency.
40  *
41  * @return
42  *  - 1 on success.
43  *  - Negative on error.
44  */
45 int power_manager_scale_mask_up(uint64_t core_mask);
46
47 /**
48  * Scale down the frequency of the cores specified in core_mask.
49  * It is thread-safe.
50  *
51  * @param core_mask
52  *  The uint64_t bit-mask of cores to change frequency.
53  *
54  * @return
55  *  - 1 on success.
56  *  - Negative on error.
57  */
58 int power_manager_scale_mask_down(uint64_t core_mask);
59
60 /**
61  * Scale to the minimum frequency of the cores specified in core_mask.
62  * It is thread-safe.
63  *
64  * @param core_mask
65  *  The uint64_t bit-mask of cores to change frequency.
66  *
67  * @return
68  *  - 1 on success.
69  *  - Negative on error.
70  */
71 int power_manager_scale_mask_min(uint64_t core_mask);
72
73 /**
74  * Scale to the maximum frequency of the cores specified in core_mask.
75  * It is thread-safe.
76  *
77  * @param core_mask
78  *  The uint64_t bit-mask of cores to change frequency.
79  *
80  * @return
81  *  - 1 on success.
82  *  - Negative on error.
83  */
84 int power_manager_scale_mask_max(uint64_t core_mask);
85
86 /**
87  * Enable Turbo Boost on the cores specified in core_mask.
88  * It is thread-safe.
89  *
90  * @param core_mask
91  *  The uint64_t bit-mask of cores to change frequency.
92  *
93  * @return
94  *  - 1 on success.
95  *  - Negative on error.
96  */
97 int power_manager_enable_turbo_mask(uint64_t core_mask);
98
99 /**
100  * Disable Turbo Boost on the cores specified in core_mask.
101  * It is thread-safe.
102  *
103  * @param core_mask
104  *  The uint64_t bit-mask of cores to change frequency.
105  *
106  * @return
107  *  - 1 on success.
108  *  - Negative on error.
109  */
110 int power_manager_disable_turbo_mask(uint64_t core_mask);
111
112 /**
113  * Scale up frequency for the core specified by core_num.
114  * It is thread-safe.
115  *
116  * @param core_num
117  *  The core number to change frequency
118  *
119  * @return
120  *  - 1 on success.
121  *  - Negative on error.
122  */
123 int power_manager_scale_core_up(unsigned core_num);
124
125 /**
126  * Scale down frequency for the core specified by core_num.
127  * It is thread-safe.
128  *
129  * @param core_num
130  *  The core number to change frequency
131  *
132  * @return
133  *  - 1 on success.
134  *  - 0 if frequency not changed.
135  *  - Negative on error.
136  */
137 int power_manager_scale_core_down(unsigned core_num);
138
139 /**
140  * Scale to minimum frequency for the core specified by core_num.
141  * It is thread-safe.
142  *
143  * @param core_num
144  *  The core number to change frequency
145  *
146  * @return
147  *  - 1 on success.
148  *  - 0 if frequency not changed.
149  *  - Negative on error.
150  */
151 int power_manager_scale_core_min(unsigned core_num);
152
153 /**
154  * Scale to maximum frequency for the core specified by core_num.
155  * It is thread-safe.
156  *
157  * @param core_num
158  *  The core number to change frequency
159  *
160  * @return
161  *  - 1 on success.
162  *  - 0 if frequency not changed.
163  *  - Negative on error.
164  */
165 int power_manager_scale_core_max(unsigned core_num);
166
167 /**
168  * Enable Turbo Boost for the core specified by core_num.
169  * It is thread-safe.
170  *
171  * @param core_num
172  *  The core number to boost
173  *
174  * @return
175  *  - 1 on success.
176  *  - Negative on error.
177  */
178 int power_manager_enable_turbo_core(unsigned int core_num);
179
180 /**
181  * Disable Turbo Boost for the core specified by core_num.
182  * It is thread-safe.
183  *
184  * @param core_num
185  *  The core number to boost
186  *
187  * @return
188  *  - 1 on success.
189  *  - Negative on error.
190  */
191 int power_manager_disable_turbo_core(unsigned int core_num);
192
193 /**
194  * Get the current freuency of the core specified by core_num
195  *
196  * @param core_num
197  *  The core number to get the current frequency
198  *
199  * @return
200  *  - 0  on error
201  *  - >0 for current frequency.
202  */
203 uint32_t power_manager_get_current_frequency(unsigned core_num);
204
205 /**
206  * Scale to medium frequency for the core specified by core_num.
207  * It is thread-safe.
208  *
209  * @param core_num
210  *  The core number to change frequency
211  *
212  * @return
213  *  - 1 on success.
214  *  - 0 if frequency not changed.
215  *  - Negative on error.
216  */
217 int power_manager_scale_core_med(unsigned int core_num);
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223
224 #endif /* POWER_MANAGER_H_ */