summaryrefslogtreecommitdiffstats
path: root/src/usr/htmgt/htmgt_cfgdata.C
blob: ef9915160aacb4ec9b7afb3eabdb9b3b14c94bf2 (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
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/htmgt/htmgt_cfgdata.C $                               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,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 <targeting/common/commontargeting.H>
#include <targeting/common/attributes.H>
#include <targeting/common/utilFilter.H>
#include "htmgt_cfgdata.H"
#include "htmgt_utility.H"
#include "htmgt_poll.H"
#include "ipmi/ipmisensor.H"
#include <htmgt/htmgt_reasoncodes.H>
#include <fapi2_attribute_service.H>
#include "htmgt_memthrottles.H"

using namespace TARGETING;


//for unit testing
//#define TRACUCOMP(args...)  TMGT_INF(args)
#define TRACUCOMP(args...)

namespace HTMGT
{

    bool G_wofSupported = true;
    uint8_t G_system_type = OCC_CFGDATA_OPENPOWER_OPALVM;

    // Send config format data to all OCCs
    void sendOccConfigData(const occCfgDataFormat i_requestedFormat)
    {
        if (G_debug_trace & DEBUG_TRACE_VERBOSE)
        {
            TMGT_INF("sendOccConfigData called");
        }

        uint8_t cmdData[OCC_MAX_DATA_LENGTH] = {0};

        const occCfgDataTable_t* start = &occCfgDataTable[0];
        const occCfgDataTable_t* end =
            &occCfgDataTable[OCC_CONFIG_TABLE_SIZE];
        bool validFormat = true;
        if (OCC_CFGDATA_CLEAR_ALL != i_requestedFormat)
        {
            const occCfgDataTable_t * target =
                std::find(start, end, i_requestedFormat);
            if (target != end)
            {
                // only need to send a single packet
                start = target;
                end = start+1;
            }
            else
            {
                TMGT_ERR("sendOccConfigData: Invalid cfg format supplied %d",
                         i_requestedFormat);
                validFormat = false;
            }
        }

        if (validFormat)
        {
            // Loop through all functional OCCs
            std::vector<Occ*> occList = OccManager::getOccArray();
            for (std::vector<Occ*>::iterator itr = occList.begin();
                 itr < occList.end();
                 itr++)
            {
                Occ * occ = (*itr);
                const uint8_t occInstance = occ->getInstance();
                const occRole role = occ->getRole();

                // Loop through all config data types
                for (const occCfgDataTable_t *itr = start; itr < end; ++itr)
                {
                    const occCfgDataFormat format = itr->format;
                    bool sendData = true;

                    // Make sure format is supported by this OCC
                    if (TARGET_MASTER == itr->targets)
                    {
                        if (OCC_ROLE_MASTER != role)
                        {
                            sendData = false;
                        }
                    }

                    // Make sure data is supported in the current state
                    const occStateId state = occ->getState();
                    if (CFGSTATE_STANDBY == itr->supportedStates)
                    {
                        if (OCC_STATE_STANDBY != state)
                        {
                            sendData = false;
                        }
                    }
                    else if (CFGSTATE_SBYOBS == itr->supportedStates)
                    {
                        if ((OCC_STATE_STANDBY != state) &&
                            (OCC_STATE_OBSERVATION != state))
                        {
                            sendData = false;
                        }
                    }

                    if (sendData)
                    {
                        uint64_t cmdDataLen = 0;
                        switch(format)
                        {
                            case OCC_CFGDATA_FREQ_POINT:
                                getFrequencyPointMessageData(cmdData,
                                                             cmdDataLen);
                                break;

                            case OCC_CFGDATA_OCC_ROLE:
                                getOCCRoleMessageData(OCC_ROLE_MASTER ==
                                                      occ->getRole(),
                                                      OCC_ROLE_FIR_MASTER ==
                                                      occ->getRole(),
                                                      cmdData, cmdDataLen);
                                break;

                            case OCC_CFGDATA_APSS_CONFIG:
                                getApssMessageData(cmdData, cmdDataLen);
                                break;

                            case OCC_CFGDATA_MEM_CONFIG:
                                getMemConfigMessageData(occ->getTarget(),
                                                        cmdData, cmdDataLen);
                                break;

                            case OCC_CFGDATA_PCAP_CONFIG:
                                getPowerCapMessageData(cmdData, cmdDataLen);
                                break;

                            case OCC_CFGDATA_SYS_CONFIG:
                                getSystemConfigMessageData(occ->getTarget(),
                                                           cmdData, cmdDataLen);
                                break;

                            case OCC_CFGDATA_MEM_THROTTLE:
                                if (!int_flags_set(FLAG_DISABLE_MEM_CONFIG))
                                {
                                    getMemThrottleMessageData(occ->getTarget(),
                                             occInstance, cmdData, cmdDataLen);
                                }
                                break;

                            case OCC_CFGDATA_TCT_CONFIG:
                                getThermalControlMessageData(cmdData,
                                                             cmdDataLen);
                                break;

                            case OCC_CFGDATA_AVSBUS_CONFIG:
                                getAVSBusConfigMessageData( occ->getTarget(),
                                                            cmdData,
                                                            cmdDataLen );
                                break;

                            case OCC_CFGDATA_GPU_CONFIG:
                                getGPUConfigMessageData(occ->getTarget(),
                                                        cmdData,
                                                        cmdDataLen);
                                break;

                            default:
                                TMGT_ERR("sendOccConfigData: Unsupported"
                                         " format type 0x%02X",
                                         format);
                        }

                        if (cmdDataLen > 0)
                        {
                            TMGT_INF("sendOccConfigData: Sending config"
                                     " 0x%02X to OCC%d",
                                     format, occInstance);
                            OccCmd cmd(occ, OCC_CMD_SETUP_CFG_DATA,
                                       cmdDataLen, cmdData);
                            errlHndl_t l_err = cmd.sendOccCmd();
                            if (l_err != nullptr)
                            {
                                TMGT_ERR("sendOccConfigData: OCC%d cfg "
                                         "format 0x%02X failed with rc=0x%04X",
                                         occInstance, format,
                                         l_err->reasonCode());
                                ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
                            }
                            else
                            {
                                if (OCC_RC_SUCCESS != cmd.getRspStatus())
                                {
                                    TMGT_ERR("sendOccConfigData: OCC%d cfg "
                                             "format 0x%02X had bad rsp status"
                                             " 0x%02X",
                                             occInstance, format,
                                             cmd.getRspStatus());
                                }
                            }

                            // Send poll between config packets to flush errors
                            l_err = OccManager::sendOccPoll();
                            if (l_err)
                            {
                                ERRORLOG::errlCommit(l_err, HTMGT_COMP_ID);
                            }
                        }
                    } // if (sendData)

                    if (OccManager::occNeedsReset())
                    {
                        TMGT_ERR("sendOccConfigData(): OCCs need to be reset");
                    }

                } // for each config format

            } // for each OCC
        }

    } // end sendOccConfigData()


/** OCC configuration data message versions */
enum occCfgDataVersion
{
    OCC_CFGDATA_FREQ_POINT_VERSION    = 0x20,
    OCC_CFGDATA_APSS_VERSION          = 0x20,
    OCC_CFGDATA_PCAP_CONFIG_VERSION   = 0x20,
    OCC_CFGDATA_SYS_CONFIG_VERSION    = 0x21,
    OCC_CFGDATA_TCT_CONFIG_VERSION    = 0x20,
};


// Utility function for writing Memory Config data
void writeMemConfigData( uint8_t *& o_data,
                         TARGETING::Target * i_target,
                         TARGETING::SENSOR_NAME i_sensorState,
                         TARGETING::SENSOR_NAME i_sensorTemp,
                         uint8_t i_centPos,
                         uint8_t i_dimmPos,
                         uint8_t i_i2cPort,
                         uint8_t i_i2cDevAddr,
                         uint64_t & io_index )
{

    //Byte 0-3 Hardware Sensor ID
    uint32_t l_sensor = UTIL::getSensorNumber( i_target,i_sensorState );
    size_t l_dataSize = sizeof(l_sensor);
    memcpy(&o_data[io_index],
           reinterpret_cast<uint8_t*>(&l_sensor),
           l_dataSize);
    io_index += l_dataSize;

    //Byte 4-7 Temperature Sensor ID
    l_sensor = UTIL::getSensorNumber( i_target,i_sensorTemp );
    memcpy(&o_data[io_index],
           reinterpret_cast<uint8_t*>(&l_sensor),
           l_dataSize);
    io_index += l_dataSize;

    //Byte 8  Nimbus     indicator
    //        Cumulus     (Centaur #)
    o_data[io_index++] = i_centPos;

    //Byte 9  Nimbus     PIB I2C Master Engine
    //        Cumulus    (DIMM #)
    o_data[io_index++] = i_dimmPos;

    //Byte 10 Nimbus    DIMM I2C Port(0,1)
    //        Cumulus   Reserved for Cumulus
    o_data[io_index++] = i_i2cPort;

    //Byte 11 Nimbus    DIMM Temp i2c address
    //        Cumulus   Reserved for Cumulus
    o_data[io_index++] = i_i2cDevAddr;
}


void getMemConfigMessageData(const TargetHandle_t i_occ,
                             uint8_t* o_data, uint64_t & o_size)
{
    uint64_t index = 0;

    assert(o_data != nullptr);

    o_data[index++] = OCC_CFGDATA_MEM_CONFIG;
    o_data[index++] = 0x21; // version

    //System reference needed for these ATTR.
    Target* sys = nullptr;
    targetService().getTopLevelTarget(sys);

    if( is_sapphire_load() )//if OPAL then no "Power Control Default" support.
    {
        //Byte 3:   Memory Power Control Default.
        o_data[index++] = 0xFF;

        //Byte 4:   Idle Power Memory Power Control.
        o_data[index++] = 0xFF;
    }
    else                    //else read in attr.
    {
        //Byte 3:   Memory Power Control Default.
        o_data[index++] = sys->getAttr<ATTR_MSS_MRW_POWER_CONTROL_REQUESTED>();

        //Byte 4:   Idle Power Memory Power Control.
        o_data[index++] =
                    sys->getAttr<ATTR_MSS_MRW_IDLE_POWER_CONTROL_REQUESTED>();
    }

    //Byte 5:   Number of data sets.
    size_t numSetsOffset = index++; //Will fill in numSets at the end

    if (!int_flags_set(FLAG_DISABLE_MEM_CONFIG))
    {
        TargetHandleList centaurs;
        TargetHandleList mbas;
        TargetHandleList dimms;
        uint8_t centPos = 0;
        uint8_t dimmPos = 0;
        uint8_t numSets = 0;

        ConstTargetHandle_t proc = getParentChip(i_occ);
        assert(proc != nullptr);

        // Save Processor Model for later
        ATTR_MODEL_type l_procModel = proc->getAttr<ATTR_MODEL>();

        if( l_procModel == MODEL_CUMULUS )
        {
            getChildAffinityTargets(centaurs, proc, CLASS_CHIP, TYPE_MEMBUF);

            TRACUCOMP("Proc 0x%X has %d centaurs",
                      proc->getAttr<ATTR_HUID>(),
                      centaurs.size());

            for ( const auto & centaur : centaurs )
            {
                numSets++;

                // TODO: RTC 163359 - OCC centaur support
                // Get the Centaur position
                centPos = centaur->getAttr<ATTR_POSITION>();
                // ATTR_POSISTION is system wide. Must be 0-7 on each OCC
                centPos = centPos%8;

                //Do the entry for the Centaur itself
                writeMemConfigData( o_data,
                                    centaur,
                                    SENSOR_NAME_MEMBUF_STATE,
                                    SENSOR_NAME_MEMBUF_TEMP,
                                    centPos,
                                    0xFF, //0xFF since a centaur
                                    0,    //Reserved for CUMULUS
                                    0,    //" "
                                    index );

                mbas.clear();
                getChildAffinityTargets(mbas, centaur,
                                        CLASS_UNIT, TYPE_MBA);

                for ( const auto & mba : mbas )
                {
                    dimms.clear();
                    getChildAffinityTargets(dimms, mba,
                                            CLASS_LOGICAL_CARD, TYPE_DIMM);

                    TRACUCOMP("MBA 0x%X has %d DIMMs",
                              mba->getAttr<ATTR_HUID>(), dimms.size());

                    for ( const auto & dimm : dimms )
                    {
                        numSets++;

                        // get the DIMM #
                        dimmPos = getOCCDIMMPos( mba, dimm );

                        // Fill in the DIMM entry
                        writeMemConfigData( o_data,
                                        dimm,
                                        SENSOR_NAME_DIMM_STATE,
                                        SENSOR_NAME_DIMM_TEMP,
                                        centPos,
                                        dimmPos,
                                        0,      //Reserved for CUMULUS
                                        0,      //"  "
                                        index );
                    }
                }
            }
        }
        else if( l_procModel == MODEL_NIMBUS )
        {
            // DIMMs are wired directly to the proc in Nimbus
            dimms.clear();
            getChildAffinityTargets( dimms,
                                     proc,
                                     CLASS_LOGICAL_CARD,
                                     TYPE_DIMM );

            for( const auto & dimm : dimms )
            {
                numSets++;

                // Get PIB I2C Master engine for this dimm
                ATTR_TEMP_SENSOR_I2C_CONFIG_type tempI2cCfgData =
                    dimm->getAttr<ATTR_TEMP_SENSOR_I2C_CONFIG>();

                // Fill in the DIMM entry
                writeMemConfigData( o_data,
                                dimm,
                                SENSOR_NAME_DIMM_STATE,//Bytes 0-3:HW sensor ID
                                SENSOR_NAME_DIMM_TEMP, //Bytes 4-7:TMP sensor ID
                                0xFF,                  //Bytes 8:MEM Nimbus,
                                tempI2cCfgData.engine, //Byte 9: DIMM Info byte1
                                tempI2cCfgData.port,   //Byte 10:DIMM Info byte2
                                tempI2cCfgData.devAddr,//Byte 11:DIMM Info byte3
                                index );
            }
        }//End MODEL_NIMBUS

        TMGT_INF("getMemConfigMessageData: returning %d"
                 " sets of data for OCC 0x%X",
                 numSets, i_occ->getAttr<ATTR_HUID>());

        o_data[numSetsOffset] = numSets;
    }
    else
    {
        TMGT_INF("getMemConfigMessageData: Mem monitoring is disabled");

        //A zero in byte 5 (numSets) means monitoring is disabled
        o_data[numSetsOffset] = 0;
    }

    o_size = index;

}




void getMemThrottleMessageData(const TargetHandle_t i_occ,
                               const uint8_t i_occ_instance,
                               uint8_t* o_data, uint64_t & o_size)
{
    uint8_t numSets = 0;
    uint64_t index = 0;

    ConstTargetHandle_t proc = getParentChip(i_occ);
    assert(proc != nullptr);
    assert(o_data != nullptr);

    //Get all functional MCSs
    TargetHandleList mcs_list;
    getAllChiplets(mcs_list, TYPE_MCS, true);
    TMGT_INF("getMemThrottleMessageData: found %d MCSs", mcs_list.size());

    o_data[index++] = OCC_CFGDATA_MEM_THROTTLE;
    o_data[index++] = 0x20; // version;

    //Byte 3:   Number of memory throttling data sets.
    size_t numSetsOffset = index++; //Will fill in numSets at the end

    //Next, the following format repeats per set/MBA:
    //Byte 0:       Cumulus: Centaur position 0-7
    //              Nimbus : Memory Controller
    //Byte 1:       Cumulus: MBA Position 0-1
    //              Nimbus : Memory Controller's physical Port # 0-3
    //Bytes 2-3:    min N_PER_MBA
    //Bytes 4-5:    Max mem power with throttle @Min
    //Bytes 6-7:    Turbo N_PER_MBA
    //Bytes 8-9:    Turbo N_PER_CHIP
    //Bytes 10-11:  Max mem power with throttle @Turbo
    //Bytes 12-13:  Power Capping N_PER_MBA
    //Bytes 14-15:  Power Capping N_PER_CHIP
    //Bytes 16-17:  Max mem power with throttle @PowerCapping
    //Bytes 18-19:  Nominal Power N_PER_MBA
    //Bytes 20-21:  Nominal Power N_PER_CHIP
    //Bytes 22-23:  Max mem power with throttle @Nominal
    //Bytes 24-29:  Reserved

    for(const auto & mcs_target : mcs_list)
    {
        uint8_t mcs_unit = 0xFF;
        if (!mcs_target->tryGetAttr<TARGETING::ATTR_CHIP_UNIT>(mcs_unit))
        {
            uint32_t mcs_huid = 0xFFFFFFFF;
            mcs_target->tryGetAttr<TARGETING::ATTR_HUID>(mcs_huid);
            TMGT_ERR("getMemThrottleMessageData: Unable to determine MCS unit"
                     " for HUID 0x%04X", mcs_huid);
            continue;
        }
        ConstTargetHandle_t proc_target = getParentChip(mcs_target);
        assert(proc_target != nullptr);

        // Make sure this MCS is for the current OCC/Proc
        if (i_occ_instance == proc_target->getAttr<TARGETING::ATTR_POSITION>())
        {
            // Read the throttle and power values for this MCS
            ATTR_OT_MIN_N_PER_MBA_type npm_min;
            ATTR_OT_MEM_POWER_type power_min;
            mcs_target->tryGetAttr<ATTR_OT_MIN_N_PER_MBA>(npm_min);
            mcs_target->tryGetAttr<ATTR_OT_MEM_POWER>(power_min);
            ATTR_N_PLUS_ONE_N_PER_MBA_type npm_redun;
            ATTR_N_PLUS_ONE_N_PER_CHIP_type npc_redun;
            ATTR_N_PLUS_ONE_MEM_POWER_type power_redun;
            mcs_target->tryGetAttr<ATTR_N_PLUS_ONE_N_PER_MBA>(npm_redun);
            mcs_target->tryGetAttr<ATTR_N_PLUS_ONE_N_PER_CHIP>(npc_redun);
            mcs_target->tryGetAttr<ATTR_N_PLUS_ONE_MEM_POWER>(power_redun);
            ATTR_POWERCAP_N_PER_MBA_type npm_pcap;
            ATTR_POWERCAP_N_PER_CHIP_type npc_pcap;
            ATTR_POWERCAP_MEM_POWER_type power_pcap;
            mcs_target->tryGetAttr<ATTR_POWERCAP_N_PER_MBA>(npm_pcap);
            mcs_target->tryGetAttr<ATTR_POWERCAP_N_PER_CHIP>(npc_pcap);
            mcs_target->tryGetAttr<ATTR_POWERCAP_MEM_POWER>(power_pcap);

            // Query the functional MCAs for this MCS
            TARGETING::TargetHandleList mca_list;
            getChildAffinityTargetsByState(mca_list, mcs_target, CLASS_UNIT,
                                           TYPE_MCA, UTIL_FILTER_FUNCTIONAL);
            for(const auto & mca_target : mca_list)
            {
                // unit identifies unique MCA under a processor
                uint8_t mca_unit = 0xFF;
                mca_target->tryGetAttr<TARGETING::ATTR_CHIP_UNIT>(mca_unit);
                const uint8_t mca_rel_pos = mca_unit % 2;
                if ((npm_min[mca_rel_pos] == 0) ||
                    (npm_redun[mca_rel_pos] == 0) ||
                    (npm_pcap[mca_rel_pos] == 0))
                {
                    TMGT_ERR("getMemThrottleMessageData: MCS%d/MCA%d [%d]"
                             " - Ignored due to null throttle",
                             mcs_unit, mca_unit, mca_rel_pos);
                    TMGT_ERR("N/slot: Min=%d, Turbo=%d, Pcap=%d",
                             npm_min[mca_rel_pos], npm_redun[mca_rel_pos],
                             npm_pcap[mca_rel_pos]);
                    continue;
                }
                if (mca_rel_pos >= TMGT_MAX_MCA_PER_MCS)
                {
                    TMGT_ERR("getMemThrottleMessageData: OCC%d / MCS%d / MCA%d"
                             " - Ignored due invalid MCA position: %d",
                             i_occ_instance, mcs_unit, mca_unit, mca_rel_pos);
                    continue;
                }
                TMGT_INF("getMemThrottleMessageData: OCC%d / MCS%d / MCA%d [%d]"
                         , i_occ_instance, mcs_unit, mca_unit, mca_rel_pos);
                // OCC expects phyMC=0 for (MCS0-1) and 1 for (MCS2-3)
                //  MCS   MCA  MCA    OCC   OCC
                // unit  unit relPos phyMC phyPort
                //   0     0    0      0     0
                //   0     1    1      0     1
                //   1     2    0      0     2
                //   1     3    1      0     3
                //   2     4    0      1     0
                //   2     5    1      1     1
                //   3     6    0      1     2
                //   3     7    1      1     3
                o_data[index] = mcs_unit >> 1; // MC (0-1)
                o_data[index+1] = mca_unit % 4; // Phy Port (0-3)
                // Minimum
                UINT16_PUT(&o_data[index+ 2], npm_min[mca_rel_pos]);
                UINT16_PUT(&o_data[index+ 4], power_min[mca_rel_pos]);
                // Turbo
                UINT16_PUT(&o_data[index+ 6], npm_redun[mca_rel_pos]);
                UINT16_PUT(&o_data[index+ 8], npc_redun[mca_rel_pos]);
                UINT16_PUT(&o_data[index+10], power_redun[mca_rel_pos]);
                // Power Capping
                UINT16_PUT(&o_data[index+12], npm_pcap[mca_rel_pos]);
                UINT16_PUT(&o_data[index+14], npc_pcap[mca_rel_pos]);
                UINT16_PUT(&o_data[index+16], power_pcap[mca_rel_pos]);
                // Nominal (same as Turbo)
                UINT16_PUT(&o_data[index+18], npm_redun[mca_rel_pos]);
                UINT16_PUT(&o_data[index+20], npc_redun[mca_rel_pos]);
                UINT16_PUT(&o_data[index+22], power_redun[mca_rel_pos]);
                index += 30;
                ++numSets ;
            }
        }
    }

    TMGT_INF("getMemThrottleMessageData: returning %d"
             " sets of data for OCC 0x%X",
             numSets, i_occ->getAttr<ATTR_HUID>());

    o_data[numSetsOffset] = numSets;

    o_size = index;

}



void getOCCRoleMessageData(bool i_master, bool i_firMaster,
                           uint8_t* o_data, uint64_t & o_size)
{
    assert(o_data != nullptr);

    o_data[0] = OCC_CFGDATA_OCC_ROLE;

    o_data[1] = OCC_ROLE_SLAVE;

    if (i_master)
    {
        o_data[1] = OCC_ROLE_MASTER;
    }

    if (i_firMaster)
    {
        o_data[1] |= OCC_ROLE_FIR_MASTER;
    }

    o_size = 2;
}


uint16_t getMaxPowerCap(Target *i_sys, bool & o_is_redundant)
{
    uint16_t o_maxPcap = 0;
    o_is_redundant = true;

#ifdef CONFIG_BMC_IPMI
    // Check if HPC limit was found
    ATTR_OPEN_POWER_N_PLUS_ONE_HPC_BULK_POWER_LIMIT_WATTS_type hpc_pcap;
    if (i_sys->tryGetAttr
        <ATTR_OPEN_POWER_N_PLUS_ONE_HPC_BULK_POWER_LIMIT_WATTS>(hpc_pcap))
    {
        if (0 != hpc_pcap)
        {
            // Check if redundant power supply policy is enabled (on BMC)
            SENSOR::getSensorReadingData redPolicyData;
            SENSOR::SensorBase
                redPolicySensor(TARGETING::SENSOR_NAME_REDUNDANT_PS_POLICY,
                                i_sys);
            errlHndl_t err = redPolicySensor.readSensorData(redPolicyData);
            if (nullptr == err)
            {
                // 0x02 == Asserted bit (redundant policy is enabled)
                if ((redPolicyData.event_status & 0x02) == 0x00)
                {
                    // non-redundant policy allows higher bulk power limit
                    // with the potential impact of OCC not being able to
                    // lower power fast enough
                    o_is_redundant = false;
                    TMGT_INF("getMaxPowerCap: maximum power cap = %dW"
                             " (HPC/non-redundant PS bulk power limit)",
                             hpc_pcap);
                    o_maxPcap = hpc_pcap;
                }
                // else redundant policy enabled, use default
            }
            else
            {
                // error reading policy, commit and use default
                TMGT_ERR("getMaxPowerCap: unable to read power supply"
                         " redundancy policy sensor, rc=0x%04X",
                         err->reasonCode());
                ERRORLOG::errlCommit(err, HTMGT_COMP_ID);
            }
        }
        // else no valid HPC limit, use default
    }
    // else HPC limit not found, use default
#endif

    if (o_is_redundant)
    {
        // Read the default N+1 bulk power limit (redundant PS policy)
        o_maxPcap = i_sys->
            getAttr<ATTR_OPEN_POWER_N_PLUS_ONE_BULK_POWER_LIMIT_WATTS>();
        TMGT_INF("getMaxPowerCap: maximum power cap = %dW "
                 "(redundant PS bulk power limit)", o_maxPcap);
    }

    return o_maxPcap;

} // end getMaxPowerCap()


void getPowerCapMessageData(uint8_t* o_data, uint64_t & o_size)
{
    uint64_t index = 0;

    Target* sys = nullptr;
    targetService().getTopLevelTarget(sys);

    assert(sys != nullptr);
    assert(o_data != nullptr);

    o_data[index++] = OCC_CFGDATA_PCAP_CONFIG;
    o_data[index++] = OCC_CFGDATA_PCAP_CONFIG_VERSION;

    // Minimum HARD Power Cap
    ATTR_OPEN_POWER_MIN_POWER_CAP_WATTS_type min_pcap =
        sys->getAttr<ATTR_OPEN_POWER_MIN_POWER_CAP_WATTS>();

    // Minimum SOFT Power Cap
    ATTR_OPEN_POWER_SOFT_MIN_PCAP_WATTS_type soft_pcap;
    if ( ! sys->tryGetAttr
            <ATTR_OPEN_POWER_SOFT_MIN_PCAP_WATTS>(soft_pcap))
    {
        // attr does not exist (us min)
        soft_pcap = min_pcap;
    }
    UINT16_PUT(&o_data[index], soft_pcap);
    index += 2;

    // Minimum Hard Power Cap
    UINT16_PUT(&o_data[index], min_pcap);
    index += 2;

    // System Maximum Power Cap
    bool is_redundant;
    const uint16_t max_pcap = getMaxPowerCap(sys, is_redundant);
    UINT16_PUT(&o_data[index], max_pcap);
    index += 2;

    // Quick Power Drop Power Cap
    ATTR_OPEN_POWER_N_BULK_POWER_LIMIT_WATTS_type qpd_pcap;
    if ( ! sys->tryGetAttr
         <ATTR_OPEN_POWER_N_BULK_POWER_LIMIT_WATTS>(qpd_pcap))
    {
        // attr does not exist, so disable by sending 0
        qpd_pcap = 0;
    }
    UINT16_PUT(&o_data[index], qpd_pcap);
    index += 2;

    TMGT_INF("getPowerCapMessageData: pcaps - soft min: %d, min: %d, max: %d,"
             " qpd: %d (in Watts)",
             soft_pcap, min_pcap, max_pcap, qpd_pcap);
    o_size = index;
}



void getSystemConfigMessageData(const TargetHandle_t i_occ, uint8_t* o_data,
                                uint64_t & o_size)
{
    uint64_t index = 0;
    uint32_t SensorID1 = 0;
    uint32_t SensorID2 = 0;
    assert(o_data != nullptr);

    TargetHandle_t sys = nullptr;
    TargetHandleList nodes;
    targetService().getTopLevelTarget(sys);
    assert(sys != nullptr);
    getChildAffinityTargets(nodes, sys, CLASS_ENC, TYPE_NODE);
    assert(!nodes.empty());
    TargetHandle_t node = nodes[0];

    o_data[index++] = OCC_CFGDATA_SYS_CONFIG;
    o_data[index++] = OCC_CFGDATA_SYS_CONFIG_VERSION;

    //System Type
    uint8_t l_throttle_below_nominal = 0;
    if(!sys->tryGetAttr
        <ATTR_REPORT_THROTTLE_BELOW_NOMINAL>(l_throttle_below_nominal))
    {
        l_throttle_below_nominal = 0;  // attr does not exist, disable
    }
    if (l_throttle_below_nominal == 1)
    {
        //1=OCC report throttling only when max frequency lowered below nominal
        G_system_type |= OCC_REPORT_THROTTLE_BELOW_NOMINAL;
    }
    else
    {
        //0=OCC report throttling when max frequency lowered below turbo
        G_system_type &= ~OCC_REPORT_THROTTLE_BELOW_NOMINAL;
    }
    bool is_redundant;
    getMaxPowerCap(sys, is_redundant);
    if (is_redundant == false)
    {
        // Power supply policy is non-redundant
        G_system_type |= OCC_CFGDATA_NON_REDUNDANT_PS;
    }
    else
    {
        // Power supply policy is redundant
        G_system_type &= ~OCC_CFGDATA_NON_REDUNDANT_PS;
    }
    o_data[index++] = G_system_type;

    //processor Callout Sensor ID
    ConstTargetHandle_t proc = getParentChip(i_occ);
    SensorID1 = UTIL::getSensorNumber(proc, SENSOR_NAME_PROC_STATE);
    memcpy(&o_data[index], &SensorID1, 4);
    index += 4;

    //Next 12*4 bytes are for core sensors.
    //If a new processor with more cores comes along,
    //this command will have to change.
    TargetHandleList cores;
    getChildChiplets(cores, proc, TYPE_CORE, false);

    TMGT_INF("getSystemConfigMessageData: systemType: 0x%02X, "
             "procSensor: 0x%04X, %d cores, %d nodes",
             G_system_type, SensorID1, cores.size(), nodes.size());

    for (uint64_t core=0; core<CFGDATA_CORES; core++)
    {
        SensorID1 = 0;
        SensorID2 = 0;

        if ( core < cores.size() )
        {
            SensorID1 = UTIL::getSensorNumber(cores[core],     //Temp Sensor
                                               SENSOR_NAME_CORE_TEMP);

            SensorID2 = UTIL::getSensorNumber(cores[core],     //Freq Sensor
                                               SENSOR_NAME_CORE_FREQ);
        }

        //Core Temp Sensor ID
        memcpy(&o_data[index], &SensorID1, 4);
        index += 4;

        //Core Frequency Sensor ID
        memcpy(&o_data[index], &SensorID2, 4);
        index += 4;
    }

    //Backplane Callout Sensor ID
    SensorID1 = UTIL::getSensorNumber(node, SENSOR_NAME_BACKPLANE_FAULT);
    memcpy(&o_data[index], &SensorID1, 4);
    index += 4;

    //APSS Callout Sensor ID
    SensorID1 = UTIL::getSensorNumber(node, SENSOR_NAME_APSS_FAULT);
    memcpy(&o_data[index], &SensorID1, 4);
    index += 4;

    //Format 21 - VRM VDD Callout Sensor ID
    SensorID1 = UTIL::getSensorNumber(node, SENSOR_NAME_VRM_VDD_FAULT);
    memcpy(&o_data[index], &SensorID1, 4);
    index += 4;

    //Format 21 - VRM VDD Temperature Sensor ID
    SensorID1 = UTIL::getSensorNumber(node, SENSOR_NAME_VRM_VDD_TEMP);
    memcpy(&o_data[index], &SensorID1, 4);
    index += 4;

    o_size = index;
}


void getThermalControlMessageData(uint8_t* o_data,
                                  uint64_t & o_size)
{
    uint64_t index = 0;
    uint8_t l_numSets = 0;
    Target* l_sys = nullptr;
    targetService().getTopLevelTarget(l_sys);

    assert(l_sys != nullptr);
    assert(o_data != nullptr);

    o_data[index++] = OCC_CFGDATA_TCT_CONFIG;
    o_data[index++] = OCC_CFGDATA_TCT_CONFIG_VERSION;

    // Get the master processor target to get the system type
    Target* l_masterProc = nullptr;
    targetService().masterProcChipTargetHandle( l_masterProc );
    ATTR_MODEL_type l_systemType = l_masterProc->getAttr<ATTR_MODEL>();


    // Processor Core Weight
    ATTR_OPEN_POWER_PROC_WEIGHT_type l_proc_weight;
    if ( ! l_sys->tryGetAttr          //if attr does not exists.
           <ATTR_OPEN_POWER_PROC_WEIGHT>(l_proc_weight))
    {
        l_proc_weight = OCC_PROC_QUAD_DEFAULT_WEIGHT;
    }
    if(l_proc_weight == 0x0)
    {
        l_proc_weight = OCC_PROC_QUAD_DEFAULT_WEIGHT;
    }
    o_data[index++] = l_proc_weight;


    // Processor Quad Weight
    ATTR_OPEN_POWER_QUAD_WEIGHT_type l_quad_weight;
    if ( ! l_sys->tryGetAttr          //if attr does not exists.
           <ATTR_OPEN_POWER_QUAD_WEIGHT>(l_quad_weight))
    {
        l_quad_weight = OCC_PROC_QUAD_DEFAULT_WEIGHT;
    }
    if(l_quad_weight == 0x0)
    {
        l_quad_weight = OCC_PROC_QUAD_DEFAULT_WEIGHT;
    }
    o_data[index++] = l_quad_weight;


    // data sets following (proc, Centaur(Cumulus only), DIMM), and
    // each will get a FRU type, DVS temp, error temp,
    // and max read timeout
    size_t l_numSetsOffset = index++;

    // Note: Bytes 4 and 5 of each data set represent the PowerVM DVFS and ERROR
    // Resending the regular DVFS and ERROR for now

    // Processor
    o_data[index++] = CFGDATA_FRU_TYPE_PROC;
    uint8_t l_DVFS_temp =l_sys->getAttr<ATTR_OPEN_POWER_PROC_DVFS_TEMP_DEG_C>();
    uint8_t l_ERR_temp =l_sys->getAttr<ATTR_OPEN_POWER_PROC_ERROR_TEMP_DEG_C>();
    uint8_t l_timeout = l_sys->getAttr<ATTR_OPEN_POWER_PROC_READ_TIMEOUT_SEC>();
    if(l_DVFS_temp == 0x0)
    {
        l_DVFS_temp = OCC_PROC_DEFAULT_DVFS_TEMP;
        l_ERR_temp  = OCC_PROC_DEFAULT_ERR_TEMP;
        l_timeout   = OCC_PROC_DEFAULT_TIMEOUT;
    }
    o_data[index++] = l_DVFS_temp;
    o_data[index++] = l_ERR_temp;
    o_data[index++] = OCC_NOT_DEFINED;     //PM_DVFS
    o_data[index++] = OCC_NOT_DEFINED;     //PM_ERROR
    o_data[index++] = l_timeout;
    l_numSets++;

    // If Nimbus, skip non-existent Centaurs
    if( l_systemType != MODEL_NIMBUS )
    {
        // Centaur
        o_data[index++] = CFGDATA_FRU_TYPE_MEMBUF;
        o_data[index++] =
                l_sys->getAttr<ATTR_OPEN_POWER_MEMCTRL_THROTTLE_TEMP_DEG_C>();
        o_data[index++] =
                l_sys->getAttr<ATTR_OPEN_POWER_MEMCTRL_ERROR_TEMP_DEG_C>();
        o_data[index++] = OCC_NOT_DEFINED;     //PM_DVFS
        o_data[index++] = OCC_NOT_DEFINED;     //PM_ERROR
        o_data[index++] =
                l_sys->getAttr<ATTR_OPEN_POWER_MEMCTRL_READ_TIMEOUT_SEC>();
        l_numSets++;
    }

    // DIMM
    o_data[index++] = CFGDATA_FRU_TYPE_DIMM;
    l_DVFS_temp =l_sys->getAttr<ATTR_OPEN_POWER_DIMM_THROTTLE_TEMP_DEG_C>();
    l_ERR_temp =l_sys->getAttr<ATTR_OPEN_POWER_DIMM_ERROR_TEMP_DEG_C>();
    l_timeout = l_sys->getAttr<ATTR_OPEN_POWER_DIMM_READ_TIMEOUT_SEC>();
    if(l_DVFS_temp == 0x0)
    {
        l_DVFS_temp = OCC_DIMM_DEFAULT_DVFS_TEMP;
        l_ERR_temp  = OCC_DIMM_DEFAULT_ERR_TEMP;
        l_timeout   = OCC_DIMM_DEFAULT_TIMEOUT;
    }
    o_data[index++] = l_DVFS_temp;
    o_data[index++] = l_ERR_temp;
    o_data[index++] = OCC_NOT_DEFINED;     //PM_DVFS
    o_data[index++] = OCC_NOT_DEFINED;     //PM_ERROR
    o_data[index++] = l_timeout;
    l_numSets++;

    // VRM
    if (!l_sys->tryGetAttr<ATTR_OPEN_POWER_VRM_READ_TIMEOUT_SEC>(l_timeout))
        l_timeout = 0;
    if (l_timeout != 0)
    {
        o_data[index++] = CFGDATA_FRU_TYPE_VRM;
        o_data[index++] = 0xFF;
        o_data[index++] = 0xFF;
        o_data[index++] = 0xFF;
        o_data[index++] = 0xFF;
        o_data[index++] = l_timeout;
        l_numSets++;
    }

    // GPU Cores
    if (!l_sys->tryGetAttr<ATTR_OPEN_POWER_GPU_READ_TIMEOUT_SEC>(l_timeout))
        l_timeout = 0xFF;
    if (l_timeout == 0)
    {
        l_timeout = 0xFF;
    }
    if (!l_sys->
        tryGetAttr<ATTR_OPEN_POWER_GPU_ERROR_TEMP_DEG_C>(l_ERR_temp))
        l_ERR_temp = OCC_NOT_DEFINED;
    if (l_ERR_temp == 0)
    {
        l_ERR_temp = OCC_NOT_DEFINED;
    }
    o_data[index++] = CFGDATA_FRU_TYPE_GPU_CORE;
    o_data[index++] = OCC_NOT_DEFINED;      //DVFS
    o_data[index++] = l_ERR_temp;           //ERROR
    o_data[index++] = OCC_NOT_DEFINED;      //PM_DVFS
    o_data[index++] = OCC_NOT_DEFINED;      //PM_ERROR
    o_data[index++] = l_timeout;
    l_numSets++;

    // GPU Memory
    if (!l_sys->
        tryGetAttr<ATTR_OPEN_POWER_GPU_MEM_READ_TIMEOUT_SEC>(l_timeout))
        l_timeout = 0xFF;
    if (l_timeout == 0)
    {
        l_timeout = 0xFF;
    }
    if (!l_sys->
        tryGetAttr<ATTR_OPEN_POWER_GPU_MEM_ERROR_TEMP_DEG_C>(l_ERR_temp))
        l_ERR_temp = OCC_NOT_DEFINED;
    if (l_ERR_temp == 0)
    {
        l_ERR_temp = OCC_NOT_DEFINED;
    }
    o_data[index++] = CFGDATA_FRU_TYPE_GPU_MEMORY;
    o_data[index++] = OCC_NOT_DEFINED;      //DVFS
    o_data[index++] = l_ERR_temp;           //ERROR
    o_data[index++] = OCC_NOT_DEFINED;      //PM_DVFS
    o_data[index++] = OCC_NOT_DEFINED;      //PM_ERROR
    o_data[index++] = l_timeout;
    l_numSets++;

    // VRM Vdd
    if(!l_sys->tryGetAttr<ATTR_OPEN_POWER_VRM_VDD_DVFS_TEMP_DEG_C>(l_DVFS_temp))
        l_DVFS_temp = OCC_NOT_DEFINED;
    if (l_DVFS_temp == 0)
    {
        l_DVFS_temp = OCC_NOT_DEFINED;
    }
    if(!l_sys->tryGetAttr<ATTR_OPEN_POWER_VRM_VDD_ERROR_TEMP_DEG_C>(l_ERR_temp))
        l_ERR_temp = OCC_NOT_DEFINED;
    if (l_ERR_temp == 0)
    {
        l_ERR_temp = OCC_NOT_DEFINED;
    }
    if(!l_sys->tryGetAttr<ATTR_OPEN_POWER_VRM_VDD_READ_TIMEOUT_SEC>(l_timeout))
        l_timeout = OCC_NOT_DEFINED;
    if(l_timeout == 0)
    {
        l_timeout = OCC_NOT_DEFINED;
    }
    o_data[index++] = CFGDATA_FRU_TYPE_VRM_VDD;
    o_data[index++] = l_DVFS_temp;          //DVFS
    o_data[index++] = l_ERR_temp;           //ERROR
    o_data[index++] = OCC_NOT_DEFINED;      //PM_DVFS
    o_data[index++] = OCC_NOT_DEFINED;      //PM_ERROR
    o_data[index++] = l_timeout;
    l_numSets++;


    o_data[l_numSetsOffset] = l_numSets;
    o_size = index;

}


void getAVSBusConfigMessageData( const TargetHandle_t i_occ,
                                 uint8_t * o_data,
                                 uint64_t & o_size )
{
    uint64_t index      = 0;
    uint8_t version = 0x01;
    o_size = 0;
    assert( o_data != nullptr );

    Target* l_sys = nullptr;
    targetService().getTopLevelTarget(l_sys);
    assert(l_sys != nullptr);

    // Get the parent processor
    ConstTargetHandle_t l_proc = getParentChip( i_occ );
    assert( l_proc != nullptr );

    // Populate the data
    o_data[index++] = OCC_CFGDATA_AVSBUS_CONFIG;
    const uint64_t version_index = index++; // version updated later
    o_data[index++] = l_proc->getAttr<ATTR_VDD_AVSBUS_BUSNUM>();//Vdd Bus
    o_data[index++] = l_proc->getAttr<ATTR_VDD_AVSBUS_RAIL>();  //Vdd Rail Sel
    o_data[index++] = 0xFF;                                     //reserved
    o_data[index++] = 0xFF;                                     //reserved
    o_data[index++] = l_proc->getAttr<ATTR_VDN_AVSBUS_BUSNUM>();//Vdn Bus
    o_data[index++] = l_proc->getAttr<ATTR_VDN_AVSBUS_RAIL>();  //Vdn Rail sel

    ATTR_NO_APSS_PROC_POWER_VCS_VIO_WATTS_type PowerAdder = 0;
    if (l_proc->tryGetAttr          //if attr exists populate Proc Power Adder.
        <ATTR_NO_APSS_PROC_POWER_VCS_VIO_WATTS>(PowerAdder))
    {
        o_data[index++] = ((PowerAdder>>8)&0xFF);
        o_data[index++] = ((PowerAdder)&0xFF);
    }
    else                            //else attr not def. set to 0x0000.
    {
        o_data[index++] = 0x00;
        o_data[index++] = 0x00;
    }

    ATTR_VDD_CURRENT_OVERFLOW_WORKAROUND_ENABLE_type overflow_enable = 0;
    ATTR_MAX_VDD_CURRENT_READING_type max_vdd_current = 0;
    if ((l_sys->tryGetAttr          //if attr exists populate overflow_enable
         <ATTR_VDD_CURRENT_OVERFLOW_WORKAROUND_ENABLE>(overflow_enable)) &&
        (l_sys->tryGetAttr          //if attr exists populate max_vdd_current
         <ATTR_MAX_VDD_CURRENT_READING>(max_vdd_current)))
    {
        if (overflow_enable == 1)
        {
            // Additional config info for Vdd Current overflow workaround
            version = 0x02;
            o_data[index++] = 0x7F; // Hardcode Vdd Current Rollover Point
            o_data[index++] = 0xFF;
            o_data[index++] = (max_vdd_current>>8) & 0xFF;
            o_data[index++] = max_vdd_current & 0xFF;
        }
    }

    o_data[version_index] = version; // Version
    o_size = index;

}


// Send config data required by OCC for GPU handling.
// The OCC will determine which GPUs are present from the APSS GPIOs.
void getGPUConfigMessageData(const TargetHandle_t i_occ,
                             uint8_t * o_data,
                             uint64_t & o_size)
{
    unsigned int index = 0;
    assert(o_data != nullptr);

    // Get system and proc target
    Target* sys = nullptr;
    targetService().getTopLevelTarget(sys);
    assert(sys != nullptr);
    ConstTargetHandle_t proc = getParentChip(i_occ);
    assert(proc != nullptr);

    // Populate the data
    o_data[index++] = OCC_CFGDATA_GPU_CONFIG;
    o_data[index++] = 0x01;             // GPU Config Version

    uint16_t power = 0;
    power = sys->getAttr<ATTR_CALCULATED_MAX_SYS_POWER_EXCLUDING_GPUS>();
    UINT16_PUT(&o_data[index], power);   // Total non-GPU max power (W)
    index += 2;

    power = sys->getAttr<ATTR_CALCULATED_PROC_MEMORY_POWER_DROP>();
    UINT16_PUT(&o_data[index], power);   // Total proc/mem power drop (W)
    index += 2;
    o_data[index++] = 0;                // reserved
    o_data[index++] = 0;

    uint32_t gpu_func_sensors[MAX_GPUS] = {0};
    uint32_t gpu_temp_sensors[MAX_GPUS] = {0};
    uint32_t gpu_memtemp_sensors[MAX_GPUS] = {0};
    // Read GPU sensor numbers
    uint8_t num_sensors = 0;
    errlHndl_t err = nullptr;
    err = SENSOR::getGpuSensors(const_cast<TARGETING::TargetHandle_t>(proc),
                                HWAS::GPU_FUNC_SENSOR,
                                num_sensors, gpu_func_sensors);
    if (err)
    {
        TMGT_ERR("getGPUConfigMessageData: getGpuSensors(GPU_FUNC_SENSOR)"
                 " failed with rc 0x%04X", err->reasonCode());
        ERRORLOG::errlCommit(err, HTMGT_COMP_ID);
        memset(gpu_func_sensors, 0, sizeof(gpu_func_sensors));
    }
    err = SENSOR::getGpuSensors(const_cast<TARGETING::TargetHandle_t>(proc),
                                HWAS::GPU_TEMPERATURE_SENSOR,
                                num_sensors, gpu_temp_sensors);
    if (err)
    {
        TMGT_ERR("getGPUConfigMessageData: getGpuSensors(GPU_TEMP_SENSOR)"
                 " failed with rc 0x%04X", err->reasonCode());
        ERRORLOG::errlCommit(err, HTMGT_COMP_ID);
        memset(gpu_temp_sensors, 0, sizeof(gpu_temp_sensors));
    }
    err = SENSOR::getGpuSensors(const_cast<TARGETING::TargetHandle_t>(proc),
                                HWAS::GPU_MEMORY_TEMP_SENSOR,
                                num_sensors, gpu_memtemp_sensors);
    if (err)
    {
        TMGT_ERR("getGPUConfigMessageData: getGpuSensors(GPU_MEM_TEMP_SENSOR)"
                 " failed with rc 0x%04X", err->reasonCode());
        ERRORLOG::errlCommit(err, HTMGT_COMP_ID);
        memset(gpu_memtemp_sensors, 0, sizeof(gpu_memtemp_sensors));
    }
    for (unsigned int index = 0; index < MAX_GPUS; ++index)
    {
        if (gpu_func_sensors[index] == TARGETING::UTIL::INVALID_IPMI_SENSOR)
            gpu_func_sensors[index] = 0;
        if (gpu_temp_sensors[index] == TARGETING::UTIL::INVALID_IPMI_SENSOR)
            gpu_temp_sensors[index] = 0;
        if (gpu_memtemp_sensors[index] == TARGETING::UTIL::INVALID_IPMI_SENSOR)
            gpu_memtemp_sensors[index] = 0;
    }

    // GPU0
    UINT32_PUT(&o_data[index], gpu_temp_sensors[0]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_memtemp_sensors[0]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_func_sensors[0]);
    index += 4;

    // GPU1
    UINT32_PUT(&o_data[index], gpu_temp_sensors[1]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_memtemp_sensors[1]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_func_sensors[1]);
    index += 4;

    // GPU2
    UINT32_PUT(&o_data[index], gpu_temp_sensors[2]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_memtemp_sensors[2]);
    index += 4;
    UINT32_PUT(&o_data[index], gpu_func_sensors[2]);
    index += 4;

    o_size = index;

} // end getGPUConfigMessageData()

// Determine if the BMC will allow turbo to be used.
// Returns true if BMC suppoted and turbo is allowed.
//         true if BMC Unsupported
//         false if supported and not allowed.
//         else false
bool bmcAllowsTurbo(Target* i_sys)
{
    bool turboAllowed = true;

    uint32_t sensorNum = UTIL::getSensorNumber(i_sys,
                                               SENSOR_NAME_TURBO_ALLOWED);
    // VALID IPMI sensors are 0-0xFE
    if (sensorNum != 0xFF)
    {
        // Check if turbo frequency is allowed on BMC
        SENSOR::getSensorReadingData turboSupportData;
        SENSOR::SensorBase turboSensor(SENSOR_NAME_TURBO_ALLOWED, i_sys);
        errlHndl_t err = turboSensor.readSensorData(turboSupportData);

        if (NULL == err)
        {
            // 0x02 == Asserted bit (turbo frequency is allowed)
            if ((turboSupportData.event_status & 0x02) == 0x02)
            {
                TMGT_INF("bmcAllowsTurbo: turbo is allowed");
            }
            else
            {
                turboAllowed = false;
            }
        }
        else
        {
            // error reading sensor, assume turbo is allowed
            TMGT_ERR("bmcAllowsTurbo: unable to read turbo support sensor "
                     " from BMC, rc=0x%04X",
                     err->reasonCode());
            delete err;
        }
    }
    // else, sensor not supported on this platform so turbo is allowed

    return turboAllowed;
}


void getFrequencyPointMessageData(uint8_t* o_data,
                                  uint64_t & o_size)
{
    uint64_t index   = 0;
    uint16_t min     = 0;
    uint16_t turbo   = 0;
    uint16_t ultra   = 0;
    uint16_t nominal = 0;
    Target* sys = nullptr;

    targetService().getTopLevelTarget(sys);
    assert(sys != nullptr);
    assert(o_data != nullptr);


    o_data[index++] = OCC_CFGDATA_FREQ_POINT;
    o_data[index++] = OCC_CFGDATA_FREQ_POINT_VERSION;

    check_wof_support(nominal, turbo, ultra);
    if (turbo == 0)
    {

        // If turbo not supported, send nominal for turbo
        // and reason code for ultra-turbo (no WOF support)
        turbo = nominal;
        ultra = WOF_UNSUPPORTED_FREQ;
    }

    //Nominal Frequency in MHz
    memcpy(&o_data[index], &nominal, 2);
    index += 2;

    //Turbo Frequency in MHz
    memcpy(&o_data[index], &turbo, 2);
    index += 2;

    //Minimum Frequency in MHz
    min = sys->getAttr<ATTR_MIN_FREQ_MHZ>();
    Target* proc = nullptr;
    targetService().masterProcChipTargetHandle(proc);
    if (proc != nullptr)
    {
        // Check if min frequency needs to be biased
        int8_t bias = proc->getAttr<ATTR_FREQ_BIAS_POWERSAVE>();
        if (bias != 0)
        {
            // Calculate biased Minimum frequency
            // (bias values are signed integers in units of 0.5 percent steps)
            min *= 1 + (bias/200.0);
            TMGT_INF("getFrequencyPointMessageData: Minimum biased by %c%d"
                     " * 0.5 percent: freq=%dMHz", (bias < 0) ? '-' : ' ',
                     (bias < 0) ? -bias : bias, min);
        }
    }
    memcpy(&o_data[index], &min, 2);
    index += 2;

    //Ultra Turbo Frequency in MHz
    memcpy(&o_data[index], &ultra, 2);
    index += 2;

    // Reserved (Static Power Save in PowerVM)
    memset(&o_data[index], 0, 2);
    index += 2;

    // Reserved (FFO in PowerVM)
    memset(&o_data[index], 0, 2);
    index += 2;

    if (ultra < 16)
    {
        TMGT_INF("Frequency Points: Min %dMHz, Nominal %dMHz, Turbo %dMHz, "
                 "Ultra (disabled %d)", min, nominal, turbo, ultra);
    }
    else
    {
        TMGT_INF("Frequency Points: Min %dMHz, Nominal %dMHz, Turbo %dMHz, "
                 "Ultra %dMHz", min, nominal, turbo, ultra);
    }

    o_size = index;
}



void getApssMessageData(uint8_t* o_data,
                        uint64_t & o_size)
{
    Target* sys = nullptr;
    targetService().getTopLevelTarget(sys);

    ATTR_ADC_CHANNEL_FUNC_IDS_type function;
    sys->tryGetAttr<ATTR_ADC_CHANNEL_FUNC_IDS>(function);

    ATTR_ADC_CHANNEL_GNDS_type ground;
    sys->tryGetAttr<ATTR_ADC_CHANNEL_GNDS>(ground);

    ATTR_ADC_CHANNEL_GAINS_type gain;
    sys->tryGetAttr<ATTR_ADC_CHANNEL_GAINS>(gain);

    ATTR_ADC_CHANNEL_OFFSETS_type offset;
    sys->tryGetAttr<ATTR_ADC_CHANNEL_OFFSETS>(offset);

    CPPASSERT(sizeof(function) == sizeof(ground));
    CPPASSERT(sizeof(function) == sizeof(gain));
    CPPASSERT(sizeof(function) == sizeof(offset));

    //The APSS function below hardcodes 16 channels,
    //so everything better agree.
    CPPASSERT(sizeof(function) == 16);
    const uint32_t (*sensors)[16] = nullptr;

#ifdef CONFIG_BMC_IPMI
    errlHndl_t err = SENSOR::getAPSSChannelSensorNumbers(sensors);
    if (err)
    {
        TMGT_ERR("getApssMessageData: Call to getAPSSChannelSensorNumbers "
                 "failed.");
        ERRORLOG::errlCommit(err, HTMGT_COMP_ID);
        sensors = nullptr;
    }
#endif

    o_data[0] = OCC_CFGDATA_APSS_CONFIG;
    o_data[1] = OCC_CFGDATA_APSS_VERSION;
    o_data[2] = 0;
    o_data[3] = 0;
    uint64_t idx = 4;

    for(uint64_t channel = 0; channel < sizeof(function); ++channel)
    {
        o_data[idx] = function[channel]; // ADC Channel assignement
        idx += sizeof(uint8_t);

        uint32_t sensorId = 0;
        if (sensors != nullptr)
        {
            sensorId = (*sensors)[channel];
        }
        memcpy(o_data+idx,&sensorId,sizeof(uint32_t)); // Sensor ID
        idx += sizeof(uint32_t);

        o_data[idx] = ground[channel];   // Ground Select
        idx += sizeof(uint8_t);

        INT32_PUT(o_data+idx, gain[channel]);
        idx += sizeof(int32_t);

        INT32_PUT(o_data+idx, offset[channel]);
        idx += sizeof(int32_t);

        TMGT_INF("APSS channel[%2d]: 0x%02X 0x%08X 0x%02X 0x%08X 0x%08X",
                 channel, function[channel], sensorId, ground[channel],
                 gain[channel], offset[channel]);
    }

    ATTR_APSS_GPIO_PORT_MODES_type  gpioMode;
    sys->tryGetAttr<ATTR_APSS_GPIO_PORT_MODES>(gpioMode);

    ATTR_APSS_GPIO_PORT_PINS_type gpioPin;
    sys->tryGetAttr<ATTR_APSS_GPIO_PORT_PINS>(gpioPin);

    uint64_t pinsPerPort = sizeof(ATTR_APSS_GPIO_PORT_PINS_type) /
        sizeof(ATTR_APSS_GPIO_PORT_MODES_type);
    uint64_t pinIdx = 0;

    for(uint64_t port = 0; port < sizeof(gpioMode); ++port)
    {
        o_data[idx] = gpioMode[port];
        idx += sizeof(uint8_t);
        o_data[idx] = 0;
        idx += sizeof(uint8_t);
        memcpy(o_data + idx, gpioPin+pinIdx, pinsPerPort);
        TMGT_INF("APSS GPIO port[%2d]: 0x%02X 0x%08X 0x%08X",
                 port, gpioMode[port], UINT32_GET(o_data+idx),
                 UINT32_GET(o_data+idx+4));
        idx += pinsPerPort;
        pinIdx += pinsPerPort;
    }

    o_size = idx;
}


// Determine if WOF is supported and what the turbo/ultra frequencies are
bool check_wof_support(uint16_t & o_nominal,
                       uint16_t & o_turbo,
                       uint16_t & o_ultra)
{
    o_turbo = 0;
    o_ultra = WOF_UNSUPPORTED_FREQ;

    Target* sys = nullptr;
    targetService().getTopLevelTarget(sys);
    assert(sys != nullptr);

    int8_t bias = 0;
    Target* proc = nullptr;
    targetService().masterProcChipTargetHandle(proc);

    // Nominal Frequency
    o_nominal = sys->getAttr<ATTR_NOMINAL_FREQ_MHZ>();
    if (proc != nullptr)
    {
        // Get bias attributes (use attributes from the first functional proc)
        // (bias values are signed integers in units of 0.5 percent steps)
        bias = proc->getAttr<ATTR_FREQ_BIAS_NOMINAL>();
        if (bias != 0)
        {
            // Calculate biased Nominal frequency
            o_nominal *= 1 + (bias/200.0);
            TMGT_INF("check_wof_support: Nominal biased by %c%d"
                     " * 0.5 percent: freq=%dMHz", (bias < 0) ? '-' : ' ',
                     (bias < 0) ? -bias : bias, o_nominal);
        }
    }

    // Check if MRW allows turbo
    uint8_t turboAllowed =
        sys->getAttr<ATTR_OPEN_POWER_TURBO_MODE_SUPPORTED>();
    if (turboAllowed)
    {
        // Check if BMC allows turbo
        if (bmcAllowsTurbo(sys))
        {
            // Turbo Frequency
            o_turbo = sys->getAttr<ATTR_FREQ_CORE_MAX>();
            if (proc != nullptr)
            {
                bias = proc->getAttr< TARGETING::ATTR_FREQ_BIAS_TURBO >();
                if (bias != 0)
                {
                    // Calculate biased Turbo frequency
                    o_turbo *= 1 + (bias/200.0);
                    TMGT_INF("check_wof_support: Turbo biased by %c%d * 0.5 "
                             "percent: freq=%dMHz", (bias < 0) ? '-' : ' ',
                             (bias < 0) ? -bias : bias, o_turbo);
                }
            }

            // Check WOF support (Ultra-Turbo)
            ATTR_SYSTEM_WOF_DISABLE_type wofSupported;
            if (!sys->tryGetAttr<ATTR_SYSTEM_WOF_DISABLE>(wofSupported))
            {
                TMGT_INF("Unable to read system attribute to determine if WOF "
                         "is supported");
                G_wofSupported = false;
                o_ultra = WOF_SYSTEM_DISABLED;
            }
            else
            {
                // Loop through all functional OCCs to find max reset count
                uint8_t largest_wof_reset_count = 0;
                uint8_t occ_instance = 0;
                std::vector<Occ*> occList = OccManager::getOccArray();
                for ( const auto & occ : occList )
                {
                    if (occ->wofResetCount() > largest_wof_reset_count)
                    {
                        occ_instance = occ->getInstance();
                        largest_wof_reset_count = occ->wofResetCount();
                    }
                }

                // Ultra Turbo Frequency in MHz
                uint16_t attrUt=sys->getAttr<ATTR_ULTRA_TURBO_FREQ_MHZ>();
                if ((attrUt > 0) && (proc != nullptr))
                {
                    bias = proc->
                        getAttr< TARGETING::ATTR_FREQ_BIAS_ULTRATURBO >();
                    if (bias != 0)
                    {
                        // Calculate biased Ultra-Turbo frequency
                        attrUt *= 1 + (bias/200.0);
                        TMGT_INF("check_wof_support: Ultra-Turbo biased by %c%d"
                                 " * 0.5 percent: freq=%dMHz",
                                 (bias < 0) ? '-' : ' ',
                                 (bias < 0) ? -bias : bias, attrUt);
                    }
                }

                if( wofSupported == SYSTEM_WOF_DISABLE_ON )
                {
                    TMGT_INF("System does not support WOF");
                    G_wofSupported = false;
                    o_ultra = WOF_SYSTEM_DISABLED;
                }
                else if( attrUt == 0 )
                {
                    TMGT_INF("Missing Ultra Turbo VPD point. WOF disabled.");
                    G_wofSupported = false;
                    o_ultra = WOF_MISSING_ULTRA_TURBO;
                }
                else if( largest_wof_reset_count >= WOF_RESET_COUNT_THRESHOLD )
                {
                    TMGT_INF("WOF reset count reached for "
                         "OCC%d count: %d. WOF disabled.",
                         occ_instance,
                         largest_wof_reset_count );
                    G_wofSupported = false;
                    o_ultra = WOF_RESET_COUNT_REACHED;
                }
                else if( o_turbo <= o_nominal )
                {
                    TMGT_INF("Turbo (%d) < nominal (%d). WOF disabled.",
                             o_turbo, o_nominal);
                    G_wofSupported = false;
                    o_ultra = WOF_UNSUPPORTED_FREQ;
                }
                else if( attrUt <= o_turbo )
                {
                    TMGT_INF("Ultra Turbo (%d) < Turbo (%d). WOF disabled.",
                             attrUt, o_turbo);
                    G_wofSupported = false;
                    o_ultra = WOF_UNSUPPORTED_FREQ;
                }
                else
                {
                    o_ultra = attrUt;
                }
            }
        }
        else
        {
            TMGT_INF("getFrequencyPoint: Turbo/WOF not allowed by BMC");
            TMGT_CONSOLE("Turbo frequency not allowed due to BMC limit");
            o_turbo = o_nominal;
            G_wofSupported = false;
        }

        if( !G_wofSupported )
        {
            TMGT_INF("check_wof_support: WOF not enabled! RC = 0x%04X",o_ultra);
        }
    }
    else
    {
        TMGT_INF("check_wof_support: Turbo/WOF not supported");
        G_wofSupported = false;
    }

    return G_wofSupported;

} // end check_wof_support()


// Debug function to return config format data
void readConfigData(Occ * i_occ,
                    const uint8_t i_format,
                    uint16_t & o_cfgDataLength,
                    uint8_t *o_cfgDataPtr)
{
    uint64_t cfgDataLength = 0;
    switch(i_format)
    {
        case OCC_CFGDATA_FREQ_POINT:
            getFrequencyPointMessageData(o_cfgDataPtr,
                                         cfgDataLength);
            break;

        case OCC_CFGDATA_OCC_ROLE:
            getOCCRoleMessageData(OCC_ROLE_MASTER ==
                                  i_occ->getRole(),
                                  OCC_ROLE_FIR_MASTER ==
                                  i_occ->getRole(),
                                  o_cfgDataPtr, cfgDataLength);
            break;

        case OCC_CFGDATA_APSS_CONFIG:
            getApssMessageData(o_cfgDataPtr, cfgDataLength);
            break;

        case OCC_CFGDATA_MEM_CONFIG:
            getMemConfigMessageData(i_occ->getTarget(),
                                    o_cfgDataPtr, cfgDataLength);
            break;

        case OCC_CFGDATA_PCAP_CONFIG:
            getPowerCapMessageData(o_cfgDataPtr, cfgDataLength);
            break;

        case OCC_CFGDATA_SYS_CONFIG:
            getSystemConfigMessageData(i_occ->getTarget(),
                                       o_cfgDataPtr, cfgDataLength);
            break;

        case OCC_CFGDATA_MEM_THROTTLE:
            {
                const uint8_t occInstance = i_occ->getInstance();
                getMemThrottleMessageData(i_occ->getTarget(),
                                          occInstance, o_cfgDataPtr,
                                          cfgDataLength);
            }
            break;

        case OCC_CFGDATA_TCT_CONFIG:
            getThermalControlMessageData(o_cfgDataPtr,
                                         cfgDataLength);
            break;

        case OCC_CFGDATA_AVSBUS_CONFIG:
            getAVSBusConfigMessageData(i_occ->getTarget(),
                                       o_cfgDataPtr,
                                       cfgDataLength );
            break;

        case OCC_CFGDATA_GPU_CONFIG:
            getGPUConfigMessageData(i_occ->getTarget(),
                                    o_cfgDataPtr,
                                    cfgDataLength);
            break;

        default:
            TMGT_ERR("readConfigData: Unsupported i_format type 0x%02X",
                     i_format);
    }
    o_cfgDataLength = cfgDataLength;

} // end readConfigData()


}
OpenPOWER on IntegriCloud