summaryrefslogtreecommitdiff
path: root/tools/power/x86/intel-speed-select/isst-display.c
blob: 8e54ce47648e28f0ffc0c297e6fd0e7655f77f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
// SPDX-License-Identifier: GPL-2.0
/*
 * Intel dynamic_speed_select -- Enumerate and control features
 * Copyright (c) 2019 Intel Corporation.
 */

#include "isst.h"

static void printcpulist(int str_len, char *str, int mask_size,
			 cpu_set_t *cpu_mask)
{
	int i, first, curr_index, index;

	if (!CPU_COUNT_S(mask_size, cpu_mask)) {
		snprintf(str, str_len, "none");
		return;
	}

	curr_index = 0;
	first = 1;
	for (i = 0; i < get_topo_max_cpus(); ++i) {
		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
			continue;
		if (!first) {
			index = snprintf(&str[curr_index],
					 str_len - curr_index, ",");
			curr_index += index;
		}
		index = snprintf(&str[curr_index], str_len - curr_index, "%d",
				 i);
		curr_index += index;
		first = 0;
	}
}

static void printcpumask(int str_len, char *str, int mask_size,
			 cpu_set_t *cpu_mask)
{
	int i, max_cpus = get_topo_max_cpus();
	unsigned int *mask;
	int size, index, curr_index;

	size = max_cpus / (sizeof(unsigned int) * 8);
	if (max_cpus % (sizeof(unsigned int) * 8))
		size++;

	mask = calloc(size, sizeof(unsigned int));
	if (!mask)
		return;

	for (i = 0; i < max_cpus; ++i) {
		int mask_index, bit_index;

		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
			continue;

		mask_index = i / (sizeof(unsigned int) * 8);
		bit_index = i % (sizeof(unsigned int) * 8);
		mask[mask_index] |= BIT(bit_index);
	}

	curr_index = 0;
	for (i = size - 1; i >= 0; --i) {
		index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
				 mask[i]);
		curr_index += index;
		if (i) {
			strncat(&str[curr_index], ",", str_len - curr_index);
			curr_index++;
		}
	}

	free(mask);
}

static void format_and_print_txt(FILE *outf, int level, char *header,
				 char *value)
{
	char *spaces = "  ";
	static char delimiters[256];
	int i, j = 0;

	if (!level)
		return;

	if (level == 1) {
		strcpy(delimiters, " ");
	} else {
		for (i = 0; i < level - 1; ++i)
			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
				      "%s", spaces);
	}

	if (header && value) {
		fprintf(outf, "%s", delimiters);
		fprintf(outf, "%s:%s\n", header, value);
	} else if (header) {
		fprintf(outf, "%s", delimiters);
		fprintf(outf, "%s\n", header);
	}
}

static int last_level;
static void format_and_print(FILE *outf, int level, char *header, char *value)
{
	char *spaces = "  ";
	static char delimiters[256];
	int i;

	if (!out_format_is_json()) {
		format_and_print_txt(outf, level, header, value);
		return;
	}

	if (level == 0) {
		if (header)
			fprintf(outf, "{");
		else
			fprintf(outf, "\n}\n");

	} else {
		int j = 0;

		for (i = 0; i < level; ++i)
			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
				      "%s", spaces);

		if (last_level == level)
			fprintf(outf, ",\n");

		if (value) {
			if (last_level != level)
				fprintf(outf, "\n");

			fprintf(outf, "%s\"%s\": ", delimiters, header);
			fprintf(outf, "\"%s\"", value);
		} else {
			for (i = last_level - 1; i >= level; --i) {
				int k = 0;

				for (j = i; j > 0; --j)
					k += snprintf(&delimiters[k],
						      sizeof(delimiters) - k,
						      "%s", spaces);
				if (i == level && header)
					fprintf(outf, "\n%s},", delimiters);
				else
					fprintf(outf, "\n%s}", delimiters);
			}
			if (abs(last_level - level) < 3)
				fprintf(outf, "\n");
			if (header)
				fprintf(outf, "%s\"%s\": {", delimiters,
					header);
		}
	}

	last_level = level;
}

static int print_package_info(int cpu, FILE *outf)
{
	char header[256];

	if (out_format_is_json()) {
		snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
			 get_physical_package_id(cpu), get_physical_die_id(cpu),
			 cpu);
		format_and_print(outf, 1, header, NULL);
		return 1;
	}
	snprintf(header, sizeof(header), "package-%d",
		 get_physical_package_id(cpu));
	format_and_print(outf, 1, header, NULL);
	snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu));
	format_and_print(outf, 2, header, NULL);
	snprintf(header, sizeof(header), "cpu-%d", cpu);
	format_and_print(outf, 3, header, NULL);

	return 3;
}

static void _isst_pbf_display_information(int cpu, FILE *outf, int level,
					  struct isst_pbf_info *pbf_info,
					  int disp_level)
{
	char header[256];
	char value[256];

	snprintf(header, sizeof(header), "speed-select-base-freq-properties");
	format_and_print(outf, disp_level, header, NULL);

	snprintf(header, sizeof(header), "high-priority-base-frequency(MHz)");
	snprintf(value, sizeof(value), "%d",
		 pbf_info->p1_high * DISP_FREQ_MULTIPLIER);
	format_and_print(outf, disp_level + 1, header, value);

	snprintf(header, sizeof(header), "high-priority-cpu-mask");
	printcpumask(sizeof(value), value, pbf_info->core_cpumask_size,
		     pbf_info->core_cpumask);
	format_and_print(outf, disp_level + 1, header, value);

	snprintf(header, sizeof(header), "high-priority-cpu-list");
	printcpulist(sizeof(value), value,
		     pbf_info->core_cpumask_size,
		     pbf_info->core_cpumask);
	format_and_print(outf, disp_level + 1, header, value);

	snprintf(header, sizeof(header), "low-priority-base-frequency(MHz)");
	snprintf(value, sizeof(value), "%d",
		 pbf_info->p1_low * DISP_FREQ_MULTIPLIER);
	format_and_print(outf, disp_level + 1, header, value);

	if (is_clx_n_platform())
		return;

	snprintf(header, sizeof(header), "tjunction-temperature(C)");
	snprintf(value, sizeof(value), "%d", pbf_info->t_prochot);
	format_and_print(outf, disp_level + 1, header, value);

	snprintf(header, sizeof(header), "thermal-design-power(W)");
	snprintf(value, sizeof(value), "%d", pbf_info->tdp);
	format_and_print(outf, disp_level + 1, header, value);
}

static void _isst_fact_display_information(int cpu, FILE *outf, int level,
					   int fact_bucket, int fact_avx,
					   struct isst_fact_info *fact_info,
					   int base_level)
{
	struct isst_fact_bucket_info *bucket_info = fact_info->bucket_info;
	char header[256];
	char value[256];
	int print = 0, j;

	for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
		if (fact_bucket != 0xff && fact_bucket != j)
			continue;

		if (!bucket_info[j].high_priority_cores_count)
			break;

		print = 1;
	}
	if (!print) {
		fprintf(stderr, "Invalid bucket\n");
		return;
	}

	snprintf(header, sizeof(header), "speed-select-turbo-freq-properties");
	format_and_print(outf, base_level, header, NULL);
	for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
		if (fact_bucket != 0xff && fact_bucket != j)
			continue;

		if (!bucket_info[j].high_priority_cores_count)
			break;

		snprintf(header, sizeof(header), "bucket-%d", j);
		format_and_print(outf, base_level + 1, header, NULL);

		snprintf(header, sizeof(header), "high-priority-cores-count");
		snprintf(value, sizeof(value), "%d",
			 bucket_info[j].high_priority_cores_count);
		format_and_print(outf, base_level + 2, header, value);

		if (fact_avx & 0x01) {
			snprintf(header, sizeof(header),
				 "high-priority-max-frequency(MHz)");
			snprintf(value, sizeof(value), "%d",
				 bucket_info[j].sse_trl * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, base_level + 2, header, value);
		}

		if (fact_avx & 0x02) {
			snprintf(header, sizeof(header),
				 "high-priority-max-avx2-frequency(MHz)");
			snprintf(value, sizeof(value), "%d",
				 bucket_info[j].avx_trl * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, base_level + 2, header, value);
		}

		if (fact_avx & 0x04) {
			snprintf(header, sizeof(header),
				 "high-priority-max-avx512-frequency(MHz)");
			snprintf(value, sizeof(value), "%d",
				 bucket_info[j].avx512_trl *
					 DISP_FREQ_MULTIPLIER);
			format_and_print(outf, base_level + 2, header, value);
		}
	}
	snprintf(header, sizeof(header),
		 "speed-select-turbo-freq-clip-frequencies");
	format_and_print(outf, base_level + 1, header, NULL);
	snprintf(header, sizeof(header), "low-priority-max-frequency(MHz)");
	snprintf(value, sizeof(value), "%d",
		 fact_info->lp_clipping_ratio_license_sse *
			 DISP_FREQ_MULTIPLIER);
	format_and_print(outf, base_level + 2, header, value);
	snprintf(header, sizeof(header),
		 "low-priority-max-avx2-frequency(MHz)");
	snprintf(value, sizeof(value), "%d",
		 fact_info->lp_clipping_ratio_license_avx2 *
			 DISP_FREQ_MULTIPLIER);
	format_and_print(outf, base_level + 2, header, value);
	snprintf(header, sizeof(header),
		 "low-priority-max-avx512-frequency(MHz)");
	snprintf(value, sizeof(value), "%d",
		 fact_info->lp_clipping_ratio_license_avx512 *
			 DISP_FREQ_MULTIPLIER);
	format_and_print(outf, base_level + 2, header, value);
}

void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix,
				 unsigned int val, char *str0, char *str1)
{
	char header[256];
	char value[256];
	int level = 1;

	if (out_format_is_json()) {
		snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
			 get_physical_package_id(cpu), get_physical_die_id(cpu),
			 cpu);
		format_and_print(outf, level++, header, NULL);
	} else {
		snprintf(header, sizeof(header), "package-%d",
			 get_physical_package_id(cpu));
		format_and_print(outf, level++, header, NULL);
		snprintf(header, sizeof(header), "die-%d",
			 get_physical_die_id(cpu));
		format_and_print(outf, level++, header, NULL);
		snprintf(header, sizeof(header), "cpu-%d", cpu);
		format_and_print(outf, level++, header, NULL);
	}

	if (str0 && !val)
		snprintf(value, sizeof(value), "%s", str0);
	else if (str1 && val)
		snprintf(value, sizeof(value), "%s", str1);
	else
		snprintf(value, sizeof(value), "%u", val);
	format_and_print(outf, level, prefix, value);

	format_and_print(outf, 1, NULL, NULL);
}

void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,
				   struct isst_pkg_ctdp *pkg_dev)
{
	char header[256];
	char value[256];
	static int level;
	int i;

	if (pkg_dev->processed)
		level = print_package_info(cpu, outf);

	for (i = 0; i <= pkg_dev->levels; ++i) {
		struct isst_pkg_ctdp_level_info *ctdp_level;
		int j;

		ctdp_level = &pkg_dev->ctdp_level[i];
		if (!ctdp_level->processed)
			continue;

		snprintf(header, sizeof(header), "perf-profile-level-%d",
			 ctdp_level->level);
		format_and_print(outf, level + 1, header, NULL);

		snprintf(header, sizeof(header), "cpu-count");
		j = get_cpu_count(get_physical_die_id(cpu),
				  get_physical_die_id(cpu));
		snprintf(value, sizeof(value), "%d", j);
		format_and_print(outf, level + 2, header, value);

		j = CPU_COUNT_S(ctdp_level->core_cpumask_size,
				ctdp_level->core_cpumask);
		if (j) {
			snprintf(header, sizeof(header), "enable-cpu-count");
			snprintf(value, sizeof(value), "%d", j);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->core_cpumask_size) {
			snprintf(header, sizeof(header), "enable-cpu-mask");
			printcpumask(sizeof(value), value,
				     ctdp_level->core_cpumask_size,
				     ctdp_level->core_cpumask);
			format_and_print(outf, level + 2, header, value);

			snprintf(header, sizeof(header), "enable-cpu-list");
			printcpulist(sizeof(value), value,
				     ctdp_level->core_cpumask_size,
				     ctdp_level->core_cpumask);
			format_and_print(outf, level + 2, header, value);
		}

		snprintf(header, sizeof(header), "thermal-design-power-ratio");
		snprintf(value, sizeof(value), "%d", ctdp_level->tdp_ratio);
		format_and_print(outf, level + 2, header, value);

		snprintf(header, sizeof(header), "base-frequency(MHz)");
		if (!ctdp_level->sse_p1)
			ctdp_level->sse_p1 = ctdp_level->tdp_ratio;
		snprintf(value, sizeof(value), "%d",
			  ctdp_level->sse_p1 * DISP_FREQ_MULTIPLIER);
		format_and_print(outf, level + 2, header, value);

		if (ctdp_level->avx2_p1) {
			snprintf(header, sizeof(header), "base-frequency-avx2(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->avx2_p1 * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->avx512_p1) {
			snprintf(header, sizeof(header), "base-frequency-avx512(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->avx512_p1 * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->uncore_p1) {
			snprintf(header, sizeof(header), "uncore-frequency-min(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->uncore_p1 * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->uncore_p0) {
			snprintf(header, sizeof(header), "uncore-frequency-max(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->uncore_p0 * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->mem_freq) {
			snprintf(header, sizeof(header), "mem-frequency(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->mem_freq * DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 2, header, value);
		}

		snprintf(header, sizeof(header),
			 "speed-select-turbo-freq");
		if (ctdp_level->fact_support) {
			if (ctdp_level->fact_enabled)
				snprintf(value, sizeof(value), "enabled");
			else
				snprintf(value, sizeof(value), "disabled");
		} else
			snprintf(value, sizeof(value), "unsupported");
		format_and_print(outf, level + 2, header, value);

		snprintf(header, sizeof(header),
			 "speed-select-base-freq");
		if (ctdp_level->pbf_support) {
			if (ctdp_level->pbf_enabled)
				snprintf(value, sizeof(value), "enabled");
			else
				snprintf(value, sizeof(value), "disabled");
		} else
			snprintf(value, sizeof(value), "unsupported");
		format_and_print(outf, level + 2, header, value);

		snprintf(header, sizeof(header),
			 "speed-select-core-power");
		if (ctdp_level->sst_cp_support) {
			if (ctdp_level->sst_cp_enabled)
				snprintf(value, sizeof(value), "enabled");
			else
				snprintf(value, sizeof(value), "disabled");
		} else
			snprintf(value, sizeof(value), "unsupported");
		format_and_print(outf, level + 2, header, value);

		if (is_clx_n_platform()) {
			if (ctdp_level->pbf_support)
				_isst_pbf_display_information(cpu, outf,
							      tdp_level,
							  &ctdp_level->pbf_info,
							      level + 2);
			continue;
		}

		if (ctdp_level->pkg_tdp) {
			snprintf(header, sizeof(header), "thermal-design-power(W)");
			snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp);
			format_and_print(outf, level + 2, header, value);
		}

		if (ctdp_level->t_proc_hot) {
			snprintf(header, sizeof(header), "tjunction-max(C)");
			snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot);
			format_and_print(outf, level + 2, header, value);
		}

		snprintf(header, sizeof(header), "turbo-ratio-limits-sse");
		format_and_print(outf, level + 2, header, NULL);
		for (j = 0; j < 8; ++j) {
			snprintf(header, sizeof(header), "bucket-%d", j);
			format_and_print(outf, level + 3, header, NULL);

			snprintf(header, sizeof(header), "core-count");
			snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
			format_and_print(outf, level + 4, header, value);

			snprintf(header, sizeof(header),
				"max-turbo-frequency(MHz)");
			snprintf(value, sizeof(value), "%d",
				 ctdp_level->trl_sse_active_cores[j] *
				  DISP_FREQ_MULTIPLIER);
			format_and_print(outf, level + 4, header, value);
		}

		if (ctdp_level->trl_avx_active_cores[0]) {
			snprintf(header, sizeof(header), "turbo-ratio-limits-avx2");
			format_and_print(outf, level + 2, header, NULL);
			for (j = 0; j < 8; ++j) {
				snprintf(header, sizeof(header), "bucket-%d", j);
				format_and_print(outf, level + 3, header, NULL);

				snprintf(header, sizeof(header), "core-count");
				snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
				format_and_print(outf, level + 4, header, value);

				snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
				snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_active_cores[j] * DISP_FREQ_MULTIPLIER);
				format_and_print(outf, level + 4, header, value);
			}
		}

		if (ctdp_level->trl_avx_512_active_cores[0]) {
			snprintf(header, sizeof(header), "turbo-ratio-limits-avx512");
			format_and_print(outf, level + 2, header, NULL);
			for (j = 0; j < 8; ++j) {
				snprintf(header, sizeof(header), "bucket-%d", j);
				format_and_print(outf, level + 3, header, NULL);

				snprintf(header, sizeof(header), "core-count");
				snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff);
				format_and_print(outf, level + 4, header, value);

				snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
				snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_512_active_cores[j] * DISP_FREQ_MULTIPLIER);
				format_and_print(outf, level + 4, header, value);
			}
		}

		if (ctdp_level->pbf_support)
			_isst_pbf_display_information(cpu, outf, i,
						      &ctdp_level->pbf_info,
						      level + 2);
		if (ctdp_level->fact_support)
			_isst_fact_display_information(cpu, outf, i, 0xff, 0xff,
						       &ctdp_level->fact_info,
						       level + 2);
	}

	format_and_print(outf, 1, NULL, NULL);
}

static int start;
void isst_ctdp_display_information_start(FILE *outf)
{
	last_level = 0;
	format_and_print(outf, 0, "start", NULL);
	start = 1;
}

void isst_ctdp_display_information_end(FILE *outf)
{
	format_and_print(outf, 0, NULL, NULL);
	start = 0;
}

void isst_pbf_display_information(int cpu, FILE *outf, int level,
				  struct isst_pbf_info *pbf_info)
{
	int _level;

	_level = print_package_info(cpu, outf);
	_isst_pbf_display_information(cpu, outf, level, pbf_info, _level + 1);
	format_and_print(outf, 1, NULL, NULL);
}

void isst_fact_display_information(int cpu, FILE *outf, int level,
				   int fact_bucket, int fact_avx,
				   struct isst_fact_info *fact_info)
{
	int _level;

	_level = print_package_info(cpu, outf);
	_isst_fact_display_information(cpu, outf, level, fact_bucket, fact_avx,
				       fact_info, _level + 1);
	format_and_print(outf, 1, NULL, NULL);
}

void isst_clos_display_information(int cpu, FILE *outf, int clos,
				   struct isst_clos_config *clos_config)
{
	char header[256];
	char value[256];
	int level;

	level = print_package_info(cpu, outf);

	snprintf(header, sizeof(header), "core-power");
	format_and_print(outf, level + 1, header, NULL);

	snprintf(header, sizeof(header), "clos");
	snprintf(value, sizeof(value), "%d", clos);
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "epp");
	snprintf(value, sizeof(value), "%d", clos_config->epp);
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "clos-proportional-priority");
	snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio);
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "clos-min");
	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * DISP_FREQ_MULTIPLIER);
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "clos-max");
	if (clos_config->clos_max == 0xff)
		snprintf(value, sizeof(value), "Max Turbo frequency");
	else
		snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * DISP_FREQ_MULTIPLIER);
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "clos-desired");
	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * DISP_FREQ_MULTIPLIER);
	format_and_print(outf, level + 2, header, value);

	format_and_print(outf, level, NULL, NULL);
}

void isst_clos_display_clos_information(int cpu, FILE *outf,
					int clos_enable, int type,
					int state, int cap)
{
	char header[256];
	char value[256];
	int level;

	level = print_package_info(cpu, outf);

	snprintf(header, sizeof(header), "core-power");
	format_and_print(outf, level + 1, header, NULL);

	snprintf(header, sizeof(header), "support-status");
	if (cap)
		snprintf(value, sizeof(value), "supported");
	else
		snprintf(value, sizeof(value), "unsupported");
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "enable-status");
	if (state)
		snprintf(value, sizeof(value), "enabled");
	else
		snprintf(value, sizeof(value), "disabled");
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "clos-enable-status");
	if (clos_enable)
		snprintf(value, sizeof(value), "enabled");
	else
		snprintf(value, sizeof(value), "disabled");
	format_and_print(outf, level + 2, header, value);

	snprintf(header, sizeof(header), "priority-type");
	if (type)
		snprintf(value, sizeof(value), "ordered");
	else
		snprintf(value, sizeof(value), "proportional");
	format_and_print(outf, level + 2, header, value);

	format_and_print(outf, level, NULL, NULL);
}

void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos)
{
	char header[256];
	char value[256];
	int level;

	level = print_package_info(cpu, outf);

	snprintf(header, sizeof(header), "get-assoc");
	format_and_print(outf, level + 1, header, NULL);

	snprintf(header, sizeof(header), "clos");
	snprintf(value, sizeof(value), "%d", clos);
	format_and_print(outf, level + 2, header, value);

	format_and_print(outf, level, NULL, NULL);
}

void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd,
			 int result)
{
	char header[256];
	char value[256];
	int level = 3;

	if (cpu >= 0)
		level = print_package_info(cpu, outf);

	snprintf(header, sizeof(header), "%s", feature);
	format_and_print(outf, level + 1, header, NULL);
	snprintf(header, sizeof(header), "%s", cmd);
	if (!result)
		snprintf(value, sizeof(value), "success");
	else
		snprintf(value, sizeof(value), "failed(error %d)", result);
	format_and_print(outf, level + 2, header, value);

	format_and_print(outf, level, NULL, NULL);
}

void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg)
{
	FILE *outf = get_output_file();
	static int error_index;
	char header[256];
	char value[256];

	if (!out_format_is_json()) {
		if (arg_valid)
			snprintf(value, sizeof(value), "%s %d", msg, arg);
		else
			snprintf(value, sizeof(value), "%s", msg);

		if (error)
			fprintf(outf, "Error: %s\n", value);
		else
			fprintf(outf, "Information: %s\n", value);
		return;
	}

	if (!start)
		format_and_print(outf, 0, "start", NULL);

	if (error)
		snprintf(header, sizeof(header), "Error%d", error_index++);
	else
		snprintf(header, sizeof(header), "Information:%d", error_index++);
	format_and_print(outf, 1, header, NULL);

	snprintf(header, sizeof(header), "message");
	if (arg_valid)
		snprintf(value, sizeof(value), "%s %d", msg, arg);
	else
		snprintf(value, sizeof(value), "%s", msg);

	format_and_print(outf, 2, header, value);
	format_and_print(outf, 1, NULL, NULL);
	if (!start)
		format_and_print(outf, 0, NULL, NULL);
}

void isst_trl_display_information(int cpu, FILE *outf, unsigned long long trl)
{
	char header[256];
	char value[256];
	int level;

	level = print_package_info(cpu, outf);

	snprintf(header, sizeof(header), "get-trl");
	format_and_print(outf, level + 1, header, NULL);

	snprintf(header, sizeof(header), "trl");
	snprintf(value, sizeof(value), "0x%llx", trl);
	format_and_print(outf, level + 2, header, value);

	format_and_print(outf, level, NULL, NULL);
}