summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/hwasPlatCallout.C
blob: c1b031d9df405cd2fb3314e703a1452db0e46c21 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwas/hwasPlatCallout.C $                              */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2013,2018                        */
/* [+] 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 hwasPlatCallout.C
 *
 *  @brief Platform Callout specific functions
 */

#include <hwas/common/hwas.H>
#include <hwas/common/hwasCommon.H>
#include <hwas/common/hwasCallout.H>
#include <hwas/common/deconfigGard.H>
#include <hwas/hwasPlat.H>
#include <initservice/initserviceif.H>
#ifdef CONFIG_BMC_IPMI
#include <ipmi/ipmisensor.H>
#endif
namespace HWAS
{

//******************************************************************************
// platHandleProcedureCallout
//******************************************************************************
errlHndl_t platHandleProcedureCallout(
        errlHndl_t &io_errl,
        epubProcedureID i_procedure,
        callOutPriority i_priority)
{
    // WARNING:
    // this hostboot code should not change io_errl, unless the caller of the
    //  processCallouts() function also changes, as today it (errlentry.C) calls
    //  from the errlEntry object

    errlHndl_t errl = NULL;

    // hostboot does not handle or do any action for procedure callouts
    return errl;
}

//******************************************************************************
// platHandleHWCallout
//******************************************************************************
errlHndl_t platHandleHWCallout(
        TARGETING::Target *i_pTarget,
        callOutPriority i_priority,
        DeconfigEnum    i_deconfigState,
        errlHndl_t &io_errl,
        GARD_ErrorType  i_gardErrorType)
{
    // WARNING:
    // this hostboot code should not change io_errl, unless the caller of the
    //  processCallouts() function also changes, as today it (errlentry.C) calls
    //  from the errlEntry object

    errlHndl_t errl = NULL;

    HWAS_INF("HW callout; pTarget %p gardErrorType %x deconfigState %x",
            i_pTarget, i_gardErrorType, i_deconfigState);

    if (hwasPLDDetection())
    {
        HWAS_INF("hwasPLDDetection return true - skipping callouts");
    }
    else if ((io_errl->sev()) == (ERRORLOG::ERRL_SEV_INFORMATIONAL))
    {
        HWAS_INF("Error log is informational - skipping callouts");
    }
    else
    {
        switch (i_gardErrorType)
        {
            case (GARD_NULL):
            {   // means no GARD operations
                break;
            }
            default:
            {

#ifndef CONFIG_NO_GARD_SUPPORT
                errl = HWAS::theDeconfigGard().platCreateGardRecord(i_pTarget,
                        io_errl->eid(),
                        i_gardErrorType);
#elif CONFIG_RECALL_DECONFIG_ON_RECONFIG
                //If Gard is turned off, always populate a reconfig type
                //in case of a reconfig loop
                errl = HWAS::theDeconfigGard()
                  .platCreateGardRecord(i_pTarget,io_errl->eid(),
                                        GARD_Reconfig);
#endif
                break;
            }
        } // switch i_gardErrorType

        switch (i_deconfigState)
        {
            case (NO_DECONFIG):
            {
                break;
            }
            case (DECONFIG):
            {
                // call HWAS common function
                errl = HWAS::theDeconfigGard().deconfigureTarget(*i_pTarget,
                            io_errl->eid());

#ifdef CONFIG_RECALL_DECONFIG_ON_RECONFIG
                //Always force a gard record on deconfig.  If already
                //garded, won't update/harm anything
                if(!errl)
                {
                    errl = HWAS::theDeconfigGard()
                      .platCreateGardRecord(i_pTarget,
                                            io_errl->eid(),
                                            GARD_Reconfig);
                }
#endif

                break;
            }
            case (DELAYED_DECONFIG):
            {
                // do nothing -- the deconfig information was already
                // put on a queue and will be processed separately,
                // when the time is right.
                break;
            }
        } // switch i_deconfigState

        // check to see if this target is the master processor
        //  and if it's being deconfigured.
        //  NOTE: will be non-functional early in IPL before discovery complete.
        TARGETING::Target *l_masterProc;
        TARGETING::targetService().masterProcChipTargetHandle(l_masterProc);
        if ( (i_pTarget == l_masterProc) &&
             (NO_DECONFIG != i_deconfigState) )
        {
            const TARGETING::HwasState hwasState =
                    l_masterProc->getAttr<TARGETING::ATTR_HWAS_STATE>();
            if (!hwasState.functional)
            {
                HWAS_ERR("master proc deconfigured - Shutdown due to plid 0x%X",
                        io_errl->plid());
                INITSERVICE::doShutdown(io_errl->plid(), true);
            }
        }
    } // PLD

    return errl;
}

//******************************************************************************
// platHandleAddBusCallout
//******************************************************************************
errlHndl_t platHandleAddBusCallout( HWAS::busCallout_t &io_busCallout,
                                    errlHndl_t &io_errl)
{
    // WARNING:
    // this hostboot code should not change io_errl, unless the caller of the
    //  processCallouts() function also changes, as today it (errlentry.C) calls
    //  from the errlEntry object

    errlHndl_t errl = NULL;

    // hostboot does not handle or do any action for bus callouts
    return errl;
}

//******************************************************************************
// platHandleI2cDeviceCallout
//******************************************************************************
errlHndl_t platHandleI2cDeviceCallout(
        TARGETING::Target *i_i2cMaster,
        uint8_t i_engine,
        uint8_t i_port,
        uint8_t i_address,
        callOutPriority i_priority,
        errlHndl_t &io_errl)
{
    errlHndl_t errl = nullptr;

    // hostboot handling is done in ERRORLOG::addI2cDeviceCallout function
    return errl;
}

//******************************************************************************
// platHandleClockCallout
//******************************************************************************
errlHndl_t platHandleClockCallout(
        TARGETING::Target *i_pTarget,
        clockTypeEnum i_clockType,
        callOutPriority i_priority,
        errlHndl_t &io_errl,
        DeconfigEnum i_deconfigState,
        GARD_ErrorType i_gardErrorType)
{
    // WARNING:
    // this hostboot code should not change io_errl, unless the caller of the
    // processCallouts() function also changes, as today it (errlentry.C) calls
    // from the errlEntry object

    errlHndl_t pError = NULL;

    if ((io_errl->sev()) == (ERRORLOG::ERRL_SEV_INFORMATIONAL))
    {
        HWAS_INF("Error log is informational - skipping clock callouts");
    }
    else
    {
#ifdef CONFIG_BMC_IPMI

        // If BMC is present and IPMI is configured system has a simple clock
        // topology, so need to update the BMC fault sensor for the clock if
        // there is a deconfig since Hostboot is the only party able to handle
        // clock fails.
        // For now, all clock sensors reside on the node target
        if(i_deconfigState == HWAS::DECONFIG)
        {
            TARGETING::TargetHandleList parentList;

            (void)getParentAffinityTargets (
                parentList,
                i_pTarget, TARGETING::CLASS_ENC, TARGETING::TYPE_NODE,
                false);

            assert(parentList.size() == 1, "Bug! Query returned multiple or no "
                "(actual = %d) parents",
                parentList.size());

            TARGETING::TargetHandle_t pTarget = parentList[0];

            // Get associated target
            TARGETING::ENTITY_ID associatedType = TARGETING::ENTITY_ID_NA;
            switch(i_clockType)
            {
                case TODCLK_TYPE:
                    associatedType = TARGETING::ENTITY_ID_TOD_CLOCK;
                    break;
                case MEMCLK_TYPE:
                case OSCREFCLK_TYPE:
                    associatedType = TARGETING::ENTITY_ID_REF_CLOCK;
                    break;
                case OSCPCICLK_TYPE:
                    associatedType = TARGETING::ENTITY_ID_PCI_CLOCK;
                    break;
                default:
                    assert(0,"Bug! Caller supplied illegal clock type.  "
                        "i_clockType = 0x%X",
                        i_clockType);
            }

            SENSOR::FaultSensor faultSensor(pTarget,associatedType);

            pError = faultSensor.setStatus(
                SENSOR::FaultSensor::FAULT_STATE_ASSERTED);
            if(pError)
            {
                HWAS_ERR("Failed setting fault sensor status for clock type "
                    "0x%X and HUID 0x%X",
                    i_clockType, TARGETING::get_huid(pTarget));
                pError->collectTrace(HWAS_COMP_NAME, 512);
                errlCommit(pError, HWAS_COMP_ID);
            }
        }

#endif

#ifdef CONFIG_CLOCK_DECONFIGS_FATAL

        // If clock deconfigs are considered fatal, and deconfig requested, then
        // call doShutdown
        if(i_deconfigState == HWAS::DECONFIG)
        {
            HWAS_INF(
                "Clock deconfiguration considered fatal, requesting "
                "shutdown.  See PLID = 0x%X for details.",
                io_errl->plid());
            INITSERVICE::doShutdown(io_errl->plid(), true);
        }

#endif

    }

    return pError;
}

//******************************************************************************
// platHandleClockCallout
//******************************************************************************
errlHndl_t platHandlePartCallout(
        TARGETING::Target *i_pTarget,
        partTypeEnum i_partType,
        callOutPriority i_priority,
        errlHndl_t &io_errl,
        DeconfigEnum i_deconfigState,
        GARD_ErrorType i_gardErrorType)
{
    // WARNING:
    // this hostboot code should not change io_errl, unless the caller of the
    // processCallouts() function also changes, as today it (errlentry.C) calls
    // from the errlEntry object

    errlHndl_t errl = NULL;

    // Hostboot does not handle or do any action for part callouts
    return errl;
}


} // namespace HWAS
OpenPOWER on IntegriCloud