summaryrefslogtreecommitdiffstats
path: root/src/usr/expscom/test/expscomtest.H
blob: 7049e84d4929bb919658550838bc8a6e9dbed778 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/expscom/test/expscomtest.H $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,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                                                     */
#ifndef __EXPSCOMTEST_H
#define __EXPSCOMTEST_H

/**
 *  @file expscomtest.H
 *
 *  @brief Test case for EXPSCOM code
*/

#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <devicefw/userif.H>
#include <expscom/expscom_reasoncodes.H>
#include <fapi2/target.H>
#include <fapi2/plat_hwp_invoker.H>
#include <fapi2_hwp_executor.H>
#include <fapi2/hw_access.H>
#include <exp_consts.H>

extern trace_desc_t* g_trac_expscom;

using namespace TARGETING;
using namespace ERRORLOG;

// Address and data to read/write
struct testExpscomAddrData
{
    uint32_t addr;
    uint64_t data;
};

// Test table values
const testExpscomAddrData g_expscomAddrTable[] =
{
        {0x501C,     0x00000000DEADBEEF},
        {0x209004,   0x00000000C0DEDEAD},
        {0x8010002,  0xDEADC0DEC0DEBEEF}
};
const uint32_t g_expscomAddrTableSz =
                    sizeof(g_expscomAddrTable)/sizeof(testExpscomAddrData);


const ScomSwitches forceI2CScom = {.useFsiScom = 0, .useXscom = 0,
                                   .useInbandScom = 0, .useSbeScom = 0,
                                   .useI2cScom = 1};

const ScomSwitches forceMMIOScom = {.useFsiScom = 0, .useXscom = 0,
                                   .useInbandScom = 1, .useSbeScom = 0,
                                   .useI2cScom = 0};

#define FAIL_TEST_RC(TARGET, STRING) \
l_fails++; \
TS_FAIL(STRING , \
        l_testEntry.data, \
        l_testEntry.addr, \
        get_huid(TARGET)); \
l_err = fapi2::rcToErrl(l_rc); \
errlCommit(l_err, 0x10);

#define FAIL_TEST_ERRL(TARGET, STRING) \
l_fails++; \
TS_FAIL(STRING , \
        l_testEntry.data, \
        l_testEntry.addr, \
        get_huid(TARGET)); \
errlCommit(l_err, 0x10);

class expscomTest: public CxxTest::TestSuite
{
public:

    /**
    * @brief EXPSCOM test I2C Path
    *        Write value and read back to verify i2c scoms to OCMBs
    */
    void testExpscomI2c(void)
    {
        TRACFCOMP( g_trac_expscom, ">> Enter  testExpscomI2c");
        // Keep trace of pass/fails
        uint32_t l_tests = 0;
        uint32_t l_fails = 0;
        errlHndl_t l_err = nullptr;

        // Fapi interfaces will be used in these tests so this variable
        // will be used to hold error from fapi calls
        fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
        fapi2::buffer<uint64_t> l_scom_buffer;
        TargetHandleList l_explorerList;

        do{
            // Get the system's OCMB chips, we will use these as test targets
            getAllChips( l_explorerList,
                          TYPE_OCMB_CHIP,
                          true ); // true: return functional OCMBs

            if(l_explorerList.size() == 0 )
            {
                TRACFCOMP( g_trac_expscom, "No OCMB targets found, skipping testExpscomI2c");
                break;
            }


            // We will use the first and last targets for these scom tests
            auto l_firstExpChip = l_explorerList.front();
            auto l_lastExpChip  = l_explorerList.back();

            // Cast the TARGETING::Targets into fapi2::Targets
            fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_firstExpChip_fapi(l_firstExpChip);
            fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_lastExpChip_fapi(l_lastExpChip);

            // Save away original scom switch info so we can restore it at the end of the test
            auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
            auto last_ocmb_info  = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();

            // This goal of this tests is to make sure I2C scom to OCMB is working so force
            // scom to go over I2C path for these targets
            l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
            l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);

            // Loop through table for first and last OCMB targets
            for( uint32_t l_num=0; l_num < g_expscomAddrTableSz; l_num++)
            {
                // Read the test entry info from the global table at the top of this file
                testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num];

                if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR)
                {
                    // If this is an IBM address then we expect 64 bits of data
                    l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data);
                }
                else
                {
                    // Otherwise we know this is a native OCMB address and it is only 32 bits
                    l_scom_buffer.insert<32,32,0,uint32_t>(l_testEntry.data);
                }

                FAPI_INVOKE_HWP(l_err, fapi2::putScom,
                                l_firstExpChip_fapi,
                                l_testEntry.addr,
                                l_scom_buffer );
                l_tests++;
                if(l_err)
                {
                    FAIL_TEST_RC(l_firstExpChip,
                                "testExpscomI2c>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X");

                }

                // putScom to last OCMB over i2c
                FAPI_INVOKE_HWP(l_err, fapi2::putScom,
                                l_lastExpChip_fapi,
                                  l_testEntry.addr,
                                l_scom_buffer );
                l_tests++;
                if(l_rc)
                {
                    FAIL_TEST_RC(l_lastExpChip,
                              "testExpscomI2c>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X");
                }


                // Flush scom buffers so it doesnt mess up next test
                l_scom_buffer.flush<0>();

                // getScom to first OCMB over i2c
                FAPI_INVOKE_HWP(l_err, fapi2::getScom,
                                l_firstExpChip_fapi,
                                l_testEntry.addr,
                                l_scom_buffer );
                l_tests++;
                if(l_rc)
                {
                    FAIL_TEST_RC(l_firstExpChip,
                                "testExpscomI2c>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X")
                }

                l_tests++;
                if(l_scom_buffer() != l_testEntry.data)
                {
                    l_fails++;
                    TS_FAIL("testExpscomI2c>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
                            l_testEntry.data,
                            l_scom_buffer(),
                            get_huid(l_firstExpChip));
                }

                // Flush scom buffers so it doesnt mess up next test
                l_scom_buffer.flush<0>();

                // getScom to last OCMB over i2c
                FAPI_INVOKE_HWP(l_err, fapi2::getScom,
                                l_lastExpChip_fapi,
                                l_testEntry.addr,
                                l_scom_buffer );
                l_tests++;
                if(l_rc)
                {
                    FAIL_TEST_RC(l_lastExpChip,
                                "testExpscomI2c>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X")
                }

                l_tests++;
                if(l_scom_buffer() != l_testEntry.data)
                {
                    l_fails++;
                    TS_FAIL("testExpscomI2c>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
                            l_testEntry.data,
                            l_scom_buffer(),
                            get_huid(l_lastExpChip));
                }
            }

            // Set ATTR_SCOM_SWITCHES back to their original values
            l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info);
            l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info);
        }while(0);

        TRACFCOMP( g_trac_expscom, "<< Exit  testExpscomI2c");
        return;
    }

    void testExpscomI2cPlatform(void)
    {

        TRACFCOMP( g_trac_expscom, ">> Enter  testExpscomI2c");
        // Keep trace of pass/fails
        uint32_t l_tests = 0;
        uint32_t l_fails = 0;
        errlHndl_t l_err = nullptr;
        size_t l_scomSize = sizeof(uint64_t);

        // Fapi interfaces will be used in these tests so this variable
        // will be used to hold error from fapi calls
        fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
        fapi2::buffer<uint64_t> l_scom_buffer;

        // Get the system's OCMB chips, we will use these as test targets
        TargetHandleList l_explorerList;

        do{

            getAllChips( l_explorerList,
                          TYPE_OCMB_CHIP,
                          true ); // true: return functional OCMBs


            if(l_explorerList.size() == 0 )
            {
                TRACFCOMP( g_trac_expscom, "No OCMB targets found, skipping testExpscomI2cPlatform");
                break;
            }

            // We will use the first and last targets for these scom tests
            auto l_firstExpChip = l_explorerList.front();
            auto l_lastExpChip  = l_explorerList.back();

            // Save away original scom switch info so we can restore it at the end of the test
            auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
            auto last_ocmb_info  = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();

            // This goal of this tests is to make sure I2C scom to OCMB is working so force
            // scom to go over I2C path for these targets
            l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
            l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);

            // Loop through table for first and last OCMB targets
            for( uint32_t l_num=0; l_num < g_expscomAddrTableSz; l_num++)
            {
                  // Read the test entry info from the global table at the top of this file
                  testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num];

                  if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR)
                  {
                      // If this is an IBM address then we expect 64 bits of data
                      l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data);
                  }
                  else
                  {
                      // Otherwise we know this is a native OCMB address and it is only 32 bits
                      l_scom_buffer.insert<32,32,0,uint32_t>(l_testEntry.data);
                  }
                  l_err = deviceWrite(l_firstExpChip,
                                    &l_scom_buffer,
                                    l_scomSize,
                                    DEVICE_SCOM_ADDRESS( l_testEntry.addr));
                  l_tests++;
                  if(l_err)
                  {
                      FAIL_TEST_ERRL(l_firstExpChip,
                                "testExpscomI2c>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X");

                  }

                  l_err = deviceWrite(l_lastExpChip,
                                      &l_scom_buffer,
                                      l_scomSize,
                                      DEVICE_SCOM_ADDRESS( l_testEntry.addr));
                  l_tests++;
                  if(l_err)
                  {
                      FAIL_TEST_ERRL(l_firstExpChip,
                                    "testExpscomI2c>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X");

                  }
                  // Flush scom buffers so it doesnt mess up next test
                  l_scom_buffer.flush<0>();

                  // getScom to first OCMB over i2c
                  l_err = deviceRead(l_firstExpChip,
                                    &l_scom_buffer(),
                                    l_scomSize,
                                    DEVICE_SCOM_ADDRESS( l_testEntry.addr));
                  l_tests++;
                  if(l_err)
                  {
                      FAIL_TEST_ERRL(l_firstExpChip,
                                "testExpscomI2c>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X")
                  }

                  l_tests++;
                  if(l_scom_buffer() != l_testEntry.data)
                  {
                      l_fails++;
                      TS_FAIL("testExpscomI2c>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
                            l_testEntry.data,
                            l_scom_buffer(),
                            get_huid(l_firstExpChip));
                  }


                  // Flush scom buffers so it doesnt mess up next test
                  l_scom_buffer.flush<0>();

                  // getScom to last OCMB over i2c
                  l_err = deviceRead(l_lastExpChip,
                                     &l_scom_buffer(),
                                     l_scomSize,
                                     DEVICE_SCOM_ADDRESS( l_testEntry.addr));
                  l_tests++;
                  if(l_err)
                  {
                      FAIL_TEST_ERRL(l_firstExpChip,
                                     "testExpscomI2c>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X")
                  }

                  l_tests++;
                  if(l_scom_buffer() != l_testEntry.data)
                  {
                      l_fails++;
                      TS_FAIL("testExpscomI2c>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
                              l_testEntry.data,
                              l_scom_buffer(),
                              get_huid(l_firstExpChip));
                  }
            }

            // Set ATTR_SCOM_SWITCHES back to their original values
            l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info);
            l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info);
        }while(0);

        TRACFCOMP( g_trac_expscom, "<< Exit  testExpscomI2c");
        return;
    }

// TODO RTC: 189447 Enable MMIO tests when MMIO drivers avail
     /**
     * @brief EXPSCOM test MMIO
     *        Write value and read back to verify MMIO scoms to OCMBs
     */
//     void testExpscomMmio(void)
//     {
//         TargetHandleList l_explorerList;
//         uint32_t l_tests = 0;
//         uint32_t l_fails = 0;
//         errlHndl_t l_err = nullptr;
//         fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
//         fapi2::buffer<uint64_t> l_scom_buffer;
//
//         // Get the system's procs
//         getAllChips( l_explorerList,
//                      TYPE_OCMB_CHIP,
//                      true ); // true: return functional OCMBs
//
//         auto l_firstExpChip = l_explorerList.front();
//         auto l_lastExpChip  = l_explorerList.back();
//
//         fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_firstExpChip_fapi(l_firstExpChip);
//         fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_lastExpChip_fapi(l_lastExpChip);
//
//         auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
//         auto last_ocmb_info  = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
//
//
//         // Loop through table for first and last OCMB, perform i2c write, then
//         // mmio read, and mmio write followed by i2c read.
//         for( uint32_t l_num=0; l_num < g_expscomAddrTableSz; l_num++)
//         {
//               testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num];
//               if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR)
//               {
//                   l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data);
//               }
//               else
//               {
//                   l_scom_buffer.insert<0,32,0,uint32_t>(l_testEntry.data);
//               }
//
//              // putScom to first OCMB over mmio
//              l_rc = fapi2::putScom(l_firstExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_firstExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//
//              // putScom to last OCMB over mmio
//              l_rc = fapi2::putScom(l_lastExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_lastExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//
//              // Flush scom buffer so it doesnt mess up next test
//              l_scom_buffer.flush<0>();
//
//
//              // getScom to first OCMB over mmio
//              l_rc = fapi2::getScom(l_firstExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_firstExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//
//              l_tests++;
//              if(l_scom_buffer() != l_testEntry.data)
//              {
//                l_fails++;
//                 TS_FAIL("testExpscomMmio>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_scom_buffer(),
//                         get_huid(l_firstExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//
//              // Flush scom buffer so it doesnt mess up next test
//              l_scom_buffer.flush<0>();
//
//              // getScom to last OCMB over mmio
//              l_rc = fapi2::getScom(l_lastExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_lastExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//
//              l_tests++;
//              if(l_scom_buffer() != l_testEntry.data)
//              {
//                l_fails++;
//                 TS_FAIL("testExpscomMmio>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_scom_buffer(),
//                         get_huid(l_lastExpChip));
//                 l_err = fapi2::rcToErrl(l_rc);
//                 errlCommit(l_err, 0x10);
//              }
//         }
//         // Set ATTR_SCOM_SWITCHES back to their original values
//         l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info);
//         l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info);
//         return;
//   }

      /**
    * @brief EXPSCOM test MMIO
    *        Write value and read back to verify MMIO
    */
//   void testExpscomCombined(void)
//   {
//         TargetHandleList l_explorerList;
//         uint32_t l_tests = 0;
//         uint32_t l_fails = 0;
//         fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS;
//         fapi2::buffer<uint64_t> l_scom_buffer;
//
//         // Get the system's procs
//         getAllChips( l_explorerList,
//                      TYPE_OCMB_CHIP,
//                      true ); // true: return functional OCMBs
//
//         auto l_firstExpChip = l_explorerList.front();
//         auto l_lastExpChip  = l_explorerList.back();
//
//         fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_firstExpChip_fapi(l_firstExpChip);
//         fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> l_lastExpChip_fapi(l_lastExpChip);
//
//        auto first_ocmb_info = l_firstExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
//         auto last_ocmb_info  = l_lastExpChip->getAttr<TARGETING::ATTR_SCOM_SWITCHES>();
//
//         // Loop through table for first and last OCMB
//         for( uint32_t l_num=0; l_num < g_expscomAddrTableSz; l_num++)
//         {
//              testExpscomAddrData l_testEntry = g_expscomAddrTable[l_num];
//
//               if(l_testEntry.addr & mss::exp::i2c::IBM_SCOM_INDICATOR)
//               {
//                   l_scom_buffer.insert<0,64,0,uint64_t>(l_testEntry.data);
//               }
//               else
//               {
//                   l_scom_buffer.insert<0,32,0,uint32_t>(l_testEntry.data);
//               }
//
//             // ODD tests  : first target writes MMIO, last target writes I2C
//             // EVEN tests : first target writes I2C, last target writes MMIO
//             if(l_num % 2)
//             {
//                 l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceMMIOScom);
//                 l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
//             }
//             else
//             {
//                 l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
//                 l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceMMIOScom);
//             }
//
//              // putScom to first OCMB over mmio
//              l_rc = fapi2::putScom(l_firstExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_firstExpChip));
//              }
//
//              // putScom to last OCMB over mmio
//              l_rc = fapi2::putScom(l_lastExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed putScom writing 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_lastExpChip));
//              }
//
//              // Flush scom buffer so it doesnt mess up next test
//              l_scom_buffer.flush<0>();
//
//              // getScom to first OCMB over mmio
//              l_rc = fapi2::getScom(l_firstExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_firstExpChip));
//              }
//
//              l_tests++;
//              if(l_scom_buffer() != l_testEntry.data)
//              {
//                l_fails++;
//                 TS_FAIL("testExpscomMmio>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_scom_buffer(),
//                         get_huid(l_firstExpChip));
//              }
//
//             // ODD tests  : first target reads I2C, last target reads MMIO
//             // EVEN tests : first target reads MMIO, last target reads I2C
//             if(l_num % 2)
//             {
//                 l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
//                 l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceMMIOScom);
//             }
//             else
//             {
//                 l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceMMIOScom);
//                 l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(forceI2CScom);
//             }
//
//              // Flush scom buffer so it doesnt mess up next test
//              l_scom_buffer.flush<0>();
//
//              // getScom to last OCMB over mmio
//              l_rc = fapi2::getScom(l_lastExpChip_fapi,
//                                    l_testEntry.addr,
//                                    l_scom_buffer);
//              l_tests++;
//              if(l_rc)
//              {
//                 l_fails++;
//                 TS_FAIL("testExpscomMmio>> Failed getScom reading 0x%.16X to 0x%.8X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_testEntry.addr,
//                         get_huid(l_lastExpChip));
//              }
//
//              l_tests++;
//              if(l_scom_buffer() != l_testEntry.data)
//              {
//                l_fails++;
//                 TS_FAIL("testExpscomMmio>> Expected 0x%.16X but got 0x%.16X on target w/ huid 0x%.8X",
//                         l_testEntry.data,
//                         l_scom_buffer(),
//                         get_huid(l_lastExpChip));
//              }
//         }
//         // Set ATTR_SCOM_SWITCHES back to their original values
//         l_firstExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(first_ocmb_info);
//         l_lastExpChip->setAttr<TARGETING::ATTR_SCOM_SWITCHES>(last_ocmb_info);
//         return;
//   }


};

#endif
OpenPOWER on IntegriCloud