forked from mchehab/rasdaemon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
non-standard-ampere.c
1108 lines (980 loc) · 32.4 KB
/
non-standard-ampere.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
/*
* Copyright (c) 2020, Ampere Computing LLC.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "non-standard-ampere.h"
#include "ras-logger.h"
#include "ras-non-standard-handler.h"
#include "ras-report.h"
#include "types.h"
/*Armv8 RAS compicant Error Record(APEI and BMC Reporting) Payload Type 0*/
static const char * const disp_payload0_err_reg_name[] = {
"Error Type:",
"Error SubType:",
"Error Instance:",
"Processor Socket:",
"Status:",
"Address:",
"MISC0:",
"MISC1:",
"MISC2:",
"MISC3:",
};
/*PCIe AER Error Payload Type 1*/
static const char * const disp_payload1_err_reg_name[] = {
"Error Type:",
"Error Subtype:",
"Error Instance:",
"Processor Socket:",
"AER_UNCORR_ERR_STATUS:",
"AER_UNCORR_ERR_MASK:",
"AER_UNCORR_ERR_SEV:",
"AER_CORR_ERR_STATUS:",
"AER_CORR_ERR_MASK:",
"AER_ROOT_ERR_CMD:",
"AER_ROOT_ERR_STATUS:",
"AER_ERR_SRC_ID:",
"Reserved:",
"Reserved:",
};
/*PCIe RAS Dat Path(RASDP), Payload Type 2 */
static const char * const disp_payload2_err_reg_name[] = {
"Error Type:",
"Error Subtype:",
"Error Instance:",
"Processor Socket:",
"CE Report Register:",
"CE Location Register:",
"CE Address:",
"UE Reprot Register:",
"UE Location Register:",
"UE Address:",
"Reserved:",
"Reserved:",
"Reserved:",
};
/*Firmware-Specific Data(ATF, SMPro, PMpro, and BERT), Payload Type 3 */
static const char * const disp_payload3_err_reg_name[] = {
"Error Type:",
"Error Subtype:",
"Error Instance:",
"Processor Socket:",
"Firmware-Specific Data 0:",
"Firmware-Specific Data 1:",
"Firmware-Specific Data 2:",
"Firmware-Specific Data 3:",
"Firmware-Specific Data 4:",
"Firmware-Specific Data 5:",
};
static const char * const err_cpm_sub_type[] = {
"Snoop-Logic",
"ARMv8 Core 0",
"ARMv8 Core 1",
};
static const char * const err_mcu_sub_type[] = {
"ERR0",
"ERR1",
"ERR2",
"ERR3",
"ERR4",
"ERR5",
"ERR6",
"Link Error",
};
static const char * const err_mesh_sub_type[] = {
"Cross Point",
"Home Node(IO)",
"Home Node(Memory)",
"CCIX Node",
};
static const char * const err_2p_link_ms_sub_type[] = {
"ERR0",
"ERR1",
"ERR2",
"ERR3",
};
static const char * const err_gic_sub_type[] = {
"ERR0",
"ERR1",
"ERR2",
"ERR3",
"ERR4",
"ERR5",
"ERR6",
"ERR7",
"ERR8",
"ERR9",
"ERR10",
"ERR11",
"ERR12",
"ERR13(GIC ITS 0)",
"ERR14(GIC ITS 1)",
"ERR15(GIC ITS 2)",
"ERR16(GIC ITS 3)",
"ERR17(GIC ITS 4)",
"ERR18(GIC ITS 5)",
"ERR19(GIC ITS 6)",
"ERR20(GIC ITS 7)",
};
/*as the SMMU's subtype value is consistent, using switch for type0*/
static char *err_smmu_sub_type(int etype)
{
switch (etype) {
case 0x00: return "TBU0";
case 0x01: return "TBU1";
case 0x02: return "TBU2";
case 0x03: return "TBU3";
case 0x04: return "TBU4";
case 0x05: return "TBU5";
case 0x06: return "TBU6";
case 0x07: return "TBU7";
case 0x08: return "TBU8";
case 0x09: return "TBU9";
case 0x64: return "TCU";
}
return "unknown error";
}
static const char * const err_pcie_aer_sub_type[] = {
"Root Port",
"Device",
};
/*as the PCIe RASDP's subtype value is consistent, using switch for type0/2*/
static char *err_peci_rasdp_sub_type(int etype)
{
switch (etype) {
case 0x00: return "RCA HB Error";
case 0x01: return "RCB HB Error";
case 0x08: return "RASDP Error";
}
return "unknown error";
}
static const char * const err_ocm_sub_type[] = {
"ERR0",
"ERR1",
"ERR2",
};
static const char * const err_smpro_sub_type[] = {
"ERR0",
"ERR1",
"MPA_ERR",
};
static const char * const err_pmpro_sub_type[] = {
"ERR0",
"ERR1",
"MPA_ERR",
};
static const char * const err_atf_fw_sub_type[] = {
"EL3",
"SPM",
"Secure Partition(SEL0/SEL1)",
};
static const char * const err_smpro_fw_sub_type[] = {
"RAS_MSG_ERR",
"",
};
static const char * const err_pmpro_fw_sub_type[] = {
"RAS_MSG_ERR",
"",
};
static const char * const err_bert_sub_type[] = {
"Default",
"Watchdog",
"ATF Fatal",
"SMPRO Fatal",
"PMPRO Fatal",
};
static char *sqlite3_table_list[] = {
"amp_payload0_event_tab",
"amp_payload1_event_tab",
"amp_payload2_event_tab",
"amp_payload3_event_tab",
};
struct amp_ras_type_info {
int id;
const char *name;
const char * const *sub;
int sub_num;
};
static const struct amp_ras_type_info amp_payload_error_type[] = {
{
.id = AMP_RAS_TYPE_CPU,
.name = "CPM",
.sub = err_cpm_sub_type,
.sub_num = ARRAY_SIZE(err_cpm_sub_type),
},
{
.id = AMP_RAS_TYPE_MCU,
.name = "MCU",
.sub = err_mcu_sub_type,
.sub_num = ARRAY_SIZE(err_mcu_sub_type),
},
{
.id = AMP_RAS_TYPE_MESH,
.name = "MESH",
.sub = err_mesh_sub_type,
.sub_num = ARRAY_SIZE(err_mesh_sub_type),
},
{
.id = AMP_RAS_TYPE_2P_LINK_QS,
.name = "2P Link(Altra)",
},
{
.id = AMP_RAS_TYPE_2P_LINK_MQ,
.name = "2P Link(Altra Max)",
.sub = err_2p_link_ms_sub_type,
.sub_num = ARRAY_SIZE(err_2p_link_ms_sub_type),
},
{
.id = AMP_RAS_TYPE_GIC,
.name = "GIC",
.sub = err_gic_sub_type,
.sub_num = ARRAY_SIZE(err_gic_sub_type),
},
{
.id = AMP_RAS_TYPE_SMMU,
.name = "SMMU",
},
{
.id = AMP_RAS_TYPE_PCIE_AER,
.name = "PCIe AER",
.sub = err_pcie_aer_sub_type,
.sub_num = ARRAY_SIZE(err_pcie_aer_sub_type),
},
{
.id = AMP_RAS_TYPE_PCIE_RASDP,
.name = "PCIe RASDP",
},
{
.id = AMP_RAS_TYPE_OCM,
.name = "OCM",
.sub = err_ocm_sub_type,
.sub_num = ARRAY_SIZE(err_ocm_sub_type),
},
{
.id = AMP_RAS_TYPE_SMPRO,
.name = "SMPRO",
.sub = err_smpro_sub_type,
.sub_num = ARRAY_SIZE(err_smpro_sub_type),
},
{
.id = AMP_RAS_TYPE_PMPRO,
.name = "PMPRO",
.sub = err_pmpro_sub_type,
.sub_num = ARRAY_SIZE(err_pmpro_sub_type),
},
{
.id = AMP_RAS_TYPE_ATF_FW,
.name = "ATF FW",
.sub = err_atf_fw_sub_type,
.sub_num = ARRAY_SIZE(err_atf_fw_sub_type),
},
{
.id = AMP_RAS_TYPE_SMPRO_FW,
.name = "SMPRO FW",
.sub = err_smpro_fw_sub_type,
.sub_num = ARRAY_SIZE(err_smpro_fw_sub_type),
},
{
.id = AMP_RAS_TYPE_PMPRO_FW,
.name = "PMPRO FW",
.sub = err_pmpro_fw_sub_type,
.sub_num = ARRAY_SIZE(err_pmpro_fw_sub_type),
},
{
.id = AMP_RAS_TYPE_BERT,
.name = "BERT",
.sub = err_bert_sub_type,
.sub_num = ARRAY_SIZE(err_bert_sub_type),
},
{
}
};
/*get the error type name*/
static const char *oem_type_name(const struct amp_ras_type_info *info,
uint8_t type_id)
{
const struct amp_ras_type_info *type = &info[0];
for (; type->name; type++) {
if (type->id != type_id)
continue;
return type->name;
}
return "unknown";
}
/*get the error subtype*/
static const char *oem_subtype_name(const struct amp_ras_type_info *info,
uint8_t type_id, uint8_t sub_type_id)
{
const struct amp_ras_type_info *type = &info[0];
for (; type->name; type++) {
const char * const *submodule = type->sub;
if (type->id != type_id)
continue;
if (!type->sub)
return type->name;
if (sub_type_id >= type->sub_num)
return "unknown";
return submodule[sub_type_id];
}
return "unknown";
}
#ifdef HAVE_SQLITE3
/*key pair definition for ampere specific error payload type 0*/
static const struct db_fields amp_payload0_event_fields[] = {
{ .name = "id", .type = "INTEGER PRIMARY KEY" },
{ .name = "timestamp", .type = "TEXT" },
{ .name = "type", .type = "TEXT" },
{ .name = "subtype", .type = "TEXT" },
{ .name = "instance", .type = "INTEGER" },
{ .name = "socket_num", .type = "INTEGER" },
{ .name = "status_reg", .type = "INTEGER" },
{ .name = "addr_reg", .type = "INTEGER" },
{ .name = "misc0", .type = "INTEGER" },
{ .name = "misc1", .type = "INTEGER" },
{ .name = "misc2", .type = "INTEGER" },
{ .name = "misc3", .type = "INTEGER" },
};
static const struct db_table_descriptor amp_payload0_event_tab = {
.name = "amp_payload0_event",
.fields = amp_payload0_event_fields,
.num_fields = ARRAY_SIZE(amp_payload0_event_fields),
};
/*key pair definition for ampere specific error payload type 1*/
static const struct db_fields amp_payload1_event_fields[] = {
{ .name = "id", .type = "INTEGER PRIMARY KEY" },
{ .name = "timestamp", .type = "TEXT" },
{ .name = "type", .type = "TEXT" },
{ .name = "subtype", .type = "TEXT" },
{ .name = "instance", .type = "INTEGER" },
{ .name = "socket_num", .type = "INTEGER" },
{ .name = "uncore_err_status", .type = "INTEGER" },
{ .name = "uncore_err_mask", .type = "INTEGER" },
{ .name = "uncore_err_sev", .type = "INTEGER" },
{ .name = "core_err_status", .type = "INTEGER" },
{ .name = "core_err_mask", .type = "INTEGER" },
{ .name = "root_err_cmd", .type = "INTEGER" },
{ .name = "root_err_status", .type = "INTEGER" },
{ .name = "src_id", .type = "INTEGER" },
{ .name = "reserved1", .type = "INTEGER" },
{ .name = "reserverd2", .type = "INTEGER" },
};
static const struct db_table_descriptor amp_payload1_event_tab = {
.name = "amp_payload1_event",
.fields = amp_payload1_event_fields,
.num_fields = ARRAY_SIZE(amp_payload1_event_fields),
};
/*key pair definition for ampere specific error payload type 2*/
static const struct db_fields amp_payload2_event_fields[] = {
{ .name = "id", .type = "INTEGER PRIMARY KEY" },
{ .name = "timestamp", .type = "TEXT" },
{ .name = "type", .type = "TEXT" },
{ .name = "subtype", .type = "TEXT" },
{ .name = "instance", .type = "INTEGER" },
{ .name = "socket_num", .type = "INTEGER" },
{ .name = "ce_report_reg", .type = "INTEGER" },
{ .name = "ce_location", .type = "INTEGER" },
{ .name = "ce_addr", .type = "INTEGER" },
{ .name = "ue_report_reg", .type = "INTEGER" },
{ .name = "ue_location", .type = "INTEGER" },
{ .name = "ue_addr", .type = "INTEGER" },
{ .name = "reserved1", .type = "INTEGER" },
{ .name = "reserved2", .type = "INTEGER" },
{ .name = "reserved2", .type = "INTEGER" },
};
static const struct db_table_descriptor amp_payload2_event_tab = {
.name = "amp_payload2_event",
.fields = amp_payload2_event_fields,
.num_fields = ARRAY_SIZE(amp_payload2_event_fields),
};
/*key pair definition for ampere specific error payload type 3*/
static const struct db_fields amp_payload3_event_fields[] = {
{ .name = "id", .type = "INTEGER PRIMARY KEY" },
{ .name = "timestamp", .type = "TEXT" },
{ .name = "type", .type = "TEXT" },
{ .name = "subtype", .type = "TEXT" },
{ .name = "instance", .type = "INTEGER" },
{ .name = "socket_num", .type = "INTEGER" },
{ .name = "fw_spec_data0", .type = "INTEGER" },
{ .name = "fw_spec_data1", .type = "INTEGER" },
{ .name = "fw_spec_data2", .type = "INTEGER" },
{ .name = "fw_spec_data3", .type = "INTEGER" },
{ .name = "fw_spec_data4", .type = "INTEGER" },
{ .name = "fw_spec_data5", .type = "INTEGER" },
};
static const struct db_table_descriptor amp_payload3_event_tab = {
.name = "amp_payload3_event",
.fields = amp_payload3_event_fields,
.num_fields = ARRAY_SIZE(amp_payload3_event_fields),
};
/*Save data with different type into sqlite3 db*/
static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
enum amp_oem_data_type data_type,
int id, int64_t data, const char *text)
{
switch (data_type) {
case AMP_OEM_DATA_TYPE_INT:
sqlite3_bind_int(ev_decoder->stmt_dec_record, id, data);
break;
case AMP_OEM_DATA_TYPE_INT64:
sqlite3_bind_int64(ev_decoder->stmt_dec_record, id, data);
break;
case AMP_OEM_DATA_TYPE_TEXT:
sqlite3_bind_text(ev_decoder->stmt_dec_record, id,
text, -1, NULL);
break;
default:
break;
}
}
static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder,
const char *name)
{
int rc;
rc = sqlite3_step(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
"Failed to do %s step on sqlite: error = %d\n", name, rc);
rc = sqlite3_reset(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
"Failed to reset %s on sqlite: error = %d\n", name, rc);
rc = sqlite3_clear_bindings(ev_decoder->stmt_dec_record);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
log(TERM, LOG_ERR,
"Failed to clear bindings %s on sqlite: error = %d\n",
name, rc);
return rc;
}
/*save all Ampere Specific Error Payload type 0 to sqlite3 database*/
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload0_type_sec *err)
{
if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD0_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD0_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD0_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD0_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD0_FIELD_STATUS_REG, err->err_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD0_FIELD_ADDR_REG,
err->err_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD0_FIELD_MISC0,
err->err_misc_0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD0_FIELD_MISC1,
err->err_misc_1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD0_FIELD_MISC2,
err->err_misc_2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD0_FIELD_MISC3,
err->err_misc_3, NULL);
store_amp_err_data(ev_decoder, "amp_payload0_event_tab");
}
}
/*save all Ampere Specific Error Payload type 1 to sqlite3 database*/
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload1_type_sec *err)
{
if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD1_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD1_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_INS,
INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_UNCORE_ERR_STATUS,
err->uncore_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_UNCORE_ERR_MASK,
err->uncore_mask, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_UNCORE_ERR_SEV,
err->uncore_sev, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_CORE_ERR_STATUS,
err->core_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_CORE_ERR_MASK,
err->core_mask, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_ROOT_ERR_CMD,
err->root_err_cmd, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_ROOT_ERR_STATUS,
err->root_status, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_SRC_ID,
err->src_id, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD1_FIELD_RESERVED1,
err->reserved1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD1_FIELD_RESERVED2,
err->reserved2, NULL);
store_amp_err_data(ev_decoder, "amp_payload1_event_tab");
}
}
/*save all Ampere Specific Error Payload type 2 to sqlite3 database*/
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload2_type_sec *err)
{
if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD2_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD2_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_CE_REPORT_REG,
err->ce_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_CE_LOACATION,
err->ce_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_CE_ADDR,
err->ce_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_UE_REPORT_REG,
err->ue_register, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_UE_LOCATION,
err->ue_location, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_UE_ADDR,
err->ue_addr, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD2_FIELD_RESERVED1,
err->reserved1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD2_FIELD_RESERVED2,
err->reserved2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD2_FIELD_RESERVED3,
err->reserved3, NULL);
store_amp_err_data(ev_decoder, "amp_payload2_event_tab");
}
}
/*save all Ampere Specific Error Payload type 3 to sqlite3 database*/
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload3_type_sec *err)
{
if (ev_decoder) {
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD3_FIELD_TYPE, 0, type_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_TEXT,
AMP_PAYLOAD3_FIELD_SUB_TYPE, 0, subtype_str);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD3_FIELD_INS, INSTANCE(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD3_FIELD_SOCKET_NUM,
SOCKET_NUM(err->instance), NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA0,
err->fw_speci_data0, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA1,
err->fw_speci_data1, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA2,
err->fw_speci_data2, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA3,
err->fw_speci_data3, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA4,
err->fw_speci_data4, NULL);
record_amp_data(ev_decoder, AMP_OEM_DATA_TYPE_INT64,
AMP_PAYLOAD3_FIELD_FW_SPEC_DATA5,
err->fw_speci_data5, NULL);
store_amp_err_data(ev_decoder, "amp_payload3_event_tab");
}
}
#else
static void record_amp_data(struct ras_ns_ev_decoder *ev_decoder,
enum amp_oem_data_type data_type,
int id, int64_t data, const char *text)
{
}
static void record_amp_payload0_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload0_type_sec *err)
{
}
static void record_amp_payload1_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload1_type_sec *err)
{
}
static void record_amp_payload2_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload2_type_sec *err)
{
}
static void record_amp_payload3_err(struct ras_ns_ev_decoder *ev_decoder,
const char *type_str, const char *subtype_str,
const struct amp_payload3_type_sec *err)
{
}
static int store_amp_err_data(struct ras_ns_ev_decoder *ev_decoder, char *name)
{
return 0;
}
#endif
/*decode ampere specific error payload type 0, the CPU's data is save*/
/*to sqlite by ras-arm-handler, others are saved by this function.*/
void decode_amp_payload0_err_regs(struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
const struct amp_payload0_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
char *end = buf + AMP_PAYLOAD0_BUF_LEN;
int i = 0, core_num = 0;
const char *subtype_str;
const char *type_str = oem_type_name(amp_payload_error_type,
TYPE(err->type));
if (TYPE(err->type) == AMP_RAS_TYPE_SMMU)
subtype_str = err_smmu_sub_type(err->subtype);
else
subtype_str = oem_subtype_name(amp_payload_error_type,
TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", subtype_str);
//display error instance
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", INSTANCE(err->instance));
//display socket number
if (!TYPE(err->type) && (err->subtype == 0x01 || err->subtype == 0x02)) {
core_num = INSTANCE(err->instance) * 2 + err->subtype - 1;
p += snprintf(p, end - p, " %s",
disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %d, Core Number is:%d\n",
SOCKET_NUM(err->instance), core_num);
} else {
p += snprintf(p, end - p, " %s",
disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %d\n", SOCKET_NUM(err->instance));
}
//display status register
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->err_status);
//display address register
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->err_addr);
//display MISC0
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->err_misc_0);
//display MISC1
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->err_misc_1);
//display MISC2
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->err_misc_2);
//display MISC3
p += snprintf(p, end - p, " %s", disp_payload0_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->err_misc_3);
if (p > buf && p < end) {
p--;
*p = '\0';
}
record_amp_payload0_err(ev_decoder, type_str, subtype_str, err);
i = 0;
p = NULL;
end = NULL;
trace_seq_printf(s, "%s\n", buf);
}
/*decode ampere specific error payload type 1 and save to sqlite db*/
static void decode_amp_payload1_err_regs(struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
const struct amp_payload1_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
char *end = buf + AMP_PAYLOAD0_BUF_LEN;
int i = 0;
const char *type_str = oem_type_name(amp_payload_error_type,
TYPE(err->type));
const char *subtype_str = oem_subtype_name(amp_payload_error_type,
TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %s", subtype_str);
//display error instance
p += snprintf(p, end - p, "\n%s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", INSTANCE(err->instance));
//display socket number
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " %d\n", SOCKET_NUM(err->instance));
//display AER_UNCORR_ERR_STATUS
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->uncore_status);
//display AER_UNCORR_ERR_MASK
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->uncore_mask);
//display AER_UNCORR_ERR_SEV
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->uncore_sev);
//display AER_CORR_ERR_STATUS
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->core_status);
//display AER_CORR_ERR_MASK
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->core_mask);
//display AER_ROOT_ERR_CMD
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->root_err_cmd);
//display AER_ROOT_ERR_STATUS
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->root_status);
//display AER_ERR_SRC_ID
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->src_id);
//display Reserved
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->reserved1);
//display Reserved
p += snprintf(p, end - p, " %s", disp_payload1_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->reserved2);
if (p > buf && p < end) {
p--;
*p = '\0';
}
record_amp_payload1_err(ev_decoder, type_str, subtype_str, err);
i = 0;
p = NULL;
end = NULL;
trace_seq_printf(s, "%s\n", buf);
}
/*decode ampere specific error payload type 2 and save to sqlite db*/
static void decode_amp_payload2_err_regs(struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
const struct amp_payload2_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
char *end = buf + AMP_PAYLOAD0_BUF_LEN;
int i = 0;
const char *subtype_str;
const char *type_str = oem_type_name(amp_payload_error_type,
TYPE(err->type));
if (TYPE(err->type) == AMP_RAS_TYPE_PCIE_RASDP)
subtype_str = err_peci_rasdp_sub_type(err->subtype);
else
subtype_str = oem_subtype_name(amp_payload_error_type,
TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", subtype_str);
//display error instance
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", INSTANCE(err->instance));
//display socket number
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " %d\n", SOCKET_NUM(err->instance));
//display CE Report Register
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ce_register);
//display CE Location Register
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ce_location);
//display CE Address
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ce_addr);
//display UE Reprot Register
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ue_register);
//display UE Location Register
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ue_location);
//display UE Address
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->ue_addr);
//display Reserved
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->reserved1);
//display Reserved
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->reserved2);
//display Reserved
p += snprintf(p, end - p, " %s", disp_payload2_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->reserved3);
if (p > buf && p < end) {
p--;
*p = '\0';
}
record_amp_payload2_err(ev_decoder, type_str, subtype_str, err);
i = 0;
p = NULL;
end = NULL;
trace_seq_printf(s, "%s\n", buf);
}
/*decode ampere specific error payload type 3 and save to sqlite db*/
static void decode_amp_payload3_err_regs(struct ras_ns_ev_decoder *ev_decoder,
struct trace_seq *s,
const struct amp_payload3_type_sec *err)
{
char buf[AMP_PAYLOAD0_BUF_LEN];
char *p = buf;
char *end = buf + AMP_PAYLOAD0_BUF_LEN;
int i = 0;
const char *type_str = oem_type_name(amp_payload_error_type,
TYPE(err->type));
const char *subtype_str = oem_subtype_name(amp_payload_error_type,
TYPE(err->type), err->subtype);
//display error type
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", type_str);
//display error subtype
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %s\n", subtype_str);
//display error instance
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", INSTANCE(err->instance));
//display socket number
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " %d\n", SOCKET_NUM(err->instance));
//display Firmware-Specific Data 0
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%x\n", err->fw_speci_data0);
//display Firmware-Specific Data 1
p += snprintf(p, end - p, " %s", disp_payload3_err_reg_name[i++]);
p += snprintf(p, end - p, " 0x%llx\n",
(unsigned long long)err->fw_speci_data1);