summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authornjames <nkskjames@gmail.com>2016-09-20 15:05:25 -0500
committernjames <nkskjames@gmail.com>2016-09-20 15:05:25 -0500
commit0d0dde4df54d8c8f101d6b23c9cfb3e55312aa3e (patch)
tree614c6e92f66fd23c99821bbe93dcf1401ba3d3ce /scripts
parent44129ae5d3b367a07faee2c0f6a00705a3746dc2 (diff)
downloadserverwiz-0d0dde4df54d8c8f101d6b23c9cfb3e55312aa3e.tar.gz
serverwiz-0d0dde4df54d8c8f101d6b23c9cfb3e55312aa3e.zip
Add support to read old and new serverwiz xml formats.
Signed-off-by: Norman James <nkskjames@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Targets.pm153
1 files changed, 106 insertions, 47 deletions
diff --git a/scripts/Targets.pm b/scripts/Targets.pm
index 2c0876f..35f0842 100644
--- a/scripts/Targets.pm
+++ b/scripts/Targets.pm
@@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2015
+# Contributors Listed Below - COPYRIGHT 2015,2016
# [+] International Business Machines Corp.
#
#
@@ -26,6 +26,7 @@ package Targets;
use strict;
use XML::Simple;
+use XML::Parser;
use Data::Dumper;
sub new
@@ -43,9 +44,10 @@ sub new
force => 0,
debug => 0,
version => "",
+ xml_version => 0,
errorsExist => 0,
NUM_PROCS => 0,
- TOP_LEVEL => "sys",
+ TOP_LEVEL => "",
TOPOLOGY => undef,
report_log => "",
vpd_num => 0,
@@ -87,10 +89,16 @@ sub loadXML
print "Loading MRW XML: $filename\n";
$self->{xml} =
XMLin($filename,forcearray => [ 'child_id', 'hidden_child_id', 'bus',
- 'property', 'field','attribute' ]);
+ 'property', 'field', 'attribute' ]);
+
+ if (defined($self->{xml}->{'enumerationTypes'}))
+ {
+ $self->{xml_version} = 1;
+ }
+
$self->storeEnumerations();
$self->storeGroups();
- $self->buildHierarchy($self->{TOP_LEVEL});
+ $self->buildHierarchy();
$self->buildAffinity();
$self->{report_filename}=$filename.".rpt";
$self->{report_filename}=~s/\.xml//g;
@@ -183,7 +191,6 @@ sub printAttribute
$filter{PCIE_NUM_LANES} = 1;
$filter{PHB_NUM} = 1;
$filter{IOP_NUM} = 1;
- $filter{LOCATION_CODE} = 1;
$filter{MCS_NUM} = 1;
$filter{SCHEMATIC_INTERFACE} = 1;
$filter{ENTITY_ID} = 1;
@@ -232,26 +239,32 @@ sub printAttribute
sub storeEnumerations
{
my $self = shift;
-
- foreach my $enumType (keys(%{ $self->{xml}->{enumerationTypes}->{enumerationType} }))
+ my $baseptr = $self->{xml}->{enumerationType};
+ if ($self->{xml_version} == 1)
+ {
+ $baseptr = $self->{xml}->{enumerationTypes}->{enumerationType};
+ }
+ foreach my $enumType (keys(%{ $baseptr }))
{
foreach my $enum (
- keys(%{$self->{xml}->{enumerationTypes}->{enumerationType}->{$enumType}->{enumerator}}))
+ keys(%{$baseptr->{$enumType}->{enumerator}}))
{
$self->{enumeration}->{$enumType}->{$enum} =
- $self->{xml}->{enumerationTypes}->{enumerationType}->{$enumType}->{enumerator}
- ->{$enum}->{value};
+ $baseptr->{$enumType}->{enumerator}->{$enum}->{value};
}
}
}
sub storeGroups
{
my $self = shift;
- foreach my $grp (keys(%{ $self->{xml}->{attributeGroups}->{attributeGroup} }))
+ foreach my $grp (keys(%{ $self->{xml}->{attributeGroups}
+ ->{attributeGroup} }))
{
- foreach my $attr (@{$self->{xml}->{attributeGroups}->{attributeGroup}->{$grp}->{'attribute'}}) {
- $self->{groups}->{$grp}->{$attr} = 1;
- }
+ foreach my $attr (@{$self->{xml}->{attributeGroups}
+ ->{attributeGroup}->{$grp}->{'attribute'}})
+ {
+ $self->{groups}->{$grp}->{$attr} = 1;
+ }
}
}
@@ -291,22 +304,43 @@ sub buildHierarchy
my $instance_path = $self->{data}->{INSTANCE_PATH};
if (!defined $instance_path)
- {
- $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 = $self->{xml}->{'targetInstances'}->{'targetInstance'}{$target};
+ 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:";
- }
+
+ 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;
@@ -344,9 +378,15 @@ sub buildHierarchy
}
}
## global attributes overwrite local
- foreach my $prop (keys %{$self->{xml}->{globalSettings}->{globalSetting}->{$key}->{property}})
+ my $settingptr = $self->{xml}->{globalSetting};
+ if ($self->{xml_version} == 1)
{
- my $val=$self->{xml}->{globalSettings}->{globalSetting}->{$key}->{property}->
+ $settingptr = $self->{xml}->{globalSettings}->{globalSetting};
+ }
+
+ foreach my $prop (keys %{$settingptr->{$key}->{property}})
+ {
+ my $val=$settingptr->{$key}->{property}->
{$prop}->{value};
$self->setAttribute($key, $prop, $val);
}
@@ -417,6 +457,7 @@ sub buildAffinity
{
my $self = shift;
my $node = -1;
+ my $tpm = -1;
my $proc = -1;
my $node_phys = "";
my $node_aff = "";
@@ -435,8 +476,10 @@ sub buildAffinity
$node = -1;
$self->{targeting}{SYS}[0]{KEY} = $target;
- $self->setAttribute($target, "AFFINITY_PATH", "affinity:sys");
- $self->setAttribute($target, "PHYS_PATH", "physical:sys");
+ $self->setAttribute($target, "AFFINITY_PATH",
+ "affinity:".$self->{TOP_LEVEL});
+ $self->setAttribute($target, "PHYS_PATH",
+ "physical:".$self->{TOP_LEVEL});
$self->setAttribute($target, "ENTITY_INSTANCE","0");
}
elsif ($type eq "NODE")
@@ -446,16 +489,29 @@ sub buildAffinity
$self->{dimm_tpos} = 0;
$self->{membuf_inst_num}=0;
$node++;
- $node_phys = "physical:sys/node-$node";
- $node_aff = "affinity:sys/node-$node";
+ $node_phys = "physical:".$self->{TOP_LEVEL}."/node-$node";
+ $node_aff = "affinity:".$self->{TOP_LEVEL}."/node-$node";
$self->{targeting}{SYS}[0]{NODES}[$node]{KEY} = $target;
$self->setAttribute($target, "AFFINITY_PATH",
- "affinity:sys/node-$node");
+ "affinity:".$self->{TOP_LEVEL}."/node-$node");
$self->setAttribute($target, "PHYS_PATH",
- "physical:sys/node-$node");
+ "physical:".$self->{TOP_LEVEL}."/node-$node");
$self->setHuid($target, 0, $node);
$self->setAttribute($target, "ENTITY_INSTANCE",$node);
}
+ elsif ($type eq "TPM")
+ {
+ $tpm++;
+ $self->{targeting}{SYS}[0]{NODES}[$node]{TPMS}[$tpm]{KEY} = $target;
+ $self->setAttribute($target, "AFFINITY_PATH",
+ "affinity:".$self->{TOP_LEVEL}.
+ "/node-$node/tpm-$tpm");
+ $self->setAttribute($target, "PHYS_PATH",
+ "physical:".$self->{TOP_LEVEL}.
+ "/node-$node/tpm-$tpm");
+ $self->setHuid($target, 0, $tpm);
+ $self->setAttribute($target, "ENTITY_INSTANCE",$tpm);
+ }
elsif ($type eq "PROC")
{
$proc++;
@@ -480,8 +536,10 @@ sub buildAffinity
$self->setHuid($target, 0, $node);
my $socket = $self->getTargetParent(
$self->getTargetParent($target));
- my $parent_affinity = "affinity:sys/node-$node/proc-$proc";
- my $parent_physical = "physical:sys/node-$node/proc-$proc";
+ my $parent_affinity = "affinity:".$self->{TOP_LEVEL}
+ ."/node-$node/proc-$proc";
+ my $parent_physical = "physical:".$self->{TOP_LEVEL}
+ ."/node-$node/proc-$proc";
$self->setAttribute($target, "AFFINITY_PATH", $parent_affinity);
$self->setAttribute($target, "PHYS_PATH", $parent_physical);
$self->setAttribute($target, "POSITION", $proc);
@@ -630,8 +688,6 @@ sub processMcs
$self->setFsiAttributes($membuf,"FSICM",0,$proc_path,$fsi_port,0);
$self->setAttribute($unit, "DMI_REFCLOCK_SWIZZLE",$fsi_port);
my $dmi_swizzle =
- $dmi_bus->{bus_attribute}->{DMI_REFCLOCK_SWIZZLE}->{default};
- $dmi_swizzle =
$self->getBusAttribute($unit,0,"DMI_REFCLOCK_SWIZZLE");
if ($dmi_swizzle ne "")
{
@@ -985,7 +1041,8 @@ sub isBadAttribute
{
return 1;
}
- if (defined $badvalue && $target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq $badvalue)
+ if (defined $badvalue &&
+ $target_ptr->{ATTRIBUTES}->{$attribute}->{default} eq $badvalue)
{
return 1;
}
@@ -1056,18 +1113,17 @@ sub getAttributeGroup
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);
+ $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};
- }
+ {
+ $attr{$attribute} = $target_ptr->{ATTRIBUTES}->{$attribute};
+ }
}
return \%attr;
}
@@ -1253,7 +1309,10 @@ sub setMruid
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 (!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}))
@@ -1389,7 +1448,7 @@ There are no arguments for the constructor.
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/node-0/motherboard-0/dimm-0>
+C</sys-0/node-0/motherboard-0/dimm-0>
=over 4
@@ -1522,4 +1581,4 @@ Prints to stdout log message is debug mode is turned on.
Norman James <njames@us.ibm.com>
-=cut \ No newline at end of file
+=cut
OpenPOWER on IntegriCloud