forked from mchehab/rasdaemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ras-record.h
179 lines (157 loc) · 5.18 KB
/
ras-record.h
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
/*
* Copyright (C) 2013 Mauro Carvalho Chehab <[email protected]>
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __RAS_RECORD_H
#define __RAS_RECORD_H
#include <stdint.h>
#include "config.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
extern long user_hz;
struct ras_events;
struct ras_mc_event {
char timestamp[64];
int error_count;
const char *error_type, *msg, *label;
unsigned char mc_index;
signed char top_layer, middle_layer, lower_layer;
unsigned long long address, grain, syndrome;
const char *driver_detail;
};
struct ras_aer_event {
char timestamp[64];
const char *error_type;
const char *dev_name;
uint8_t tlp_header_valid;
uint32_t *tlp_header;
const char *msg;
};
struct ras_extlog_event {
char timestamp[64];
int32_t error_seq;
int8_t etype;
int8_t severity;
unsigned long long address;
int8_t pa_mask_lsb;
const char *fru_id;
const char *fru_text;
const char *cper_data;
unsigned short cper_data_length;
};
struct ras_non_standard_event {
char timestamp[64];
const char *sec_type, *fru_id, *fru_text;
const char *severity;
const uint8_t *error;
uint32_t length;
};
struct ras_arm_event {
char timestamp[64];
int32_t error_count;
int8_t affinity;
int64_t mpidr;
int64_t midr;
int32_t running_state;
int32_t psci_state;
};
struct devlink_event {
char timestamp[64];
const char *bus_name;
const char *dev_name;
const char *driver_name;
const char *reporter_name;
char *msg;
};
struct diskerror_event {
char timestamp[64];
char *dev;
unsigned long long sector;
unsigned int nr_sector;
const char *error;
const char *rwbs;
const char *cmd;
};
struct ras_mc_event;
struct ras_aer_event;
struct ras_extlog_event;
struct ras_non_standard_event;
struct ras_arm_event;
struct mce_event;
struct devlink_event;
struct diskerror_event;
#ifdef HAVE_SQLITE3
#include <sqlite3.h>
struct sqlite3_priv {
sqlite3 *db;
sqlite3_stmt *stmt_mc_event;
#ifdef HAVE_AER
sqlite3_stmt *stmt_aer_event;
#endif
#ifdef HAVE_MCE
sqlite3_stmt *stmt_mce_record;
#endif
#ifdef HAVE_EXTLOG
sqlite3_stmt *stmt_extlog_record;
#endif
#ifdef HAVE_NON_STANDARD
sqlite3_stmt *stmt_non_standard_record;
#endif
#ifdef HAVE_ARM
sqlite3_stmt *stmt_arm_record;
#endif
#ifdef HAVE_DEVLINK
sqlite3_stmt *stmt_devlink_event;
#endif
#ifdef HAVE_DISKERROR
sqlite3_stmt *stmt_diskerror_event;
#endif
};
struct db_fields {
char *name;
char *type;
};
struct db_table_descriptor {
char *name;
const struct db_fields *fields;
size_t num_fields;
};
int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras);
int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras);
int ras_mc_add_vendor_table(struct ras_events *ras, sqlite3_stmt **stmt,
const struct db_table_descriptor *db_tab);
int ras_mc_finalize_vendor_table(sqlite3_stmt *stmt);
int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev);
int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev);
int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev);
int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev);
int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev);
int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev);
#else
static inline int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) { return 0; };
static inline int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras) { return 0; };
static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
static inline int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev) { return 0; };
static inline int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev) { return 0; };
static inline int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev) { return 0; };
static inline int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev) { return 0; };
static inline int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev) { return 0; };
static inline int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev) { return 0; };
#endif
#endif