summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/hwas.C
blob: ca2ed5adf869d3211fcf49447cb83825f0e5ebb7 (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/hwas/hwas.C $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2011
//
//  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 other-
//  wise divested of its trade secrets, irrespective of what has
//  been deposited with the U.S. Copyright Office.
//
//  Origin: 30
//
//  IBM_PROLOG_END

/**
 *  @file hwas.C
 *
 *  HardWare Availability Service functions.
 *  See hwas.H for doxygen documentation tags.
 *
 */


/******************************************************************************/
// Includes
/******************************************************************************/
#include    <stdint.h>

#include    <kernel/console.H>
#include    <trace/interface.H>
#include    <initservice/taskargs.H>
#include    <errl/errlentry.H>
#include    <targeting/targetservice.H>
#include    <targeting/iterators/rangefilter.H>
#include    <targeting/predicates/predicatectm.H>
#include    <fsi/fsiif.H>

#include    <hwas/hwas.H>
#include    <hwas/deconfigGard.H>
#include    <targeting/util.H>

namespace   HWAS
{
trace_desc_t *g_trac_hwas = NULL;
TRAC_INIT(&g_trac_hwas, "HWAS", 2048 );

using   namespace   TARGETING;


void    init_target_states( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );
    TARGETING::HwasState l_hwasState;

    TRACDCOMP( g_trac_hwas, "init_target_states entry: set default HWAS state:" );

    //  loop through all the targets and set HWAS_STATE to a known default
    TARGETING::TargetIterator l_TargetItr = TARGETING::targetService().begin();
    for(    ;
            l_TargetItr != TARGETING::targetService().end();
            ++l_TargetItr
    )
    {
        l_hwasState =   l_TargetItr->getAttr<ATTR_HWAS_STATE>();
        l_hwasState.poweredOn             =   false;
        l_hwasState.present               =   false;
        l_hwasState.functional            =   false;
        l_hwasState.changedSinceLastIPL   =   false;
        l_hwasState.gardLevel             =   0;
        l_TargetItr->setAttr<ATTR_HWAS_STATE>( l_hwasState );
    }



    /**
     * @todo    Enable cpu 0 and centaur 0 for now.
     */
    //  $$$$$   TEMPORARY   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    //  get the master processor, this should be CPU 0
    TARGETING::Target* l_pMasterProcChipTargetHandle = NULL;
    (void)TARGETING::targetService().masterProcChipTargetHandle(
            l_pMasterProcChipTargetHandle);
    if (l_pMasterProcChipTargetHandle == NULL)
    {
        TRACFCOMP( g_trac_hwas, "FAILED to get master processor target");
    }
    else
    {
        //  set master chip to poweredOn, present, functional

        l_hwasState =   l_pMasterProcChipTargetHandle->getAttr<ATTR_HWAS_STATE>();
        l_hwasState.poweredOn             =   true;
        l_hwasState.present               =   true;
        l_hwasState.functional            =   true;
        l_hwasState.changedSinceLastIPL   =   false;
        l_hwasState.gardLevel             =   0;
        l_pMasterProcChipTargetHandle->setAttr<ATTR_HWAS_STATE>( l_hwasState );

        //  get the mcs "chiplets" associated with this cpu
        TARGETING::PredicateCTM l_mcsChipFilter(CLASS_UNIT, TYPE_MCS);
        TARGETING::TargetHandleList l_mcsTargetList;
        TARGETING::targetService().getAssociated(
                l_mcsTargetList,
                l_pMasterProcChipTargetHandle,
                TARGETING::TargetService::CHILD,
                TARGETING::TargetService::IMMEDIATE,
                &l_mcsChipFilter );
        //  debug...
        TRACDCOMP( g_trac_hwas,
                "%d MCSs for master processor",
                l_mcsTargetList.size() );

        for ( uint8_t i=0; i < l_mcsTargetList.size(); i++ )
        {
            //  set each MCS to poweredON, present, functional
            l_hwasState =   l_mcsTargetList[i]->getAttr<ATTR_HWAS_STATE>();
            l_hwasState.poweredOn             =   true;
            l_hwasState.present               =   true;
            l_hwasState.functional            =   true;
            l_hwasState.changedSinceLastIPL   =   false;
            l_hwasState.gardLevel             =   0;
            l_mcsTargetList[i]->setAttr<ATTR_HWAS_STATE>( l_hwasState );


            //  If ATTR_CHIP_UNIT==0 or 1, find the centaur underneath it
            //  and set it to good as well.
            if (    ( l_mcsTargetList[i]->getAttr<ATTR_CHIP_UNIT>() == 0 )
                 || ( l_mcsTargetList[i]->getAttr<ATTR_CHIP_UNIT>() == 1 )
                )
            {
                TARGETING::PredicateCTM l_membufChips(CLASS_CHIP, TYPE_MEMBUF);
                TARGETING::TargetHandleList l_memTargetList;
                TARGETING::targetService().getAssociated(l_memTargetList,
                        l_mcsTargetList[i],
                        TARGETING::TargetService::CHILD_BY_AFFINITY,
                        TARGETING::TargetService::ALL,
                        &l_membufChips);
                //  debug...
                TRACDCOMP( g_trac_hwas,
                        "%d MEMBUFSs associated with MCS %d",
                        l_memTargetList.size(),
                        l_mcsTargetList[i]->getAttr<ATTR_CHIP_UNIT>() );

                for ( uint8_t ii=0; ii < l_memTargetList.size(); ii++ )
                {
                    // set the Centaur(s) connected to MCS0 to poweredOn,
                    //      present, functional
                    l_hwasState =   l_memTargetList[ii]->getAttr<ATTR_HWAS_STATE>();
                    l_hwasState.poweredOn             =   true;
                    l_hwasState.present               =   true;
                    l_hwasState.functional            =   true;
                    l_hwasState.changedSinceLastIPL   =   false;
                    l_hwasState.gardLevel             =   0;
                    l_memTargetList[ii]->setAttr<ATTR_HWAS_STATE>( l_hwasState );

                    // look for the dimms on each centaur
                    TARGETING::PredicateCTM l_dimms(CLASS_LOGICAL_CARD, TYPE_DIMM);
                    TARGETING::TargetHandleList l_dimmTargetList;
                    TARGETING::targetService().getAssociated(l_dimmTargetList,
                            l_memTargetList[ii],
                            TARGETING::TargetService::CHILD_BY_AFFINITY,
                            TARGETING::TargetService::ALL, &l_dimms);
                    //  debug...
                    TRACDCOMP( g_trac_hwas,
                            "    %d DIMMs associated with MEM %d",
                            l_dimmTargetList.size(), ii);

                    // Return fapi::Targets to the caller
                    for (uint32_t iii = 0; iii < l_dimmTargetList.size(); iii++)
                    {
                        // set the dimm(s) connected to MCS0 to poweredOn,
                        //      present, functional
                        l_hwasState =   l_dimmTargetList[iii]->getAttr<ATTR_HWAS_STATE>();
                        l_hwasState.poweredOn             =   true;
                        l_hwasState.present               =   true;
                        l_hwasState.functional            =   true;
                        l_hwasState.changedSinceLastIPL   =   false;
                        l_hwasState.gardLevel             =   0;
                        l_dimmTargetList[iii]->setAttr<ATTR_HWAS_STATE>( l_hwasState );
                    }   // end for iii dimTargets
                }   // end for ii memTargets
            }   // end if only 0 and 1
        }   // end for i mcsTargets
    }   // end else
    //  $$$$$   TEMPORARY   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}


void    init_fsi( void *io_pArgs )
{
    errlHndl_t  l_errl      =   NULL;
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "init_fsi entry" );

    l_errl  =   FSI::initializeHardware( );
    if ( l_errl )
    {
        TRACFCOMP( g_trac_hwas, "ERROR: failed to init FSI hardware" );
        pTaskArgs->postErrorLog( l_errl );
    }

    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_fsi_info( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_fsi_info entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_dd_presence( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_dd_presence entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_pr_keyword_data( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_pr_keyword_data" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_partial_bad( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_partial_bad entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_gard( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_gard entry" );

    errlHndl_t l_errl = theDeconfigGard().clearGardRecordsForReplacedTargets();

    if (l_errl)
    {
        TRACFCOMP(g_trac_hwas, "ERROR: apply_gard failed to clear GARD Records for replaced Targets");
        pTaskArgs->postErrorLog(l_errl);
    }
    else
    {
        l_errl = theDeconfigGard().deconfigureTargetsFromGardRecordsForIpl();

        if (l_errl)
        {
            TRACFCOMP(g_trac_hwas, "ERROR: apply_gard failed to deconfigure Targets from GARD Records for IPL");
            pTaskArgs->postErrorLog(l_errl);
        }
        else
        {
            TRACFCOMP(g_trac_hwas, "apply_gard completed successfully");
        }
    }

    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}


};   // end namespace

OpenPOWER on IntegriCloud