summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfP8Mcs.C
blob: 1c3ee9e1cfcae35bfe0b5abc5b285890aced6636 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfP8Mcs.C $           */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,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  prdfP8Mcs.C
 *  @brief Contains all the plugin code for the PRD P8 MCS
 */

// Framework includes
#include <iipServiceDataCollector.h>
#include <iipSystem.h>
#include <prdfExtensibleChip.H>
#include <prdfGlobal.H>
#include <prdfPluginMap.H>
#include <UtilHash.H>

// Pegasus includes
#include <prdfCenMbaCaptureData.H>
#include <prdfCenMembufDataBundle.H>
#include <prdfLaneRepair.H>
#include <prdfP8McsDataBundle.H>
#include <prdfCenMemUtils.H>

#include <prdfP8McsExtraSig.H>

//##############################################################################
//
//                             Special plugins
//
//##############################################################################

namespace PRDF
{

using namespace PlatServices;
using namespace TARGETING;

namespace Mcs
{

/**
 * @brief  Plugin that initializes the MCS data bundle.
 * @param  i_mcsChip An MCS chip.
 * @return SUCCESS
 */
int32_t Initialize( ExtensibleChip * i_mcsChip )
{
    i_mcsChip->getDataBundle() = new P8McsDataBundle( i_mcsChip );
    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( Mcs, Initialize );

/**
 * @brief Check for and handle a Centaur Unit Checkstop
 * @param i_mcsChip An MCS chip.
 * @param i_sc Step Code Data structure
 * @return failure or success
 */
int32_t CheckCentaurCheckstop( ExtensibleChip * i_mcsChip,
                               STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t l_rc = SUCCESS;

    do
    {
        // Skip if we're already at Unit Checkstop in SDC
        if (i_sc.service_data->GetFlag(ServiceDataCollector::UNIT_CS))
            break;

        // Check MCIFIR[31] for presence of Centaur checkstop
        SCAN_COMM_REGISTER_CLASS * l_mcifir = i_mcsChip->getRegister("MCIFIR");
        l_rc = l_mcifir->Read();

        if (l_rc)
        {
            PRDF_ERR( "[CheckCentaurCheckstop] SCOM fail on 0x%08x rc=%x",
                      i_mcsChip->GetId(), l_rc);
            break;
        }

        if ( ! l_mcifir->IsBitSet(31) )  { break; }

        // Set Unit checkstop flag
        i_sc.service_data->SetFlag(ServiceDataCollector::UNIT_CS);
        i_sc.service_data->SetThresholdMaskId(0);

        // Set the cause attention type
        i_sc.service_data->SetCauseAttentionType(UNIT_CS);

    } while (0);

    return l_rc;
}

/**
 * @brief Analysis code that is called before the main analyze() function.
 * @param i_mcsChip An MCS chip.
 * @param i_sc Step Code Data structure
 * @param o_analyzed TRUE if analysis has been done on this chip
 * @return failure or success
 */
int32_t PreAnalysis( ExtensibleChip * i_mcsChip, STEP_CODE_DATA_STRUCT & i_sc,
                     bool & o_analyzed )
{
    o_analyzed = false;

    // Get memory capture data.
    CaptureData & cd = i_sc.service_data->GetCaptureData();
    P8McsDataBundle * mcsdb = getMcsDataBundle( i_mcsChip );
    ExtensibleChip * membChip = mcsdb->getMembChip();
    if ( NULL != membChip )
    {
        membChip->CaptureErrorData( cd, Util::hashString("FirRegs") );
        membChip->CaptureErrorData( cd, Util::hashString("CerrRegs") );

        CenMbaCaptureData::addMemChipletFirRegs( membChip, cd );
    }

    // Check for a Centaur Checkstop
    int32_t o_rc = CheckCentaurCheckstop( i_mcsChip, i_sc );
    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( "[Mcs::PreAnalysis] CheckCentaurCheckstop() failed" );
    }

    return o_rc;
}
PRDF_PLUGIN_DEFINE( Mcs, PreAnalysis );

/**
 * @brief  Plugin function called after analysis is complete but before PRD
 *         exits.
 * @param  i_mcsChip MCS chip
 * @param  i_sc      The step code data struct.
 * @note   This is especially useful for any analysis that still needs to be
 *         done after the framework clears the FIR bits that were at attention.
 * @return SUCCESS.
 */
int32_t PostAnalysis( ExtensibleChip * i_mcsChip,
                      STEP_CODE_DATA_STRUCT & i_sc )
{
    #define PRDF_FUNC "[Mcs::PostAnalysis] "
    int32_t l_rc = SUCCESS;

    if ( i_sc.service_data->GetFlag(ServiceDataCollector::UNIT_CS) &&
         (CHECK_STOP != i_sc.service_data->GetAttentionType()) )
    {
        P8McsDataBundle * mcsdb = getMcsDataBundle( i_mcsChip );
        ExtensibleChip * membChip = mcsdb->getMembChip();
        if ( NULL != membChip )
        {
            l_rc = MemUtils::chnlCsCleanup( membChip, i_sc );
            if( SUCCESS != l_rc )
            {
                PRDF_ERR( PRDF_FUNC"ChnlCsCleanup() failed for Membuf:0x%08X",
                          membChip->GetId() );
            }
        }
    }

    return SUCCESS;
    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( Mcs, PostAnalysis );

/**
 * @brief  Checks if spare deployed bit for DMI bus for this MCS is set.
 * @param  i_mcsChip MCS chip
 * @param  i_sc      The step code data struct.
 * @return SUCCESS if bit is on, FAIL otherwise.
 */
int32_t checkSpareBit( ExtensibleChip * i_mcsChip,
                       STEP_CODE_DATA_STRUCT & i_sc )
{
    using namespace LaneRepair;

    int32_t l_rc = FAIL; // Default is to handle the attention (via rule code).

    ExtensibleChip * mbChip = getMcsDataBundle( i_mcsChip )->getMembChip();

    if ( isSpareBitOnDMIBus(i_mcsChip, mbChip) )
    {
        // Ignore attention and do not commit the error log.
        i_sc.service_data->DontCommitErrorLog();
        l_rc = SUCCESS;
    }

    return l_rc;
}
PRDF_PLUGIN_DEFINE( Mcs, checkSpareBit );

/**
 * @fn ClearMbsSecondaryBits
 * @brief Clears MBS secondary Fir bits which may come up because of MCIFIR
 * @param  i_chip       The Mcs chip.
 * @param  i_sc         ServiceDataColector.
 * @return SUCCESS.

 */
int32_t ClearMbsSecondaryBits( ExtensibleChip * i_chip,
                               STEP_CODE_DATA_STRUCT & i_sc  )
{
    #define PRDF_FUNC "[ClearMbsSecondaryBits] "

    int32_t l_rc = SUCCESS;
    do
    {
        P8McsDataBundle * mcsdb = getMcsDataBundle( i_chip );
        ExtensibleChip * membChip = mcsdb->getMembChip();

        if ( NULL == membChip ) break;

        // Not checking if MBSFIR bits are set or not.
        // Clearing them blindly as it will give better performance.
        SCAN_COMM_REGISTER_CLASS * mbsAndFir =
                                membChip->getRegister("MBSFIR_AND");

        if( NULL == mbsAndFir )
        {
            PRDF_ERR( PRDF_FUNC"Can not find MBSFIR_AND "
                       "for 0x%08x", membChip->GetId());
            break;
        }
        mbsAndFir->setAllBits();

        mbsAndFir->ClearBit(3);
        mbsAndFir->ClearBit(4);
        l_rc = mbsAndFir->Write();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"MBSFIR_AND write failed"
                       "for 0x%08x", membChip->GetId());
            break;
        }
    }while( 0 );
    return SUCCESS;

    #undef PRDF_FUNC
} PRDF_PLUGIN_DEFINE( Mcs, ClearMbsSecondaryBits );

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

/**
 * @brief   When not in MNFG mode, clear the service call flag so that
 *          thresholding will still be done, but no visible error log committed.
 * @param   i_chip MCS chip
 * @param   i_sc   Step code data struct
 * @returns SUCCESS always
 */
int32_t ClearServiceCallFlag( ExtensibleChip * i_chip,
                              STEP_CODE_DATA_STRUCT & i_sc )
{
    if ( i_sc.service_data->IsAtThreshold() && !mfgMode() )
    {
        i_sc.service_data->ClearFlag(ServiceDataCollector::SERVICE_CALL);
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( Mcs, ClearServiceCallFlag );

/**
 * @brief   Checks if the parent proc chip is either a Murano at DD least 2.0
 *          or a Venice. If neither, implements the DD1 actions
 *          of MBSFIR for the specified bit.
 * @param   i_mcsChip MCS chip
 * @param   i_sc      Step code data struct
 * @return  FAIL if MuranoDD2Plus or Venice, SUCCESS otherwise
 */
int32_t dd1mcifirBit(ExtensibleChip * i_mcsChip,
                     STEP_CODE_DATA_STRUCT & i_sc,
                     uint32_t i_bitNum )
{
    int32_t l_rc = SUCCESS;
    bool isMuranoDD2Plus = false;
    bool isVenice = false;
    TargetHandle_t l_mcsTrgt = i_mcsChip->GetChipHandle();
    TargetHandle_t l_proc  = getParentChip( l_mcsTrgt );
    uint8_t l_chipLevel = getChipLevel(l_proc);
    MODEL l_model = getProcModel(l_proc);

    if( MODEL_VENICE == l_model )
        isVenice = true;
    else if( (0x20 <= l_chipLevel) && (MODEL_MURANO == l_model) )
        isMuranoDD2Plus = true;

    if(isMuranoDD2Plus || isVenice)
    {
        l_rc = FAIL;
    }
    else
    {
        i_sc.service_data->SetCallout(l_mcsTrgt, MRU_MED);
        ClearServiceCallFlag(i_mcsChip, i_sc);
        if(48 == i_bitNum)
            i_sc.service_data->SetErrorSig( PRDFSIG_MciFir_48_DD1Signature );
        else if(49 == i_bitNum)
            i_sc.service_data->SetErrorSig( PRDFSIG_MciFir_49_DD1Signature );
    }

    return l_rc;
}

#define PLUGIN_MCIFIR_DD1_CHECK( BITNUM )                     \
int32_t dd1mcifirBit##BITNUM (ExtensibleChip * i_mcsChip,     \
                              STEP_CODE_DATA_STRUCT & i_sc )  \
{                                                             \
    return dd1mcifirBit( i_mcsChip, i_sc, BITNUM );           \
}                                                             \
PRDF_PLUGIN_DEFINE( Mcs, dd1mcifirBit##BITNUM );

PLUGIN_MCIFIR_DD1_CHECK( 48 )
PLUGIN_MCIFIR_DD1_CHECK( 49 )

} // end namespace Mcs
} // end namespace PRDF

OpenPOWER on IntegriCloud