diff options
author | Mike Jones <mjjones@us.ibm.com> | 2013-01-23 15:20:16 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-01-24 10:02:54 -0600 |
commit | 3a493afceefd273807642a64d0992f4d96569739 (patch) | |
tree | 74882258b2a72e3790bf77031dd6bd9d8de57036 | |
parent | 10040185a64e19a75145962e4490ec30a7061aea (diff) | |
download | talos-hostboot-3a493afceefd273807642a64d0992f4d96569739.tar.gz talos-hostboot-3a493afceefd273807642a64d0992f4d96569739.zip |
HWPF: Correctly check requested state in FAPI System Config Query Functions
The TODOs in the code to correctly return targets of the specified state
have been done. Also targeting utilFilter interfaces have been used
where possible to query targets
Change-Id: I52f56ab6482bd2e6f1ddcf6a7fa24f6ca9c25103
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/3006
Tested-by: Jenkins Server
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatSystemConfig.C | 289 |
1 files changed, 141 insertions, 148 deletions
diff --git a/src/usr/hwpf/plat/fapiPlatSystemConfig.C b/src/usr/hwpf/plat/fapiPlatSystemConfig.C index 5ba76f620..220c6ba88 100644 --- a/src/usr/hwpf/plat/fapiPlatSystemConfig.C +++ b/src/usr/hwpf/plat/fapiPlatSystemConfig.C @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/hwpf/plat/fapiPlatSystemConfig.C $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/plat/fapiPlatSystemConfig.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ /** * @file fapiPlatSystemConfig.C * @@ -32,6 +32,7 @@ #include <fapiSystemConfig.H> #include <fapiPlatReasonCodes.H> #include <errl/errlentry.H> +#include <targeting/common/utilFilter.H> #include <targeting/common/targetservice.H> #include <targeting/common/predicates/predicatectm.H> @@ -47,23 +48,17 @@ fapi::ReturnCode fapiGetChildChiplets( std::vector<fapi::Target> & o_chiplets, const fapi::TargetState i_state) { - // TODO. Need to support i_state - FAPI_INF(ENTER_MRK "fapiGetChildChiplets. Chiplet Type: 0x%x. State: 0x%x", i_chipletType, i_state); fapi::ReturnCode l_rc; o_chiplets.clear(); - // Create a Class/Type/Model predicate to look for units - TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_UNIT); - // Check that the input target is a chip if (!i_chip.isChip()) { FAPI_ERR("fapiGetChildChiplets. Input target type 0x%x is not a chip", i_chip.getType()); - /*@ * @errortype * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS @@ -82,32 +77,32 @@ fapi::ReturnCode fapiGetChildChiplets( } else { - // Update the predicate to look for the specified type + TARGETING::TYPE l_type = TARGETING::TYPE_NA; + if (i_chipletType == fapi::TARGET_TYPE_EX_CHIPLET) { - l_predicate.setType(TARGETING::TYPE_EX); + l_type = TARGETING::TYPE_EX; } else if (i_chipletType == fapi::TARGET_TYPE_MBA_CHIPLET) { - l_predicate.setType(TARGETING::TYPE_MBA); + l_type = TARGETING::TYPE_MBA; } else if (i_chipletType == fapi::TARGET_TYPE_MCS_CHIPLET) { - l_predicate.setType(TARGETING::TYPE_MCS); + l_type = TARGETING::TYPE_MCS; } else if (i_chipletType == fapi::TARGET_TYPE_XBUS_ENDPOINT) { - l_predicate.setType(TARGETING::TYPE_XBUS); + l_type = TARGETING::TYPE_XBUS; } else if (i_chipletType == fapi::TARGET_TYPE_ABUS_ENDPOINT) { - l_predicate.setType(TARGETING::TYPE_ABUS); + l_type = TARGETING::TYPE_ABUS; } else { FAPI_ERR("fapiGetChildChiplets. Chiplet type 0x%x not supported", i_chipletType); - /*@ * @errortype * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS @@ -125,54 +120,61 @@ fapi::ReturnCode fapiGetChildChiplets( // Attach the error log to the fapi::ReturnCode l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); } - } - do - { - if (l_rc) + if (!l_rc) { - break; - } + // Extract the HostBoot Target pointer for the input chip + TARGETING::Target * l_pChip = + reinterpret_cast<TARGETING::Target*>(i_chip.get()); - // Extract the HostBoot Target pointer for the input chip - TARGETING::Target * l_pChip = - reinterpret_cast<TARGETING::Target*>(i_chip.get()); - - if (l_pChip == NULL) - { - /*@ - * @errortype - * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS - * @reasoncode RC_EMBEDDED_NULL_TARGET_PTR - * @devdesc fapi target has embedded null target pointer - */ - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_CHILD_CHIPLETS, - fapi::RC_EMBEDDED_NULL_TARGET_PTR); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - // Create a vector of TARGETING::Target pointers - TARGETING::TargetHandleList l_chipletList; - - // Get children chiplets - TARGETING::targetService(). - getAssociated(l_chipletList, l_pChip, - TARGETING::TargetService::CHILD, - TARGETING::TargetService::ALL, &l_predicate); - - // Return fapi::Targets to the caller - for (uint32_t i = 0; i < l_chipletList.size(); i++) - { - fapi::Target l_chiplet(i_chipletType, - reinterpret_cast<void *>(l_chipletList[i])); - o_chiplets.push_back(l_chiplet); + if (l_pChip == NULL) + { + FAPI_ERR("fapiGetChildChiplets. Embedded NULL target pointer"); + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_CHILD_CHIPLETS + * @reasoncode RC_EMBEDDED_NULL_TARGET_PTR + * @devdesc fapi target has embedded null target pointer + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_CHILD_CHIPLETS, + fapi::RC_EMBEDDED_NULL_TARGET_PTR); + + // Attach the error log to the fapi::ReturnCode + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); + } + else + { + TARGETING::TargetHandleList l_chipletList; + + TARGETING::getChildChiplets(l_chipletList, l_pChip, l_type, + false); + + // Return fapi::Targets to the caller + for (uint32_t i = 0; i < l_chipletList.size(); i++) + { + TARGETING::HwasState l_state = + l_chipletList[i]->getAttr<TARGETING::ATTR_HWAS_STATE>(); + + if ((fapi::TARGET_STATE_PRESENT == i_state) && + !l_state.present) + { + continue; + } + if ((fapi::TARGET_STATE_FUNCTIONAL == i_state) && + !l_state.functional) + { + continue; + } + + fapi::Target l_chiplet(i_chipletType, + reinterpret_cast<void *>(l_chipletList[i])); + o_chiplets.push_back(l_chiplet); + } + } } - } while(0); + } FAPI_INF(EXIT_MRK "fapiGetChildChiplets. %d results", o_chiplets.size()); return l_rc; @@ -186,26 +188,18 @@ fapi::ReturnCode fapiGetAssociatedDimms( std::vector<fapi::Target> & o_dimms, const fapi::TargetState i_state) { - // TODO. Need to support i_state - FAPI_INF(ENTER_MRK "fapiGetAssociatedDimms. State: 0x%x", i_state); fapi::ReturnCode l_rc; o_dimms.clear(); - // Create a Class/Type/Model predicate to look for dimm cards - TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_LOGICAL_CARD, - TARGETING::TYPE_DIMM); - // Extract the HostBoot Target pointer for the input target TARGETING::Target * l_pTarget = reinterpret_cast<TARGETING::Target*>(i_target.get()); - // Create a vector of TARGETING::Target pointers - TARGETING::TargetHandleList l_dimmList; - if (l_pTarget == NULL) { + FAPI_ERR("fapiGetAssociatedDimms. Embedded NULL target pointer"); /*@ * @errortype * @moduleid MOD_FAPI_GET_ASSOCIATE_DIMMS @@ -223,18 +217,35 @@ fapi::ReturnCode fapiGetAssociatedDimms( else { // Get associated dimms + TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_LOGICAL_CARD, + TARGETING::TYPE_DIMM); + TARGETING::TargetHandleList l_dimmList; + TARGETING::targetService(). getAssociated(l_dimmList, l_pTarget, TARGETING::TargetService::CHILD_BY_AFFINITY, TARGETING::TargetService::ALL, &l_predicate); - } - // Return fapi::Targets to the caller - for (uint32_t i = 0; i < l_dimmList.size(); i++) - { - fapi::Target l_dimm(fapi::TARGET_TYPE_DIMM, - reinterpret_cast<void *>(l_dimmList[i])); - o_dimms.push_back(l_dimm); + // Return fapi::Targets to the caller + for (uint32_t i = 0; i < l_dimmList.size(); i++) + { + TARGETING::HwasState l_state = + l_dimmList[i]->getAttr<TARGETING::ATTR_HWAS_STATE>(); + + if ((fapi::TARGET_STATE_PRESENT == i_state) && !l_state.present) + { + continue; + } + if ((fapi::TARGET_STATE_FUNCTIONAL == i_state) && + !l_state.functional) + { + continue; + } + + fapi::Target l_dimm(fapi::TARGET_TYPE_DIMM, + reinterpret_cast<void *>(l_dimmList[i])); + o_dimms.push_back(l_dimm); + } } FAPI_INF(EXIT_MRK "fapiGetAssociatedDimms. %d results", o_dimms.size()); @@ -274,18 +285,8 @@ fapi::ReturnCode fapiGetParentChip( // Attach the error log to the fapi::ReturnCode l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); } - - do + else { - - if (l_rc) - { - break; - } - - // Create a Class/Type/Model predicate to look for chips - TARGETING::PredicateCTM l_predicate(TARGETING::CLASS_CHIP); - // Extract the HostBoot Target pointer for the input chiplet TARGETING::Target * l_pChiplet = reinterpret_cast<TARGETING::Target*>(i_chiplet.get()); @@ -305,57 +306,49 @@ fapi::ReturnCode fapiGetParentChip( // Attach the error log to the fapi::ReturnCode l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); - break; - } - - // Create a vector of TARGETING::Target pointers - TARGETING::TargetHandleList l_chipList; - - // Get parent - TARGETING::targetService(). - getAssociated(l_chipList, l_pChiplet, - TARGETING::TargetService::PARENT, - TARGETING::TargetService::ALL, &l_predicate); - - if (l_chipList.size() != 1) - { - // One parent chip was not found - FAPI_ERR("fapiGetParentChip. Number of parents found is %d", - l_chipList.size()); - - /*@ - * @errortype - * @moduleid MOD_FAPI_GET_PARENT_CHIP - * @reasoncode RC_NO_SINGLE_PARENT - * @userdata1 Number of parents found - * @devdesc fapiGetParentChip request did not find one parent - */ - errlHndl_t l_pError = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - fapi::MOD_FAPI_GET_PARENT_CHIP, - fapi::RC_NO_SINGLE_PARENT, - l_chipList.size()); - - // Attach the error log to the fapi::ReturnCode - l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); } else { - // Set the output chip type - if (l_chipList[0]->getAttr<TARGETING::ATTR_TYPE>() == - TARGETING::TYPE_PROC) + const TARGETING::Target * l_pChip = + TARGETING::getParentChip(l_pChiplet); + + if (l_pChip == NULL) { - o_chip.setType(fapi::TARGET_TYPE_PROC_CHIP); + // One parent chip was not found + FAPI_ERR("fapiGetParentChip. Parent not found"); + /*@ + * @errortype + * @moduleid MOD_FAPI_GET_PARENT_CHIP + * @reasoncode RC_NO_SINGLE_PARENT + * @devdesc fapiGetParentChip request did not find one parent + */ + errlHndl_t l_pError = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + fapi::MOD_FAPI_GET_PARENT_CHIP, + fapi::RC_NO_SINGLE_PARENT); + + // Attach the error log to the fapi::ReturnCode + l_rc.setPlatError(reinterpret_cast<void *> (l_pError)); } else { - o_chip.setType(fapi::TARGET_TYPE_MEMBUF_CHIP); + // Set the output chip type + if (l_pChip->getAttr<TARGETING::ATTR_TYPE>() == + TARGETING::TYPE_PROC) + { + o_chip.setType(fapi::TARGET_TYPE_PROC_CHIP); + } + else + { + o_chip.setType(fapi::TARGET_TYPE_MEMBUF_CHIP); + } + + // Set the output chip (platform specific) handle + o_chip.set(reinterpret_cast<void *> + (const_cast<TARGETING::Target*>(l_pChip))); } - - // Set the output chip (platform specific) handle - o_chip.set(reinterpret_cast<void *>(l_chipList[0])); } - } while(0); + } FAPI_INF(EXIT_MRK "fapiGetParentChip"); return l_rc; |