summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/common/xmltohb/xmltohb.pl
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2013-08-28 15:20:48 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-09-18 10:43:03 -0500
commitaf0bcac5124a4c54ec38e6d00d14f2cec19d5c77 (patch)
tree5deb2f080d7b62c0ceb11d869c9e45807e23da48 /src/usr/targeting/common/xmltohb/xmltohb.pl
parent2fb853f4dbc589e955f4d364a5aa33aa37a88da3 (diff)
downloadtalos-hostboot-af0bcac5124a4c54ec38e6d00d14f2cec19d5c77.tar.gz
talos-hostboot-af0bcac5124a4c54ec38e6d00d14f2cec19d5c77.zip
Change attribute lookup to be binary search.
This reduces the number of simics cycles to IPL by ~11% on a single processor stand-alone model. Change-Id: I11411f6c9a16856092c551882eb51e63e700fe3d Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/5980 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/common/xmltohb/xmltohb.pl')
-rwxr-xr-xsrc/usr/targeting/common/xmltohb/xmltohb.pl43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl
index a395ca6c3..3397c2f20 100755
--- a/src/usr/targeting/common/xmltohb/xmltohb.pl
+++ b/src/usr/targeting/common/xmltohb/xmltohb.pl
@@ -443,7 +443,7 @@ sub validateTargetInstances{
sub handleTgtPtrAttributesFsp
{
my($attributes) = @_;
-
+
# replace PEER_TARGET attribute<PHYS_PATH> value with PEER's HUID
foreach my $targetInstance (@{${$attributes}->{targetInstance}})
{
@@ -451,17 +451,17 @@ sub handleTgtPtrAttributesFsp
{
if (exists $attr->{default})
{
- if( ($attr->{default} ne "NULL")
+ if( ($attr->{default} ne "NULL")
&& ($attr->{id} eq "PEER_TARGET"))
{
- my $peerHUID = getPeerHuid(${$attributes},
+ my $peerHUID = getPeerHuid(${$attributes},
$attr->{default});
if($peerHUID == INVALID_HUID)
{
fatal("HUID for Peer Target not found");
}
$attr->{default} = (hex($peerHUID) << 32);
- $attr->{default} = sprintf("0x%X",$attr->{default});
+ $attr->{default} = sprintf("0x%X",$attr->{default});
}
}
}
@@ -524,7 +524,7 @@ sub handleTgtPtrAttributesHb{
}
}
-sub getPeerHuid
+sub getPeerHuid
{
my($attributes, $peerPhysPath) = @_;
@@ -562,7 +562,7 @@ sub getPeerHuid
}
}
- return $peerHUID;
+ return $peerHUID;
}
sub SOURCE_FILE_GENERATION_FUNCTIONS { }
@@ -2715,6 +2715,15 @@ sub writeTargetErrlHFile {
sub UTILITY_FUNCTIONS { }
################################################################################
+# Get the hash hex string for an attribute name (ID).
+################################################################################
+sub getAttributeIdHashStr
+{
+ my ($attrId) = @_;
+ return substr(md5_hex($attrId),0,7);
+}
+
+################################################################################
# Get generated enumeration describing attribute IDs
################################################################################
@@ -2733,8 +2742,7 @@ sub getAttributeIdEnumeration {
foreach my $attribute (@{$attributes->{attribute}})
{
- my $attributeHexVal = md5_hex($attribute->{id});
- my $attributeHexVal28bit =substr($attributeHexVal,0,7);
+ my $attributeHexVal28bit = getAttributeIdHashStr($attribute->{id});
if(exists($attrValHash{$attributeHexVal28bit}))
{
@@ -3423,14 +3431,14 @@ sub isFspTargetInstance {
if(%g_fspTargetTypesCache)
{
- $fspTargetInstance = %g_fspTargetTypesCache->{$targetInstance->{type}};
+ $fspTargetInstance = $g_fspTargetTypesCache{$targetInstance->{type}};
}
else
{
%g_fspTargetTypesCache =
map { $_->{id} => exists $_->{fspOnly} ? 1:0 }
@{$attributes->{targetType}};
- $fspTargetInstance = %g_fspTargetTypesCache->{$targetInstance->{type}};
+ $fspTargetInstance = $g_fspTargetTypesCache{$targetInstance->{type}};
}
return $fspTargetInstance;
@@ -3984,8 +3992,14 @@ sub generateTargetingImage {
getTargetAttributes($targetType, $attributes,\%attrhash);
# Serialize per target type attribute list
+ # Sort the list by attribute ID (hash value) so that we can do a
+ # binary search at runtime.
my $perTargetTypeAttrBinData;
- for my $attributeId (sort(keys %attrhash))
+ for my $attributeId
+ (sort
+ { getAttributeIdHashStr($a) cmp getAttributeIdHashStr($b) }
+ (keys %attrhash)
+ )
{
$perTargetTypeAttrBinData .= packEnumeration(
$attributeIdEnumeration,
@@ -4141,7 +4155,12 @@ sub generateTargetingImage {
my %attributeDefCache =
map { $_->{id} => $_} @{$attributes->{attribute}};
- for my $attributeId (sort(keys %attrhash))
+ # Must have the same order as the attribute list from above.
+ for my $attributeId
+ (sort
+ { getAttributeIdHashStr($a) cmp getAttributeIdHashStr($b) }
+ (keys %attrhash)
+ )
{
my $attributeDef = $attributeDefCache{$attributeId};
if (not defined $attributeDef)
OpenPOWER on IntegriCloud