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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/sbeio/sbe_ffdc_package_parser.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#include <sbeio/sbe_ffdc_package_parser.H>
#include <hwp_return_codes.H>
#include <trace/interface.H>
#include <xscom/piberror.H>
extern trace_desc_t* g_trac_sbeio;
#define SBE_TRACF(printf_string,args...) \
TRACFCOMP(g_trac_sbeio, "sbe ffdc: " printf_string,##args)
namespace SBEIO
{
//---------------------------------------------------------------------------
FfdcParsedPackage::ParsedType
FfdcParsedPackage::rcToParsedType(uint32_t fapiRc)
{
ParsedType retval{ParsedType::NONE};
switch(fapiRc)
{
case fapi2::RC_SBE_SCOM_FAILURE:
case fapi2::RC_SBE_PIB_XSCOM_ERROR:
case fapi2::RC_SBE_PIB_OFFLINE_ERROR:
case fapi2::RC_SBE_PIB_PARTIAL_ERROR:
case fapi2::RC_SBE_PIB_ADDRESS_ERROR:
case fapi2::RC_SBE_PIB_CLOCK_ERROR:
case fapi2::RC_SBE_PIB_PARITY_ERROR:
case fapi2::RC_SBE_PIB_TIMEOUT_ERROR:
{
retval = ParsedType::SBE_SCOM_PIB_ERROR;
break;
}
}
return retval;
}
//---------------------------------------------------------------------------
void FfdcParsedPackage::doDefaultProcessing(
const ffdc_package& i_ffdc_package,
TARGETING::Target* i_target,
errlHndl_t i_errl
)
{
ParsedType l_type = rcToParsedType(i_ffdc_package.rc);
switch(l_type)
{
case ParsedType::SBE_SCOM_PIB_ERROR:
{
FfdcScomPibErrorPackage ffdcPackage{i_ffdc_package};
ffdcPackage(i_target, i_errl);
break;
}
case ParsedType::NONE:
{
//If the schema matches then we probably have a new rc
//that has yet to be accounted for.
if(0 != i_ffdc_package.rc)
{
if(FfdcScomPibErrorPackage::doesPackageMatchSchema
(i_ffdc_package))
{
SBE_TRACF(WARN_MRK"Unknown RC matches "
"SBE_SCOM_PIB_ERROR FFDC schema. RC: 0x%08X",
i_ffdc_package.rc
);
FfdcScomPibErrorPackage ffdcPackage{i_ffdc_package,
true
};
ffdcPackage(i_target, i_errl);
}
}
break;
}
default:
{
SBE_TRACF(INFO_MRK"Unknown FFDC schema type encountered. "
"Parsed Type: 0x%04X",
static_cast<uint16_t>(l_type)
);
break;
}
}
}
//---------------------------------------------------------------------------
std::shared_ptr<const FfdcParsedPackage>
FfdcParsedPackage::getParsedPackage(const ffdc_package& i_ffdc_package)
{
std::shared_ptr<const FfdcParsedPackage> retval;
ParsedType l_type = rcToParsedType(i_ffdc_package.rc);
switch(l_type)
{
case ParsedType::SBE_SCOM_PIB_ERROR:
{
FfdcParsedPackage* ptr =
new FfdcScomPibErrorPackage(i_ffdc_package);
retval.reset(ptr);
break;
}
default:
{
SBE_TRACF(WARN_MRK"No FFDC schema found for RC 0x%08X",
i_ffdc_package.rc
);
retval.reset(new FfdcParsedPackage());
break;
}
}
return retval;
}
//----------------------------------------------------------------------------
FfdcScomPibErrorPackage::FfdcScomPibErrorPackage(const ffdc_package& i_ffdc,
bool ignoreRC
)
{
validateFFDCPackage(i_ffdc, ignoreRC);
}
//----------------------------------------------------------------------------
bool FfdcScomPibErrorPackage::validateFFDCPackage(const ffdc_package& i_ffdc,
bool ignoreRC)
{
//Schema
// u32 u32 u64 u32 u64
// | FAPI RC | SCOM ADDR SIZE | SCOM ADDR | PIB RC SIZE | PIB RC |
bool retval{false};
do
{
if(nullptr == i_ffdc.ffdcPtr)
{
parsedType(ParsedType::NONE);
break;
}
//if ignoreRC is true then schema validation has already been done.
//Skip this step and parse the FFDC data.
if(not ignoreRC)
{
if(ParsedType::SBE_SCOM_PIB_ERROR != rcToParsedType(i_ffdc.rc))
{
parsedType(ParsedType::NONE);
break;
}
if(not doesPackageMatchSchema(i_ffdc))
{
parsedType(ParsedType::NONE);
break;
}
}
constexpr size_t scomAddressOffset = sizeof(uint32_t) + //FAPI RC
sizeof(uint32_t); //size of Scom
//Addr
constexpr size_t pibRcOffset = sizeof(uint32_t) + //FAPI RC
sizeof(uint32_t) + //size of Scom Addr
sizeof(uint64_t) + //Scom Address
sizeof(uint32_t); //size of PIB RC
const char* l_buffer = reinterpret_cast<const char*>(i_ffdc.ffdcPtr);
iv_scomAddress = *(reinterpret_cast<const uint64_t*>
(l_buffer + scomAddressOffset));
iv_pibRc = *(reinterpret_cast<const uint64_t*>
(l_buffer + pibRcOffset));
//Make this instance valid by assigning a ParsedType other than none.
parsedType(ParsedType::SBE_SCOM_PIB_ERROR);
retval = true;
}
while(0);
return retval;
}
//------------------------------------------------------------------------
bool FfdcScomPibErrorPackage::doesPackageMatchSchema(const ffdc_package&
i_ffdc)
{
//Schema
// u32 u32 u64 u32 u64
// | FAPI RC | SCOM ADDR SIZE | SCOM ADDR | PIB RC SIZE | PIB RC |
bool retval{false};
do
{
if(nullptr == i_ffdc.ffdcPtr)
{
return retval;
}
constexpr uint32_t l_expectedPIBSize = sizeof(uint64_t);
constexpr uint32_t l_expectedScomAddrSize{sizeof(uint64_t)};
constexpr size_t expectedSize = sizeof(uint32_t) + //FAPI RC
sizeof(uint32_t) + //size of Scom Addr
sizeof(uint64_t) + //Scom Address
sizeof(uint32_t) + //size of PIB RC
sizeof(uint64_t); //PIB RC
constexpr size_t scomAddrSizeOffset = sizeof(uint32_t); //FAPI RC
constexpr size_t pibSizeOffset = sizeof(uint32_t) + //FAPI RC
sizeof(uint32_t) + //size of Scom Addr
sizeof(uint64_t); //Scom Address
if(expectedSize != i_ffdc.size)
{
break;
}
const char* l_buffer = reinterpret_cast<const char*>(i_ffdc.ffdcPtr);
if(l_expectedScomAddrSize != *(reinterpret_cast<const uint32_t*>
(l_buffer + scomAddrSizeOffset)))
{
break;
}
uint32_t l_pibSize = *(reinterpret_cast<const uint32_t*>
(l_buffer + pibSizeOffset));
if(l_expectedPIBSize != l_pibSize)
{
//This can be deduced as uint32_t, we'll check uint16_t as well
if(not (l_pibSize < l_expectedPIBSize && l_pibSize != 0 &&
0 == l_pibSize%sizeof(uint16_t)))
{
break;
}
}
retval = true;
}
while(0);
return retval;
}
//--------------------------------------------------------------------------
void FfdcScomPibErrorPackage::addFruCallouts(TARGETING::Target* i_target,
errlHndl_t i_errl
) const
{
if(isValid())
{
if(PIB::PIB_NO_ERROR != iv_pibRc && INVALID_DATA != iv_pibRc)
{
PIB::addFruCallouts
(i_target, iv_pibRc, iv_scomAddress, i_errl);
}
}
}
//---------------------------------------------------------------------------
void FfdcScomPibErrorPackage::operator()(TARGETING::Target* i_target,
errlHndl_t i_errl
) const
{
if(isValid())
{
addFruCallouts(i_target, i_errl);
}
}
}
|