forked from linux-nvme/nvme-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvme-print-stdout.c
5223 lines (4642 loc) · 169 KB
/
nvme-print-stdout.c
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: GPL-2.0-or-later
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
#include <ccan/ccan/strset/strset.h>
#include <ccan/ccan/htable/htable_type.h>
#include <ccan/ccan/htable/htable.h>
#include <ccan/ccan/hash/hash.h>
#include "nvme.h"
#include "libnvme.h"
#include "nvme-print.h"
#include "nvme-models.h"
#include "util/suffix.h"
#include "util/types.h"
#include "common.h"
static const uint8_t zero_uuid[16] = { 0 };
static const uint8_t invalid_uuid[16] = {[0 ... 15] = 0xff };
static const char dash[100] = {[0 ... 99] = '-'};
static struct print_ops stdout_print_ops;
static const char *subsys_key(const struct nvme_subsystem *s)
{
return nvme_subsystem_get_name((nvme_subsystem_t)s);
}
static const char *ctrl_key(const struct nvme_ctrl *c)
{
return nvme_ctrl_get_name((nvme_ctrl_t)c);
}
static const char *ns_key(const struct nvme_ns *n)
{
return nvme_ns_get_name((nvme_ns_t)n);
}
static bool subsys_cmp(const struct nvme_subsystem *s, const char *name)
{
return !strcmp(nvme_subsystem_get_name((nvme_subsystem_t)s), name);
}
static bool ctrl_cmp(const struct nvme_ctrl *c, const char *name)
{
return !strcmp(nvme_ctrl_get_name((nvme_ctrl_t)c), name);
}
static bool ns_cmp(const struct nvme_ns *n, const char *name)
{
return !strcmp(nvme_ns_get_name((nvme_ns_t)n), name);
}
HTABLE_DEFINE_TYPE(struct nvme_subsystem, subsys_key, hash_string,
subsys_cmp, htable_subsys);
HTABLE_DEFINE_TYPE(struct nvme_ctrl, ctrl_key, hash_string,
ctrl_cmp, htable_ctrl);
HTABLE_DEFINE_TYPE(struct nvme_ns, ns_key, hash_string,
ns_cmp, htable_ns);
static void htable_ctrl_add_unique(struct htable_ctrl *ht, nvme_ctrl_t c)
{
if (htable_ctrl_get(ht, nvme_ctrl_get_name(c)))
return;
htable_ctrl_add(ht, c);
}
static void htable_ns_add_unique(struct htable_ns *ht, nvme_ns_t n)
{
struct htable_ns_iter it;
nvme_ns_t _n;
/*
* Test if namespace pointer is already in the hash, and thus avoid
* inserting severaltimes the same pointer.
*/
for (_n = htable_ns_getfirst(ht, nvme_ns_get_name(n), &it);
_n;
_n = htable_ns_getnext(ht, nvme_ns_get_name(n), &it)) {
if (_n == n)
return;
}
htable_ns_add(ht, n);
}
struct nvme_resources {
nvme_root_t r;
struct htable_subsys ht_s;
struct htable_ctrl ht_c;
struct htable_ns ht_n;
struct strset subsystems;
struct strset ctrls;
struct strset namespaces;
};
static int nvme_resources_init(nvme_root_t r, struct nvme_resources *res)
{
nvme_host_t h;
nvme_subsystem_t s;
nvme_ctrl_t c;
nvme_ns_t n;
nvme_path_t p;
res->r = r;
htable_subsys_init(&res->ht_s);
htable_ctrl_init(&res->ht_c);
htable_ns_init(&res->ht_n);
strset_init(&res->subsystems);
strset_init(&res->ctrls);
strset_init(&res->namespaces);
nvme_for_each_host(r, h) {
nvme_for_each_subsystem(h, s) {
htable_subsys_add(&res->ht_s, s);
strset_add(&res->subsystems, nvme_subsystem_get_name(s));
nvme_subsystem_for_each_ctrl(s, c) {
htable_ctrl_add_unique(&res->ht_c, c);
strset_add(&res->ctrls, nvme_ctrl_get_name(c));
nvme_ctrl_for_each_ns(c, n) {
htable_ns_add_unique(&res->ht_n, n);
strset_add(&res->namespaces, nvme_ns_get_name(n));
}
nvme_ctrl_for_each_path(c, p) {
n = nvme_path_get_ns(p);
if (n) {
htable_ns_add_unique(&res->ht_n, n);
strset_add(&res->namespaces, nvme_ns_get_name(n));
}
}
}
nvme_subsystem_for_each_ns(s, n) {
htable_ns_add_unique(&res->ht_n, n);
strset_add(&res->namespaces, nvme_ns_get_name(n));
}
}
}
return 0;
}
static void nvme_resources_free(struct nvme_resources *res)
{
strset_clear(&res->namespaces);
strset_clear(&res->ctrls);
strset_clear(&res->subsystems);
htable_ns_clear(&res->ht_n);
htable_ctrl_clear(&res->ht_c);
htable_subsys_clear(&res->ht_s);
}
static void stdout_feature_show_fields(enum nvme_features_id fid,
unsigned int result,
unsigned char *buf);
static void stdout_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname);
static void stdout_predictable_latency_per_nvmset(
struct nvme_nvmset_predictable_lat_log *plpns_log,
__u16 nvmset_id, const char *devname)
{
printf("Predictable Latency Per NVM Set Log for device: %s\n",
devname);
printf("Predictable Latency Per NVM Set Log for NVM Set ID: %u\n",
le16_to_cpu(nvmset_id));
printf("Status: %u\n", plpns_log->status);
printf("Event Type: %u\n",
le16_to_cpu(plpns_log->event_type));
printf("DTWIN Reads Typical: %"PRIu64"\n",
le64_to_cpu(plpns_log->dtwin_rt));
printf("DTWIN Writes Typical: %"PRIu64"\n",
le64_to_cpu(plpns_log->dtwin_wt));
printf("DTWIN Time Maximum: %"PRIu64"\n",
le64_to_cpu(plpns_log->dtwin_tmax));
printf("NDWIN Time Minimum High: %"PRIu64"\n",
le64_to_cpu(plpns_log->ndwin_tmin_hi));
printf("NDWIN Time Minimum Low: %"PRIu64"\n",
le64_to_cpu(plpns_log->ndwin_tmin_lo));
printf("DTWIN Reads Estimate: %"PRIu64"\n",
le64_to_cpu(plpns_log->dtwin_re));
printf("DTWIN Writes Estimate: %"PRIu64"\n",
le64_to_cpu(plpns_log->dtwin_we));
printf("DTWIN Time Estimate: %"PRIu64"\n\n\n",
le64_to_cpu(plpns_log->dtwin_te));
}
static void stdout_predictable_latency_event_agg_log(
struct nvme_aggregate_predictable_lat_event *pea_log,
__u64 log_entries, __u32 size, const char *devname)
{
__u64 num_iter;
__u64 num_entries;
num_entries = le64_to_cpu(pea_log->num_entries);
printf("Predictable Latency Event Aggregate Log for device: %s\n", devname);
printf("Number of Entries Available: %"PRIu64"\n", (uint64_t)num_entries);
num_iter = min(num_entries, log_entries);
for (int i = 0; i < num_iter; i++)
printf("Entry[%d]: %u\n", i + 1, le16_to_cpu(pea_log->entries[i]));
}
static void stdout_persistent_event_log_rci(__le32 pel_header_rci)
{
__u32 rci = le32_to_cpu(pel_header_rci);
__u32 rsvd19 = NVME_PEL_RCI_RSVD(rci);
__u8 rce = NVME_PEL_RCI_RCE(rci);
__u8 rcpit = NVME_PEL_RCI_RCPIT(rci);
__u16 rcpid = NVME_PEL_RCI_RCPID(rci);
if (rsvd19)
printf(" [31:19] : %#x\tReserved\n", rsvd19);
printf("\tReporting Context Exists (RCE): %s(%u)\n", rce ? "true" : "false", rce);
printf("\tReporting Context Port Identifier Type (RCPIT): %u(%s)\n", rcpit,
nvme_pel_rci_rcpit_to_string(rcpit));
printf("\tReporting Context Port Identifier (RCPID): %#x\n\n", rcpid);
}
static void stdout_persistent_event_entry_ehai(__u8 ehai)
{
__u8 rsvd1 = NVME_PEL_EHAI_RSVD(ehai);
__u8 pit = NVME_PEL_EHAI_PIT(ehai);
printf(" [7:2] : %#x\tReserved\n", rsvd1);
printf("\tPort Identifier Type (PIT): %u(%s)\n", pit, nvme_pel_ehai_pit_to_string(pit));
}
static void stdout_add_bitmap(int i, __u8 seb)
{
for (int bit = 0; bit < CHAR_BIT; bit++) {
if (nvme_pel_event_to_string(bit + i * CHAR_BIT)) {
if ((seb >> bit) & 0x1)
printf(" Support %s\n",
nvme_pel_event_to_string(bit + i * CHAR_BIT));
}
}
}
static void stdout_persistent_event_log(void *pevent_log_info,
__u8 action, __u32 size,
const char *devname)
{
__u32 offset, por_info_len, por_info_list;
__u64 *fw_rev;
int fid, cdw11, dword_cnt;
unsigned char *mem_buf = NULL;
struct nvme_smart_log *smart_event;
struct nvme_fw_commit_event *fw_commit_event;
struct nvme_time_stamp_change_event *ts_change_event;
struct nvme_power_on_reset_info_list *por_event;
struct nvme_nss_hw_err_event *nss_hw_err_event;
struct nvme_change_ns_event *ns_event;
struct nvme_format_nvm_start_event *format_start_event;
struct nvme_format_nvm_compln_event *format_cmpln_event;
struct nvme_sanitize_start_event *sanitize_start_event;
struct nvme_sanitize_compln_event *sanitize_cmpln_event;
struct nvme_set_feature_event *set_feat_event;
struct nvme_thermal_exc_event *thermal_exc_event;
struct nvme_persistent_event_log *pevent_log_head;
struct nvme_persistent_event_entry *pevent_entry_head;
int human = stdout_print_ops.flags & VERBOSE;
offset = sizeof(*pevent_log_head);
printf("Persistent Event Log for device: %s\n", devname);
printf("Action for Persistent Event Log: %u\n", action);
if (size >= offset) {
pevent_log_head = pevent_log_info;
printf("Log Identifier: %u\n", pevent_log_head->lid);
printf("Total Number of Events: %u\n",
le32_to_cpu(pevent_log_head->tnev));
printf("Total Log Length : %"PRIu64"\n",
le64_to_cpu(pevent_log_head->tll));
printf("Log Revision: %u\n", pevent_log_head->rv);
printf("Log Header Length: %u\n", pevent_log_head->lhl);
printf("Timestamp: %"PRIu64"\n",
le64_to_cpu(pevent_log_head->ts));
printf("Power On Hours (POH): %s",
uint128_t_to_l10n_string(le128_to_cpu(pevent_log_head->poh)));
printf("Power Cycle Count: %"PRIu64"\n",
le64_to_cpu(pevent_log_head->pcc));
printf("PCI Vendor ID (VID): %u\n",
le16_to_cpu(pevent_log_head->vid));
printf("PCI Subsystem Vendor ID (SSVID): %u\n",
le16_to_cpu(pevent_log_head->ssvid));
printf("Serial Number (SN): %-.*s\n",
(int)sizeof(pevent_log_head->sn), pevent_log_head->sn);
printf("Model Number (MN): %-.*s\n",
(int)sizeof(pevent_log_head->mn), pevent_log_head->mn);
printf("NVM Subsystem NVMe Qualified Name (SUBNQN): %-.*s\n",
(int)sizeof(pevent_log_head->subnqn),
pevent_log_head->subnqn);
printf("Generation Number: %u\n",
le16_to_cpu(pevent_log_head->gen_number));
printf("Reporting Context Information (RCI): %u\n",
le32_to_cpu(pevent_log_head->rci));
if (human)
stdout_persistent_event_log_rci(pevent_log_head->rci);
printf("Supported Events Bitmap:\n");
for (int i = 0; i < 32; i++) {
if (pevent_log_head->seb[i] == 0)
continue;
stdout_add_bitmap(i, pevent_log_head->seb[i]);
}
} else {
printf("No log data can be shown with this log len at least " \
"512 bytes is required or can be 0 to read the complete "\
"log page after context established\n");
return;
}
printf("\n");
printf("\nPersistent Event Entries:\n");
for (int i = 0; i < le32_to_cpu(pevent_log_head->tnev); i++) {
if (offset + sizeof(*pevent_entry_head) >= size)
break;
pevent_entry_head = pevent_log_info + offset;
if ((offset + pevent_entry_head->ehl + 3 +
le16_to_cpu(pevent_entry_head->el)) >= size)
break;
printf("Event Number: %u\n", i);
printf("Event Type: %s\n", nvme_pel_event_to_string(pevent_entry_head->etype));
printf("Event Type Revision: %u\n", pevent_entry_head->etype_rev);
printf("Event Header Length: %u\n", pevent_entry_head->ehl);
printf("Event Header Additional Info: %u\n", pevent_entry_head->ehai);
if (human)
stdout_persistent_event_entry_ehai(pevent_entry_head->ehai);
printf("Controller Identifier: %u\n",
le16_to_cpu(pevent_entry_head->cntlid));
printf("Event Timestamp: %"PRIu64"\n",
le64_to_cpu(pevent_entry_head->ets));
printf("Port Identifier: %u\n",
le16_to_cpu(pevent_entry_head->pelpid));
printf("Vendor Specific Information Length: %u\n",
le16_to_cpu(pevent_entry_head->vsil));
printf("Event Length: %u\n", le16_to_cpu(pevent_entry_head->el));
offset += pevent_entry_head->ehl + 3;
switch (pevent_entry_head->etype) {
case NVME_PEL_SMART_HEALTH_EVENT:
smart_event = pevent_log_info + offset;
printf("Smart Health Event Entry:\n");
stdout_smart_log(smart_event, NVME_NSID_ALL, devname);
break;
case NVME_PEL_FW_COMMIT_EVENT:
fw_commit_event = pevent_log_info + offset;
printf("FW Commit Event Entry:\n");
printf("Old Firmware Revision: %"PRIu64" (%s)\n",
le64_to_cpu(fw_commit_event->old_fw_rev),
util_fw_to_string((char *)&fw_commit_event->old_fw_rev));
printf("New Firmware Revision: %"PRIu64" (%s)\n",
le64_to_cpu(fw_commit_event->new_fw_rev),
util_fw_to_string((char *)&fw_commit_event->new_fw_rev));
printf("FW Commit Action: %u\n",
fw_commit_event->fw_commit_action);
printf("FW Slot: %u\n", fw_commit_event->fw_slot);
printf("Status Code Type for Firmware Commit Command: %u\n",
fw_commit_event->sct_fw);
printf("Status Returned for Firmware Commit Command: %u\n",
fw_commit_event->sc_fw);
printf("Vendor Assigned Firmware Commit Result Code: %u\n",
le16_to_cpu(fw_commit_event->vndr_assign_fw_commit_rc));
break;
case NVME_PEL_TIMESTAMP_EVENT:
ts_change_event = pevent_log_info + offset;
printf("Time Stamp Change Event Entry:\n");
printf("Previous Timestamp: %"PRIu64"\n",
le64_to_cpu(ts_change_event->previous_timestamp));
printf("Milliseconds Since Reset: %"PRIu64"\n",
le64_to_cpu(ts_change_event->ml_secs_since_reset));
break;
case NVME_PEL_POWER_ON_RESET_EVENT:
por_info_len = (le16_to_cpu(pevent_entry_head->el) -
le16_to_cpu(pevent_entry_head->vsil) - sizeof(*fw_rev));
por_info_list = por_info_len / sizeof(*por_event);
printf("Power On Reset Event Entry:\n");
fw_rev = pevent_log_info + offset;
printf("Firmware Revision: %"PRIu64" (%s)\n", le64_to_cpu(*fw_rev),
util_fw_to_string((char *)fw_rev));
printf("Reset Information List:\n");
for (int i = 0; i < por_info_list; i++) {
por_event = pevent_log_info + offset +
sizeof(*fw_rev) + i * sizeof(*por_event);
printf("Controller ID: %u\n", le16_to_cpu(por_event->cid));
printf("Firmware Activation: %u\n",
por_event->fw_act);
printf("Operation in Progress: %u\n",
por_event->op_in_prog);
printf("Controller Power Cycle: %u\n",
le32_to_cpu(por_event->ctrl_power_cycle));
printf("Power on milliseconds: %"PRIu64"\n",
le64_to_cpu(por_event->power_on_ml_seconds));
printf("Controller Timestamp: %"PRIu64"\n",
le64_to_cpu(por_event->ctrl_time_stamp));
}
break;
case NVME_PEL_NSS_HW_ERROR_EVENT:
nss_hw_err_event = pevent_log_info + offset;
printf("NVM Subsystem Hardware Error Event Code Entry: %u, %s\n",
le16_to_cpu(nss_hw_err_event->nss_hw_err_event_code),
nvme_nss_hw_error_to_string(nss_hw_err_event->nss_hw_err_event_code));
break;
case NVME_PEL_CHANGE_NS_EVENT:
ns_event = pevent_log_info + offset;
printf("Change Namespace Event Entry:\n");
printf("Namespace Management CDW10: %u\n",
le32_to_cpu(ns_event->nsmgt_cdw10));
printf("Namespace Size: %"PRIu64"\n",
le64_to_cpu(ns_event->nsze));
printf("Namespace Capacity: %"PRIu64"\n",
le64_to_cpu(ns_event->nscap));
printf("Formatted LBA Size: %u\n", ns_event->flbas);
printf("End-to-end Data Protection Type Settings: %u\n",
ns_event->dps);
printf("Namespace Multi-path I/O and Namespace Sharing" \
" Capabilities: %u\n", ns_event->nmic);
printf("ANA Group Identifier: %u\n",
le32_to_cpu(ns_event->ana_grp_id));
printf("NVM Set Identifier: %u\n", le16_to_cpu(ns_event->nvmset_id));
printf("Namespace ID: %u\n", le32_to_cpu(ns_event->nsid));
break;
case NVME_PEL_FORMAT_START_EVENT:
format_start_event = pevent_log_info + offset;
printf("Format NVM Start Event Entry:\n");
printf("Namespace Identifier: %u\n",
le32_to_cpu(format_start_event->nsid));
printf("Format NVM Attributes: %u\n",
format_start_event->fna);
printf("Format NVM CDW10: %u\n",
le32_to_cpu(format_start_event->format_nvm_cdw10));
break;
case NVME_PEL_FORMAT_COMPLETION_EVENT:
format_cmpln_event = pevent_log_info + offset;
printf("Format NVM Completion Event Entry:\n");
printf("Namespace Identifier: %u\n",
le32_to_cpu(format_cmpln_event->nsid));
printf("Smallest Format Progress Indicator: %u\n",
format_cmpln_event->smallest_fpi);
printf("Format NVM Status: %u\n",
format_cmpln_event->format_nvm_status);
printf("Completion Information: %u\n",
le16_to_cpu(format_cmpln_event->compln_info));
printf("Status Field: %u\n",
le32_to_cpu(format_cmpln_event->status_field));
break;
case NVME_PEL_SANITIZE_START_EVENT:
sanitize_start_event = pevent_log_info + offset;
printf("Sanitize Start Event Entry:\n");
printf("SANICAP: %u\n", sanitize_start_event->sani_cap);
printf("Sanitize CDW10: %u\n",
le32_to_cpu(sanitize_start_event->sani_cdw10));
printf("Sanitize CDW11: %u\n",
le32_to_cpu(sanitize_start_event->sani_cdw11));
break;
case NVME_PEL_SANITIZE_COMPLETION_EVENT:
sanitize_cmpln_event = pevent_log_info + offset;
printf("Sanitize Completion Event Entry:\n");
printf("Sanitize Progress: %u\n",
le16_to_cpu(sanitize_cmpln_event->sani_prog));
printf("Sanitize Status: %u\n",
le16_to_cpu(sanitize_cmpln_event->sani_status));
printf("Completion Information: %u\n",
le16_to_cpu(sanitize_cmpln_event->cmpln_info));
break;
case NVME_PEL_SET_FEATURE_EVENT:
set_feat_event = pevent_log_info + offset;
printf("Set Feature Event Entry:\n");
dword_cnt = NVME_SET_FEAT_EVENT_DW_COUNT(set_feat_event->layout);
fid = NVME_GET(le32_to_cpu(set_feat_event->cdw_mem[0]), FEATURES_CDW10_FID);
cdw11 = le32_to_cpu(set_feat_event->cdw_mem[1]);
printf("Set Feature ID :%#02x (%s), value:%#08x\n", fid,
nvme_feature_to_string(fid), cdw11);
if (NVME_SET_FEAT_EVENT_MB_COUNT(set_feat_event->layout)) {
mem_buf = (unsigned char *)(set_feat_event + 4 + dword_cnt * 4);
stdout_feature_show_fields(fid, cdw11, mem_buf);
}
break;
case NVME_PEL_TELEMETRY_CRT:
d(pevent_log_info + offset, 512, 16, 1);
break;
case NVME_PEL_THERMAL_EXCURSION_EVENT:
thermal_exc_event = pevent_log_info + offset;
printf("Thermal Excursion Event Entry:\n");
printf("Over Temperature: %u\n", thermal_exc_event->over_temp);
printf("Threshold: %u\n", thermal_exc_event->threshold);
break;
default:
printf("Reserved Event\n\n");
break;
}
offset += le16_to_cpu(pevent_entry_head->el);
printf("\n");
}
}
static void stdout_endurance_group_event_agg_log(
struct nvme_aggregate_predictable_lat_event *endurance_log,
__u64 log_entries, __u32 size, const char *devname)
{
printf("Endurance Group Event Aggregate Log for device: %s\n", devname);
printf("Number of Entries Available: %"PRIu64"\n",
le64_to_cpu(endurance_log->num_entries));
for (int i = 0; i < log_entries; i++) {
printf("Entry[%d]: %u\n", i + 1,
le16_to_cpu(endurance_log->entries[i]));
}
}
static void stdout_lba_status_log(void *lba_status, __u32 size,
const char *devname)
{
struct nvme_lba_status_log *hdr;
struct nvme_lbas_ns_element *ns_element;
struct nvme_lba_rd *range_desc;
int offset = sizeof(*hdr);
__u32 num_lba_desc, num_elements;
hdr = lba_status;
printf("LBA Status Log for device: %s\n", devname);
printf("LBA Status Log Page Length: %"PRIu32"\n",
le32_to_cpu(hdr->lslplen));
num_elements = le32_to_cpu(hdr->nlslne);
printf("Number of LBA Status Log Namespace Elements: %"PRIu32"\n",
num_elements);
printf("Estimate of Unrecoverable Logical Blocks: %"PRIu32"\n",
le32_to_cpu(hdr->estulb));
printf("LBA Status Generation Counter: %"PRIu16"\n", le16_to_cpu(hdr->lsgc));
for (int ele = 0; ele < num_elements; ele++) {
ns_element = lba_status + offset;
printf("Namespace Element Identifier: %"PRIu32"\n",
le32_to_cpu(ns_element->neid));
num_lba_desc = le32_to_cpu(ns_element->nlrd);
printf("Number of LBA Range Descriptors: %"PRIu32"\n", num_lba_desc);
printf("Recommended Action Type: %u\n", ns_element->ratype);
offset += sizeof(*ns_element);
if (num_lba_desc != 0xffffffff) {
for (int i = 0; i < num_lba_desc; i++) {
range_desc = lba_status + offset;
printf("RSLBA[%d]: %"PRIu64"\n", i,
le64_to_cpu(range_desc->rslba));
printf("RNLB[%d]: %"PRIu32"\n", i,
le32_to_cpu(range_desc->rnlb));
offset += sizeof(*range_desc);
}
} else {
printf("Number of LBA Range Descriptors (NLRD) set to %#x for "\
"NS element %d\n", num_lba_desc, ele);
}
}
}
static void stdout_resv_notif_log(struct nvme_resv_notification_log *resv,
const char *devname)
{
printf("Reservation Notif Log for device: %s\n", devname);
printf("Log Page Count : %"PRIx64"\n",
le64_to_cpu(resv->lpc));
printf("Resv Notif Log Page Type : %u (%s)\n",
resv->rnlpt,
nvme_resv_notif_to_string(resv->rnlpt));
printf("Num of Available Log Pages : %u\n", resv->nalp);
printf("Namespace ID: : %"PRIx32"\n",
le32_to_cpu(resv->nsid));
}
static void stdout_fid_support_effects_log_human(__u32 fid_support)
{
const char *set = "+";
const char *clr = "-";
__u16 fsp;
printf(" FSUPP+");
printf(" UDCC%s", (fid_support & NVME_FID_SUPPORTED_EFFECTS_UDCC) ? set : clr);
printf(" NCC%s", (fid_support & NVME_FID_SUPPORTED_EFFECTS_NCC) ? set : clr);
printf(" NIC%s", (fid_support & NVME_FID_SUPPORTED_EFFECTS_NIC) ? set : clr);
printf(" CCC%s", (fid_support & NVME_FID_SUPPORTED_EFFECTS_CCC) ? set : clr);
printf(" USS%s", (fid_support & NVME_FID_SUPPORTED_EFFECTS_UUID_SEL) ? set : clr);
fsp = NVME_GET(fid_support, FID_SUPPORTED_EFFECTS_SCOPE);
printf(" NAMESPACE SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_NS) ? set : clr);
printf(" CONTROLLER SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_CTRL) ? set : clr);
printf(" NVM SET SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_NVM_SET) ? set : clr);
printf(" ENDURANCE GROUP SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_ENDGRP) ? set : clr);
printf(" DOMAIN SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_DOMAIN) ? set : clr);
printf(" NVM Subsystem SCOPE%s", (fsp & NVME_FID_SUPPORTED_EFFECTS_SCOPE_NSS) ? set : clr);
}
static void stdout_fid_support_effects_log(struct nvme_fid_supported_effects_log *fid_log,
const char *devname)
{
__u32 fid_effect;
int i, human = stdout_print_ops.flags & VERBOSE;
printf("FID Supports Effects Log for device: %s\n", devname);
printf("Admin Command Set\n");
for (i = 0; i < 256; i++) {
fid_effect = le32_to_cpu(fid_log->fid_support[i]);
if (fid_effect & NVME_FID_SUPPORTED_EFFECTS_FSUPP) {
printf("FID %02x -> Support Effects Log: %08x", i,
fid_effect);
if (human)
stdout_fid_support_effects_log_human(fid_effect);
printf("\n");
}
}
}
static void stdout_mi_cmd_support_effects_log_human(__u32 mi_cmd_support)
{
const char *set = "+";
const char *clr = "-";
__u16 csp;
printf(" CSUPP+");
printf(" UDCC%s", (mi_cmd_support & NVME_MI_CMD_SUPPORTED_EFFECTS_UDCC) ? set : clr);
printf(" NCC%s", (mi_cmd_support & NVME_MI_CMD_SUPPORTED_EFFECTS_NCC) ? set : clr);
printf(" NIC%s", (mi_cmd_support & NVME_MI_CMD_SUPPORTED_EFFECTS_NIC) ? set : clr);
printf(" CCC%s", (mi_cmd_support & NVME_MI_CMD_SUPPORTED_EFFECTS_CCC) ? set : clr);
csp = NVME_GET(mi_cmd_support, MI_CMD_SUPPORTED_EFFECTS_SCOPE);
printf(" NAMESPACE SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_NS) ? set : clr);
printf(" CONTROLLER SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_CTRL) ? set : clr);
printf(" NVM SET SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_NVM_SET) ? set : clr);
printf(" ENDURANCE GROUP SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_ENDGRP) ? set : clr);
printf(" DOMAIN SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_DOMAIN) ? set : clr);
printf(" NVM Subsystem SCOPE%s", (csp & NVME_MI_CMD_SUPPORTED_EFFECTS_SCOPE_NSS) ? set : clr);
}
static void stdout_mi_cmd_support_effects_log(struct nvme_mi_cmd_supported_effects_log *mi_cmd_log,
const char *devname)
{
__u32 mi_cmd_effect;
int i, human = stdout_print_ops.flags & VERBOSE;
printf("MI Commands Support Effects Log for device: %s\n", devname);
printf("Admin Command Set\n");
for (i = 0; i < NVME_LOG_MI_CMD_SUPPORTED_EFFECTS_MAX; i++) {
mi_cmd_effect = le32_to_cpu(mi_cmd_log->mi_cmd_support[i]);
if (mi_cmd_effect & NVME_MI_CMD_SUPPORTED_EFFECTS_CSUPP) {
printf("MI CMD %02x -> Support Effects Log: %08x", i,
mi_cmd_effect);
if (human)
stdout_mi_cmd_support_effects_log_human(mi_cmd_effect);
printf("\n");
}
}
}
static void stdout_boot_part_log(void *bp_log, const char *devname,
__u32 size)
{
struct nvme_boot_partition *hdr = bp_log;
printf("Boot Partition Log for device: %s\n", devname);
printf("Log ID: %u\n", hdr->lid);
printf("Boot Partition Size: %u KiB\n",
NVME_BOOT_PARTITION_INFO_BPSZ(le32_to_cpu(hdr->bpinfo)));
printf("Active BPID: %u\n", NVME_BOOT_PARTITION_INFO_ABPID(le32_to_cpu(hdr->bpinfo)));
}
static const char *eomip_to_string(__u8 eomip)
{
const char *string;
switch (eomip) {
case NVME_PHY_RX_EOM_NOT_STARTED:
string = "Not Started";
break;
case NVME_PHY_RX_EOM_IN_PROGRESS:
string = "In Progress";
break;
case NVME_PHY_RX_EOM_COMPLETED:
string = "Completed";
break;
default:
string = "Unknown";
break;
}
return string;
}
static void stdout_phy_rx_eom_odp(uint8_t odp)
{
__u8 rsvd = NVME_EOM_ODP_RSVD(odp);
__u8 edfp = NVME_EOM_ODP_EDFP(odp);
__u8 pefp = NVME_EOM_ODP_PEFP(odp);
if (rsvd)
printf(" [7:2] : %#x\tReserved\n", rsvd);
printf(" [1:1] : %#x\tEye Data Field %sPresent\n",
edfp, edfp ? "" : "Not ");
printf(" [0:0] : %#x\tPrintable Eye Field %sPresent\n",
pefp, pefp ? "" : "Not ");
}
static void stdout_eom_printable_eye(struct nvme_eom_lane_desc *lane)
{
char *eye = (char *)lane->eye_desc;
int i, j;
for (i = 0; i < lane->nrows; i++) {
for (j = 0; j < lane->ncols; j++)
printf("%c", eye[i * lane->ncols + j]);
printf("\n");
}
}
static void stdout_phy_rx_eom_descs(struct nvme_phy_rx_eom_log *log)
{
void *p = log->descs;
int i;
for (i = 0; i < log->nd; i++) {
struct nvme_eom_lane_desc *desc = p;
printf("Measurement Status: %s\n",
desc->mstatus ? "Successful" : "Not Successful");
printf("Lane: %u\n", desc->lane);
printf("Eye: %u\n", desc->eye);
printf("Top: %u\n", le16_to_cpu(desc->top));
printf("Bottom: %u\n", le16_to_cpu(desc->bottom));
printf("Left: %u\n", le16_to_cpu(desc->left));
printf("Right: %u\n", le16_to_cpu(desc->right));
printf("Number of Rows: %u\n", le16_to_cpu(desc->nrows));
printf("Number of Columns: %u\n", le16_to_cpu(desc->ncols));
printf("Eye Data Length: %u\n", le16_to_cpu(desc->edlen));
if (NVME_EOM_ODP_PEFP(log->odp))
stdout_eom_printable_eye(desc);
/* Eye Data field is vendor specific */
p += log->dsize;
}
}
static void stdout_phy_rx_eom_log(struct nvme_phy_rx_eom_log *log, __u16 controller)
{
int human = stdout_print_ops.flags & VERBOSE;
printf("Physical Interface Receiver Eye Opening Measurement Log for controller ID: %u\n", controller);
printf("Log ID: %u\n", log->lid);
printf("EOM In Progress: %s\n", eomip_to_string(log->eomip));
printf("Header Size: %u\n", le16_to_cpu(log->hsize));
printf("Result Size: %u\n", le32_to_cpu(log->rsize));
printf("EOM Data Generation Number: %u\n", log->eomdgn);
printf("Log Revision: %u\n", log->lr);
printf("Optional Data Present: %u\n", log->odp);
if (human)
stdout_phy_rx_eom_odp(log->odp);
printf("Lanes: %u\n", log->lanes);
printf("Eyes Per Lane: %u\n", log->epl);
printf("Log Specific Parameter Field Copy: %u\n", log->lspfc);
printf("Link Information: %u\n", log->li);
printf("Log Specific Identifier Copy: %u\n", le16_to_cpu(log->lsic));
printf("Descriptor Size: %u\n", le32_to_cpu(log->dsize));
printf("Number of Descriptors: %u\n", le16_to_cpu(log->nd));
printf("Maximum Top Bottom: %u\n", le16_to_cpu(log->maxtb));
printf("Maximum Left Right: %u\n", le16_to_cpu(log->maxlr));
printf("Estimated Time for Good Quality: %u\n", le16_to_cpu(log->etgood));
printf("Estimated Time for Better Quality: %u\n", le16_to_cpu(log->etbetter));
printf("Estimated Time for Best Quality: %u\n", le16_to_cpu(log->etbest));
if (log->eomip == NVME_PHY_RX_EOM_COMPLETED)
stdout_phy_rx_eom_descs(log);
}
static void stdout_media_unit_stat_log(struct nvme_media_unit_stat_log *mus_log)
{
int i;
int nmu = le16_to_cpu(mus_log->nmu);
printf("Number of Media Unit Status Descriptors: %u\n", nmu);
printf("Number of Channels: %u\n", le16_to_cpu(mus_log->cchans));
printf("Selected Configuration: %u\n", le16_to_cpu(mus_log->sel_config));
for (i = 0; i < nmu; i++) {
printf("Media Unit Status Descriptor: %u\n", i);
printf("Media Unit Identifier: %u\n",
le16_to_cpu(mus_log->mus_desc[i].muid));
printf("Domain Identifier: %u\n",
le16_to_cpu(mus_log->mus_desc[i].domainid));
printf("Endurance Group Identifier: %u\n",
le16_to_cpu(mus_log->mus_desc[i].endgid));
printf("NVM Set Identifier: %u\n",
le16_to_cpu(mus_log->mus_desc[i].nvmsetid));
printf("Capacity Adjustment Factor: %u\n",
le16_to_cpu(mus_log->mus_desc[i].cap_adj_fctr));
printf("Available Spare: %u\n", mus_log->mus_desc[i].avl_spare);
printf("Percentage Used: %u\n", mus_log->mus_desc[i].percent_used);
printf("Number of Channels: %u\n", mus_log->mus_desc[i].mucs);
printf("Channel Identifiers Offset: %u\n", mus_log->mus_desc[i].cio);
}
}
static void stdout_fdp_config_fdpa(uint8_t fdpa)
{
__u8 valid = NVME_GET(fdpa, FDP_CONFIG_FDPA_VALID);
__u8 rsvd = (fdpa >> 5) & 0x3;
__u8 fdpvwc = NVME_GET(fdpa, FDP_CONFIG_FDPA_FDPVWC);
__u8 rgif = NVME_GET(fdpa, FDP_CONFIG_FDPA_RGIF);
printf(" [7:7] : %#x\tFDP Configuration %sValid\n",
valid, valid ? "" : "Not ");
if (rsvd)
printf(" [6:5] : %#x\tReserved\n", rsvd);
printf(" [4:4] : %#x\tFDP Volatile Write Cache %sPresent\n",
fdpvwc, fdpvwc ? "" : "Not ");
printf(" [3:0] : %#x\tReclaim Group Identifier Format\n", rgif);
}
static void stdout_fdp_configs(struct nvme_fdp_config_log *log, size_t len)
{
void *p = log->configs;
int human = stdout_print_ops.flags & VERBOSE;
uint16_t n;
n = le16_to_cpu(log->n) + 1;
for (int i = 0; i < n; i++) {
struct nvme_fdp_config_desc *config = p;
printf("FDP Attributes: %#x\n", config->fdpa);
if (human)
stdout_fdp_config_fdpa(config->fdpa);
printf("Vendor Specific Size: %u\n", config->vss);
printf("Number of Reclaim Groups: %"PRIu32"\n", le32_to_cpu(config->nrg));
printf("Number of Reclaim Unit Handles: %"PRIu16"\n", le16_to_cpu(config->nruh));
printf("Number of Namespaces Supported: %"PRIu32"\n", le32_to_cpu(config->nnss));
printf("Reclaim Unit Nominal Size: %"PRIu64"\n", le64_to_cpu(config->runs));
printf("Estimated Reclaim Unit Time Limit: %"PRIu32"\n", le32_to_cpu(config->erutl));
printf("Reclaim Unit Handle List:\n");
for (int j = 0; j < le16_to_cpu(config->nruh); j++) {
struct nvme_fdp_ruh_desc *ruh = &config->ruhs[j];
printf(" [%d]: %s\n", j, ruh->ruht == NVME_FDP_RUHT_INITIALLY_ISOLATED ? "Initially Isolated" : "Persistently Isolated");
}
p += config->size;
}
}
static void stdout_fdp_usage(struct nvme_fdp_ruhu_log *log, size_t len)
{
uint16_t nruh = le16_to_cpu(log->nruh);
for (int i = 0; i < nruh; i++) {
struct nvme_fdp_ruhu_desc *ruhu = &log->ruhus[i];
printf("Reclaim Unit Handle %d Attributes: %#"PRIx8" (%s)\n", i, ruhu->ruha,
ruhu->ruha == 0x0 ? "Unused" : (
ruhu->ruha == 0x1 ? "Host Specified" : (
ruhu->ruha == 0x2 ? "Controller Specified" : "Unknown")));
}
}
static void stdout_fdp_stats(struct nvme_fdp_stats_log *log)
{
printf("Host Bytes with Metadata Written (HBMW): %s\n",
uint128_t_to_l10n_string(le128_to_cpu(log->hbmw)));
printf("Media Bytes with Metadata Written (MBMW): %s\n",
uint128_t_to_l10n_string(le128_to_cpu(log->mbmw)));
printf("Media Bytes Erased (MBE): %s\n",
uint128_t_to_l10n_string(le128_to_cpu(log->mbe)));
}
static void stdout_fdp_events(struct nvme_fdp_events_log *log)
{
struct tm *tm;
char buffer[320];
time_t ts;
uint32_t n = le32_to_cpu(log->n);
for (unsigned int i = 0; i < n; i++) {
struct nvme_fdp_event *event = &log->events[i];
ts = int48_to_long(event->ts.timestamp) / 1000;
tm = localtime(&ts);
printf("Event[%u]\n", i);
printf(" Event Type: %#"PRIx8" (%s)\n", event->type,
nvme_fdp_event_to_string(event->type));
printf(" Event Timestamp: %"PRIu64" (%s)\n", int48_to_long(event->ts.timestamp),
strftime(buffer, sizeof(buffer), "%c %Z", tm) ? buffer : "-");
if (event->flags & NVME_FDP_EVENT_F_PIV)
printf(" Placement Identifier (PID): %#"PRIx16"\n",
le16_to_cpu(event->pid));
if (event->flags & NVME_FDP_EVENT_F_NSIDV)
printf(" Namespace Identifier (NSID): %"PRIu32"\n", le32_to_cpu(event->nsid));
if (event->type == NVME_FDP_EVENT_REALLOC) {
struct nvme_fdp_event_realloc *mr;
mr = (struct nvme_fdp_event_realloc *)&event->type_specific;
printf(" Number of LBAs Moved (NLBAM): %"PRIu16"\n", le16_to_cpu(mr->nlbam));
if (mr->flags & NVME_FDP_EVENT_REALLOC_F_LBAV)
printf(" Logical Block Address (LBA): %#"PRIx64"\n",
le64_to_cpu(mr->lba));
}
if (event->flags & NVME_FDP_EVENT_F_LV) {
printf(" Reclaim Group Identifier: %"PRIu16"\n", le16_to_cpu(event->rgid));
printf(" Reclaim Unit Handle Identifier %"PRIu8"\n", event->ruhid);
}
printf("\n");
}
}
static void stdout_fdp_ruh_status(struct nvme_fdp_ruh_status *status, size_t len)
{
uint16_t nruhsd = le16_to_cpu(status->nruhsd);
for (unsigned int i = 0; i < nruhsd; i++) {
struct nvme_fdp_ruh_status_desc *ruhs = &status->ruhss[i];
printf("Placement Identifier %"PRIu16"; Reclaim Unit Handle Identifier %"PRIu16"\n",
le16_to_cpu(ruhs->pid), le16_to_cpu(ruhs->ruhid));
printf(" Estimated Active Reclaim Unit Time Remaining (EARUTR): %"PRIu32"\n",
le32_to_cpu(ruhs->earutr));
printf(" Reclaim Unit Available Media Writes (RUAMW): %"PRIu64"\n",
le64_to_cpu(ruhs->ruamw));
printf("\n");
}
}
static void stdout_supported_cap_config_log(struct nvme_supported_cap_config_list_log *cap)
{
struct nvme_end_grp_chan_desc *chan_desc;
int i, j, k, l, m, sccn, egcn, egsets, egchans, chmus;
sccn = cap->sccn;
printf("Number of Supported Capacity Configurations: %u\n", sccn);
for (i = 0; i < sccn; i++) {
printf("Capacity Configuration Descriptor: %u\n", i);
printf("Capacity Configuration Identifier: %u\n",
le16_to_cpu(cap->cap_config_desc[i].cap_config_id));
printf("Domain Identifier: %u\n",
le16_to_cpu(cap->cap_config_desc[i].domainid));
egcn = le16_to_cpu(cap->cap_config_desc[i].egcn);
printf("Number of Endurance Group Configuration Descriptors: %u\n", egcn);
for (j = 0; j < egcn; j++) {
printf("Endurance Group Identifier: %u\n",
le16_to_cpu(cap->cap_config_desc[i].egcd[j].endgid));
printf("Capacity Adjustment Factor: %u\n",
le16_to_cpu(cap->cap_config_desc[i].egcd[j].cap_adj_factor));
printf("Total Endurance Group Capacity: %s\n",
uint128_t_to_l10n_string(le128_to_cpu(
cap->cap_config_desc[i].egcd[j].tegcap)));
printf("Spare Endurance Group Capacity: %s\n",
uint128_t_to_l10n_string(le128_to_cpu(
cap->cap_config_desc[i].egcd[j].segcap)));
printf("Endurance Estimate: %s\n",
uint128_t_to_l10n_string(le128_to_cpu(
cap->cap_config_desc[i].egcd[j].end_est)));
egsets = le16_to_cpu(cap->cap_config_desc[i].egcd[j].egsets);
printf("Number of NVM Sets: %u\n", egsets);
for (k = 0; k < egsets; k++)
printf("NVM Set %d Identifier: %u\n", i,
le16_to_cpu(cap->cap_config_desc[i].egcd[j].nvmsetid[k]));
chan_desc = (struct nvme_end_grp_chan_desc *)
&cap->cap_config_desc[i].egcd[j].nvmsetid[egsets];
egchans = le16_to_cpu(chan_desc->egchans);
printf("Number of Channels: %u\n", egchans);
for (l = 0; l < egchans; l++) {
printf("Channel Identifier: %u\n",
le16_to_cpu(chan_desc->chan_config_desc[l].chanid));
chmus = le16_to_cpu(chan_desc->chan_config_desc[l].chmus);
printf("Number of Channel Media Units: %u\n", chmus);
for (m = 0; m < chmus; m++) {
printf("Media Unit Identifier: %u\n",