diff options
Diffstat (limited to 'src/usr/targeting')
-rw-r--r-- | src/usr/targeting/common/util.C | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/usr/targeting/common/util.C b/src/usr/targeting/common/util.C index c8b8c7c5f..a5a9bb7a9 100644 --- a/src/usr/targeting/common/util.C +++ b/src/usr/targeting/common/util.C @@ -38,6 +38,9 @@ #include <targeting/common/utilFilter.H> #include <targeting/common/trace.H> +#define MCA_PER_MCS 2 +#define DIMM_PER_MCA 2 + namespace TARGETING { @@ -281,4 +284,46 @@ uint8_t is_fused_mode( ) } // end is_fused_mode +/** + * @brief Determine if the given dimm target is an NVDIMM + * + * @param[in] i_target : dimm target to check + * + * @return bool - True if the given target is an NVDIMM + */ +bool isNVDIMM( TARGETING::Target * i_target ) +{ + // Not the most elegant way of doing it but the hybrid attributes + // are at the MCS level. Need to find my way up to MCS and check + // if the dimm is hybrid + TARGETING::TargetHandleList l_mcaList; + getParentAffinityTargets(l_mcaList, i_target, TARGETING::CLASS_UNIT, TARGETING::TYPE_MCA); + + if (l_mcaList.size()) + { + TARGETING::TargetHandleList l_mcsList; + getParentAffinityTargets(l_mcsList, l_mcaList[0], TARGETING::CLASS_UNIT, TARGETING::TYPE_MCS); + + if(l_mcsList.size()) + { + // 2-D array. [MCA][DIMM] + TARGETING::ATTR_EFF_HYBRID_type l_hybrid; + TARGETING::ATTR_EFF_HYBRID_MEMORY_TYPE_type l_hybrid_type; + + if( l_mcsList[0]->tryGetAttr<TARGETING::ATTR_EFF_HYBRID>(l_hybrid) && + l_mcsList[0]->tryGetAttr<TARGETING::ATTR_EFF_HYBRID_MEMORY_TYPE>(l_hybrid_type) ) + { + //Using relative position to lookup the hybrid attribute for the current dimm + TARGETING::ATTR_REL_POS_type l_dimm_rel_pos = i_target->getAttr<ATTR_REL_POS>(); + TARGETING::ATTR_REL_POS_type l_mca_rel_pos = l_mcaList[0]->getAttr<ATTR_REL_POS>(); + + return (l_hybrid[l_mca_rel_pos][l_dimm_rel_pos] == TARGETING::EFF_HYBRID_IS_HYBRID && + l_hybrid_type[l_mca_rel_pos][l_dimm_rel_pos] == TARGETING::EFF_HYBRID_MEMORY_TYPE_NVDIMM); + } + } + } + + return false; +} + } // end namespace TARGETING |