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