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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/diag/prdf/common/framework/service/prdfTargetServices.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
/**
* @file prdfTargetServices.C
* @brief PRD wrapper of targeting code
*/
//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <prdfTargetServices.H>
#include <prdfGlobal.H>
#include <prdfErrlUtil.H>
#include <prdfTrace.H>
#include <algorithm>
//#include <fapi.H> TODO RTC 136126
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
// Pegasus includes
#include <prdfCenAddress.H>
using namespace TARGETING;
//------------------------------------------------------------------------------
namespace PRDF
{
namespace PlatServices
{
//##############################################################################
//##
//## System Level Utility Functions
//##
//##############################################################################
// local utility function.
ATTR_PAYLOAD_KIND_type getPayloadType()
{
ATTR_PAYLOAD_KIND_type payload = PAYLOAD_KIND_UNKNOWN;
TargetHandle_t sysTrgt = getSystemTarget();
if ( NULL != sysTrgt )
{
payload = sysTrgt->getAttr<ATTR_PAYLOAD_KIND>();
}
return payload;
}
//------------------------------------------------------------------------------
bool isHyprConfigPhyp()
{
return PAYLOAD_KIND_PHYP == getPayloadType();
}
//------------------------------------------------------------------------------
bool isHyprConfigOpal()
{
return PAYLOAD_KIND_SAPPHIRE == getPayloadType();
}
//------------------------------------------------------------------------------
bool isHyprRunning()
{
bool rc = false;
#ifdef __HOSTBOOT_MODULE
// ATTR_PAYLOAD_STATE is not defined in Hostboot. We can assume that if
// __HOSTBOOT_RUNTIME is defined then the hypervisor is running.
#ifdef __HOSTBOOT_RUNTIME
rc = true;
#else
rc = false;
#endif
#else
TargetHandle_t sysTrgt = getSystemTarget();
if ( NULL != sysTrgt )
{
rc = (PAYLOAD_STATE_RUNNING == sysTrgt->getAttr<ATTR_PAYLOAD_STATE>());
}
#endif
return rc;
}
bool hasRedundantClocks()
{
bool l_hasRedundantClks = false;
TargetHandle_t l_pTarget = getSystemTarget();
if(l_pTarget && l_pTarget->getAttr<ATTR_REDUNDANT_CLOCKS>())
{
l_hasRedundantClks = true;
}
return l_hasRedundantClks;
}
//##############################################################################
//##
//## Target Manipulation Utility Functions
//##
//##############################################################################
// FIXME: RTC 62867
// This function is using type PRDF::HUID. I think it should now be using
// TARGETING::HUID_ATTR. Also, will need equivalent to
// PRDF::INVALID_HUID. I think HWSV has HWSV_INVALID_HUID, but I don't
// think that exists in Hostboot. Need a common interface before making
// changes.
TARGETING::TargetHandle_t getTarget( HUID i_huid )
{
TargetHandle_t o_target = NULL;
// FIXME: RTC 62867
// This is an incredibly inefficient linear search. It is recommended
// that the common targeting code provide an interface for us so that
// all users can call the potentially optimized function. There is a
// function available in HWSV (hwsvTargetUtil.H) but not in Hostboot.
// Sadly, the HWSV code does this exact linear search.
TargetService & l_targetService = targetService();
for ( TargetIterator l_targetPtr = l_targetService.begin();
l_targetPtr != l_targetService.end(); ++l_targetPtr )
{
if ( i_huid == (l_targetPtr->getAttr<ATTR_HUID>()) )
{
o_target = (*l_targetPtr);
break;
}
}
if ( NULL == o_target )
{
PRDF_ERR( "[getTarget] i_huid: 0x%08x failed", i_huid );
}
return o_target;
}
//------------------------------------------------------------------------------
TARGETING::TargetHandle_t getTarget( const TARGETING::EntityPath & i_path )
{
TargetHandle_t o_target = targetService().toTarget( i_path );
if ( NULL == o_target )
{
PRDF_ERR( "[getTarget] Failed: i_path = " ); i_path.dump();
}
return o_target;
}
//------------------------------------------------------------------------------
int32_t getEntityPath( TARGETING::TargetHandle_t i_target,
TARGETING::EntityPath & o_path,
TARGETING::EntityPath::PATH_TYPE i_pathType )
{
int32_t o_rc = FAIL;
do
{
if ( NULL == i_target ) break;
if ( EntityPath::PATH_NA != i_pathType )
o_path.setType( i_pathType );
ATTRIBUTE_ID attr = ATTR_NA;
switch ( o_path.type() )
{
case EntityPath::PATH_AFFINITY: attr = ATTR_AFFINITY_PATH; break;
case EntityPath::PATH_PHYSICAL: attr = ATTR_PHYS_PATH; break;
case EntityPath::PATH_POWER: attr = ATTR_POWER_PATH; break;
default: ;
}
if ( ATTR_NA == attr )
{
PRDF_ERR( "[getEntityPath] Unsupported EntityPath type %d",
o_path.type() );
break;
}
if ( !targetService().tryGetPath(attr, i_target, o_path) )
{
PRDF_ERR( "[getEntityPath] Failed to get path %d", attr );
break;
}
o_rc = SUCCESS;
} while (0);
if ( SUCCESS != o_rc )
{
PRDF_ERR( "[getEntityPath] Failed: i_target=0x%08x",
getHuid(i_target) );
}
return o_rc;
}
//------------------------------------------------------------------------------
HUID getHuid( TARGETING::TargetHandle_t i_target )
{
HUID o_huid = INVALID_HUID;
do
{
if ( NULL == i_target ) break; // return INVALID_HUID
if ( !i_target->tryGetAttr<ATTR_HUID>(o_huid) )
{
PRDF_ERR( "[getHuid] Failed to get ATTR_HUID" );
o_huid = INVALID_HUID; // Just in case.
}
} while (0);
return o_huid;
}
//------------------------------------------------------------------------------
bool isFunctional( TARGETING::TargetHandle_t i_target )
{
bool o_funcState = false;
do
{
if ( NULL == i_target )
{
PRDF_ERR( "[isFunctional] i_target is NULL" );
break;
}
HwasState l_funcState;
if ( !i_target->tryGetAttr<ATTR_HWAS_STATE>(l_funcState) )
{
PRDF_ERR( "[isFunctional] Failed to get ATTR_HWAS_STATE" );
break;
}
if ( l_funcState.functional ) o_funcState =true;
} while (0);
return o_funcState;
}
//------------------------------------------------------------------------------
TARGETING::TYPE getTargetType( TARGETING::TargetHandle_t i_target )
{
TYPE o_type = TYPE_LAST_IN_RANGE;
if ( NULL != i_target )
{
if ( !i_target->tryGetAttr<ATTR_TYPE>(o_type) )
{
PRDF_ERR( "[getTargetType] Failed to get ATTR_TYPE" );
o_type = TYPE_LAST_IN_RANGE; // Just in case
}
}
if ( TYPE_LAST_IN_RANGE == o_type )
{
PRDF_ERR( "[getTargetType] Failed: i_target=0x%08x",
getHuid(i_target) );
}
return o_type;
}
//------------------------------------------------------------------------------
TARGETING::CLASS getTargetClass( TARGETING::TargetHandle_t i_target )
{
CLASS o_class = CLASS_NA;
if ( NULL != i_target )
{
if ( !i_target->tryGetAttr<ATTR_CLASS>(o_class) )
{
PRDF_ERR( "[getTargetClass] Failed to get ATTR_CLASS" );
o_class = CLASS_NA; // Just in case
}
}
if ( CLASS_NA == o_class )
{
PRDF_ERR( "[getTargetClass] Failed: i_target=0x%08x",
getHuid(i_target) );
}
return o_class;
}
//------------------------------------------------------------------------------
void printTargetInfo( TARGETING::TargetHandle_t i_target )
{
EntityPath l_path ( EntityPath::PATH_PHYSICAL );
int32_t l_rc = getEntityPath( i_target, l_path );
if ( SUCCESS == l_rc )
{
PRDF_DTRAC( "PRDCONFIG: HUID=0x%08x path=", getHuid(i_target) );
l_path.dump();
}
else
{
PRDF_ERR( "[printTargetInfo] Failed: i_target=0x%08x",
getHuid(i_target) );
}
}
//------------------------------------------------------------------------------
uint8_t getChipLevel( TARGETING::TargetHandle_t i_target )
{
uint8_t o_chipLvl = 0;
do
{
if ( NULL == i_target ) break;
TargetHandle_t l_parentTarget = getParentChip( i_target );
if ( NULL == l_parentTarget ) break;
if ( !l_parentTarget->tryGetAttr<ATTR_EC>(o_chipLvl) )
{
PRDF_ERR( "[getChipLevel] Failed to get ATTR_EC" );
o_chipLvl = 0; // Just in case
}
} while (0);
if ( 0 == o_chipLvl )
{
PRDF_ERR( "[getChipLevel] Failed: i_target=0x%08x", getHuid(i_target) );
}
return o_chipLvl;
}
//------------------------------------------------------------------------------
void setHWStateChanged(TARGETING::TargetHandle_t i_target)
{
#define PRDF_FUNC "[PlatServices::setHWStateChanged] "
if(NULL != i_target)
{
TYPE type = getTargetType(i_target);
if( (TYPE_DIMM == type) ||
(TYPE_MEMBUF == type) ||
(TYPE_MCS == type) )
{
update_hwas_changed_mask(i_target, HWAS_CHANGED_BIT_MEMDIAG);
}
else
{
PRDF_ERR(PRDF_FUNC "invalid target type: 0x%08x", type);
}
}
else
{
PRDF_ERR(PRDF_FUNC "i_target is null");
}
#undef PRDF_FUNC
}
//##############################################################################
//##
//## getConnected() support functions
//##
//##############################################################################
// This is a helper function for getConnected(). It will return the association
// type (CHILD_BY_AFFINITY or PARENT_BY_AFFINITY) between a target and
// destination target type. The function only characterizes parent or child
// relationships. It does not do any peer-to-peer relationships. The function
// will return non-SUCCESS if a relationship is not supported.
struct conn_t
{
TYPE from : 8;
TYPE to : 8;
TargetService::ASSOCIATION_TYPE type : 8;
static uint32_t getSortOrder( TYPE type )
{
// Can't trust that the order of the TYPE enum does not change so create
// our own sorting order.
uint32_t order = 0;
switch ( type )
{
case TYPE_SYS: order = 0; break;
case TYPE_NODE: order = 1; break;
case TYPE_OSC: order = 2; break;
case TYPE_OSCPCICLK: order = 3; break;
case TYPE_PROC: order = 4; break;
case TYPE_TODCLK: order = 5; break;
case TYPE_PCICLKENDPT: order = 6; break;
case TYPE_PORE: order = 7; break;
case TYPE_NX: order = 8; break;
case TYPE_OCC: order = 9; break;
case TYPE_PSI: order = 10; break;
case TYPE_EX: order = 11; break;
case TYPE_XBUS: order = 12; break;
case TYPE_ABUS: order = 13; break;
case TYPE_PCI: order = 14; break;
case TYPE_MCS: order = 15; break;
case TYPE_MEMBUF: order = 16; break;
case TYPE_L4: order = 17; break;
case TYPE_MBA: order = 18; break;
case TYPE_DIMM: order = 19; break;
default: ;
}
return order;
}
bool operator<( const conn_t & r )
{
uint32_t thisOrder = getSortOrder(this->from);
uint32_t thatOrder = getSortOrder(r.from);
if ( thisOrder == thatOrder )
return ( getSortOrder(this->to) < getSortOrder(r.to) );
else
return ( thisOrder < thatOrder );
}
};
int32_t getAssociationType( TARGETING::TargetHandle_t i_target,
TARGETING::TYPE i_connType,
TARGETING::TargetService::ASSOCIATION_TYPE & o_type)
{
#define PRDF_FUNC "[PlatServices::getAssociationType] "
int32_t o_rc = SUCCESS;
static conn_t lookups[] =
{
// This table must be sorted based on the < operator of struct conn_t.
{ TYPE_SYS, TYPE_NODE, TargetService::CHILD_BY_AFFINITY },
{ TYPE_SYS, TYPE_OSC, TargetService::CHILD_BY_AFFINITY },
{ TYPE_SYS, TYPE_OSCPCICLK, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_SYS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_NODE, TYPE_OSC, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_OSCPCICLK, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_PROC, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_TODCLK, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_PCICLKENDPT,TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_OCC, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_PSI, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_EX, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_XBUS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_ABUS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_PCI, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_MCS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_MEMBUF, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_L4, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_MBA, TargetService::CHILD_BY_AFFINITY },
{ TYPE_NODE, TYPE_DIMM, TargetService::CHILD_BY_AFFINITY },
{ TYPE_OSC, TYPE_SYS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OSC, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OSC, TYPE_TODCLK, TargetService::CHILD_BY_AFFINITY },
{ TYPE_OSCPCICLK, TYPE_SYS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OSCPCICLK, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OSCPCICLK, TYPE_PCICLKENDPT, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PROC, TYPE_TODCLK, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_PCICLKENDPT,TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_PORE, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_NX, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_OCC, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_PSI, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_EX, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_XBUS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_ABUS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_PCI, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_MCS, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_MEMBUF, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_L4, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_MBA, TargetService::CHILD_BY_AFFINITY },
{ TYPE_PROC, TYPE_DIMM, TargetService::CHILD_BY_AFFINITY },
{ TYPE_TODCLK, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_TODCLK, TYPE_OSC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_TODCLK, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCICLKENDPT, TYPE_SYS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCICLKENDPT, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCICLKENDPT, TYPE_OSCPCICLK, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCICLKENDPT, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PORE, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_NX, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OCC, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_OCC, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PSI, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PSI, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_EX, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_EX, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_XBUS, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_XBUS, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_ABUS, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_ABUS, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCI, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_PCI, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MCS, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MCS, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MCS, TYPE_MEMBUF, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MCS, TYPE_L4, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MCS, TYPE_MBA, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MCS, TYPE_DIMM, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_MCS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_L4, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_MBA, TargetService::CHILD_BY_AFFINITY },
{ TYPE_MEMBUF, TYPE_DIMM, TargetService::CHILD_BY_AFFINITY },
{ TYPE_L4, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_L4, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_L4, TYPE_MCS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_L4, TYPE_MEMBUF, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MBA, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MBA, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MBA, TYPE_MCS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MBA, TYPE_MEMBUF, TargetService::PARENT_BY_AFFINITY },
{ TYPE_MBA, TYPE_DIMM, TargetService::CHILD_BY_AFFINITY },
{ TYPE_DIMM, TYPE_NODE, TargetService::PARENT_BY_AFFINITY },
{ TYPE_DIMM, TYPE_PROC, TargetService::PARENT_BY_AFFINITY },
{ TYPE_DIMM, TYPE_MCS, TargetService::PARENT_BY_AFFINITY },
{ TYPE_DIMM, TYPE_MEMBUF, TargetService::PARENT_BY_AFFINITY },
{ TYPE_DIMM, TYPE_MBA, TargetService::PARENT_BY_AFFINITY },
};
do
{
if ( NULL == i_target )
{
PRDF_ERR( PRDF_FUNC "Given target is null" );
o_rc = FAIL; break;
}
const size_t sz_lookups = sizeof(lookups) / sizeof(conn_t);
TYPE type = getTargetType(i_target);
conn_t match = { type, i_connType, TargetService::CHILD_BY_AFFINITY };
conn_t * it = std::lower_bound( lookups, lookups + sz_lookups, match );
if ( (it == lookups + sz_lookups) || // off the end
(type != it->from) || (i_connType != it->to) ) // not equals
{
PRDF_ERR( PRDF_FUNC "Look-up failed: i_target=0x%08x i_connType=%d",
getHuid(i_target), i_connType );
o_rc = FAIL; break;
}
o_type = it->type;
} while (0);
return o_rc;
#undef PRDF_FUNC
}
// Helper function for the various getConnected() functions.
TargetHandleList getConnAssoc( TargetHandle_t i_target, TYPE i_connType,
TargetService::ASSOCIATION_TYPE i_assocType )
{
#define PRDF_FUNC "[PlatServices::getConnAssoc] "
TargetHandleList o_list; // Default empty list
do
{
if ( NULL == i_target )
{
PRDF_ERR( PRDF_FUNC "Given target is null" );
break;
}
// Match any class, specified type, and functional.
PredicateCTM predType( CLASS_NA, i_connType );
PredicateIsFunctional predFunc;
PredicatePostfixExpr predAnd;
predAnd.push(&predType).push(&predFunc).And();
targetService().getAssociated( o_list, i_target, i_assocType,
TargetService::ALL, &predAnd );
} while(0);
return o_list;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
TargetHandleList getConnected( TargetHandle_t i_target, TYPE i_connType )
{
TargetHandleList o_list; // Default empty list
do
{
if ( i_connType == getTargetType(i_target) )
{
o_list.push_back( i_target );
break;
}
TargetService::ASSOCIATION_TYPE assocType;
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
if ( SUCCESS != l_rc ) break;
o_list = getConnAssoc( i_target, i_connType, assocType );
} while(0);
return o_list;
}
//------------------------------------------------------------------------------
TargetHandle_t getConnectedParent( TargetHandle_t i_target, TYPE i_connType )
{
#define PRDF_FUNC "[PlatServices::getConnectedParent] "
TargetHandle_t o_parent = NULL;
do
{
if ( i_connType == getTargetType(i_target) )
{
o_parent = i_target;
break;
}
TargetService::ASSOCIATION_TYPE assocType;
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
if ( SUCCESS != l_rc ) break;
if ( TargetService::PARENT_BY_AFFINITY != assocType )
{
PRDF_ERR( PRDF_FUNC "Unsupported parent connection: i_target=0x%08x "
"i_connType=%d", getHuid(i_target), i_connType );
break;
}
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
if ( 1 != list.size() ) // Should be one and only one parent
{
PRDF_ERR( PRDF_FUNC "Could not find parent: i_target=0x%08x "
"i_connType=%d", getHuid(i_target), i_connType );
break;
}
o_parent = list[0];
} while(0);
return o_parent;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
TargetHandle_t getConnectedChild( TargetHandle_t i_target, TYPE i_connType,
uint32_t i_position )
{
#define PRDF_FUNC "[PlatServices::getConnectedChild] "
TargetHandle_t o_child = NULL;
do
{
TargetService::ASSOCIATION_TYPE assocType;
int32_t l_rc = getAssociationType( i_target, i_connType, assocType );
if ( SUCCESS != l_rc ) break;
if ( TargetService::CHILD_BY_AFFINITY != assocType )
{
PRDF_ERR( PRDF_FUNC "Unsupported child connection: i_target=0x%08x "
"i_connType=%d", getHuid(i_target), i_connType );
break;
}
// SPECIAL CASE: The MEMBUF position number is relative to the PROC,
// not the MCS. This means the MEMBUF position number is the same
// as the position number of the attached MCS. In many cases, we
// want to get the MEMBUF connected to the MCS, but don't have
// knowledge of the MCS's position number (espeically in the rule
// code. So the following will change the desired position number
// to the MCS position number for MCS->MEMBUF connections only.
if ( TYPE_MCS == getTargetType(i_target) && TYPE_MEMBUF == i_connType )
i_position = getTargetPosition(i_target);
TargetHandleList list = getConnAssoc( i_target, i_connType, assocType );
for ( TargetHandleList::iterator i = list.begin();
i != list.end(); ++i )
{
if ( i_position == getTargetPosition(*i) )
{
o_child = *i;
break;
}
}
} while(0);
return o_child;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
TargetHandle_t getConnectedPeerTarget( TargetHandle_t i_target )
{
#define PRDF_FUNC "[PlatServices::getConnectedPeerTarget] "
TargetHandle_t o_target = NULL;
do
{
if ( NULL == i_target )
{
PRDF_ERR( PRDF_FUNC "Given target is NULL" );
break;
}
TYPE type = getTargetType( i_target );
switch( type )
{
case TYPE_XBUS:
case TYPE_ABUS:
case TYPE_PSI:
case TYPE_PCICLKENDPT:
o_target = i_target->getAttr<ATTR_PEER_TARGET>();
break;
default:
PRDF_ERR( PRDF_FUNC "Target type not supported: i_target=0x%08x "
"type=0x%x", getHuid(i_target), type );
}
} while(0);
return o_target;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
TargetHandle_t getConnectedPeerProc( TargetHandle_t i_procTarget,
TYPE i_busType, uint32_t i_busPos )
{
#define PRDF_FUNC "[PlatServices::getConnectedPeerProc] "
TargetHandle_t o_target = NULL;
do
{
if ( NULL == i_procTarget || TYPE_PROC != getTargetType(i_procTarget) )
{
PRDF_ERR( PRDF_FUNC "Given target is not of TYPE_PROC: "
"i_procTarget=0x%08x", getHuid(i_procTarget) );
break;
}
if ( !( ((TYPE_XBUS == i_busType) && (MAX_XBUS_PER_PROC > i_busPos)) ||
((TYPE_ABUS == i_busType) && (MAX_ABUS_PER_PROC > i_busPos)) ) )
break;
// Starting PROC -> starting XBUS/ABUS.
TargetHandle_t busTarget = getConnectedChild( i_procTarget, i_busType,
i_busPos );
if ( NULL == busTarget ) break;
// Starting XBUS/ABUS -> ATTR_PEER_TARGET -> destination XBUS/ABUS.
TargetHandle_t destTarget = getConnectedPeerTarget( busTarget );
if ( NULL == destTarget ) break;
// Destination XBUS/ABUS -> destination PROC.
o_target = getConnectedParent( destTarget, TYPE_PROC );
} while(0);
return o_target;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
TARGETING::TargetHandle_t getSystemTarget()
{
TargetHandle_t sysTarget = NULL;
targetService().getTopLevelTarget( sysTarget );
if ( NULL == sysTarget )
{
PRDF_ERR( "[getSystemTarget] Failed" );
}
return sysTarget;
}
//------------------------------------------------------------------------------
TARGETING::TargetHandle_t getParentChip( TARGETING::TargetHandle_t i_target )
{
TargetHandle_t o_chipTarget = NULL;
CLASS l_class = getTargetClass( i_target );
switch ( l_class )
{
case CLASS_CHIP:
o_chipTarget = i_target;
break;
case CLASS_UNIT:
{
TargetHandleList l_list;
PredicateCTM l_predClass( CLASS_CHIP );
targetService().getAssociated( l_list, i_target,
TargetService::PARENT,
TargetService::ALL,
&l_predClass );
if ( 1 == l_list.size() )
{
o_chipTarget = l_list[0];
}
else
{
PRDF_ERR( "[getParentChip] Could not find parent chip" );
}
break;
}
default:
PRDF_ERR( "[getParentChip] Unsupported class: %d", l_class );
}
if ( NULL == o_chipTarget )
{
PRDF_ERR( "[getParentChip] Failed: i_target=0x%08x",
getHuid(i_target) );
}
return o_chipTarget;
}
//------------------------------------------------------------------------------
TARGETING::TargetHandleList getFunctionalTargetList( TARGETING::TYPE i_type )
{
TargetHandleList o_list; // Default empty list.
TargetService & l_targetService = targetService();
// Match any class, specified type, and functional.
PredicateCTM l_predType( CLASS_NA, i_type );
PredicateIsFunctional l_predFunc;
PredicatePostfixExpr l_predAnd;
l_predAnd.push(&l_predType).push(&l_predFunc).And();
// Defining a filter to get a list of all targets of i_type.
TargetRangeFilter l_filter( l_targetService.begin(), l_targetService.end(),
&l_predAnd );
for( ; l_filter; ++l_filter )
{
// Adding functional target to the vector.
o_list.push_back( *l_filter );
}
return o_list;
}
//------------------------------------------------------------------------------
bool checkLastFuncEx( TARGETING::TargetHandle_t i_exTarget )
{
bool o_lastEx = false;
TargetHandleList l_list = getFunctionalTargetList( TYPE_EX );
if ( 1 == l_list.size() && l_list[0] == i_exTarget )
o_lastEx = true;
return o_lastEx;
}
//------------------------------------------------------------------------------
TargetHandle_t getMasterProc()
{
TargetHandle_t masterProc = NULL;
targetService().masterProcChipTargetHandle( masterProc );
return masterProc;
}
//##############################################################################
//##
//## Target position support code
//##
//##############################################################################
uint32_t getTargetPosition( TARGETING::TargetHandle_t i_target )
{
#define PRDF_FUNC "[PlatServices::getTargetPosition] "
uint32_t o_pos = INVALID_POSITION_BOUND;
CLASS l_class = getTargetClass( i_target );
switch ( l_class )
{
case CLASS_CHIP:
{
TYPE l_type = getTargetType( i_target );
switch ( l_type )
{
case TYPE_PROC:
case TYPE_OSC:
case TYPE_OSCPCICLK:
case TYPE_OSCREFCLK:
{
uint16_t tmpPos = 0;
if ( !i_target->tryGetAttr<ATTR_POSITION>(tmpPos) )
{
PRDF_ERR( PRDF_FUNC "Failed to get ATTR_POSITION" );
}
else
o_pos = (uint32_t)tmpPos;
break;
}
case TYPE_MEMBUF:
o_pos = getMemChnl( i_target );
break;
default:
PRDF_ERR( PRDF_FUNC "Unsupported type: %d", l_type );
}
break;
}
case CLASS_UNIT:
{
uint8_t tmpPos = 0;
if ( !i_target->tryGetAttr<ATTR_CHIP_UNIT>(tmpPos) )
{
PRDF_ERR( PRDF_FUNC "Failed to get ATTR_CHIP_UNIT" );
}
else
o_pos = (uint32_t)tmpPos;
break;
}
case CLASS_ENC:
o_pos = getNodePosition( i_target );
break;
default:
PRDF_ERR( PRDF_FUNC "Unsupported class: %d", l_class );
}
if ( INVALID_POSITION_BOUND == o_pos )
{
PRDF_ERR( PRDF_FUNC "Failed: target=0x%08x", getHuid(i_target) );
}
#undef PRDF_FUNC
return o_pos;
}
//------------------------------------------------------------------------------
uint32_t getNodePosition( TARGETING::TargetHandle_t i_target )
{
uint32_t o_pos = INVALID_POSITION_BOUND;
do
{
// Get the node handle.
TargetHandle_t node = getConnectedParent( i_target, TYPE_NODE );
if ( NULL == node )
{
PRDF_ERR( "[getNodePosition] Failed to get node target" );
break;
}
// FIXME: RTC 120711 will add NODE POSITION keyword
// that we can use instead of ePath instance.
EntityPath l_path ( EntityPath::PATH_PHYSICAL );
int32_t l_rc = getEntityPath( node, l_path );
if ( SUCCESS != l_rc ) break;
o_pos = l_path[l_path.size()-1].instance;
} while (0);
if ( INVALID_POSITION_BOUND == o_pos )
{
PRDF_ERR( "[getNodePosition] Failed: target=0x%08x",
getHuid(i_target) );
}
return o_pos;
}
//------------------------------------------------------------------------------
TARGETING::MODEL getProcModel( TARGETING::TargetHandle_t i_proc )
{
#define PRDF_FUNC "[PlatServices::getProcModel] "
MODEL l_model = MODEL_NA;
if( TYPE_PROC == getTargetType( i_proc ) )
{
l_model = i_proc->getAttr<ATTR_MODEL>();
}
else
{
PRDF_ERR( PRDF_FUNC "Invalid Target Huid = 0x%08x", getHuid( i_proc ) );
}
return l_model;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
uint32_t getPhbConfig( TARGETING::TargetHandle_t i_proc )
{
#define PRDF_FUNC "[PlatServices::getPhbConfig] "
uint32_t l_pciConfig = 0xffffffff;
if ( TYPE_PROC == getTargetType(i_proc) )
{
l_pciConfig = i_proc->getAttr<ATTR_PROC_PCIE_IOP_CONFIG>();
}
else
{
PRDF_ERR( PRDF_FUNC "Invalid Target Huid = 0x%08x", getHuid(i_proc) );
}
return l_pciConfig;
#undef PRDF_FUNC
}
//##############################################################################
//##
//## Memory specific functions
//##
//##############################################################################
int32_t getMasterRanks( TargetHandle_t i_memTrgt,
std::vector<CenRank> & o_ranks,
uint8_t i_ds )
{
#define PRDF_FUNC "PlatServices::getMasterRanks] "
int32_t o_rc = FAIL;
o_ranks.clear();
do
{
if ( NULL == i_memTrgt ) break;
TargetHandle_t mbaTrgt = getConnectedParent( i_memTrgt, TYPE_MBA );
if ( NULL == mbaTrgt )
{
PRDF_ERR( PRDF_FUNC "getConnectedParent() failed" );
break;
}
if( MAX_DIMM_PER_PORT < i_ds )
{
PRDF_ERR( PRDF_FUNC "Invalid value for Dimm Slct:%u", i_ds );
break;
}
uint8_t info[MAX_PORT_PER_MBA][MAX_DIMM_PER_PORT];
if ( !mbaTrgt->tryGetAttr<ATTR_EFF_DIMM_RANKS_CONFIGED>(info) )
{
PRDF_ERR( PRDF_FUNC "Failed to get ATTR_EFF_DIMM_RANKS_CONFIGED" );
break;
}
// NOTE: DIMMs must be plugged into pairs. So the values for each port
// select will be the same for each DIMM select. There is no need
// to interate on both port selects.
for ( uint32_t ds = 0; ds < MAX_DIMM_PER_PORT; ds++ )
{
// if we are requested to get master ranks on a specific
// DIMM, ignore if ds does not match the specific DIMM.
// We have kept MAX_DIMM_PER_PORT as special value ( default )
// for getting total ranks across both DIMMS.
if( ( MAX_DIMM_PER_PORT != i_ds ) && ( ds != i_ds ) )
continue;
uint8_t rankMask = info[0][ds];
if ( 0 == (rankMask & 0xf0) ) continue; // Nothing configured.
for ( uint32_t rs = 0; rs < 4; rs++ )
{
if ( 0 != (rankMask & (0x80 >> rs)) )
{
o_ranks.push_back( CenRank((ds << 2) | rs) );
}
}
}
o_rc = SUCCESS;
} while (0);
if ( SUCCESS != o_rc )
{
PRDF_ERR( PRDF_FUNC "Failed: i_memTrgt=0x%08x", getHuid(i_memTrgt) );
}
return o_rc;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
uint32_t getMemChnl( TARGETING::TargetHandle_t i_memTarget )
{
#define PRDF_FUNC "[PlatServices::getMemChnl] "
uint32_t o_chnl = INVALID_POSITION_BOUND; // Intentially set to
// INVALID_POSITION_BOUND for call
// from getTargetPosition().
do
{
if ( NULL == i_memTarget ) break;
TargetHandle_t mcsTarget = getConnectedParent( i_memTarget, TYPE_MCS );
if ( NULL == mcsTarget )
{
PRDF_ERR( PRDF_FUNC "getConnectedParent() failed" );
break;
}
o_chnl = getTargetPosition( mcsTarget );
} while (0);
if ( MAX_MCS_PER_PROC <= o_chnl ) // Real MCS position check.
{
PRDF_ERR( PRDF_FUNC "Failed: i_memTarget=0x%08x",
getHuid(i_memTarget) );
}
return o_chnl;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
int32_t isMembufOnDimm( TARGETING::TargetHandle_t i_memTarget,
bool & o_isBuffered )
{
int32_t o_rc = FAIL;
o_isBuffered = false;
do
{
// The DIMMs in an node should either all be buffered or all not. So
// we can check the attribute from ANY MBA.
TargetHandleList list = getConnected( i_memTarget, TYPE_MBA );
if ( 0 == list.size() )
{
PRDF_ERR( "[isMembufOnDimm] Couldn't find an MBA target" );
break;
}
TargetHandle_t mbaTarget = list[0];
o_isBuffered = mbaTarget->getAttr<ATTR_EFF_CUSTOM_DIMM>();
o_rc = SUCCESS;
} while (0);
if ( SUCCESS != o_rc )
{
PRDF_ERR( "[isMembufOnDimm] Failed: i_memTarget=0x%08x",
getHuid(i_memTarget) );
}
return o_rc;
}
//------------------------------------------------------------------------------
int32_t getMbaPort( TARGETING::TargetHandle_t i_dimmTarget, uint8_t & o_port )
{
return i_dimmTarget->tryGetAttr<ATTR_MBA_PORT>(o_port) ? SUCCESS : FAIL;
}
//------------------------------------------------------------------------------
int32_t getMbaDimm( TARGETING::TargetHandle_t i_dimmTarget, uint8_t & o_dimm )
{
return i_dimmTarget->tryGetAttr<ATTR_MBA_DIMM>(o_dimm) ? SUCCESS : FAIL;
}
//------------------------------------------------------------------------------
int32_t getDramGen( TARGETING::TargetHandle_t i_mba, uint8_t & o_dramGen )
{
#define PRDF_FUNC "[PlatServices::getDramGen] "
int32_t o_rc = FAIL;
do
{
if ( TYPE_MBA != getTargetType( i_mba ) )
{
PRDF_ERR( PRDF_FUNC "Invalid Target. HUID:0X%08X",
getHuid( i_mba ) );
break;
}
o_dramGen = i_mba->getAttr<ATTR_EFF_DRAM_GEN>( );
o_rc = SUCCESS;
}while(0);
return o_rc;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
int32_t getDimmRowCol( TARGETING::TargetHandle_t i_mba, uint8_t & o_rowNum,
uint8_t & o_colNum )
{
#define PRDF_FUNC "[PlatServices::getDimmRowCol] "
int32_t o_rc = FAIL;
do
{
if ( TYPE_MBA != getTargetType( i_mba ) )
{
PRDF_ERR( PRDF_FUNC "Invalid Target. HUID:0X%08X",
getHuid( i_mba ) );
break;
}
o_rowNum = i_mba->getAttr<ATTR_EFF_DRAM_ROWS>();
o_colNum = i_mba->getAttr<ATTR_EFF_DRAM_COLS>();
o_rc = SUCCESS;
}while(0);
return o_rc;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
/* TODO RTC 136126
bool isDramWidthX4( TargetHandle_t i_mba )
{
return ( fapi::ENUM_ATTR_EFF_DRAM_WIDTH_X4 ==
i_mba->getAttr<ATTR_EFF_DRAM_WIDTH>() );
}
*/
//------------------------------------------------------------------------------
uint8_t getRanksPerDimm( TargetHandle_t i_mba, uint8_t i_ds )
{
#define PRDF_FUNC "[PlatServices::getRanksPerDimm] "
uint8_t rankCount = 0; // default if something fails
do
{
if ( MAX_DIMM_PER_PORT <= i_ds )
{
PRDF_ERR( PRDF_FUNC "Invalid parameters i_ds:%u", i_ds );
break;
}
// NOTE: Unable to use getAttr() because it is not able to return an
// array. Otherwise, all of the following would be able to fit in
// one line of code. The targeting may fix this later.
ATTR_EFF_NUM_RANKS_PER_DIMM_type attr;
if ( !i_mba->tryGetAttr<ATTR_EFF_NUM_RANKS_PER_DIMM>(attr) )
{
PRDF_ERR( PRDF_FUNC "failed to get ATTR_EFF_NUM_RANKS_PER_DIMM" );
break;
}
// Note that DIMMs are plugged in pairs so the rank numbers should be
// the same for each port.
rankCount = attr[0][i_ds];
} while(0);
return rankCount;
#undef PRDF_FUNC
}
//------------------------------------------------------------------------------
uint8_t getMasterRanksPerDimm( TARGETING::TargetHandle_t i_mbaTarget,
uint8_t i_ds )
{
#define PRDF_FUNC "[PlatServices::getMasterRanksPerDimm] "
uint8_t rankCount = 0; // default if something fails
do
{
if ( MAX_DIMM_PER_PORT <= i_ds )
{
PRDF_ERR( PRDF_FUNC"Invalid parameters i_ds:%u", i_ds );
break;
}
// NOTE: Unable to use getAttr() because it is not able to return an
// array. Otherwise, all of the following would be able to fit in
// one line of code. The targeting may fix this later.
ATTR_EFF_NUM_MASTER_RANKS_PER_DIMM_type attr;
if (!i_mbaTarget->tryGetAttr<ATTR_EFF_NUM_MASTER_RANKS_PER_DIMM>(attr))
{
PRDF_ERR(PRDF_FUNC"fail get ATTR_EFF_NUM_MASTER_RANKS_PER_DIMM");
break;
}
// Note that DIMMs are plugged in pairs so the rank numbers should be
// the same for each port.
rankCount = attr[0][i_ds];
} while(0);
return rankCount;
#undef PRDF_FUNC
}
//##############################################################################
//##
//## Clock specific functions
//##
//##############################################################################
TARGETING::TargetHandle_t getClockId(TARGETING::TargetHandle_t
i_pGivenTarget,
TARGETING ::TYPE i_connType,
uint32_t i_oscPos)
{
#define PRDF_FUNC "[PlatServices::getClockId] "
TargetHandleList l_clockCardlist;
TargetHandle_t l_target = i_pGivenTarget;
TargetHandle_t o_pClockCardHandle = NULL;
do
{
if ( i_oscPos >= MAX_PCIE_OSC_PER_NODE )
{
PRDF_ERR(PRDF_FUNC "target: 0x%.8X - invalid "
"i_oscPos: %d", getHuid(i_pGivenTarget), i_oscPos);
break;
}
// If membuf target, use the connected proc target
if(TYPE_MEMBUF == getTargetType(i_pGivenTarget))
{
l_target = getConnectedParent(i_pGivenTarget, TYPE_PROC);
if(NULL == l_target)
{
PRDF_ERR(PRDF_FUNC "failed to get proc target "
"connected to membuf 0x%.8X",
getHuid(l_target));
break;
}
}
PredicateIsFunctional l_funcFilter;
PredicateCTM l_oscFilter(CLASS_CHIP, i_connType);
PredicateCTM l_peerFilter(CLASS_UNIT,
(i_connType == TYPE_OSCREFCLK ?
TYPE_REFCLKENDPT: TYPE_PCICLKENDPT));
PredicatePostfixExpr l_funcAndOscFilter, l_funcAndPeerFilter;
l_funcAndOscFilter.push(&l_oscFilter).push(&l_funcFilter).And();
l_funcAndPeerFilter.push(&l_peerFilter).push(&l_funcFilter).And();
//PROC <---> CLKTYPE <---> PEER <---> CLKTYPE <---> OSC
//Get the oscillators related to this proc
getPeerTargets( l_clockCardlist, // List of connected OSCs
l_target, // to this proc
// filter to get to clock endpoints
&l_funcAndPeerFilter/*&l_peerFilter*/,
// filter to get the driving OSC
&l_funcAndOscFilter/*&l_oscFilter*/);
for(TargetHandleList::iterator l_itr = l_clockCardlist.begin();
l_itr != l_clockCardlist.end();
++l_itr)
{
PRDF_TRAC(PRDF_FUNC "OSC 0x%.8X, pos: %d is connected to "
"proc 0x%.8X, inputOscPos: %d", getHuid(*l_itr),
getTargetPosition(*l_itr), getHuid(l_target), i_oscPos);
if ( i_oscPos == getTargetPosition(*l_itr) )
{
o_pClockCardHandle = *l_itr;
}
}
} while(0);
return o_pClockCardHandle;
#undef PRDF_FUNC
}
//##############################################################################
//## MNFG Policy Flag Functions
//##############################################################################
// Helper function to access the state of manufacturing policy flags.
bool isMnfgFlagSet( uint32_t i_flag )
{
bool o_rc = false;
ATTR_MNFG_FLAGS_type l_attrValue = 0;
TargetHandle_t l_pTopTarget= NULL;
targetService().getTopLevelTarget(l_pTopTarget);
if(l_pTopTarget)
{
l_attrValue = l_pTopTarget->getAttr<ATTR_MNFG_FLAGS>();
o_rc = l_attrValue & i_flag;
}
else
{
PRDF_ERR("[isMnfgFlagSet] error finding l_pTopTarget");
}
//PRDF_TRAC("[isMnfgFlagSet] MNFG Flags: 0x%016llX, i_flag: "
// "0x%08X, o_rc: %d", l_attrValue, i_flag, o_rc);
return o_rc;
}
//------------------------------------------------------------------------------
bool mfgMode()
{ return isMnfgFlagSet( MNFG_FLAG_THRESHOLDS ); }
bool isFabeRepairDisabled()
{ return isMnfgFlagSet( MNFG_FLAG_DISABLE_FABRIC_eREPAIR ); }
bool isMemeRepairDisabled()
{ return isMnfgFlagSet( MNFG_FLAG_DISABLE_MEMORY_eREPAIR ); }
bool mnfgTerminate()
{ return isMnfgFlagSet( MNFG_FLAG_SRC_TERM ); }
bool areDramRepairsDisabled()
{ return isMnfgFlagSet( MNFG_FLAG_DISABLE_DRAM_REPAIRS ); }
bool enableFastBgScrub()
{ return isMnfgFlagSet( MNFG_FLAG_FAST_BACKGROUND_SCRUB ); }
bool mnfgSpareDramDeploy()
{ return isMnfgFlagSet( MNFG_FLAG_TEST_DRAM_REPAIRS ); }
bool isMfgCeCheckingEnabled()
{ return isMnfgFlagSet( MNFG_FLAG_IPL_MEMORY_CE_CHECKING ); }
bool isMfgAvpEnabled()
{ return isMnfgFlagSet( MNFG_FLAG_AVP_ENABLE ); }
bool isMfgHdatAvpEnabled()
{ return isMnfgFlagSet( MNFG_FLAG_HDAT_AVP_ENABLE ); }
} // end namespace PlatServices
} // end namespace PRDF
|