summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Veloz <rveloz@us.ibm.com>2018-08-31 04:35:33 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2018-09-28 17:28:53 -0500
commita92f91459eb2a1c197e4f15d7341f1f501b89079 (patch)
tree0f16152b0185b5accca8ac03bf549fa160b800b7
parent5baacd28d51e361566f587c6b613ba679352d4ec (diff)
downloadtalos-hostboot-a92f91459eb2a1c197e4f15d7341f1f501b89079.tar.gz
talos-hostboot-a92f91459eb2a1c197e4f15d7341f1f501b89079.zip
Added the I2C MUX attribute and target definitions
- Defined the I2C_MUX_INFO attribute - Defined the i2c_mux target with I2C_MUX_INFO as an attribute - Defined the i2c_mux target to have parent 'chip' - Added attribute fields i2cMuxSelector and i2cMuxPath to attributes EEPROM_NV_INFO, EEPROM_SBE_BACKUP_INFO, EEPROM_SBE_PRIMARY_INFO, EEPROM_VPD_BACKUP_INFO, EEPROM_VPD_PRIMARY_INFO, FAPI_I2C_CONTROL_INFO, TEMP_SENSOR_I2C_CONFIG and TPM_INFO. All these had I2C info in them (i2cMasterPath, port, devAddr, engine, etc). RTC:196807 CMVC-Prereq:1068716 Change-Id: Iadf4909411329c8b7b961efc2cb0789f5b96a49f Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/65540 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
-rw-r--r--src/usr/targeting/common/entitypath.C2
-rw-r--r--[-rwxr-xr-x]src/usr/targeting/common/xmltohb/attribute_types.xml215
-rw-r--r--src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml48
-rw-r--r--src/usr/targeting/common/xmltohb/target_types.xml17
-rwxr-xr-xsrc/usr/targeting/common/xmltohb/xmltohb.pl240
-rw-r--r--src/usr/targeting/test/testtargeting.H101
6 files changed, 574 insertions, 49 deletions
diff --git a/src/usr/targeting/common/entitypath.C b/src/usr/targeting/common/entitypath.C
index 9697dde98..ed81d1b4a 100644
--- a/src/usr/targeting/common/entitypath.C
+++ b/src/usr/targeting/common/entitypath.C
@@ -481,6 +481,8 @@ const char* EntityPath::pathElementTypeAsString(
return "OCBM_CHIP";
case TYPE_MEM_PORT:
return "MEM_PORT";
+ case TYPE_I2C_MUX:
+ return "I2C_MUX";
// case TYPE_FSI_LINK:
// return "FSI-link";
// case TYPE_CFAM:
diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml
index 6b0c2acdd..5250b2b05 100755..100644
--- a/src/usr/targeting/common/xmltohb/attribute_types.xml
+++ b/src/usr/targeting/common/xmltohb/attribute_types.xml
@@ -959,6 +959,24 @@
<type>uint64_t</type>
<default>0x05</default>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<persistency>non-volatile</persistency>
<readable/>
@@ -1033,6 +1051,24 @@
<name>writeCycleTime</name>
<type>uint64_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address the EERPROM slaves</description>
<id>EEPROM_SBE_BACKUP_INFO</id>
@@ -1109,6 +1145,24 @@
<name>writeCycleTime</name>
<type>uint64_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address the EERPROM slaves</description>
<id>EEPROM_SBE_PRIMARY_INFO</id>
@@ -1185,6 +1239,24 @@
<name>writeCycleTime</name>
<type>uint64_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address the EERPROM slaves</description>
<id>EEPROM_VPD_BACKUP_INFO</id>
@@ -1268,6 +1340,24 @@
<name>writeCycleTime</name>
<type>uint64_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address the EEPROM slaves</description>
<id>EEPROM_VPD_PRIMARY_INFO</id>
@@ -1295,8 +1385,8 @@
</attribute>
<attribute>
- <!-- @fixme -->
<id>EFF_DRAM_COLS</id>
+ <!-- @fixme -->
<description>Number of DRAM columns. Initialized and used by HWPs.</description>
<simpleType>
<uint8_t/>
@@ -1307,8 +1397,8 @@
</attribute>
<attribute>
- <!-- @fixme -->
<id>EFF_DRAM_ROWS</id>
+ <!-- @fixme -->
<description>Number of DRAM rows. Initialized and used by HWPs.</description>
<simpleType>
<uint8_t/>
@@ -1455,6 +1545,24 @@
<name>devAddr</name>
<type>uint8_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<persistency>non-volatile</persistency>
<readable/>
@@ -1621,6 +1729,7 @@
<writeable/>
</attribute>
+ <!-- Required by FSP -->
<attribute>
<id>FREQ_PROC_REFCLOCK</id>
<description>
@@ -2016,8 +2125,8 @@
<value>0xA</value>
</enumerator>
<enumerator>
- <!-- deprecated -->
<name>NVLINK</name>
+ <!-- deprecated -->
<value>0xB</value>
</enumerator>
<enumerator>
@@ -2056,13 +2165,13 @@
<value>0x1</value>
</enumerator>
<enumerator>
- <!-- deprecated -->
<name>955X</name>
+ <!-- deprecated -->
<value>0x1</value>
</enumerator>
<enumerator>
- <!-- deprecated -->
<name>SEEPROM</name>
+ <!-- deprecated -->
<value>0x2</value>
</enumerator>
<enumerator>
@@ -2082,8 +2191,8 @@
<value>0x5</value>
</enumerator>
<enumerator>
- <!-- deprecated -->
<name>NVLINK</name>
+ <!-- deprecated -->
<value>0x6</value>
</enumerator>
<enumerator>
@@ -2398,6 +2507,51 @@
<attribute>
<complexType>
+ <description>Structure to define the addressing for
+ an I2C mux target. </description>
+ <!-- Master Target Definition -->
+ <field>
+ <!--- NOTE: default physical sys-0 is not a valid entity path,
+ this must be populated with a valid entity path. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the chip that contains the I2C
+ master.</description>
+ <name>i2cMasterPath</name>
+ <type>EntityPath</type>
+ </field>
+ <!-- Port Definition -->
+ <field>
+ <default>0x00</default>
+ <description>Port from the I2C Master device. This is a
+ 6-bit value. </description>
+ <name>port</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- Device Address Definition -->
+ <field>
+ <default>0x00</default>
+ <description>Device address on the I2C bus. This is a 7-bit
+ value, but then shifted 1 bit left. </description>
+ <name>devAddr</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- Engine Definition -->
+ <field>
+ <default>0x00</default>
+ <description>I2C master engine. This is a 2-bit value. </description>
+ <name>engine</name>
+ <type>uint8_t</type>
+ </field>
+ </complexType>
+ <description>Information used to control a specific i2c mux device,
+ to select a particular target bus. </description>
+ <id>I2C_MUX_INFO</id>
+ <persistency>non-volatile</persistency>
+ <readable/>
+ </attribute>
+
+ <attribute>
+ <complexType>
<description>Structure which defines which I2C access method to use at
a point in time. Only applicable if target supports one or more I2C
types. Only one bit (of the first two) can ever be set at any one time.
@@ -2774,6 +2928,7 @@
</simpleType>
</attribute>
+ <!-- End Required by FSP -->
<attribute>
<id>MAX_DMI_PER_PROC</id>
<description>
@@ -3172,7 +3327,6 @@
</description>
<simpleType>
<uint64_t>
- <!-- 4PT -->
<default>0x4000000000000</default>
</uint64_t>
</simpleType>
@@ -3689,6 +3843,9 @@
<enumerator>
<name>AST2500</name>
</enumerator>
+ <enumerator>
+ <name>PCA9847</name>
+ </enumerator>
<id>MODEL</id>
</enumerationType>
@@ -6068,8 +6225,8 @@
<simpleType>
<uint16_t/>
</simpleType>
- <!-- @fixme -->
<persistency>non-volatile</persistency>
+ <!-- @fixme -->
<readable/>
<writeable/>
<ignoreEkb/>
@@ -6979,6 +7136,24 @@
<name>devAddr</name>
<type>uint8_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address an I2C slave device</description>
<id>TEMP_SENSOR_I2C_CONFIG</id>
@@ -7255,6 +7430,24 @@
<name>byteAddrOffset</name>
<type>uint8_t</type>
</field>
+ <!-- i2c Mux Bus Selector Definition -->
+ <field>
+ <default>0xFF</default>
+ <description>Determines which of the N selectable buses the mux
+ will connect to. OxFF indicates no mux present
+ or N/A.</description>
+ <name>i2cMuxBusSelector</name>
+ <type>uint8_t</type>
+ </field>
+ <!-- i2c Mux Path Definition -->
+ <field>
+ <!-- NOTE: physical:sys-0 implies that there is no mux in
+ the bus path for this part. -->
+ <default>physical:sys-0</default>
+ <description>Entity path to the I2C mux for this device.</description>
+ <name>i2cMuxPath</name>
+ <type>EntityPath</type>
+ </field>
</complexType>
<description>Information needed to address the TPM slaves</description>
<id>TPM_INFO</id>
@@ -7624,9 +7817,13 @@
<value>76</value>
</enumerator>
<enumerator>
- <name>LAST_IN_RANGE</name>
+ <name>I2C_MUX</name>
<value>77</value>
</enumerator>
+ <enumerator>
+ <name>LAST_IN_RANGE</name>
+ <value>78</value>
+ </enumerator>
<id>TYPE</id>
</enumerationType>
diff --git a/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml b/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml
index c7d87beaa..2a9c82f72 100644
--- a/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml
+++ b/src/usr/targeting/common/xmltohb/simics_CUMULUS.system.xml
@@ -13635,10 +13635,48 @@
</attribute>
</targetInstance>
-
-<!-- Cumulus proc 0 end -->
-
-
-
+<!-- For testing purposes only, will replace with real values later -->
+<targetInstance>
+ <id>sys0node0i2cmux0</id>
+ <type>i2c_mux_pca9847</type>
+ <attribute>
+ <id>HUID</id>
+ <default>0x004D0000</default>
+ </attribute>
+ <attribute>
+ <id>PHYS_PATH</id>
+ <default>physical:sys-0/node-0/i2c_mux-0</default>
+ </attribute>
+ <attribute>
+ <id>AFFINITY_PATH</id>
+ <default>affinity:sys-0/node-0/proc-0/i2c_mux-0</default>
+ </attribute>
+ <attribute>
+ <id>PRIMARY_CAPABILITIES</id>
+ <default>
+ <field><id>reserved</id><value>0</value></field>
+ <field><id>supportsFsiScom</id><value>0</value></field>
+ <field><id>supportsInbandScom</id><value>0</value></field>
+ <field><id>supportsXscom</id><value>0</value></field>
+ </default>
+ </attribute>
+ <attribute>
+ <id>ORDINAL_ID</id>
+ <default>0</default>
+ </attribute>
+ <attribute>
+ <id>FAPI_NAME</id>
+ <default>NA</default>
+ </attribute>
+ <attribute>
+ <id>I2C_MUX_INFO</id>
+ <default>
+ <field><id>i2cMasterPath</id><value>physical:sys-0/node-0/proc-0</value></field>
+ <field><id>port</id><value>4</value></field>
+ <field><id>devAddr</id><value>0xA0</value></field>
+ <field><id>engine</id><value>2</value></field>
+ </default>
+ </attribute>
+</targetInstance>
</attributes>
diff --git a/src/usr/targeting/common/xmltohb/target_types.xml b/src/usr/targeting/common/xmltohb/target_types.xml
index 16a7fc60d..f0640050f 100644
--- a/src/usr/targeting/common/xmltohb/target_types.xml
+++ b/src/usr/targeting/common/xmltohb/target_types.xml
@@ -878,6 +878,22 @@
</targetType>
<targetType>
+ <id>i2c_mux_pca9847</id>
+ <parent>chip</parent>
+ <attribute>
+ <id>I2C_MUX_INFO</id>
+ </attribute>
+ <attribute>
+ <id>MODEL</id>
+ <default>PCA9847</default>
+ </attribute>
+ <attribute>
+ <id>TYPE</id>
+ <default>I2C_MUX</default>
+ </attribute>
+ </targetType>
+
+ <targetType>
<id>lcard-dimm</id>
<parent>card</parent>
<attribute>
@@ -2217,7 +2233,6 @@
</attribute>
<attribute>
<id>HWAS_STATE_CHANGED_SUBSCRIPTION_MASK</id>
- <!-- GARD -->
<default>0x00000001</default>
</attribute>
<attribute>
diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl
index eef142c9d..60fe126d3 100755
--- a/src/usr/targeting/common/xmltohb/xmltohb.pl
+++ b/src/usr/targeting/common/xmltohb/xmltohb.pl
@@ -4986,36 +4986,176 @@ sub getAttributeDefault {
}
################################################################################
+# Merge the fields of two complex attributes
+################################################################################
+
+# This function will merge the fields of two complex attributes.
+#
+# The field's value from $newAttrFields will be merged into $currentAttrFields.
+# $currentAttrFields must have, at a minimum, all the fields that are in
+# $newAttrFields. If not then this function will halt execution with an error
+# message. Fields that are in $currentAttrFields that have no associated value
+# within $newAttrFields will be left as is.
+#
+# param [in] - $newAttrFields - These are the new fields with new values that
+# are to be merged.
+#
+# param [in] - $currentAttrFields - These are the current fields which, at a
+# minimum, include ALL the fields from $newAttrFields.
+# There may be more.
+#
+# return - The two fields successfully merged
+#
+
+sub mergeComplexAttributeFields {
+ my($newAttrFields, $currentAttrFields) = @_;
+
+ # Make a deep copy of the current fields, don't want to modify
+ # $currentAttrFields - leave as is. This copy will contain the merger of
+ # the two fields.
+ my $mergedFields = dclone $currentAttrFields;
+
+ # Iterate over the fields of $newField and look for their corresponding id
+ # in $currentAttrFields. All the fields in $newField should exist in
+ # $currentAttrFields, if not, then there is a problem
+ foreach my $newField (@{$newAttrFields->{default}->{field}})
+ {
+ my $foundField = 0;
+
+ # Iterate over $mergedFields (really $currentAttrFields) looking
+ # for the $newField of $newAttrFields
+ foreach my $currentField (@{$mergedFields->{default}->{field}})
+ {
+ # Found the field in question
+ if ($currentField->{id} eq $newField->{id})
+ {
+ # Merge in the new value from $newField
+ $currentField->{value} = $newField->{value};
+ $foundField = 1;
+ last;
+ }
+ } # end foreach my $currentField ...
+
+ # A field was not found ... halt execution
+ if ($foundField == 0)
+ {
+ croak("Field $newField is not supported.")
+ }
+ } # end foreach my $newField ...
+
+ return $mergedFields;
+}
+
+################################################################################
# Get target attributes
################################################################################
+# This function will recursively work from the most derived target to the base
+# target. This function does not work on target instances, only the target
+# types themselves. $type is the current target being worked on.
+#
+# The default values for the attributes associated with the current target
+# are gathered and consolidated in the attribute hash ($attrhasha). If there is
+# no default value assocaited with that attribute then the attribute in the hash
+# does not get updated - don't want to wipe out the current data with no data.
+#
+# BUT if the current target is the base target type (or the most derived target
+# type) and there is no default value for the attribute, the attribute is still
+# added to the attribute hash with defaults taken from the attribute definition
+# itself as found in the attrubutes_types.xml.
+#
+# If the attribute is a simple type and it has a default value associated with
+# it, then the attribute hash is simply updated with the new default value.
+#
+# If the attribute is a complex type and it has default values, the fields of
+# the attribute will be merged with the same attribute in the hash, with the new
+# attribute's fields taking precedence and any undefined fields keeping thier
+# current value. Again do not want to wipe out the current fields with no data.
+#
+# param [in] - $type - The target type (ie 'base', 'unit', 'unit-phb-power9',
+# etc) currently being processed
+# param [in] - $attributes - This has all data associated with attributes,
+# target types, target instances and other data aggregates.
+# param [in/out] - $attrhasha - An aggregate list of the attributes as each
+# attribute is gathered from the target type and maintained
+# in this list.
+#
+
sub getTargetAttributes {
my($type,$attributes,$attrhasha) = @_;
foreach my $targetType (@{$attributes->{targetType}})
{
- if($targetType->{id} eq $type)
+ if ($targetType->{id} eq $type)
{
- if(exists $targetType->{parent})
+ if (exists $targetType->{parent})
{
getTargetAttributes($targetType->{parent},
- $attributes,$attrhasha);
+ $attributes,$attrhasha);
}
+ # Iterate thru all of this target's attribute and
+ # copy them over to aggregate attributes if necessary
foreach my $attr (@{$targetType->{attribute}})
{
- $attrhasha->{ $attr->{id} } = $attr;
+ # Flag to indicate that a complex type has been found
+ my $isComplex = 0;
- if(!exists $attrhasha->{ $attr->{id}}->{default})
+ # Determine if attribute ($attr) is a complex type.
+ # Complex types are handled differently than simple types.
+ # This is SO inefficient, I know no other way to determine this
+ foreach my $attribute (@{$attributes->{attribute}})
{
- my $default = getAttributeDefault($attr->{id},$attributes);
- $attrhasha->{ $attr->{id}}->{default} = $default;
+ if ( ($attribute->{id} eq $attr->{id}) &&
+ (exists $attribute->{complexType}) )
+ {
+ $isComplex = 1;
+ last;
+ }
}
- }
- last;
- }
- }
+ # If the aggregate of attributes ($attrhasha) does NOT currently
+ # contain the attribute ($attr) then set the base's attribute
+ # to the aggregate list ($attrhasha), regardless if attribute
+ # ($attr) is complex or not. This will give a base line to
+ # work with.
+ if (!exists $attrhasha->{ $attr->{id}})
+ {
+ my $default = getAttributeDefault($attr->{id},$attributes);
+ $attrhasha->{ $attr->{id}}->{default} = $default;
+
+ # Add the 'id' value to the attribute
+ $attrhasha->{ $attr->{id}}->{id} = $attr->{id};
+ }
+
+ # If the attribute ($attr) has no default, then there is
+ # nothing to do. Move onto the next attribute.
+ if (!exists $attr->{default})
+ {
+ next;
+ }
+
+ # The simple type attribute ($attr) has a default value,
+ # replace current attribute in aggregate list ($attrhasha)
+ # with this one ($attr)
+ if ($isComplex == 0)
+ {
+ $attrhasha->{ $attr->{id} } = $attr;
+ }
+ else
+ # This is a complex attribute. Need to merge fields of
+ # current attribute, within the aggregate list ($attrhasha),
+ # with this new attribute's fields ($attr).
+ {
+ my $mergedFields = mergeComplexAttributeFields($attr,
+ $attrhasha->{ $attr->{id}});
+ $attrhasha->{ $attr->{id}}->{default} =
+ $mergedFields->{default};
+ } # end if ($isComplex == 0) ... else ...
+ } # end foreach my $attr (@{$targetType->{attribute}})
+ last;
+ } # end if($targetType->{id} eq $type)
+ } # end foreach my $targetType (@{$attributes->{targetType}})
}
################################################################################
@@ -6221,10 +6361,54 @@ sub generateTargetingImage {
# attribute has already been defined
foreach my $targetInstanceAttribute (@{$targetInstance->{attribute}})
{
- # if the default tag is missing from an attribute then verify that
+ # If the attribute($targetInstanceAttribute->{id}) is defined for
+ # the hash ($attrhash) AND the attribute($targetInstanceAttribute)
+ # has default data then update the hash. There is no point in
+ # updating the hash if the attribute has nothing to update with and
+ # could possibly wipe out a valid default value currently in
+ # the hash.
+ if ( (exists $attrhash{$targetInstanceAttribute->{id}}) &&
+ (exists $targetInstanceAttribute->{default}) )
+ {
+ # Determine if the attribute is a complex attribute by probing
+ # the default. If the default is a HASH then this indicates
+ # a complex type.
+ if (ref ($targetInstanceAttribute->{default}) eq "HASH")
+ {
+ # Grab a copy of the attribute data from the hash
+ my $attrData = $attrhash{ $targetInstanceAttribute->{id} };
+
+ # Merge the two data types into one consolidated data with
+ # the attribute's field defaults replacing the hash's
+ # attribute field data. Leaving any undefined attribute's
+ # field as is (keeping the hash's field data in this case).
+ my $defaultFields = mergeComplexAttributeFields(
+ $targetInstanceAttribute, $attrData);
+
+ # Update the hash with the merged data
+ $attrhash{$targetInstanceAttribute->{id}} = $defaultFields;
+ }
+ else
+ # This is a simple type, just set the data
+ {
+ $attrhash{ $targetInstanceAttribute->{id} } =
+ $targetInstanceAttribute;
+ }
+ }
+ # If the attribute is not defined in the hash, then
+ # throw out an error
+ elsif ( !exists $attrhash{ $targetInstanceAttribute->{id} } )
+ {
+ croak("Target instance \"$targetInstance->{id}\" of type \" "
+ . "$targetInstance->{type} \" cannot override attribute "
+ . "\"$targetInstanceAttribute->{id}\" unless the attribute "
+ . "has already been defined in the target type "
+ . "inheritance chain.");
+ }
+ # If the default tag is missing from an attribute then verify that
# it is not required to be assigned a default value by the system
# owner.
- if(!exists $targetInstanceAttribute->{default})
+ else
{
foreach my $attribute_type (@{$allAttributes->{attribute}})
{
@@ -6233,29 +6417,17 @@ sub generateTargetingImage {
if (exists $attribute_type->{mrwRequired})
{
croak("Error in Target instance "
- . "\"$targetInstance->{id}\": "
- . "Attribute \"$attribute_type->{id}\" with tag "
- . "\"<mrwRequired/>\" is required to have an "
- . "instance level override from either the MRW "
- . "or MRW processing tools.");
+ . "\"$targetInstance->{id}\": "
+ . "Attribute \"$attribute_type->{id}\" with tag "
+ . "\"<mrwRequired/>\" is required to have an "
+ . "instance level override from either the MRW "
+ . "or MRW processing tools.");
}
last;
- }
- }
- }
-
- if(exists $attrhash{$targetInstanceAttribute->{id}})
- {
- $attrhash{ $targetInstanceAttribute->{id} } = $targetInstanceAttribute;
- }
- else
- {
- croak("Target instance \"$targetInstance->{id}\" of type \" $targetInstance->{type} \" cannot "
- . "override attribute \"$targetInstanceAttribute->{id}\" unless "
- . "the attribute has already been defined in the target "
- . "type inheritance chain.");
- }
- }
+ }# end if ($attribute_type->{id} ...
+ } # end foreach my $attribute_type ...
+ } # end else
+ } # end foreach my $targetInstanceAttribute ...
my $huidValue = $attrhash{HUID}->{default};
diff --git a/src/usr/targeting/test/testtargeting.H b/src/usr/targeting/test/testtargeting.H
index b0c70c188..c87d599e9 100644
--- a/src/usr/targeting/test/testtargeting.H
+++ b/src/usr/targeting/test/testtargeting.H
@@ -395,6 +395,107 @@ class TargetingTestSuite : public CxxTest::TestSuite
TS_TRACE(EXIT_MRK "testNvTarget");
}
+
+
+ void testI2cMux()
+ {
+ TS_TRACE(ENTER_MRK "testI2cMux" );
+
+ TARGETING::TargetRangeFilter l_targetList(
+ TARGETING::targetService().begin(),
+ TARGETING::targetService().end(),
+ nullptr);
+
+ if (l_targetList)
+ {
+ for (;l_targetList;++l_targetList)
+ {
+ auto targetClass =
+ l_targetList->getAttr<TARGETING::ATTR_CLASS>();
+ auto targetType = l_targetList->getAttr<TARGETING::ATTR_TYPE>();
+ auto targetModel =
+ l_targetList->getAttr<TARGETING::ATTR_MODEL>();
+ if ( (TARGETING::CLASS_CHIP == targetClass) &&
+ (TARGETING::TYPE_I2C_MUX == targetType) &&
+ (TARGETING::MODEL_PCA9847 == targetModel) )
+ {
+ // Mask off upper 8 bits in case of multiple nodes
+ uint32_t l_huid = get_huid(*l_targetList) & 0x00FFFFFF;
+ // Extract the type, drop instance info
+ l_huid = l_huid >> 16;
+ if (TARGETING::TYPE_I2C_MUX != l_huid)
+ {
+ TS_FAIL("testI2cMux::huid returned(0x%X), "
+ "expected(0x%X)",
+ l_huid,
+ TARGETING::TYPE_I2C_MUX);
+ }
+
+ TARGETING::I2cMuxInfo l_i2cMuxInfo =
+ l_targetList->getAttr<TARGETING::ATTR_I2C_MUX_INFO>();
+
+ if (TARGETING::EntityPath::PATH_PHYSICAL !=
+ l_i2cMuxInfo.i2cMasterPath.type())
+ {
+ TS_FAIL("testI2cMux::i2cMuxPath type "
+ "returned(%d), expected(PHYSICAL)",
+ l_i2cMuxInfo.i2cMasterPath.type());
+ }
+
+ char * l_pathAsString =
+ l_i2cMuxInfo.i2cMasterPath.toString();
+ if (0 != strcmp(l_pathAsString,
+ "Physical:/Sys0/Node0/Proc0"))
+ {
+ TS_FAIL("testI2cMux::i2cMuxPath path "
+ "returned(%s), "
+ "expected(Physical:/Sys0/Node0/Proc0)",
+ l_pathAsString);
+ } // end if (TARGETING
+
+ free (l_pathAsString);
+ l_pathAsString = nullptr;
+ } // end if ( (TARGETING::CLASS_CHIP == targetClass) ...
+ else if ( (TARGETING::CLASS_ENC == targetClass) &&
+ (TARGETING::TYPE_NODE == targetType) &&
+ (TARGETING::MODEL_POWER9 == targetModel) )
+
+ {
+ TARGETING::EepromVpdPrimaryInfo l_eepromInfo =
+ l_targetList->
+ getAttr<TARGETING::ATTR_EEPROM_VPD_PRIMARY_INFO>();
+
+ if (TARGETING::EntityPath::PATH_PHYSICAL !=
+ l_eepromInfo.i2cMuxPath.type())
+ {
+ TS_FAIL("testI2cMux::i2cMuxPath type returned(%d), "
+ "expected(PHYSICAL)",
+ l_eepromInfo.i2cMuxPath.type());
+ }
+
+ char * l_pathAsString =
+ l_eepromInfo.i2cMuxPath.toString();
+
+ if (0 != strcmp(l_pathAsString,
+ "Physical:/Sys0"))
+ {
+ TS_FAIL("testI2cMux::i2cMuxPath path returned(%s), "
+ "expected(Physical:/Sys0)",
+ l_pathAsString);
+ }
+ free (l_pathAsString);
+ l_pathAsString = nullptr;
+ } // end if ( (TARGETING::CLASS_ENC == targetClass) ...
+ } // end for (l_targetList;++l_targetList)
+ } // end if (l_targetList)
+ else
+ {
+ TS_FAIL("testI2cMux::No targets containing I2C Mux found");
+ }
+
+ TS_TRACE(EXIT_MRK "testI2cMux");
+ }
+
};
#endif // End __TARGETING_TESTTARGETING_H
OpenPOWER on IntegriCloud