-
Notifications
You must be signed in to change notification settings - Fork 12
/
libekb.H
204 lines (169 loc) · 4.89 KB
/
libekb.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
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
#ifndef __LIBEKB_H__
#define __LIBEKB_H__
#include <string>
#include <utility>
#include <vector>
#define LIBEKB_LOG_ERR 0
#define LIBEKB_LOG_INF 1
#define LIBEKB_LOG_IMP 2
#define LIBEKB_LOG_MFG 3
#define LIBEKB_LOG_SCAN 4
#define LIBEKB_LOG_DBG 5
extern "C" {
#include <stdarg.h>
#include <cstdint>
typedef void (*libekb_log_func_t)(void *private_data, const char *fmt,
va_list ap);
int libekb_init(void);
void libekb_set_logfunc(libekb_log_func_t fn, void *private_data);
void libekb_set_loglevel(int loglevel);
void libekb_log(int loglevel, const char *fmt, ...);
}
/*
* @brief To get hardware callout details
*
* This is used to get required hardware information to callout
* if any failures happended.
*/
struct HWCallout {
// To get hardware id which is defined in hwp error xml
std::string hwid;
// To get defined priority in error xml for callout hardware
// based on priority
std::string callout_priority;
// To get entity path of hardware (target) which is defined
// in POWER cec device tree
std::vector<uint8_t> target_entity_path;
// To indicate, a planar callout is required for this error.
bool isPlanarCallout;
// To get clock position and it used for identify clock position
// for processor
uint8_t clkPos;
};
/*
* @brief To get procedure callout details
*
* This is used to get required procedure information to callout
* if any failures happended.
*/
struct ProcedureCallout {
// To get proecdure info which is defined in error xml to callout
std::string proc_callout;
// To get defined priority in error xml for callout procedures
// based on priority
std::string callout_priority;
};
/*
* @brief To get target which is required callout, deconfigure and guard
*
*/
struct CDG_Target {
// To get entity path of hardware (target) which is defined
// in POWER cec device tree
std::vector<uint8_t> target_entity_path;
// To indicate callout is require or not
// true - required
// false - not required
bool callout;
// To get callout priority if callout is true
std::string callout_priority;
// To indicate deconfigure is require or not
// true - required
// false - not required
bool deconfigure;
// To indicate guard hardware (target) is require or not
// true - required
// false - not required
bool guard;
// To get guard type which is defined in error xml
std::string guard_type;
};
/*
* @brief Hardware procedure error info which is defined in error xml
*/
struct HWP_ErrorInfo {
// To get hwp return code which is defined in error xml for
// each error
std::string rc;
// To get return code desciption
std::string rc_desc;
// To get available FFDCData for particular hwp failures which are
// defined in error xml
// pair<variable|attribute_Name, Value>
std::vector<std::pair<std::string, std::string>> ffdcs_data;
// To get list of hardware callout info
std::vector<HWCallout> hwcallouts;
// To get list of procedure callout info
std::vector<ProcedureCallout> procedures_callout;
// TO get list of target to do callout, deconfigure and guard
std::vector<CDG_Target> cdg_targets;
};
/*
* @brief Used to get type of ffdc
*/
enum FFDC_TYPE {
// No ffdc
FFDC_TYPE_NONE = 0,
// Unsupported ffdc by libekb
FFDC_TYPE_UNSUPPORTED = 1,
// FFDC is created for hardware procedure failures
FFDC_TYPE_HWP = 2,
// FFDC is created for spare clock failures need to log as informational
FFDC_TYPE_SPARE_CLOCK_INFO = 3
};
/*
* @brief First Failure Data Collection
*/
struct FFDC {
// To get FFDC type i.e who is created during execution of hwp
FFDC_TYPE ffdc_type;
// To get detailed message which will used for trace
std::string message;
// To get detailed hardware procedure ffdc
// @note use if ffdc_type is HWP
HWP_ErrorInfo hwp_errorinfo;
};
/*
* @brief SBE FFDC packet
*/
typedef struct sbeFfdcPacket {
uint32_t fapiRc; // Fapi Rc
uint32_t ffdcLengthInWords; // length of Fapi FFDC data
uint32_t *ffdcData = nullptr; // fapi FFDC data
~sbeFfdcPacket()
{
// freeup the ffdcData allocated memory
if (ffdcData) {
delete[] ffdcData;
ffdcData = nullptr;
}
}
} sbeFfdcPacketType;
/*
* @brief Used to collect first failure data collection
*
* This api is used to collect failure data for libekb failures.
*
* @param ffdc used to pass buffer to fill FFDC data
*
* @retrun void
*/
void libekb_get_ffdc(FFDC &ffdc);
/*
* @brief Used to collect sbe first failure data collection
*
* This interface reads the SBE FFDC packet, calls appropriate
* FAPI functions for further processing, and then adds to the
* FFDC buffer input. Also adds the special callout based on
* the fapiRC in the SBE FFDC packet.
*
* @param ffdc used to pass buffer to fill FFDC data
* @param pkt SBE FFDC packet
* @param chipPos failing chip position
* @param chip_type type of the failing chip
*
* @retrun void
*/
void libekb_get_sbe_ffdc(FFDC &ffdc, const sbeFfdcPacketType &ffdc_pkt,
int chipPos, uint32_t sbeChipType);
#endif /* __LIBEKB_H__ */