summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/p9/prdfLaneRepair.C
blob: 6cb4e6535a7280138ac9f2ed53cc3dc7f2056621 (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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/p9/prdfLaneRepair.C $           */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017,2019                        */
/* [+] 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 prdfLaneRepair.C */

#include <prdfLaneRepair.H>

// Framework includes
#include <prdfPluginDef.H>
#include <prdfLaneRepair.H>
#include <prdfPlatServices.H>
#include <iipconst.h>
#include <prdfGlobal.H>
#include <iipSystem.h>
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <UtilHash.H>

#include <prdfLaneRepairExtraSig.H>
#include <hwas/common/hwasCallout.H>

#ifndef __HOSTBOOT_MODULE
#include <hwsvSvrErrl.H>
#endif // not hostboot module


using namespace TARGETING;

namespace PRDF
{
using namespace PlatServices;

namespace LaneRepair
{

TargetHandle_t getTxBusEndPt( TargetHandle_t i_rxTrgt)
{
    TargetHandle_t o_txTrgt = nullptr;

    PRDF_ASSERT(nullptr != i_rxTrgt);

    TYPE busType = getTargetType(i_rxTrgt);
    if ( TYPE_XBUS == busType || TYPE_OBUS == busType )
    {
        o_txTrgt = getConnectedPeerTarget( i_rxTrgt );
    }
    else if (TYPE_DMI == busType)
    {
        // Get connected memory buffer
        o_txTrgt = getConnectedChild( i_rxTrgt, TYPE_MEMBUF, 0 );
    }
    else if (TYPE_MEMBUF == busType)
    {
        // grab connected DMI parent
        o_txTrgt = getConnectedParent( i_rxTrgt, TYPE_DMI );
    }

    PRDF_ASSERT(nullptr != o_txTrgt);
    return o_txTrgt;
}

// Wrapper to check appropriate eRepair MNFG flag
template<TYPE T>
bool isLaneRepairDisabled();

template<>
bool isLaneRepairDisabled<TYPE_OBUS>()
{
    return isFabeRepairDisabled();
}
template<>
bool isLaneRepairDisabled<TYPE_XBUS>()
{
    return isFabeRepairDisabled();
}
template<>
bool isLaneRepairDisabled<TYPE_DMI>()
{
    return isMemeRepairDisabled();
}
template<>
bool isLaneRepairDisabled<TYPE_MEMBUF>()
{
    return isMemeRepairDisabled();
}


template< TYPE T_RX, TYPE T_TX >
int32_t __handleLaneRepairEvent( ExtensibleChip * i_chip,
                                 STEP_CODE_DATA_STRUCT & i_sc,
                                 bool i_spareDeployed )
{
    #define PRDF_FUNC "[LaneRepair::handleLaneRepairEvent] "

    int32_t l_rc = SUCCESS;
    TargetHandle_t rxBusTgt = i_chip->getTrgt();
    TargetHandle_t txBusTgt = nullptr;


    // Make predictive on first occurrence in MFG
    if ( isLaneRepairDisabled<T_RX>() )
    {
        i_sc.service_data->setServiceCall();
    }


    bool thrExceeded;
    // Number of clock groups on this interface. (2 for xbus, 1 for all others)
    uint8_t clkGrps = (T_RX == TYPE_XBUS) ? 2 : 1;
    std::vector<uint8_t> rx_lanes[2];    // Failing lanes on clock group 0/1
    // RX-side, previously failed laned lanes stored in VPD for each clk grp
    std::vector<uint8_t> rx_vpdLanes[2];
    // TX-side, previously failed laned lanes stored in VPD for each clk grp
    std::vector<uint8_t> tx_vpdLanes[2];
    BitStringBuffer l_newLaneMap0to63(64); // FFDC Bitmap of newly failed lanes
    BitStringBuffer l_newLaneMap64to127(64);
    BitStringBuffer l_vpdLaneMap0to63(64); // FFDC Bitmap of VPD failed lanes
    BitStringBuffer l_vpdLaneMap64to127(64);

    do
    {
        // Get the TX target
        txBusTgt = getTxBusEndPt(rxBusTgt);

        // Call io_read_erepair for each group
        for (uint8_t i=0; i<clkGrps; ++i)
        {
            l_rc = readErepair<T_RX>(rxBusTgt, rx_lanes[i], i);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC "readErepair() failed: rxBusTgt=0x%08x",
                          getHuid(rxBusTgt) );
                break;
            }

            // Add newly failed lanes to capture data
            for ( auto lane : rx_lanes[i] )
            {
                lane += i * 16; // Adjust for multiple clock groups (XBUS only).
                if (lane < 64)
                    l_newLaneMap0to63.setBit(lane);
                else if (lane < 128)
                    l_newLaneMap64to127.setBit(lane - 64);
                else
                {
                    PRDF_ERR( PRDF_FUNC "Invalid lane number %d: "
                              "rxBusTgt=0x%08x", lane, getHuid(rxBusTgt) );
                }
            }
        }

        if ( SUCCESS != l_rc) break;

        // Add failed lane capture data to errorlog
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                ( Util::hashString("ALL_FAILED_LANES_0TO63") ^
                                  i_chip->getSignatureOffset() ),
                                l_newLaneMap0to63);
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                ( Util::hashString("ALL_FAILED_LANES_64TO127") ^
                                  i_chip->getSignatureOffset() ),
                                l_newLaneMap64to127);

        // Don't read/write VPD in mfg mode if erepair is disabled
        if ( !isLaneRepairDisabled<T_RX>() )
        {
            // Read Failed Lanes from VPD
            for (uint8_t i=0; i<clkGrps; ++i)
            {
                l_rc = getVpdFailedLanes<T_RX>(rxBusTgt, rx_vpdLanes[i],
                                               tx_vpdLanes[i], i);

                if (SUCCESS != l_rc)
                {
                    PRDF_ERR( PRDF_FUNC "getVpdFailedLanes() failed: "
                              "rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                    break;
                }

                // Add VPD lanes to capture data
                for ( auto lane : rx_vpdLanes[i] )
                {
                    lane += i * 16; // Adjust for multiple clock groups (XBUS
                                    // only).
                    if (lane < 64)
                        l_vpdLaneMap0to63.setBit(lane);
                    else if (lane < 128)
                        l_vpdLaneMap64to127.setBit(lane - 64);
                    else
                    {
                        PRDF_ERR( PRDF_FUNC "Invalid VPD lane number %d: "
                                  "rxBusTgt=0x%08x", lane, getHuid(rxBusTgt) );
                    }
                }
            } // end Read Failed Lanes from VPD

            if ( SUCCESS != l_rc) break;

            // Add failed lane capture data to errorlog
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                ( Util::hashString("VPD_FAILED_LANES_0TO63") ^
                                  i_chip->getSignatureOffset() ),
                                l_vpdLaneMap0to63);
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                               ( Util::hashString("VPD_FAILED_LANES_64TO127") ^
                                 i_chip->getSignatureOffset() ),
                               l_vpdLaneMap64to127);

            if (i_spareDeployed)
            {
                for (uint8_t i=0; i<clkGrps; ++i)
                {
                    if (rx_lanes[i].size() == 0)
                        continue;

                    // Call Erepair to update VPD
                    l_rc = setVpdFailedLanes<T_RX, T_TX>(rxBusTgt, txBusTgt,
                                                  rx_lanes[i], thrExceeded, i);

                    if (SUCCESS != l_rc)
                    {
                        PRDF_ERR( PRDF_FUNC "setVpdFailedLanes() failed: "
                                  "rxBusTgt=0x%08x txBusTgt=0x%08x",
                                  getHuid(rxBusTgt), getHuid(txBusTgt) );
                        break;
                    }
                    if( thrExceeded )
                    {
                        i_sc.service_data->SetErrorSig(
                                              PRDFSIG_ERepair_FWThrExceeded );
                        i_sc.service_data->setServiceCall();
                        break;
                    }
                    else
                    {
                        // Update lists of lanes from VPD
                        rx_vpdLanes[i].clear(); tx_vpdLanes[i].clear();
                        l_rc = getVpdFailedLanes<T_RX>( rxBusTgt,
                                                        rx_vpdLanes[i],
                                                        tx_vpdLanes[i], i );

                        if (SUCCESS != l_rc)
                        {
                            PRDF_ERR( PRDF_FUNC
                                      "getVpdFailedLanes() before power down "
                                      "failed: rxBusTgt=0x%08x",
                                      getHuid(rxBusTgt) );
                            break;
                        }

                        // Power down all lanes that have been saved in VPD
                        l_rc = powerDownLanes<T_RX>( rxBusTgt, rx_vpdLanes[i],
                                                     tx_vpdLanes[i], i );
                        if (SUCCESS != l_rc)
                        {
                            PRDF_ERR( PRDF_FUNC "powerDownLanes() failed: "
                                      "rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                            break;
                        }
                    }
                }

                if ( SUCCESS != l_rc) break;

            }
        }
    } while (0);

    // Clear FIRs
    l_rc |= clearIOFirs<T_RX>(rxBusTgt);

    // This return code gets returned by the plugin code back to the rule code.
    // So, we do not want to give a return code that the rule code does not
    // understand. So far, there is no need return a special code, so always
    // return SUCCESS.
    if ( SUCCESS != l_rc )
    {
        PRDF_ERR( PRDF_FUNC "i_chip: 0x%08x busType:%d",
                  i_chip->GetId(), T_RX );

        i_sc.service_data->SetErrorSig(PRDFSIG_ERepair_ERROR);
        i_sc.service_data->SetCallout(LEVEL2_SUPPORT, MRU_MED, NO_GARD);
        i_sc.service_data->SetCallout(SP_CODE, MRU_MED, NO_GARD);
        i_sc.service_data->setServiceCall();
    }

    return SUCCESS;

    #undef PRDF_FUNC
}

template<>
int32_t __handleLaneRepairEvent<TYPE_OBUS, TYPE_OBUS>( ExtensibleChip * i_chip,
                                                  STEP_CODE_DATA_STRUCT & i_sc,
                                                  bool i_spareDeployed )
{
    TargetHandle_t rxBusTgt = i_chip->getTrgt();

    // Make predictive on first occurrence in MFG
    if ( isLaneRepairDisabled<TYPE_OBUS>() )
    {
        i_sc.service_data->setServiceCall();
    }

    // RTC 174485
    // Need HWPs for this. Just callout bus interface for now.
    if ( obusInSmpMode(rxBusTgt) )
    {
        calloutBusInterface( i_chip, i_sc, MRU_LOW );
        i_sc.service_data->setServiceCall();
    }
    else
    {
        PRDF_ERR( "__handleLaneRepairEvent: Lane repair only supported "
          "in SMP mode obus: 0x%08x", getHuid(rxBusTgt) );
        i_sc.service_data->SetCallout( LEVEL2_SUPPORT, MRU_MED, NO_GARD );
        i_sc.service_data->SetCallout( SP_CODE, MRU_MED, NO_GARD );
        i_sc.service_data->setServiceCall();
    }
    return SUCCESS;
}


int32_t handleLaneRepairEvent( ExtensibleChip * i_chip,
                               STEP_CODE_DATA_STRUCT & i_sc,
                               bool i_spareDeployed )
{
    int32_t rc = SUCCESS;
    TYPE trgtType = getTargetType(i_chip->getTrgt());
    switch (trgtType)
    {
      case TYPE_OBUS:
        rc = __handleLaneRepairEvent<TYPE_OBUS,TYPE_OBUS>( i_chip, i_sc,
                                                           i_spareDeployed );
        break;
      case TYPE_XBUS:
        rc = __handleLaneRepairEvent<TYPE_XBUS,TYPE_XBUS>( i_chip, i_sc,
                                                           i_spareDeployed );
        break;
      case TYPE_DMI:
        rc = __handleLaneRepairEvent<TYPE_DMI,TYPE_MEMBUF>( i_chip, i_sc,
                                                            i_spareDeployed );
        break;
      case TYPE_MEMBUF:
        rc = __handleLaneRepairEvent<TYPE_MEMBUF,TYPE_DMI>( i_chip, i_sc,
                                                            i_spareDeployed );
        break;

      default:
        PRDF_ASSERT( false );  // Unsupported type for handleLaneRepairEvent
    }
    return rc;
}


void   obus_smpCallout( TargetHandle_t i_smpTgt, TargetHandle_t i_obusTgt,
                        STEP_CODE_DATA_STRUCT & i_sc )
{
    errlHndl_t l_mainElog = NULL;
    l_mainElog = ServiceGeneratorClass::ThisServiceGenerator().getErrl();

    if ( NULL == l_mainElog )
    {
        PRDF_ERR("smpCallout_link Failed to get the global error log" );
    }
    else
    {
        // add callout(s) on any bit firing
        // get the peer SMGROUP target associated with input SMPGROUP
        TargetHandle_t  l_smpPeerTgt =  i_smpTgt->getAttr<ATTR_PEER_TARGET>();
        PRDF_ASSERT(nullptr != l_smpPeerTgt);

    #ifdef __HOSTBOOT_MODULE
        HWAS::CalloutFlag_t calloutFlg = HWAS::FLAG_NONE;

        // Get Link position 0/1 (check if tgt pos is even/odd)
        uint32_t lnk = getTargetPosition(i_smpTgt) % 2;

        // If Link status reg has been zeroed, we know this link has failed
        ExtensibleChip *obusChip =
            (ExtensibleChip *)systemPtr->GetChip( i_obusTgt );
        SCAN_COMM_REGISTER_CLASS *lnkStat = obusChip->getRegister(
            lnk==0 ? "LINK_STATUS_REG0" : "LINK_STATUS_REG1" );

        int32_t rc = lnkStat->Read();

        if (rc != SUCCESS)
        {
            PRDF_ERR("smpCallout_link Failed to read LINK_STATUS_REG");
        }
        else if ( lnkStat->BitStringIsZero() )
        {
            calloutFlg = HWAS::FLAG_LINK_DOWN;

            // Indicate in the multi-signature section that the link has failed.
            // This allows us to know what attention we were handling in the
            // primary signature.
            i_sc.service_data->AddSignatureList(i_obusTgt, PRDFSIG_LinkFailed);

            // Make the error log predictive and mask.
            i_sc.service_data->SetThresholdMaskId(0);
        }

        l_mainElog->addBusCallout( i_smpTgt, l_smpPeerTgt, HWAS::O_BUS_TYPE,
                                   HWAS::SRCI_PRIORITY_MED, calloutFlg );
    #else
        // FSP code
        #ifndef ESW_SIM_COMPILE
        errlHndl_t  l_err = NULL;

        // Call SVPD routine to add callouts
        l_err = HWSV::SvrError::AddBusCallouts( l_mainElog, i_smpTgt,
                                                l_smpPeerTgt, HWAS::O_BUS_TYPE,
                                                SRCI_PRIORITY_MED );

        if (NULL != l_err)
        {
            PRDF_ERR("AddBusCallouts failed");
            l_err->CollectTrace(PRDF_COMP_NAME, 1024);
            l_err->commit( PRDF_COMP_ID, ERRL_ACTION_REPORT );
            delete l_err;
           l_err = NULL;
        }
        #endif // not simulation

    #endif  // else FSP side
    } // main elog is non-null


} // end  obus_smpCallout - two SMP targets


/** Given an OBUS TARGET and SMP link number -- get the SMP target **/
void  obus_getSmpTarget( TargetHandle_t &i_obusTgt,
                         uint32_t i_link,
                         TargetHandle_t &o_smpTgt )
{
    PredicateCTM           l_unitMatch(CLASS_UNIT, TYPE_SMPGROUP );
    TargetHandleList       l_smpTargetList;
    uint32_t               l_smpNum    = 0;
    TYPE                   l_targType = getTargetType(i_obusTgt);


    o_smpTgt = nullptr;

    // Validate we have expected target
    if ( TYPE_OBUS != l_targType )
    {
        PRDF_ERR("obus_callout Invalid Target(%d) on link%d",
                  l_targType, i_link );
        PRDF_ASSERT(false);
    }

    // Get all SMPGROUPS associated with OBUS target
    targetService().getAssociated(
                l_smpTargetList,
                i_obusTgt,
                TARGETING::TargetService::CHILD,
                TARGETING::TargetService::ALL,
                &l_unitMatch);

    // Find the match in SMPGROUP targets
    for ( auto  l_smp : l_smpTargetList )
    {
        l_smpNum = l_smp->getAttr<ATTR_CHIP_UNIT>();

        // ==========================================
        // Link numbering from hardware is just 0:1
        //  in OBUS related FIR.
        // ==========================================
        // SMPGROUP numbering is 0:7  (2 per OBUS chiplet)
        //
        //  OBUS0  link 0:1 ->  SMGROUP 0:1
        //  OBUS1  link 0:1 ->  SMGROUP 2:3
        //  OBUS2  link 0:1 ->  SMGROUP 4:5
        //  OBUS3  link 0:1 ->  SMGROUP 6:7
        // ==========================================
        l_smpNum = l_smpNum % 2;

        if (i_link == l_smpNum)
        {
            // We found the SMPGROUP
            o_smpTgt = l_smp;
            break;
        } // end if right LINK

    } // end for on smp targets

} // end obus_getSmpTarget


/** Given the OBUS TARGET and SMP link number -- do the callout **/
void  obus_smpCallout_link( TargetHandle_t &i_obusTgt, uint32_t i_link,
                            STEP_CODE_DATA_STRUCT & i_sc )
{
    #define PRDF_FUNC "[LaneRepair::obus_smpCallout_link] "

    if ( !obusInSmpMode(i_obusTgt) )
    {
        // There is no support in for calling out the other end of an NV or
        // openCAPI bus. By design, any FIR bits associated with those bus types
        // should not be driving attentions. So instead use the default callout.

        PRDF_ERR( PRDF_FUNC "Bus callouts only supported in SMP mode: "
                  "i_obusTgt=0x%08x", getHuid(i_obusTgt) );

        i_sc.service_data->SetCallout( LEVEL2_SUPPORT, MRU_MED, NO_GARD );
        i_sc.service_data->SetCallout( SP_CODE, MRU_MED, NO_GARD );
        i_sc.service_data->setServiceCall();
    }
    else
    {
        TargetHandle_t  l_smpTarg     = nullptr;

        // Get the associated SMP target for this OBUS target
        obus_getSmpTarget( i_obusTgt, i_link, l_smpTarg );
        PRDF_ASSERT(nullptr != l_smpTarg);

        // Callout both SMPGROUPS
        obus_smpCallout( l_smpTarg, i_obusTgt, i_sc );
    }

    return;

    #undef PRDF_FUNC

} // end  obus_smpCallout_link -  smp link number


/** Given the OBUS unit number and SMP link number -- do the callout **/
void  obus_smpCallout_link( uint32_t  i_obusNum, ExtensibleChip * i_chip,
                            uint32_t i_link, STEP_CODE_DATA_STRUCT & i_sc )
{
    // From NEST so it will be a processor target
    TargetHandle_t rxTrgt = i_chip->getTrgt();

    // We need the right OBUS target from this processor
    TargetHandle_t   l_obus = getConnectedChild(rxTrgt,
                                                TYPE_OBUS, i_obusNum);

    PRDF_ASSERT( NULL != l_obus );

    // We found the right OBUS target
    obus_smpCallout_link( l_obus, i_link, i_sc );

} // end  obus_smpCallout_link - obus & smp link numbers


int32_t obus_callout_L0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // Need the obus target
    TargetHandle_t rxTrgt = i_chip->getTrgt();
    // Call out LINK0 in SMPGROUP
    obus_smpCallout_link( rxTrgt, 0, i_sc );

    return rc;

} // end  obus_callout_L0
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,  LaneRepair, obus_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus, LaneRepair, obus_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_obus,   LaneRepair, obus_callout_L0 );

int32_t obus_callout_L1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
   int32_t rc = SUCCESS;

    // Need the obus target
    TargetHandle_t rxTrgt = i_chip->getTrgt();
    // Call out LINK1 in SMPGROUP
    obus_smpCallout_link( rxTrgt, 1, i_sc );

    return rc;

} // end  obus_callout_L1
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,  LaneRepair, obus_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus, LaneRepair, obus_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_obus,   LaneRepair, obus_callout_L1 );

int32_t obus0_callout_L0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus0 link0
    obus_smpCallout_link( 0, i_chip, 0, i_sc );

    return rc;

} // end obus0_callout_L0
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus0_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus0_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus0_callout_L0 );

int32_t obus0_callout_L1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus0 link1
    obus_smpCallout_link( 0, i_chip, 1, i_sc );

    return rc;

} // end obus0_callout_L1
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus0_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus0_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus0_callout_L1 );

int32_t obus1_callout_L0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus1 link0
    obus_smpCallout_link( 1, i_chip, 0, i_sc );

    return rc;

} // end obus1_callout_L0
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus1_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus1_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus1_callout_L0 );

int32_t obus1_callout_L1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus1 link1
    obus_smpCallout_link( 1, i_chip, 1, i_sc );

    return rc;

} // end obus1_callout_L1
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus1_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus1_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus1_callout_L1 );

int32_t obus2_callout_L0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus2 link0
    obus_smpCallout_link( 2, i_chip, 0, i_sc );

    return rc;

} // end obus2_callout_L0
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus2_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus2_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus2_callout_L0 );

int32_t obus2_callout_L1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus2 link1
    obus_smpCallout_link( 2, i_chip, 1, i_sc );

    return rc;

} // end obus2_callout_L1
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus2_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus2_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus2_callout_L1 );

int32_t obus3_callout_L0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus3 link0
    obus_smpCallout_link( 3, i_chip, 0, i_sc );

    return rc;

} // end obus3_callout_L0
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus3_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus3_callout_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus3_callout_L0 );

int32_t obus3_callout_L1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    // callout obus3 link0
    obus_smpCallout_link( 3, i_chip, 1, i_sc );

    return rc;

} // end obus3_callout_L1
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, obus3_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, obus3_callout_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, obus3_callout_L1 );

void  obus_clearMaskFail( errlHndl_t &io_errl, TargetHandle_t &i_rxTrgt,
                          TargetHandle_t &i_txTrgt, uint32_t i_link )
{
    // ensure we have valid inputs
    PRDF_ASSERT( NULL != i_rxTrgt );
    PRDF_ASSERT( NULL != i_txTrgt );
    PRDF_ASSERT( NULL != io_errl );

    uint32_t         l_rc = SUCCESS;
    ExtensibleChip  *l_rxChip =
                            (ExtensibleChip *)systemPtr->GetChip( i_rxTrgt );
    ExtensibleChip  *l_txChip =
                            (ExtensibleChip *)systemPtr->GetChip( i_txTrgt );


    do
    {
        if (MODEL_NIMBUS == getChipModel(i_rxTrgt))
        {
            PRDF_ERR("[obus_clearMaskFail] called on NIMBUS");
            break;
        } // nimbus not supported


        // These defines are for LINK0
        // (LINK1 will be the next bit for each of these)
        #define OBUS_CRC_ERRORS     6
        #define OBUS_ECC_ERRORS    14
        #define OBUS_NO_SPARE      42
        #define OBUS_SPARE_DONE    44
        #define OBUS_TOO_MANY_CRC  46
        #define OBUS_LNK0_TRAINING_FAILED  56

        // Normal rule file handling should clear bit 56
        // or bit 57 and mask it for the target we got the
        // attention on.
        // We still need to do it for the other end of the cable.

        // Clear the FIR on other end
        SCAN_COMM_REGISTER_CLASS * obusTxFir_and = l_txChip->getRegister("IOOLFIR_AND");
        obusTxFir_and->setAllBits();
        obusTxFir_and->ClearBit(OBUS_LNK0_TRAINING_FAILED + i_link);
        // MASK the attention on the other end
        SCAN_COMM_REGISTER_CLASS * obusTxMask_or = l_txChip->getRegister("IOOLFIR_MASK_OR");
        obusTxMask_or->clearAllBits();
        obusTxMask_or->SetBit(OBUS_LNK0_TRAINING_FAILED + i_link);

        // Clear other related bits for link0 or link1
        // on the current target with the active attention
        SCAN_COMM_REGISTER_CLASS * obusRxFir_and = l_rxChip->getRegister("IOOLFIR_AND");
        obusRxFir_and->setAllBits();
        obusRxFir_and->ClearBit(OBUS_CRC_ERRORS   + i_link);
        obusRxFir_and->ClearBit(OBUS_ECC_ERRORS   + i_link);
        obusRxFir_and->ClearBit(OBUS_NO_SPARE     + i_link);
        obusRxFir_and->ClearBit(OBUS_SPARE_DONE   + i_link);
        obusRxFir_and->ClearBit(OBUS_TOO_MANY_CRC + i_link);

        // put back the MASK and FIRs to hardware
        l_rc  = obusTxMask_or->Write();
        l_rc |= obusTxFir_and->Write();
        l_rc |= obusRxFir_and->Write();

        if ( SUCCESS != l_rc )
        {
            PRDF_ERR("obus_clearMaskFail failed handling link %d", i_link);
        }

    } while (0);

} // end obus_clearMaskFail



int32_t obus_fail_L0( ExtensibleChip * i_chip,
                      STEP_CODE_DATA_STRUCT & i_sc )
{
    int32_t rc = SUCCESS;

    TargetHandle_t  rxTrgt = i_chip->getTrgt();
    TargetHandle_t  txTrgt = getTxBusEndPt(rxTrgt);

    do
    {
        errlHndl_t l_mainElog = NULL;
        l_mainElog = ServiceGeneratorClass::ThisServiceGenerator().getErrl();
        if ( NULL == l_mainElog )
        {
            PRDF_ERR( "obus_fail Failed to get the global error log" );
            rc = FAIL;
            break;
        }

        // invoke routine to clear and mask the failure and
        // other related bits.
        obus_clearMaskFail( l_mainElog, rxTrgt, txTrgt, 0 );

    } while(0);


    return rc;

} // end obus_fail_L0
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,  LaneRepair, obus_fail_L0 );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus, LaneRepair, obus_fail_L0 );
PRDF_PLUGIN_DEFINE_NS( axone_obus,   LaneRepair, obus_fail_L0 );

int32_t obus_fail_L1( ExtensibleChip * i_chip,
                      STEP_CODE_DATA_STRUCT & i_sc )
{
   int32_t rc = SUCCESS;

    TargetHandle_t  rxTrgt = i_chip->getTrgt();
    TargetHandle_t  txTrgt = getTxBusEndPt(rxTrgt);

    do
    {
        errlHndl_t l_mainElog = NULL;
        l_mainElog = ServiceGeneratorClass::ThisServiceGenerator().getErrl();
        if ( NULL == l_mainElog )
        {
            PRDF_ERR( "obus_fail_Failed to get the global error log" );
            rc = FAIL;
            break;
        }

        // invoke routine to clear and mask the failure and
        // other related bits.
        obus_clearMaskFail( l_mainElog, rxTrgt, txTrgt, 1 );

    } while(0);

    return rc;

} // end obus_fail_L1
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,  LaneRepair, obus_fail_L1 );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus, LaneRepair, obus_fail_L1 );
PRDF_PLUGIN_DEFINE_NS( axone_obus,   LaneRepair, obus_fail_L1 );

/** Need routine to capture FFDC for PBIOOFIR **/
void    baseCaptureSmpFFDC( ExtensibleChip * i_chip,
                            STEP_CODE_DATA_STRUCT & io_sc,
                            uint32_t  i_obusNum )
{
    // get the specific OBUS target we are interested in
    TargetHandle_t   l_obus = getConnectedChild(i_chip->getTrgt(),
                                                TYPE_OBUS, i_obusNum);

    ExtensibleChip * l_obusChip;
    l_obusChip = (ExtensibleChip *)systemPtr->GetChip(l_obus);
    // Add OBUS registers for this instance
    if( NULL != l_obusChip )
    {
        l_obusChip->CaptureErrorData(
                          io_sc.service_data->GetCaptureData(),
                          Util::hashString("smpCableFFDC"));
    }

} // baseCaptureSmpFFDC

int32_t captureSmpObus0( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    baseCaptureSmpFFDC( i_chip, io_sc, 0 );
    return SUCCESS;

} // end captureSmpObus0
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, captureSmpObus0 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, captureSmpObus0 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, captureSmpObus0 );

int32_t captureSmpObus1( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    baseCaptureSmpFFDC( i_chip, io_sc, 1 );
    return SUCCESS;

} // end captureSmpObus1
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, captureSmpObus1 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, captureSmpObus1 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, captureSmpObus1 );

int32_t captureSmpObus2( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    baseCaptureSmpFFDC( i_chip, io_sc, 2 );
    return SUCCESS;

} // end captureSmpObus2
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, captureSmpObus2 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, captureSmpObus2 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, captureSmpObus2 );

int32_t captureSmpObus3( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    baseCaptureSmpFFDC( i_chip, io_sc, 3 );
    return SUCCESS;

} // end captureSmpObus3
PRDF_PLUGIN_DEFINE_NS( cumulus_proc, LaneRepair, captureSmpObus3 );
PRDF_PLUGIN_DEFINE_NS( nimbus_proc,  LaneRepair, captureSmpObus3 );
PRDF_PLUGIN_DEFINE_NS( axone_proc,   LaneRepair, captureSmpObus3 );

int32_t calloutBusInterface( ExtensibleChip * i_chip,
                             STEP_CODE_DATA_STRUCT & i_sc,
                             PRDpriority i_priority )
{
    #define PRDF_FUNC "[PrdfLaneRepair::calloutBusInterface] "

    int32_t rc = SUCCESS;

    do {
        // Get both endpoints
        TargetHandle_t rxTrgt = i_chip->getTrgt();
        TYPE rxType = getTargetType(rxTrgt);

        if ( rxType == TYPE_OBUS && !obusInSmpMode( rxTrgt ) )
        {
            // There is no support in hostboot for calling out the other end of
            // an NV or openCAPI bus. By design, any FIR bits associated with
            // those bus types should not be taking a CalloutBusInterface
            // action. So if we hit this case, just make a default callout.

            PRDF_ERR( PRDF_FUNC "Lane repair only supported in SMP mode "
                      "obus: 0x%08x", getHuid(rxTrgt) );

            i_sc.service_data->SetCallout( LEVEL2_SUPPORT, MRU_MED, NO_GARD );
            i_sc.service_data->SetCallout( SP_CODE, MRU_MED, NO_GARD );
            i_sc.service_data->setServiceCall();
            break;
        }

        TargetHandle_t txTrgt = getTxBusEndPt(rxTrgt);
        TYPE txType = getTargetType(txTrgt);

        // Add the endpoint target callouts
        i_sc.service_data->SetCallout( rxTrgt, MRU_MEDA );
        i_sc.service_data->SetCallout( txTrgt, MRU_MEDA);

        // Get the HWAS bus type.
        HWAS::busTypeEnum hwasType = HWAS::X_BUS_TYPE;
        if ( TYPE_XBUS == rxType && TYPE_XBUS == txType )
        {
            hwasType = HWAS::X_BUS_TYPE;
        }
        else if ( TYPE_OBUS == rxType && TYPE_OBUS == txType )
        {
            hwasType = HWAS::O_BUS_TYPE;
        }
        else if ( (TYPE_DMI == rxType && TYPE_MEMBUF == txType) ||
                  (TYPE_MEMBUF == rxType && TYPE_DMI == txType) )
        {
            hwasType = HWAS::DMI_BUS_TYPE;
        }
        else
        {
            PRDF_ASSERT( false );
        }

        // Get the global error log.
        errlHndl_t errl = NULL;
        errl = ServiceGeneratorClass::ThisServiceGenerator().getErrl();
        if ( NULL == errl )
        {
            PRDF_ERR( PRDF_FUNC "Failed to get the global error log" );
            rc = FAIL; break;
        }

        // Callout this bus interface.
        PRDF_ADD_BUS_CALLOUT( errl, rxTrgt, txTrgt, hwasType, i_priority );

    } while(0);

    return rc;

    #undef PRDF_FUNC
}



// Lane Repair Rule Plugins

/**
 * @brief  Handles Spare Lane Deployed Event
 * @param  i_chip chip.
 * @param  io_sc  Step code data struct.
 * @return SUCCESS always
 */
int32_t spareDeployed( ExtensibleChip * i_chip,
                       STEP_CODE_DATA_STRUCT & io_sc )
{
    if ( CHECK_STOP != io_sc.service_data->getPrimaryAttnType() )
        return handleLaneRepairEvent(i_chip, io_sc, true);
    else
        return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_xbus,    LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( cumulus_xbus,   LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( axone_xbus,     LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,    LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus,   LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( axone_obus,     LaneRepair, spareDeployed );
PRDF_PLUGIN_DEFINE_NS( centaur_membuf, LaneRepair, spareDeployed );

/**
 * @brief  Handles Max Spares Exceeded Event
 * @param  i_chip chip.
 * @param  io_sc  Step code data struct.
 * @return SUCCESS always
 */
int32_t maxSparesExceeded( ExtensibleChip * i_chip,
                           STEP_CODE_DATA_STRUCT & io_sc )
{
    if ( CHECK_STOP != io_sc.service_data->getPrimaryAttnType() )
        return handleLaneRepairEvent(i_chip, io_sc, false);
    else
        return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_xbus,    LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( cumulus_xbus,   LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( axone_xbus,     LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,    LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus,   LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( axone_obus,     LaneRepair, maxSparesExceeded );
PRDF_PLUGIN_DEFINE_NS( centaur_membuf, LaneRepair, maxSparesExceeded );

/**
 * @brief  Handles Too Many Bus Errors Event
 * @param  i_chip chip
 * @param  io_sc  Step code data struct.
 * @return SUCCESS always
 */
int32_t tooManyBusErrors( ExtensibleChip * i_chip,
                          STEP_CODE_DATA_STRUCT & io_sc )
{
    if ( CHECK_STOP != io_sc.service_data->getPrimaryAttnType() )
        return handleLaneRepairEvent(i_chip, io_sc, false);
    else
        return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_xbus,    LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( cumulus_xbus,   LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( axone_xbus,     LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,    LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus,   LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( axone_obus,     LaneRepair, tooManyBusErrors );
PRDF_PLUGIN_DEFINE_NS( centaur_membuf, LaneRepair, tooManyBusErrors );

/**
 * @brief Add callouts for a BUS interface
 * @param  i_chip Bus endpt chip
 * @param  io_sc  Step code data struct.
 * @return SUCCESS always
 */
int32_t calloutBusInterfacePlugin( ExtensibleChip * i_chip,
                                   STEP_CODE_DATA_STRUCT & io_sc )
{
    calloutBusInterface(i_chip, io_sc, MRU_LOW);
    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_xbus,    LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( cumulus_xbus,   LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( axone_xbus,     LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( nimbus_obus,    LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( cumulus_obus,   LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( axone_obus,     LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( cumulus_dmi,    LaneRepair, calloutBusInterfacePlugin );
PRDF_PLUGIN_DEFINE_NS( centaur_membuf, LaneRepair, calloutBusInterfacePlugin );


//------------------------------------------------------------------------------

#define CREATE_CALL_CHILD_LANE_REPAIR_FUNCTION( PLUGIN_FUNCTION) \
int32_t callChildLR_##PLUGIN_FUNCTION( ExtensibleChip * i_chip, \
                                      TARGETING::TYPE i_type, \
                                      uint32_t i_pos, \
                                      STEP_CODE_DATA_STRUCT & io_sc) \
{ \
    ExtensibleChip * endPoint = getConnectedChild( i_chip, i_type, i_pos ); \
\
    if ( nullptr == endPoint ) \
    { \
        PRDF_ERR( "[callLaneRepairRulePluginOnChild_##TYPE] Connection lookup failed:" \
            " 0x%08x 0x%02x %d", i_chip->getHuid(), i_type, i_pos ); \
        io_sc.service_data->SetCallout(LEVEL2_SUPPORT, MRU_HIGH); \
        io_sc.service_data->SetCallout(i_chip->getTrgt()); \
        io_sc.service_data->SetThresholdMaskId(0); \
    } \
    else \
    { \
        /* ignore rc as this is a plugin call */ \
        PLUGIN_FUNCTION( endPoint, io_sc ); \
    } \
\
     /* Always return SUCCESS because other rc types (ie. FAIL) */ \
     /* are not necessarily understood by plugin rule code */ \
    return SUCCESS; \
}


// Create plugin calling wrapper functions
CREATE_CALL_CHILD_LANE_REPAIR_FUNCTION( calloutBusInterfacePlugin)
CREATE_CALL_CHILD_LANE_REPAIR_FUNCTION( maxSparesExceeded)
CREATE_CALL_CHILD_LANE_REPAIR_FUNCTION( spareDeployed)
CREATE_CALL_CHILD_LANE_REPAIR_FUNCTION( tooManyBusErrors)

//------------------------------------------------------------------------------

#define PLUGIN_CALLOUT_INTERFACE( TYPE, POS ) \
int32_t calloutBusInterface_##TYPE##POS( ExtensibleChip * i_chip, \
                                         STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return callChildLR_calloutBusInterfacePlugin( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS(nimbus_proc,  LaneRepair, calloutBusInterface_##TYPE##POS);\
PRDF_PLUGIN_DEFINE_NS(cumulus_proc, LaneRepair, calloutBusInterface_##TYPE##POS); \
PRDF_PLUGIN_DEFINE_NS(axone_proc,   LaneRepair, calloutBusInterface_##TYPE##POS);

PLUGIN_CALLOUT_INTERFACE( XBUS, 0 )
PLUGIN_CALLOUT_INTERFACE( XBUS, 1 )
PLUGIN_CALLOUT_INTERFACE( XBUS, 2 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 0 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 1 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 2 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 3 )



#undef PLUGIN_CALLOUT_INTERFACE

//------------------------------------------------------------------------------

#define PLUGIN_LANE_REPAIR_DMI( TYPE, POS ) \
int32_t calloutBusInterface_##TYPE##POS( ExtensibleChip * i_chip, \
                                         STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return callChildLR_calloutBusInterfacePlugin( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS( cumulus_mc, LaneRepair, calloutBusInterface_##TYPE##POS ); \
\
int32_t maxSparesExceeded_##TYPE##POS( ExtensibleChip * i_chip, \
                                       STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return callChildLR_maxSparesExceeded( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS( cumulus_mc, LaneRepair, maxSparesExceeded_##TYPE##POS ); \
\
int32_t spareDeployed_##TYPE##POS( ExtensibleChip * i_chip, \
                                   STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return callChildLR_spareDeployed( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS( cumulus_mc, LaneRepair, spareDeployed_##TYPE##POS ); \
\
int32_t tooManyBusErrors_##TYPE##POS( ExtensibleChip * i_chip, \
                                      STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return callChildLR_tooManyBusErrors( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS( cumulus_mc, LaneRepair, tooManyBusErrors_##TYPE##POS );

// Handle the MC chip target to DMI conversion
PLUGIN_LANE_REPAIR_DMI( DMI, 0 )
PLUGIN_LANE_REPAIR_DMI( DMI, 1 )
PLUGIN_LANE_REPAIR_DMI( DMI, 2 )
PLUGIN_LANE_REPAIR_DMI( DMI, 3 )

#undef PLUGIN_LANE_REPAIR_DMI

//------------------------------------------------------------------------------


} // end namespace LaneRepair

} // end namespace PRDF

OpenPOWER on IntegriCloud