summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaCaptureData.C
blob: 180bf563eedb18c29abd28f088c5bae31381f5e1 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaCaptureData.C $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2004,2014              */
/*                                                                        */
/* 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 prdfCenMbaCaptureData.C
 *  @brief Utility Functions to capture MBA data
 */

#include <prdfCenMbaCaptureData.H>

// Framwork includes
#include <iipServiceDataCollector.h>
#include <prdfDramRepairUsrData.H>
#include <prdfExtensibleChip.H>
#include <prdfRasServices.H>
#include <utilmem.H>
#include <UtilHash.H>

// Pegasus includes
#include <prdfCenDqBitmap.H>
#include <prdfCenMarkstore.H>
#include <prdfCenMbaDataBundle.H>
#include <prdfCenMembufDataBundle.H>

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

namespace CenMbaCaptureData
{

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

void addMemChipletFirRegs( ExtensibleChip * i_membChip, CaptureData & io_cd )
{
    #define PRDF_FUNC "[CenMbaCaptureData::addMemChipletFirRegs] "

    int32_t l_rc = SUCCESS;

    do
    {
        if ( NULL == i_membChip )
        {
            PRDF_ERR( PRDF_FUNC"Given target is NULL" );
            break;
        }

        if ( TYPE_MEMBUF != getTargetType(i_membChip->GetChipHandle()) )
        {
            PRDF_ERR( PRDF_FUNC"Invalid target type: i_membChip=0x%08x",
                      i_membChip->GetId() );
            break;
        }

        SCAN_COMM_REGISTER_CLASS * cs_global, * re_global, * spa_global;
        cs_global  = i_membChip->getRegister("GLOBAL_CS_FIR");
        re_global  = i_membChip->getRegister("GLOBAL_RE_FIR");
        spa_global = i_membChip->getRegister("GLOBAL_SPA");
        l_rc  = cs_global->Read() | re_global->Read() | spa_global->Read();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"Failed to read a GLOBAL register on "
                      "0x%08x", i_membChip->GetId() );
            break;
        }

        // If global bit 3 is not on, can't scom mem chiplets or mba's
        if( ! (cs_global->IsBitSet(3) ||
               re_global->IsBitSet(3) ||
               spa_global->IsBitSet(3)) )
        {
            break;
        }

        i_membChip->CaptureErrorData(io_cd,
                                     Util::hashString("MemChipletRegs"));

        CenMembufDataBundle * membdb = getMembufDataBundle( i_membChip );

        for ( uint32_t i = 0; i < MAX_MBA_PER_MEMBUF; i++ )
        {
            ExtensibleChip * mbaChip = membdb->getMbaChip(i);
            if ( NULL == mbaChip )
            {
                PRDF_ERR( PRDF_FUNC"MEM_CHIPLET registers indicated an "
                          "attention but no chip found: i_membChip=0x%08x "
                          "i=%d", i_membChip->GetId(), i );
                continue;
            }

            mbaChip->CaptureErrorData(io_cd,
                                      Util::hashString("MemChipletRegs") );
        }

    } while (0);

    #undef PRDF_FUNC
}

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

void addMemEccData( TargetHandle_t i_mbaTrgt, errlHndl_t io_errl )
{
    CaptureData cd;

    // Add DRAM repairs data from hardware.
    captureDramRepairsData( i_mbaTrgt, cd );

    // Add DRAM repairs data from VPD.
    captureDramRepairsVpd( i_mbaTrgt, cd );

    ErrDataService::AddCapData( cd, io_errl );
}

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

void addMemEccData( ExtensibleChip * i_mbaChip, STEP_CODE_DATA_STRUCT & io_sc )
{
    CaptureData & cd = io_sc.service_data->GetCaptureData();

    CenMbaDataBundle * mbadb = getMbaDataBundle( i_mbaChip );
    TargetHandle_t mbaTarget = i_mbaChip->GetChipHandle();

    // Add UE table to capture data.
    mbadb->iv_ueTable.addCapData( cd );

    // Add CE table to capture data.
    mbadb->iv_ceTable.addCapData( cd );

    // Add RCE table to capture data.
    mbadb->iv_rceTable.addCapData( cd );

    // Add DRAM repairs data from hardware.
    captureDramRepairsData( mbaTarget, cd );

    // Add DRAM repairs data from VPD.
    captureDramRepairsVpd( mbaTarget, cd );
}

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

void captureDramRepairsData( TARGETING::TargetHandle_t i_mbaTrgt,
                             CaptureData & io_cd )
{
    #define PRDF_FUNC "[CenMbaCaptureData::captureDramRepairsData] "
    using namespace fapi; // for spare config

    int32_t rc = SUCCESS;
    DramRepairMbaData mbaData;

    mbaData.header.isSpareDram = false;
    std::vector<CenRank> masterRanks;

    do
    {
        rc = getMasterRanks( i_mbaTrgt, masterRanks );
        if ( SUCCESS != rc )
        {
            PRDF_ERR( PRDF_FUNC"getMasterRanks() failed" );
            break;
        }
        if( masterRanks.empty() )
        {
            PRDF_ERR( PRDF_FUNC"Master Rank list size is 0");
            break;;
        }
        uint8_t spareConfig = ENUM_ATTR_VPD_DIMM_SPARE_NO_SPARE;
        // check for spare DRAM. Port does not matter.
        // Also this configuration is same for all ranks on MBA.
        rc = getDimmSpareConfig( i_mbaTrgt, masterRanks[0], 0, spareConfig );
        if( SUCCESS != rc )
        {
            PRDF_ERR( PRDF_FUNC"getDimmSpareConfig() failed" );
            break;
        }

        if( ENUM_ATTR_VPD_DIMM_SPARE_NO_SPARE != spareConfig )
            mbaData.header.isSpareDram = true;

        // Iterate all ranks to get DRAM repair data
        for ( std::vector<CenRank>::iterator it = masterRanks.begin();
              it != masterRanks.end(); it++ )
        {
            // Get chip/symbol marks
            CenMark mark;
            rc = mssGetMarkStore( i_mbaTrgt, *it, mark );
            if ( SUCCESS != rc )
            {
                PRDF_ERR( PRDF_FUNC"mssGetMarkStore() Failed");
                continue;
            }

            // Get DRAM spares
            CenSymbol sp0, sp1, ecc;
            rc = mssGetSteerMux( i_mbaTrgt, *it, sp0, sp1, ecc );
            if ( SUCCESS != rc )
            {
                PRDF_ERR( PRDF_FUNC"mssGetSteerMux() failed");
                continue;
            }

            // Add data
            DramRepairRankData rankData = { (*it).getMaster(),
                                            mark.getCM().getSymbol(),
                                            mark.getSM().getSymbol(),
                                            sp0.getSymbol(),
                                            sp1.getSymbol(),
                                            ecc.getSymbol() };
            if ( rankData.valid() )
            {
                mbaData.rankDataList.push_back(rankData);
            }
        }
        // If MBA had some DRAM repair data, add header information
        if( mbaData.rankDataList.size() > 0 )
        {
            mbaData.header.rankCount = mbaData.rankDataList.size();
            mbaData.header.isX4Dram =  isDramWidthX4( i_mbaTrgt );
            UtilMem dramStream;
            dramStream << mbaData;

            #ifndef PPC
            // Fix endianess issues with non PPC machines.
            // This is a workaround. Though UtilMem takes care of endianess,
            // It seems with capture data its not working
            const size_t sz_word = sizeof(uint32_t);

            // Allign data with 32 bit boundary
            for (uint32_t i = 0; i < ( dramStream.size()%sz_word ); i++)
            {
                uint8_t dummy = 0;
                dramStream << dummy;
            }
            for ( uint32_t i = 0; i < ( dramStream.size()/sz_word); i++ )
            {
                ((uint32_t*)dramStream.base())[i] =
                            htonl(((uint32_t*)dramStream.base())[i]);
            }
            #endif

            // Allocate space for the capture data.
            BIT_STRING_ADDRESS_CLASS dramRepairData ( 0,( dramStream.size() )*8,
                                               (CPU_WORD *) dramStream.base() );
            io_cd.Add( i_mbaTrgt, Util::hashString("DRAM_REPAIRS_DATA"),
                       dramRepairData );
        }
    }while(0);

    if( FAIL == rc )
        PRDF_ERR( PRDF_FUNC"Failed for MBA 0x%08X", getHuid( i_mbaTrgt ) );

    #undef PRDF_FUNC
}

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

void captureDramRepairsVpd( TargetHandle_t i_mbaTrgt, CaptureData & io_cd )
{
    #define PRDF_FUNC "[captureDramRepairsVpd] "

    // Get the maximum capture data size.
    static const size_t sz_rank  = sizeof(uint8_t);
    static const size_t sz_entry = PORT_SLCT_PER_MBA * DIMM_DQ_RANK_BITMAP_SIZE;
    static const size_t sz_word  = sizeof(CPU_WORD);
    int32_t rc = SUCCESS;

    do
    {
        std::vector<CenRank> masterRanks;
        rc = getMasterRanks( i_mbaTrgt, masterRanks );
        if ( SUCCESS != rc )
        {
            PRDF_ERR( PRDF_FUNC"getMasterRanks() failed" );
            break;
        }

        if( masterRanks.empty() )
        {
            PRDF_ERR( PRDF_FUNC"Master Rank list size is 0");
            break;
        }

        // Get the maximum capture data size.
        size_t sz_maxData = masterRanks.size() * (sz_rank + sz_entry);

        // Adjust the size for endianess.
        sz_maxData = ((sz_maxData + sz_word-1) / sz_word) * sz_word;

        // Initialize to 0.
        uint8_t capData[sz_maxData];
        memset( capData, 0x00, sz_maxData );

        // Iterate all ranks to get VPD data
        uint32_t idx = 0;
        for ( std::vector<CenRank>::iterator it = masterRanks.begin();
              it != masterRanks.end(); it++ )
        {
            CenDqBitmap bitmap;
            uint8_t rank = it->getMaster();

            if ( SUCCESS != getBadDqBitmap(i_mbaTrgt, *it, bitmap, true) )
            {
                PRDF_ERR( PRDF_FUNC"getBadDqBitmap() failed: MBA=0x%08x"
                          " rank=%d", getHuid(i_mbaTrgt), rank );
                continue; // skip this rank
            }

            if ( bitmap.badDqs() ) // make sure the data is non-zero
            {
                // Add the rank, then the entry data.
                capData[idx] = rank;              idx += sz_rank;
                memcpy(&capData[idx], bitmap.getData(), sz_entry);
                idx += sz_entry;
            }
        }

        if( 0 == idx ) break; // Nothing to capture

        // Fix endianess issues with non PPC machines.
        size_t sz_capData = idx;
        sz_capData = ((sz_capData + sz_word-1) / sz_word) * sz_word;
        for ( uint32_t i = 0; i < (sz_capData/sz_word); i++ )
            ((CPU_WORD*)capData)[i] = htonl(((CPU_WORD*)capData)[i]);

        // Add data to capture data.
        BIT_STRING_ADDRESS_CLASS bs ( 0, sz_capData*8, (CPU_WORD *) &capData );
        io_cd.Add( i_mbaTrgt, Util::hashString("DRAM_REPAIRS_VPD"), bs );

    }while(0);

    if( FAIL == rc )
        PRDF_ERR( PRDF_FUNC"Failed for MBA 0x%08X", getHuid( i_mbaTrgt ) );

    #undef PRDF_FUNC
}

}  //end namespace MbaCaptureData

} // end namespace PRDF


OpenPOWER on IntegriCloud