diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2016-03-14 11:27:49 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-03-23 11:31:45 -0400 |
commit | 16ff4c0894f726ea97362536af36a413b1f255cd (patch) | |
tree | 78e5c57d3fe5307917dca729d444437db8ead3b3 /src/usr | |
parent | efb976fc64fc447d93015d3bb950431f341b6c19 (diff) | |
download | talos-hostboot-16ff4c0894f726ea97362536af36a413b1f255cd.tar.gz talos-hostboot-16ff4c0894f726ea97362536af36a413b1f255cd.zip |
Support getChildren and getParent FAPI2 tests
- Added FAPI reason codes to support tests
- Added special handlers to getParent/getChildren for pervasive associations
- Added new APIs to filtering utilities to walk pervasive associations
- Updated getParent/getChildren tests to fully exercise pervasive associations
RTC: 148577
Change-Id: I0d8ec427e6c2092852a32c7da605d1c47c554b50
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22084
Tested-by: Jenkins Server
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: FSP CI Jenkins
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/fapi2/test/fapi2GetChildrenTest.C | 220 | ||||
-rw-r--r-- | src/usr/fapi2/test/fapi2GetParentTest.C | 134 | ||||
-rw-r--r-- | src/usr/fapi2/test/fapi2TestUtils.H | 45 | ||||
-rw-r--r-- | src/usr/targeting/common/utilFilter.C | 22 |
4 files changed, 381 insertions, 40 deletions
diff --git a/src/usr/fapi2/test/fapi2GetChildrenTest.C b/src/usr/fapi2/test/fapi2GetChildrenTest.C index b7923081c..cd394f3ef 100644 --- a/src/usr/fapi2/test/fapi2GetChildrenTest.C +++ b/src/usr/fapi2/test/fapi2GetChildrenTest.C @@ -29,6 +29,7 @@ #include <hwpf_fapi2_reasoncodes.H> #include <fapi2TestUtils.H> #include <cxxtest/TestSuite.H> +#include <functional> using namespace fapi2; @@ -116,7 +117,6 @@ errlHndl_t fapi2GetChildrenTest() } } - Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget( l_nimbusProc); Target<fapi2::TARGET_TYPE_EQ> fapi2_eqTarget( @@ -125,8 +125,6 @@ errlHndl_t fapi2GetChildrenTest() targeting_targets[MY_EX]); Target<fapi2::TARGET_TYPE_MCS> fapi2_mcsTarget( targeting_targets[MY_MCS]);; - Target<fapi2::TARGET_TYPE_PERV> fapi2_pervTarget( - targeting_targets[MY_PERV]); Target<fapi2::TARGET_TYPE_MCBIST> fapi2_mcbistTarget( targeting_targets[MY_MCBIST]); @@ -216,52 +214,196 @@ errlHndl_t fapi2GetChildrenTest() break; } - //Currently PERV targets do not have CORE children, but its valid to look for PERV's children - //TODO 148577 Implement Parent/Child Relationships for PERV Targets - // valid children for PERV + // Test pervasive children + + // Valid children for PERV: // PERV -> EQ // PERV -> CORE // PERV -> XBUS // PERV -> OBUS // PERV -> CAPP // PERV -> NV // PERV -> MCBIST // PERV -> MCS // PERV -> MCA // PERV -> PEC // PERV -> PHB // PERV -> MI // PERV -> DMI - l_childCores = fapi2_pervTarget.getChildren<fapi2::TARGET_TYPE_CORE>(TARGET_STATE_PRESENT); - l_targetHuid = TARGETING::get_huid(targeting_targets[MY_PERV]) ; - l_actualSize = l_childCores.size(); - l_expectedSize = 0; - numTests++; - if(l_actualSize != l_expectedSize) + static struct pervasiveChildTestRec { + + // Expected number of children + uint32_t expectedSize; + + // Lambda function specifying which pervasive chip units map to + // children of the type implied by the body of the lambda function + // below + bool (*unitMapsToRightTargetType)(TARGETING::ATTR_CHIP_UNIT_type); + + // Lambda function taking a pervasive target and returning the + // number of children it has for a given FAPI type + size_t (*actualSize)(Target<fapi2::TARGET_TYPE_PERV>&); + + } pervasiveChildTests [] = { + + // EQ pervasive has 1 EQ child + {PERV_EQ_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= EQ_LOW) && (i_unit <= EQ_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_EQ>( + TARGET_STATE_PRESENT).size(); } }, + + // CORE pervasive has 1 CORE child + {PERV_CORE_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= CORE_LOW) && (i_unit <= CORE_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_CORE>( + TARGET_STATE_PRESENT).size(); } }, + + // XBUS pervasive has 2 XBUS children + {PERV_XBUS_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return (i_unit == XBUS_RANGE); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_XBUS>( + TARGET_STATE_PRESENT).size(); } }, + + // OBUS pervasive has 1 OBUS child + {PERV_OBUS_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= OBUS_LOW) && (i_unit <= OBUS_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_OBUS>( + TARGET_STATE_PRESENT).size(); } }, + + // CAPP pervasive has 1 CAPP child + {PERV_CAPP_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit == CAPP0_RANGE) || (i_unit == CAPP1_RANGE));}, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_CAPP>( + TARGET_STATE_PRESENT).size(); } }, + + // NV pervasive has 2 NV children + {PERV_NV_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return (i_unit == NV_RANGE); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_NV>( + TARGET_STATE_PRESENT).size(); } }, + + // MCBIST/MCS/MCA pervasive has 1 MCBIST child + {PERV_MCBIST_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ( (i_unit >= MC_LOW) + && (i_unit <= MC_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_MCBIST>( + TARGET_STATE_PRESENT).size(); } }, + + // MCBIST/MCS/MCA pervasive has 2 MCS children + {PERV_MCS_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= MC_LOW) && (i_unit <= MC_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_MCS>( + TARGET_STATE_PRESENT).size(); } }, + + // MCBIST/MCS/MCA pervasive has 4 MCA children + {PERV_MCA_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= MC_LOW) && (i_unit <= MC_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_MCA>( + TARGET_STATE_PRESENT).size(); } }, + + // PEC/PHB pervasive has 1 PEC child + {PERV_PEC_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return ((i_unit >= PEC_LOW) && (i_unit <= PEC_HIGH)); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_PEC>( + TARGET_STATE_PRESENT).size(); } }, + + // PEC/PHB pervasive with 1 PHB child + {PERV_PEC0_PHB_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return (i_unit == PEC_LOW); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_PHB>( + TARGET_STATE_PRESENT).size(); } }, + + // PEC/PHB pervasive with 2 PHB children + {PERV_PEC1_PHB_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return (i_unit == PEC_MID); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_PHB>( + TARGET_STATE_PRESENT).size(); } }, + + // PEC/PHB pervasive with 3 PHB children + {PERV_PEC2_PHB_CHILDREN, + [](TARGETING::ATTR_CHIP_UNIT_type i_unit) + { return (i_unit == PEC_HIGH); }, + [](Target<fapi2::TARGET_TYPE_PERV>& i_perv) + { return i_perv.getChildren<fapi2::TARGET_TYPE_PHB>( + TARGET_STATE_PRESENT).size(); } }, + + // No MI or DMI units for Nimbus + }; + + // Build list of all pervasive targets in the blueprint + TARGETING::TargetHandleList pervasiveTargets; + TARGETING::getAllChiplets( + pervasiveTargets, + TARGETING::TYPE_PERV, + false); + + // Test each type of target that can be a child of a pervasive + for(const pervasiveChildTestRec& pervasiveChildTest + : pervasiveChildTests) { - numFails++; - break; - } + l_expectedSize = pervasiveChildTest.expectedSize; + l_actualSize = 0; + l_targetHuid = 0; + + numTests++; + TARGETING::TargetHandle_t candidateTarget = NULL; + for(TARGETING::TargetHandleList::const_iterator pIt + = pervasiveTargets.begin(); + pIt != pervasiveTargets.end(); + ++pIt) + { + auto unit = (*pIt)->getAttr<TARGETING::ATTR_CHIP_UNIT>(); + if ( pervasiveChildTest.unitMapsToRightTargetType(unit) ) + { + candidateTarget = (*pIt); + break; + } + } - l_childEQs = fapi2_pervTarget.getChildren<fapi2::TARGET_TYPE_EQ>(TARGET_STATE_PRESENT); - l_targetHuid = TARGETING::get_huid(targeting_targets[MY_PERV]) ; - l_actualSize = l_childEQs.size(); - l_expectedSize = 0; + if(candidateTarget == NULL) + { + numFails++; + break; + } - numTests++; - if(l_actualSize != l_expectedSize) - { - numFails++; - break; - } + l_targetHuid = TARGETING::get_huid(candidateTarget); - l_childXBUSs = fapi2_pervTarget.getChildren<fapi2::TARGET_TYPE_XBUS>(TARGET_STATE_PRESENT); - l_targetHuid = TARGETING::get_huid(targeting_targets[MY_PERV]) ; - l_actualSize = l_childXBUSs.size(); - l_expectedSize = 0; + Target<fapi2::TARGET_TYPE_PERV> fapi2_pervTarget( + candidateTarget); + + l_actualSize = pervasiveChildTest.actualSize(fapi2_pervTarget); + + if(l_actualSize != l_expectedSize) + { + numFails++; + break; + } - numTests++; - if(l_actualSize != l_expectedSize) - { - numFails++; - break; } - //Uncomment to test compile fails -// std::vector<Target<fapi2::TARGET_TYPE_PROC_CHIP> > l_childProcs; -// l_childProcs = fapi2_procTarget.getChildren<fapi2::TARGET_TYPE_PROC_CHIP>(TARGET_STATE_PRESENT); -// l_childCores = fapi2_mcsTarget.getChildren<fapi2::TARGET_TYPE_CORE>(TARGET_STATE_PRESENT); + + // Uncomment to test compile fails + // std::vector<Target<fapi2::TARGET_TYPE_PROC_CHIP> > l_childProcs; + // l_childProcs = fapi2_procTarget.getChildren< + // fapi2::TARGET_TYPE_PROC_CHIP>(TARGET_STATE_PRESENT); + // l_childCores = fapi2_mcsTarget.getChildren< + // fapi2::TARGET_TYPE_CORE>(TARGET_STATE_PRESENT); + }while(0); if(l_actualSize != l_expectedSize) @@ -296,4 +438,4 @@ errlHndl_t fapi2GetChildrenTest() -}
\ No newline at end of file +} diff --git a/src/usr/fapi2/test/fapi2GetParentTest.C b/src/usr/fapi2/test/fapi2GetParentTest.C index 3fc30cfbb..d17968b52 100644 --- a/src/usr/fapi2/test/fapi2GetParentTest.C +++ b/src/usr/fapi2/test/fapi2GetParentTest.C @@ -34,7 +34,26 @@ using namespace fapi2; namespace fapi2 { -//@TODO RTC:148577 need to add tests to get the PERV parent of targets +/** + * @brief Helper to get the parent pervasive of the given target + * + * @tparam K Input target's FAPI2 type + * @tparam V Platform target handle type + * + * @param[in] i_pTarget Targeting target + * + * @return Platform target handle giving the pervasive of the input target + * @retval NULL No parent found + * @retval !NULL Parent found, equal to the retval + */ +template< TargetType K, typename V = plat_target_handle_t > +inline V getPervasiveParent(V i_pTarget) +{ + Target<K,V> fapi2_target(i_pTarget); + return static_cast<V>( + fapi2_target.template getParent<TARGET_TYPE_PERV>()); +} + //****************************************************************************** // fapi2GetParentTest //****************************************************************************** @@ -946,6 +965,119 @@ errlHndl_t fapi2GetParentTest() numFails++; } + // Check units which have a pervasive parent + + static struct pervasiveParentTestRec { + + // Source unit from which to find parent pervasive + TARGETING::Target* pTarget; + + // Lambda function taking a unit target and returning its + // parent pervasive target (if any) + TARGETING::Target* (*getParent)(TARGETING::Target* i_pTarget); + + } pervasiveParentTests [] = { + + {targeting_targets[MY_EQ], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_EQ>(i_pTarget); }}, + {targeting_targets[MY_CORE], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_CORE>(i_pTarget); }}, + {targeting_targets[MY_MCS], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_MCS>(i_pTarget); }}, + {targeting_targets[MY_MCA], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_MCA>(i_pTarget); }}, + {targeting_targets[MY_MCBIST], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_MCBIST>(i_pTarget);}}, + {targeting_targets[MY_PEC], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_PEC>(i_pTarget); }}, + {targeting_targets[MY_PHB], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_PHB>(i_pTarget); }}, + {targeting_targets[MY_XBUS], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_XBUS>(i_pTarget); }}, + {targeting_targets[MY_OBUS], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_OBUS>(i_pTarget); }}, + {targeting_targets[MY_NV], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_NV>(i_pTarget); }}, + {targeting_targets[MY_CAPP], + [](TARGETING::Target* i_pTarget) + {return getPervasiveParent<TARGET_TYPE_CAPP>(i_pTarget); }}, + }; + + // Test each type of target that can have exactly one pervasive parent + for(const pervasiveParentTestRec& pervasiveParentTest + : pervasiveParentTests) + { + numTests++; + l_tempTargetingParent = pervasiveParentTest.getParent( + pervasiveParentTest.pTarget); + + // Result must be a non-NULL target of pervasive type, and its + // parent must be the same proc as the other tests above + TARGETING::Target* pPervasiveParent = NULL; + if( l_tempTargetingParent + && ( l_tempTargetingParent->getAttr<TARGETING::ATTR_TYPE>() + == TARGETING::TYPE_PERV)) + { + Target<TARGET_TYPE_PERV> fapi2_pervTarg(l_tempTargetingParent); + pPervasiveParent = static_cast<TARGETING::Target*>( + fapi2_pervTarg.getParent<TARGET_TYPE_PROC_CHIP>()); + } + + // If the parent of the target under test was NULL, or it was + // not a pervasive, or if the parent of the pervasive was NULL + // or was not the processor, fail the test + if(TARGETING::get_huid(l_nimbusProc) != + TARGETING::get_huid(pPervasiveParent)) + { + TARGETING::ATTR_CHIP_UNIT_type instance = 0; + TARGETING::ATTR_TYPE_type type = TARGETING::TYPE_NA; + pervasiveParentTest.pTarget-> + tryGetAttr<TARGETING::ATTR_CHIP_UNIT>(instance); + pervasiveParentTest.pTarget-> + tryGetAttr<TARGETING::ATTR_TYPE>(type); + + /*@ + * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid fapi2::MOD_FAPI2_PLAT_GET_PARENT_TEST + * @reasoncode fapi2::RC_UNIT_NO_PERV_FOUND + * @userdata1[0:31] Actual PROC HUID + * @userdata1[32:63] Actual PERV HUID + * @userdata2[0:31] Source unit's "chip unit" + * @userdata2[32:63] Source unit's "targeting type" + * @devdesc Could not find the parent PERV of this + * unit target or the pervasive did not + * map to expected PROC + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi2::MOD_FAPI2_PLAT_GET_PARENT_TEST, + fapi2::RC_UNIT_NO_PERV_FOUND, + TWO_UINT32_TO_UINT64( + TO_UINT32( + TARGETING::get_huid(pPervasiveParent)), + TO_UINT32( + TARGETING::get_huid(l_tempTargetingParent))), + TWO_UINT32_TO_UINT64( + TO_UINT32(instance), + TO_UINT32(type)), + true/*SW Error*/); + + errlCommit(l_err,HWPF_COMP_ID); + TS_FAIL("fapi2TargetTest::Unable to find unit's pervasive!"); + numFails++; + } + } + }while(0); FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numTests, numFails); return l_err; diff --git a/src/usr/fapi2/test/fapi2TestUtils.H b/src/usr/fapi2/test/fapi2TestUtils.H index 0a841d6a6..2fafc296b 100644 --- a/src/usr/fapi2/test/fapi2TestUtils.H +++ b/src/usr/fapi2/test/fapi2TestUtils.H @@ -63,6 +63,51 @@ enum{ NUM_TARGETS }; +/** + * @brief Number of children of given type that applicable pervasive has + */ +enum PERVASIVE_CHILDREN { + PERV_EQ_CHILDREN = 1, + PERV_CORE_CHILDREN = 1, + PERV_XBUS_CHILDREN = 2, + PERV_OBUS_CHILDREN = 1, + PERV_CAPP_CHILDREN = 1, + PERV_NV_CHILDREN = 2, + PERV_MCBIST_CHILDREN = 1, + PERV_MCS_CHILDREN = 2, + PERV_MCA_CHILDREN = 4, + PERV_PEC_CHILDREN = 1, + PERV_PEC0_PHB_CHILDREN = 1, + PERV_PEC1_PHB_CHILDREN = 2, + PERV_PEC2_PHB_CHILDREN = 3, +}; + +/** + * @brief Unit ranges for pervasive function + * + * @par Detailed Description: + * Maps pervasive target with chip unit X to one or more unit types. For + * example, a pervasive chip unit of 18 maps to EQ type because + * EQ_LOW <= X <= EQ_HIGH . + */ +enum PERVASIVE_RANGE { + EQ_LOW = 16, + EQ_HIGH = 21, + CORE_LOW = 32, + CORE_HIGH = 55, + XBUS_RANGE = 6, + OBUS_LOW = 9, + OBUS_HIGH = 12, + CAPP0_RANGE = 2, + CAPP1_RANGE = 4, + NV_RANGE = 5, + MC_LOW = 7, + MC_HIGH = 8, + PEC_LOW = 13, + PEC_MID = 14, + PEC_HIGH = 15, +}; + /// /// @brief Generates a list of platform targets of all differnt types. /// This comes in handy when testing out fapi2 target interfaces diff --git a/src/usr/targeting/common/utilFilter.C b/src/usr/targeting/common/utilFilter.C index aeca62ad3..a58a7e585 100644 --- a/src/usr/targeting/common/utilFilter.C +++ b/src/usr/targeting/common/utilFilter.C @@ -388,6 +388,17 @@ void getChildAffinityTargetsByState( TargetService::CHILD_BY_AFFINITY); } +void getPervasiveChildTargetsByState( + TARGETING::TargetHandleList& o_vector, + const Target* i_target, + CLASS i_class, + TYPE i_type, + ResourceState i_state ) + +{ + getAffinityTargets(o_vector, i_target, i_class, i_type, i_state, + TargetService::PERVASIVE_CHILD); +} void getParentAffinityTargetsByState( TARGETING::TargetHandleList& o_vector, @@ -401,6 +412,17 @@ void getParentAffinityTargetsByState( TargetService::PARENT_BY_AFFINITY); } +void getParentPervasiveTargetsByState( + TARGETING::TargetHandleList& o_vector, + const Target* i_target, + CLASS i_class, + TYPE i_type, + ResourceState i_state ) +{ + getAffinityTargets(o_vector, i_target, i_class, i_type, i_state, + TargetService::PARENT_PERVASIVE); +} + const Target * getParentChip( const Target * i_pChiplet ) { |