]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/examples/vm_power_manager/power_manager.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / 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 #define FREQ_WINDOW_SIZE 32
13
14 enum {
15 FREQ_UNKNOWN,
16 FREQ_MIN,
17 FREQ_MAX
18 };
19
20 struct core_details {
21 uint64_t last_branches;
22 uint64_t last_branch_misses;
23 uint16_t global_enabled_cpus;
24 uint16_t oob_enabled;
25 int msr_fd;
26 uint16_t freq_directions[FREQ_WINDOW_SIZE];
27 uint16_t freq_window_idx;
28 uint16_t freq_state;
29 };
30
31 struct core_info {
32 uint16_t core_count;
33 struct core_details *cd;
34 float branch_ratio_threshold;
35 };
36
37 #define BRANCH_RATIO_THRESHOLD 0.1
38
39 struct core_info *
40 get_core_info(void);
41
42 int
43 core_info_init(void);
44
45 #define RTE_LOGTYPE_POWER_MANAGER RTE_LOGTYPE_USER1
46
47 /**
48 * Initialize power management.
49 * Initializes resources and verifies the number of CPUs on the system.
50 * Wraps librte_power int rte_power_init(unsigned lcore_id);
51 *
52 * @return
53 * - 0 on success.
54 * - Negative on error.
55 */
56 int power_manager_init(void);
57
58 /**
59 * Exit power management. Must be called prior to exiting the application.
60 *
61 * @return
62 * - 0 on success.
63 * - Negative on error.
64 */
65 int power_manager_exit(void);
66
67 /**
68 * Scale up the frequency of the cores specified in core_mask.
69 * It is thread-safe.
70 *
71 * @param core_mask
72 * The uint64_t bit-mask of cores to change frequency.
73 *
74 * @return
75 * - 1 on success.
76 * - Negative on error.
77 */
78 int power_manager_scale_mask_up(uint64_t core_mask);
79
80 /**
81 * Scale down the frequency of the cores specified in core_mask.
82 * It is thread-safe.
83 *
84 * @param core_mask
85 * The uint64_t bit-mask of cores to change frequency.
86 *
87 * @return
88 * - 1 on success.
89 * - Negative on error.
90 */
91 int power_manager_scale_mask_down(uint64_t core_mask);
92
93 /**
94 * Scale to the minimum frequency of the cores specified in core_mask.
95 * It is thread-safe.
96 *
97 * @param core_mask
98 * The uint64_t bit-mask of cores to change frequency.
99 *
100 * @return
101 * - 1 on success.
102 * - Negative on error.
103 */
104 int power_manager_scale_mask_min(uint64_t core_mask);
105
106 /**
107 * Scale to the maximum frequency of the cores specified in core_mask.
108 * It is thread-safe.
109 *
110 * @param core_mask
111 * The uint64_t bit-mask of cores to change frequency.
112 *
113 * @return
114 * - 1 on success.
115 * - Negative on error.
116 */
117 int power_manager_scale_mask_max(uint64_t core_mask);
118
119 /**
120 * Enable Turbo Boost on the cores specified in core_mask.
121 * It is thread-safe.
122 *
123 * @param core_mask
124 * The uint64_t bit-mask of cores to change frequency.
125 *
126 * @return
127 * - 1 on success.
128 * - Negative on error.
129 */
130 int power_manager_enable_turbo_mask(uint64_t core_mask);
131
132 /**
133 * Disable Turbo Boost on the cores specified in core_mask.
134 * It is thread-safe.
135 *
136 * @param core_mask
137 * The uint64_t bit-mask of cores to change frequency.
138 *
139 * @return
140 * - 1 on success.
141 * - Negative on error.
142 */
143 int power_manager_disable_turbo_mask(uint64_t core_mask);
144
145 /**
146 * Scale up frequency for the core specified by core_num.
147 * It is thread-safe.
148 *
149 * @param core_num
150 * The core number to change frequency
151 *
152 * @return
153 * - 1 on success.
154 * - Negative on error.
155 */
156 int power_manager_scale_core_up(unsigned core_num);
157
158 /**
159 * Scale down frequency for the core specified by core_num.
160 * It is thread-safe.
161 *
162 * @param core_num
163 * The core number to change frequency
164 *
165 * @return
166 * - 1 on success.
167 * - 0 if frequency not changed.
168 * - Negative on error.
169 */
170 int power_manager_scale_core_down(unsigned core_num);
171
172 /**
173 * Scale to minimum frequency for the core specified by core_num.
174 * It is thread-safe.
175 *
176 * @param core_num
177 * The core number to change frequency
178 *
179 * @return
180 * - 1 on success.
181 * - 0 if frequency not changed.
182 * - Negative on error.
183 */
184 int power_manager_scale_core_min(unsigned core_num);
185
186 /**
187 * Scale to maximum frequency for the core specified by core_num.
188 * It is thread-safe.
189 *
190 * @param core_num
191 * The core number to change frequency
192 *
193 * @return
194 * - 1 on success.
195 * - 0 if frequency not changed.
196 * - Negative on error.
197 */
198 int power_manager_scale_core_max(unsigned core_num);
199
200 /**
201 * Enable Turbo Boost for the core specified by core_num.
202 * It is thread-safe.
203 *
204 * @param core_num
205 * The core number to boost
206 *
207 * @return
208 * - 1 on success.
209 * - Negative on error.
210 */
211 int power_manager_enable_turbo_core(unsigned int core_num);
212
213 /**
214 * Disable Turbo Boost for the core specified by core_num.
215 * It is thread-safe.
216 *
217 * @param core_num
218 * The core number to boost
219 *
220 * @return
221 * - 1 on success.
222 * - Negative on error.
223 */
224 int power_manager_disable_turbo_core(unsigned int core_num);
225
226 /**
227 * Get the current freuency of the core specified by core_num
228 *
229 * @param core_num
230 * The core number to get the current frequency
231 *
232 * @return
233 * - 0 on error
234 * - >0 for current frequency.
235 */
236 uint32_t power_manager_get_current_frequency(unsigned core_num);
237
238 /**
239 * Scale to medium frequency for the core specified by core_num.
240 * It is thread-safe.
241 *
242 * @param core_num
243 * The core number to change frequency
244 *
245 * @return
246 * - 1 on success.
247 * - 0 if frequency not changed.
248 * - Negative on error.
249 */
250 int power_manager_scale_core_med(unsigned int core_num);
251
252 #ifdef __cplusplus
253 }
254 #endif
255
256
257 #endif /* POWER_MANAGER_H_ */