summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Derksen <v2cibmd@us.ibm.com>2016-10-28 08:31:19 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2016-11-04 17:06:02 -0400
commit0d34e171ea23a73a93657d4b39ea3d75d75d63c7 (patch)
treea86c6e80601d57b43141dd86ac73bded371a9f63
parentb544343639825fd63f8b0a0eedce4fb4fb5558c3 (diff)
downloadtalos-hostboot-0d34e171ea23a73a93657d4b39ea3d75d75d63c7.tar.gz
talos-hostboot-0d34e171ea23a73a93657d4b39ea3d75d75d63c7.zip
Support comma-delimited targets in attribute override
Change-Id: I338335ae1e447bfe9bb78cf424b4754199fcd9ab RTC:162535 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/31992 Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com> 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: Martin Gloff <mgloff@us.ibm.com> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
-rw-r--r--src/usr/targeting/attroverride/README.attr_override14
-rwxr-xr-xsrc/usr/targeting/attroverride/attrTextToBinaryBlob.C331
-rwxr-xr-xsrc/usr/targeting/attroverride/attrTextToBinaryBlob.H40
3 files changed, 308 insertions, 77 deletions
diff --git a/src/usr/targeting/attroverride/README.attr_override b/src/usr/targeting/attroverride/README.attr_override
index c18900f20..da323e2c1 100644
--- a/src/usr/targeting/attroverride/README.attr_override
+++ b/src/usr/targeting/attroverride/README.attr_override
@@ -56,7 +56,6 @@ the user would like to override along with their new values.
#####Other target examples:
-
- System Target:
- target
- target = k0:n0:s0
@@ -65,6 +64,9 @@ the user would like to override along with their new values.
- DIMM Target
- target = k0:n0:s0:dimm:p06
+ - Multiple DIMM Targets
+ - target = k0:n0:s0:dimm:p2,4
+
- All p8 chips
- target = k0:n0:s0:p8:pall
@@ -73,7 +75,7 @@ the user would like to override along with their new values.
- Node number specified (Brazos only, for Tuleta, always use n0)
- target = k0:n1:s0:dimm:p06
- - target = k0:nall:s0:dimm:p06
+ - target = k0:nall:s0:dimm:p06
###Rules:
@@ -103,15 +105,15 @@ the user would like to override along with their new values.
- The next part of the line specifies the target position (for units
this is the parent chip position)
- - :p0 or :p1 or :p511 or :pall etc (note that 'all' specifies an
- override for all Targets of the specified type)
+ - :p0 or :p1 or :p1,3 or :p511 or :pall etc (note that 'all'
+ specifies an override for all Targets of the specified type)
- The next part of the line specified the target unit position (only
applicable to targets)
- - :c0 or :c1 or :call etc (note that 'all' specifies an override for
- all Targets of the specified type)
+ - :c0 or :c1 or :c1,2 or :call etc (note that 'all' specifies
+ an override for all Targets of the specified type)
- Lines starting with "ATTR_" specify attribute overrides
diff --git a/src/usr/targeting/attroverride/attrTextToBinaryBlob.C b/src/usr/targeting/attroverride/attrTextToBinaryBlob.C
index 2ac53969a..9ca5b4acd 100755
--- a/src/usr/targeting/attroverride/attrTextToBinaryBlob.C
+++ b/src/usr/targeting/attroverride/attrTextToBinaryBlob.C
@@ -487,23 +487,59 @@ bool AttrTextToBinaryBlob::attrFileAttrLineToFields(
return l_success;
}
-
+//******************************************************************************
+void AttrTextToBinaryBlob::updateLabels(
+ std::vector<target_label> & io_labels,
+ const target_label & i_label_override)
+{
+ for (auto & l_label : io_labels)
+ {
+ if (i_label_override.node != AttributeTank::ATTR_NODE_NA)
+ {
+ l_label.node = i_label_override.node;
+ }
+ if (i_label_override.targetPos != AttributeTank::ATTR_POS_NA)
+ {
+ l_label.targetPos = i_label_override.targetPos;
+ }
+ if (i_label_override.unitPos != AttributeTank::ATTR_UNIT_POS_NA)
+ {
+ l_label.unitPos = i_label_override.unitPos;
+ }
+ }
+}
//******************************************************************************
bool AttrTextToBinaryBlob::attrFileTargetLineToData(
const std::string & i_line,
const AttributeTank::TankLayer i_tankLayer,
uint32_t & o_targetType,
- uint16_t & o_targetPos,
- uint8_t & o_targetUnitPos,
- uint8_t & o_targetNode)
+ std::vector<target_label> & o_targetLabels)
{
/*
* e.g. "target = k0:n0:s0:centaur.mba:p02:c1"
* - o_targetType = 0x00000001
- * - o_targetPos = 2
- * - o_targetUnitPos = 1
+ * - 1 target specified:
+ * node: 0, targetPos: 2, unitPos: 1
+ *
+ *
+ * e.g. "target = k0:n0:s0:centaur.mba:p0,3:c1"
+ * - o_targetType = 0x00000001
+ * - 2 targets specified:
+ * node: 0, targetPos: 0, unitPos: 1
+ * node: 0, targetPos: 3, unitPos: 1
*/
+
+ // create a generic label
+ target_label l_label;
+
+ // always start with no targets
+ o_targetLabels.clear();
+
+ // find positions
+ size_t l_comma_pos;
+ size_t l_colon_pos;
+
bool l_err = false;
// If the target string is not decoded into a non-system target and
// explicit positions are not found then the caller will get these defaults
@@ -519,9 +555,7 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
{
o_targetType = TARGETING::TYPE_SYS;
}
- o_targetNode = AttributeTank:: ATTR_NODE_NA;
- o_targetPos = AttributeTank:: ATTR_POS_NA;
- o_targetUnitPos = AttributeTank::ATTR_UNIT_POS_NA;
+
// Find the node, target type, pos and unit-pos
int l_cageIndex = i_line.find(ATTR_CAGE_NUMBER);
if(l_cageIndex != std::string::npos )
@@ -541,13 +575,40 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
}
else
{
- o_targetNode = strtoul(l_line.c_str(), NULL, 10);
+ l_colon_pos = l_line.find(':');
+ l_comma_pos = l_line.find(',');
+
+ // make sure comma comes before ending colon
+ while ((l_comma_pos != std::string::npos) &&
+ (l_comma_pos < l_colon_pos))
+ {
+ // grab number (stops at first non-numerical character)
+ l_label.node = strtoul(l_line.c_str(), NULL, 10);
+
+ // add a new target label node number
+ o_targetLabels.push_back(l_label);
+
+ // increment line past the comma
+ l_line = l_line.substr(l_comma_pos+1);
+
+ // search for next potential comma
+ l_comma_pos = l_line.find(',');
+ }
+ // grab number (stops at first non-numerical character)
+ l_label.node = strtoul(l_line.c_str(), NULL, 10);
- size_t l_pos = l_line.find(':');
+ // add the last target label node number
+ o_targetLabels.push_back(l_label);
- if (l_pos != std::string::npos)
+ // turn off overriding node
+ l_label.node = AttributeTank::ATTR_NODE_NA;
+
+ // line may have changed size so refind the ending colon
+ // for the node part
+ l_colon_pos = l_line.find(':');
+ if (l_colon_pos != std::string::npos)
{
- l_line = l_line.substr(l_pos);
+ l_line = l_line.substr(l_colon_pos);
}
else
{
@@ -565,17 +626,24 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
// Figure out the target type
// Remove the end of the target string (position and unitpos) before
// using the line to search for target types
- auto l_pos = l_line.find(":");
+ l_colon_pos = l_line.find(":");
+
std::string l_targetType;
+ std::string l_origTargetType;
TargStrToType* chip_type_first = NULL;
TargStrToType* chip_type_last = NULL;
TargStrToType* item = NULL;
- if( l_pos != std::string::npos)
+ if( l_colon_pos != std::string::npos)
{
- l_targetType = l_line.substr(0, l_pos);
+ // save the full target type name
+ l_origTargetType = l_line.substr(0, l_colon_pos);
+
+ // put it into an alterable target type
+ l_targetType = l_origTargetType;
+
auto l_dotIndex = l_targetType.find(".");
if(l_dotIndex != std::string::npos)
@@ -588,7 +656,6 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
chip_type_first = &CHIP_UNIT_TYPE_TARG_STR_TO_TYPE[0];
chip_type_last = &CHIP_UNIT_TYPE_TARG_STR_TO_TYPE
[(sizeof(CHIP_UNIT_TYPE_TARG_STR_TO_TYPE)/sizeof(TargStrToType))-1];
-
}
else
{
@@ -602,7 +669,7 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
//Search for target type
item = std::find( chip_type_first,
- chip_type_last, l_targetType.c_str());
+ chip_type_last, l_targetType.c_str());
if( item != chip_type_last )
{
@@ -610,7 +677,9 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
// choose fapi2 or targeting type
o_targetType = ( i_tankLayer == AttributeTank::TANK_LAYER_TARG ?
item->iv_targType : item->iv_fapiType);
- l_line = l_line.substr(l_targetType.length());
+
+ // skip past the full target type name
+ l_line = l_line.substr(l_origTargetType.length());
l_sysTarget = false;
}
else
@@ -623,11 +692,13 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
}
else
{
+ // no target type specified, so default to sys target
l_sysTarget = true;
}
- // For a non-system target, figure out the position and unit position
+ // For a non-system target,
+ // figure out the position and unit position
if (l_sysTarget == false)
{
// Figure out the target's position
@@ -641,13 +712,76 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
}
else
{
- o_targetPos = strtoul(l_line.c_str(), NULL, 10);
+ bool firstPos = true;
+ l_colon_pos = l_line.find(':');
+ l_comma_pos = l_line.find(',');
+ std::vector<target_label> origCopy;
- size_t l_pos = l_line.find(':');
+ while ((l_comma_pos != std::string::npos) &&
+ (l_comma_pos < l_colon_pos))
+ {
+ // grab targetPos number
+ // (stops at first non-numerical character)
+ l_label.targetPos =
+ strtoul(l_line.c_str(), NULL, 10);
+
+ if (firstPos)
+ {
+ // save a copy of current targets before
+ // adding targetPos
+ origCopy = o_targetLabels;
+
+ // update targetPos of current targets
+ updateLabels(o_targetLabels, l_label);
+ firstPos = false;
+ }
+ else
+ {
+ // update targetPos of original targets
+ updateLabels(origCopy, l_label);
+
+ // add these new targetPos targets to
+ // current target list
+ o_targetLabels.insert( o_targetLabels.end(),
+ origCopy.begin(),
+ origCopy.end() );
+ }
+
+ // skip past the comma
+ l_line = l_line.substr(l_comma_pos+1);
+
+ // now look for next potential comma
+ l_comma_pos = l_line.find(',');
+ }
+
+ // grab number (stops at first non-numerical character)
+ l_label.targetPos = strtoul(l_line.c_str(), NULL, 10);
+ if (firstPos)
+ {
+ // no comma found, so just update
+ // current target list
+ updateLabels(o_targetLabels, l_label);
+ }
+ else
+ {
+ // last targetPos in comma list
+ // update targetPos of original targets
+ updateLabels(origCopy, l_label);
+
+ // add these new targetPos targets to
+ // the current target list
+ o_targetLabels.insert(o_targetLabels.end(),
+ origCopy.begin(),
+ origCopy.end());
+ }
+ l_label.targetPos = AttributeTank::ATTR_POS_NA;
- if (l_pos != std::string::npos)
+ // line may have changed size so refind the ending colon
+ // for targetPos part
+ l_colon_pos = l_line.find(':');
+ if (l_colon_pos != std::string::npos)
{
- l_line = l_line.substr(l_pos);
+ l_line = l_line.substr(l_colon_pos);
}
else
{
@@ -667,7 +801,63 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
}
else
{
- o_targetUnitPos = strtoul(l_line.c_str(), NULL, 10);
+ bool firstPos = true;
+ l_comma_pos = l_line.find(',');
+ std::vector<target_label> origCopy;
+
+ while (l_comma_pos != std::string::npos)
+ {
+ // grab unitPos number
+ // (stops at first non-numerical character)
+ l_label.unitPos = strtoul(l_line.c_str(), NULL, 10);
+ if (firstPos)
+ {
+ // save a copy of current targets
+ // before adding unitPos
+ origCopy = o_targetLabels;
+
+ // update unitPos of current targets
+ updateLabels(o_targetLabels, l_label);
+ firstPos = false;
+ }
+ else
+ {
+ // update unitPos of original targets
+ updateLabels(origCopy, l_label);
+
+ // add these new unitPos targets to
+ // the current target list
+ o_targetLabels.insert( o_targetLabels.end(),
+ origCopy.begin(),
+ origCopy.end() );
+ }
+ // skip past the comma
+ l_line = l_line.substr(l_comma_pos+1);
+
+ // now look for next potential comma
+ l_comma_pos = l_line.find(',');
+ }
+
+ // grab number (stops at first non-numerical character)
+ l_label.unitPos = strtoul(l_line.c_str(), NULL, 10);
+ if (firstPos)
+ {
+ // no comma found, so just update
+ // current target list
+ updateLabels(o_targetLabels, l_label);
+ }
+ else
+ {
+ // last unitPos in comma list
+ // update unitPos of original targets
+ updateLabels(origCopy, l_label);
+
+ // add these new unitPos targets to
+ // the current target list
+ o_targetLabels.insert(o_targetLabels.end(),
+ origCopy.begin(),
+ origCopy.end());
+ }
}
}
}
@@ -676,7 +866,10 @@ bool AttrTextToBinaryBlob::attrFileTargetLineToData(
// System targets must have an NA node
if (l_sysTarget)
{
- o_targetNode = AttributeTank::ATTR_NODE_NA;
+ if (o_targetLabels.size() == 0)
+ {
+ o_targetLabels.push_back(l_label);
+ }
}
} while( 0 );
@@ -847,6 +1040,8 @@ bool AttrTextToBinaryBlob::attrTextToBinaryBlob( std::ifstream& i_file,
uint16_t l_pos = AttributeTank::ATTR_POS_NA;
uint8_t l_unitPos = AttributeTank::ATTR_UNIT_POS_NA;
uint8_t l_node = AttributeTank::ATTR_NODE_NA;
+ std::vector<target_label> l_targetLabels;
+
uint32_t l_valSize = 0;
uint8_t * l_pVal = NULL;
bool l_const = false;
@@ -960,9 +1155,12 @@ bool AttrTextToBinaryBlob::attrTextToBinaryBlob( std::ifstream& i_file,
break;
}
+
// Get the Target Data for this attribute
- l_pErr = attrFileTargetLineToData(l_targetLine, l_tankLayer, l_targetType,
- l_pos, l_unitPos, l_node);
+ l_pErr = attrFileTargetLineToData(l_targetLine,
+ l_tankLayer,
+ l_targetType,
+ l_targetLabels);
if (l_pErr)
{
@@ -978,48 +1176,55 @@ bool AttrTextToBinaryBlob::attrTextToBinaryBlob( std::ifstream& i_file,
l_flags = AttributeTank::ATTR_FLAG_CONST;
}
+ for (const auto & l_label : l_targetLabels)
+ {
+ l_pos = l_label.targetPos;
+ l_unitPos = l_label.unitPos;
+ l_node = l_label.node;
- //Add data to AttributeHeader
- l_attrData.iv_attrId = l_attrId;
- l_attrData.iv_targetType = l_targetType;
- l_attrData.iv_pos = l_pos;
- l_attrData.iv_unitPos = l_unitPos;
- l_attrData.iv_node = l_node;
- l_attrData.iv_flags = l_flags;
- l_attrData.iv_valSize = l_valSize;
+ //Add data to AttributeHeader
+ l_attrData.iv_attrId = l_attrId;
+ l_attrData.iv_targetType = l_targetType;
+ l_attrData.iv_pos = l_pos;
+ l_attrData.iv_unitPos = l_unitPos;
+ l_attrData.iv_node = l_node;
+ l_attrData.iv_flags = l_flags;
+ l_attrData.iv_valSize = l_valSize;
- if( g_showDebugLogs )
- {
- //Print information
- printf("attrTextToBinaryBlob: ATTR override "
- "Id: 0x%08x, TargType: 0x%08x, Pos: 0x%04x, "
- "UPos: 0x%02x\n",
- l_attrId, l_targetType, l_pos, l_unitPos);
- printf("attrTextToBinaryBlob: ATTR override "
- "Node: 0x%02x, Flags: 0x%02x, Size: 0x%08x",
- l_node, l_flags, l_valSize);
- printf(" Val: 0x");
- //print the value
- for(int i = 0; i < l_valSize; i++)
+ if( g_showDebugLogs )
{
- printf("%x", l_pVal[i]);
+ //Print information
+ printf("attrTextToBinaryBlob: ATTR override "
+ "Id: 0x%08x, TargType: 0x%08x, Pos: 0x%04x, "
+ "UPos: 0x%02x\n",
+ l_attrId, l_targetType, l_pos, l_unitPos);
+ printf("attrTextToBinaryBlob: ATTR override "
+ "Node: 0x%02x, Flags: 0x%02x, Size: 0x%08x",
+ l_node, l_flags, l_valSize);
+ printf(" Val: 0x");
+ //print the value
+ for(int i = 0; i < l_valSize; i++)
+ {
+ printf("%x", l_pVal[i]);
+ }
+ printf("\n\n");
}
- printf("\n\n");
- }
- //write attribute data into a buffer
- l_pErr = writeDataToBuffer( l_attrData,
- l_tankLayer,
- l_pVal,
- l_attrBlob,
- l_buffer,
- l_totalSize );
+ //write attribute data into a buffer
+ l_pErr = writeDataToBuffer( l_attrData,
+ l_tankLayer,
+ l_pVal,
+ l_attrBlob,
+ l_buffer,
+ l_totalSize );
+
+ if( l_pErr )
+ {
+ printf("An error occured in writeDataToBuffer\n");
+ }
+ } // End of target labels
- if( l_pErr )
- {
- printf("An error occured in writeDataToBuffer\n");
- }
delete[] l_pVal;
l_pVal = NULL;
}
diff --git a/src/usr/targeting/attroverride/attrTextToBinaryBlob.H b/src/usr/targeting/attroverride/attrTextToBinaryBlob.H
index ff7340c63..6650d7845 100755
--- a/src/usr/targeting/attroverride/attrTextToBinaryBlob.H
+++ b/src/usr/targeting/attroverride/attrTextToBinaryBlob.H
@@ -34,7 +34,6 @@
namespace AttrTextToBinaryBlob
{
-
/**
* Constant for the maximum number of array dimensions an attribute can have
*/
@@ -160,24 +159,49 @@ namespace AttrTextToBinaryBlob
bool & o_const);
/**
+ * Structure for target's identification
+ *
+ * node Target Node Number
+ * targetPos Target Position
+ * unitPos Target Unit Position
+ */
+ struct target_label
+ {
+ uint8_t node;
+ uint16_t targetPos;
+ uint8_t unitPos;
+ target_label():node(AttributeTank::ATTR_NODE_NA),
+ targetPos(AttributeTank::ATTR_POS_NA),
+ unitPos(AttributeTank::ATTR_UNIT_POS_NA){}
+ };
+
+ /**
+ * @brief Helper function that updates label list
+ *
+ * @param[in/out] io_labels Label list to be updated
+ * @param[in] i_label_override Specifies override values to
+ * apply to each label in list
+ *
+ */
+ static void updateLabels(std::vector<target_label> & io_labels,
+ const target_label & i_label_override);
+
+ /**
* @brief Converts a target line from an Attribute Text File to data
*
* @param[in] i_line Ref to string containing target line
* @param[in] i_tankLayer Firmware layer containing the tank
* @param[out] o_targetType Target Type (as stored in tank)
- * @param[out] o_targetPos Target Position (as stored in tank)
- * @param[out] o_targetUnitPos Target Unit Position (as stored in tank)
- * @param[out] o_targetNode Target Node Number
+ * @param[out] o_targetLabels List of target labels
*
- * @return - true if the target line was successfully parse, false otherwise
+ * @return - true if the target line was successfully parsed, false otherwise
*/
static bool attrFileTargetLineToData(
const std::string & i_line,
const AttributeTank::TankLayer i_tankLayer,
uint32_t & o_targetType,
- uint16_t & o_targetPos,
- uint8_t & o_targetUnitPos,
- uint8_t & o_targetNode);
+ std::vector<target_label> & o_targetLabels);
+
/**
* @brief Converts a set of attribute lines (all for the same attribute)
OpenPOWER on IntegriCloud