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 if (is_clx_n_platform()) { 422 if (ctdp_level->pbf_support) 423 _isst_pbf_display_information(cpu, outf, 424 tdp_level, 425 &ctdp_level->pbf_info, 426 base_level + 4); 427 continue; 428 } 429 430 if (ctdp_level->pkg_tdp) { 431 snprintf(header, sizeof(header), "thermal-design-power(W)"); 432 snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp); 433 format_and_print(outf, base_level + 4, header, value); 434 } 435 436 if (ctdp_level->t_proc_hot) { 437 snprintf(header, sizeof(header), "tjunction-max(C)"); 438 snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot); 439 format_and_print(outf, base_level + 4, header, value); 440 } 441 442 snprintf(header, sizeof(header), "turbo-ratio-limits-sse"); 443 format_and_print(outf, base_level + 4, header, NULL); 444 for (j = 0; j < 8; ++j) { 445 snprintf(header, sizeof(header), "bucket-%d", j); 446 format_and_print(outf, base_level + 5, header, NULL); 447 448 snprintf(header, sizeof(header), "core-count"); 449 snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff); 450 format_and_print(outf, base_level + 6, header, value); 451 452 snprintf(header, sizeof(header), 453 "max-turbo-frequency(MHz)"); 454 snprintf(value, sizeof(value), "%d", 455 ctdp_level->trl_sse_active_cores[j] * 456 DISP_FREQ_MULTIPLIER); 457 format_and_print(outf, base_level + 6, header, value); 458 } 459 460 if (ctdp_level->trl_avx_active_cores[0]) { 461 snprintf(header, sizeof(header), "turbo-ratio-limits-avx2"); 462 format_and_print(outf, base_level + 4, header, NULL); 463 for (j = 0; j < 8; ++j) { 464 snprintf(header, sizeof(header), "bucket-%d", j); 465 format_and_print(outf, base_level + 5, header, NULL); 466 467 snprintf(header, sizeof(header), "core-count"); 468 snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff); 469 format_and_print(outf, base_level + 6, header, value); 470 471 snprintf(header, sizeof(header), "max-turbo-frequency(MHz)"); 472 snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_active_cores[j] * DISP_FREQ_MULTIPLIER); 473 format_and_print(outf, base_level + 6, header, value); 474 } 475 } 476 477 if (ctdp_level->trl_avx_512_active_cores[0]) { 478 snprintf(header, sizeof(header), "turbo-ratio-limits-avx512"); 479 format_and_print(outf, base_level + 4, header, NULL); 480 for (j = 0; j < 8; ++j) { 481 snprintf(header, sizeof(header), "bucket-%d", j); 482 format_and_print(outf, base_level + 5, header, NULL); 483 484 snprintf(header, sizeof(header), "core-count"); 485 snprintf(value, sizeof(value), "%llu", (ctdp_level->buckets_info >> (j * 8)) & 0xff); 486 format_and_print(outf, base_level + 6, header, value); 487 488 snprintf(header, sizeof(header), "max-turbo-frequency(MHz)"); 489 snprintf(value, sizeof(value), "%d", ctdp_level->trl_avx_512_active_cores[j] * DISP_FREQ_MULTIPLIER); 490 format_and_print(outf, base_level + 6, header, value); 491 } 492 } 493 494 if (ctdp_level->pbf_support) 495 _isst_pbf_display_information(cpu, outf, i, 496 &ctdp_level->pbf_info, 497 base_level + 4); 498 if (ctdp_level->fact_support) 499 _isst_fact_display_information(cpu, outf, i, 0xff, 0xff, 500 &ctdp_level->fact_info, 501 base_level + 4); 502 } 503 504 format_and_print(outf, 1, NULL, NULL); 505 } 506 507 void isst_ctdp_display_information_start(FILE *outf) 508 { 509 last_level = 0; 510 format_and_print(outf, 0, "start", NULL); 511 } 512 513 void isst_ctdp_display_information_end(FILE *outf) 514 { 515 format_and_print(outf, 0, NULL, NULL); 516 } 517 518 void isst_pbf_display_information(int cpu, FILE *outf, int level, 519 struct isst_pbf_info *pbf_info) 520 { 521 print_package_info(cpu, outf); 522 _isst_pbf_display_information(cpu, outf, level, pbf_info, 4); 523 format_and_print(outf, 1, NULL, NULL); 524 } 525 526 void isst_fact_display_information(int cpu, FILE *outf, int level, 527 int fact_bucket, int fact_avx, 528 struct isst_fact_info *fact_info) 529 { 530 print_package_info(cpu, outf); 531 _isst_fact_display_information(cpu, outf, level, fact_bucket, fact_avx, 532 fact_info, 4); 533 format_and_print(outf, 1, NULL, NULL); 534 } 535 536 void isst_clos_display_information(int cpu, FILE *outf, int clos, 537 struct isst_clos_config *clos_config) 538 { 539 char header[256]; 540 char value[256]; 541 542 snprintf(header, sizeof(header), "package-%d", 543 get_physical_package_id(cpu)); 544 format_and_print(outf, 1, header, NULL); 545 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 546 format_and_print(outf, 2, header, NULL); 547 snprintf(header, sizeof(header), "cpu-%d", cpu); 548 format_and_print(outf, 3, header, NULL); 549 550 snprintf(header, sizeof(header), "core-power"); 551 format_and_print(outf, 4, header, NULL); 552 553 snprintf(header, sizeof(header), "clos"); 554 snprintf(value, sizeof(value), "%d", clos); 555 format_and_print(outf, 5, header, value); 556 557 snprintf(header, sizeof(header), "epp"); 558 snprintf(value, sizeof(value), "%d", clos_config->epp); 559 format_and_print(outf, 5, header, value); 560 561 snprintf(header, sizeof(header), "clos-proportional-priority"); 562 snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio); 563 format_and_print(outf, 5, header, value); 564 565 snprintf(header, sizeof(header), "clos-min"); 566 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * DISP_FREQ_MULTIPLIER); 567 format_and_print(outf, 5, header, value); 568 569 snprintf(header, sizeof(header), "clos-max"); 570 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * DISP_FREQ_MULTIPLIER); 571 format_and_print(outf, 5, header, value); 572 573 snprintf(header, sizeof(header), "clos-desired"); 574 snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * DISP_FREQ_MULTIPLIER); 575 format_and_print(outf, 5, header, value); 576 577 format_and_print(outf, 1, NULL, NULL); 578 } 579 580 void isst_clos_display_clos_information(int cpu, FILE *outf, 581 int clos_enable, int type) 582 { 583 char header[256]; 584 char value[256]; 585 586 snprintf(header, sizeof(header), "package-%d", 587 get_physical_package_id(cpu)); 588 format_and_print(outf, 1, header, NULL); 589 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 590 format_and_print(outf, 2, header, NULL); 591 snprintf(header, sizeof(header), "cpu-%d", cpu); 592 format_and_print(outf, 3, header, NULL); 593 594 snprintf(header, sizeof(header), "core-power"); 595 format_and_print(outf, 4, header, NULL); 596 597 snprintf(header, sizeof(header), "enable-status"); 598 snprintf(value, sizeof(value), "%d", clos_enable); 599 format_and_print(outf, 5, header, value); 600 601 snprintf(header, sizeof(header), "priority-type"); 602 snprintf(value, sizeof(value), "%d", type); 603 format_and_print(outf, 5, header, value); 604 605 format_and_print(outf, 1, NULL, NULL); 606 } 607 608 void isst_clos_display_assoc_information(int cpu, FILE *outf, int clos) 609 { 610 char header[256]; 611 char value[256]; 612 613 snprintf(header, sizeof(header), "package-%d", 614 get_physical_package_id(cpu)); 615 format_and_print(outf, 1, header, NULL); 616 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 617 format_and_print(outf, 2, header, NULL); 618 snprintf(header, sizeof(header), "cpu-%d", cpu); 619 format_and_print(outf, 3, header, NULL); 620 621 snprintf(header, sizeof(header), "get-assoc"); 622 format_and_print(outf, 4, header, NULL); 623 624 snprintf(header, sizeof(header), "clos"); 625 snprintf(value, sizeof(value), "%d", clos); 626 format_and_print(outf, 5, header, value); 627 628 format_and_print(outf, 1, NULL, NULL); 629 } 630 631 void isst_display_result(int cpu, FILE *outf, char *feature, char *cmd, 632 int result) 633 { 634 char header[256]; 635 char value[256]; 636 637 snprintf(header, sizeof(header), "package-%d", 638 get_physical_package_id(cpu)); 639 format_and_print(outf, 1, header, NULL); 640 snprintf(header, sizeof(header), "die-%d", get_physical_die_id(cpu)); 641 format_and_print(outf, 2, header, NULL); 642 snprintf(header, sizeof(header), "cpu-%d", cpu); 643 format_and_print(outf, 3, header, NULL); 644 snprintf(header, sizeof(header), "%s", feature); 645 format_and_print(outf, 4, header, NULL); 646 snprintf(header, sizeof(header), "%s", cmd); 647 if (!result) 648 snprintf(value, sizeof(value), "success"); 649 else 650 snprintf(value, sizeof(value), "failed(error %d)", result); 651 format_and_print(outf, 5, header, value); 652 653 format_and_print(outf, 1, NULL, NULL); 654 } 655