summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfP8Mcs.C
blob: dc00d96ca360a436de61067576b9c333f94fe798 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfP8Mcs.C $           */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,2015                        */
/* [+] 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                                                     */

/** @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 <prdfCalloutUtil.H>
#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 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 = MemUtils::checkMcsChannelFail( i_mcsChip, i_sc );
    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( "[Mcs::PreAnalysis] MemUtils::checkMcsChannelFail() 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;

    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() &&
         (CHECK_STOP != i_sc.service_data->getPrimaryAttnType()) &&
         (!i_sc.service_data->GetFlag(ServiceDataCollector::UNIT_CS)) )
    {
        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 )

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

/**
 * @brief   Handles a memory mirror action event.
 * @param   i_mcsChip An MCS chip.
 * @param   i_sc      The step code data struct
 * @returns SUCCESS always
 */
int32_t handleMirrorAction( ExtensibleChip * i_mcsChip,
                            STEP_CODE_DATA_STRUCT & i_sc )
{
    #define PRDF_FUNC "[ClearMbsSecondaryBits] "

    int32_t l_rc = SUCCESS;

    do
    {
        // Get the primary MCS of the mirrored pair.
        P8McsDataBundle * mcsdb = getMcsDataBundle( i_mcsChip );
        ExtensibleChip * primcs = mcsdb->getPrimaryMirroredMcs();
        if ( NULL == primcs )
        {
            PRDF_ERR( PRDF_FUNC "getPrimaryMirroredMcs() failed: "
                      "i_mcsChip=0x%08x", i_mcsChip->GetId() );
            break;
        }

        // Manually capture the registers needed from the primary MCS.
        CaptureData & cd = i_sc.service_data->GetCaptureData();
        primcs->CaptureErrorData( cd, Util::hashString("MirrorRegs") );

        SCAN_COMM_REGISTER_CLASS * reg = primcs->getRegister("MCHWFM");
        l_rc = reg->Read();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC "Read() failed on MCHWFM: primcs=0x%08x",
                      primcs->GetId() );
            break;
        }

        if ( i_sc.service_data->IsAtThreshold() )
        {
            if ( reg->IsBitSet(1) ) // Mirror disabled.
            {
                // Error log will be predictive.
                i_sc.service_data->SetErrorSig( PRDFSIG_MirrorActionTH );
            }
            else // Mirror still enabled but getting a flood of attentions.
            {
                // Just submit the error log as hidden.
                i_sc.service_data->Nologging();
                i_sc.service_data->Gard( GardAction::NoGard );
            }
        }
        else // Under threshold
        {
            // Re-enable the mirror.
            reg->ClearBit(1);
            reg->ClearBit(2);
            reg->ClearBit(3);

            l_rc = reg->Write();
            if ( SUCCESS != l_rc )
            {
                PRDF_ERR( PRDF_FUNC "Write() failed on MCHWFM: primcs=0x%08x",
                          primcs->GetId() );
                break;
            }
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( Mcs, handleMirrorAction );

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

int32_t calloutInterface_dmi( ExtensibleChip * i_mcsChip,
                              STEP_CODE_DATA_STRUCT & io_sc )
{
    CalloutUtil::calloutBusInterface( i_mcsChip, MRU_LOW );
    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( Mcs, calloutInterface_dmi );

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

OpenPOWER on IntegriCloud