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