1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef POWER_MANAGER_H_
6 #define POWER_MANAGER_H_
12 #define FREQ_WINDOW_SIZE 32
21 uint64_t last_branches;
22 uint64_t last_branch_misses;
23 uint16_t global_enabled_cpus;
26 uint16_t freq_directions[FREQ_WINDOW_SIZE];
27 uint16_t freq_window_idx;
29 float branch_ratio_threshold;
34 struct core_details *cd;
37 #define BRANCH_RATIO_THRESHOLD 0.1
45 #define RTE_LOGTYPE_POWER_MANAGER RTE_LOGTYPE_USER1
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);
54 * - Negative on error.
56 int power_manager_init(void);
59 * Exit power management. Must be called prior to exiting the application.
63 * - Negative on error.
65 int power_manager_exit(void);
68 * Scale up the frequency of the cores specified in core_mask.
72 * The uint64_t bit-mask of cores to change frequency.
76 * - Negative on error.
78 int power_manager_scale_mask_up(uint64_t core_mask);
81 * Scale down the frequency of the cores specified in core_mask.
85 * The uint64_t bit-mask of cores to change frequency.
89 * - Negative on error.
91 int power_manager_scale_mask_down(uint64_t core_mask);
94 * Scale to the minimum frequency of the cores specified in core_mask.
98 * The uint64_t bit-mask of cores to change frequency.
102 * - Negative on error.
104 int power_manager_scale_mask_min(uint64_t core_mask);
107 * Scale to the maximum frequency of the cores specified in core_mask.
111 * The uint64_t bit-mask of cores to change frequency.
115 * - Negative on error.
117 int power_manager_scale_mask_max(uint64_t core_mask);
120 * Enable Turbo Boost on the cores specified in core_mask.
124 * The uint64_t bit-mask of cores to change frequency.
128 * - Negative on error.
130 int power_manager_enable_turbo_mask(uint64_t core_mask);
133 * Disable Turbo Boost on the cores specified in core_mask.
137 * The uint64_t bit-mask of cores to change frequency.
141 * - Negative on error.
143 int power_manager_disable_turbo_mask(uint64_t core_mask);
146 * Scale up frequency for the core specified by core_num.
150 * The core number to change frequency
154 * - Negative on error.
156 int power_manager_scale_core_up(unsigned core_num);
159 * Scale down frequency for the core specified by core_num.
163 * The core number to change frequency
167 * - 0 if frequency not changed.
168 * - Negative on error.
170 int power_manager_scale_core_down(unsigned core_num);
173 * Scale to minimum frequency for the core specified by core_num.
177 * The core number to change frequency
181 * - 0 if frequency not changed.
182 * - Negative on error.
184 int power_manager_scale_core_min(unsigned core_num);
187 * Scale to maximum frequency for the core specified by core_num.
191 * The core number to change frequency
195 * - 0 if frequency not changed.
196 * - Negative on error.
198 int power_manager_scale_core_max(unsigned core_num);
201 * Enable Turbo Boost for the core specified by core_num.
205 * The core number to boost
209 * - Negative on error.
211 int power_manager_enable_turbo_core(unsigned int core_num);
214 * Disable Turbo Boost for the core specified by core_num.
218 * The core number to boost
222 * - Negative on error.
224 int power_manager_disable_turbo_core(unsigned int core_num);
227 * Get the current freuency of the core specified by core_num
230 * The core number to get the current frequency
234 * - >0 for current frequency.
236 uint32_t power_manager_get_current_frequency(unsigned core_num);
239 * Scale to medium frequency for the core specified by core_num.
243 * The core number to change frequency
247 * - 0 if frequency not changed.
248 * - Negative on error.
250 int power_manager_scale_core_med(unsigned int core_num);
257 #endif /* POWER_MANAGER_H_ */