From af6b57dcb79e522d6a4e140f7952f58b3419cee1 Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Mon, 7 Jul 2014 10:24:06 -0500 Subject: Add BMC Attr override support Change-Id: I1a42fec21189c55c75e9073527867e4e95528794 RTC: 108376 CMVC-Corec: 931324 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/11995 Reviewed-by: A. Patrick Williams III Tested-by: Jenkins Server --- src/usr/targeting/common/attributeTank.C | 124 ++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 2 deletions(-) (limited to 'src/usr/targeting/common/attributeTank.C') diff --git a/src/usr/targeting/common/attributeTank.C b/src/usr/targeting/common/attributeTank.C index 76e330e69..0ec8fd761 100644 --- a/src/usr/targeting/common/attributeTank.C +++ b/src/usr/targeting/common/attributeTank.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* [+] 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. */ @@ -29,6 +31,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include + + namespace TARGETING { @@ -277,7 +288,6 @@ void AttributeTank::serializeAttributes( uint32_t l_index = 0; AttributesCItr_t l_itr = iv_attributes.begin(); - while (l_itr != iv_attributes.end()) { // Fill up the buffer with as many attributes as possible @@ -467,4 +477,114 @@ AttributeTank::Attribute::~Attribute() iv_pVal = NULL; } +//****************************************************************************** +errlHndl_t AttributeTank::writePermAttributes() +{ + errlHndl_t l_err = NULL; + + for(AttributesCItr_t l_attrIter = iv_attributes.begin(); + l_attrIter != iv_attributes.end(); ++l_attrIter) + { + Attribute* l_attr = *l_attrIter; + AttributeHeader l_attrHdr = l_attr->iv_hdr; + PredicatePostfixExpr l_permAttrOverrides; + + // Predicate to match target type + PredicateCTM l_targetTypeFilter + (CLASS_NA, static_cast(l_attrHdr.iv_targetType)); + + // Predicate to match attribute tank target position + PredicateAttrTankTargetPos l_targetPosFilter(l_attrHdr.iv_pos, + l_attrHdr.iv_unitPos, + l_attrHdr.iv_node); + + l_permAttrOverrides.push(&l_targetTypeFilter) + .push(&l_targetPosFilter).And(); + + // Apply the filter through all targets + TargetRangeFilter l_permTargetList( targetService().begin(), + targetService().end(), + &l_permAttrOverrides); + + // Write permanent attributes to target + for ( ; l_permTargetList; ++l_permTargetList) + { + bool l_success = (*l_permTargetList)->_trySetAttr( + static_cast(l_attrHdr.iv_attrId), + l_attrHdr.iv_valSize, + l_attr->iv_pVal ); + + if (l_success) + { + TRACFCOMP(g_trac_targeting, "writePermAttributes: Successful permanent override of Attr ID:0x%X Value:0x%lX applied to target 0x%X", + l_attrHdr.iv_attrId, + *reinterpret_cast(l_attr->iv_pVal), + (*l_permTargetList)->getAttr() ); + } + else + { + uint8_t * io_pAttrData = NULL; + bool l_found = (*l_permTargetList)->_tryGetAttr( + static_cast(l_attrHdr.iv_attrId), + l_attrHdr.iv_valSize, + io_pAttrData); + + if (l_found) + { + TRACFCOMP(g_trac_targeting, "writePermAttributes: Value NOT applied to target, override failed for Attr ID:0x%X Value:0x%lX on target 0x%X - current value 0x%lX", + l_attrHdr.iv_attrId, + *reinterpret_cast(l_attr->iv_pVal), + (*l_permTargetList)->getAttr(), + *reinterpret_cast(io_pAttrData) ); + /*@ + * @errortype + * @moduleid TARG_WRITE_PERM_ATTR + * @reasoncode TARG_RC_WRITE_PERM_ATTR_FAIL + * @userdata1 Target specified + * @userdata2 Attribute specified + * @devdesc Failure applying given attribute override + * on given target + */ + UTIL::createTracingError( + TARG_WRITE_PERM_ATTR, + TARG_RC_WRITE_PERM_ATTR_FAIL, + (*l_permTargetList)->getAttr(), + l_attrHdr.iv_attrId, + 0,0, + l_err); + break; + } + else + { + TRACFCOMP(g_trac_targeting, "writePermAttributes: Target does not have attribute, override NOT applied for Attr ID:0x%X on target 0x%X", + l_attrHdr.iv_attrId, + (*l_permTargetList)->getAttr() ); + /*@ + * @errortype + * @moduleid TARG_WRITE_PERM_ATTR + * @reasoncode TARG_RC_WRITE_PERM_ATTR_TARGET_FAIL + * @userdata1 Target specified + * @userdata2 Attribute specified + * @devdesc Given target does not have given attribute + * to apply override + */ + UTIL::createTracingError( + TARG_WRITE_PERM_ATTR, + TARG_RC_WRITE_PERM_ATTR_TARGET_FAIL, + (*l_permTargetList)->getAttr(), + l_attrHdr.iv_attrId, + 0,0, + l_err); + break; + } + } + } + if (l_err) + { + break; + } + } + return l_err; +} + } -- cgit v1.2.3