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 int print_package_info(int cpu, FILE *outf) 162 { 163 char header[256]; 164 165 if (out_format_is_json()) { 166 snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d", 167 get_physical_package_id(cpu), get_physical_die_id(cpu), 168 cpu); 169 format_and_print(outf, 1, header, NULL); 170 return 1; 171 } 172 snprintf(header, sizeof(header), "package-%d", 173 get_physical_package_id(cpu)); 174 format_and_print(outf, 1, header, NULL); 175 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 176 format_and_print(outf, 2, header, NULL); 177 snprintf(header, sizeof(header), "cpu-%d", cpu); 178 format_and_print(outf, 3, header, NULL); 179 180 return 3; 181 } 182 183 static void _isst_pbf_display_information(int cpu, FILE *outf, int level, 184 struct isst_pbf_info *pbf_info, 185 int disp_level) 186 { 187 char header[256]; 188 char value[256]; 189 190 snprintf(header, sizeof(header), "speed-select-base-freq-properties"); 191 format_and_print(outf, disp_level, header, NULL); 192 193 snprintf(header, sizeof(header), "high-priority-base-frequency(MHz)"); 194 snprintf(value, sizeof(value), "%d", 195 pbf_info->p1_high * DISP_FREQ_MULTIPLIER); 196 format_and_print(outf, disp_level + 1, header, value); 197 198 snprintf(header, sizeof(header), "high-priority-cpu-mask"); 199 printcpumask(sizeof(value), value, pbf_info->core_cpumask_size, 200 pbf_info->core_cpumask); 201 format_and_print(outf, disp_level + 1, header, value); 202 203 snprintf(header, sizeof(header), "high-priority-cpu-list"); 204 printcpulist(sizeof(value), value, 205 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), "low-priority-base-frequency(MHz)"); 210 snprintf(value, sizeof(value), "%d", 211 pbf_info->p1_low * DISP_FREQ_MULTIPLIER); 212 format_and_print(outf, disp_level + 1, header, value); 213 214 if (is_clx_n_platform()) 215 return; 216 217 snprintf(header, sizeof(header), "tjunction-temperature(C)"); 218 snprintf(value, sizeof(value), "%d", pbf_info->t_prochot); 219 format_and_print(outf, disp_level + 1, header, value); 220 221 snprintf(header, sizeof(header), "thermal-design-power(W)"); 222 snprintf(value, sizeof(value), "%d", pbf_info->tdp); 223 format_and_print(outf, disp_level + 1, header, value); 224 } 225 226 static void _isst_fact_display_information(int cpu, FILE *outf, int level, 227 int fact_bucket, int fact_avx, 228 struct isst_fact_info *fact_info, 229 int base_level) 230 { 231 struct isst_fact_bucket_info *bucket_info = fact_info->bucket_info; 232 char header[256]; 233 char value[256]; 234 int print = 0, j; 235 236 for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) { 237 if (fact_bucket != 0xff && fact_bucket != j) 238 continue; 239 240 if (!bucket_info[j].high_priority_cores_count) 241 break; 242 243 print = 1; 244 } 245 if (!print) { 246 fprintf(stderr, "Invalid bucket\n"); 247 return; 248 } 249 250 snprintf(header, sizeof(header), "speed-select-turbo-freq-properties"); 251 format_and_print(outf, base_level, header, NULL); 252 for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) { 253 if (fact_bucket != 0xff && fact_bucket != j) 254 continue; 255 256 if (!bucket_info[j].high_priority_cores_count) 257 break; 258 259 snprintf(header, sizeof(header), "bucket-%d", j); 260 format_and_print(outf, base_level + 1, header, NULL); 261 262 snprintf(header, sizeof(header), "high-priority-cores-count"); 263 snprintf(value, sizeof(value), "%d", 264 bucket_info[j].high_priority_cores_count); 265 format_and_print(outf, base_level + 2, header, value); 266 267 if (fact_avx & 0x01) { 268 snprintf(header, sizeof(header), 269 "high-priority-max-frequency(MHz)"); 270 snprintf(value, sizeof(value), "%d", 271 bucket_info[j].sse_trl * DISP_FREQ_MULTIPLIER); 272 format_and_print(outf, base_level + 2, header, value); 273 } 274 275 if (fact_avx & 0x02) { 276 snprintf(header, sizeof(header), 277 "high-priority-max-avx2-frequency(MHz)"); 278 snprintf(value, sizeof(value), "%d", 279 bucket_info[j].avx_trl * DISP_FREQ_MULTIPLIER); 280 format_and_print(outf, base_level + 2, header, value); 281 } 282 283 if (fact_avx & 0x04) { 284 snprintf(header, sizeof(header), 285 "high-priority-max-avx512-frequency(MHz)"); 286 snprintf(value, sizeof(value), "%d", 287 bucket_info[j].avx512_trl * 288 DISP_FREQ_MULTIPLIER); 289 format_and_print(outf, base_level + 2, header, value); 290 } 291 } 292 snprintf(header, sizeof(header), 293 "speed-select-turbo-freq-clip-frequencies"); 294 format_and_print(outf, base_level + 1, header, NULL); 295 snprintf(header, sizeof(header), "low-priority-max-frequency(MHz)"); 296 snprintf(value, sizeof(value), "%d", 297 fact_info->lp_clipping_ratio_license_sse * 298 DISP_FREQ_MULTIPLIER); 299 format_and_print(outf, base_level + 2, header, value); 300 snprintf(header, sizeof(header), 301 "low-priority-max-avx2-frequency(MHz)"); 302 snprintf(value, sizeof(value), "%d", 303 fact_info->lp_clipping_ratio_license_avx2 * 304 DISP_FREQ_MULTIPLIER); 305 format_and_print(outf, base_level + 2, header, value); 306 snprintf(header, sizeof(header), 307 "low-priority-max-avx512-frequency(MHz)"); 308 snprintf(value, sizeof(value), "%d", 309 fact_info->lp_clipping_ratio_license_avx512 * 310 DISP_FREQ_MULTIPLIER); 311 format_and_print(outf, base_level + 2, header, value); 312 } 313 314 void isst_ctdp_display_core_info(int cpu, FILE *outf, char *prefix, 315 unsigned int val, char *str0, char *str1) 316 { 317 char header[256]; 318 char value[256]; 319 320 snprintf(header, sizeof(header), "package-%d", 321 get_physical_package_id(cpu)); 322 format_and_print(outf, 1, header, NULL); 323 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 324 format_and_print(outf, 2, header, NULL); 325 snprintf(header, sizeof(header), "cpu-%d", cpu); 326 format_and_print(outf, 3, header, NULL); 327 if (str0 && !val) 328 snprintf(value, sizeof(value), "%s", str0); 329 else if (str1 && val) 330 snprintf(value, sizeof(value), "%s", str1); 331 else 332 snprintf(value, sizeof(value), "%u", val); 333 format_and_print(outf, 4, prefix, value); 334 335 format_and_print(outf, 1, NULL, NULL); 336 } 337 338 void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level, 339 struct isst_pkg_ctdp *pkg_dev) 340 { 341 char header[256]; 342 char value[256]; 343 static int level; 344 int i; 345 346 if (pkg_dev->processed) 347 level = print_package_info(cpu, outf); 348 349 for (i = 0; i <= pkg_dev->levels; ++i) { 350 struct isst_pkg_ctdp_level_info *ctdp_level; 351 int j; 352 353 ctdp_level = &pkg_dev->ctdp_level[i]; 354 if (!ctdp_level->processed) 355 continue; 356 357 snprintf(header, sizeof(header), "perf-profile-level-%d", 358 ctdp_level->level); 359 format_and_print(outf, level + 1, header, NULL); 360 361 snprintf(header, sizeof(header), "cpu-count"); 362 j = get_cpu_count(get_physical_die_id(cpu), 363 get_physical_die_id(cpu)); 364 snprintf(value, sizeof(value), "%d", j); 365 format_and_print(outf, level + 2, header, value); 366 367 j = CPU_COUNT_S(ctdp_level->core_cpumask_size, 368 ctdp_level->core_cpumask); 369 if (j) { 370 snprintf(header, sizeof(header), "enable-cpu-count"); 371 snprintf(value, sizeof(value), "%d", j); 372 format_and_print(outf, level + 2, header, value); 373 } 374 375 if (ctdp_level->core_cpumask_size) { 376 snprintf(header, sizeof(header), "enable-cpu-mask"); 377 printcpumask(sizeof(value), value, 378 ctdp_level->core_cpumask_size, 379 ctdp_level->core_cpumask); 380 format_and_print(outf, level + 2, header, value); 381 382 snprintf(header, sizeof(header), "enable-cpu-list"); 383 printcpulist(sizeof(value), value, 384 ctdp_level->core_cpumask_size, 385 ctdp_level->core_cpumask); 386 format_and_print(outf, level + 2, header, value); 387 } 388 389 snprintf(header, sizeof(header), "thermal-design-power-ratio"); 390 snprintf(value, sizeof(value), "%d", ctdp_level->tdp_ratio); 391 format_and_print(outf, level + 2, header, value); 392 393 snprintf(header, sizeof(header), "base-frequency(MHz)"); 394 if (!ctdp_level->sse_p1) 395 ctdp_level->sse_p1 = ctdp_level->tdp_ratio; 396 snprintf(value, sizeof(value), "%d", 397 ctdp_level->sse_p1 * DISP_FREQ_MULTIPLIER); 398 format_and_print(outf, level + 2, header, value); 399 400 if (ctdp_level->avx2_p1) { 401 snprintf(header, sizeof(header), "base-frequency-avx2(MHz)"); 402 snprintf(value, sizeof(value), "%d", 403 ctdp_level->avx2_p1 * DISP_FREQ_MULTIPLIER); 404 format_and_print(outf, level + 2, header, value); 405 } 406 407 if (ctdp_level->avx512_p1) { 408 snprintf(header, sizeof(header), "base-frequency-avx512(MHz)"); 409 snprintf(value, sizeof(value), "%d", 410 ctdp_level->avx512_p1 * DISP_FREQ_MULTIPLIER); 411 format_and_print(outf, level + 2, header, value); 412 } 413 414 if (ctdp_level->uncore_p1) { 415 snprintf(header, sizeof(header), "uncore-frequency-min(MHz)"); 416 snprintf(value, sizeof(value), "%d", 417 ctdp_level->uncore_p1 * DISP_FREQ_MULTIPLIER); 418 format_and_print(outf, level + 2, header, value); 419 } 420 421 if (ctdp_level->uncore_p0) { 422 snprintf(header, sizeof(header), "uncore-frequency-max(MHz)"); 423 snprintf(value, sizeof(value), "%d", 424 ctdp_level->uncore_p0 * DISP_FREQ_MULTIPLIER); 425 format_and_print(outf, level + 2, header, value); 426 } 427 428 if (ctdp_level->mem_freq) { 429 snprintf(header, sizeof(header), "mem-frequency(MHz)"); 430 snprintf(value, sizeof(value), "%d", 431 ctdp_level->mem_freq * DISP_FREQ_MULTIPLIER); 432 format_and_print(outf, level + 2, header, value); 433 } 434 435 snprintf(header, sizeof(header), 436 "speed-select-turbo-freq"); 437 if (ctdp_level->fact_support) { 438 if (ctdp_level->fact_enabled) 439 snprintf(value, sizeof(value), "enabled"); 440 else 441 snprintf(value, sizeof(value), "disabled"); 442 } else 443 snprintf(value, sizeof(value), "unsupported"); 444 format_and_print(outf, level + 2, header, value); 445 446 snprintf(header, sizeof(header), 447 "speed-select-base-freq"); 448 if (ctdp_level->pbf_support) { 449 if (ctdp_level->pbf_enabled) 450 snprintf(value, sizeof(value), "enabled"); 451 else 452 snprintf(value, sizeof(value), "disabled"); 453 } else 454 snprintf(value, sizeof(value), "unsupported"); 455 format_and_print(outf, level + 2, header, value); 456 457 snprintf(header, sizeof(header), 458 "speed-select-core-power"); 459 if (ctdp_level->sst_cp_support) { 460 if (ctdp_level->sst_cp_enabled) 461 snprintf(value, sizeof(value), "enabled"); 462 else 463 snprintf(value, sizeof(value), "disabled"); 464 } else 465 snprintf(value, sizeof(value), "unsupported"); 466 format_and_print(outf, level + 2, header, value); 467 468 if (is_clx_n_platform()) { 469 if (ctdp_level->pbf_support) 470 _isst_pbf_display_information(cpu, outf, 471 tdp_level, 472 &ctdp_level->pbf_info, 473 level + 1); 474 continue; 475 } 476 477 if (ctdp_level->pkg_tdp) { 478 snprintf(header, sizeof(header), "thermal-design-power(W)"); 479 snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp); 480 format_and_print(outf, level + 2, header, value); 481 } 482 483 if (ctdp_level->t_proc_hot) { 484 snprintf(header, sizeof(header), "tjunction-max(C)"); 485 snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot); 486 format_and_print(outf, level + 2, header, value); 487 } 488 489 snprintf(header, sizeof(header), "turbo-ratio-limits-sse"); 490 format_and_print(outf, level + 2, header, NULL); 491 for (j = 0; j < 8; ++j) { 492 snprintf(header, sizeof(header), "bucket-%d", j); 493 format_and_print(outf, level + 3, 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, level + 4, header, value); 498 499 snprintf(header, sizeof(header), 500 "max-turbo-frequency(MHz)"); 501 snprintf(value, sizeof(value), "%d", 502 ctdp_level->trl_sse_active_cores[j] * 503 DISP_FREQ_MULTIPLIER); 504 format_and_print(outf, level + 4, header, value); 505 } 506 507 if (ctdp_level->trl_avx_active_cores[0]) { 508 snprintf(header, sizeof(header), "turbo-ratio-limits-avx2"); 509 format_and_print(outf, level + 2, header, NULL); 510 for (j = 0; j < 8; ++j) { 511 snprintf(header, sizeof(header), "bucket-%d", j); 512 format_and_print(outf, level + 3, header, NULL); 513 514 snprintf(header, sizeof(header), "core-count"); 515 snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff); 516 format_and_print(outf, level + 4, header, value); 517 518 snprintf(header, sizeof(header), "max-turbo-frequency(MHz)"); 519 snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_active_cores[j] * DISP_FREQ_MULTIPLIER); 520 format_and_print(outf, level + 4, header, value); 521 } 522 } 523 524 if (ctdp_level->trl_avx_512_active_cores[0]) { 525 snprintf(header, sizeof(header), "turbo-ratio-limits-avx512"); 526 format_and_print(outf, level + 2, header, NULL); 527 for (j = 0; j < 8; ++j) { 528 snprintf(header, sizeof(header), "bucket-%d", j); 529 format_and_print(outf, level + 3, header, NULL); 530 531 snprintf(header, sizeof(header), "core-count"); 532 snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff); 533 format_and_print(outf, level + 4, header, value); 534 535 snprintf(header, sizeof(header), "max-turbo-frequency(MHz)"); 536 snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_512_active_cores[j] * DISP_FREQ_MULTIPLIER); 537 format_and_print(outf, level + 4, header, value); 538 } 539 } 540 541 if (ctdp_level->pbf_support) 542 _isst_pbf_display_information(cpu, outf, i, 543 &ctdp_level->pbf_info, 544 level + 2); 545 if (ctdp_level->fact_support) 546 _isst_fact_display_information(cpu, outf, i, 0xff, 0xff, 547 &ctdp_level->fact_info, 548 level + 2); 549 } 550 551 format_and_print(outf, 1, NULL, NULL); 552 } 553 554 static int start; 555 void isst_ctdp_display_information_start(FILE *outf) 556 { 557 last_level = 0; 558 format_and_print(outf, 0, "start", NULL); 559 start = 1; 560 } 561 562 void isst_ctdp_display_information_end(FILE *outf) 563 { 564 format_and_print(outf, 0, NULL, NULL); 565 start = 0; 566 } 567 568 void isst_pbf_display_information(int cpu, FILE *outf, int level, 569 struct isst_pbf_info *pbf_info) 570 { 571 int _level; 572 573 _level = print_package_info(cpu, outf); 574 _isst_pbf_display_information(cpu, outf, level, pbf_info, _level + 1); 575 format_and_print(outf, 1, NULL, NULL); 576 } 577 578 void isst_fact_display_information(int cpu, FILE *outf, int level, 579 int fact_bucket, int fact_avx, 580 struct isst_fact_info *fact_info) 581 { 582 int _level; 583 584 _level = print_package_info(cpu, outf); 585 _isst_fact_display_information(cpu, outf, level, fact_bucket, fact_avx, 586 fact_info, _level + 1); 587 format_and_print(outf, 1, NULL, NULL); 588 } 589 590 void isst_clos_display_information(int cpu, FILE *outf, int clos, 591 struct isst_clos_config *clos_config) 592 { 593 char header[256]; 594 char value[256]; 595 int level; 596 597 level = print_package_info(cpu, outf); 598 599 snprintf(header, sizeof(header), "core-power"); 600 format_and_print(outf, level + 1, header, NULL); 601 602 snprintf(header, sizeof(header), "clos"); 603 snprintf(value, sizeof(value), "%d", clos); 604 format_and_print(outf, level + 2, header, value); 605 606 snprintf(header, sizeof(header), "epp"); 607 snprintf(value, sizeof(value), "%d", clos_config->epp); 608 format_and_print(outf, level + 2, header, value); 609 610 snprintf(header, sizeof(header), "clos-proportional-priority"); 611 snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio); 612 format_and_print(outf, level + 2, header, value); 613 614 snprintf(header, sizeof(header), "clos-min"); 615 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * DISP_FREQ_MULTIPLIER); 616 format_and_print(outf, level + 2, header, value); 617 618 snprintf(header, sizeof(header), "clos-max"); 619 if (clos_config->clos_max == 0xff) 620 snprintf(value, sizeof(value), "Max Turbo frequency"); 621 else 622 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * DISP_FREQ_MULTIPLIER); 623 format_and_print(outf, level + 2, header, value); 624 625 snprintf(header, sizeof(header), "clos-desired"); 626 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * DISP_FREQ_MULTIPLIER); 627 format_and_print(outf, level + 2, header, value); 628 629 format_and_print(outf, level, NULL, NULL); 630 } 631 632 void isst_clos_display_clos_information(int cpu, FILE *outf, 633 int clos_enable, int type, 634 int state, int cap) 635 { 636 char header[256]; 637 char value[256]; 638 int level; 639 640 level = print_package_info(cpu, outf); 641 642 snprintf(header, sizeof(header), "core-power"); 643 format_and_print(outf, level + 1, header, NULL); 644 645 snprintf(header, sizeof(header), "support-status"); 646 if (cap) 647 snprintf(value, sizeof(value), "supported"); 648 else 649 snprintf(value, sizeof(value), "unsupported"); 650 format_and_print(outf, level + 2, header, value); 651 652 snprintf(header, sizeof(header), "enable-status"); 653 if (state) 654 snprintf(value, sizeof(value), "enabled"); 655 else 656 snprintf(value, sizeof(value), "disabled"); 657 format_and_print(outf, level + 2, header, value); 658 659 snprintf(header, sizeof(header), "clos-enable-status"); 660 if (clos_enable) 661 snprintf(value, sizeof(value), "enabled"); 662 else 663 snprintf(value, sizeof(value), "disabled"); 664 format_and_print(outf, level + 2, header, value); 665 666 snprintf(header, sizeof(header), "priority-type"); 667 if (type) 668 snprintf(value, sizeof(value), "ordered"); 669 else 670 snprintf(value, sizeof(value), "proportional"); 671 format_and_print(outf, level + 2, header, value); 672 673 format_and_print(outf, level, NULL, NULL); 674 } 675 676 void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos) 677 { 678 char header[256]; 679 char value[256]; 680 int level; 681 682 level = print_package_info(cpu, outf); 683 684 snprintf(header, sizeof(header), "get-assoc"); 685 format_and_print(outf, level + 1, header, NULL); 686 687 snprintf(header, sizeof(header), "clos"); 688 snprintf(value, sizeof(value), "%d", clos); 689 format_and_print(outf, level + 2, header, value); 690 691 format_and_print(outf, level, NULL, NULL); 692 } 693 694 void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd, 695 int result) 696 { 697 char header[256]; 698 char value[256]; 699 int level = 3; 700 701 if (cpu >= 0) 702 level = print_package_info(cpu, outf); 703 704 snprintf(header, sizeof(header), "%s", feature); 705 format_and_print(outf, level + 1, header, NULL); 706 snprintf(header, sizeof(header), "%s", cmd); 707 if (!result) 708 snprintf(value, sizeof(value), "success"); 709 else 710 snprintf(value, sizeof(value), "failed(error %d)", result); 711 format_and_print(outf, level + 2, header, value); 712 713 format_and_print(outf, level, NULL, NULL); 714 } 715 716 void isst_display_error_info_message(int error, char *msg, int arg_valid, int arg) 717 { 718 FILE *outf = get_output_file(); 719 static int error_index; 720 char header[256]; 721 char value[256]; 722 723 if (!out_format_is_json()) { 724 if (arg_valid) 725 snprintf(value, sizeof(value), "%s %d", msg, arg); 726 else 727 snprintf(value, sizeof(value), "%s", msg); 728 729 if (error) 730 fprintf(outf, "Error: %s\n", value); 731 else 732 fprintf(outf, "Information: %s\n", value); 733 return; 734 } 735 736 if (!start) 737 format_and_print(outf, 0, "start", NULL); 738 739 if (error) 740 snprintf(header, sizeof(header), "Error%d", error_index++); 741 else 742 snprintf(header, sizeof(header), "Information:%d", error_index++); 743 format_and_print(outf, 1, header, NULL); 744 745 snprintf(header, sizeof(header), "message"); 746 if (arg_valid) 747 snprintf(value, sizeof(value), "%s %d", msg, arg); 748 else 749 snprintf(value, sizeof(value), "%s", msg); 750 751 format_and_print(outf, 2, header, value); 752 format_and_print(outf, 1, NULL, NULL); 753 if (!start) 754 format_and_print(outf, 0, NULL, NULL); 755 } 756