Repository navigation
Expand file tree
/
Copy pathtb_ctl.c
More file actions
1807 lines (1612 loc) · 63 KB
/
Copy pathtb_ctl.c
File metadata and controls
1807 lines (1612 loc) · 63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2026 Intel Corporation. All rights reserved.
//
// sof-tb-ctl: Command-Line & Interactive Network Control Tool for SOF Testbench4
// Supports all SOFR v1 binary opcodes (0x0000 - 0x0076), dynamic IPC4 pipeline
// and module construction, topology load/unload/run-test, scheduler & buffer
// telemetry, workload simulation, and persistent interactive REPL / batch scripts.
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include "testbench/sof_remote_proto.h"
static uint32_t g_req_seq = 1;
static int read_exact(int fd, void *buf, size_t len)
{
uint8_t *p = (uint8_t *)buf;
size_t rem = len;
while (rem > 0) {
ssize_t n = recv(fd, p, rem, 0);
if (n <= 0) {
if (n < 0 && errno == EINTR)
continue;
return -1;
}
p += n;
rem -= (size_t)n;
}
return 0;
}
static int write_exact(int fd, const void *buf, size_t len)
{
const uint8_t *p = (const uint8_t *)buf;
size_t rem = len;
while (rem > 0) {
ssize_t n = send(fd, p, rem, MSG_NOSIGNAL);
if (n <= 0) {
if (n < 0 && errno == EINTR)
continue;
return -1;
}
p += n;
rem -= (size_t)n;
}
return 0;
}
static int connect_server(const char *host, int port)
{
struct addrinfo hints, *res = NULL, *rp;
char port_str[16];
int sock = -1;
int one = 1;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
snprintf(port_str, sizeof(port_str), "%d", port);
if (getaddrinfo(host, port_str, &hints, &res) != 0) {
char ssh_host[128];
const char *alt = sof_resolve_ssh_host(host, ssh_host, sizeof(ssh_host));
if (alt == host || getaddrinfo(alt, port_str, &hints, &res) != 0)
return -1;
}
for (rp = res; rp != NULL; rp = rp->ai_next) {
sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (sock < 0)
continue;
if (connect(sock, rp->ai_addr, rp->ai_addrlen) == 0)
break;
close(sock);
sock = -1;
}
freeaddrinfo(res);
if (sock >= 0)
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
return sock;
}
static int rpc_call(int sock, uint16_t opcode, const void *req_payload, uint32_t req_len,
struct sof_net_hdr *rsp_hdr_out, uint8_t **rsp_payload_out);
static uint32_t g_last_wire_bytes;
static uint32_t g_last_raw_bytes;
static bool g_server_no_compress;
static int rpc_call(int sock, uint16_t opcode, const void *req_payload, uint32_t req_len,
struct sof_net_hdr *rsp_hdr_out, uint8_t **rsp_payload_out)
{
uint16_t wire_op = g_server_no_compress ? opcode :
(uint16_t)(opcode | SOF_NET_OP_FLAG_COMPRESSED);
struct sof_net_hdr req_hdr = {
.magic = SOF_NET_MAGIC,
.version = SOF_NET_VERSION,
.opcode = wire_op,
.req_id = g_req_seq++,
.payload_len = req_payload ? req_len : 0,
.status = 0,
};
struct sof_net_hdr rsp_hdr;
uint8_t *buf = NULL;
if (rsp_payload_out)
*rsp_payload_out = NULL;
if (write_exact(sock, &req_hdr, sizeof(req_hdr)) < 0)
return -EIO;
if (req_payload && req_len > 0) {
if (write_exact(sock, req_payload, req_len) < 0)
return -EIO;
}
if (read_exact(sock, &rsp_hdr, sizeof(rsp_hdr)) < 0)
return -EIO;
if (rsp_hdr.magic != SOF_NET_MAGIC)
return -EPROTO;
/* Fallback for older servers that do not recognize SOF_NET_OP_FLAG_COMPRESSED */
if (rsp_hdr.status == -ENOSYS && !g_server_no_compress && rsp_hdr.payload_len == 0) {
g_server_no_compress = true;
return rpc_call(sock, opcode, req_payload, req_len, rsp_hdr_out, rsp_payload_out);
}
g_last_wire_bytes = rsp_hdr.payload_len;
g_last_raw_bytes = rsp_hdr.payload_len;
if (rsp_hdr.payload_len > 0) {
buf = calloc(1, rsp_hdr.payload_len + 1);
if (!buf)
return -ENOMEM;
if (read_exact(sock, buf, rsp_hdr.payload_len) < 0) {
free(buf);
return -EIO;
}
buf[rsp_hdr.payload_len] = '\0';
if ((rsp_hdr.opcode & SOF_NET_OP_FLAG_COMPRESSED) &&
rsp_hdr.payload_len >= sizeof(struct sof_net_comp_hdr)) {
uint8_t *dbuf = NULL;
uint32_t dlen = 0;
if (sof_net_decompress(buf, rsp_hdr.payload_len, &dbuf, &dlen) != 0) {
free(buf);
return -EPROTO;
}
free(buf);
buf = dbuf;
rsp_hdr.payload_len = dlen;
rsp_hdr.opcode &= SOF_NET_OP_MASK;
g_last_raw_bytes = dlen;
if (rsp_hdr.opcode == SOF_NET_OP_TELEM_SNAPSHOT &&
dlen >= sizeof(struct sof_net_telem_snapshot)) {
struct sof_net_telem_snapshot *sn =
(struct sof_net_telem_snapshot *)buf;
if (sn->flags_present & SOF_TELEM_FL_PMW2_WIN3)
sof_tel_pmw2_to_legacy_win3(sn->perf_win3, sn->pmw2_win3);
}
}
} else {
rsp_hdr.opcode &= SOF_NET_OP_MASK;
}
if (rsp_hdr_out)
*rsp_hdr_out = rsp_hdr;
if (rsp_payload_out)
*rsp_payload_out = buf;
else
free(buf);
return rsp_hdr.status;
}
static uint8_t *load_file_or_hex(const char *arg, uint32_t *len_out)
{
FILE *fp = fopen(arg, "rb");
*len_out = 0;
if (fp) {
long sz;
uint8_t *buf;
fseek(fp, 0, SEEK_END);
sz = ftell(fp);
fseek(fp, 0, SEEK_SET);
if (sz <= 0) {
fclose(fp);
return NULL;
}
buf = malloc((size_t)sz);
if (!buf) {
fclose(fp);
return NULL;
}
if (fread(buf, 1, (size_t)sz, fp) != (size_t)sz) {
free(buf);
fclose(fp);
return NULL;
}
fclose(fp);
*len_out = (uint32_t)sz;
return buf;
}
/* Parse hex string (with or without 0x/colons/spaces) */
size_t slen = strlen(arg);
uint8_t *buf = malloc(slen / 2 + 4);
uint32_t idx = 0;
const char *p = arg;
if (!buf)
return NULL;
if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X'))
p += 2;
while (*p) {
while (*p && !isxdigit((unsigned char)*p))
p++;
if (!*p)
break;
char h[3] = { p[0], p[1] ? p[1] : '0', '\0' };
buf[idx++] = (uint8_t)strtoul(h, NULL, 16);
p += p[1] ? 2 : 1;
}
*len_out = idx;
return buf;
}
static void hexdump(const uint8_t *data, uint32_t len, uint32_t base_off)
{
uint32_t i, j;
for (i = 0; i < len; i += 16) {
printf(" %06x: ", base_off + i);
for (j = 0; j < 16; j++) {
if (i + j < len)
printf("%02x ", data[i + j]);
else
printf(" ");
}
printf(" |");
for (j = 0; j < 16 && i + j < len; j++) {
uint8_t c = data[i + j];
printf("%c", (c >= 32 && c < 127) ? c : '.');
}
printf("|\n");
}
}
static int exec_shell_cmd(int sock, const char *cmd_str, bool check_err_lines)
{
struct sof_net_hdr rhdr;
uint8_t *rbuf = NULL;
uint32_t clen = (uint32_t)strlen(cmd_str) + 1;
uint32_t req_len = sizeof(struct sof_net_shell_req) + clen;
uint8_t *req_buf = calloc(1, req_len);
struct sof_net_shell_req *sreq;
int st;
int ret = 0;
if (!req_buf)
return -ENOMEM;
sreq = (struct sof_net_shell_req *)req_buf;
sreq->timeout_ms = 30000;
sreq->cmd_len = clen;
memcpy(req_buf + sizeof(*sreq), cmd_str, clen);
st = rpc_call(sock, SOF_NET_OP_SHELL_EXEC, req_buf, req_len, &rhdr, &rbuf);
free(req_buf);
if (st < 0) {
fprintf(stderr, "error: shell RPC failed (%d)\n", st);
free(rbuf);
return st;
}
if (rbuf && rhdr.payload_len > 0) {
printf("%s", (char *)rbuf);
if (((char *)rbuf)[rhdr.payload_len - 1] != '\n')
printf("\n");
if (check_err_lines) {
if (strncmp((char *)rbuf, "error:", 6) == 0 ||
strstr((char *)rbuf, "\nerror:") != NULL)
ret = 1;
}
}
free(rbuf);
return ret;
}
static int exec_joined_shell_cmd(int sock, const char *prefix, int argc, char **argv,
bool check_err_lines)
{
char cmd_buf[8192];
size_t off = 0;
int i;
if (prefix && *prefix)
off += snprintf(cmd_buf + off, sizeof(cmd_buf) - off, "%s", prefix);
for (i = 0; i < argc && off + 256 < sizeof(cmd_buf); i++) {
bool has_space = strchr(argv[i], ' ') != NULL || strchr(argv[i], '\t') != NULL;
bool prev_is_flag = (i > 0 && argv[i - 1][0] == '-');
if (off > 0)
off += snprintf(cmd_buf + off, sizeof(cmd_buf) - off, " ");
if (has_space && prev_is_flag && argv[i][0] != '"' && argv[i][0] != '\'')
off += snprintf(cmd_buf + off, sizeof(cmd_buf) - off, "\"%s\"", argv[i]);
else
off += snprintf(cmd_buf + off, sizeof(cmd_buf) - off, "%s", argv[i]);
}
return exec_shell_cmd(sock, cmd_buf, check_err_lines);
}
static void print_usage(const char *prog)
{
printf("Usage: %s [-H <host>] [-p <port>] [-f <script_file>] [command [args...]]\n\n"
"Options:\n"
" -H <host> Target testbench IP address (default: 127.0.0.1)\n"
" -p <port> Target testbench TCP port (default: 9998)\n"
" -f <file> Execute batch commands from <file> over 1 connection\n"
" -h, --help Show this help message\n\n"
"Core & Device Opcodes:\n"
" ping Ping server (SOF_NET_OP_PING)\n"
" info Get device & FW info (SOF_NET_OP_GET_INFO)\n"
" pm [query|wake|release|boot|core-get|core-put] [core] PM control (SOF_NET_OP_PM_CTL)\n"
" core <get|put|enable|disable> <core_id> Enable/disable DSP core\n"
" win-info List SRAM windows & debug slots\n"
" win-read <win_id> <offset> <size> [slot_type] Read SRAM window bytes\n"
" win-write <win_id> <offset> <hex_or_file> Write SRAM window bytes\n"
" winstream [cmd_text] Exchange Zephyr winstream shell I/O\n\n"
"IPC4, Large Config & Dynamic Module Loading:\n"
" ipc-tx <prim_hex> <ext_hex> [data_hex|file] [rx_sz] Send raw IPC4 message\n"
" large-cfg-get <mod> <inst> <param> [sz] [out_file] Get IPC4 large config\n"
" large-cfg-set <mod> <inst> <param> <hex_or_file> Set IPC4 large config\n"
" llext-load <file.llext|.so> [lib_id] [name] Load dynamic module (SOF_NET_OP_LLEXT_LOAD)\n\n"
"Interactive Topology, Pipeline, Platform & Module Construction:\n"
" platform-cfg [status | presets | preset <name> | cores <N> |\n"
" mem <hpsram[,lpsram[,dram]]> | freq <mhz_or_hz | core:freq,...>]\n"
" Configure/query platform hardware specs\n"
" run-test -t <tplg> [-A <plat>] [-N <cores>] [-m <mem>] [-F <freq>] [-p <pipes>]\n"
" [-i <in>] [-o <out>] [-r <rate>] [-R <rate>] [-c <ch>] [-n <ch>]\n"
" [-b <fmt>] [-s <ctl>] [-w <m>] [-M <m>]\n"
" Run full topology test in persistent server\n"
" io-cfg [-i <in>] [-o <out>] [-r <rate>] [-R <rate>] [-c <ch>] [-n <ch>] [-b <fmt>]\n"
" tplg-load <file.tplg> [p1,p2,...] Load topology and start pipelines\n"
" tplg-unload Reset and unload active topology\n"
" pipelines | widgets | modules | controls Inspect active pipelines, widgets & kctls\n"
" ppl-create <id> [prio] [core] Create IPC4 pipeline\n"
" ppl-state <id> <run|pause|reset> Set IPC4 pipeline state\n"
" ppl-delete <id> Delete IPC4 pipeline\n"
" mod-init <mod> <inst> <ppl> [core] [dom] Initialize IPC4 module instance\n"
" mod-bind <sm> <si> <sq> <dm> <di> <dq> Bind source module queue to destination\n"
" mod-unbind <sm> <si> <sq> <dm> <di> <dq> Unbind module instances\n"
" mod-delete <mod_id> <inst_id> Delete module instance\n\n"
"Telemetry, Workload Simulation, Probes & Audio Control:\n"
" telem [mask_hex] Get composite telemetry snapshot\n"
" sched-telem | sched-telem-reset Show/reset per-core/pipe/module telemetry\n"
" sched-trace [N] [--core C] [--pipe P] [--comp ID] [--domain ll|dp|sync] [--json F] [--clear]\n"
" Get per-iteration LL/DP module scheduling timeline\n"
" mod-buffers [id_or_name] Show module entry/exit buffer levels & taps\n"
" stats | heap Show file I/O stats and module heap usage\n"
" workload-sim [get | set <off|virtual|realtime> [sram|dram] [factor] [cyc_word] |\n"
" freq <spec> | mem <sram|dram> [factor] [cyc] | mod <id> <cpc> [mem] | reset]\n"
" probes [avail | active | extract [comp_id] [out.raw]]\n"
" pcm [status | start-tone [dev] [freq] [rate] [ch] | stop-tone |\n"
" play <file.raw> [dev] [rate] [ch] | capture <ms> [out.raw]]\n"
" compr <status|caps|play|pause|resume|stop> [card] [dev] [file]\n"
" cards | pcm-caps [card] [dev] | dapm [out.dot]\n"
" kctl <list | get <id_or_name> | set <id_or_name> <v0> [v1...] | set-bytes <id> <file>>\n"
" pause | resume | step [N] | loglevel <0..4> | quit\n"
" shell <cmd...> | repl Execute shell command or start REPL\n",
prog);
}
static int dispatch_command(int sock, int argc, char **argv)
{
struct sof_net_hdr rhdr;
uint8_t *rbuf = NULL;
const char *cmd;
int st;
if (argc <= 0 || !argv[0])
return 0;
cmd = argv[0];
if (strcmp(cmd, "help") == 0 || strcmp(cmd, "-h") == 0 || strcmp(cmd, "--help") == 0) {
print_usage("sof-tb-ctl");
return 0;
}
if (strcmp(cmd, "ping") == 0) {
st = rpc_call(sock, SOF_NET_OP_PING, NULL, 0, &rhdr, &rbuf);
if (st == 0 && rbuf)
printf("PING -> %s (req_id=%u, status=%d)\n",
(char *)rbuf, rhdr.req_id, rhdr.status);
else
fprintf(stderr, "error: PING failed (%d)\n", st);
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "info") == 0) {
st = rpc_call(sock, SOF_NET_OP_GET_INFO, NULL, 0, &rhdr, &rbuf);
if (st == 0 && rbuf && rhdr.payload_len >= sizeof(struct sof_cdev_info)) {
const struct sof_cdev_info *inf = (const struct sof_cdev_info *)rbuf;
printf("=== SOF Device & Firmware Info ===\n"
" Platform: %s (IPC%u, HW IP v%u)\n"
" FW Version: v%u.%u.%u.%u (state=%u)\n"
" Topology/FW: %s\n"
" Power State: %s (pm_runtime=%u)\n"
" DSP Cores: %u total, enabled_mask=0x%x\n"
" Max IPC Size: %u bytes\n",
inf->platform, inf->ipc_type == 1 ? 4 : 3, inf->hw_ip_version,
inf->fw_ver_major, inf->fw_ver_minor,
inf->fw_ver_micro, inf->fw_ver_build, inf->fw_state,
inf->fw_filename[0] ? inf->fw_filename : "(none)",
inf->dsp_power_state == 1 ? "D0 (ACTIVE)" : "D3 (SUSPENDED)",
inf->pm_runtime_active,
inf->num_cores, inf->enabled_cores_mask,
inf->max_payload_size);
} else {
fprintf(stderr, "error: GET_INFO failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "pm") == 0 || strcmp(cmd, "core") == 0) {
struct sof_cdev_pm_ctl req = {0};
const char *sub = (argc > 1) ? argv[1] : "query";
if (strcmp(cmd, "core") == 0) {
if (strcmp(sub, "get") == 0 || strcmp(sub, "enable") == 0)
req.op = SOF_PM_OP_CORE_GET;
else if (strcmp(sub, "put") == 0 || strcmp(sub, "disable") == 0)
req.op = SOF_PM_OP_CORE_PUT;
else
req.op = SOF_PM_OP_QUERY;
req.core_id = (argc > 2) ? (uint32_t)atoi(argv[2]) : 0;
} else {
if (strcmp(sub, "wake") == 0)
req.op = SOF_PM_OP_WAKE_HOLD;
else if (strcmp(sub, "release") == 0)
req.op = SOF_PM_OP_RELEASE_HOLD;
else if (strcmp(sub, "boot") == 0)
req.op = SOF_PM_OP_BOOT_DSP;
else if (strcmp(sub, "core-get") == 0)
req.op = SOF_PM_OP_CORE_GET;
else if (strcmp(sub, "core-put") == 0)
req.op = SOF_PM_OP_CORE_PUT;
else
req.op = SOF_PM_OP_QUERY;
req.core_id = (argc > 2) ? (uint32_t)atoi(argv[2]) : 0;
}
st = rpc_call(sock, SOF_NET_OP_PM_CTL, &req, sizeof(req), &rhdr, &rbuf);
if (st == 0 && rbuf && rhdr.payload_len >= sizeof(req)) {
const struct sof_cdev_pm_ctl *rsp = (const struct sof_cdev_pm_ctl *)rbuf;
printf("PM_CTL(op=%u, core=%u) -> fw_state=%u power=%s cores_mask=0x%x d0_hold=%u\n",
rsp->op, rsp->core_id, rsp->fw_state,
rsp->dsp_power_state == 1 ? "D0" : "D3",
rsp->enabled_cores_mask, rsp->fd_holding_d0);
} else {
fprintf(stderr, "error: PM_CTL failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "ipc-tx") == 0) {
if (argc < 3) {
fprintf(stderr, "Usage: ipc-tx <primary_hex> <extension_hex> [payload_hex_or_file] [rx_size]\n");
return 1;
}
struct sof_net_ipc_tx_req ireq = {0};
uint8_t *tx_data = NULL;
uint32_t tx_len = 0;
ireq.primary = (uint32_t)strtoul(argv[1], NULL, 0);
ireq.extension = (uint32_t)strtoul(argv[2], NULL, 0);
if (argc > 3 && strcmp(argv[3], "-") != 0 && strcmp(argv[3], "0") != 0)
tx_data = load_file_or_hex(argv[3], &tx_len);
ireq.tx_size = tx_len;
ireq.rx_size = (argc > 4) ? (uint32_t)strtoul(argv[4], NULL, 0) : 0;
uint8_t *req_buf = calloc(1, sizeof(ireq) + tx_len);
if (!req_buf) {
free(tx_data);
return 1;
}
memcpy(req_buf, &ireq, sizeof(ireq));
if (tx_data && tx_len > 0)
memcpy(req_buf + sizeof(ireq), tx_data, tx_len);
free(tx_data);
st = rpc_call(sock, SOF_NET_OP_IPC_TX, req_buf, sizeof(ireq) + tx_len, &rhdr, &rbuf);
free(req_buf);
if (st == 0 && rbuf && rhdr.payload_len >= sizeof(struct sof_net_ipc_tx_rsp)) {
const struct sof_net_ipc_tx_rsp *rsp = (const struct sof_net_ipc_tx_rsp *)rbuf;
printf("IPC_TX -> reply_primary=0x%08x reply_ext=0x%08x ipc_status=%d rx_size=%u\n",
rsp->reply_primary, rsp->reply_extension, rsp->ipc_status, rsp->rx_size);
if (rsp->rx_size > 0 && rhdr.payload_len >= sizeof(*rsp) + rsp->rx_size)
hexdump(rbuf + sizeof(*rsp), rsp->rx_size, 0);
} else {
fprintf(stderr, "error: IPC_TX failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "large-cfg-get") == 0) {
if (argc < 4) {
fprintf(stderr, "Usage: large-cfg-get <mod_id> <inst_id> <param_id> [max_size] [out_file]\n");
return 1;
}
struct sof_net_large_cfg_req lreq = {
.module_id = (uint32_t)strtoul(argv[1], NULL, 0),
.instance_id = (uint32_t)strtoul(argv[2], NULL, 0),
.param_id = (uint32_t)strtoul(argv[3], NULL, 0),
.set_get = SOF_CDEV_LARGE_CFG_GET,
.data_size = (argc > 4) ? (uint32_t)strtoul(argv[4], NULL, 0) : 4096,
.flags = 0,
};
st = rpc_call(sock, SOF_NET_OP_IPC_LARGE_CFG, &lreq, sizeof(lreq), &rhdr, &rbuf);
if (st == 0) {
printf("LARGE_CFG_GET(mod=0x%x, inst=%u, param=%u) -> %u bytes\n",
lreq.module_id, lreq.instance_id, lreq.param_id, rhdr.payload_len);
if (argc > 5 && rbuf && rhdr.payload_len > 0) {
FILE *fp = fopen(argv[5], "wb");
if (fp) {
fwrite(rbuf, 1, rhdr.payload_len, fp);
fclose(fp);
printf("Saved %u bytes to %s\n", rhdr.payload_len, argv[5]);
}
} else if (rbuf && rhdr.payload_len > 0) {
hexdump(rbuf, rhdr.payload_len < 256 ? rhdr.payload_len : 256, 0);
}
} else {
fprintf(stderr, "error: LARGE_CFG_GET failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "large-cfg-set") == 0) {
if (argc < 5) {
fprintf(stderr, "Usage: large-cfg-set <mod_id> <inst_id> <param_id> <hex_or_file>\n");
return 1;
}
uint32_t dlen = 0;
uint8_t *dbytes = load_file_or_hex(argv[4], &dlen);
if (!dbytes || dlen == 0) {
fprintf(stderr, "error: invalid payload '%s'\n", argv[4]);
free(dbytes);
return 1;
}
struct sof_net_large_cfg_req lreq = {
.module_id = (uint32_t)strtoul(argv[1], NULL, 0),
.instance_id = (uint32_t)strtoul(argv[2], NULL, 0),
.param_id = (uint32_t)strtoul(argv[3], NULL, 0),
.set_get = SOF_CDEV_LARGE_CFG_SET,
.data_size = dlen,
.flags = 0,
};
uint8_t *req_buf = calloc(1, sizeof(lreq) + dlen);
memcpy(req_buf, &lreq, sizeof(lreq));
memcpy(req_buf + sizeof(lreq), dbytes, dlen);
free(dbytes);
st = rpc_call(sock, SOF_NET_OP_IPC_LARGE_CFG, req_buf, sizeof(lreq) + dlen, &rhdr, &rbuf);
free(req_buf);
free(rbuf);
if (st == 0)
printf("LARGE_CFG_SET(mod=0x%x, inst=%u, param=%u, size=%u) -> OK\n",
lreq.module_id, lreq.instance_id, lreq.param_id, dlen);
else
fprintf(stderr, "error: LARGE_CFG_SET failed (%d)\n", st);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "win-info") == 0) {
st = rpc_call(sock, SOF_NET_OP_WIN_INFO, NULL, 0, &rhdr, &rbuf);
if (st == 0 && rbuf && rhdr.payload_len >= sizeof(struct sof_cdev_win_info)) {
const struct sof_cdev_win_info *wi = (const struct sof_cdev_win_info *)rbuf;
int i;
printf("=== Emulated DSP SRAM Windows ===\n");
for (i = 0; i < SOF_CDEV_MAX_WINDOWS; i++) {
if (!wi->windows[i].size)
continue;
printf(" [Window %u] bar_offset=0x%06x size=%6u flags=0x%x\n",
wi->windows[i].win_id, wi->windows[i].bar_offset,
wi->windows[i].size, wi->windows[i].flags);
}
printf("=== Window 2 Debug Slots ===\n");
for (i = 0; i < SOF_CDEV_MAX_DEBUG_SLOTS; i++) {
if (!wi->debug_slots[i].type)
continue;
printf(" [Slot %2d] res_id=0x%08x type=0x%08x vma=0x%08x off=0x%05x size=%u\n",
wi->debug_slots[i].slot_index, wi->debug_slots[i].res_id,
wi->debug_slots[i].type, wi->debug_slots[i].vma,
wi->debug_slots[i].win_offset, wi->debug_slots[i].size);
}
} else {
fprintf(stderr, "error: WIN_INFO failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "win-read") == 0) {
if (argc < 4) {
fprintf(stderr, "Usage: win-read <win_id> <offset> <size> [slot_type]\n");
return 1;
}
struct sof_net_win_io_req wreq = {
.win_id = (uint32_t)strtoul(argv[1], NULL, 0),
.offset = (uint32_t)strtoul(argv[2], NULL, 0),
.size = (uint32_t)strtoul(argv[3], NULL, 0),
.slot_type = (argc > 4) ? (uint32_t)strtoul(argv[4], NULL, 0) : 0,
.slot_index = 0,
.flags = 0,
};
st = rpc_call(sock, SOF_NET_OP_WIN_READ, &wreq, sizeof(wreq), &rhdr, &rbuf);
if (st == 0 && rbuf) {
printf("WIN_READ(win=%u, off=0x%x, size=%u):\n",
wreq.win_id, wreq.offset, rhdr.payload_len);
hexdump(rbuf, rhdr.payload_len, wreq.offset);
} else {
fprintf(stderr, "error: WIN_READ failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "win-write") == 0) {
if (argc < 4) {
fprintf(stderr, "Usage: win-write <win_id> <offset> <hex_or_file>\n");
return 1;
}
uint32_t dlen = 0;
uint8_t *dbytes = load_file_or_hex(argv[3], &dlen);
if (!dbytes || dlen == 0) {
free(dbytes);
return 1;
}
struct sof_net_win_io_req wreq = {
.win_id = (uint32_t)strtoul(argv[1], NULL, 0),
.offset = (uint32_t)strtoul(argv[2], NULL, 0),
.size = dlen,
};
uint8_t *req_buf = calloc(1, sizeof(wreq) + dlen);
memcpy(req_buf, &wreq, sizeof(wreq));
memcpy(req_buf + sizeof(wreq), dbytes, dlen);
free(dbytes);
st = rpc_call(sock, SOF_NET_OP_WIN_WRITE, req_buf, sizeof(wreq) + dlen, &rhdr, &rbuf);
free(req_buf);
free(rbuf);
if (st == 0)
printf("WIN_WRITE(win=%u, off=0x%x, size=%u) -> OK\n",
wreq.win_id, wreq.offset, dlen);
else
fprintf(stderr, "error: WIN_WRITE failed (%d)\n", st);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "winstream") == 0) {
const char *tx_cmd = (argc > 1) ? argv[1] : "version";
uint32_t tx_len = (uint32_t)strlen(tx_cmd);
struct sof_net_winstream_req wsreq = {
.slot_type = SOF_CDEV_SLOT_SHELL,
.rx_win_size = 4096,
.tx_len = tx_len,
.rx_buf_len = 4096,
.seq_in = 0,
};
uint8_t *req_buf = calloc(1, sizeof(wsreq) + tx_len);
memcpy(req_buf, &wsreq, sizeof(wsreq));
memcpy(req_buf + sizeof(wsreq), tx_cmd, tx_len);
st = rpc_call(sock, SOF_NET_OP_WINSTREAM_IO, req_buf, sizeof(wsreq) + tx_len, &rhdr, &rbuf);
free(req_buf);
if (st == 0 && rbuf && rhdr.payload_len >= sizeof(struct sof_net_winstream_rsp)) {
const struct sof_net_winstream_rsp *wsrsp =
(const struct sof_net_winstream_rsp *)rbuf;
printf("%.*s\n", (int)wsrsp->rx_bytes_read,
(const char *)(rbuf + sizeof(*wsrsp)));
} else {
fprintf(stderr, "error: WINSTREAM_IO failed (%d)\n", st);
}
free(rbuf);
return st < 0 ? 1 : 0;
}
if (strcmp(cmd, "telem") == 0) {
bool hot_req = (argc > 1 &&
(strcmp(argv[1], "--hot") == 0 || strcmp(argv[1], "hot") == 0));
uint32_t qmask = (argc > 1 && !hot_req) ?
(uint32_t)strtoul(argv[1], NULL, 0) :
(hot_req ?
(SOF_TELEM_FL_FW_REGS | SOF_TELEM_FL_TELEM_SLOT |
SOF_TELEM_FL_PERF_WIN3 | SOF_TELEM_FL_TEL2_SLOT |
SOF_TELEM_FL_PMW2_WIN3 | SOF_TELEM_FL_HOT_ONLY) :
(0x7FU | SOF_TELEM_FL_TEL2_SLOT | SOF_TELEM_FL_PMW2_WIN3));
struct sof_net_telem_req treq = {
.query_mask = qmask,
.flags = SOF_TELEM_FL_WAKE_DSP | SOF_TELEM_FL_COMPRESS |
(hot_req ? SOF_TELEM_FL_HOT_ONLY : 0),
};
st = rpc_call(sock, SOF_NET_OP_TELEM_SNAPSHOT, &treq, sizeof(treq), &rhdr, &rbuf);
if (st == 0 && rbuf && rhdr.payload_len >= SOF_NET_TELEM_SNAPSHOT_V1_SIZE) {
const struct sof_net_telem_snapshot *sn =
(const struct sof_net_telem_snapshot *)rbuf;
const uint32_t *r32 = (const uint32_t *)sn->fw_regs;
int i;
double saved_pct = g_last_raw_bytes > 0 ?
100.0 * (1.0 - (double)g_last_wire_bytes /
(double)g_last_raw_bytes) : 0.0;
printf("=== SOF Composite Telemetry Snapshot ===\n"
" Platform: %s (Topology: %s)\n"
" Wire Payload: %u B (%s, %.1f%% reduction from %u B raw)\n"
" Flags Present: 0x%03x, Active PCM Streams: %u\n"
" FW Regs: fw_status=0x%08x fps=0x%08x ticks=%u\n"
" TLV Sizes: mem=%uB pwr=%uB ext_perf=%uB modules=%uB\n",
sn->dev_info.platform,
sn->dev_info.fw_filename[0] ? sn->dev_info.fw_filename : "(none)",
g_last_wire_bytes,
(sn->flags_present & SOF_TELEM_FL_HOT_ONLY) ? "SOFZ+HOT_ONLY" : "SOFZ",
saved_pct, g_last_raw_bytes,
sn->flags_present, sn->active_pcm_streams,
r32[0], r32[2], r32[4],
sn->mem_state_len, sn->pwr_state_len,
sn->ext_perf_len, sn->modules_info_len);
if (sn->flags_present & SOF_TELEM_FL_TELEM_SLOT) {
uint32_t sep = *(const uint32_t *)sn->telem_slot;
int max_c = sn->dev_info.num_cores ?
(int)sn->dev_info.num_cores : (int)SOF_TEL_MAX_CORES;
printf(" [Systick Core Telemetry (sep=0x%08x)]\n", sep);
for (i = 0; i < max_c &&
4U + (size_t)(i + 1) * 32U <= sizeof(sn->telem_slot);
i++) {
const uint32_t *c =
(const uint32_t *)(sn->telem_slot + 4 + i * 32);
if (c[0] == 0 && c[4] == 0 && i > 0)
continue;
printf(" Core %d: ticks=%u last_cyc=%u max_cyc=%u avg_kcps=%u peak_kcps=%u\n",
i, c[0], c[1], c[2], c[4], c[5]);
}
}
/* Check extended TEL2 slot (MW2 Slot 1) */
const uint8_t *t2_buf = NULL;
uint32_t t2_len = 0;
if (rhdr.payload_len >= sizeof(struct sof_net_telem_snapshot) &&
(sn->flags_present & SOF_TELEM_FL_TEL2_SLOT) &&
sn->tel2_slot_len > 0) {
t2_buf = sn->tel2_slot;
t2_len = sn->tel2_slot_len <= sizeof(sn->tel2_slot) ?
sn->tel2_slot_len : (uint32_t)sizeof(sn->tel2_slot);
} else if (sn->flags_present & SOF_TELEM_FL_TELEM_SLOT) {
t2_buf = sn->telem_slot;
t2_len = sizeof(sn->telem_slot);
}
int bias = sof_tel2_slot_bias(t2_buf, t2_len);
if (bias >= 0) {
const struct sof_tel_ext_hdr *eh =
(const struct sof_tel_ext_hdr *)
(t2_buf + SOF_TEL_EXT_HDR_OFFSET - bias);
printf(" [MW2 Slot 1 Extended Telemetry 'TEL2' v%u (cores=%u, secs=%u, seq=%u, ts=%u us, bias=-%dB)]\n",
eh->version, eh->max_cores, eh->num_secs,
eh->seq, eh->timestamp_us, bias);
if (SOF_TEL_OFF_HOT_LINE0 - (uint32_t)bias +
sizeof(struct sof_tel_hot_line0) <= t2_len) {
const struct sof_tel_hot_line0 *h0 =
(const struct sof_tel_hot_line0 *)
(t2_buf + SOF_TEL_OFF_HOT_LINE0 - bias);
printf(" Hot Zone: total_xruns=%u | Core LL overruns=[%u,%u,%u,%u,%u] DP misses=[%u,%u,%u,%u,%u] LL tasks=[%u,%u,%u,%u,%u]\n",
h0->total_xrun_events,
h0->ll_overrun_count[0], h0->ll_overrun_count[1],
h0->ll_overrun_count[2], h0->ll_overrun_count[3],
h0->ll_overrun_count[4],
h0->dp_deadline_misses[0], h0->dp_deadline_misses[1],
h0->dp_deadline_misses[2], h0->dp_deadline_misses[3],
h0->dp_deadline_misses[4],
h0->active_ll_tasks[0], h0->active_ll_tasks[1],
h0->active_ll_tasks[2], h0->active_ll_tasks[3],
h0->active_ll_tasks[4]);
}
if (SOF_TEL_OFF_MEM_SEC - (uint32_t)bias +
sizeof(struct sof_tel_mem_section) <= t2_len) {
const struct sof_tel_mem_section *ms =
(const struct sof_tel_mem_section *)
(t2_buf + SOF_TEL_OFF_MEM_SEC - bias);
static const char * const hnames[] = {
"NONE", "SYS", "SHARED", "LL_USER", "L3_IMR", "DRV_USER"
};
printf(" Memory & SRAM: HP free=%u/%u pages, LP free=%u/%u pages, EBB=0x%04x%08x, VMH=%uB (%u bundles, oom=%u), fast_get=%u (%uB)\n",
ms->sram.hp_sram_free_pages,
ms->sram.hp_sram_total_pages,
ms->sram.lp_sram_free_pages,
ms->sram.lp_sram_total_pages,
ms->sram.ebb_power_mask_hi,
ms->sram.ebb_power_mask_lo,
ms->vmh_region_size, ms->vmh_bundle_count,
ms->vmh_oom_total,
ms->fast_get.active_entries,
ms->fast_get.total_sram_bytes);
for (i = 0; i < (int)SOF_TEL_MAX_HEAPS; i++) {
const struct sof_tel_heap_info *hi = &ms->heaps[i];
if (!hi->heap_type && !hi->total_bytes)
continue;
const char *hn = hi->heap_type < 6 ?
hnames[hi->heap_type] : "OTHER";
printf(" Heap[%d] %-8s: alloc=%7uB free=%7uB peak=%7uB total=%7uB fails=%u\n",
i, hn, hi->allocated_bytes, hi->free_bytes,
hi->max_allocated_bytes, hi->total_bytes,
hi->alloc_fail_count);
}
}
if (SOF_TEL_OFF_VREG_SEC - (uint32_t)bias +
sizeof(struct sof_tel_vregion_section) <= t2_len) {
const struct sof_tel_vregion_section *vs =
(const struct sof_tel_vregion_section *)
(t2_buf + SOF_TEL_OFF_VREG_SEC - bias);
printf(" Vregions: vpages free=%u/%u (min_free=%u, base_va=0x%08x, active_vreg=%u/%u, fails=%u)\n",
vs->free_pages, vs->total_pages, vs->min_free_pages,
vs->region_base_va, vs->active_vregion_count,
vs->total_vregions_created, vs->alloc_fail_count);
}
if (SOF_TEL_OFF_PPL_SEC - (uint32_t)bias +
sizeof(struct sof_tel_ppl_section) <= t2_len) {
const struct sof_tel_ppl_section *ps =
(const struct sof_tel_ppl_section *)
(t2_buf + SOF_TEL_OFF_PPL_SEC - bias);
printf(" Pipelines: active=%u, total_comps=%u\n",
ps->active_ppl_count, ps->total_comp_count);
for (i = 0; i < (int)ps->active_ppl_count &&
i < (int)SOF_TEL_MAX_PIPELINES; i++) {
const struct sof_tel_ppl_info *pi = &ps->pipelines[i];
printf(" PPL[%d] id=%u core=%u prio=%u status=%u comps=%u period=%u us sched_comp=0x%x\n",
i, pi->pipeline_id, pi->core, pi->priority,
pi->status, pi->comp_count, pi->period_us,
pi->sched_comp_id);
}
}
if (SOF_TEL_OFF_DAI_SEC - (uint32_t)bias +
sizeof(struct sof_tel_dai_section) <= t2_len &&
SOF_TEL_OFF_GW_HOT - (uint32_t)bias +
sizeof(struct sof_tel_gw_hot) * SOF_TEL_MAX_GATEWAYS <= t2_len) {
const struct sof_tel_dai_section *ds =
(const struct sof_tel_dai_section *)
(t2_buf + SOF_TEL_OFF_DAI_SEC - bias);
const struct sof_tel_gw_hot *gh =
(const struct sof_tel_gw_hot *)
(t2_buf + SOF_TEL_OFF_GW_HOT - bias);
static const char * const gwnames[] = {
"NONE", "SSP", "DMIC", "ALH", "HDA", "HOST_DMA", "OTHER"
};
for (i = 0; i < (int)SOF_TEL_MAX_GATEWAYS; i++) {
const struct sof_tel_gw_cold *gc = &ds->gateways[i];
if (!gc->gw_type)
continue;
const char *gn = gc->gw_type < 7 ?
gwnames[gc->gw_type] : "OTHER";
printf(" Gateway[%d] %-8s idx=%u dir=%s chan=%d comp=0x%04x state=%u period=%uB buf=%uB | hot: xfer=%uKB avail=%uB xruns=%u\n",
i, gn, gc->index,
gc->direction ? "CAP" : "PLAY",
gc->dma_chan, gc->comp_id, gc->state,
gc->period_bytes, gc->dma_buf_size,
gh[i].total_kb_or_frames,
gh[i].dma_buf_avail_bytes,
gh[i].xrun_or_skip_count);
}
} else if (SOF_TEL_OFF_GW_HOT - (uint32_t)bias +
sizeof(struct sof_tel_gw_hot) * SOF_TEL_MAX_GATEWAYS <= t2_len) {
const struct sof_tel_gw_hot *gh =
(const struct sof_tel_gw_hot *)
(t2_buf + SOF_TEL_OFF_GW_HOT - bias);
for (i = 0; i < (int)SOF_TEL_MAX_GATEWAYS; i++) {
if (!gh[i].total_kb_or_frames &&
!gh[i].dma_buf_avail_bytes &&
!gh[i].xrun_or_skip_count)
continue;
printf(" Gateway[%d] hot: xfer=%uKB avail=%uB xruns=%u\n",
i, gh[i].total_kb_or_frames,
gh[i].dma_buf_avail_bytes,
gh[i].xrun_or_skip_count);
}
}
if (SOF_TEL_OFF_THD_SEC - (uint32_t)bias +
sizeof(struct sof_tel_thread_section) <= t2_len) {
const struct sof_tel_thread_section *ts =
(const struct sof_tel_thread_section *)
(t2_buf + SOF_TEL_OFF_THD_SEC - bias);
printf(" Zephyr Threads: count=%u (dropped=%u, seq=%u)\n",
ts->thread_count, ts->dropped_threads,
ts->sample_seq);
for (i = 0; i < (int)ts->thread_count &&
i < (int)SOF_TEL_MAX_THREADS; i++) {
const struct sof_tel_thread_info *ti = &ts->threads[i];
char tname[9];
memcpy(tname, ti->name, 8);
tname[8] = '\0';
printf(" Thd[%2d] %-8s id=0x%08x core=%u prio=%3d cpu=%5.1f%% stack_hwm=%5.1f%% (%4uB) kcyc=%u\n",
i, tname, ti->thread_id, ti->core, ti->prio,
(ti->cpu_load * 100.0) / 255.0,
(ti->stack_usage * 100.0) / 255.0,
(unsigned int)ti->stack_size_chunks * 64U,
ti->total_exec_kcycles);
}
}
}
/* Check extended PMW2 window (MW3, 8 KB) */
if (rhdr.payload_len >= sizeof(struct sof_net_telem_snapshot) &&
(sn->flags_present & SOF_TELEM_FL_PMW2_WIN3) &&
sn->pmw2_win3_len >= sizeof(struct sof_tel_mw3_hdr) +
SOF_TEL_MW3_HDR_OFFSET) {
uint32_t w3_avail = sn->pmw2_win3_len <= sizeof(sn->pmw2_win3) ?
sn->pmw2_win3_len :
(uint32_t)sizeof(sn->pmw2_win3);
const uint8_t *w3 = sn->pmw2_win3;
const struct sof_tel_mw3_hdr *mh =
(const struct sof_tel_mw3_hdr *)(w3 + SOF_TEL_MW3_HDR_OFFSET);
if (mh->magic == SOF_TEL_MW3_MAGIC) {
uint32_t max_comp = mh->max_comp_entries <= SOF_TEL_MW3_MAX_COMP_ITEMS ?
mh->max_comp_entries : SOF_TEL_MW3_MAX_COMP_ITEMS;
uint32_t max_io = mh->max_io_entries <= SOF_TEL_MW3_MAX_IO_ITEMS ?
mh->max_io_entries : SOF_TEL_MW3_MAX_IO_ITEMS;
bool has_hot = (size_t)mh->mod_hot_offset +
(size_t)max_comp * sizeof(struct sof_tel_mod_hot) <= w3_avail;
bool has_cold = (size_t)mh->mod_cold_offset +
(size_t)max_comp * sizeof(struct sof_tel_mod_cold) <= w3_avail;
bool has_io = (size_t)mh->io_perf_offset +
(size_t)max_io * sizeof(struct sof_tel_io_perf_item) <= w3_avail;
printf(" [MW3 Extended Performance & Module Resources 'PMW2' v%u (max_comp=%u, max_io=%u)]\n",
mh->version, mh->max_comp_entries, mh->max_io_entries);