summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/service/prdfPlatServices_common.C
blob: 3fd188b630f4cee6af7d446f59ccd4622f320f8e (plain)
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: ./common/framework/service/prdfPlatServices_common.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  prdfPlatServices_common.C
 * @brief Wrapper code for external interfaces used by PRD.
 *
 * This file contains code that is strictly common between FSP and Hostboot. All
 * platform specific code should be in the respective FSP only or Hostboot only
 * files.
 */

#include <prdfPlatServices.H>

#include <prdfGlobal.H>
#include <prdfAssert.h>
#include <prdfTrace.H>
#include <prdfErrlUtil.H>

#include <dimmBadDqBitmapFuncs.H> // for dimm[S|G]etBadDqBitmap()

//FIXME RTC:64173 - erepair code not in FSP yet
#ifdef __HOSTBOOT_MODULE
#include <io_read_erepair.H>
#include <io_power_down_lanes.H>
#include <io_clear_firs.H>
#include <erepairAccessorHwpFuncs.H>
#endif

using namespace TARGETING;

//------------------------------------------------------------------------------

namespace PRDF
{

namespace PlatServices
{

//##############################################################################
//##                     Utility Functions (for this file only)
//##############################################################################

fapi::TargetType getFapiType( TARGETING::TargetHandle_t i_target )
{
    fapi::TargetType o_type = fapi::TARGET_TYPE_NONE;

    switch ( getTargetType(i_target) )
    {
        case TYPE_PROC:   o_type = fapi::TARGET_TYPE_PROC_CHIP;     break;
        case TYPE_EX:     o_type = fapi::TARGET_TYPE_EX_CHIPLET;    break;
        case TYPE_ABUS:   o_type = fapi::TARGET_TYPE_ABUS_ENDPOINT; break;
        case TYPE_XBUS:   o_type = fapi::TARGET_TYPE_XBUS_ENDPOINT; break;
        case TYPE_MCS:    o_type = fapi::TARGET_TYPE_MCS_CHIPLET;   break;
        case TYPE_MEMBUF: o_type = fapi::TARGET_TYPE_MEMBUF_CHIP;   break;
        case TYPE_MBA:    o_type = fapi::TARGET_TYPE_MBA_CHIPLET;   break;
        case TYPE_DIMM:   o_type = fapi::TARGET_TYPE_DIMM;          break;
        default: ;
    }

    return o_type;
}

//##############################################################################
//##                     System Level Utility Functions
//##############################################################################

void getECIDString( TargetHandle_t i_target, const char * o_ecidStr )
{
    o_ecidStr ="";
    PRDF_ERR( "[PlatServices::getECIDString] Function not implemented yet" );
}

//------------------------------------------------------------------------------

fapi::Target getFapiTarget( TARGETING::TargetHandle_t i_target )
{
    return fapi::Target( getFapiType(i_target), i_target );
}


//##############################################################################
//##                       Processor specific functions
//##############################################################################

//##############################################################################
//##                       Lane Repair functions
//##############################################################################

int32_t readErepair(TargetHandle_t i_rxBusTgt,
                    std::vector<uint8_t> &o_rxFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    //FIXME RTC:64173 - erepair code not in FSP yet
#ifdef __HOSTBOOT_MODULE
    PRD_FAPI_TO_ERRL(err,
                     io_read_erepair,
                     getFapiTarget(i_rxBusTgt),
                     o_rxFailLanes);
#endif

     if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::readErepair] HUID: 0x%08x io_read_erepair "
                  "failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

int32_t clearIOFirs(TargetHandle_t i_rxBusTgt)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    //FIXME RTC:64173 - erepair code not in FSP yet
#ifdef __HOSTBOOT_MODULE
    PRD_FAPI_TO_ERRL(err,
                     io_clear_firs,
                     getFapiTarget(i_rxBusTgt));
#endif

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::clearIOFirs] HUID: 0x%08x io_clear_firs "
                  "failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

int32_t powerDownLanes(TargetHandle_t i_rxBusTgt,
                       const std::vector<uint8_t> &i_rxFailLanes,
                       const std::vector<uint8_t> &i_txFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    //FIXME RTC:64173 - erepair code not in FSP yet
#ifdef __HOSTBOOT_MODULE
    PRD_FAPI_TO_ERRL(err,
                     io_power_down_lanes,
                     getFapiTarget(i_rxBusTgt),
                     i_txFailLanes,
                     i_rxFailLanes);
#endif

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::powerDownLanes] HUID: 0x%08x "
                  "io_power_down_lanes failed", getHuid(i_rxBusTgt) );
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}


int32_t getVpdFailedLanes(TargetHandle_t i_rxBusTgt,
                          std::vector<uint8_t> &o_rxFailLanes,
                          std::vector<uint8_t> &o_txFailLanes)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    //FIXME RTC:64173 - erepair code not in FSP yet
#ifdef __HOSTBOOT_MODULE
    PRD_FAPI_TO_ERRL(err,
                     erepairGetFailedLanes,
                     getFapiTarget(i_rxBusTgt),
                     o_rxFailLanes,
                     o_txFailLanes);
#endif

    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::getVpdFailedLanes] HUID: 0x%08x "
                  "erepairGetFailedLanes failed",
                  getHuid(i_rxBusTgt));
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

int32_t setVpdFailedLanes(TargetHandle_t i_rxBusTgt,
                          TargetHandle_t i_txBusTgt,
                          std::vector<uint8_t> &i_rxFailLanes,
                          bool & o_thrExceeded)
{
    int32_t o_rc = SUCCESS;
    errlHndl_t err = NULL;

    //FIXME interface being updated in RTC59554
    /*
    PRD_FAPI_TO_ERRL(err,
                    erepairSetFailedLanes,
                    getFapiTarget(i_rxBusTgt),
                    getFapiTarget(i_txBusTgt),
                    o_rxFailLanes,
                    o_thrExceeded);
     */
    if(NULL != err)
    {
        PRDF_ERR( "[PlatServices::setVpdFailedLanes] rxHUID: 0x%08x "
                  "txHUID: 0x%08x erepairSetFailedLanes failed",
                  getHuid(i_rxBusTgt), getHuid(i_txBusTgt));
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

//##############################################################################
//##                        Memory specific functions
//##############################################################################

int32_t getBadDqBitmap( TargetHandle_t i_mbaTarget, const uint8_t i_portSlct,
                        const uint8_t i_dimmSlct, const uint8_t i_rankSlct,
                        uint8_t (&o_data)[DIMM_DQ_RANK_BITMAP_SIZE] )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, dimmGetBadDqBitmap, getFapiTarget(i_mbaTarget),
                      i_portSlct, i_dimmSlct, i_rankSlct, o_data );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::getBadDqBitmap] dimmGetBadDqBitmap() failed. "
                  "HUID: 0x%08x port: %d DIMM: %d rank: %d",
                  getHuid(i_mbaTarget), i_portSlct, i_dimmSlct, i_rankSlct );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

//------------------------------------------------------------------------------

int32_t setBadDqBitmap( TargetHandle_t i_mbaTarget, const uint8_t i_portSlct,
                        const uint8_t i_dimmSlct, const uint8_t i_rankSlct,
                        const uint8_t (&i_data)[DIMM_DQ_RANK_BITMAP_SIZE] )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, dimmSetBadDqBitmap, getFapiTarget(i_mbaTarget),
                      i_portSlct, i_dimmSlct, i_rankSlct, i_data );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::getBadDqBitmap] dimmSetBadDqBitmap() failed. "
                  "HUID: 0x%08x ps: %d ds: %d rs: %d",
                  getHuid(i_mbaTarget), i_portSlct, i_dimmSlct, i_rankSlct );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

//------------------------------------------------------------------------------

int32_t mssGetMarkStore( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                         uint8_t & o_chipMark, uint8_t & o_symbolMark )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, mss_get_mark_store, getFapiTarget(i_mbaTarget),
                      i_rank, o_chipMark, o_symbolMark );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssGetMarkStore] mss_get_mark_store() "
                  "failed. HUID: 0x%08x rank: %d",
                  getHuid(i_mbaTarget), i_rank );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

//------------------------------------------------------------------------------

int32_t mssSetMarkStore( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                         uint8_t i_chipMark, uint8_t i_symbolMark )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    // TODO: mss_put_mark_store() will give a certain return code if the write
    //       to mark store was circumvented by hardware. Will need to check this
    //       return code.

    PRD_FAPI_TO_ERRL( errl, mss_put_mark_store, getFapiTarget(i_mbaTarget),
                      i_rank, i_chipMark, i_symbolMark );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssSetMarkStore] mss_put_mark_store() "
                  "failed. HUID: 0x%08x rank: %d cm: %d sm: %d",
                  getHuid(i_mbaTarget), i_rank, i_chipMark, i_symbolMark );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;
}

//------------------------------------------------------------------------------

int32_t mssGetSteerMux( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                        uint8_t & o_port0Spare, uint8_t & o_port1Spare,
                        uint8_t & o_eccSpare )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, mss_check_steering, getFapiTarget(i_mbaTarget),
                      i_rank, o_port0Spare, o_port1Spare, o_eccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssGetSteerMux] mss_check_steering() "
                  "failed. HUID: 0x%08x rank: %d",
                  getHuid(i_mbaTarget), i_rank );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;

}

//------------------------------------------------------------------------------

int32_t mssSetSteerMux( TargetHandle_t i_mbaTarget, uint8_t i_rank,
                        uint8_t i_symbol, bool i_x4EccSpare )
{
    int32_t o_rc = SUCCESS;

    errlHndl_t errl = NULL;

    PRD_FAPI_TO_ERRL( errl, mss_do_steering, getFapiTarget(i_mbaTarget),
                      i_rank, i_symbol, i_x4EccSpare );

    if ( NULL != errl )
    {
        PRDF_ERR( "[PlatServices::mssSetSteerMux] mss_do_steering "
                  "failed. HUID: 0x%08x rank: %d symbol: %d eccSpare: %c",
                  getHuid(i_mbaTarget), i_rank, i_symbol,
                  i_x4EccSpare ? 'T' : 'F' );
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }

    return o_rc;

}

//------------------------------------------------------------------------------

/* TODO - Get the memory buffer raw card type (i.e. R/C A). This is needed for
          the DRAM site locations for buffered DIMMs. Should be able to get this
          from an attribute but doesn't look like this is available yet.
getMembufRawCardType()
{
}
*/

//------------------------------------------------------------------------------

/* TODO - Get the type of the card a DIMM is plugged into. This is needed for
          the DRAM site locations for IS DIMMs. Should be able to get this from
          an attribute but doesn't look like this is available yet.
getDimmPlugCardType()
{
}
*/

//##############################################################################
//##                    Maintance Command class wrapper
//##############################################################################

mss_MaintCmdWrapper::mss_MaintCmdWrapper( mss_MaintCmd * i_maintCmd ) :
    iv_cmd(i_maintCmd)
{}

//------------------------------------------------------------------------------

mss_MaintCmdWrapper::~mss_MaintCmdWrapper()
{
    delete iv_cmd;
}

//------------------------------------------------------------------------------

int32_t mss_MaintCmdWrapper::stopCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->stopCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::stopCmd failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

//------------------------------------------------------------------------------

int32_t mss_MaintCmdWrapper::setupAndExecuteCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->setupAndExecuteCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::setupAndExecuteCmd "
                   "failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

//------------------------------------------------------------------------------

int32_t mss_MaintCmdWrapper::cleanupCmd()
{
    PRDF_ASSERT( NULL != iv_cmd );
    int32_t o_rc = SUCCESS;
    fapi::ReturnCode l_rc = iv_cmd->cleanupCmd();

    //  convert FAPI RC to error handle
    errlHndl_t err = fapi::fapiRcToErrl(l_rc);

    if (NULL != err)
    {
        PRDF_GET_REASONCODE(err, o_rc);
        PRDF_ERR( "mss_MaintCmdWrapper::cleanupCmd failed: [0x%X]", o_rc);
        PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
        o_rc = FAIL;
    }
    return o_rc;
}

//------------------------------------------------------------------------------

mss_MaintCmdWrapper * createTimeBaseScrub(
                        const TARGETING::TargetHandle_t i_mba,
                        uint64_t i_startAddr, uint64_t i_endAddr,
                        bool  i_isFastSpeed, uint32_t i_stopCondition )
{
    ecmdDataBufferBase ecmdStartAddr(64);
    ecmdDataBufferBase ecmdEndAddr(64);

    ecmdStartAddr.setDoubleWord(0, i_startAddr);
    ecmdEndAddr.setDoubleWord(0, i_endAddr);

    mss_MaintCmd::TimeBaseSpeed cmdSpeed = mss_MaintCmd::SLOW_12H;
    if ( i_isFastSpeed )
        cmdSpeed = mss_MaintCmd::FAST_AS_POSSIBLE;

    mss_MaintCmd * cmd = new mss_TimeBaseScrub( getFapiTarget(i_mba),
                                                ecmdStartAddr, ecmdEndAddr,
                                                cmdSpeed, i_stopCondition,
                                                false );

    mss_MaintCmdWrapper * cmdWrapper = new mss_MaintCmdWrapper(cmd);

    return cmdWrapper;
}

} // end namespace PlatServices

} // end namespace PRDF

OpenPOWER on IntegriCloud