summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep16/call_host_ipl_complete.C
blob: 3993fda8b0b556cf522366205a83460c6a6e3df3 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep16/call_host_ipl_complete.C $             */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,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                                                     */

#include    <errl/errlentry.H>
#include    <initservice/isteps_trace.H>
#include    <isteps/hwpisteperror.H>
#include    <errl/errludtarget.H>
#include    <errl/errlmanager.H>

#include    <initservice/initserviceif.H>
#include    <initservice/istepdispatcherif.H>

//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>
#include    <fapi2/target.H>
#include    <fapi2/plat_hwp_invoker.H>

#include   <p9_switch_rec_attn.H>

#include    <targeting/attrrp.H>
#include    <sys/internode.h>
#include    <runtime/runtime.H>
#include    <util/utiltce.H>

#include    <util/utilsemipersist.H>
#include    <hwas/common/deconfigGard.H>
#ifdef CONFIG_BMC_IPMI
#include    <ipmi/ipmisensor.H>
#endif
using   namespace   ERRORLOG;
using   namespace   TARGETING;
using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   fapi2;


namespace ISTEP_16
{
void* call_host_ipl_complete (void *io_pArgs)
{
    errlHndl_t  l_err  =   NULL;

    IStepError  l_stepError;
    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_ipl_complete entry" );
    do
    {
        // only run on non-FSP systems
        if( !INITSERVICE::spBaseServicesEnabled() )
        {
            //No more reconfig loops are supported from this point
            //forward.  Clean up the semi persistent area
            //   1) clear magic number (so next boot thinks it is cold)
            //      a) DON'T clear mfg term setting (so read-modify)
            //   2) clear any reconfig specific gard records
            Util::semiPersistData_t l_semiData;  //inits to 0s
            Util::readSemiPersistData(l_semiData);
            l_semiData.magic = 0x0;
            Util::writeSemiPersistData(l_semiData);

            l_err = HWAS::clearGardByType(HWAS::GARD_Reconfig);
            if (l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "ERROR 0x%.8X: clearGardByType( )",
                          l_err->reasonCode() );
                // Create IStep error log and cross ref error that occurred
                l_stepError.addErrorDetails( l_err );
                errlCommit( l_err, ISTEP_COMP_ID );
            }
        }

#ifdef CONFIG_BMC_IPMI
        // Alert BMC to clear HB volatile memory
        SENSOR::HbVolatileSensor l_hbVolatileCtl;
        l_err = l_hbVolatileCtl.setHbVolatile(
                            SENSOR::HbVolatileSensor::ENABLE_VOLATILE );
        if(l_err)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                "Failure in notifying BMC to clear hostboot volatile section,"
                " RC=%X", ERRL_GETRC_SAFE(l_err) );

            // This error could come from OpenPower system without
            // updated OpenBMC code so just delete the error
            delete l_err;
            l_err = nullptr;
        }
#endif

        if (TCE::utilUseTcesForDmas())
        {
            l_err = TCE::utilSetupPayloadTces();

            if( l_err )
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                           ERR_MRK"TCE::utilSetupPayloadTces failed");
                // Don't continue with the rest of this istep
                break;
            }
        }

        // Initialize the RUNTIME DATA attributes
        // that HDAT needs to allocate memory for us.
        // -----------------------------------------
        TARGETING::Target * sys = NULL;
        TARGETING::targetService().getTopLevelTarget( sys );
        assert(sys != NULL);

        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"Initialize the runtime "
                "data attributes for HDAT consumption");

        // Set number of pointer pairs for HDAT HB RESERVED MEM
        uint32_t  l_numRsvMemSections = HB_RSV_MEM_NUM_PTRS;
        sys->setAttr<ATTR_HDAT_RSV_MEM_NUM_SECTIONS>(l_numRsvMemSections);

        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                           "number of HB Reserved mem sections = %d",
                           l_numRsvMemSections );

        // Set number of pointer pairs for HDAT HBRT
        uint32_t  l_numHbrtSections = HBRT_NUM_PTRS;
        sys->setAttr<ATTR_HDAT_HBRT_NUM_SECTIONS>(l_numHbrtSections);

        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                           "number of HBRT sections = %d",
                           l_numHbrtSections );

        uint64_t  l_maxSecSize  = VMM_RT_VPD_SIZE;

        // Set max size of a HBRT section for HDAT
        TARGETING::ATTR_HDAT_HBRT_SECTION_SIZE_type l_secSize = {0};
        uint64_t *l_p_secSize =
            reinterpret_cast<uint64_t *>(&l_secSize);

        uint32_t l_attrArraySize =
            sizeof(ATTR_HDAT_HBRT_SECTION_SIZE_type) / sizeof(l_secSize[0]);
        assert(l_numHbrtSections <= l_attrArraySize);

        uint64_t  l_attrSize = AttrRP::maxSize();
        l_maxSecSize = (l_attrSize > l_maxSecSize) ? l_attrSize : l_maxSecSize;

        for (uint32_t  l_sect=0; (l_sect < l_numHbrtSections); l_sect++)
        {
            l_p_secSize[l_sect] = l_maxSecSize;
        }
        sys->setAttr<ATTR_HDAT_HBRT_SECTION_SIZE>(l_secSize);


//@TODO RTC:150266 HWPs for Centuar+Cumulus
// Need cen_switch_rec_attn for mem_chips
#if 0
        if ( INITSERVICE::spBaseServicesEnabled())
        {
            // For FSP based systems, do not route centaur
            // attentions through host after this step.
            // Loop through all the centaurs in the system
            // and run cen_switch_rec_attn
            TARGETING::TargetHandleList l_memTargetList;
            getAllChips(l_memTargetList, TYPE_MEMBUF );

            for ( TargetHandleList::iterator l_iter = l_memTargetList.begin();
                  l_iter != l_memTargetList.end();
                  ++l_iter )
            {
                TARGETING::Target * l_memChip  =   (*l_iter) ;

                //  dump physical path to target
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                         "Running cen_switch_rec_attn HWP on target HUID %.8X",
                         TARGETING::get_huid(l_memChip) );


                const fapi2::Target<TARGET_TYPE_MEMBUF_CHIP> l_fap2_centTarget(
                            const_cast<TARGETING::Target*> (l_memChip));
                FAPI_INVOKE_HWP( l_err,
                                 cen_switch_rec_attn,
                                 l_fap2_centTarget );


                if (l_err)
                {
                    // log error for this centaur and continue

                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                              "ERROR 0x%.8X: cen_switch_rec_attn HWP( )",
                              l_err->reasonCode() );

                    // Add all the details for this centaur
                    ErrlUserDetailsTarget myDetails(l_memChip);

                    // capture the target data in the elog
                    myDetails.addToLog(l_err);

                    // Create IStep error log and cross ref error that occurred
                    l_stepError.addErrorDetails( l_err );

                    // Commit Error
                    errlCommit( l_err, HWPF_COMP_ID );
                }
                else
                {
                    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                               "SUCCESS: cen_switch_rec_attn HWP( )" );
                }
            }   // endfor

        } // end if ( INITSERVICE::spBaseServicesEnabled())

#endif

        TARGETING::TargetHandleList l_procChips;
        //Use targeting code to get a list of all processors
        getAllChips( l_procChips, TARGETING::TYPE_PROC   );

        //Loop through all of the procs and call the HWP on each one
        for (const auto & l_procChip: l_procChips)
        {
            const fapi2::Target<TARGET_TYPE_PROC_CHIP>
                l_fapiProcTarget(l_procChip);

            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
            "Running p9_switch_rec_attn HWP on target HUID %.8X",
            TARGETING::get_huid(l_procChip) );

            //  call p9_switch_rec_attn
            FAPI_INVOKE_HWP(l_err, p9_switch_rec_attn, l_fapiProcTarget);

            if (l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "ERROR 0x%.8X: p9_switch_rec_attn HWP returned error",
                          l_err->reasonCode());

                // capture the target data in the elog
                ErrlUserDetailsTarget(l_procChip).addToLog( l_err );

                //Create IStep error log and cross reference error that occurred
                l_stepError.addErrorDetails( l_err );

                //break to end because if p9_switch_rec_attn fails
                //recoverable/special attentions control didnt make it back
                // to the fsp, this is a fatal error
                break;
            }
            else
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                      "SUCCESS: p9_switch_rec_attn HWP( ) on target HUID %.8X",
                    TARGETING::get_huid(l_procChip) );
            }
        }

        //if an error occurred during for loop, break to error handling
        if( l_err )
        {
            break;
        }

        // Sync attributes to Fsp
        l_err = syncAllAttributesToFsp();

        if( l_err )
        {
            break;
        }

        // Send Sync Point to Fsp
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   INFO_MRK"Send SYNC_POINT_REACHED msg to Fsp" );
        l_err = INITSERVICE::sendSyncPoint();

    } while( 0 );

    if( l_err )
    {
        // collect and log any remaining errors

        // Create IStep error log and cross reference error that occurred
        l_stepError.addErrorDetails( l_err );

        // Commit Error
        errlCommit( l_err, HWPF_COMP_ID );
    }

    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_ipl_complete exit ");

    // end task, returning any errorlogs to IStepDisp
    return l_stepError.getErrorHandle();
}


};
OpenPOWER on IntegriCloud