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
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
|
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/usr/targeting/common/Targets.pm $
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2015,2017
# [+] 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
package Targets;
use strict;
use XML::Simple;
use XML::Parser;
use Data::Dumper;
use feature "state";
use constant
{
PERVASIVE_PARENT_CORE_OFFSET => 32,
PERVASIVE_PARENT_EQ_OFFSET => 16,
PERVASIVE_PARENT_XBUS_OFFSET => 6,
PERVASIVE_PARENT_OBUS_OFFSET => 9,
PERVASIVE_PARENT_MCBIST_OFFSET => 7,
PERVASIVE_PARENT_MCS_OFFSET => 7,
PERVASIVE_PARENT_MCA_OFFSET => 7,
PERVASIVE_PARENT_PEC_OFFSET => 13,
PERVASIVE_PARENT_PHB_OFFSET => 13,
PERVASIVE_PARENT_NPU_OFFSET => 5,
NUM_PROCS_PER_GROUP => 4,
};
my %maxInstance = (
"PROC" => 8,
"CORE" => 24,
"EX" => 12,
"EQ" => 6,
"ABUS" => 3,
"XBUS" => 3,
"OBUS" => 4,
"MCBIST" => 2,
"MCS" => 4,
"MCA" => 8,
"PHB" => 6, #PHB is same as PCIE
"PEC" => 3, #PEC is same as PBCQ
"MBA" => 2,
"PPE" => 51, #Only 21, but they are sparsely populated
"PERV" => 56, #Only 42, but they are sparsely populated
"CAPP" => 2,
"SBE" => 1,
"OBUS_BRICK" => 12,
"NPU" => 1,
"MI" => 4,
"OCC" => 1,
);
sub new
{
my $class = shift;
my $self = {
xml => undef,
data => undef,
targeting => undef,
enumerations => undef,
MAX_MCS => 0,
UNIT_COUNTS => undef,
master_proc => undef,
huid_idx => undef,
mru_idx => undef,
force => 0,
debug => 0,
version => "",
xml_version => 0,
errorsExist => 0,
NUM_PROCS => 0,
TOP_LEVEL => "",
TOPOLOGY => undef,
report_log => "",
vpd_num => 0,
DMI_FSI_MAP => {
'0' => '3',
'1' => '2',
'4' => '7',
'5' => '6'
}
# TODO RTC:132549
# DMI_FSI_MAP is a lookup table for DMI channel to FSI and ref clock.
# It is processor specific and needs to be pulled from a
# processor attribute instead of being hardcoded
};
return bless $self, $class;
}
sub setVersion
{
my $self = shift;
my $version = shift;
$self->{version} = $version;
}
sub getData
{
my $self = shift;
return $self->{data};
}
## loads ServerWiz XML format
sub loadXML
{
my $self = shift;
my $filename = shift;
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
print "Loading MRW XML: $filename\n";
$self->{xml} =
XMLin($filename,forcearray => [ 'child_id', 'hidden_child_id', 'bus',
'property', 'field', 'attribute',
'enumerator' ]);
if (defined($self->{xml}->{'enumerationTypes'}))
{
$self->{xml_version} = 1;
}
$self->storeEnumerations();
$self->storeGroups();
$self->buildHierarchy();
$self->buildAffinity();
$self->{report_filename}=$filename.".rpt";
$self->{report_filename}=~s/\.xml//g;
}
################################################
## prints out final XML for HOSTBOOT consumption
sub printXML
{
my $self = shift;
my $fh = shift;
my $t = shift;
my $atTop = 0;
if ($t eq "top")
{
$atTop = 1;
$t = $self->{targeting}->{SYS};
print $fh "<attributes>\n";
print $fh "<version>" . $self->{version} . "</version>\n";
}
if (ref($t) ne "ARRAY")
{
return;
}
for (my $p = 0; $p < scalar(@{$t}); $p++)
{
if (ref($t->[$p]) ne "HASH") { next; }
my $target = $t->[$p]->{KEY};
$self->printTarget($fh, $target);
my $children = $t->[$p];
foreach my $u (sort(keys %{$children}))
{
if ($u ne "KEY")
{
$self->printXML($fh, $t->[$p]->{$u});
}
}
}
if ($atTop)
{
print $fh "</attributes>\n";
}
}
sub printTarget
{
my $self = shift;
my $fh = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
if ($target eq "")
{
return;
}
print $fh "<targetInstance>\n";
my $target_id = $self->getAttribute($target, "PHYS_PATH");
$target_id = substr($target_id, 9);
$target_id =~ s/\///g;
$target_id =~ s/\-//g;
print $fh "\t<id>" . $target_id . "</id>\n";
print $fh "\t<type>" . $self->getTargetType($target) . "</type>\n";
## get attributes
foreach my $attr (sort (keys %{ $target_ptr->{ATTRIBUTES} }))
{
$self->printAttribute($fh, $target_ptr->{ATTRIBUTES}, $attr);
}
print $fh "</targetInstance>\n";
}
sub printAttribute
{
my $self = shift;
my $fh = shift;
my $target_ptr = shift;
my $attribute = shift;
my $r = "";
# TODO RTC: TBD
# temporary until we converge attribute types
my %filter;
$filter{MODEL} = 1;
$filter{NUMERIC_POD_TYPE_TEST} = 1;
if ($filter{$attribute} == 1)
{
return;
}
print $fh "\t<attribute>\n";
print $fh "\t\t<id>$attribute</id>\n";
my $value = $target_ptr->{$attribute}->{default};
if (ref($value) eq "HASH")
{
if (defined($value->{field}))
{
print $fh "\t\t<default>\n";
foreach my $f (sort keys %{ $value->{field} })
{
my $v = $value->{field}->{$f}->{value};
print $fh "\t\t\t<field><id>$f</id><value>$v</value></field>\n";
}
print $fh "\t\t</default>\n";
}
}
else
{
if ($value ne "") {
print $fh "\t\t<default>$value</default>\n";
}
}
print $fh "\t</attribute>\n";
}
## stores TYPE enumeration values which is used to generate HUIDs
sub storeEnumerations
{
my $self = shift;
my $baseptr = $self->{xml}->{enumerationType};
if ($self->{xml_version} == 1)
{
$baseptr = $self->{xml}->{enumerationTypes}->{enumerationType};
}
foreach my $enumType (keys(%{ $baseptr }))
{
foreach my $enum (
keys(%{$baseptr->{$enumType}->{enumerator}}))
{
$self->{enumeration}->{$enumType}->{$enum} =
$baseptr->{$enumType}->{enumerator}->{$enum}->{value};
}
}
}
sub storeGroups
{
my $self = shift;
foreach my $grp (keys(%{ $self->{xml}->{attributeGroups}
->{attributeGroup} }))
{
foreach my $attr (@{$self->{xml}->{attributeGroups}
->{attributeGroup}->{$grp}->{'attribute'}})
{
$self->{groups}->{$grp}->{$attr} = 1;
}
}
}
####################################################
## build target hierarchy recursively
##
## creates convenient data structure
## for accessing targets and busses
## Structure:
##
##{TARGETS} # location of all targets
##{NSTANCE_PATH} # keeps track of hierarchy
## path while iterating
##{TARGETS} -> target_name # specific target
##{TARGETS} -> target_name -> {TARGET} # pointer to target data
## from XML data struture
##{TARGETS} -> target_name -> {TYPE}# special attribute
##{TARGETS} -> target_name -> {PARENT} # parent target name
##{TARGETS} -> target_name -> {CHILDREN} # array of children targets
##{TARGETS} -> target_name -> {CONNECTION} -> {DEST} # array of connection
## destination targets
##{TARGETS} -> target_name -> {CONNECTION} -> {BUS} # array of busses
##{TARGETS} -> target_name -> {CHILDREN} # array of children targets
##{TARGETS} -> target_name -> {ATTRIBUTES} # attributes
## {ENUMERATION} -> enumeration_type -> enum # value of enumeration
## {BUSSES} -> bus_type[] # array of busses by
## bus_type (I2C, FSI, etc)
## {BUSSES} -> bus_type[] -> {BUS} # pointer to bus target
## from xml structure
## {BUSSES} -> bus_type[] -> {SOURCE_TARGET} # source target name
## {BUSSES} -> bus_type[] -> {DEST_TARGET} # dest target name
sub buildHierarchy
{
my $self = shift;
my $target = shift;
my $instance_path = $self->{data}->{INSTANCE_PATH};
if (!defined $instance_path)
{
$instance_path = "";
}
my $baseptr = $self->{xml}->{'targetInstance'};
if ($self->{xml_version} == 1)
{
$baseptr = $self->{xml}->{'targetInstances'}->{'targetInstance'};
}
if ($target eq "")
{
## find system target
foreach my $t (keys(%{$baseptr}))
{
if ($baseptr->{$t}->{attribute}->{TYPE}->{default} eq "SYS")
{
$self->{TOP_LEVEL} = $t;
$target = $t;
}
}
}
if ($target eq "")
{
die "Unable to find system top level target\n";
}
my $old_path = $instance_path;
my $target_xml = $baseptr->{$target};
my $affinity_target = $target;
my $key = $instance_path . "/" . $target;
if ($instance_path ne "")
{
$instance_path = "instance:" . substr($instance_path, 1);
}
else
{
$instance_path = "instance:";
}
$self->setAttribute($key, "INSTANCE_PATH", $instance_path);
$self->{data}->{TARGETS}->{$key}->{TARGET} = $target_xml;
$self->{data}->{INSTANCE_PATH} = $old_path . "/" . $target;
## copy attributes
foreach my $attribute (keys %{ $target_xml->{attribute} })
{
my $value = $target_xml->{attribute}->{$attribute}->{default};
if (ref($value) eq "HASH")
{
if (defined($value->{field}))
{
foreach my $f (keys %{ $value->{field} })
{
my $field_val=$value->{field}{$f}{value};
if (ref($field_val)) {
$self->setAttributeField($key, $attribute, $f,"");
}
else
{
$self->setAttributeField($key, $attribute, $f,
$value->{field}{$f}{value});
}
}
}
else
{
$self->setAttribute($key, $attribute, "");
}
}
else
{
$self->setAttribute($key, $attribute, $value);
}
}
## global attributes overwrite local
my $settingptr = $self->{xml}->{globalSetting};
if ($self->{xml_version} == 1)
{
$settingptr = $self->{xml}->{globalSettings}->{globalSetting};
}
foreach my $prop (keys %{$settingptr->{$key}->{property}})
{
my $val=$settingptr->{$key}->{property}->
{$prop}->{value};
$self->setAttribute($key, $prop, $val);
}
## Save busses
if (defined($target_xml->{bus}))
{
foreach my $b (@{ $target_xml->{bus} })
{
if (ref($b->{dest_path}) eq "HASH") {
$b->{dest_path}="";
}
if (ref($b->{source_path}) eq "HASH") {
$b->{source_path}="";
}
my $source_target =
$key . "/" . $b->{source_path} . $b->{source_target};
my $dest_target = $key . "/" . $b->{dest_path} . $b->{dest_target};
my $bus_type = $b->{bus_type};
push(
@{
$self->{data}->{TARGETS}->{$source_target}->{CONNECTION}
->{DEST}
},
$dest_target
);
push(
@{
$self->{data}->{TARGETS}->{$source_target}->{CONNECTION}
->{BUS}
},
$b
);
my %bus_entry;
$bus_entry{SOURCE_TARGET} = $source_target;
$bus_entry{DEST_TARGET} = $dest_target;
$bus_entry{BUS_TARGET} = $b;
push(@{ $self->{data}->{BUSSES}->{$bus_type} }, \%bus_entry);
}
}
foreach my $child (@{ $target_xml->{child_id} })
{
my $child_key = $self->{data}->{INSTANCE_PATH} . "/" . $child;
$self->{data}->{TARGETS}->{$child_key}->{PARENT} = $key;
push(@{ $self->{data}->{TARGETS}->{$key}->{CHILDREN} }, $child_key);
$self->buildHierarchy($child);
}
foreach my $child (@{ $target_xml->{hidden_child_id} })
{
my $child_key = $self->{data}->{INSTANCE_PATH} . "/" . $child;
$self->{data}->{TARGETS}->{$child_key}->{PARENT} = $key;
push(@{ $self->{data}->{TARGETS}->{$key}->{CHILDREN} }, $child_key);
$self->buildHierarchy($child);
}
$self->{data}->{INSTANCE_PATH} = $old_path;
}
##########################################################
## traces busses and builds affinity hierarchy
## HOSTBOOT expected hierarchy: sys/node/proc/<unit>
## sys/node/proc/mcs/membuf/<unit>
## sys/node/proc/mcs/membuf/mba/dimm
## This function also sets the common attributes for all the targets
## Common attributes include:
## - FAPI_NAME
## - PHYS_PATH
## - AFFINITY_PATH
## - ORDINAL_ID
## - HUID
sub buildAffinity
{
my $self = shift;
my $node = -1;
my $proc = -1;
my $tpm = -1;
my $sys_phys = "";
my $node_phys = "";
my $node_aff = "";
my $sys_pos = -1;
my $mcbist = -1;
$self->{membuf_inst_num}=0;
## count children target types
foreach my $target (sort keys %{ $self->{data}->{TARGETS} })
{
my $children = $self->getTargetChildren($target);
if ($children ne "") {
foreach my $child (@{ $children })
{
my $type = $self->getType($child);
$self->{UNIT_COUNTS}->{$target}->{$type}++;
}
}
}
foreach my $target (sort keys %{ $self->{data}->{TARGETS} })
{
my $target_ptr = $self->{data}->{TARGETS}{$target};
my $type = $self->getType($target);
my $type_id = $self->getEnumValue("TYPE", $type);
my $pos = $self->{data}->{TARGETS}{$target}{TARGET}{position};
$sys_pos = $pos if ($type eq "SYS");
if ($type_id eq "") { $type_id = 0; }
if ($type eq "SYS")
{
$proc = -1;
$node = -1;
$self->{targeting}{SYS}[0]{KEY} = $target;
#SYS target has PHYS_PATH and AFFINITY_PATH defined in the XML
#Also, there is no HUID for SYS
$self->setAttribute($target,"FAPI_NAME",getFapiName($type));
$self->setAttribute($target,"FAPI_POS", $pos);
$self->setAttribute($target,"ORDINAL_ID", $pos);
$sys_phys = $self->getAttribute($target, "PHYS_PATH");
$sys_phys = substr($sys_phys, 9);
}
elsif ($type eq "NODE")
{
$proc = -1;
$self->{membuf_inst_num} = 0;
$node++;
$node_phys = "physical:".$sys_phys."/node-$node";
$node_aff = "affinity:".$sys_phys."/node-$node";
$self->{targeting}{SYS}[0]{NODES}[$node]{KEY} = $target;
$self->setHuid($target, $sys_pos, $node);
$self->setAttribute($target, "FAPI_NAME",getFapiName($type));
$self->setAttribute($target, "FAPI_POS", $pos);
$self->setAttribute($target, "PHYS_PATH", $node_phys);
$self->setAttribute($target, "AFFINITY_PATH", $node_aff);
$self->setAttribute($target, "ORDINAL_ID", $pos);
}
elsif ($type eq "TPM")
{
$tpm++;
$self->{targeting}{SYS}[0]{NODES}[$node]{TPMS}[$tpm]{KEY} = $target;
my $tpm_phys = $node_phys . "/tpm-$tpm";
my $tpm_aff = $node_aff . "/tpm-$tpm";
$self->setHuid($target, $sys_pos, $tpm);
$self->setAttribute($target, "FAPI_NAME",getFapiName($type));
$self->setAttribute($target, "FAPI_POS", $pos);
$self->setAttribute($target, "PHYS_PATH", $tpm_phys);
$self->setAttribute($target, "AFFINITY_PATH", $tpm_aff);
$self->setAttribute($target, "ORDINAL_ID", $pos);
}
elsif ($type eq "MCS")
{
$self->setAttribute($target, "VPD_REC_NUM", 0);
$self->setAttribute($target, "MEMVPD_POS",
$self->getAttribute($target, "CHIP_UNIT"));
}
elsif ($type eq "MCA")
{
my $ddrs = $self->findConnections($target,"DDR4","");
$self->processDimms($ddrs, $sys_pos, $node_phys, $node, $proc);
}
elsif ($type eq "PROC")
{
$proc++;
my $num_mcs = 0;
### count number of MCSs
foreach my $unit (@{ $self->{data}->{TARGETS}{$target}{CHILDREN} })
{
my $unit_type = $self->getType($unit);
if ($unit_type eq "MCBIST")
{
$num_mcs+=2; # 2 MCS's per MCBIST
}
}
if ($num_mcs > $self->{MAX_MCS})
{
$self->{MAX_MCS} = $num_mcs;
}
$self->{NUM_PROCS_PER_NODE} = $proc + 1;
$self->{targeting}->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{KEY} =
$target;
my $socket=$self->getTargetParent($self->getTargetParent($target));
my $parent_affinity = $node_aff . "/proc-$proc";
my $parent_physical = $node_phys . "/proc-$proc";
my $fapi_name = getFapiName($type, $node, $proc);
$self->setHuid($target, $sys_pos, $node);
$self->setAttribute($target, "FAPI_NAME", $fapi_name);
$self->setAttribute($target, "PHYS_PATH", $parent_physical);
$self->setAttribute($target, "AFFINITY_PATH", $parent_affinity);
$self->setAttribute($target, "ORDINAL_ID", $proc);
$self->setAttribute($target, "POSITION", $proc);
$self->setAttribute($target, "FABRIC_GROUP_ID",
$self->getAttribute($socket,"FABRIC_GROUP_ID"));
$self->setAttribute($target, "FABRIC_CHIP_ID",
$self->getAttribute($socket,"FABRIC_CHIP_ID"));
$self->setAttribute($target, "VPD_REC_NUM", $proc);
$self->setAttribute($target, "FAPI_POS",
$self->getAttribute($socket,"FABRIC_GROUP_ID") *
NUM_PROCS_PER_GROUP +
$self->getAttribute($socket,"FABRIC_CHIP_ID"));
$self->iterateOverChiplets($target, $sys_pos, $node, $proc);
}
}
}
sub iterateOverChiplets
{
my $self = shift;
my $target = shift;
my $sys = shift;
my $node = shift;
my $proc = shift;
my $tgt_ptr = $self->getTarget($target);
my $tgt_type = $self->getType($target);
my $target_children = $self->getTargetChildren($target);
if ($target_children eq "")
{
return "";
}
else
{
my @phb_array = ();
my @non_connected_phb_array = ();
foreach my $child (@{ $self->getTargetChildren($target) })
{
# For PEC children, we need to remove duplicate PHB targets
if ($tgt_type eq "PEC")
{
my $pec_num = $self->getAttribute($target, "CHIP_UNIT");
$self->setAttribute($child,"AFFINITY_PATH",$self
->getAttribute($target,"AFFINITY_PATH"));
$self->setAttribute($child,"PHYS_PATH",$self
->getAttribute($target,"PHYS_PATH"));
foreach my $phb (@{ $self->getTargetChildren($child) })
{
my $phb_num = $self->getAttribute($phb, "CHIP_UNIT");
foreach my $pcibus (@{ $self->getTargetChildren($phb) })
{
# We need to ensure that all PHB's get added to the
# MRW, but PHB's with busses connected take priority
# and we cannot have duplicate PHB targets in the MRW.
# We processes every PHB pci bus config starting with
# the config with the fewest PHB's. For PEC2 we start
# with PHB3_x16. If a bus is not connected to that PHB
# we add it to the phb_array anyway so the target will
# be populated in the HB MRW. As we processes the later
# PHB configs under PEC2 we may find that PHB3 has a
# bus connected to it. Since the bus config takes
# priority over the target that was already added to
# the phb_array, we just overwrite that phb_array entry
# with the PHB that has a bus connected.
if (($self->getNumConnections($pcibus) > 0) &&
(@phb_array[$phb_num] eq ""))
{
# This PHB does have a bus connection and the slot
# is empty. We must add it to the PHB array
@phb_array[$phb_num] = $phb;
}
elsif (($self->getNumConnections($pcibus) == 0) &&
(@phb_array[$phb_num] eq ""))
{
# This PHB does NOT have a bus connection. It's
# slot is still empty, so we must add it to the
# array so every PHB has a target in the MRW.
@phb_array[$phb_num] = $phb;
# Also add it to the non_connected_phb_array so we
# can examine later it if needs to be overriden.
@non_connected_phb_array[$phb_num] = $phb;
}
elsif (($self->getNumConnections($pcibus) > 0) &&
(@phb_array[$phb_num] ne ""))
{
# This PHB has a connection, but the slot has
# already been filled by another PHB. We need to
# check if it was a non connected PHB
if(@non_connected_phb_array[$phb_num] ne "")
{
# The previous connection in the PHB elecment
# is not connected to a bus. We should
# override it
@phb_array[$phb_num] = $phb;
}
else
{
# This is our "bug" scenerio. We have found a
# connection, but that PHB element is already
# filled in the array. We need to kill the
# program.
printf("Found a duplicate connection for PEC %s PHB %s.\n",$pec_num,$phb_num);
die "Duplicate PHB bus connection found\n";
}
}
}
}
}
else
{
my $unit_ptr = $self->getTarget($child);
my $unit_type = $self->getType($child);
#System XML has some sensor target as hidden children
#of targets. We don't care for sensors in this function
#So, we can avoid them with this conditional
if ($unit_type ne "NA" && $unit_type ne "FSI" &&
$unit_type ne "PCI")
{
#set common attrs for child
$self->setCommonAttrForChiplet($child, $sys, $node, $proc);
$self->iterateOverChiplets($child, $sys, $node, $proc);
}
}
}
my $size = @phb_array;
# For every entry in the PHB array, if there is a PHB in its slot
# we add that PHB target to the MRW.
# We process PEC's individually, so we need to make sure the PHB slot
# has a PHB in it. eg: phb_array[0] will be empty for when processing
# PEC1 and 2 as there is no PHB0 configured for those PECs.
for (my $i = 0; $i < $size; $i++)
{
if (@phb_array[$i] ne "")
{
$self->setCommonAttrForChiplet
(@phb_array[$i], $sys, $node, $proc);
}
}
}
}
sub setCommonAttrForChiplet
{
my $self = shift;
my $target = shift;
my $sys = shift;
my $node = shift;
my $proc = shift;
my $tgt_ptr = $self->getTarget($target);
my $tgt_type = $self->getType($target);
push(@{$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{$tgt_type}},
{ 'KEY' => $target });
#This is a static variable. Persists over time
#everything that is a grand_children of proc
state %grand_children;
if (not %grand_children)
{
$grand_children{"EX"} = 1;
$grand_children{"CORE"} = 1;
$grand_children{"MCS"} = 1;
$grand_children{"MCA"} = 1;
}
my $pos = $self->getAttribute($target, "CHIP_UNIT");
my $unit_pos = $pos;
#HB expects chiplets' positions in AFFINITY_PATH to be relative to the
#parent, serverwiz outputs it unique/absolute.
#Since, in P9, each of the chiplets only have
#up to two children (each eq has 2 ex, each ex has 2 cores, each mcbist has
#two mcs, etc), we can simply calculate this by (absolute_Pos%2)
#CHIP_UNIT is absolute position
if ($grand_children{$tgt_type} eq 1)
{
$unit_pos = $pos%2;
}
elsif ($tgt_type eq "OBUS_BRICK")
{
$unit_pos = $pos%3;
}
my $parent_affinity = $self->getAttribute(
$self->getTargetParent($target),"AFFINITY_PATH");
my $parent_physical = $self->getAttribute(
$self->getTargetParent($target),"PHYS_PATH");
my $affinity_path = $parent_affinity . "/" . lc $tgt_type ."-". $unit_pos;
my $physical_path = $parent_physical . "/" . lc $tgt_type ."-". $unit_pos;
my $fapi_name = getFapiName($tgt_type, $node, $proc, $pos);
#unique offset per system
my $offset = ($proc * $maxInstance{$tgt_type}) + $pos;
$self->{huid_idx}->{$tgt_type} = $offset;
$self->setHuid($target, $sys, $node);
$self->setAttribute($target, "FAPI_NAME", $fapi_name);
$self->setAttribute($target, "PHYS_PATH", $physical_path);
$self->setAttribute($target, "AFFINITY_PATH", $affinity_path);
$self->setAttribute($target, "ORDINAL_ID", $pos);
$self->setAttribute($target, "FAPI_POS", $offset);
$self->setAttribute($target, "REL_POS", $pos);
my $pervasive_parent= getPervasiveForUnit("$tgt_type$pos");
if ($pervasive_parent ne "")
{
my $perv_parent_val =
"physical:sys-$sys/node-$node/proc-$proc/perv-$pervasive_parent";
$self->setAttribute($target, "PARENT_PERVASIVE", $perv_parent_val);
}
}
sub getFapiName
{
my $target = shift;
my $node = shift;
my $chipPos = shift;
my $chipletPos = shift;
if ($target eq "")
{
die "getFapiName: ERROR: Please specify a taget name\n";
}
#This is a static variable. Persists over time
state %nonFapiTargets;
if (not %nonFapiTargets)
{
$nonFapiTargets{"NODE"} = "NA";
$nonFapiTargets{"TPM"} = "NA";
$nonFapiTargets{"NVBUS"} = "NA";
$nonFapiTargets{"OCC"} = "NA";
$nonFapiTargets{"NPU"} = "NA";
}
if ($nonFapiTargets{$target} eq "NA")
{
return $nonFapiTargets{$target};
}
elsif ($target eq "SYS")
{
return "k0";
}
elsif ($target eq "PROC" || $target eq "DIMM")
{
if ($node eq "" || $chipPos eq "")
{
die "getFapiName: ERROR: Must specify node and chipPos for $target
current node: $node, chipPos: $chipPos\n";
}
my $chip_name = ($target eq "PROC") ? "pu" : "dimm";
my $fapi_name = sprintf("%s:k0:n%d:s0:p%02d",$chip_name,$node,$chipPos);
return $fapi_name;
}
else
{
if ($node eq "" || $chipPos eq "" || $chipletPos eq "")
{
die "getFapiName: ERROR: Must specify node, chipPos,
chipletPos for $target. Current node: $node, chipPos: $chipPos
chipletPos: $chipletPos\n";
}
$target = lc $target;
my $fapi_name = sprintf("pu.$target:k0:n%d:s0:p%02d:c%d",
$node, $chipPos, $chipletPos);
return $fapi_name;
}
}
sub getPervasiveForUnit
{
# Input should be of the form <type><chip unit>, example: "core0"
my ($unit) = @_;
# The mapping is a static variable that is preserved across new calls to
# the function to speed up the mapping performance
state %unitToPervasive;
if ( not %unitToPervasive )
{
for my $core (0..$maxInstance{"CORE"}-1)
{
$unitToPervasive{"CORE$core"} = PERVASIVE_PARENT_CORE_OFFSET+$core;
}
for my $eq (0..$maxInstance{"EQ"}-1)
{
$unitToPervasive{"EQ$eq"} = PERVASIVE_PARENT_EQ_OFFSET + $eq;
}
for my $xbus (0..$maxInstance{"XBUS"}-1)
{
$unitToPervasive{"XBUS$xbus"} = PERVASIVE_PARENT_XBUS_OFFSET;
}
for my $obus (0..$maxInstance{"OBUS"}-1)
{
$unitToPervasive{"OBUS$obus"} = PERVASIVE_PARENT_OBUS_OFFSET+$obus;
}
for my $capp (0..$maxInstance{"CAPP"}-1)
{
$unitToPervasive{"CAPP$capp"} = 2 * ($capp+1);
}
for my $mcbist (0..$maxInstance{"MCBIST"}-1)
{
$unitToPervasive{"MCBIST$mcbist"} =
PERVASIVE_PARENT_MCBIST_OFFSET + $mcbist;
}
for my $mcs (0..$maxInstance{"MCS"}-1)
{
$unitToPervasive{"MCS$mcs"} =
PERVASIVE_PARENT_MCS_OFFSET + ($mcs > 1);
}
for my $mca (0..$maxInstance{"MCA"}-1)
{
$unitToPervasive{"MCA$mca"} =
PERVASIVE_PARENT_MCA_OFFSET + ($mca > 3);
}
for my $pec (0..$maxInstance{"PEC"}-1)
{
$unitToPervasive{"PEC$pec"} =
PERVASIVE_PARENT_PEC_OFFSET + $pec;
}
for my $phb (0..$maxInstance{"PHB"}-1)
{
$unitToPervasive{"PHB$phb"} =
PERVASIVE_PARENT_PHB_OFFSET + ($phb>0) + ($phb>2);
}
my $offset = 0;
for my $obrick (0..$maxInstance{"OBUS_BRICK"}-1)
{
$offset += (($obrick%3 == 0) && ($obrick != 0)) ? 1 : 0;
$unitToPervasive{"OBUS_BRICK$obrick"}
= PERVASIVE_PARENT_OBUS_OFFSET + $offset;
}
for my $npu (0..$maxInstance{"NPU"}-1)
{
$unitToPervasive{"NPU$npu"} = PERVASIVE_PARENT_NPU_OFFSET;
}
}
my $pervasive = "";
if(exists $unitToPervasive{$unit})
{
$pervasive = $unitToPervasive{$unit};
}
return $pervasive
}
sub processDimms
{
my $self = shift;
my $ddrs = shift;
my $sys = shift;
my $node_phys = shift;
my $node = shift;
my $proc = shift;
if ($ddrs ne "")
{
#There should be 2 Connections
#Each MCA has 2 ddr channels
foreach my $dimms (@{$ddrs->{CONN}})
{
my $ddr = $dimms->{SOURCE};
my $port_num = $self->getAttribute($ddr,"MBA_PORT");
my $dimm_num = $self->getAttribute($ddr,"MBA_DIMM");
my $dimm=$dimms->{DEST_PARENT};
#proc->mcbist->mcs->mca->ddr
my $mca_target = $self->getTargetParent($ddr);
my $mcs_target = $self->getTargetParent($mca_target);
my $mcbist_target = $self->getTargetParent($mcs_target);
my $proc_target = $self->getTargetParent($mcbist_target);
my $dimm_connector_tgt = $self->getTargetParent($dimm);
my $mca = $self->getAttribute($mca_target, "CHIP_UNIT")%2;
my $mcs = $self->getAttribute($mcs_target, "CHIP_UNIT")%2;
my $mcbist = $self->getAttribute($mcbist_target, "CHIP_UNIT");
my $dimm_pos= $self->getAttribute($dimm_connector_tgt,"POSITION");
$self->setAttribute($dimm, "AFFINITY_PATH",
$self->getAttribute($mcbist_target, "AFFINITY_PATH")
. "/mcs-$mcs/mca-$mca/dimm-$port_num"
);
$self->setAttribute($dimm, "PHYS_PATH",
$node_phys . "/dimm-" . $dimm_pos);
my $type = $self->getType($dimm);
$self->setAttribute($dimm, "ORDINAL_ID",$dimm_pos);
$self->setAttribute($dimm, "POSITION", $dimm_pos);
$self->setAttribute($dimm, "VPD_REC_NUM", $dimm_pos);
$self->setAttribute($dimm, "REL_POS", $port_num);
$self->setAttribute($dimm, "MBA_DIMM", $port_num); #which dimm
$self->setAttribute($dimm, "MBA_PORT", 0); #0, each MCA is a port
## set all FAPI_POS
my $MCBIST_PER_CHIP = $self->{UNIT_COUNTS}->
{$proc_target}->{MCBIST};
my $MCS_PER_CHIP = $self->{UNIT_COUNTS}->
{$mcbist_target}->{MCS} * $MCBIST_PER_CHIP;
my $MCA_PER_CHIP = $self->{UNIT_COUNTS}->
{$mcs_target}->{MCA} * $MCS_PER_CHIP;
my $DIMM_PER_MCA = 2;
my $parent_proc_fapi_pos =
$self->getAttribute($proc_target, "FAPI_POS");
my $mcbist_pos = ($parent_proc_fapi_pos * $MCBIST_PER_CHIP) +
$self->getAttribute($mcbist_target,"REL_POS");
my $mcs_pos = ($parent_proc_fapi_pos * $MCS_PER_CHIP) +
$self->getAttribute($mcs_target,"REL_POS");
my $mca_pos = ($parent_proc_fapi_pos * $MCA_PER_CHIP) +
$self->getAttribute($mca_target,"REL_POS");
my $dimm_pos = ($mca_pos * $DIMM_PER_MCA) +
$self->getAttribute($dimm,"REL_POS");
$self->setAttribute($dimm,"FAPI_NAME",
getFapiName($type, $node, $dimm_pos));
$self->setAttribute($mcbist_target, "FAPI_POS", $mcbist_pos);
$self->setAttribute($mcs_target, "FAPI_POS", $mcs_pos);
$self->setAttribute($mca_target, "FAPI_POS", $mca_pos);
$self->setAttribute($dimm, "FAPI_POS", $dimm_pos);
$self->{huid_idx}->{$type} = $dimm_pos;
$self->setHuid($dimm, $sys, $node);
$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{MCBISTS}[$mcbist]
{MCSS}[$mcs]{MCAS}[$mca]{DIMMS}[$dimm_pos]{KEY}
= $dimm;
}
}
}
sub processMcs
{
#@TODO RTC:163874
#Most of the nimmbus functionality is already in incorporated in other
#functions. Leaving this in as we may need this code for centaur/cumulus.
=begin
my $self = shift;
my $unit = shift;
my $node = shift;
my $proc = shift;
my $mcbist = shift;
my $parent_affinity = shift;
my $parent_physical = shift;
my $node_phys = shift;
my $mcs = $self->getAttribute($unit, "CHIP_UNIT");
my $membufnum = $proc * $self->{MAX_MCS} + $mcs;
$self->setAttribute($unit, "AFFINITY_PATH",$parent_affinity . "/mcs-$mcs");
$self->setAttribute($unit, "PHYS_PATH", $parent_physical . "/mcs-$mcs");
$self->setAttribute($unit, "MCS_NUM", $mcs);
$self->setHuid($unit, 0, $node);
$self->{targeting}{SYS}[0]{NODES}[$node]{MCBISTS}{$mcbist}{MCSS}[$mcs]{KEY}
= $unit;
# $self->setAttribute($unit, "EI_BUS_TX_LANE_INVERT","0");
# $self->setAttribute($unit, "EI_BUS_TX_MSBSWAP","0");
# $self->setAttribute($unit, "DMI_REFCLOCK_SWIZZLE","0");
## Find connected membufs
my $membuf_dmi = $self->{data}->{TARGETS}{$unit}{CONNECTION}{DEST}[0];
if (defined($membuf_dmi))
{
## found membuf connected
my $membuf =
$self->{data}->{TARGETS}{$membuf_dmi}
{PARENT}; ## get parent of dmi unit which is membuf
my $dmi_bus = $self->{data}->{TARGETS}{$unit}{CONNECTION}{BUS}[0];
$self->setAttribute($membuf, "POSITION",$membufnum);
$self->setAttribute($membuf, "AFFINITY_PATH",
$parent_affinity . "/mcs-$mcs/membuf-$membufnum");
$self->setAttribute($membuf, "PHYS_PATH",
$node_phys . "/membuf-$membufnum");
## copy DMI bus attributes to membuf
$self->setAttribute($unit, "EI_BUS_TX_LANE_INVERT",
$dmi_bus->{bus_attribute}->{PROC_TX_LANE_INVERT}->{default});
$self->setAttribute($unit, "EI_BUS_TX_MSBSWAP",
$dmi_bus->{bus_attribute}->{PROC_TX_MSBSWAP}->{default});
$self->setAttribute($membuf, "EI_BUS_TX_LANE_INVERT",
$dmi_bus->{bus_attribute}->{MEMBUF_TX_LANE_INVERT}->{default});
$self->setAttribute($membuf, "EI_BUS_TX_MSBSWAP",
$dmi_bus->{bus_attribute}->{MEMBUF_TX_MSBSWAP}->{default});
## auto setup FSI assuming schematic symbol. If FSI busses are
## defined in serverwiz2, this will be overridden
## in the schematic symbol, the fsi port num matches dmi ref clk num
my $fsi_port = $self->{DMI_FSI_MAP}->{$mcs};
my $proc_key =
$self->{targeting}->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{KEY};
my $proc_path = $self->getAttribute($proc_key,"PHYS_PATH");
$self->setFsiAttributes($membuf,"FSICM",0,$proc_path,$fsi_port,0);
$self->setAttribute($unit, "DMI_REFCLOCK_SWIZZLE",$fsi_port);
my $dmi_swizzle =
$self->getBusAttribute($unit,0,"DMI_REFCLOCK_SWIZZLE");
if ($dmi_swizzle ne "")
{
$self->setAttribute($unit, "DMI_REFCLOCK_SWIZZLE",$dmi_swizzle);
}
$self->setHuid($membuf, 0, $node);
$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{MCSS}[$mcs] {MEMBUFS}[0]{KEY} =
$membuf;
$self->setAttribute($membuf, "ENTITY_INSTANCE",
$self->{membuf_inst_num});
$self->{membuf_inst_num}++;
## get the mbas
foreach my $child (@{ $self->{data}->{TARGETS}{$membuf}{CHILDREN} })
{
## need to not hardcard the subunits
if ($self->getType($child) eq "L4")
{
$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{MCSS}[$mcs]{MEMBUFS}[0]
{L4S}[0] {KEY} = $child;
$self->setAttribute($child, "AFFINITY_PATH",
$parent_affinity . "/mcs-$mcs/membuf-$membufnum/l4-0");
$self->setAttribute($child, "PHYS_PATH",
$node_phys . "/membuf-$membufnum/l4-0");
$self->setHuid($child, 0, $node);
}
if ($self->getType($child) eq "MCA")
{
my $mba = $self->getAttribute($child,"MBA_NUM");
$self->setAttribute($child, "AFFINITY_PATH",
$parent_affinity . "/mcs-$mcs/membuf-$membufnum/mba-$mba");
$self->setAttribute($child, "PHYS_PATH",
$node_phys . "/membuf-$membufnum/mba-$mba");
$self->setHuid($child, 0, $node);
$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc]{MCSS}[$mcs]{MEMBUFS}[0]
{MBAS}[$mba]{KEY} = $child;
## Trace the DDR busses to find connected DIMM
my $ddrs = $self->findConnections($child,"DDR4","");
if ($ddrs ne "")
{
my $affinitypos=0;
foreach my $dimms (@{$ddrs->{CONN}})
{
my $ddr = $dimms->{SOURCE};
my $port_num = $self->getAttribute($ddr,"MBA_PORT");
my $dimm_num = $self->getAttribute($ddr,"MBA_DIMM");
my $dimm=$dimms->{DEST_PARENT};
$self->setAttribute($dimm,"MBA_PORT",$port_num);
$self->setAttribute($dimm,"MBA_DIMM",$dimm_num);
my $aff_pos=16*$proc+$mcs*$self->{MAX_MCS}+4*$mba+
2*$port_num+$dimm_num;
$self->setAttribute($dimm, "AFFINITY_PATH",
$parent_affinity
. "/mcs-$mcs/membuf-$membufnum/mba-$mba/dimm-$affinitypos"
);
$self->setAttribute($dimm, "PHYS_PATH",
$node_phys . "/dimm-" . $self->{dimm_tpos});
$self->setAttribute($dimm, "POSITION",
$aff_pos);
$self->setAttribute($dimm, "VPD_REC_NUM",
$aff_pos);
$self->setHuid($dimm, 0, $node);
$self->{targeting}
->{SYS}[0]{NODES}[$node]{PROCS}[$proc] {MCSS}[$mcs]
{MEMBUFS}[0]{MBAS}[$mba] {DIMMS}[$affinitypos]{KEY} =
$dimm;
$self->setAttribute($dimm, "ENTITY_INSTANCE",
$self->{dimm_tpos});
$self->{dimm_tpos}++;
$affinitypos++;
}
}
}
}
}
=cut
}
sub setFsiAttributes
{
my $self = shift;
my $target = shift;
my $type = shift;
my $cmfsi = shift;
my $phys_path = shift;
my $fsi_port = shift;
my $flip_port = shift;
$self->setAttribute($target, "FSI_MASTER_TYPE","NO_MASTER");
if ($type eq "FSIM")
{
$self->setAttribute($target, "FSI_MASTER_TYPE","MFSI");
}
if ($type eq "FSICM")
{
$self->setAttribute($target, "FSI_MASTER_TYPE","CMFSI");
}
$self->setAttribute($target, "FSI_MASTER_CHIP","physical:sys");
$self->setAttribute($target, "FSI_MASTER_PORT","0xFF");
$self->setAttribute($target, "ALTFSI_MASTER_CHIP","physical:sys");
$self->setAttribute($target, "ALTFSI_MASTER_PORT","0xFF");
$self->setAttribute($target, "FSI_SLAVE_CASCADE", "0");
if ($cmfsi == 0)
{
$self->setAttribute($target, "FSI_MASTER_CHIP",$phys_path);
$self->setAttribute($target, "FSI_MASTER_PORT", $fsi_port);
}
else
{
$self->setAttribute($target, "ALTFSI_MASTER_CHIP",$phys_path);
$self->setAttribute($target, "ALTFSI_MASTER_PORT", $fsi_port);
}
$self->setAttributeField($target, "FSI_OPTION_FLAGS","flipPort",
$flip_port);
$self->setAttributeField($target, "FSI_OPTION_FLAGS","reserved", "0");
}
## remove target
sub removeTarget
{
my $self = shift;
my $target = shift;
delete $self->{data}->{TARGETS}->{$target};
}
## returns pointer to target from target name
sub getTarget
{
my $self = shift;
my $target = shift;
return $self->{data}->{TARGETS}->{$target};
}
## returns pointer to array of all targets
sub getAllTargets
{
my $self = shift;
my $target = shift;
return $self->{data}->{TARGETS};
}
## returns the target name of the parent of passed in target
sub getTargetParent
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{PARENT};
}
## returns the number of connections associated with target
sub getNumConnections
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($target_ptr->{CONNECTION}->{DEST}))
{
return 0;
}
return scalar(@{ $target_ptr->{CONNECTION}->{DEST} });
}
## returns destination target name of first connection
## useful for point to point busses with only 1 endpoint
sub getFirstConnectionDestination
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{CONNECTION}->{DEST}->[0];
}
## returns pointer to bus of first connection
sub getFirstConnectionBus
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{CONNECTION}->{BUS}->[0];
}
## returns target name of $i connection
sub getConnectionDestination
{
my $self = shift;
my $target = shift;
my $i = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{CONNECTION}->{DEST}->[$i];
}
sub getConnectionBus
{
my $self = shift;
my $target = shift;
my $i = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{CONNECTION}->{BUS}->[$i];
}
sub findFirstEndpoint
{
my $self = shift;
my $target = shift;
my $bus_type = shift;
my $end_type = shift;
my $target_children = $self->getTargetChildren($target);
if ($target_children eq "") { return ""; }
foreach my $child (@{ $self->getTargetChildren($target) })
{
my $child_bus_type = $self->getBusType($child);
if ($child_bus_type eq $bus_type)
{
for (my $i = 0; $i < $self->getNumConnections($child); $i++)
{
my $dest_target = $self->getConnectionDestination($child, $i);
my $dest_parent = $self->getTargetParent($dest_target);
my $type = $self->getMrwType($dest_parent);
my $dest_type = $self->getType($dest_parent);
if ($type eq "NA") { $type = $dest_type; }
if ($type eq $end_type)
{
return $dest_parent;
}
}
}
}
return "";
}
sub findConnections
{
my $self = shift;
my $target = shift;
my $bus_type = shift;
my $end_type = shift;
my %connections;
my $num=0;
my $target_children = $self->getTargetChildren($target);
if ($target_children eq "")
{
return "";
}
foreach my $child ($self->getAllTargetChildren($target))
{
my $child_bus_type = $self->getBusType($child);
if ($child_bus_type eq $bus_type)
{
for (my $i = 0; $i < $self->getNumConnections($child); $i++)
{
my $dest_target = $self->getConnectionDestination($child, $i);
my $dest_parent = $self->getTargetParent($dest_target);
my $type = $self->getMrwType($dest_parent);
my $dest_type = $self->getType($dest_parent);
my $dest_class = $self->getAttribute($dest_parent,"CLASS");
if ($type eq "NA")
{
$type = $dest_type;
}
if ($type eq "NA") {
$type = $dest_class;
}
if ($end_type ne "") {
#Look for an end_type match on any ancestor, as
#connections may have a destination unit with a hierarchy
#like unit->pingroup->muxgroup->chip where the chip has
#the interesting type.
while ($type ne $end_type) {
$dest_parent = $self->getTargetParent($dest_parent);
if ($dest_parent eq "") {
last;
}
$type = $self->getMrwType($dest_parent);
if ($type eq "NA") {
$type = $self->getType($dest_parent);
}
if ($type eq "NA") {
$type = $self->getAttribute($dest_parent, "CLASS");
}
}
}
if ($type eq $end_type || $end_type eq "")
{
$connections{CONN}[$num]{SOURCE}=$child;
$connections{CONN}[$num]{SOURCE_PARENT}=$target;
$connections{CONN}[$num]{DEST}=$dest_target;
$connections{CONN}[$num]{DEST_PARENT}=$dest_parent;
$connections{CONN}[$num]{BUS_NUM}=$i;
$num++;
}
}
}
}
if ($num==0) { return ""; }
return \%connections;
}
## returns BUS_TYPE attribute of target
sub getBusType
{
my $self = shift;
my $target = shift;
my $type = $self->getAttribute($target, "BUS_TYPE");
if ($type eq "") { $type = "NA"; }
return $type;
}
## return target type
sub getType
{
my $self = shift;
my $target = shift;
my $type = $self->getAttribute($target, "TYPE");
if ($type eq "") { $type = "NA"; }
return $type;
}
## return target type
sub getMrwType
{
my $self = shift;
my $target = shift;
my $type = $self->getAttribute($target, "MRW_TYPE");
if ($type eq "") { $type = "NA"; }
return $type;
}
## returns target instance name
sub getInstanceName
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{TARGET}->{instance_name};
}
## returns the parent target type
sub getTargetType
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
return $target_ptr->{TARGET}->{type};
}
## checks if attribute is value
## must be defined and have a non-empty value
sub isBadAttribute
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $badvalue = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}))
{
return 1;
}
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}))
{
return 1;
}
if ($target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq "")
{
return 1;
}
if (defined $badvalue &&
$target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq $badvalue)
{
return 1;
}
return 0;
}
## checks if complex attribute field is
## defined and non-empty
sub isBadComplexAttribute
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $field = shift;
my $badvalue = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}))
{
return 1;
}
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}))
{
return 1;
}
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}->{field}))
{
return 1;
}
if ($target_ptr->{ATTRIBUTES}->{$attribute}->{default}->{field}->{$field}
->{value} eq "")
{
return 1;
}
if ($target_ptr->{ATTRIBUTES}->{$attribute}->{default}->{field}->{$field}
->{value} eq $badvalue)
{
return 1;
}
return 0;
}
## returns attribute value
sub getAttribute
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}))
{
printf("ERROR: getAttribute(%s,%s) | Attribute not defined\n",
$target, $attribute);
$self->myExit(4);
}
if (ref($target_ptr->{ATTRIBUTES}->{$attribute}->{default}) eq "HASH")
{
return "";
}
return $target_ptr->{ATTRIBUTES}->{$attribute}->{default};
}
sub getAttributeGroup
{
my $self = shift;
my $target = shift;
my $group = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($self->{groups}->{$group})) {
printf("ERROR: getAttributeGroup(%s,%s) | Group not defined\n",
$target, $group);
$self->myExit(4);
}
my %attr;
foreach my $attribute (keys(%{$self->{groups}->{$group}}))
{
if (defined($target_ptr->{ATTRIBUTES}->{$attribute}->{default}))
{
$attr{$attribute} = $target_ptr->{ATTRIBUTES}->{$attribute};
}
}
return \%attr;
}
## renames a target attribute
sub renameAttribute
{
my $self = shift;
my $target = shift;
my $oldName = shift;
my $newName = shift;
my $target_ptr = $self->{data}->{TARGETS}->{$target};
if (!defined($target_ptr->{ATTRIBUTES}->{$oldName}))
{
return 1;
}
$target_ptr->{ATTRIBUTES}->{$newName}->{default} =
$target_ptr->{ATTRIBUTES}->{$oldName}->{default};
delete($target_ptr->{ATTRIBUTES}->{$oldName});
$self->log($target, "Renaming attribute: $oldName => $newName");
return 0;
}
## copy an attribute between targets
sub copyAttribute
{
my $self = shift;
my $source_target = shift;
my $dest_target = shift;
my $attribute = shift;
my $value=$self->getAttribute($source_target,$attribute);
$self->setAttribute($dest_target,$attribute,$value);
$self->log($dest_target, "Copy Attribute: $attribute=$value");
}
## copy an attribute between targets
sub copyAttributeFields
{
my $self = shift;
my $source_target = shift;
my $dest_target = shift;
my $attribute = shift;
foreach my $f(sort keys
%{$self->{data}->{TARGETS}->{$source_target}->{ATTRIBUTES}->{$attribute}->{default}->{field}})
{
my $field_val = $self->getAttributeField($source_target,
$attribute, $f);
$self->setAttributeField($dest_target,$attribute,$f,
$field_val);
$self->log($dest_target, "Copy Attribute Field:$attribute($f)=$field_val");
}
}
## sets an attribute
sub setAttribute
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $value = shift;
my $target_ptr = $self->getTarget($target);
$target_ptr->{ATTRIBUTES}->{$attribute}->{default} = $value;
$self->log($target, "Setting Attribute: $attribute=$value");
}
## sets the field of a complex attribute
sub setAttributeField
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $field = shift;
my $value = shift;
$self->{data}->{TARGETS}->{$target}->{ATTRIBUTES}->{$attribute}->{default}
->{field}->{$field}->{value} = $value;
$self->log($target, "Setting Attribute: $attribute ($field) =$value");
}
## returns complex attribute value
sub getAttributeField
{
my $self = shift;
my $target = shift;
my $attribute = shift;
my $field = shift;
my $target_ptr = $self->getTarget($target);
if (!defined($target_ptr->{ATTRIBUTES}->{$attribute}->
{default}->{field}->{$field}->{value}))
{
printf("ERROR: getAttributeField(%s,%s,%s) | Attribute not defined\n",
$target, $attribute,$field);
$self->myExit(4);
}
return $target_ptr->{ATTRIBUTES}->{$attribute}->
{default}->{field}->{$field}->{value};
}
## returns an attribute from a bus
sub getBusAttribute
{
my $self = shift;
my $target = shift;
my $busnum = shift;
my $attr = shift;
my $target_ptr = $self->getTarget($target);
if (
!defined(
$target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}
->{$attr}->{default}
)
)
{
printf("ERROR: getBusAttribute(%s,%d,%s) | Attribute not defined\n",
$target, $busnum, $attr);
$self->myExit(4);
}
if (ref($target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}->{$attr}
->{default}) eq "HASH") {
return "";
}
return $target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}->{$attr}
->{default};
}
## returns a boolean for if a given bus attribute is defined
sub isBusAttributeDefined
{
my $self = shift;
my $target = shift;
my $busnum = shift;
my $attr = shift;
my $target_ptr = $self->getTarget($target);
return defined($target_ptr->{CONNECTION}->{BUS}->[$busnum]->{bus_attribute}
->{$attr}->{default});
}
## returns a pointer to an array of children target names
sub getTargetChildren
{
my $self = shift;
my $target = shift;
my $target_ptr = $self->getTarget($target);
## this is an array
return $target_ptr->{CHILDREN};
}
## returns an array of all child (including grandchildren) target names
sub getAllTargetChildren
{
my $self = shift;
my $target = shift;
my @children;
my $targets = $self->getTargetChildren($target);
if ($targets ne "")
{
for my $child (@$targets)
{
push @children, $child;
my @more = $self->getAllTargetChildren($child);
push @children, @more;
}
}
return @children;
}
sub getEnumValue
{
my $self = shift;
my $enumType = shift;
my $enumName = shift;
if (!defined($self->{enumeration}->{$enumType}->{$enumName}))
{
printf("ERROR: getEnumValue(%s,%s) | enumType not defined\n",
$enumType, $enumName);
$self->myExit(4);
}
return $self->{enumeration}->{$enumType}->{$enumName};
}
sub getEnumHash
{
my $self = shift;
my $enumType = shift;
my $enumName = shift;
if (!defined($self->{enumeration}->{$enumType}))
{
printf("ERROR: getEnumValue(%s) | enumType not defined\n",
$enumType);
print Dumper($self->{enumeration});
$self->myExit(4);
}
return $self->{enumeration}->{$enumType};
}
sub setHuid
{
my $self = shift;
my $target = shift;
my $sys = shift;
my $node = shift;
my $type = $self->getType($target);
my $type_id = $self->{enumeration}->{TYPE}->{$type};
if ($type_id eq "") { $type_id = 0; }
if ($type_id == 0) { return; }
my $index = 0;
if (defined($self->{huid_idx}->{$type}))
{
$index = $self->{huid_idx}->{$type};
}
else { $self->{huid_idx}->{$type} = 0; }
# Format: SSSS NNNN TTTTTTTT iiiiiiiiiiiiiiii
my $huid = sprintf("%01x%01x%02x%04x", $sys, $node, $type_id, $index);
$huid = "0x" . uc($huid);
$self->setAttribute($target, "HUID", $huid);
$self->{huid_idx}->{$type}++;
$self->log($target, "Setting HUID: $huid");
$self->setMruid($target, $node);
}
sub setMruid
{
my $self = shift;
my $target = shift;
my $node = shift;
my $type = $self->getType($target);
my $mru_prefix_id = $self->{enumeration}->{MRU_PREFIX}->{$type};
if (!defined $mru_prefix_id || $mru_prefix_id eq "")
{
$mru_prefix_id = "0xFFFF";
}
if ($mru_prefix_id eq "0xFFFF") { return; }
my $index = 0;
if (defined($self->{mru_idx}->{$node}->{$type}))
{
$index = $self->{mru_idx}->{$node}->{$type};
}
else { $self->{mru_idx}->{$node}->{$type} = 0; }
my $mruid = sprintf("%s%04x", $mru_prefix_id, $index);
$self->setAttribute($target, "MRU_ID", $mruid);
$self->{mru_idx}->{$node}->{$type}++;
}
sub getMasterProc
{
my $self = shift;
return $self->{master_proc};
}
sub setMasterProc
{
my $self = shift;
my $target = shift;
$self->{master_proc}=$target;
}
sub getSystemName
{
my $self = shift;
return $self->getAttribute("/".$self->{TOP_LEVEL}, "SYSTEM_NAME");
}
sub myExit
{
my $self = shift;
my $exit_code = shift;
if ($exit_code eq "") { $exit_code = 0; }
$self->{errorsExist} = 1;
if ($self->{force} == 0)
{
exit($exit_code);
}
}
sub log
{
my $self = shift;
my $target = shift;
my $msg = shift;
if ($self->{debug})
{
print "DEBUG: ($target) $msg\n";
}
}
sub writeReport
{
my $self = shift;
my $msg = shift;
$self->{report_log}=$self->{report_log}.$msg;
}
sub writeReportFile
{
my $self = shift;
open(R,">$self->{report_filename}") ||
die "Unable to create file: ".$self->{report_filename};
print R $self->{report_log};
close R;
}
1;
=head1 NAME
Targets
=head1 SYNOPSIS
use Targets;
my $targets = Targets->new;
$targets->loadXML("myfile.xml");
foreach my $target ( sort keys %{ $targets->getAllTargets() } ) {
## do stuff with targets
}
$targets->printXML( $file_handle, "top" );
=head1 DESCRIPTION
C<Targets> is a class that consumes XML generated by ServerWiz2. The XML
describes a POWER system topology including nodes, cards, chips, and busses.
=head1 OVERVIEW
A simple example of a ServerWiz2 topology would be:
=over 4
=item Topology Example:
-system
-node
-motherboard
-processor
-pcie card
- daughtercard
- memory buffer
- dimms
=back
Targets->loadXML("myfile.xml") reads this topology and creates 2 data
structures. One data structure simply represents the hierarchical system
topology. The other data structure represents the hierarchical structure
that hostboot expects (affinity path).
Unlike hostboot, everything in ServerWiz2 is represented as a target.
For example, FSI and I2C units are targets under the processor that have a
bus type and therefore allow connections to be made.
=head1 CONSTRUCTOR
=over 4
=item new ()
There are no arguments for the constructor.
=back
=head1 METHODS
C<TARGET> is a pointer to data structure containing all target information.
C<TARGET_STRING> is the hierarchical target string used as key for data
structure. An example for C<TARGET_STRING> would be:
C</sys-0/node-0/motherboard-0/dimm-0>
=over 4
=item loadXml (C<FILENAME>)
Reads ServerWiz2 XML C<FILENAME> and stores into a data structure for
manipulation and printing.
=item removeTarget(C<TARGET_STRING>)
Removes the given target from the data structure (C<TARGET>)
=item getTarget(C<TARGET_STRING>)
Returns pointer to data structure (C<TARGET>)
=item getAllTargets(C<TARGET_STRING>)
Returns array with all existing target data structures
=item getTargetParent(C<TARGET_STRING>)
Returns C<TARGET_STRING> of parent target
=item getNumConnections(C<TARGET_STRING>)
Returns the number of bus connections to this target
=item getFirstConnectionDestination(C<TARGET_STRING>)
Returns the target string of the first target found connected to
C<TARGET_STRING>. This is useful because many busses are guaranteed
to only have one connection because they are point to point.
=item getFirstConnectionBus(C<TARGET_STRING>)
Returns the data structure of the bus of the first target found connected to
C<TARGET_STRING>. The bus data structure is also a target with attributes.
=item getConnectionDestination(C<TARGET_STRING>,C<INDEX>)
Returns the target string of the C<INDEX> target found connected to
C<TARGET_STRING>.
=item getConnectionBus(C<TARGET_STRING>)
Returns the data structure of the C<INDEX> bus target found connected to
C<TARGET_STRING>.
=item findEndpoint(C<TARGET_STRING>,C<BUS_TYPE>,C<ENDPOINT_MRW_TYPE>)
Searches through all connections to C<TARGET_STRING>
for a endpoint C<MRW_TYPE> and C<BUS_TYPE>
=item getBusType(C<TARGET_STRING>)
Returns the BUS_TYPE attribute of (C<TARGET_STRING>). Examples are I2C and DMI.
=item getType(C<TARGET_STRING>)
Returns the TYPE attribute of (C<TARGET_STRING>).
Examples are PROC and MEMBUF.
=item getMrwType(C<TARGET_STRING>)
Returns the MRW_TYPE attribute of (C<TARGET_STRING>).
Examples are CARD and PCI_CONFIG. This
is an extension to the TYPE attribute and are types that hostboot does
not care about.
=item getTargetType(C<TARGET_STRING>)
Returns the target type id of (C<TARGET_STRING>).
This is not the TYPE attribute. This is the
<id> from target_types.xml. Examples are unit-pci-power8 and enc-node-power8.
=item isBadAttribute(C<TARGET_STRING>,C<ATTRIBUTE_NAME>)
Tests where attribute (C<ATTRIBUTE_NAME>) has been set in
target (C<TARGET_STRING>). Returns true if attribute is undefined or empty
and false if attribute is defined and not empty.
=item getAttribute(C<TARGET_STRING>,C<ATTRIBUTE_NAME>)
Returns the value of attribute C<ATTRIBUTE_NAME> in target C<TARGET_STRING>.
=item renameAttribute(C<TARGET_STRING>,C<ATTRIBUTE_OLDNAME>,
C<ATTRIBUTE_OLDNAME>)
Renames attribute C<ATTRIBUTE_OLDNAME> to C<ATTRIBUTE_NEWNAME> in target
C<TARGET_STRING>.
=item setAttribute(C<TARGET_STRING>,C<ATTRIBUTE_NAME>,C<VALUE>)
Sets attribute C<ATTRIBUTE_NAME> of target C<TARGET_STRING> to value C<VALUE>.
=item setAttributeField(C<TARGET_STRING>,C<ATTRIBUTE_NAME>,C<FIELD>,C<VALUE>)
Sets attribute C<ATTRIBUTE_NAME> and field C<FIELD> of target C<TARGET_STRING>
to value C<VALUE>. This is for complex attributes.
=item getBusAttribute(C<TARGET_STRING>,C<INDEX>,C<ATTRIBUTE_NAME>)
Gets the attribute C<ATTRIBUTE_NAME> from bus C<TARGET_STRING> bus number
C<INDEX>.
=item isBusAttributeDefined(C<TARGET_STRING>,C<INDEX>.C<ATTRIBUTE_NAME>)
Looks for a specific attribute and returns if it exists or not
=item getTargetChildren(C<TARGET_STRING>)
Returns an array of target strings representing all the children of target
C<TARGET_STRING>.
=item getAllTargetChildren(C<TARGET_STRING>)
Returns an array of target strings representing all the children of target
C<TARGET_STRING>, including grandchildren and below as well.
=item getEnumValue(C<ENUM_TYPE>,C<ENUM_NAME>)
Returns the enum value of type C<ENUM_TYPE> and name C<ENUM_NAME>. The
enumerations are also defined in ServerWiz2 XML output and are directly
copied from attribute_types.xml.
=item getMasterProc()
Returns the target string of the master processor.
=item myExit(C<EXIT_NUM>)
Calls exit(C<EXIT_NUM>) when force flag is not set.
=item log(C<TARGET_STRING>,C<MESSAGE>)
Prints to stdout log message is debug mode is turned on.
=back
=head1 CREDITS
Norman James <njames@us.ibm.com>
=cut
|