From 06ed7403d044d8a0776440019ec8e893dd7661ae Mon Sep 17 00:00:00 2001 From: Andre Marin Date: Wed, 17 Jul 2019 23:42:23 -0400 Subject: Move find_magic from generic to Nimbus subdir path Change-Id: Ie963953758cc178432e096057240d7ab5c82d7ac Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/80595 Tested-by: FSP CI Jenkins Tested-by: Jenkins Server Reviewed-by: Louis Stermole Reviewed-by: Mark Pizzutillo Tested-by: Hostboot CI Reviewed-by: Jennifer A Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/80935 Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Christian R Geddes --- .../chips/p9/procedures/hwp/memory/lib/fir/check.C | 2 +- .../p9/procedures/hwp/memory/lib/fir/unmask.C | 2 +- .../p9/procedures/hwp/memory/lib/mcbist/memdiags.C | 3 +- .../p9/procedures/hwp/memory/lib/phy/ddr_phy.C | 2 +- .../chips/p9/procedures/hwp/memory/lib/phy/dp16.C | 2 +- .../procedures/hwp/memory/lib/utils/find_magic.H | 140 ++++++++++++++++++ .../p9/procedures/hwp/memory/p9_mss_scominit.C | 2 +- src/import/generic/memory/lib/utils/find_magic.H | 164 --------------------- .../memory/lib/utils/mcbist/gen_mss_memdiags.H | 24 ++- 9 files changed, 169 insertions(+), 172 deletions(-) create mode 100644 src/import/chips/p9/procedures/hwp/memory/lib/utils/find_magic.H delete mode 100644 src/import/generic/memory/lib/utils/find_magic.H (limited to 'src/import') diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/fir/check.C b/src/import/chips/p9/procedures/hwp/memory/lib/fir/check.C index de7b6003b..df352f489 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/fir/check.C +++ b/src/import/chips/p9/procedures/hwp/memory/lib/fir/check.C @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/fir/unmask.C b/src/import/chips/p9/procedures/hwp/memory/lib/fir/unmask.C index 800291aea..10a5ef4d3 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/fir/unmask.C +++ b/src/import/chips/p9/procedures/hwp/memory/lib/fir/unmask.C @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/mcbist/memdiags.C b/src/import/chips/p9/procedures/hwp/memory/lib/mcbist/memdiags.C index 682226cfd..2f8b88b4c 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/mcbist/memdiags.C +++ b/src/import/chips/p9/procedures/hwp/memory/lib/mcbist/memdiags.C @@ -38,7 +38,6 @@ #include #include -#include #include #include #include @@ -305,7 +304,7 @@ fapi2::ReturnCode operation::multi_port_init_internal() "Start address %d larger than end address %d for %s", l_portdimm_start_address, l_portdimm_end_address, mss::c_str(iv_target)); - // Determine which ports are functional and whether we can broadcast to them +// Determine which ports are functional and whether we can broadcast to them // If we're in broadcast mode, PRD sends DIMM 0/1 of the first functional and configured port, // and we then run all ports in parallel (ports set in subtest config) if( mss::mcbist::is_broadcast_capable(iv_target) == mss::YES ) diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/phy/ddr_phy.C b/src/import/chips/p9/procedures/hwp/memory/lib/phy/ddr_phy.C index 5aba2807e..a799a5c16 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/phy/ddr_phy.C +++ b/src/import/chips/p9/procedures/hwp/memory/lib/phy/ddr_phy.C @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/phy/dp16.C b/src/import/chips/p9/procedures/hwp/memory/lib/phy/dp16.C index de647a577..81b8114ff 100644 --- a/src/import/chips/p9/procedures/hwp/memory/lib/phy/dp16.C +++ b/src/import/chips/p9/procedures/hwp/memory/lib/phy/dp16.C @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/import/chips/p9/procedures/hwp/memory/lib/utils/find_magic.H b/src/import/chips/p9/procedures/hwp/memory/lib/utils/find_magic.H new file mode 100644 index 000000000..3c8a385c4 --- /dev/null +++ b/src/import/chips/p9/procedures/hwp/memory/lib/utils/find_magic.H @@ -0,0 +1,140 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/import/chips/p9/procedures/hwp/memory/lib/utils/find_magic.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ + +#ifndef _MSS_FIND_WITH_MAGIC_H +#define _MSS_FIND_WITH_MAGIC_H + +#include +#include +#include +#include +#include + +namespace mss +{ + +/// +/// @brief find the union of functionl targets and any magic targets +/// @note The PHY has a logic block which is only contained in the 0th PHY in the controller. +/// This makes the 0th PHY 'magic' in that it needs to always be present if not functional. +/// This function returns all functional targets and includes the magic target whether or not +/// it is truly functional. +/// @tparam M the target type to be returned +/// @tparam T the fapi2 target type of the argument +/// @param[in] i_target the fapi2 target T +/// @return a vector of M targets. +/// +template< fapi2::TargetType M, fapi2::TargetType T > +inline std::vector< fapi2::Target > find_targets_with_magic( const fapi2::Target& i_target); + +/// +/// @brief find a set of magic elements based on a fapi2 target +/// @note The PHY has a logic block which is only contained in the 0th PHY in the controller. +/// This makes the 0th PHY 'magic' in that it needs to always be present if not functional. +/// This function returns all magic targets whether or not it is truly functional. +/// It does not include other functional or present targets. +/// @tparam M the target type to be returned +/// @tparam T the fapi2 target type of the argument +/// @param[in] i_target the fapi2 target T +/// @return a vector of M targets. +/// +template< fapi2::TargetType M, fapi2::TargetType T > +inline std::vector< fapi2::Target > find_magic_targets( const fapi2::Target& i_target); + +/// +/// @brief find the magic MCA connected to an MCBIST +/// @param[in] i_target the fapi2::Target MCBIST +/// @return a vector of fapi2::TARGET_TYPE_MCA +/// +template<> +inline std::vector< fapi2::Target > +find_magic_targets(const fapi2::Target& i_target) +{ + // The magic port is in position 0, relative to the MCBIST + constexpr uint64_t RELATIVE_MAGIC_POS = 0; + + // This is only one magic MCA on every MCBIST, so we only return a vector of one + std::vector> l_magic_ports; + + // Get all the present MCA children and find the target with the relative position of 0 + for (const auto& p : i_target.getChildren(fapi2::TARGET_STATE_PRESENT)) + { + if (mss::relative_pos(p) == RELATIVE_MAGIC_POS) + { + l_magic_ports.push_back(p); + } + } + + // We don't care if the vector is empty. We don't know what the caller will do with this + // and they might not care if there is no magic port either ... + return l_magic_ports; +} + +/// +/// @brief find the union of functionl targets and any magic targets +/// @param[in] i_target the fapi2::Target MCBIST +/// @return a vector of i2::Target +/// +template<> +inline std::vector< fapi2::Target > +find_targets_with_magic( const fapi2::Target& i_target) +{ + // We need the union of the functional target list and the magic target list. We can + // get a little tricky with the MCA's - we know there's only one magic port. + // So if the one magic port isn't in the list of functional ports, add it + auto l_magic_ports = find_magic_targets(i_target); + + if (l_magic_ports.size() != 1) + { + FAPI_ERR("Found wrong number of magic ports on %s (%d)", mss::c_str(i_target), l_magic_ports.size()); + fapi2::Assert(false); + } + + auto l_ports = mss::find_targets(i_target); + const auto l_magic_pos = mss::relative_pos(l_magic_ports[0]); + const auto l_magic_port = std::find_if(l_ports.begin(), l_ports.end(), + [&l_magic_pos](const fapi2::Target& t) + { + // Check ports by relative position. + const auto l_pos = mss::relative_pos(t); + FAPI_DBG("checking for magic port at %d candidate is %d", l_magic_pos, l_pos); + return l_magic_pos == l_pos; + }); + + if (l_magic_port == l_ports.end()) + { + // Add the magic port to the front of the port vector. + FAPI_DBG("inserting magic port %d", l_magic_pos); + l_ports.insert(l_ports.begin(), l_magic_ports[0]); + } + + // In either case, l_ports is the proper thing to return. Either the magic port was in + // l_ports or it is now because we inserted it. + return l_ports; +} + +}// mss + +#endif diff --git a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C index d2f58b0bc..1980f2374 100644 --- a/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C +++ b/src/import/chips/p9/procedures/hwp/memory/p9_mss_scominit.C @@ -44,7 +44,7 @@ #include #include #include -#include +#include using fapi2::TARGET_TYPE_MCA; using fapi2::TARGET_TYPE_MCBIST; diff --git a/src/import/generic/memory/lib/utils/find_magic.H b/src/import/generic/memory/lib/utils/find_magic.H deleted file mode 100644 index a67d4f2e8..000000000 --- a/src/import/generic/memory/lib/utils/find_magic.H +++ /dev/null @@ -1,164 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/import/generic/memory/lib/utils/find_magic.H $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2019 */ -/* [+] 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 */ - -#ifndef _MSS_FIND_WITH_MAGIC_H -#define _MSS_FIND_WITH_MAGIC_H - -#include -#include -#include -#include -#include - -namespace mss -{ - -/// -/// @brief find the union of functionl targets and any magic targets -/// @note The PHY has a logic block which is only contained in the 0th PHY in the controller. -/// This makes the 0th PHY 'magic' in that it needs to always be present if not functional. -/// This function returns all functional targets and includes the magic target whether or not -/// it is truly functional. -/// @tparam M the target type to be returned -/// @tparam T the fapi2 target type of the argument -/// @param[in] i_target the fapi2 target T -/// @return a vector of M targets. -/// -template< fapi2::TargetType M, fapi2::TargetType T > -inline std::vector< fapi2::Target > find_targets_with_magic( const fapi2::Target& i_target); - -/// -/// @brief find a set of magic elements based on a fapi2 target -/// @note The PHY has a logic block which is only contained in the 0th PHY in the controller. -/// This makes the 0th PHY 'magic' in that it needs to always be present if not functional. -/// This function returns all magic targets whether or not it is truly functional. -/// It does not include other functional or present targets. -/// @tparam M the target type to be returned -/// @tparam T the fapi2 target type of the argument -/// @param[in] i_target the fapi2 target T -/// @return a vector of M targets. -/// -template< fapi2::TargetType M, fapi2::TargetType T > -inline std::vector< fapi2::Target > find_magic_targets( const fapi2::Target& i_target); - -/// -/// @brief find the magic MCA connected to an MCBIST -/// @param[in] i_target the fapi2::Target MCBIST -/// @return a vector of fapi2::TARGET_TYPE_MCA -/// -template<> -inline std::vector< fapi2::Target > -find_magic_targets(const fapi2::Target& i_target) -{ - // The magic port is in position 0, relative to the MCBIST - constexpr uint64_t RELATIVE_MAGIC_POS = 0; - - // This is only one magic MCA on every MCBIST, so we only return a vector of one - std::vector> l_magic_ports; - - // Get all the present MCA children and find the target with the relative position of 0 - for (const auto& p : i_target.getChildren(fapi2::TARGET_STATE_PRESENT)) - { - if (mss::relative_pos(p) == RELATIVE_MAGIC_POS) - { - l_magic_ports.push_back(p); - } - } - - // We don't care if the vector is empty. We don't know what the caller will do with this - // and they might not care if there is no magic port either ... - return l_magic_ports; -} - -/// -/// @brief find the union of functionl targets and any magic targets -/// @param[in] i_target the fapi2::Target MCBIST -/// @return a vector of i2::Target -/// -template<> -inline std::vector< fapi2::Target > -find_targets_with_magic( const fapi2::Target& i_target) -{ - // We need the union of the functional target list and the magic target list. We can - // get a little tricky with the MCA's - we know there's only one magic port. - // So if the one magic port isn't in the list of functional ports, add it - auto l_magic_ports = find_magic_targets(i_target); - - if (l_magic_ports.size() != 1) - { - FAPI_ERR("Found wrong number of magic ports on %s (%d)", mss::c_str(i_target), l_magic_ports.size()); - fapi2::Assert(false); - } - - auto l_ports = mss::find_targets(i_target); - const auto l_magic_pos = mss::relative_pos(l_magic_ports[0]); - const auto l_magic_port = std::find_if(l_ports.begin(), l_ports.end(), - [&l_magic_pos](const fapi2::Target& t) - { - // Check ports by relative position. - const auto l_pos = mss::relative_pos(t); - FAPI_DBG("checking for magic port at %d candidate is %d", l_magic_pos, l_pos); - return l_magic_pos == l_pos; - }); - - if (l_magic_port == l_ports.end()) - { - // Add the magic port to the front of the port vector. - FAPI_DBG("inserting magic port %d", l_magic_pos); - l_ports.insert(l_ports.begin(), l_magic_ports[0]); - } - - // In either case, l_ports is the proper thing to return. Either the magic port was in - // l_ports or it is now because we inserted it. - return l_ports; -} - -/// -/// @brief Determine if a thing is functional -/// @tparam I, the type of the item we want to check for -/// @tparam P, the type of the parent which holds the things of interest -/// @param[in] i_target the parent containing the thing we're looking for -/// @param[in] i_rel_pos the relative position of the item of interest. -/// @return bool true iff the thing at i_rel_pos is noted as functional -/// -template< fapi2::TargetType I, fapi2::TargetType P > -bool is_functional( const fapi2::Target

& i_target, const uint64_t i_rel_pos ) -{ - // Not sure of a good way to do this ... we get all the functional - // children of the parent and look for our relative position ... - for (const auto& i : i_target.template getChildren(fapi2::TARGET_STATE_FUNCTIONAL)) - { - if (mss::template relative_pos

(i) == i_rel_pos) - { - return true; - } - } - - return false; -} - -}// mss - -#endif diff --git a/src/import/generic/memory/lib/utils/mcbist/gen_mss_memdiags.H b/src/import/generic/memory/lib/utils/mcbist/gen_mss_memdiags.H index dad5df32e..dfb6b495b 100644 --- a/src/import/generic/memory/lib/utils/mcbist/gen_mss_memdiags.H +++ b/src/import/generic/memory/lib/utils/mcbist/gen_mss_memdiags.H @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -56,6 +55,29 @@ namespace mss { +/// +/// @brief Determine if a thing is functional +/// @tparam I, the type of the item we want to check for +/// @tparam P, the type of the parent which holds the things of interest +/// @param[in] i_target the parent containing the thing we're looking for +/// @param[in] i_rel_pos the relative position of the item of interest. +/// @return bool true iff the thing at i_rel_pos is noted as functional +/// +template< fapi2::TargetType I, fapi2::TargetType P > +inline bool is_functional( const fapi2::Target

& i_target, const uint64_t i_rel_pos ) +{ + // Not sure of a good way to do this ... we get all the functional + // children of the parent and look for our relative position ... + for (const auto& i : i_target.template getChildren(fapi2::TARGET_STATE_FUNCTIONAL)) + { + if (mss::template relative_pos

(i) == i_rel_pos) + { + return true; + } + } + + return false; +} namespace mcbist { -- cgit v1.2.3