1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Intel dynamic_speed_select -- Enumerate and control features
4  * Copyright (c) 2019 Intel Corporation.
5  */
6 
7 #include "isst.h"
8 
9 static void printcpulist(int str_len, char *str, int mask_size,
10 			 cpu_set_t *cpu_mask)
11 {
12 	int i, first, curr_index, index;
13 
14 	if (!CPU_COUNT_S(mask_size, cpu_mask)) {
15 		snprintf(str, str_len, "none");
16 		return;
17 	}
18 
19 	curr_index = 0;
20 	first = 1;
21 	for (i = 0; i < get_topo_max_cpus(); ++i) {
22 		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
23 			continue;
24 		if (!first) {
25 			index = snprintf(&str[curr_index],
26 					 str_len - curr_index, ",");
27 			curr_index += index;
28 		}
29 		index = snprintf(&str[curr_index], str_len - curr_index, "%d",
30 				 i);
31 		curr_index += index;
32 		first = 0;
33 	}
34 }
35 
36 static void printcpumask(int str_len, char *str, int mask_size,
37 			 cpu_set_t *cpu_mask)
38 {
39 	int i, max_cpus = get_topo_max_cpus();
40 	unsigned int *mask;
41 	int size, index, curr_index;
42 
43 	size = max_cpus / (sizeof(unsigned int) * 8);
44 	if (max_cpus % (sizeof(unsigned int) * 8))
45 		size++;
46 
47 	mask = calloc(size, sizeof(unsigned int));
48 	if (!mask)
49 		return;
50 
51 	for (i = 0; i < max_cpus; ++i) {
52 		int mask_index, bit_index;
53 
54 		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
55 			continue;
56 
57 		mask_index = i / (sizeof(unsigned int) * 8);
58 		bit_index = i % (sizeof(unsigned int) * 8);
59 		mask[mask_index] |= BIT(bit_index);
60 	}
61 
62 	curr_index = 0;
63 	for (i = size - 1; i >= 0; --i) {
64 		index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
65 				 mask[i]);
66 		curr_index += index;
67 		if (i) {
68 			strncat(&str[curr_index], ",", str_len - curr_index);
69 			curr_index++;
70 		}
71 	}
72 
73 	free(mask);
74 }
75 
76 static void format_and_print_txt(FILE *outf, int level, char *header,
77 				 char *value)
78 {
79 	char *spaces = "  ";
80 	static char delimiters[256];
81 	int i, j = 0;
82 
83 	if (!level)
84 		return;
85 
86 	if (level == 1) {
87 		strcpy(delimiters, " ");
88 	} else {
89 		for (i = 0; i < level - 1; ++i)
90 			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
91 				      "%s", spaces);
92 	}
93 
94 	if (header && value) {
95 		fprintf(outf, "%s", delimiters);
96 		fprintf(outf, "%s:%s\n", header, value);
97 	} else if (header) {
98 		fprintf(outf, "%s", delimiters);
99 		fprintf(outf, "%s\n", header);
100 	}
101 }
102 
103 static int last_level;
104 static void format_and_print(FILE *outf, int level, char *header, char *value)
105 {
106 	char *spaces = "  ";
107 	static char delimiters[256];
108 	int i;
109 
110 	if (!out_format_is_json()) {
111 		format_and_print_txt(outf, level, header, value);
112 		return;
113 	}
114 
115 	if (level == 0) {
116 		if (header)
117 			fprintf(outf, "{");
118 		else
119 			fprintf(outf, "\n}\n");
120 
121 	} else {
122 		int j = 0;
123 
124 		for (i = 0; i < level; ++i)
125 			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
126 				      "%s", spaces);
127 
128 		if (last_level == level)
129 			fprintf(outf, ",\n");
130 
131 		if (value) {
132 			if (last_level != level)
133 				fprintf(outf, "\n");
134 
135 			fprintf(outf, "%s\"%s\": ", delimiters, header);
136 			fprintf(outf, "\"%s\"", value);
137 		} else {
138 			for (i = last_level - 1; i >= level; --i) {
139 				int k = 0;
140 
141 				for (j = i; j > 0; --j)
142 					k += snprintf(&delimiters[k],
143 						      sizeof(delimiters) - k,
144 						      "%s", spaces);
145 				if (i == level && header)
146 					fprintf(outf, "\n%s},", delimiters);
147 				else
148 					fprintf(outf, "\n%s}", delimiters);
149 			}
150 			if (abs(last_level - level) < 3)
151 				fprintf(outf, "\n");
152 			if (header)
153 				fprintf(outf, "%s\"%s\": {", delimiters,
154 					header);
155 		}
156 	}
157 
158 	last_level = level;
159 }
160 
161 static void print_package_info(int cpu, FILE *outf)
162 {
163 	char header[256];
164 
165 	snprintf(header, sizeof(header), "package-%d",
166 		 get_physical_package_id(cpu));
167 	format_and_print(outf, 1, header, NULL);
168 	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
169 	format_and_print(outf, 2, header, NULL);
170 	snprintf(header, sizeof(header), "cpu-%d", cpu);
171 	format_and_print(outf, 3, header, NULL);
172 }
173 
174 static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
175 					  struct isst_pbf_info *pbf_info,
176 					  int disp_level)
177 {
178 	char header[256];
179 	char value[256];
180 
181 	snprintf(header, sizeof(header), "speed-select-base-freq");
182 	format_and_print(outf, disp_level, header, NULL);
183 
184 	snprintf(header, sizeof(header), "high-priority-base-frequency(MHz)");
185 	snprintf(value, sizeof(value), "%d",
186 		 pbf_info->p1_high * DISP_FREQ_MULTIPLIER);
187 	format_and_print(outf, disp_level + 1, header, value);
188 
189 	snprintf(header, sizeof(header), "high-priority-cpu-mask");
190 	printcpumask(sizeof(value), value, pbf_info->core_cpumask_size,
191 		     pbf_info->core_cpumask);
192 	format_and_print(outf, disp_level + 1, header, value);
193 
194 	snprintf(header, sizeof(header), "high-priority-cpu-list");
195 	printcpulist(sizeof(value), value,
196 		     pbf_info->core_cpumask_size,
197 		     pbf_info->core_cpumask);
198 	format_and_print(outf, disp_level + 1, header, value);
199 
200 	snprintf(header, sizeof(header), "low-priority-base-frequency(MHz)");
201 	snprintf(value, sizeof(value), "%d",
202 		 pbf_info->p1_low * DISP_FREQ_MULTIPLIER);
203 	format_and_print(outf, disp_level + 1, header, value);
204 
205 	if (is_clx_n_platform())
206 		return;
207 
208 	snprintf(header, sizeof(header), "tjunction-temperature(C)");
209 	snprintf(value, sizeof(value), "%d", pbf_info->t_prochot);
210 	format_and_print(outf, disp_level + 1, header, value);
211 
212 	snprintf(header, sizeof(header), "thermal-design-power(W)");
213 	snprintf(value, sizeof(value), "%d", pbf_info->tdp);
214 	format_and_print(outf, disp_level + 1, header, value);
215 }
216 
217 static void _isst_fact_display_information(int cpu, FILE *outf, int level,
218 					   int fact_bucket, int fact_avx,
219 					   struct isst_fact_info *fact_info,
220 					   int base_level)
221 {
222 	struct isst_fact_bucket_info *bucket_info = fact_info->bucket_info;
223 	char header[256];
224 	char value[256];
225 	int j;
226 
227 	snprintf(header, sizeof(header), "speed-select-turbo-freq");
228 	format_and_print(outf, base_level, header, NULL);
229 	for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
230 		if (fact_bucket != 0xff && fact_bucket != j)
231 			continue;
232 
233 		if (!bucket_info[j].high_priority_cores_count)
234 			break;
235 
236 		snprintf(header, sizeof(header), "bucket-%d", j);
237 		format_and_print(outf, base_level + 1, header, NULL);
238 
239 		snprintf(header, sizeof(header), "high-priority-cores-count");
240 		snprintf(value, sizeof(value), "%d",
241 			 bucket_info[j].high_priority_cores_count);
242 		format_and_print(outf, base_level + 2, header, value);
243 
244 		if (fact_avx & 0x01) {
245 			snprintf(header, sizeof(header),
246 				 "high-priority-max-frequency(MHz)");
247 			snprintf(value, sizeof(value), "%d",
248 				 bucket_info[j].sse_trl * DISP_FREQ_MULTIPLIER);
249 			format_and_print(outf, base_level + 2, header, value);
250 		}
251 
252 		if (fact_avx & 0x02) {
253 			snprintf(header, sizeof(header),
254 				 "high-priority-max-avx2-frequency(MHz)");
255 			snprintf(value, sizeof(value), "%d",
256 				 bucket_info[j].avx_trl * DISP_FREQ_MULTIPLIER);
257 			format_and_print(outf, base_level + 2, header, value);
258 		}
259 
260 		if (fact_avx & 0x04) {
261 			snprintf(header, sizeof(header),
262 				 "high-priority-max-avx512-frequency(MHz)");
263 			snprintf(value, sizeof(value), "%d",
264 				 bucket_info[j].avx512_trl *
265 					 DISP_FREQ_MULTIPLIER);
266 			format_and_print(outf, base_level + 2, header, value);
267 		}
268 	}
269 	snprintf(header, sizeof(header),
270 		 "speed-select-turbo-freq-clip-frequencies");
271 	format_and_print(outf, base_level + 1, header, NULL);
272 	snprintf(header, sizeof(header), "low-priority-max-frequency(MHz)");
273 	snprintf(value, sizeof(value), "%d",
274 		 fact_info->lp_clipping_ratio_license_sse *
275 			 DISP_FREQ_MULTIPLIER);
276 	format_and_print(outf, base_level + 2, header, value);
277 	snprintf(header, sizeof(header),
278 		 "low-priority-max-avx2-frequency(MHz)");
279 	snprintf(value, sizeof(value), "%d",
280 		 fact_info->lp_clipping_ratio_license_avx2 *
281 			 DISP_FREQ_MULTIPLIER);
282 	format_and_print(outf, base_level + 2, header, value);
283 	snprintf(header, sizeof(header),
284 		 "low-priority-max-avx512-frequency(MHz)");
285 	snprintf(value, sizeof(value), "%d",
286 		 fact_info->lp_clipping_ratio_license_avx512 *
287 			 DISP_FREQ_MULTIPLIER);
288 	format_and_print(outf, base_level + 2, header, value);
289 }
290 
291 void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
292 				 unsigned int val)
293 {
294 	char header[256];
295 	char value[256];
296 
297 	snprintf(header, sizeof(header), "package-%d",
298 		 get_physical_package_id(cpu));
299 	format_and_print(outf, 1, header, NULL);
300 	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
301 	format_and_print(outf, 2, header, NULL);
302 	snprintf(header, sizeof(header), "cpu-%d", cpu);
303 	format_and_print(outf, 3, header, NULL);
304 
305 	snprintf(value, sizeof(value), "%u", val);
306 	format_and_print(outf, 4, prefix, value);
307 
308 	format_and_print(outf, 1, NULL, NULL);
309 }
310 
311 void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
312 				   struct isst_pkg_ctdp *pkg_dev)
313 {
314 	char header[256];
315 	char value[256];
316 	int i, base_level = 1;
317 
318 	if (pkg_dev->processed)
319 		print_package_info(cpu, outf);
320 
321 	for (i = 0; i <= pkg_dev->levels; ++i) {
322 		struct isst_pkg_ctdp_level_info *ctdp_level;
323 		int j;
324 
325 		ctdp_level = &pkg_dev->ctdp_level[i];
326 		if (!ctdp_level->processed)
327 			continue;
328 
329 		snprintf(header, sizeof(header), "perf-profile-level-%d",
330 			 ctdp_level->level);
331 		format_and_print(outf, base_level + 3, header, NULL);
332 
333 		snprintf(header, sizeof(header), "cpu-count");
334 		j = get_cpu_count(get_physical_die_id(cpu),
335 				  get_physical_die_id(cpu));
336 		snprintf(value, sizeof(value), "%d", j);
337 		format_and_print(outf, base_level + 4, header, value);
338 
339 		if (ctdp_level->core_cpumask_size) {
340 			snprintf(header, sizeof(header), "enable-cpu-mask");
341 			printcpumask(sizeof(value), value,
342 				     ctdp_level->core_cpumask_size,
343 				     ctdp_level->core_cpumask);
344 			format_and_print(outf, base_level + 4, header, value);
345 
346 			snprintf(header, sizeof(header), "enable-cpu-list");
347 			printcpulist(sizeof(value), value,
348 				     ctdp_level->core_cpumask_size,
349 				     ctdp_level->core_cpumask);
350 			format_and_print(outf, base_level + 4, header, value);
351 		}
352 
353 		snprintf(header, sizeof(header), "thermal-design-power-ratio");
354 		snprintf(value, sizeof(value), "%d", ctdp_level->tdp_ratio);
355 		format_and_print(outf, base_level + 4, header, value);
356 
357 		snprintf(header, sizeof(header), "base-frequency(MHz)");
358 		if (!ctdp_level->sse_p1)
359 			ctdp_level->sse_p1 = ctdp_level->tdp_ratio;
360 		snprintf(value, sizeof(value), "%d",
361 			  ctdp_level->sse_p1 * DISP_FREQ_MULTIPLIER);
362 		format_and_print(outf, base_level + 4, header, value);
363 
364 		if (ctdp_level->avx2_p1) {
365 			snprintf(header, sizeof(header), "base-frequency-avx2(MHz)");
366 			snprintf(value, sizeof(value), "%d",
367 				 ctdp_level->avx2_p1 * DISP_FREQ_MULTIPLIER);
368 			format_and_print(outf, base_level + 4, header, value);
369 		}
370 
371 		if (ctdp_level->avx512_p1) {
372 			snprintf(header, sizeof(header), "base-frequency-avx512(MHz)");
373 			snprintf(value, sizeof(value), "%d",
374 				 ctdp_level->avx512_p1 * DISP_FREQ_MULTIPLIER);
375 			format_and_print(outf, base_level + 4, header, value);
376 		}
377 
378 		if (ctdp_level->uncore_p1) {
379 			snprintf(header, sizeof(header), "uncore-frequency-min(MHz)");
380 			snprintf(value, sizeof(value), "%d",
381 				 ctdp_level->uncore_p1 * DISP_FREQ_MULTIPLIER);
382 			format_and_print(outf, base_level + 4, header, value);
383 		}
384 
385 		if (ctdp_level->uncore_p0) {
386 			snprintf(header, sizeof(header), "uncore-frequency-max(MHz)");
387 			snprintf(value, sizeof(value), "%d",
388 				 ctdp_level->uncore_p0 * DISP_FREQ_MULTIPLIER);
389 			format_and_print(outf, base_level + 4, header, value);
390 		}
391 
392 		if (ctdp_level->mem_freq) {
393 			snprintf(header, sizeof(header), "mem-frequency(MHz)");
394 			snprintf(value, sizeof(value), "%d",
395 				 ctdp_level->mem_freq * DISP_FREQ_MULTIPLIER);
396 			format_and_print(outf, base_level + 4, header, value);
397 		}
398 
399 		snprintf(header, sizeof(header),
400 			 "speed-select-turbo-freq");
401 		if (ctdp_level->fact_support) {
402 			if (ctdp_level->fact_enabled)
403 				snprintf(value, sizeof(value), "enabled");
404 			else
405 				snprintf(value, sizeof(value), "disabled");
406 		} else
407 			snprintf(value, sizeof(value), "unsupported");
408 		format_and_print(outf, base_level + 4, header, value);
409 
410 		snprintf(header, sizeof(header),
411 			 "speed-select-base-freq");
412 		if (ctdp_level->pbf_support) {
413 			if (ctdp_level->pbf_enabled)
414 				snprintf(value, sizeof(value), "enabled");
415 			else
416 				snprintf(value, sizeof(value), "disabled");
417 		} else
418 			snprintf(value, sizeof(value), "unsupported");
419 		format_and_print(outf, base_level + 4, header, value);
420 
421 		snprintf(header, sizeof(header),
422 			 "speed-select-core-power");
423 		if (ctdp_level->sst_cp_support) {
424 			if (ctdp_level->sst_cp_enabled)
425 				snprintf(value, sizeof(value), "enabled");
426 			else
427 				snprintf(value, sizeof(value), "disabled");
428 		} else
429 			snprintf(value, sizeof(value), "unsupported");
430 		format_and_print(outf, base_level + 4, header, value);
431 
432 		if (is_clx_n_platform()) {
433 			if (ctdp_level->pbf_support)
434 				_isst_pbf_display_information(cpu, outf,
435 							      tdp_level,
436 							  &ctdp_level->pbf_info,
437 							      base_level + 4);
438 			continue;
439 		}
440 
441 		if (ctdp_level->pkg_tdp) {
442 			snprintf(header, sizeof(header), "thermal-design-power(W)");
443 			snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp);
444 			format_and_print(outf, base_level + 4, header, value);
445 		}
446 
447 		if (ctdp_level->t_proc_hot) {
448 			snprintf(header, sizeof(header), "tjunction-max(C)");
449 			snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot);
450 			format_and_print(outf, base_level + 4, header, value);
451 		}
452 
453 		snprintf(header, sizeof(header), "turbo-ratio-limits-sse");
454 		format_and_print(outf, base_level + 4, header, NULL);
455 		for (j = 0; j < 8; ++j) {
456 			snprintf(header, sizeof(header), "bucket-%d", j);
457 			format_and_print(outf, base_level + 5, header, NULL);
458 
459 			snprintf(header, sizeof(header), "core-count");
460 			snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
461 			format_and_print(outf, base_level + 6, header, value);
462 
463 			snprintf(header, sizeof(header),
464 				"max-turbo-frequency(MHz)");
465 			snprintf(value, sizeof(value), "%d",
466 				 ctdp_level->trl_sse_active_cores[j] *
467 				  DISP_FREQ_MULTIPLIER);
468 			format_and_print(outf, base_level + 6, header, value);
469 		}
470 
471 		if (ctdp_level->trl_avx_active_cores[0]) {
472 			snprintf(header, sizeof(header), "turbo-ratio-limits-avx2");
473 			format_and_print(outf, base_level + 4, header, NULL);
474 			for (j = 0; j < 8; ++j) {
475 				snprintf(header, sizeof(header), "bucket-%d", j);
476 				format_and_print(outf, base_level + 5, header, NULL);
477 
478 				snprintf(header, sizeof(header), "core-count");
479 				snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
480 				format_and_print(outf, base_level + 6, header, value);
481 
482 				snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
483 				snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_active_cores[j] * DISP_FREQ_MULTIPLIER);
484 				format_and_print(outf, base_level + 6, header, value);
485 			}
486 		}
487 
488 		if (ctdp_level->trl_avx_512_active_cores[0]) {
489 			snprintf(header, sizeof(header), "turbo-ratio-limits-avx512");
490 			format_and_print(outf, base_level + 4, header, NULL);
491 			for (j = 0; j < 8; ++j) {
492 				snprintf(header, sizeof(header), "bucket-%d", j);
493 				format_and_print(outf, base_level + 5, header, NULL);
494 
495 				snprintf(header, sizeof(header), "core-count");
496 				snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
497 				format_and_print(outf, base_level + 6, header, value);
498 
499 				snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
500 				snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_512_active_cores[j] * DISP_FREQ_MULTIPLIER);
501 			format_and_print(outf, base_level + 6, header, value);
502 			}
503 		}
504 
505 		if (ctdp_level->pbf_support)
506 			_isst_pbf_display_information(cpu, outf, i,
507 						      &ctdp_level->pbf_info,
508 						      base_level + 4);
509 		if (ctdp_level->fact_support)
510 			_isst_fact_display_information(cpu, outf, i, 0xff, 0xff,
511 						       &ctdp_level->fact_info,
512 						       base_level + 4);
513 	}
514 
515 	format_and_print(outf, 1, NULL, NULL);
516 }
517 
518 void isst_ctdp_display_information_start(FILE *outf)
519 {
520 	last_level = 0;
521 	format_and_print(outf, 0, "start", NULL);
522 }
523 
524 void isst_ctdp_display_information_end(FILE *outf)
525 {
526 	format_and_print(outf, 0, NULL, NULL);
527 }
528 
529 void isst_pbf_display_information(int cpu, FILE *outf, int level,
530 				  struct isst_pbf_info *pbf_info)
531 {
532 	print_package_info(cpu, outf);
533 	_isst_pbf_display_information(cpu, outf, level, pbf_info, 4);
534 	format_and_print(outf, 1, NULL, NULL);
535 }
536 
537 void isst_fact_display_information(int cpu, FILE *outf, int level,
538 				   int fact_bucket, int fact_avx,
539 				   struct isst_fact_info *fact_info)
540 {
541 	print_package_info(cpu, outf);
542 	_isst_fact_display_information(cpu, outf, level, fact_bucket, fact_avx,
543 				       fact_info, 4);
544 	format_and_print(outf, 1, NULL, NULL);
545 }
546 
547 void isst_clos_display_information(int cpu, FILE *outf, int clos,
548 				   struct isst_clos_config *clos_config)
549 {
550 	char header[256];
551 	char value[256];
552 
553 	snprintf(header, sizeof(header), "package-%d",
554 		 get_physical_package_id(cpu));
555 	format_and_print(outf, 1, header, NULL);
556 	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
557 	format_and_print(outf, 2, header, NULL);
558 	snprintf(header, sizeof(header), "cpu-%d", cpu);
559 	format_and_print(outf, 3, header, NULL);
560 
561 	snprintf(header, sizeof(header), "core-power");
562 	format_and_print(outf, 4, header, NULL);
563 
564 	snprintf(header, sizeof(header), "clos");
565 	snprintf(value, sizeof(value), "%d", clos);
566 	format_and_print(outf, 5, header, value);
567 
568 	snprintf(header, sizeof(header), "epp");
569 	snprintf(value, sizeof(value), "%d", clos_config->epp);
570 	format_and_print(outf, 5, header, value);
571 
572 	snprintf(header, sizeof(header), "clos-proportional-priority");
573 	snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio);
574 	format_and_print(outf, 5, header, value);
575 
576 	snprintf(header, sizeof(header), "clos-min");
577 	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * DISP_FREQ_MULTIPLIER);
578 	format_and_print(outf, 5, header, value);
579 
580 	snprintf(header, sizeof(header), "clos-max");
581 	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * DISP_FREQ_MULTIPLIER);
582 	format_and_print(outf, 5, header, value);
583 
584 	snprintf(header, sizeof(header), "clos-desired");
585 	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * DISP_FREQ_MULTIPLIER);
586 	format_and_print(outf, 5, header, value);
587 
588 	format_and_print(outf, 1, NULL, NULL);
589 }
590 
591 void isst_clos_display_clos_information(int cpu, FILE *outf,
592 					int clos_enable, int type)
593 {
594 	char header[256];
595 	char value[256];
596 
597 	snprintf(header, sizeof(header), "package-%d",
598 		 get_physical_package_id(cpu));
599 	format_and_print(outf, 1, header, NULL);
600 	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
601 	format_and_print(outf, 2, header, NULL);
602 	snprintf(header, sizeof(header), "cpu-%d", cpu);
603 	format_and_print(outf, 3, header, NULL);
604 
605 	snprintf(header, sizeof(header), "core-power");
606 	format_and_print(outf, 4, header, NULL);
607 
608 	snprintf(header, sizeof(header), "enable-status");
609 	snprintf(value, sizeof(value), "%d", clos_enable);
610 	format_and_print(outf, 5, header, value);
611 
612 	snprintf(header, sizeof(header), "priority-type");
613 	snprintf(value, sizeof(value), "%d", type);
614 	format_and_print(outf, 5, header, value);
615 
616 	format_and_print(outf, 1, NULL, NULL);
617 }
618 
619 void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos)
620 {
621 	char header[256];
622 	char value[256];
623 
624 	snprintf(header, sizeof(header), "package-%d",
625 		 get_physical_package_id(cpu));
626 	format_and_print(outf, 1, header, NULL);
627 	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
628 	format_and_print(outf, 2, header, NULL);
629 	snprintf(header, sizeof(header), "cpu-%d", cpu);
630 	format_and_print(outf, 3, header, NULL);
631 
632 	snprintf(header, sizeof(header), "get-assoc");
633 	format_and_print(outf, 4, header, NULL);
634 
635 	snprintf(header, sizeof(header), "clos");
636 	snprintf(value, sizeof(value), "%d", clos);
637 	format_and_print(outf, 5, header, value);
638 
639 	format_and_print(outf, 1, NULL, NULL);
640 }
641 
642 void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd,
643 			 int result)
644 {
645 	char header[256];
646 	char value[256];
647 
648 	if (cpu >= 0) {
649 		snprintf(header, sizeof(header), "package-%d",
650 			 get_physical_package_id(cpu));
651 		format_and_print(outf, 1, header, NULL);
652 		snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
653 		format_and_print(outf, 2, header, NULL);
654 		snprintf(header, sizeof(header), "cpu-%d", cpu);
655 		format_and_print(outf, 3, header, NULL);
656 	}
657 	snprintf(header, sizeof(header), "%s", feature);
658 	format_and_print(outf, 4, header, NULL);
659 	snprintf(header, sizeof(header), "%s", cmd);
660 	if (!result)
661 		snprintf(value, sizeof(value), "success");
662 	else
663 		snprintf(value, sizeof(value), "failed(error %d)", result);
664 	format_and_print(outf, 5, header, value);
665 
666 	format_and_print(outf, 1, NULL, NULL);
667 }
668