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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/hwpf/hwp/erepairGetFailedLanesHwp.C $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2012,2013 */
/* */
/* p1 */
/* */
/* Object Code Only (OCO) source materials */
/* Licensed Internal Code Source Materials */
/* IBM HostBoot Licensed Internal Code */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
/**
* @file erepairGetFailedLanesHwp.C
*
* @brief FW Team HWP that accesses the fail lanes of Fabric and Memory buses.
*/
/*
* Change Log ******************************************************************
* Flag Defect/Feature User Date Description
* ------ -------------- ---------- ----------- ----------------------------
* bilicon 09/14/2012 Created.
*/
#include <erepairGetFailedLanesHwp.H>
extern "C"
{
/******************************************************************************
* Forward Declarations
*****************************************************************************/
/**
* @brief Function called by the FW Team HWP that reads the data from Field VPD.
* This function makes the actual calls to read the VPD
* It determines the size of the buffer to be read, allocates memory
* of the determined size, calls fapiGetMvpdField to read the eRepair
* records. This buffer is further passed to another routine for
* parsing.
*
* @param[in] i_tgtHandle Reference to X-Bus or A-Bus or MCS target
* @param[in] i_procTgt Reference to the Processor target associated with
* passed i_tgtHandle
* @param[in] i_recordType This is the VPD record type that is used to query
* the VPD data
* @param[o] o_txFailLanes Reference to a vector that will hold eRepair fail
* lane numbers of the Tx sub-interface.
* @param[o] o_rxFailLanes Reference to a vector that will hold eRepair fail
* lane numbers of the Rx sub-interface.
*
* @return ReturnCode
*/
fapi::ReturnCode retrieveRepairData(const fapi::Target &i_tgtHandle,
const fapi::Target &i_procTgt,
fapi::MvpdRecord i_recordType,
std::vector<uint8_t> &o_txFailLanes,
std::vector<uint8_t> &o_rxFailLanes);
/**
* @brief Function called by the FW Team HWP that parses the data read from
* Field VPD. This function matches each eRepair record read from the VPD
* and matches it against the attributes of the passed target.
* If a match is found, the corresponding eRepair record is copied into
* the respective failLane vectors to be returned to the caller.
*
* @param[in] i_tgtHandle Reference to X-Bus or A-Bus or MCS target
* @param[in] i_buf This is the buffer that has the eRepair records
* read from the VPD
* @param[in] i_bufSz This is the size of passed buffer in terms of bytes
* @param[o] o_txFailLanes Reference to a vector that will hold eRepair fail
* lane numbers of the Tx sub-interface.
* @param[o] o_rxFailLanes Reference to a vector that will hold eRepair fail
* lane numbers of the Rx sub-interface.
*
* @return ReturnCode
*/
fapi::ReturnCode determineRepairLanes(const fapi::Target &i_tgtHandle,
uint8_t *i_buf,
uint32_t i_bufSz,
std::vector<uint8_t> &o_txFailLanes,
std::vector<uint8_t> &o_rxFailLanes);
/******************************************************************************
* Accessor HWP
*****************************************************************************/
fapi::ReturnCode erepairGetFailedLanesHwp(const fapi::Target &i_tgtHandle,
std::vector<uint8_t> &o_txFailLanes,
std::vector<uint8_t> &o_rxFailLanes)
{
fapi::ReturnCode l_rc;
fapi::Target l_processorTgt;
fapi::MvpdRecord l_fieldRecord;
fapi::TargetType l_tgtType = fapi::TARGET_TYPE_NONE;
std::vector<fapi::Target> l_mcsChiplets;
FAPI_INF(">> erepairGetFailedLanesHwp: i_tgtHandle: %s",
i_tgtHandle.toEcmdString());
do
{
o_txFailLanes.clear();
o_rxFailLanes.clear();
// Determine the type of target
l_tgtType = i_tgtHandle.getType();
// Verify if the correct target type is passed
// TODO: l_tgtType of fapi::TARGET_TYPE_MEMBUF_CHIP will be supported
// when HWSV will provide the device driver to read the
// Centaur FRU VPD. RTC Task 51234, Depends on Story 44009
if((l_tgtType != fapi::TARGET_TYPE_MCS_CHIPLET) &&
(l_tgtType != fapi::TARGET_TYPE_XBUS_ENDPOINT) &&
(l_tgtType != fapi::TARGET_TYPE_ABUS_ENDPOINT))
{
FAPI_ERR("erepairGetFailedLanesHwp: Invalid Target type %d",
l_tgtType);
FAPI_SET_HWP_ERROR(l_rc, RC_ACCESSOR_HWP_INVALID_TARGET_TYPE);
break;
}
// Determine the Processor target
l_rc = fapiGetParentChip(i_tgtHandle, l_processorTgt);
if(l_rc)
{
FAPI_ERR("Error (0x%x) from fapiGetParentChip",
static_cast<uint32_t>(l_rc));
break;
}
// Retrieve the Field eRepair lane numbers from the VPD
l_fieldRecord = fapi::MVPD_RECORD_VWML;
l_rc = retrieveRepairData(i_tgtHandle,
l_processorTgt,
l_fieldRecord,
o_txFailLanes,
o_rxFailLanes);
if(l_rc)
{
FAPI_ERR("Error (0x%x) during retrieval of Field records",
static_cast<uint32_t>(l_rc));
break;
}
}while(0);
FAPI_INF("<< erepairGetFailedLanesHwp");
return l_rc;
}
fapi::ReturnCode retrieveRepairData(const fapi::Target &i_tgtHandle,
const fapi::Target &i_procTgt,
fapi::MvpdRecord i_recordType,
std::vector<uint8_t> &o_txFailLanes,
std::vector<uint8_t> &o_rxFailLanes)
{
uint8_t *l_retBuf = NULL;
uint32_t l_bufSize = 0;
fapi::ReturnCode l_rc;
FAPI_INF(">> retrieveRepairData: i_procTgt: %s", i_procTgt.toEcmdString());
do
{
// Determine the size of the eRepair data in the VPD
l_rc = fapiGetMvpdField(i_recordType,
fapi::MVPD_KEYWORD_PDI,
i_procTgt,
NULL,
l_bufSize);
if(l_rc)
{
FAPI_ERR("Error (0x%x) from fapiGetMvpdField",
static_cast<uint32_t> (l_rc));
break;
}
if(l_bufSize != 0)
{
// Allocate memory for buffer
l_retBuf = new uint8_t[l_bufSize];
if(l_retBuf == NULL)
{
FAPI_ERR("Failed to allocate memory size of %d", l_bufSize);
FAPI_SET_HWP_ERROR(l_rc, RC_ACCESSOR_HWP_MEMORY_ALLOC_FAIL);
break;
}
// Retrieve the Field eRepair data from the PNOR
l_rc = fapiGetMvpdField(i_recordType,
fapi::MVPD_KEYWORD_PDI,
i_procTgt,
l_retBuf,
l_bufSize);
if(l_rc)
{
FAPI_ERR("Error (0x%x) from fapiGetMvpdField",
static_cast<uint32_t> (l_rc));
break;
}
// Parse the buffer to determine eRepair lanes and copy the
// fail lane numbers to the return vector
l_rc = determineRepairLanes(i_tgtHandle,
l_retBuf,
l_bufSize,
o_txFailLanes,
o_rxFailLanes);
if(l_rc)
{
FAPI_ERR("determineRepairLanes failed");
break;
}
}
}while(0);
// Delete the buffer which has Field eRepair data
delete[] l_retBuf;
FAPI_INF("<< retrieveRepairData");
return (l_rc);
}
fapi::ReturnCode determineRepairLanes(const fapi::Target &i_tgtHandle,
uint8_t *i_buf,
uint32_t i_bufSz,
std::vector<uint8_t> &o_txFailLanes,
std::vector<uint8_t> &o_rxFailLanes)
{
uint32_t l_numRepairs = 0;
uint8_t *l_vpdPtr = NULL;
eRepairHeader *l_vpdHeadPtr = NULL;
uint32_t l_loop = 0;
uint32_t l_bytesParsed = 0;
const uint32_t l_memRepairDataSz = sizeof(eRepairMemBus);
const uint32_t l_fabricRepairDataSz = sizeof(eRepairPowerBus);
fapi::TargetType l_tgtType = fapi::TARGET_TYPE_NONE;
fapi::ReturnCode l_rc;
fapi::ATTR_CHIP_UNIT_POS_Type l_busNum;
FAPI_INF(">> determineRepairLanes");
do
{
// Read the header and count information
l_vpdPtr = i_buf; // point to the start of header data
l_vpdHeadPtr = reinterpret_cast<eRepairHeader *> (l_vpdPtr);
l_numRepairs = l_vpdHeadPtr->numRecords;
l_bytesParsed = sizeof(eRepairHeader); // we've read the header data
l_vpdPtr += sizeof(eRepairHeader); // point to the start of repair data
l_tgtType = i_tgtHandle.getType();
// Parse for Power bus data
if((l_tgtType == fapi::TARGET_TYPE_XBUS_ENDPOINT) ||
(l_tgtType == fapi::TARGET_TYPE_ABUS_ENDPOINT))
{
eRepairPowerBus l_fabricBus;
// Read Power bus eRepair data and get the failed lane numbers
for(l_loop = 0;
l_loop < l_numRepairs;
l_loop++, (l_vpdPtr += l_fabricRepairDataSz))
{
// Make sure we are not parsing more data than the passed size
l_bytesParsed += l_fabricRepairDataSz;
if(l_bytesParsed > i_bufSz)
{
break;
}
memcpy(&l_fabricBus, l_vpdPtr, l_fabricRepairDataSz);
// Check if we have the correct Processor ID
// Get the MRU ID of the passed processor target and
// match with l_fabricBus.device.processor_id.
// Note: This is currently not required.
// Check if we have the matching the Fabric Bus types
if((l_fabricBus.type != EREPAIR::PROCESSOR_EI4) &&
(l_fabricBus.type != EREPAIR::PROCESSOR_EDI))
{
continue;
}
// Check if we have the matching fabric bus interface
l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS,&i_tgtHandle,l_busNum);
if(l_rc)
{
FAPI_ERR("Error (0x%x), from FAPI_ATTR_GET",
static_cast<uint32_t>(l_rc));
break;
}
if(l_fabricBus.device.fabricBus != l_busNum)
{
continue;
}
// Check if we have valid fail lane numbers
if(l_fabricBus.failBit == EREPAIR::INVALID_FAIL_LANE_NUMBER)
{
continue;
}
// Copy the fail lane numbers in the vectors
if(l_fabricBus.interface == EREPAIR::PBUS_DRIVER)
{
o_txFailLanes.push_back(l_fabricBus.failBit);
}
else if(l_fabricBus.interface == EREPAIR::PBUS_RECEIVER)
{
o_rxFailLanes.push_back(l_fabricBus.failBit);
}
} // end of for loop
} // end of if(l_tgtType is XBus or ABus)
else if(l_tgtType == fapi::TARGET_TYPE_MCS_CHIPLET)
{
// Parse for Memory bus data
eRepairMemBus l_memBus;
// Read Power bus eRepair data and get the failed lane numbers
for(l_loop = 0;
l_loop < l_numRepairs;
l_loop++, (l_vpdPtr += l_memRepairDataSz))
{
// Make sure we are not parsing more data than the passed size
l_bytesParsed += l_memRepairDataSz;
if(l_bytesParsed > i_bufSz)
{
break;
}
memcpy(&l_memBus, l_vpdPtr, l_memRepairDataSz);
// Check if we have the correct Processor ID
// Get the MRU ID of the passed processor target and
// match with l_memBus.device.processor_id
// Note: This is currently not required.
// Check if we have the matching the Memory Bus types
if(l_memBus.type != EREPAIR::MEMORY_EDI)
{
continue;
}
// Check if we have the matching memory bus interface
l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS,&i_tgtHandle,l_busNum);
if(l_rc)
{
FAPI_ERR("Error (0x%x), from ATTR_CHIP_UNIT_POS",
static_cast<uint32_t>(l_rc));
break;
}
if(l_memBus.device.memChannel != l_busNum)
{
continue;
}
// Check if we have valid fail lane numbers
if(l_memBus.failBit == EREPAIR::INVALID_FAIL_LANE_NUMBER)
{
continue;
}
// Copy the fail lane numbers in the vectors
if(l_memBus.interface == EREPAIR::DMI_MCS_DRIVE)
{
o_txFailLanes.push_back(l_memBus.failBit);
}
else if(l_memBus.interface == EREPAIR::DMI_MCS_RECEIVE)
{
o_rxFailLanes.push_back(l_memBus.failBit);
}
} // end of for loop
} // end of if(l_tgtType is MCS)
}while(0);
FAPI_INF("<< determineRepairLanes: tx: %d, rx: %d",
o_txFailLanes.size(), o_rxFailLanes.size());
return(l_rc);
}
}// endof extern "C"
|