summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2GetChipletNumTest.H
blob: 59c9acd4be89dea808a3d24c0c7c251958932436 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/fapi2GetChipletNumTest.H $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2018                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#include <fapi2.H>
#include <commontargeting.H>
#include <cxxtest/TestSuite.H>
#include "fapi2TestUtils.H"


namespace fapi2
{

class Fapi2GetChipletNum : public CxxTest::TestSuite
{
    public:

    void testVerifyiPhbChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF ("Start testVerifyiPhbChipletNum");
        do
        {
            // find all PHB units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predPhb(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_PHB);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predPhb);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyiPhbChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all PHB chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_PHB> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyiPhbChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();

                // PEC-0 PBH-0 maps to pervasive id 0x0D
                if (l_chip_unit == 0)
                {
                    l_exp_chiplet_id = START_PEC_0_CHIPLET_NUM;
                }
                // PEC-1 PBH-0 maps to pervasive id 0x0E
                // PEC-1 PBH-1 maps to pervasive id 0x0E
                else if ((l_chip_unit >= 1) && (l_chip_unit <= 2))
                {
                    l_exp_chiplet_id = START_PEC_1_CHIPLET_NUM;
                }
                // PEC-2 PBH-0 maps to pervasive id 0x0F
                // PEC-2 PBH-1 maps to pervasive id 0x0F
                // PEC-2 PBH-2 maps to pervasive id 0x0F
                else if ((l_chip_unit >= 3) && (l_chip_unit <= 5))
                {
                    l_exp_chiplet_id = START_PEC_2_CHIPLET_NUM;
                }

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyiPhbChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyiPhbChipletNum");
    }

    void testVerifyObusBrickChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF ("Start testVerifyObusBrickChipletNum");
        do
        {
            // find the all OBUS Brick units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predObusBrick(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_OBUS_BRICK);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predObusBrick);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyObusBrickChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all OBUS BRICK chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_OBUS_BRICK> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyObusBrickChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                //OBUS Brick's chiplet id should be same as its parent
                auto l_parent = static_cast<TARGETING::Target*>
                        (fapi2_Target.getParent<TARGET_TYPE_OBUS>());
                l_chip_unit = l_parent->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_OBUS_BRICK_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyObusBrickChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyObusBrickChipletNum");
    }

    void testVerifyPecChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF ("Start testVerifyPecChipletNum");
        do
        {
            // find all PEC units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predPec(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_PEC);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predPec);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyPecChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all PEC chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_PEC> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyPecChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                // PEC 0,1,2 maps to pervasive ids 0x0D, 0x0E, 0x0F
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_PEC_0_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyPecChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyPecChipletNum");
    }

    void testVerifyCappChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF ("Start testVerifyCappChipletNum");
        do
        {
            // find all CAPP units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predCapp(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_CAPP);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predCapp);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyCappChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all CAPP chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_CAPP> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyCappChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                // CAPP 0,1 maps to pervasive ids 0x02, 0x04
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                if (l_chip_unit == 0 )
                {
                    l_exp_chiplet_id = START_CAPP_CHIPLET_NUM;
                }
                else
                {
                    l_exp_chiplet_id = START_CAPP_CHIPLET_NUM + 2;
                }

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyCappChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyCappChipletNum");
    }

    void testVerifyMcbistChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF ("Start testVerifyMcbistChipletNum");
        do
        {
            // find all MCBIST units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predMcbist(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_MCBIST);

            TARGETING::Target* l_pMasterProcChip = nullptr;
            TARGETING::targetService().masterProcChipTargetHandle(l_pMasterProcChip);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predMcbist);

            if (l_TargetList.empty())
            {
                if(TARGETING::MODEL_NIMBUS ==
                    l_pMasterProcChip->getAttr<TARGETING::ATTR_MODEL>())
                {
                    TS_FAIL("testVerifyMcbistChipletNum: empty l_TargetList");
                }
                break;
            }

            // Iterate through all MCBIST chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_MCBIST> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyMcbistChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                // MCBIST 0,1 maps to pervasive ids 0x07, 0x08
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_MCBIST_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyMcbistChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyMcbistChipletNum");
    }

    void testVerifyMcsChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;

        FAPI_INF("Start testVerifyMcsChipletNum");
        do
        {
            // find all MCS units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predMcs(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_MCS);

            TARGETING::Target* l_pMasterProcChip = nullptr;
            TARGETING::targetService().masterProcChipTargetHandle(l_pMasterProcChip);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predMcs);

            if (l_TargetList.empty())
            {
                if(TARGETING::MODEL_NIMBUS ==
                    l_pMasterProcChip->getAttr<TARGETING::ATTR_MODEL>())
                {
                    TS_FAIL("testVerifyMcsChipletNum: empty l_TargetList");
                }
                break;
            }

            // Iterate through all MCS chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_MCS> fapi2_Target(l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyMcsChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                ReturnCode l_rc;
                fapi2::ATTR_CHIP_UNIT_POS_Type l_chipPos = 0;
                l_rc = FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS,
                            l_Target, l_chipPos);
                if( l_rc )
                {
                    TS_FAIL("testVerifyMcsChipletNum: Error getting fapi::ATTR_CHIP_UNIT_POS");
                    break;
                }

                // MCS 0..1, 2..3 maps to pervasive ids 0x07, 0x08
                l_exp_chiplet_id = (l_chipPos/2) + START_MCBIST_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyMcsChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyMcsChipletNum");
    }

    void testVerifyMcaChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF("Start testVerifyMcaChipletNum");
        do
        {
            // find all MCA units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predMca(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_MCA);

            TARGETING::Target* l_pMasterProcChip = nullptr;
            TARGETING::targetService().masterProcChipTargetHandle(l_pMasterProcChip);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predMca);

            if (l_TargetList.empty())
            {
                if(TARGETING::MODEL_NIMBUS ==
                    l_pMasterProcChip->getAttr<TARGETING::ATTR_MODEL>())
                {
                    TS_FAIL("testVerifyMcaChipletNum: empty l_TargetList");
                }
                break;
            }

            // Iterate through all MCA chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_MCBIST> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyMcaChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target), l_chiplet_id);

                // MCA 0..3, 4..7 maps to pervasive ids 0x07, 0x08
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit / 4 + START_MCBIST_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyMcaChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyMcaChipletNum");
    }

    void testVerifyObusChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF("Start testVerifyObusChipletNum");
        do
        {
            // find all OBUS units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predObus(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_OBUS);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predObus);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyObusChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all OBUS chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_OBUS> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyObusChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                ReturnCode l_rc;
                fapi2::ATTR_CHIP_UNIT_POS_Type l_chipPos = 0;
                l_rc = FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS,
                            l_Target, l_chipPos);
                if( l_rc )
                {
                    TS_FAIL("testVerifyObusChipletNum: Error getting fapi::ATTR_CHIP_UNIT_POS");
                    break;
                }

                // OBUS 0,3 maps to pervasive ids 0x09, 0x0C
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_OBUS_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyObusChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyObusChipletNum");
    }

    void testVerifyXbusChipletNum()
    {
        uint8_t  l_chiplet_id = 0;

        FAPI_INF("Start testVerifyXbusChipletNum");
        do
        {
            // find all XBUS units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predXbus(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_XBUS);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predXbus);

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyXbusChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all XBUS chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_XBUS> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyXbusChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                // XBUS 0,1 maps to pervasive id 0x06
                if (l_chiplet_id != START_XBUS_CHIPLET_NUM)
                {
                    TS_FAIL("testVerifyXbusChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            START_XBUS_CHIPLET_NUM, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyXbusChipletNum");
    }
    void testVerifyPervChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF("Start testVerifyPervChipletNum");
        do
        {
            // find all PERV units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predPerv(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_PERV);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predPerv );

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyPervChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all PERV chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_PERV> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyPervChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                // PERV units and chiplet ids are same
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();

                if (l_chiplet_id != l_chip_unit)
                {
                    TS_FAIL("testVerifyPervChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_chip_unit, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyPervChipletNum");
    }

    void testVerifyEQChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        FAPI_INF("Start testVerifyEQChipletNum");
        do
        {
            // find all EQ units`
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predEq(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_EQ);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predEq );

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyEQChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all EQ chiplets
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_EQ> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyEQChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                // EQ 0..5 maps to pervasive ids 0x10..0x15
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_EQ_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyEQChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyEQChipletNum");
    }

    void testVerifyEXChipletNum()
    {
        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;

        FAPI_INF("Start testVerifyEXChipletNum");
        do
        {
            // find all EX units
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predEx(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_EX);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predEx );

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyEXChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all EXs
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_EX> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyEXChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                ReturnCode l_rc;
                fapi2::ATTR_CHIP_UNIT_POS_Type chipPos = 0;
                l_rc = FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS,
                            l_Target,chipPos);
                if( l_rc )
                {
                    TS_FAIL("testVerifyEXChipletNum: Error getting fapi::ATTR_CHIP_UNIT_POS");
                    break;
                }

                // EXs maps to pervasive id of their parents 0x10..0x15
                l_exp_chiplet_id = (chipPos/2) + START_EQ_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyEXChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyEXChipletNum");
    }

    void testVerifyCoreChipletNum()
    {
        FAPI_INF("Start testVerifyCoreChipletNum");

        uint8_t  l_chiplet_id = 0;
        uint8_t  l_exp_chiplet_id = 0;
        uint8_t  l_chip_unit = 0;

        do
        {
            // find all cpu COREs
            TARGETING::Target * pSys;
            TARGETING::targetService().getTopLevelTarget(pSys);
            TARGETING::PredicateCTM predCore(TARGETING::CLASS_UNIT,
                    TARGETING::TYPE_CORE);

            TARGETING::TargetHandleList l_TargetList;
            TARGETING::targetService().getAssociated( l_TargetList, pSys,
                    TARGETING::TargetService::CHILD,
                    TARGETING::TargetService::ALL,
                    &predCore );

            if (l_TargetList.empty())
            {
                TS_FAIL("testVerifyCoreChipletNum: empty l_TargetList");
                break;
            }

            // Iterate through all cores
            for (auto & l_Target : l_TargetList)
            {
                // map Targeting Type to fapi2 Type
                Target<fapi2::TARGET_TYPE_CORE> fapi2_Target( l_Target);
                l_chiplet_id = fapi2_Target.getChipletNumber();

                FAPI_DBG("testVerifyCoreChipletNum HUID: %.8X, ChipletId: %.8X",
                    TARGETING::get_huid(l_Target),
                    l_chiplet_id);

                // Processor Core 0..23 maps to pervasive ids 0x20..0x37
                l_chip_unit = l_Target->getAttr<TARGETING::ATTR_CHIP_UNIT>();
                l_exp_chiplet_id = l_chip_unit + START_CORE_CHIPLET_NUM;

                if (l_chiplet_id != l_exp_chiplet_id)
                {
                    TS_FAIL("testVerifyCoreChipletNum: Mismatch HUID %.8X - Expected: %.8X:, Found: %.8X",
                            TARGETING::get_huid(l_Target),
                            l_exp_chiplet_id, l_chiplet_id);
                    break;
                }
            }
        } while(0);
        FAPI_INF("Complete testVerifyCoreChipletNum");
    }

    //**************************************************************************
    // test_fapi2GetChipletNum
    //**************************************************************************
    void test_fapi2ChipletNum()
    {

        FAPI_DBG("Enter test_fapi2GetChipletNum");
        do
        {

            testVerifyEQChipletNum();

            testVerifyEXChipletNum();

            testVerifyCoreChipletNum();

            testVerifyPervChipletNum();

            testVerifyXbusChipletNum();

            testVerifyObusChipletNum();

            testVerifyMcbistChipletNum();

            testVerifyMcsChipletNum();

            testVerifyMcaChipletNum();

            // @todo RTC 178802 Enable test cases turned off during bring up
            // Need to add Cumulus specific tests here - MC/MI/DMI

            testVerifyCappChipletNum();

            testVerifyObusBrickChipletNum();

            testVerifyPecChipletNum();

            testVerifyiPhbChipletNum();

        } while(0);
        FAPI_DBG("test_fapi2ChipletNum Test Complete.");
    } // end test_fapi2ChipletNum()

}; // end class

}// end namespace fapi2

OpenPOWER on IntegriCloud