summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/edi_ei_initialization/edi_ei_initialization.C
blob: 20db46f4fa89534dc7d02c669af36198c131292f (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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/edi_ei_initialization/edi_ei_initialization.C $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* 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 otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/**
 *  @file edi_ei_initialization.C
 *
 *  Support file for IStep: edi_ei_initialization
 *   EDI, EI Initialization
 *
 *  *****************************************************************
 *  THIS FILE WAS GENERATED ON 2012-04-11:1606
 *  *****************************************************************
 *
 *  HWP_IGNORE_VERSION_CHECK
 *
 */

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

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

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

#include    <initservice/isteps_trace.H>

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

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

//  fapi support
#include    <fapi.H>
#include    <fapiPlatHwpInvoker.H>

#include    "edi_ei_initialization.H"
#include    <pbusLinkSvc.H>

//  Uncomment these files as they become available:
#include    "io_restore_erepair.H"
// #include    "fabric_io_dccal/fabric_io_dccal.H"
// #include    "fabric_erepair/fabric_erepair.H"
#include    "fabric_io_run_training/fabric_io_run_training.H"
#include    "io_pre_trainadv.H"
#include    "io_post_trainadv.H"
// #include    "host_startprd_pbus/host_startprd_pbus.H"
// #include    "host_attnlisten_proc/host_attnlisten_proc.H"
#include    "proc_fab_iovalid/proc_fab_iovalid.H"
#include    <diag/prdf/prdfMain.H>
#include    "fabric_io_dccal/fabric_io_dccal.H"

// eRepair Restore
#include <erepairAccessorHwpFuncs.H>

namespace   EDI_EI_INITIALIZATION
{


using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   ERRORLOG;
using   namespace   TARGETING;
using   namespace   fapi;
using   namespace   HWAS;


//
//  Wrapper function to call fabric_erepair
//
void*    call_fabric_erepair( void    *io_pArgs )
{
    ISTEP_ERROR::IStepError l_StepError;
    errlHndl_t l_errl = NULL;
    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_fabric_erepair entry" );

    std::vector<uint8_t> l_endp1_txFaillanes;
    std::vector<uint8_t> l_endp1_rxFaillanes;
    std::vector<uint8_t> l_endp2_txFaillanes;
    std::vector<uint8_t> l_endp2_rxFaillanes;

    TargetPairs_t l_PbusConnections;
    const uint32_t MaxBusSet = 2;
    TYPE busSet[MaxBusSet] = { TYPE_ABUS, TYPE_XBUS };
    uint32_t l_count = 0;
    fapi::TargetType l_tgtType = fapi::TARGET_TYPE_NONE;

    for (uint32_t i = 0; l_StepError.isNull() && (i < MaxBusSet); i++)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                            l_PbusConnections, busSet[i] );
        if ( l_errl )
        {
            // Create IStep error log and cross reference error that occurred
            l_StepError.addErrorDetails( l_errl );

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

        for (TargetPairs_t::const_iterator l_itr = l_PbusConnections.begin();
             (l_StepError.isNull()) && (l_itr != l_PbusConnections.end());
             ++l_itr)
        {
            const fapi::Target l_fapi_endp1_target(
                   (i ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->first)));
            const fapi::Target l_fapi_endp2_target(
                   (i ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->second)));

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "===== " );

            // Get the repair lanes from the VPD
            fapi::ReturnCode l_rc;
            l_endp1_txFaillanes.clear();
            l_endp1_rxFaillanes.clear();
            l_endp2_txFaillanes.clear();
            l_endp2_rxFaillanes.clear();
            l_rc = erepairGetRestoreLanes(l_fapi_endp1_target,
                                          l_endp1_txFaillanes,
                                          l_endp1_rxFaillanes,
                                          l_fapi_endp2_target,
                                          l_endp2_txFaillanes,
                                          l_endp2_rxFaillanes);

            if(l_rc)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "Unable to"
                          " retrieve fabric eRepair data from the VPD");

                // convert the FAPI return code to an err handle
                l_errl = fapiRcToErrl(l_rc);

                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).addToLog( l_errl );
                ErrlUserDetailsTarget(l_itr->second).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);

                break;
            }

            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                   "===== Call io_restore_erepair HWP"
                   "%cbus connection ", (i ? 'X' : 'A') );

            if(l_endp1_txFaillanes.size() || l_endp1_rxFaillanes.size())
            {
                // call the io_restore_erepair HWP to restore eRepair
                // lanes of endp1

                FAPI_INVOKE_HWP(l_errl,
                                io_restore_erepair,
                                l_fapi_endp1_target,
                                l_endp1_txFaillanes,
                                l_endp1_rxFaillanes);
            }

            if(l_errl)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "ERROR 0x%.8X :  io_restore_erepair HWP"
                        "%cbus connection ",
                        l_errl->reasonCode(), (i ? 'X' : 'A') );

                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).addToLog( l_errl );
                ErrlUserDetailsTarget(l_itr->second).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);
                break;
            }

            l_tgtType = l_fapi_endp1_target.getType();
            for(l_count = 0; l_count < l_endp1_txFaillanes.size(); l_count++)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"Successfully"
                          " restored Tx lane %d, of %s, of endpoint %s",
                          l_endp1_txFaillanes[l_count],
                          l_tgtType == TARGET_TYPE_XBUS_ENDPOINT ? "X-Bus" :
                          "A-Bus", l_fapi_endp1_target.toEcmdString());
            }

            for(l_count = 0; l_count < l_endp1_rxFaillanes.size(); l_count++)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"Successfully"
                          " restored Rx lane %d, of %s, of endpoint %s",
                          l_endp1_rxFaillanes[l_count],
                          l_tgtType == TARGET_TYPE_XBUS_ENDPOINT ? "X-Bus" :
                          "A-Bus", l_fapi_endp1_target.toEcmdString());
            }

            if(l_endp2_txFaillanes.size() || l_endp2_rxFaillanes.size())
            {
                // call the io_restore_erepair HWP to restore eRepair
                // lanes of endp2

                FAPI_INVOKE_HWP(l_errl,
                                io_restore_erepair,
                                l_fapi_endp2_target,
                                l_endp2_txFaillanes,
                                l_endp2_rxFaillanes);
            }

            if (l_errl)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                            "ERROR 0x%.8X :  io_restore_erepair HWP"
                            "%cbus connection ",
                            l_errl->reasonCode(), (i ? 'X' : 'A') );

                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).addToLog( l_errl );
                ErrlUserDetailsTarget(l_itr->second).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);
                break;
            }

            l_tgtType = l_fapi_endp2_target.getType();
            for(l_count = 0; l_count < l_endp2_txFaillanes.size(); l_count++)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"Successfully"
                          " restored Tx lane %d, of %s, of endpoint %s",
                          l_endp1_txFaillanes[l_count],
                          l_tgtType == TARGET_TYPE_XBUS_ENDPOINT ? "X-Bus" :
                          "A-Bus", l_fapi_endp2_target.toEcmdString());
            }

            for(l_count = 0; l_count < l_endp2_rxFaillanes.size(); l_count++)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"Successfully"
                          " restored Rx lane %d, of %s, of endpoint %s",
                          l_endp2_rxFaillanes[l_count],
                          l_tgtType == TARGET_TYPE_XBUS_ENDPOINT ? "X-Bus" :
                          "A-Bus", l_fapi_endp2_target.toEcmdString());
            }
        } // end for l_PbusConnections
    } // end for MaxBusSet

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

    return l_StepError.getErrorHandle();
}



//
//  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" );

    TargetPairs_t l_PbusConnections;
    TargetPairs_t::iterator l_itr;
    const uint32_t MaxBusSet = 2;
    TYPE busSet[MaxBusSet] = { TYPE_ABUS, TYPE_XBUS };

    // Note:
    // Due to lab tester board environment, HW procedure writer (Varkey) has
    // requested to send in one target of a time (we used to send in
    // both ends in one call). Even though they don't have to be
    // in order, we should keep the pair concept here in case we need to send
    // in a pair in the future again.
    for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                            l_PbusConnections, busSet[ii] );

        for (l_itr = l_PbusConnections.begin();
             l_itr != l_PbusConnections.end();
             ++l_itr)
        {
            const fapi::Target l_fapi_endp1_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->first)));
            const fapi::Target l_fapi_endp2_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->second)));

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, fabric_io_dccal, l_fapi_endp1_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "%s : %cbus connection fabric_io_dccal. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->first) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).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
            }

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, fabric_io_dccal, l_fapi_endp2_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "%s : %cbus connection fabric_io_dccal. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->second) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->second).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
            }
        }
    }

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

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



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

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

    TargetPairs_t l_PbusConnections;
    TargetPairs_t::iterator l_itr;
    const uint32_t MaxBusSet = 2;
    TYPE busSet[MaxBusSet] = { TYPE_ABUS, TYPE_XBUS };

    // Note:
    // Due to lab tester board environment, HW procedure writer (Varkey) has
    // requested to send in one target of a time (we used to send in
    // both ends in one call). Even though they don't have to be
    // in order, we should keep the pair concept here in case we need to send
    // in a pair in the future again.

    for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                            l_PbusConnections, busSet[ii] );

        for (l_itr = l_PbusConnections.begin();
             l_itr != l_PbusConnections.end();
             ++l_itr)
        {
            const fapi::Target l_fapi_endp1_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->first)));
            const fapi::Target l_fapi_endp2_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->second)));

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, io_pre_trainadv, l_fapi_endp1_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "%s : %cbus connection fabric_pre_trainadv. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->first) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).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
            }

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, io_pre_trainadv, l_fapi_endp2_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "%s : %cbus connection fabric_pre_trainadv. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->second) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->second).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
            }
        }
    }

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

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



//
//  Wrapper function to call fabric_io_run_training
//
void*    call_fabric_io_run_training( void    *io_pArgs )
{
    errlHndl_t  l_errl  =   NULL;

    IStepError  l_StepError;

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

    TargetPairs_t l_PbusConnections;
    const uint32_t MaxBusSet = 2;

    // Note: Run XBUS first to match with Cronus
    TYPE busSet[MaxBusSet] = { TYPE_XBUS, TYPE_ABUS };

    for (uint32_t i = 0; l_StepError.isNull() && (i < MaxBusSet); i++)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                            l_PbusConnections, busSet[i] );

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

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

        for (TargetPairs_t::const_iterator l_itr = l_PbusConnections.begin();
             (l_StepError.isNull()) && (l_itr != l_PbusConnections.end());
             ++l_itr)
        {
            const fapi::Target l_fapi_endp1_target(
                   (i ? TARGET_TYPE_ABUS_ENDPOINT : TARGET_TYPE_XBUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->first)));
            const fapi::Target l_fapi_endp2_target(
                   (i ? TARGET_TYPE_ABUS_ENDPOINT : TARGET_TYPE_XBUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->second)));

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, fabric_io_run_training,
                             l_fapi_endp1_target, l_fapi_endp2_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "%s : %cbus connection io_run_training",
                       (l_errl ? "ERROR" : "SUCCESS"),
                       (i ? 'A' : 'X') );

            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).addToLog( l_errl );
                ErrlUserDetailsTarget(l_itr->second).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 );
            }
        }
    }

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

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


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

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

    TargetPairs_t l_PbusConnections;
    TargetPairs_t::iterator l_itr;
    const uint32_t MaxBusSet = 2;
    TYPE busSet[MaxBusSet] = { TYPE_ABUS, TYPE_XBUS };

    // Note:
    // Due to lab tester board environment, HW procedure writer (Varkey) has
    // requested to send in one target of a time (we used to send in
    // both ends in one call). Even though they don't have to be
    // in order, we should keep the pair concept here in case we need to send
    // in a pair in the future again.

    for (uint32_t ii = 0; (!l_errl) && (ii < MaxBusSet); ii++)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                            l_PbusConnections, busSet[ii] );

        for (l_itr = l_PbusConnections.begin();
             l_itr != l_PbusConnections.end();
             ++l_itr)
        {
            const fapi::Target l_fapi_endp1_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->first)));
            const fapi::Target l_fapi_endp2_target(
                   (ii ? TARGET_TYPE_XBUS_ENDPOINT : TARGET_TYPE_ABUS_ENDPOINT),
                   (const_cast<TARGETING::Target*>(l_itr->second)));

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, io_post_trainadv, l_fapi_endp1_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "%s : %cbus connection fabric_post_trainadv. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->first) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->first).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
            }

            //  call the HWP with each bus connection
            FAPI_INVOKE_HWP( l_errl, io_post_trainadv, l_fapi_endp2_target );

            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                  "%s : %cbus connection fabric_post_trainadv. Target 0x%.8X",
                       (l_errl ? "ERROR" : "SUCCESS"), (ii ? 'X' : 'A'),
                        TARGETING::get_huid(l_itr->second) );
            if ( l_errl )
            {
                // capture the target data in the elog
                ErrlUserDetailsTarget(l_itr->second).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
            }
        }
    }

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

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


//
//  Wrapper function to call host_startprd_pbus
//
void*    call_host_startprd_pbus( void    *io_pArgs )
{
    errlHndl_t  l_errl  =   NULL;

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

    l_errl = PRDF::initialize();

    if (l_errl)
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                "Error returned from call to PRDF::initialize");
    }

    // Perform calculated deconfiguration of procs based on
    // bus endpoint deconfigurations, and perform SMP node
    // balancing
    l_errl = HWAS::theDeconfigGard().deconfigureAssocProc();

    if (l_errl)
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                "Error returned from call to "
                "HWAS::theDeconfigGard().deconfigureAssocProc");
    }

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

    // end task, returning any errorlogs to IStepDisp
    return l_errl;
}



//
//  Wrapper function to call host_attnlisten_proc
//
void*    call_host_attnlisten_proc( void    *io_pArgs )
{
    errlHndl_t  l_errl  =   NULL;

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_attnlisten_proc entry" );

#if 0
    // @@@@@    CUSTOM BLOCK:   @@@@@
    //  figure out what targets we need
    //  customize any other inputs
    //  set up loops to go through all targets (if parallel, spin off a task)

    //  write HUID of target
    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                "target HUID %.8X", TARGETING::get_huid(l));

    // cast OUR type of target to a FAPI type of target.
    const fapi::Target l_fapi_@targetN_target( TARGET_TYPE_MEMBUF_CHIP,
                        (const_cast<TARGETING::Target*>(l_@targetN_target)) );

    //  call the HWP with each fapi::Target
    FAPI_INVOKE_HWP( l_errl, host_attnlisten_proc, _args_...);
    if ( l_errl )
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                  "ERROR : .........." );
        errlCommit( l_errl, HWPF_COMP_ID );
    }
    else
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "SUCCESS : .........." );
    }
    // @@@@@    END CUSTOM BLOCK:   @@@@@
#endif

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_attnlisten_proc exit" );

    // end task, returning any errorlogs to IStepDisp
    return l_errl;
}



//
//  Wrapper function to call proc_fab_iovalid
//
void*    call_proc_fab_iovalid( void    *io_pArgs )
{
    errlHndl_t l_errl = NULL;

    IStepError l_StepError;

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

    // Get all chip/chiplet targets
    TARGETING::TargetHandleList l_cpuTargetList;
    getAllChips(l_cpuTargetList, TYPE_PROC);

    TargetPairs_t l_abusConnections;
    TargetPairs_t l_xbusConnections;
    l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                 l_abusConnections, TYPE_ABUS, false );
    if (!l_errl)
    {
        l_errl = PbusLinkSvc::getTheInstance().getPbusConnections(
                                 l_xbusConnections, TYPE_XBUS, false );
    }

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

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

    std::vector<proc_fab_iovalid_proc_chip> l_smp;

    for (TargetHandleList::const_iterator l_cpu_iter = l_cpuTargetList.begin();
         l_StepError.isNull() && (l_cpu_iter != l_cpuTargetList.end());
         ++l_cpu_iter)
    {
        proc_fab_iovalid_proc_chip l_procEntry;

        TARGETING::TargetHandle_t l_pTarget = *l_cpu_iter;
        fapi::Target l_fapiproc_target( TARGET_TYPE_PROC_CHIP, l_pTarget);

        l_procEntry.this_chip = l_fapiproc_target;
        l_procEntry.a0 = false;
        l_procEntry.a1 = false;
        l_procEntry.a2 = false;
        l_procEntry.x0 = false;
        l_procEntry.x1 = false;
        l_procEntry.x2 = false;
        l_procEntry.x3 = false;

        TARGETING::TargetHandleList l_abuses;
        getChildChiplets( l_abuses, l_pTarget, TYPE_ABUS );

        for (TargetHandleList::const_iterator l_abus_iter = l_abuses.begin();
            l_abus_iter != l_abuses.end();
            ++l_abus_iter)
        {
            TARGETING::TargetHandle_t l_target = *l_abus_iter;
            uint8_t l_srcID = l_target->getAttr<ATTR_CHIP_UNIT>();
            TargetPairs_t::iterator l_itr = l_abusConnections.find(l_target);
            if ( l_itr == l_abusConnections.end() )
            {
                continue;
            }
            switch (l_srcID)
            {
                case 0: l_procEntry.a0 = true; break;
                case 1: l_procEntry.a1 = true; break;
                case 2: l_procEntry.a2 = true; break;
               default: break;
            }
        }

        TARGETING::TargetHandleList l_xbuses;
        getChildChiplets( l_xbuses, l_pTarget, TYPE_XBUS );

        for (TargetHandleList::const_iterator l_xbus_iter = l_xbuses.begin();
            l_xbus_iter != l_xbuses.end();
            ++l_xbus_iter)
        {
            TARGETING::TargetHandle_t l_target = *l_xbus_iter;
            uint8_t l_srcID = l_target->getAttr<ATTR_CHIP_UNIT>();
            TargetPairs_t::iterator l_itr = l_xbusConnections.find(l_target);
            if ( l_itr == l_xbusConnections.end() )
            {
                continue;
            }
            switch (l_srcID)
            {
                case 0: l_procEntry.x0 = true; break;
                case 1: l_procEntry.x1 = true; break;
                case 2: l_procEntry.x2 = true; break;
                case 3: l_procEntry.x3 = true; break;
               default: break;
            }
        }

        l_smp.push_back(l_procEntry);
    }

    if (!l_errl)
    {
        FAPI_INVOKE_HWP( l_errl, proc_fab_iovalid, l_smp, true );

        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                "%s : proc_fab_iovalid HWP.",
                (l_errl ? "ERROR" : "SUCCESS"));
    }

    if (l_errl)
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                "ERROR : call_proc_fab_iovalid encountered an error");

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

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

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

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

//
//  function to unfence inter-enclosure abus links
//
errlHndl_t  smp_unfencing_inter_enclosure_abus_links()
{
    errlHndl_t l_errl = NULL;

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

    // Get all chip/chiplet targets
    TARGETING::TargetHandleList l_cpuTargetList;
    getAllChips(l_cpuTargetList, TYPE_PROC);

    std::vector<proc_fab_iovalid_proc_chip> l_smp;

    for (TargetHandleList::const_iterator l_cpu_iter = l_cpuTargetList.begin();
         l_cpu_iter != l_cpuTargetList.end();
         ++l_cpu_iter)
    {
        proc_fab_iovalid_proc_chip l_procEntry;

        TARGETING::TargetHandle_t l_pTarget = *l_cpu_iter;
        fapi::Target l_fapiproc_target(TARGET_TYPE_PROC_CHIP, l_pTarget);

        l_procEntry.this_chip = l_fapiproc_target;
        l_procEntry.a0 = false;
        l_procEntry.a1 = false;
        l_procEntry.a2 = false;
        l_procEntry.x0 = false;
        l_procEntry.x1 = false;
        l_procEntry.x2 = false;
        l_procEntry.x3 = false;

        TARGETING::TargetHandleList l_abuses;
        getChildChiplets( l_abuses, l_pTarget, TYPE_ABUS );

        for (TargetHandleList::const_iterator l_abus_iter = l_abuses.begin();
            l_abus_iter != l_abuses.end();
            ++l_abus_iter)
        {
            TARGETING::TargetHandle_t l_pAbusTarget = *l_abus_iter;
            ATTR_CHIP_UNIT_type l_srcID;
            ATTR_IS_INTER_ENCLOSURE_BUS_type l_flag;
            l_srcID = l_pAbusTarget->getAttr<ATTR_CHIP_UNIT>();
            l_flag = l_pAbusTarget->getAttr<ATTR_IS_INTER_ENCLOSURE_BUS>();
            switch (l_srcID)
            {
                case 0: l_procEntry.a0 = l_flag ? true : false; break;
                case 1: l_procEntry.a1 = l_flag ? true : false; break;
                case 2: l_procEntry.a2 = l_flag ? true : false; break;
               default: break;
            }
        }

        l_smp.push_back(l_procEntry);
    }

    FAPI_INVOKE_HWP( l_errl, proc_fab_iovalid, l_smp, true );

    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                "%s : proc_fab_iovalid HWP.",
                (l_errl ? "ERROR" : "SUCCESS"));

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

    return l_errl;
}

};   // end namespace
OpenPOWER on IntegriCloud