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

Function power_check_turbo

dpdk/lib/power/power_cppc_cpufreq.c:115–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115static int
116power_check_turbo(struct cppc_power_info *pi)
117{
118 FILE *f_nom = NULL, *f_max = NULL, *f_cmax = NULL;
119 int ret = -1;
120 uint32_t nominal_perf = 0, highest_perf = 0, cpuinfo_max_freq = 0;
121
122 open_core_sysfs_file(&f_max, "r", POWER_SYSFILE_HIGHEST_PERF,
123 pi->lcore_id);
124 if (f_max == NULL) {
125 RTE_LOG(ERR, POWER, "failed to open %s\n",
126 POWER_SYSFILE_HIGHEST_PERF);
127 goto err;
128 }
129
130 open_core_sysfs_file(&f_nom, "r", POWER_SYSFILE_NOMINAL_PERF,
131 pi->lcore_id);
132 if (f_nom == NULL) {
133 RTE_LOG(ERR, POWER, "failed to open %s\n",
134 POWER_SYSFILE_NOMINAL_PERF);
135 goto err;
136 }
137
138 open_core_sysfs_file(&f_cmax, "r", POWER_SYSFILE_SYS_MAX,
139 pi->lcore_id);
140 if (f_cmax == NULL) {
141 RTE_LOG(ERR, POWER, "failed to open %s\n",
142 POWER_SYSFILE_SYS_MAX);
143 goto err;
144 }
145
146 ret = read_core_sysfs_u32(f_max, &highest_perf);
147 if (ret < 0) {
148 RTE_LOG(ERR, POWER, "Failed to read %s\n",
149 POWER_SYSFILE_HIGHEST_PERF);
150 goto err;
151 }
152
153 ret = read_core_sysfs_u32(f_nom, &nominal_perf);
154 if (ret < 0) {
155 RTE_LOG(ERR, POWER, "Failed to read %s\n",
156 POWER_SYSFILE_NOMINAL_PERF);
157 goto err;
158 }
159
160 ret = read_core_sysfs_u32(f_cmax, &cpuinfo_max_freq);
161 if (ret < 0) {
162 RTE_LOG(ERR, POWER, "Failed to read %s\n",
163 POWER_SYSFILE_SYS_MAX);
164 goto err;
165 }
166
167 pi->highest_perf = highest_perf;
168 pi->nominal_perf = nominal_perf;
169
170 if ((highest_perf > nominal_perf) && ((cpuinfo_max_freq == highest_perf)
171 || cpuinfo_max_freq == highest_perf * UNIT_DIFF)) {
172 pi->turbo_available = 1;

Callers 1

Calls 2

open_core_sysfs_fileFunction · 0.85
read_core_sysfs_u32Function · 0.85

Tested by

no test coverage detected