summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep09/call_fabric_io_dccal.C
blob: 45c32fc6df8c415adf3f24631b654c26d674fcdc (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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep09/call_fabric_io_dccal.C $               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2016                        */
/* [+] 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 call_fabric_io_dccal.C
 *
 *  Support file for IStep: edi_ei_initialization
 *   EDI, EI Initialization
 *
 *  HWP_IGNORE_VERSION_CHECK
 *
 */

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

#include    <trace/interface.H>
#include    <initservice/taskargs.H>
#include    <errl/errlentry.H>

#include    <isteps/hwpisteperror.H>
#include    <errl/errludtarget.H>

#include    <initservice/isteps_trace.H>

#include    <hwas/common/deconfigGard.H>
#include    <hwas/common/hwasCommon.H>

#include    <sbe/sbeif.H>

//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>
#include    <targeting/common/trace.H>

#include  <pbusLinkSvc.H>
#include  <fapi2/target.H>
#include  <fapi2/plat_hwp_invoker.H>

// HWP
#include    <p9_io_xbus_dccal.H>

namespace   ISTEP_09
{
using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   ERRORLOG;
using   namespace   TARGETING;

//
//  Wrapper function to call fabric_io_dccal
//
void*    call_fabric_io_dccal( void    *io_pArgs )
{
    errlHndl_t  l_errl = NULL;
    IStepError  l_StepError;

    // We are not running this analog procedure in VPO
    if (TARGETING::is_vpo())
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "Skip call_fabric_io_dccal in VPO!");
        return l_StepError.getErrorHandle();
    }

    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_fabric_io_dccal entry" );

    EDI_EI_INITIALIZATION::TargetPairs_t l_PbusConnections;
    const uint32_t MaxBusSet = 1;
    TYPE busSet[MaxBusSet] = { TYPE_XBUS }; // TODO RTC:152304 - add TYPE_OBUS

    for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++)
    {
        l_errl = EDI_EI_INITIALIZATION::PbusLinkSvc::getTheInstance().
                    getPbusConnections(l_PbusConnections, busSet[ii]);
        if (l_errl)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                "ERROR 0x%.8X : getPbusConnections TYPE_%cBUS returns error",
                l_errl->reasonCode(), (ii ? 'X':'O') );

            // Create IStep error log and cross reference to error that occurred
            l_StepError.addErrorDetails( l_errl );

            // Commit the error log
            // Log should be deleted and set to NULL in errlCommit.
            errlCommit(l_errl, HWPF_COMP_ID);

            // Don't continue with a potential bad connection set
            break;
        }

        //This HWP is broken into substeps, we want to deconfigure
        //bad targets if one of the substeps fails so check this error
        // between each substep.
        bool l_subStepError = false;

        for (const auto & l_PbusConnection: l_PbusConnections)
        {
            bool l_firstTargetValid = true;
            bool l_secondTargetValid = true;

            //Set up fapi2 targets for each end of the connections
            const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first;
            const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second;

            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                l_firstPbusFapi2Target(
                (const_cast<TARGETING::Target*>(l_firstPbusTarget)));
            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                l_secondPbusFapi2Target(
                (const_cast<TARGETING::Target*>(l_secondPbusTarget)));

            // group is either 0 or 1
            std::vector<uint8_t> l_groups = {0,1};
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "Running p9_io_xbus_dccal HWP  on "
                        "this %cbus target %.8X on all groups",
                        (ii ? 'X' : 'O'),
                        TARGETING::get_huid(l_firstPbusTarget) );

            FAPI_INVOKE_HWP( l_errl,
                           p9_io_xbus_dccal,
                           XbusDccalMode::TxZcalRunBus,
                           l_firstPbusFapi2Target,
                           l_groups[0] );

            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl);

                // Create IStep error log and cross ref error that occurred
                l_StepError.addErrorDetails( l_errl );

                // Commit Error
                errlCommit( l_errl, HWPF_COMP_ID );
                l_errl = NULL;

                //Note that the first target is invalid
                l_firstTargetValid = false;
                //Note that this substep had an error
                l_subStepError = true;

            }

            if(l_firstTargetValid)
            {
                for(auto l_group : l_groups)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                p9_io_xbus_dccal,
                                XbusDccalMode::TxZcalSetGrp,
                                     l_firstPbusFapi2Target,
                                l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        l_errl = NULL;
                        //Note that this target is invalid
                        l_firstTargetValid = false;
                        //Note that this substep had an error
                        l_subStepError = true;
                        //if any of the groups have an error just break out
                        break;
                    }
                }
            }

           TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
           "Running p9_io_xbus_dccal HWP on "
           "this %cbus target %.8X on all groups",
           (ii ? 'X' : 'O'),
           TARGETING::get_huid(l_secondPbusTarget) );

           FAPI_INVOKE_HWP( l_errl,
                            p9_io_xbus_dccal,
                            XbusDccalMode::TxZcalRunBus,
                            l_secondPbusFapi2Target,
                            l_groups[0] );

            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl);

                // Create IStep error log and cross ref error that occurred
                l_StepError.addErrorDetails( l_errl );

                // Commit Error
                errlCommit( l_errl, HWPF_COMP_ID );
                l_errl = NULL;
                // Note that the second target is invalid
                l_secondTargetValid = false;
                // Note that an error was detected during this substep
                l_subStepError = true;

            }

            if(l_secondTargetValid)
            {
                for(auto l_group : l_groups)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                    p9_io_xbus_dccal,
                                    XbusDccalMode::TxZcalSetGrp,
                                    l_secondPbusFapi2Target,
                                    l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );

                        //set l_errl to null for future use
                        l_errl = NULL;

                        //one of the channels is bad on this target, its not valid
                        l_secondTargetValid = false;

                        //if any errors were found on this substep, we will skip the remainder
                        l_subStepError = true;

                        //if any of the groups have an error just break out
                        break;
                    }
                }
            }
        }

        if(l_subStepError)
        {
            //Try the next connection set
            continue;
        }

        for (const auto & l_PbusConnection: l_PbusConnections)
        {
            //Initially assume both targets are valid
            uint8_t l_firstTargetValid = true;
            uint8_t l_secondTargetValid = true;

            //Set up fapi2 targets for each end of the connections
            const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first;
            const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second;

            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                l_firstPbusFapi2Target(
                (const_cast<TARGETING::Target*>(l_firstPbusTarget)));
            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
                l_secondPbusFapi2Target(
                (const_cast<TARGETING::Target*>(l_secondPbusTarget)));

            // group is either 0 or 1
            std::vector<uint8_t> l_groups = {0,1};

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                    "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                    "this %cbus target %.8X on all groups",
                    (ii ? 'X' : 'O'),
                    XbusDccalMode::RxDccalStartGrp,
                    TARGETING::get_huid(l_firstPbusTarget) );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                        "this %cbus target %.8X on all groups",
                        (ii ? 'X' : 'O'),
                        XbusDccalMode::RxDccalStartGrp,
                        TARGETING::get_huid(l_secondPbusTarget) );

            for(auto l_group : l_groups)
            {
                if(l_firstTargetValid)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                    p9_io_xbus_dccal,
                                    XbusDccalMode::RxDccalStartGrp,
                                    l_firstPbusFapi2Target,
                                    l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_firstPbusTarget).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        l_errl = NULL;

                        //Note the error on this substep
                        l_subStepError = true;
                        //Note that first target is invalid for next group
                        l_firstTargetValid = false;
                    }
                }

                if(l_secondTargetValid)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                    p9_io_xbus_dccal,
                                    XbusDccalMode::RxDccalStartGrp,
                                    l_secondPbusFapi2Target,
                                    l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_secondPbusTarget).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        l_errl = NULL;

                        //Note the error on this substep
                        l_subStepError = true;
                        //Note that second target is invalid for next group
                        l_secondTargetValid = false;
                    }
                }
            }
        }

        if(l_subStepError)
        {
            //Try the next connection set
            continue;
        }

        for (const auto & l_PbusConnection: l_PbusConnections)
        {
            //Initially assume both targets are valid
            uint8_t l_firstTargetValid = true;
            uint8_t l_secondTargetValid = true;

            //Set up fapi2 targets for each end of the connections
            const TARGETING::Target* l_firstPbusTarget = l_PbusConnection.first;
            const TARGETING::Target* l_secondPbusTarget = l_PbusConnection.second;

            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
            l_firstPbusFapi2Target(
            (const_cast<TARGETING::Target*>(l_firstPbusTarget)));
            const fapi2::Target <fapi2::TARGET_TYPE_XBUS>
            l_secondPbusFapi2Target(
            (const_cast<TARGETING::Target*>(l_secondPbusTarget)));

            // group is either 0 or 1
            std::vector<uint8_t> l_groups = {0,1};
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                        "this %cbus target %.8X on all groups",
                        (ii ? 'X' : 'O'),
                        XbusDccalMode::RxDccalCheckGrp,
                        TARGETING::get_huid(l_firstPbusFapi2Target) );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "Running p9_io_xbus_dccal HWP with mode = %.8X on "
                        "this %cbus target %.8X on all groups",
                        (ii ? 'X' : 'O'),
                        XbusDccalMode::RxDccalCheckGrp,
                        TARGETING::get_huid(l_secondPbusFapi2Target) );

            for(auto l_group : l_groups)
            {
                if(l_firstTargetValid)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                    p9_io_xbus_dccal,
                                    XbusDccalMode::RxDccalCheckGrp,
                                    l_firstPbusFapi2Target,
                                    l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_firstPbusFapi2Target).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        // We want to continue the training despite the error, so
                        // no break
                        l_errl = NULL;
                        //Note that first target is invalid for next group
                        l_firstTargetValid = false;
                    }
                }

                if(l_secondTargetValid)
                {
                    FAPI_INVOKE_HWP( l_errl,
                                    p9_io_xbus_dccal,
                                    XbusDccalMode::RxDccalCheckGrp,
                                    l_secondPbusFapi2Target,
                                    l_group );

                    if ( l_errl )
                    {
                        // capture the target data in the elog
                        ErrlUserDetailsTarget(l_secondPbusFapi2Target).addToLog(l_errl);

                        // Create IStep error log and cross ref error that occurred
                        l_StepError.addErrorDetails( l_errl );

                        // Commit Error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        // We want to continue the training despite the error, so
                        // no break
                        l_errl = NULL;
                        //Note that second target is invalid for next group
                        l_secondTargetValid = false;
                    }
                }
            }
        }
    } // end of connection set loop

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

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

};
OpenPOWER on IntegriCloud