summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H5
-rw-r--r--src/include/usr/fapi2/target.H149
-rw-r--r--src/include/usr/targeting/common/predicates/predicateattrval.H4
-rw-r--r--src/usr/fapi2/test/fapi2GetOtherEnd.C215
-rw-r--r--src/usr/fapi2/test/fapi2Test.H18
-rw-r--r--src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml8
6 files changed, 377 insertions, 22 deletions
diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
index c737ca692..730e809f7 100644
--- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
+++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H
@@ -48,6 +48,8 @@ namespace fapi2
MOD_FAPI2_PLAT_GET_PARENT_TEST = 0x05,
MOD_FAPI2_PLAT_GET_CHILDREN_TEST = 0x06,
MOD_FAPI2_VERIFYCFAMACCESSTARGET = 0x07,
+ MOD_FAPI2_PLAT_GET_OTHER_END_TEST = 0x08,
+ MOD_FAPI2_PLAT_GET_OTHER_END = 0x09,
};
/**
@@ -90,6 +92,9 @@ namespace fapi2
RC_SBE_NO_PROC_FOUND = FAPI2_COMP_ID | 0x21,
RC_INVALID_CHILD_COUNT = FAPI2_COMP_ID | 0x22,
RC_UNIT_NO_PERV_FOUND = FAPI2_COMP_ID | 0x23,
+ RC_INCORRECT_OTHER_END = FAPI2_COMP_ID | 0x24,
+ RC_FOUND_TOO_MANY_PEERS = FAPI2_COMP_ID | 0x25,
+ RC_FOUND_NO_PEERS = FAPI2_COMP_ID | 0x26,
// HWP generated errors
RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f,
diff --git a/src/include/usr/fapi2/target.H b/src/include/usr/fapi2/target.H
index 5f21eb3b3..068fe2586 100644
--- a/src/include/usr/fapi2/target.H
+++ b/src/include/usr/fapi2/target.H
@@ -39,15 +39,27 @@
#include <stdio.h>
#include <stdint.h>
#include <vector>
-#include <fapi2_target.H>
#include <target_types.H>
+#include <return_code_defs.H>
+#include <fapi2_target.H>
+
+#include <hwpf_fapi2_reasoncodes.H>
// HB platform support
#include <fapiPlatTrace.H>
#include <targeting/common/target.H>
#include <targeting/common/commontargeting.H>
+#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
+#include <targeting/common/predicates/predicatectm.H>
+#include <targeting/common/predicates/predicateisfunctional.H>
+
+//@TODO RTC:150675 get error info from getOtherEnd fails
+//#include <errl/errlentry.H>
+//#include <errl/errlmanager.H>
+
+
namespace PLAT_TARGET
{
@@ -716,10 +728,10 @@ FAPI_DBG(ENTER_MRK "getChildren. Type 0x%08x State:0x%08x", T, i_state);
///
/// @brief Get the target at the other end of a bus - dimm included
-/// @tparam T The type of the parent
+/// @tparam T The type of the the other end
/// @tparam K The type of target of which this is called
/// @tparam V the type of the target's Value
-/// @param[in] i_state The desired TargetState of the children
+/// @param[in] i_state The desired TargetState of the other end
/// @return Target<T> a target representing the thing on the other end
/// @note Can be easily changed to a vector if needed
///
@@ -728,11 +740,132 @@ template<TargetType T>
inline Target<T>
Target<K, V>::getOtherEnd(const TargetState i_state) const
{
- //@TODO RTC:129517
- // Implementation note: cast to a composite of
- // bus types and the compiler will check if this is
- // a good function at compile time
- return Target<T>();
+ fapi2::Target<T> l_target;
+ this->getOtherEnd<T>( l_target, i_state);
+
+ return l_target;
+
+}
+
+///
+/// @brief Get the target at the other end of a bus
+/// @tparam T The type of the target on the other end
+/// @param[out] o_target A target representing the thing on the other end
+/// @param[in] i_state The desired TargetState of the other end
+/// @return FAPI2_RC_SUCCESS if OK, platforms will return a non-success
+/// ReturnCode in the event of failure
+/// @note o_target is only valid if return is FAPI2_RC_SUCCESS
+///
+template<TargetType K, typename V>
+template<TargetType T>
+inline fapi2::ReturnCodes
+Target<K, V>::getOtherEnd(fapi2::Target<T>& o_target,
+ const TargetState i_state) const
+{
+ ReturnCodes l_rc;
+// errlHndl_t l_errl = NULL;
+ TARGETING::TargetHandleList l_peerTargetList;
+ TARGETING::TYPE requiredPeerType = fapi2::convertFapi2TypeToTargeting(T);
+ TARGETING::CLASS targetClass = TARGETING::CLASS_NA;
+
+ //TODO RTC:148934 add static_asserts for correct types
+ switch(requiredPeerType)
+ {
+ case TARGETING::TYPE_XBUS :
+ targetClass = TARGETING::CLASS_UNIT; break;
+ case TARGETING::TYPE_OBUS :
+ targetClass = TARGETING::CLASS_UNIT; break;
+ case TARGETING::TYPE_DMI :
+ targetClass = TARGETING::CLASS_UNIT; break;
+ case TARGETING::TYPE_DIMM :
+ targetClass = TARGETING::CLASS_LOGICAL_CARD; break;
+ case TARGETING::TYPE_MEMBUF :
+ targetClass = TARGETING::CLASS_CHIP; break;
+ default:
+ break;
+ }
+ TARGETING::PredicateCTM l_peerFilter(targetClass);
+
+ if(i_state == TARGET_STATE_FUNCTIONAL)
+ {
+ TARGETING::PredicateIsFunctional l_funcFilter;
+ TARGETING::PredicatePostfixExpr l_funcAndpeerFilter;
+ l_funcAndpeerFilter.push(&l_peerFilter).push(&l_funcFilter).And();
+ getPeerTargets( l_peerTargetList, // list of targets on other end
+ static_cast<TARGETING::Target*>(this->get()),//To this target
+ NULL/*&l_peerFilter*/, // Don't need to filter peers
+ &l_funcAndpeerFilter);//filter results to be the right class & state
+ }
+ else if(i_state == TARGET_STATE_PRESENT)
+ {
+ TARGETING::PredicatePostfixExpr l_presAndpeerFilter;
+ l_presAndpeerFilter.push(&l_peerFilter);
+
+ getPeerTargets( l_peerTargetList, // list of targets on other end
+ static_cast<TARGETING::Target*>(this->get()), //to this target
+ NULL, //No need to filter peers
+ &l_presAndpeerFilter);//filter results to be the right class & state
+ }
+
+ fapi2::Target<T> fapi2_peerTarget = NULL;
+
+ if(l_peerTargetList.size() == 0)
+ {
+ l_rc = FAPI2_RC_FALSE;
+ //@TODO RTC:150675 get error info from getOtherEnd fails
+#if 0
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END
+ * @reasoncode fapi2::RC_FOUND_NO_PEERS
+ * @userdata1[0:31] Unused
+ * @userdata1[32:63] Unused
+ * @userdata2 Unused
+ * @devdesc Unable to resolve other end of xbus
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_PLAT_GET_OTHER_END,
+ fapi2::RC_FOUND_NO_PEERS,
+ NULL,
+ NULL,
+ true/*SW Error*/);
+ errlCommit(l_errl,FAPI2_COMP_ID);
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
+#endif
+ }
+ else if(l_peerTargetList.size() > 1)
+ {
+ l_rc = FAPI2_RC_FALSE;
+ //@TODO RTC:150675 get error info from getOtherEnd fails
+#if 0
+ /*@
+ * @errortype ERRORLOG::ERRL_SEV_UNRECOVERABLE
+ * @moduleid fapi2::MOD_FAPI2_PLAT_GET_OTHER_END
+ * @reasoncode fapi2::RC_FOUND_TOO_MANY_PEERS
+ * @userdata1[0:31] Unused
+ * @userdata1[32:63] Unused
+ * @userdata2 Unused
+ * @devdesc Unable to resolve other end of xbus
+ */
+ l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_PLAT_GET_OTHER_END,
+ fapi2::RC_FOUND_TOO_MANY_PEERS,
+ NULL,
+ NULL,
+ true/*SW Error*/);
+ errlCommit(l_errl,FAPI2_COMP_ID);
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_err));
+#endif
+ }
+ else
+ {
+ fapi2_peerTarget = fapi2::Target<T>(l_peerTargetList[0]);
+ }
+ o_target = fapi2_peerTarget;
+
+ return l_rc;
}
diff --git a/src/include/usr/targeting/common/predicates/predicateattrval.H b/src/include/usr/targeting/common/predicates/predicateattrval.H
index 20585763e..2fecadc82 100644
--- a/src/include/usr/targeting/common/predicates/predicateattrval.H
+++ b/src/include/usr/targeting/common/predicates/predicateattrval.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2013,2014 */
+/* Contributors Listed Below - COPYRIGHT 2013,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -85,7 +85,7 @@ class PredicateAttrVal : public PredicateBase
* Assuming the attribute is present, this determines what check
* needs to be performed on i_value.
* If false (default), the predicate registers a match when the
- * attribute's value is i_value; If false, the predicate registers
+ * attribute's value is i_value; If true, the predicate registers
* a match when the attribute's value is != i_value
*/
PredicateAttrVal(
diff --git a/src/usr/fapi2/test/fapi2GetOtherEnd.C b/src/usr/fapi2/test/fapi2GetOtherEnd.C
new file mode 100644
index 000000000..193e13b31
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2GetOtherEnd.C
@@ -0,0 +1,215 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2GetOtherEnd.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* [+] 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. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <fapi2.H>
+#include <hwpf_fapi2_reasoncodes.H>
+#include <fapi2TestUtils.H>
+#include <cxxtest/TestSuite.H>
+#include <targeting/common/target.H>
+#include <targeting/common/util.H>
+
+
+namespace fapi2
+{
+
+
+//******************************************************************************
+// fapi2GetOtherEnd
+//******************************************************************************
+errlHndl_t fapi2GetOtherEnd()
+{
+ int numTests = 0;
+ int numFails = 0;
+ errlHndl_t l_errl = NULL;
+
+ do
+ {
+ // Create a vector of TARGETING::Target pointers
+ TARGETING::TargetHandleList chipListNonFunct;
+
+ // Get a list of all of the xbus chips present
+ TARGETING::getAllChiplets(chipListNonFunct,
+ TARGETING::TYPE_XBUS, false);
+ TARGETING::Target * l_peerTarget;
+ fapi2::Target<fapi2::TARGET_TYPE_XBUS> fapi2_xbusTargetPeer;
+ for(uint32_t i = 0; i < chipListNonFunct.size(); i++)
+ {
+ chipListNonFunct[i]->
+ tryGetAttr<TARGETING::ATTR_PEER_TARGET>(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTargetPeerPlatform(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTarget(chipListNonFunct[i]);
+ if(l_peerTarget != NULL)
+ {
+ numTests++;
+ if(fapi2_xbusTarget.getOtherEnd<TARGET_TYPE_XBUS>(fapi2_xbusTargetPeer,TARGET_STATE_PRESENT) == FAPI2_RC_SUCCESS)
+ {
+ if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer)
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast<TARGETING::Target*>(fapi2_xbusTargetPeer)));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", chipListNonFunct[i]);
+ }
+ }
+
+
+ for(uint32_t i = 0; i < chipListNonFunct.size(); i++)
+ {
+ chipListNonFunct[i]->
+ tryGetAttr<TARGETING::ATTR_PEER_TARGET>(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTargetPeerPlatform(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTarget(chipListNonFunct[i]);
+ if(l_peerTarget != NULL)
+ {
+ numTests++;
+ fapi2_xbusTargetPeer = fapi2_xbusTarget.getOtherEnd<TARGET_TYPE_XBUS>(TARGET_STATE_PRESENT);
+ if(fapi2_xbusTargetPeer)
+ {
+ if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer)
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast<TARGETING::Target*>(fapi2_xbusTargetPeer)));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", chipListNonFunct[i]);
+ }
+ }
+
+ // Create a vector of TARGETING::Target pointers
+ TARGETING::TargetHandleList chipListFunct;
+
+ // Get a list of all of the xbus chips that are functional
+ TARGETING::getAllChiplets(chipListFunct, TARGETING::TYPE_XBUS, true);
+
+ //NOTE: This Part of the test will fail if a certain target A's
+ // PEER_TARGET attr doesn't point to target B that
+ // has a PEER_TARGET that points back to target A
+ // So basically:
+ // A.PEER_TARGET MUST EQUAL B
+ // B.PEER_TARGET MUST EQUAL A
+
+ FAPI_ERR("list of functional targets is size %d " , chipListFunct.size());
+ for(uint32_t i = 0; i < chipListFunct.size(); i++)
+ {
+ chipListFunct[i]->tryGetAttr<TARGETING::ATTR_PEER_TARGET>(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTargetPeerPlatform(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTarget(chipListFunct[i]);
+
+ if(l_peerTarget != NULL)
+ {
+ numTests++;
+ if(fapi2_xbusTarget.getOtherEnd<TARGET_TYPE_XBUS>(fapi2_xbusTargetPeer,TARGET_STATE_FUNCTIONAL) == FAPI2_RC_SUCCESS)
+ {
+ if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer)
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast<TARGETING::Target*>(fapi2_xbusTargetPeer)));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", TARGETING::get_huid(chipListFunct[i]));
+ }
+ }
+
+ for(uint32_t i = 0; i < chipListFunct.size(); i++)
+ {
+ chipListFunct[i]->tryGetAttr<TARGETING::ATTR_PEER_TARGET>(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTargetPeerPlatform(l_peerTarget);
+ const fapi2::Target<fapi2::TARGET_TYPE_XBUS>
+ fapi2_xbusTarget(chipListFunct[i]);
+
+ if(l_peerTarget != NULL)
+ {
+ numTests++;
+ fapi2_xbusTargetPeer = fapi2_xbusTarget.getOtherEnd<TARGET_TYPE_XBUS>(TARGET_STATE_FUNCTIONAL);
+ if(fapi2_xbusTargetPeer)
+ {
+ if(fapi2_xbusTargetPeerPlatform != fapi2_xbusTargetPeer)
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned the incorrect target! expected %x, instead got %x ", TARGETING::get_huid(l_peerTarget), TARGETING::get_huid(static_cast<TARGETING::Target*>(fapi2_xbusTargetPeer)));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ TS_FAIL("fapiGetOtherEnd:: getOtherEnd returned failed to return a target although it should have returned %x", TARGETING::get_huid(l_peerTarget));
+ numFails++;
+ break;
+ }
+ }
+ else
+ {
+ FAPI_ERR("fapiGetOtherEnd:: WARNING ! Target with HUID: %x has an unreachable peer target", TARGETING::get_huid(chipListFunct[i]));
+ }
+ }
+
+ FAPI_INF("fapi2TargetTest:: Test Complete. %d/%d fails", numFails, numTests);
+
+ }while(0);
+
+ return l_errl;
+}
+
+} \ No newline at end of file
diff --git a/src/usr/fapi2/test/fapi2Test.H b/src/usr/fapi2/test/fapi2Test.H
index 366921dbb..00a9bac46 100644
--- a/src/usr/fapi2/test/fapi2Test.H
+++ b/src/usr/fapi2/test/fapi2Test.H
@@ -47,6 +47,7 @@
#include "fapi2GetParentTest.C"
#include "fapi2HwpTest.C"
#include "fapi2GetChildrenTest.C"
+#include "fapi2GetOtherEnd.C"
using namespace fapi2;
@@ -63,21 +64,22 @@ void test_fapi2Test(void)
{
FAPI_INF(">>>>>>test_fapi2Test starting...");
- FAPI_INF(">>test_fapi2HwpTest starting...");
+ FAPI_INF(">>fapi2HwpTest starting...");
fapi2HwpTest();
- FAPI_INF("<<test_fapi2HwpTest exiting...");
+ FAPI_INF("<<fapi2HwpTest exiting...");
- FAPI_INF(">>test_fapi2GetChildrenTest starting...");
+ FAPI_INF(">>fapi2GetChildren starting...");
fapi2GetChildrenTest();
- FAPI_INF("<<test_fapi2ChildTest exiting...");
+ FAPI_INF("<<fapi2GetChildren exiting...");
- FAPI_INF(">>fapi2TargetTest::testFapi2GetParent starting...");
+ FAPI_INF(">>fapi2GetParent starting...");
fapi2GetParentTest();
- FAPI_INF("<<FAPI2: testFapi2GetParent exiting...");
+ FAPI_INF("<<fapi2GetParent exiting...");
- FAPI_INF("<<<<<<test_fapi2Test exiting...");
+ FAPI_INF(">>fapi2GetOtherEnd starting...");
+ fapi2GetOtherEnd();
+ FAPI_INF(">>fapi2GetOtherEnd exiting...");
}
-
};
#endif \ No newline at end of file
diff --git a/src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml b/src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml
index d5d50cfd2..e3b2c1099 100644
--- a/src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml
+++ b/src/usr/targeting/common/xmltohb/simics_NIMBUS.system.xml
@@ -4048,10 +4048,10 @@
<id>CHIP_UNIT</id>
<default>1</default>
</attribute>
-<!-- <attribute> // @FIXME RTC 127337
+ <attribute>
<id>PEER_TARGET</id>
<default>physical:sys-0/node-0/proc-1/xbus-1</default>
- </attribute> // @FIXME RTC 127337 -->
+ </attribute>
<attribute>
<id>PARENT_PERVASIVE</id>
<default>physical:sys-0/node-0/proc-0/perv-6</default>
@@ -4085,10 +4085,10 @@
<id>CHIP_UNIT</id>
<default>2</default>
</attribute>
-<!-- <attribute> // @FIXME RTC 127337
+ <attribute>
<id>PEER_TARGET</id>
<default>physical:sys-0/node-0/proc-2/xbus-1</default>
- </attribute> // @FIXME RTC 127337 -->
+ </attribute>
<attribute>
<id>PARENT_PERVASIVE</id>
<default>physical:sys-0/node-0/proc-0/perv-6</default>
OpenPOWER on IntegriCloud