summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfPciOscSwitchDomain.C
blob: 0495b47c147b63e647f355ef620d2da56bded4fa (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfPciOscSwitchDomain.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2017                        */
/* [+] 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  PciOscSwitchDomain.C
 *  @brief Definition of PllDomain class
 */

#include <iipscr.h>
#include <iipsdbug.h>
#include <iipServiceDataCollector.h>
#include <prdfErrorSignature.H>
#include <iipResolution.h>
#include <prdfPlatServices.H>
#include <prdfPluginDef.H>
#include <prdfGlobal.H>
#include <iipSystem.h>
#include <UtilHash.H>
#include <prdfPciOscSwitchDomain.H>
#include <prdfP8ProcExtraSig.H>

#ifndef __HOSTBOOT_MODULE
#include <hdctContent.H>
#include <prdfSdcFileControl.H>
#endif

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

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

int32_t PciOscSwitchDomain::Initialize(void)
{
    return SUCCESS;
}

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

bool PciOscSwitchDomain::Query(ATTENTION_TYPE attentionType)
{
    #define  PRDF_FUNC  "PciOscSwitchDomain::Query "
    bool errorFound = false;

    // Only check for PCI osc switchover on redundant clock systems
    // System always checks for RE's first, even if there is an XSTOP
    // So we only need to check for PLL errors on RECOVERABLE type
    if( hasRedundantClocks() && ( attentionType == RECOVERABLE ) )
    {
        // check sysdbug for attention first
        SYSTEM_DEBUG_CLASS sysdbug;
        for( unsigned int index = 0;
             (index < GetSize()) && (errorFound == false); ++index )
        {
            ExtensibleChip * l_chip = LookUp( index );
            TARGETING::TargetHandle_t l_chipTgt = l_chip->GetChipHandle();
            bool l_analysisPending =
                  sysdbug.isActiveAttentionPending( l_chipTgt, RECOVERABLE );

            if( l_analysisPending )
            {
                ExtensibleChipFunction * l_query =
                            l_chip->getExtensibleFunction("queryPciOscErr");
                int32_t rc = (*l_query)(l_chip,
                          PluginDef::bindParm< bool &>(errorFound) );

                // if rc then scom read failed - Error log has already
                // been generated.

                if( PRD_POWER_FAULT == rc )
                {
                    PRDF_ERR( PRDF_FUNC "Power Fault detected!" );
                    break;
                }

                if( SUCCESS != rc )
                {
                    PRDF_ERR( PRDF_FUNC "SCOM fail. RC=%x", rc );
                }
            }
        }
    }

    #undef PRDF_FUNC
    return errorFound;
}

//------------------------------------------------------------------------------
int32_t PciOscSwitchDomain::Analyze( STEP_CODE_DATA_STRUCT & i_sc,
                                     ATTENTION_TYPE i_attentionType )
{
    #define PRDF_FUNC "PciOscSwitchDomain::Analyze "

    int32_t o_rc = SUCCESS;
    bool foundAttn = false;

    for( uint32_t index = 0; index < GetSize(); ++index )
    {
        ExtensibleChip * l_chip = LookUp( index );
        ExtensibleChipFunction * l_query =
            l_chip->getExtensibleFunction( "queryPciOscErr" );

        if( NULL == l_query )
        {
            continue;
        }

        o_rc = (*l_query)(l_chip,
                          PluginDef::bindParm< bool &>(foundAttn) );

        if( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "Query failed HUID: 0x%08x", l_chip->GetId() );
            break;
        }

        if( foundAttn )
        {
            // Set Signature
            i_sc.service_data->GetErrorSignature()->setChipId(
                                                        l_chip->GetId());

            PciOscConnList l_pciOscData;
            o_rc = analyzePciOscSwitch( l_chip, i_sc, l_pciOscData );

            if( SUCCESS != o_rc )
            {
                PRDF_ERR(PRDF_FUNC " PCI CLK Switch over analysis failed" );
                break;
            }

            addHwCalloutAndSignature( i_sc, l_pciOscData );

            // Set dump flag
            i_sc.service_data->SetDump( CONTENT_HW,
                                        l_chip->GetChipHandle() );
            break;
        }
    }//end of for loop

    #undef PRDF_FUNC
    return o_rc;
}

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

int32_t PciOscSwitchDomain::analyzePciOscSwitch(
                                        ExtensibleChip * i_chip,
                                        STEP_CODE_DATA_STRUCT & i_sc,
                                        PciOscConnList & o_pciOscSwitchData )
{
    #define PRDF_FUNC "PciOscSwitchDomain::analyzePciOscSwitch "
    int32_t o_rc = SUCCESS;

    do
    {

        TargetHandle_t l_chipTgt = i_chip->GetChipHandle();
        ExtensibleChipFunction * l_anlzPci =
                i_chip->getExtensibleFunction( "analyzePciClkFailover" );

        if( NULL == l_anlzPci )
        {
            o_rc = FAIL;
            break;
        }

        TargetHandle_t nodeTgt = getConnectedParent( l_chipTgt, TYPE_NODE );

        if( NULL == nodeTgt )
        {
            PRDF_ERR( PRDF_FUNC "unable to get node HUID: 0x%08x ",
                       i_chip->GetId() );
            o_rc = FAIL;
            break;
        }

        TargetHandleList pciConProcList = getConnected( nodeTgt, TYPE_PROC );

        for( TargetHandleList::iterator it = pciConProcList.begin();
             it != pciConProcList.end(); it++ )
        {
            ExtensibleChip * l_procChip = findChip( *it );

            if( NULL == l_procChip )
            {
                PRDF_ERR( PRDF_FUNC " could not find chip 0x%08x",
                          getHuid(*it) );
                continue;
            }

            // Capture PllFIRs group
            l_procChip->CaptureErrorData(
                    i_sc.service_data->GetCaptureData(),
                    Util::hashString("PllFIRs"));

            // Call this chip's capturePllFfdc plugin if it exists.
            ExtensibleChipFunction * l_captureFfdc =
                l_procChip->getExtensibleFunction("capturePllFfdcIo", true);

            if ( NULL != l_captureFfdc )
            {
                (*l_captureFfdc)( l_procChip,
                                  PluginDef::bindParm<STEP_CODE_DATA_STRUCT &>
                                  (i_sc) );
            }

            o_rc = (*l_anlzPci)( l_procChip,
                                 PluginDef::bindParm< PciOscConnList& >
                                 ( o_pciOscSwitchData ));
            if( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "analysis failed HUID: 0x%08x",
                          l_procChip->GetId() );
                break;
            }
        }

        #ifndef __HOSTBOOT_MODULE
        ServiceDataCollector & sdc = *(i_sc.service_data);
        SyncAnalysis (sdc);  //Add call to Sync SDC
        #endif

        o_rc = clearPciSwitchError( o_pciOscSwitchData );

        if( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC " Failed to clear PCI Osc error" );
            break;
        }

    }while(0);

    #undef PRDF_FUNC

    return o_rc;
}

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

bool PciOscSwitchDomain::checkMultiOscFailure( PciOscConnList & i_pciOscData )
{
    bool o_multipleOscFail = false;
    do
    {
        if( 0 == i_pciOscData.size() )
        {
            break;
        }

        PciOscConnList::iterator it = i_pciOscData.begin();
        uint32_t firstOscPos = it->pciOscPosition;

        for( ; it != i_pciOscData.end(); it++ )
        {
            if( firstOscPos != it->pciOscPosition )
            {
                o_multipleOscFail = true;
                break;
            }
        }

    }while(0);

    return o_multipleOscFail;
}

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

void PciOscSwitchDomain::addHwCalloutAndSignature( STEP_CODE_DATA_STRUCT & i_sc,
                                        PciOscConnList & i_pciOscSwitchData )
{
    #define PRDF_FUNC "PciOscSwitchDomain::addHwCalloutAndSignature "
    ErrorSignature * esig = i_sc.service_data->GetErrorSignature();
    uint32_t signature = esig->getSigId();

    do
    {
        uint32_t listSize = i_pciOscSwitchData.size();

        if( 0 == listSize )
        {
            PRDF_ERR( PRDF_FUNC "PCI Osc Switch Over: Analysis failed");
            i_sc.service_data->SetCallout( LEVEL2_SUPPORT, MRU_MED, NO_GARD );
            signature = PRDFSIG_PCI_OSC_ANL_FAILED;
            break;
        }

        PciOscConnList::iterator it = i_pciOscSwitchData.begin();
        TargetHandle_t procTgt = it->pciParentProc->GetChipHandle();
        TargetHandle_t l_nodeTgt =
                getConnectedParent( procTgt, TYPE_NODE );

        if( 1 < listSize )
        {
            if( 0 == it->pciOscPosition )
            {
                signature = PRDFSIG_MULTI_PROC_PCI_OSC0_FAILOVER;
            }
            else
            {
                signature = PRDFSIG_MULTI_PROC_PCI_OSC1_FAILOVER;
            }

            if( checkMultiOscFailure( i_pciOscSwitchData ) )
            {
                PRDF_ERR( PRDF_FUNC "Multiple pci Osc failures detected");
                signature = PRDFSIG_PCI_MULTIPLE_OSC_FO;
                i_sc.service_data->SetCallout(LEVEL2_SUPPORT, MRU_MED, NO_GARD);
            }

            i_sc.service_data->SetCallout( it->pciOscCard, MRU_HIGH );
            i_sc.service_data->SetCallout( l_nodeTgt, MRU_LOW, NO_GARD );
        }
        else
        {
            // Pci Osc endpoints are not supported as gardable
            // so instead, we'll need to callout/gard the source PCI OSC
            i_sc.service_data->SetCallout( procTgt, MRU_MED, NO_GARD);
            i_sc.service_data->SetCallout( l_nodeTgt, MRU_LOW , NO_GARD );
            i_sc.service_data->SetCallout( it->pciOscCard, MRU_HIGH );
            //i_sc.service_data->SetCallout( it->procPciEndPoint, MRU_MEDA );
            //i_sc.service_data->SetCallout( it->oscPciEndPoint, MRU_MEDA );

            if( 0 == it->pciOscPosition )
            {
                signature = PRDFSIG_PCI_OSC0_FAILOVER;
            }
            else
            {
                signature = PRDFSIG_PCI_OSC1_FAILOVER;
            }
        }
    }while(0);

    i_sc.service_data->SetErrorSig( signature );
    i_sc.service_data->setServiceCall();
    #undef PRDF_FUNC
}

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

int32_t PciOscSwitchDomain::clearPciSwitchError(
                                PciOscConnList & io_oscSwitchData )
{
    #define PRDF_FUNC "PciOscSwitchDomain::clearPciSwitchError "
    uint32_t o_rc = SUCCESS;

    for( PciOscConnList::iterator it = io_oscSwitchData.begin();
         it != io_oscSwitchData.end(); it++ )
    {
        ExtensibleChipFunction * l_clrPci =
                it->pciParentProc->getExtensibleFunction("clearPciOscFailOver");

        o_rc = (* l_clrPci )( it->pciParentProc,
                      PluginDef::bindParm< uint32_t &> ( it->pciOscPosition ));

        if( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC " Failed to clear PCI clk error bits"
                      "HUID: 0x%08x", it->pciParentProc->GetId() );
            break;
        }

    }

    #undef PRDF_FUNC
    return o_rc;
}

void PciOscSwitchDomain::Order( ATTENTION_TYPE i_attentionType )
{
    //Order is not relevant.
}

ExtensibleChip * PciOscSwitchDomain::findChip( TargetHandle_t i_chipTgt )
{
    ExtensibleChip * l_procChip = NULL;
    for( uint32_t i = 0; i < GetSize(); i++ )
    {
        l_procChip = LookUp( i );
        if( i_chipTgt == l_procChip->GetChipHandle() )
        {
            break;
        }

        l_procChip = NULL;
    }

    return l_procChip;
}

} // end namespace PRDF

OpenPOWER on IntegriCloud