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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/scom/DmiScomWorkaround.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 "DmiScomWorkaround.H"
#include <devicefw/driverif.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <trace/interface.H>
#include <util/misc.H>
#include <algorithm>
extern trace_desc_t* g_trac_scom;
#define SCOM_DMI_WA_TRACD(printf_string,args...) \
TRACDCOMP(g_trac_scom,"DmiScomWorkaround::" printf_string,##args)
namespace SCOM
{
uint64_t DmiScomWorkaround::cv_model_cumulus = 0;
//---------------------------------------------------------------------------
bool DmiScomWorkaround::requestRetry(errlHndl_t i_errl,
uint32_t i_retryCount,
DeviceFW::OperationType i_opType,
TARGETING::Target* i_target,
void* i_buffer,
size_t i_buflen,
int64_t i_accessType,
uint64_t i_addr
) const
{
constexpr uint64_t MODEL_UNINITIALIZED=0x00;
constexpr uint64_t MODEL_IS_CUMULUS=0x01;
constexpr uint64_t MODEL_IS_NOT_CUMULUS=0x02;
bool l_retval{false};
do
{
uint64_t l_model_cumulus = __sync_fetch_and_add(&cv_model_cumulus, 0);
// useCachedProcModel is a dependency injection seam that
// allows us to obtain the processor model with every call
// to support unit testing with mocked targets. In non-test
// code useCachedProcModel always returns true and the
// Processor model is cached for performance optimization.
if(useCachedProcModel())
{
//If the model is not cumulus then the workaround is not applicable
if(MODEL_IS_NOT_CUMULUS ==
(MODEL_IS_NOT_CUMULUS & l_model_cumulus))
{
break;
}
}
//The workaround is only valid for READ operations
if(DeviceFW::READ != i_opType)
{
break;
}
//we only need one retry at most.
if(i_retryCount > 0)
{
break;
}
if(nullptr == i_target)
{
break;
}
//Get the target type. We are only concerned with processor
//targets.
TARGETING::ATTR_TYPE_type l_type = TARGETING::TYPE_NA;
if(not getTargetType(i_target, l_type))
{
break;
}
if(TARGETING::TYPE_PROC != l_type)
{
break;
}
//The workaround is only applicable to CUMULUS models.
//If the model has not yet been determined, then discover
//the model in order to avoid future processing when running on a
//non-cumulus model. This code block is run only until the
//processor model is discovered, after which the check at the
//beginning of the method tests for the correct model.
if(MODEL_UNINITIALIZED == l_model_cumulus || !useCachedProcModel())
{
TARGETING::ATTR_MODEL_type l_model;
if(getTargetModel(i_target, l_model))
{
const char* model_name = "Unknown";
if(TARGETING::MODEL_CUMULUS != l_model)
{
if(useCachedProcModel())
{
//Cache model for a quick check at the start
//of the routine.
__sync_fetch_and_or(&cv_model_cumulus,
MODEL_IS_NOT_CUMULUS);
}
if(TARGETING::MODEL_NIMBUS == l_model)
{
model_name = "NIMBUS";
}
SCOM_DMI_WA_TRACD("requestRetry: "
"%s System Detected!",
model_name
);
break;
}
else
{
if(useCachedProcModel())
{
//Cache model for a quick check at the start
//of the routine.
__sync_fetch_and_or(&cv_model_cumulus,
MODEL_IS_CUMULUS);
}
model_name = "CUMULUS";
SCOM_DMI_WA_TRACD("requestRetry: "
"%s System Detected!",
model_name
);
}
}
}
//we'll check the EC Level every time in case
//a system is encountered with different EC Levels
uint8_t l_ecLevel{};
if(getTargetECLevel(i_target, l_ecLevel))
{
if(0x0 != l_ecLevel && 0x10 != l_ecLevel)
{
break;
}
}
// Match Address Formats 0x050108[23ab][3-a]
// 0x030108[23ab][3-a]
//
// Step 1: Check that the prefix matches 0x050108XX or 0x030108XX
// Step 2: Check that the last nibble of the address in [0x3,0xa]
// Step 3: Check that the 3rd bit of nibble 2 is not set and the
// 2nd bit is set.
// 2 - 0010
// 3 - 0011
// a - 1010
// b - 1011
if(
(((0xFFFFFF00 & i_addr) == 0x05010800) ||
((0xFFFFFF00 & i_addr) == 0x03010800)) &&
(((0x0000000F & i_addr) >= 0x00000003) &&
((0x0000000F & i_addr) <= 0x0000000a)) &&
(((0x00000040 | 0x00000020) & i_addr) == 0x00000020)
)
{
l_retval = true;
}
}
while(0);
if(l_retval)
{
incRetryCount();
}
return l_retval;
}
//----------------------------------------------------------------------------
std::shared_ptr<const PostOpRetryCheck> DmiScomWorkaround::theInstance()
{
static std::shared_ptr<const PostOpRetryCheck>
ls_instance(new DmiScomWorkaround);
return ls_instance;
}
//----------------------------------------------------------------------------
bool DmiScomWorkaround::getTargetType(TARGETING::Target* i_target,
TARGETING::TYPE& o_type) const
{
bool l_retval{false};
if(nullptr != i_target)
{
if(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL == i_target)
{
o_type = TARGETING::TYPE_PROC;
l_retval = true;
}
else if(i_target->tryGetAttr<TARGETING::ATTR_TYPE>(o_type))
{
l_retval = true;
}
}
return l_retval;
}
//----------------------------------------------------------------------------
bool DmiScomWorkaround::getTargetModel(TARGETING::Target* i_target,
TARGETING::MODEL& o_model) const
{
bool l_retval{false};
TARGETING::MODEL l_model = TARGETING::MODEL_NA;
TARGETING::TYPE l_type = TARGETING::TYPE_NA;
if(nullptr != i_target &&
TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL != i_target)
{
if(getTargetType(i_target, l_type))
{
if(TARGETING::TYPE_PROC == l_type)
{
if(i_target->tryGetAttr<TARGETING::ATTR_MODEL>(l_model))
{
o_model = l_model;
l_retval = true;
}
}
}
}
return l_retval;
}
//---------------------------------------------------------------------------
bool DmiScomWorkaround::getTargetECLevel(TARGETING::Target* i_target,
uint8_t& o_ecLevel) const
{
bool l_retval{false};
uint8_t l_ecLevel{0};
if(nullptr != i_target &&
TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL != i_target)
{
TARGETING::TYPE l_type = TARGETING::TYPE_NA;
if(getTargetType(i_target, l_type))
{
if(TARGETING::TYPE_PROC == l_type)
{
if(i_target->tryGetAttr<TARGETING::ATTR_EC>(l_ecLevel))
{
o_ecLevel = l_ecLevel;
l_retval = true;
}
}
}
}
return l_retval;
}
} //End Namespace
|