MCPcopy Create free account
hub / github.com/F-Stack/f-stack / power_get_available_freqs

Function power_get_available_freqs

dpdk/lib/power/power_cppc_cpufreq.c:201–278  ·  view source on GitHub ↗

* It is to get the available frequencies of the specific lcore by reading the * sys file. */

Source from the content-addressed store, hash-verified

199 * sys file.
200 */
201static int
202power_get_available_freqs(struct cppc_power_info *pi)
203{
204 FILE *f_min = NULL, *f_max = NULL;
205 int ret = -1;
206 uint32_t scaling_min_freq = 0, scaling_max_freq = 0, nominal_perf = 0;
207 uint32_t i, num_freqs = 0;
208
209 open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_SCALING_MAX_FREQ,
210 pi->lcore_id);
211 if (f_max == NULL) {
212 RTE_LOG(ERR, POWER, "failed to open %s\n",
213 POWER_SYSFILE_SCALING_MAX_FREQ);
214 goto out;
215 }
216
217 open_core_sysfs_file(&f_min, "r", POWER_SYSFILE_SCALING_MIN_FREQ,
218 pi->lcore_id);
219 if (f_min == NULL) {
220 RTE_LOG(ERR, POWER, "failed to open %s\n",
221 POWER_SYSFILE_SCALING_MIN_FREQ);
222 goto out;
223 }
224
225 ret = read_core_sysfs_u32(f_max, &scaling_max_freq);
226 if (ret < 0) {
227 RTE_LOG(ERR, POWER, "Failed to read %s\n",
228 POWER_SYSFILE_SCALING_MAX_FREQ);
229 goto out;
230 }
231
232 ret = read_core_sysfs_u32(f_min, &scaling_min_freq);
233 if (ret < 0) {
234 RTE_LOG(ERR, POWER, "Failed to read %s\n",
235 POWER_SYSFILE_SCALING_MIN_FREQ);
236 goto out;
237 }
238
239 power_check_turbo(pi);
240
241 if (scaling_max_freq < scaling_min_freq)
242 goto out;
243
244 /* If turbo is available then there is one extra freq bucket
245 * to store the sys max freq which value is scaling_max_freq
246 */
247 nominal_perf = (pi->nominal_perf < UNIT_DIFF) ?
248 pi->nominal_perf * UNIT_DIFF : pi->nominal_perf;
249 num_freqs = (nominal_perf - scaling_min_freq) / BUS_FREQ + 1 +
250 pi->turbo_available;
251 if (num_freqs >= RTE_MAX_LCORE_FREQS) {
252 RTE_LOG(ERR, POWER, "Too many available frequencies: %d\n",
253 num_freqs);
254 goto out;
255 }
256
257 /* Generate the freq bucket array. */
258 for (i = 0, pi->nb_freqs = 0; i < num_freqs; i++) {

Callers 1

power_cppc_cpufreq_initFunction · 0.70

Calls 3

open_core_sysfs_fileFunction · 0.85
read_core_sysfs_u32Function · 0.85
power_check_turboFunction · 0.70

Tested by

no test coverage detected