diff options
Diffstat (limited to 'src/import/generic/memory/lib')
18 files changed, 855 insertions, 697 deletions
diff --git a/src/import/generic/memory/lib/data_engine/attr_engine_traits.H b/src/import/generic/memory/lib/data_engine/attr_engine_traits.H index 72e89b3f3..1d7388f65 100644 --- a/src/import/generic/memory/lib/data_engine/attr_engine_traits.H +++ b/src/import/generic/memory/lib/data_engine/attr_engine_traits.H @@ -70,7 +70,7 @@ struct attrEngineTraits<attr_eff_engine_fields, DRAM_WIDTH> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_DRAM_WIDTH, i_target, o_setting); + return mss::attr::get_dram_width(i_target, o_setting); } /// @@ -82,7 +82,7 @@ struct attrEngineTraits<attr_eff_engine_fields, DRAM_WIDTH> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_DRAM_WIDTH, i_target, i_setting); + return mss::attr::set_dram_width(i_target, i_setting); } /// @@ -158,7 +158,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_RCV_IMP_DQ_DQS> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_RCV_IMP_DQ_DQS, i_target, o_setting); + return mss::attr::get_si_mc_rcv_imp_dq_dqs(i_target, o_setting); } /// @@ -170,7 +170,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_RCV_IMP_DQ_DQS> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_RCV_IMP_DQ_DQS, i_target, i_setting); + return mss::attr::set_si_mc_rcv_imp_dq_dqs(i_target, i_setting); } /// @@ -208,7 +208,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_DQ_DQS_PULL_UP> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_DQ_DQS_PULL_UP, i_target, o_setting); + return mss::attr::get_si_mc_drv_imp_dq_dqs_pull_up(i_target, o_setting); } /// @@ -220,7 +220,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_DQ_DQS_PULL_UP> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_DQ_DQS_PULL_UP, i_target, i_setting); + return mss::attr::set_si_mc_drv_imp_dq_dqs_pull_up(i_target, i_setting); } /// @@ -258,7 +258,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_DQ_DQS_PULL_DOWN> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_DQ_DQS_PULL_DOWN, i_target, o_setting); + return mss::attr::get_si_mc_drv_imp_dq_dqs_pull_down(i_target, o_setting); } /// @@ -270,7 +270,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_DQ_DQS_PULL_DOWN> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_DQ_DQS_PULL_DOWN, i_target, i_setting); + return mss::attr::set_si_mc_drv_imp_dq_dqs_pull_down(i_target, i_setting); } /// @@ -309,7 +309,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_DQ_DQS> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_DQ_DQS, i_target, o_setting); + return mss::attr::get_si_mc_drv_slew_rate_dq_dqs(i_target, o_setting); } /// @@ -321,7 +321,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_DQ_DQS> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_DQ_DQS, i_target, i_setting); + return mss::attr::set_si_mc_drv_slew_rate_dq_dqs(i_target, i_setting); } /// @@ -359,7 +359,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_CMD_ADDR> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_CMD_ADDR, i_target, o_setting); + return mss::attr::get_si_mc_drv_imp_cmd_addr(i_target, o_setting); } /// @@ -371,7 +371,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_CMD_ADDR> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_CMD_ADDR, i_target, i_setting); + return mss::attr::set_si_mc_drv_imp_cmd_addr(i_target, i_setting); } /// @@ -409,7 +409,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_CMD_ADDR> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_CMD_ADDR, i_target, o_setting); + return mss::attr::get_si_mc_drv_slew_rate_cmd_addr(i_target, o_setting); } /// @@ -421,7 +421,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_CMD_ADDR> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_CMD_ADDR, i_target, i_setting); + return mss::attr::set_si_mc_drv_slew_rate_cmd_addr(i_target, i_setting); } /// @@ -459,7 +459,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_CLK> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_CLK, i_target, o_setting); + return mss::attr::get_si_mc_drv_imp_clk(i_target, o_setting); } /// @@ -471,7 +471,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_IMP_CLK> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_IMP_CLK, i_target, i_setting); + return mss::attr::set_si_mc_drv_imp_clk(i_target, i_setting); } /// @@ -509,7 +509,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_CLK> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_CLK, i_target, o_setting); + return mss::attr::get_si_mc_drv_slew_rate_clk(i_target, o_setting); } /// @@ -521,7 +521,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_SLEW_RATE_CLK> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_SLEW_RATE_CLK, i_target, i_setting); + return mss::attr::set_si_mc_drv_slew_rate_clk(i_target, i_setting); } /// @@ -559,7 +559,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_RCV_IMP_ALERT_N> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_RCV_IMP_ALERT_N, i_target, o_setting); + return mss::attr::get_si_mc_rcv_imp_alert_n(i_target, o_setting); } /// @@ -571,7 +571,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_RCV_IMP_ALERT_N> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_RCV_IMP_ALERT_N, i_target, i_setting); + return mss::attr::set_si_mc_rcv_imp_alert_n(i_target, i_setting); } /// @@ -609,7 +609,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_NOM> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_DRAM_RTT_NOM, i_target, o_setting); + return mss::attr::get_si_dram_rtt_nom(i_target, o_setting); } /// @@ -621,7 +621,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_NOM> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_DRAM_RTT_NOM, i_target, i_setting); + return mss::attr::set_si_dram_rtt_nom(i_target, i_setting); } /// @@ -659,7 +659,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_WR> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_DRAM_RTT_WR, i_target, o_setting); + return mss::attr::get_si_dram_rtt_wr(i_target, o_setting); } /// @@ -671,7 +671,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_WR> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_DRAM_RTT_WR, i_target, i_setting); + return mss::attr::set_si_dram_rtt_wr(i_target, i_setting); } /// @@ -709,7 +709,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_PARK> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_DRAM_RTT_PARK, i_target, o_setting); + return mss::attr::get_si_dram_rtt_park(i_target, o_setting); } /// @@ -721,7 +721,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_RTT_PARK> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_DRAM_RTT_PARK, i_target, i_setting); + return mss::attr::set_si_dram_rtt_park(i_target, i_setting); } /// @@ -759,7 +759,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_PREAMBLE> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_DRAM_PREAMBLE, i_target, o_setting); + return mss::attr::get_si_dram_preamble(i_target, o_setting); } /// @@ -771,7 +771,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_PREAMBLE> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_DRAM_PREAMBLE, i_target, i_setting); + return mss::attr::set_si_dram_preamble(i_target, i_setting); } /// @@ -810,7 +810,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_EQ_DQ_DQS> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_MC_DRV_EQ_DQ_DQS, i_target, o_setting); + return mss::attr::get_si_mc_drv_eq_dq_dqs(i_target, o_setting); } /// @@ -822,7 +822,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_MC_DRV_EQ_DQ_DQS> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_MC_DRV_EQ_DQ_DQS, i_target, i_setting); + return mss::attr::set_si_mc_drv_eq_dq_dqs(i_target, i_setting); } /// @@ -860,7 +860,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_DRV_IMP_DQ_DQS> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_DRAM_DRV_IMP_DQ_DQS, i_target, o_setting); + return mss::attr::get_si_dram_drv_imp_dq_dqs(i_target, o_setting); } /// @@ -872,7 +872,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_DRAM_DRV_IMP_DQ_DQS> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_DRAM_DRV_IMP_DQ_DQS, i_target, i_setting); + return mss::attr::set_si_dram_drv_imp_dq_dqs(i_target, i_setting); } /// @@ -910,7 +910,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_VREF_DQ_TRAIN_RANGE> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_VREF_DQ_TRAIN_RANGE, i_target, o_setting); + return mss::attr::get_si_vref_dq_train_range(i_target, o_setting); } /// @@ -922,7 +922,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_VREF_DQ_TRAIN_RANGE> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_VREF_DQ_TRAIN_RANGE, i_target, i_setting); + return mss::attr::set_si_vref_dq_train_range(i_target, i_setting); } /// @@ -960,7 +960,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_VREF_DQ_TRAIN_VALUE> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_VREF_DQ_TRAIN_VALUE, i_target, o_setting); + return mss::attr::get_si_vref_dq_train_value(i_target, o_setting); } /// @@ -972,7 +972,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_VREF_DQ_TRAIN_VALUE> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_VREF_DQ_TRAIN_VALUE, i_target, o_setting); + return mss::attr::set_si_vref_dq_train_value(i_target, o_setting); } /// @@ -1010,7 +1010,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_ODT_WR> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_ODT_WR, i_target, o_setting); + return mss::attr::get_si_odt_wr(i_target, o_setting); } /// @@ -1022,7 +1022,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_ODT_WR> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_ODT_WR, i_target, i_setting); + return mss::attr::set_si_odt_wr(i_target, i_setting); } /// @@ -1095,7 +1095,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_ODT_RD> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_ODT_RD, i_target, o_setting); + return mss::attr::get_si_odt_rd(i_target, o_setting); } /// @@ -1107,7 +1107,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_ODT_RD> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_ODT_RD, i_target, i_setting); + return mss::attr::set_si_odt_rd(i_target, i_setting); } /// @@ -1179,7 +1179,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_GEARDOWN_MODE> static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_SI_GEARDOWN_MODE, i_target, o_setting); + return mss::attr::get_si_geardown_mode(i_target, o_setting); } /// @@ -1191,7 +1191,7 @@ struct attrEngineTraits<attr_si_engine_fields, SI_GEARDOWN_MODE> static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_SI_GEARDOWN_MODE, i_target, i_setting); + return mss::attr::set_si_geardown_mode(i_target, i_setting); } /// diff --git a/src/import/generic/memory/lib/data_engine/data_engine.H b/src/import/generic/memory/lib/data_engine/data_engine.H index 6a7cbb437..aa0fb5f0a 100644 --- a/src/import/generic/memory/lib/data_engine/data_engine.H +++ b/src/import/generic/memory/lib/data_engine/data_engine.H @@ -236,6 +236,27 @@ struct attr_eff_engine } }; +/// +/// @brief Data structure to set effective config EFF data +/// @class attr_derived_engine +/// @tparam ET attr fields enum type +/// +template < typename ET, typename TT = attrEnumTraits<ET> > +struct attr_derived_engine +{ + using attr_eng_t = gen::attr_engine<ET, static_cast<ET>(TT::DISPATCHER)>; + + /// + /// @brief Sets attr fields denoted by an eum list + /// @param[in] i_target the DIMM target + /// @return FAPI2_RC_SUCCESS iff ok + /// + static fapi2::ReturnCode set(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) + { + return attr_eng_t::set(i_target); + } +}; + }// mss #endif diff --git a/src/import/generic/memory/lib/data_engine/data_engine_traits_def.H b/src/import/generic/memory/lib/data_engine/data_engine_traits_def.H index 4a802bd46..57ae5355b 100644 --- a/src/import/generic/memory/lib/data_engine/data_engine_traits_def.H +++ b/src/import/generic/memory/lib/data_engine/data_engine_traits_def.H @@ -45,11 +45,29 @@ namespace mss /// /// @brief enum list of preliminary data fields /// +enum generic_metadata_fields +{ + // Template recursive base case + ATTR_METADATA_BASE_CASE = 0, + + // Attrs to set + DIMM_TYPE_METADATA = 1, + DRAM_GEN_METADATA = 2, + DIMM_POS_METADATA = 3, + + // Dispatcher set to last enum value + ATTR_METADATA_DISPATCHER = DIMM_POS_METADATA, +}; + +/// +/// @brief enum list of preliminary data fields +/// enum pre_data_init_fields { // Template recursive base case ATTR_PRE_DATA_ENGINE_CASE = 0, + // Attrs to set DIMM_TYPE = 1, DRAM_GEN = 2, HYBRID = 3, @@ -119,6 +137,13 @@ enum attr_si_engine_fields template< proc_type T, pre_data_init_fields TT > class preDataInitTraits; +/// +/// @brief Traits associated with DIMM positioning +/// @class dimmPosTraits +/// @tparam MC the MC type +/// +template< mss::mc_type MC > +class dimmPosTraits; /// /// @brief Forward declartion of traits for attrEngineTraits @@ -139,7 +164,7 @@ template < typename ET, ET T > struct setTimingTraits; /// -/// @brief Forward declartion of traits for attr_engine +/// @brief Forward declartion of traits for attrEnumTraits /// @class attrEnumTraits /// @tparam ET enum type /// diff --git a/src/import/generic/memory/lib/data_engine/data_engine_utils.H b/src/import/generic/memory/lib/data_engine/data_engine_utils.H index 5436fd5a3..aaf9a0485 100644 --- a/src/import/generic/memory/lib/data_engine/data_engine_utils.H +++ b/src/import/generic/memory/lib/data_engine/data_engine_utils.H @@ -39,6 +39,7 @@ #include <fapi2.H> #include <generic/memory/lib/utils/index.H> #include <generic/memory/lib/utils/find.H> +#include <generic/memory/lib/utils/pos.H> #include <generic/memory/lib/spd/ddimm/efd_decoder.H> #include <generic/memory/lib/spd/spd_facade.H> @@ -61,8 +62,8 @@ struct DataSetterTraits2D; /// template < > struct DataSetterTraits2D < proc_type::NIMBUS, - procTraits<proc_type::NIMBUS>::PORTS_PER_MCS, - procTraits<proc_type::NIMBUS>::DIMMS_PER_PORT + mcTypeTraits<mc_type::NIMBUS>::PORTS_PER_MCS, + mcTypeTraits<mc_type::NIMBUS>::DIMMS_PER_PORT > { static constexpr fapi2::TargetType TARGET = fapi2::TARGET_TYPE_MCA; @@ -319,6 +320,31 @@ fapi_try_exit: /// /// @brief Helper function to update the structure that holds attr data +/// @tparam T the FAPI2 TargetType +/// @tparam IT Input data type +/// @tparam FFDC type +/// @tparam OT Output data type +/// @param[in] i_target the FAPI2 target +/// @param[in] i_setting array to set +/// @param[in] i_ffdc_code FFDC function code +/// @param[out] o_data output to set +/// @return FAPI2_RC_SUCCESS iff okay +/// +template < fapi2::TargetType T, + typename IT, + typename FFDC, + typename OT > +inline fapi2::ReturnCode update_data( const fapi2::Target<T>& i_target, + const IT i_setting, + const FFDC i_ffdc_code, + OT& o_data ) +{ + FAPI_DBG("Updating data with %d for %s", i_setting, spd::c_str(i_target)); + o_data = i_setting; + return fapi2::FAPI2_RC_SUCCESS; +} +/// +/// @brief Helper function to update the structure that holds attr data /// @tparam DT the data type /// @tparam IT Input data type /// @tparam FFDC type @@ -358,7 +384,7 @@ template< typename TT, inline fapi2::ReturnCode set_field(const fapi2::Target<T>& i_target, const IT i_setting) { - const auto l_attr_target = mss::find_target<TT::TARGET>(i_target); + const auto l_attr_target = mss::find_target<TT::TARGET_TYPE>(i_target); typename TT::attr_type l_attr_list = {}; FAPI_TRY( TT::get_attr(l_attr_target, l_attr_list) ); @@ -446,6 +472,24 @@ struct attr_engine { /// /// @brief Sets attributes fields F in ET + /// @tparam T the fapi2 target type + /// @param[in] i_target the fapi2 target + /// @return FAPI2_RC_SUCCESS iff oka + /// + template < fapi2::TargetType T > + static fapi2::ReturnCode single_set(const fapi2::Target<T>& i_target) + { + typename TT::attr_integral_type l_value = 0; + FAPI_TRY( TT::get_value_to_set(i_target, l_value) ); + + FAPI_TRY( set_field<TT>(i_target, l_value) ); + + fapi_try_exit: + return fapi2::current_err; + } + + /// + /// @brief Sets attributes fields F in ET /// @tparam DT the data type /// @param[in] i_data the data (efd_decoder, spd_facade, etc.) /// @return FAPI2_RC_SUCCESS iff ok @@ -481,6 +525,26 @@ struct attr_engine fapi_try_exit: return fapi2::current_err; } + + /// + /// @brief Sets attributes fields F in ET + /// @tparam T the fapi2 target type + /// @param[in] i_target the fapi2 target + /// @return FAPI2_RC_SUCCESS iff ok + /// + template < fapi2::TargetType T > + static fapi2::ReturnCode set(const fapi2::Target<T>& i_target) + { + FAPI_TRY( (attr_engine<ET, F>::single_set(i_target)) ); + + // Compiler isn't smart enough to deduce F - 1u (decrementing the enum values by 1) + // Cast needed to help the compiler deduce this value is an ET type + // This does the recursive call to unroll a compile-time looping of a enum list of attrs to set + FAPI_TRY( (attr_engine < ET, static_cast<ET>(F - 1u) >::set(i_target)) ); + + fapi_try_exit: + return fapi2::current_err; + } }; /// @@ -498,6 +562,18 @@ struct attr_engine< ET, { /// /// @brief Sets attributes fields F in ET + /// @tparam T the fapi2 target type + /// @param[in] i_target the fapi2 target + /// @return FAPI2_RC_SUCCESS iff ok + /// + template < fapi2::TargetType T > + static fapi2::ReturnCode set(const fapi2::Target<T>& i_target) + { + return fapi2::FAPI2_RC_SUCCESS; + } + + /// + /// @brief Sets attributes fields F in ET /// @tparam DT the data type /// @param[in] i_data the data (efd_decoder, spd_facade, etc.) /// @return FAPI2_RC_SUCCESS iff ok @@ -509,6 +585,30 @@ struct attr_engine< ET, } }; +/// +/// @brief Return a DIMM's position from a fapi2 target +/// @tparam TT Traits associated with DIMM position (e.g. dimmPosTraits) +/// @tparam OT the output type +/// @param[in] i_target a target representing the target in question +/// @param[out] o_value The position relative to the chip +/// +template< typename TT, typename OT> +fapi2::ReturnCode dimm_pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, OT& o_value) +{ + const auto l_proc_pos = mss::pos( TT::get_proc(i_target) ); + + typename TT::pos_type l_pos = 0; + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos)); + + // To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos value + // to the processor (stride across which ever processor we're on) and then add in the delta + // per processor as ATTR_POS isn't processor relative (delta is the total dimm on a processor) + o_value = ((l_pos - (l_proc_pos * TT::DIMM_STRIDE_PER_PROC)) % TT::TOTAL_DIMM) + (TT::TOTAL_DIMM * l_proc_pos); + +fapi_try_exit: + return fapi2::current_err; +} + }// gen }//mss diff --git a/src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H b/src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H index 69234151e..0fd4a0056 100644 --- a/src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H +++ b/src/import/generic/memory/lib/data_engine/p9a/p9a_data_init_traits.H @@ -39,14 +39,76 @@ #include <generic/memory/lib/data_engine/data_engine_traits_def.H> #include <generic/memory/lib/data_engine/data_engine_utils.H> #include <generic/memory/lib/spd/spd_facade.H> +#include <generic/memory/lib/mss_generic_attribute_getters.H> +#include <generic/memory/lib/mss_generic_attribute_setters.H> namespace mss { /// +/// @brief Helper function to get dimm_type from SPD +/// @param[in] i_spd_data SPD data +/// @param[in] i_setting value we want to set attr with +/// @return FAPI2_RC_SUCCESS iff okay +/// +static fapi2::ReturnCode get_dimm_type(const spd::facade& i_spd_data, + uint8_t& o_setting) +{ + // ========================================================= + // DDR4 SPD Document Release 4 + // Byte 3 (0x003): Key Byte / Module Type + // ========================================================= + static const std::vector< std::pair<uint8_t, uint8_t> > BASE_MODULE_TYPE_MAP = + { + //{key byte, dimm type} + {1, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_RDIMM}, + {2, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_UDIMM}, + {10, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_DDIMM}, + // All others reserved or not supported + }; + + const auto l_dimm = i_spd_data.get_dimm_target(); + uint8_t l_base_module_type = 0; + FAPI_TRY(i_spd_data.base_module(l_base_module_type)); + FAPI_TRY(lookup_table_check(l_dimm, BASE_MODULE_TYPE_MAP, SET_ATTR_DIMM_TYPE, l_base_module_type, o_setting)); + +fapi_try_exit: + return fapi2::current_err; +} + +/// +/// @brief Helper function to get dram_gen from SPD +/// @param[in] i_spd_data SPD data +/// @param[in] i_setting value we want to set attr with +/// @return FAPI2_RC_SUCCESS iff okay +/// +static fapi2::ReturnCode get_dram_gen(const spd::facade& i_spd_data, + uint8_t& o_setting) +{ + // ========================================================= + // DDR4 SPD Document Release 4 + // Byte 2 (0x002): Key Byte / DRAM Device Type + // ========================================================= + static const std::vector< std::pair<uint8_t, uint8_t> > DRAM_GEN_MAP = + { + //{key value, dram gen} + {0x0C, fapi2::ENUM_ATTR_MEM_EFF_DRAM_GEN_DDR4} + // Other key bytes reserved or not supported + }; + + const auto l_dimm = i_spd_data.get_dimm_target(); + uint8_t l_device_type = 0; + FAPI_TRY(i_spd_data.device_type(l_device_type)); + FAPI_TRY(lookup_table_check(l_dimm, DRAM_GEN_MAP, SET_ATTR_DRAM_GEN, l_device_type, o_setting)); + +fapi_try_exit: + return fapi2::current_err; +} + +/// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, DIMM_TYPE specialization +/// @note pre_data_init_fields, DIMM_TYPE specialization /// template<> struct attrEngineTraits<pre_data_init_fields, DIMM_TYPE> @@ -58,26 +120,26 @@ struct attrEngineTraits<pre_data_init_fields, DIMM_TYPE> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_DIMM_TYPE, i_target, o_setting); + return mss::attr::get_dimm_type(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_DIMM_TYPE, i_target, i_setting); + return mss::attr::set_dimm_type(i_target, i_setting); } /// @@ -89,33 +151,14 @@ struct attrEngineTraits<pre_data_init_fields, DIMM_TYPE> static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data, attr_integral_type& o_setting) { - // ========================================================= - // DDR4 SPD Document Release 4 - // Byte 3 (0x003): Key Byte / Module Type - // ========================================================= - static const std::vector< std::pair<uint8_t, uint8_t> > BASE_MODULE_TYPE_MAP = - { - //{key byte, dimm type} - {1, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_RDIMM}, - {2, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_UDIMM}, - {10, fapi2::ENUM_ATTR_MEM_EFF_DIMM_TYPE_DDIMM}, - // All others reserved or not supported - }; - - uint8_t l_base_module_type = 0; - FAPI_TRY(i_spd_data.base_module(l_base_module_type)); - FAPI_TRY(lookup_table_check(i_spd_data.get_dimm_target(), BASE_MODULE_TYPE_MAP, SET_ATTR_DIMM_TYPE, l_base_module_type, - o_setting)); - - fapi_try_exit: - return fapi2::current_err; + return get_dimm_type(i_spd_data, o_setting); } }; /// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, DRAM_GEN specialization +/// @note pre_data_init_fields, DRAM_GEN specialization /// template<> struct attrEngineTraits<pre_data_init_fields, DRAM_GEN> @@ -127,26 +170,26 @@ struct attrEngineTraits<pre_data_init_fields, DRAM_GEN> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_DRAM_GEN, i_target, o_setting); + return mss::attr::get_dram_gen(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_DRAM_GEN, i_target, i_setting); + return mss::attr::set_dram_gen(i_target, i_setting); } /// @@ -158,30 +201,14 @@ struct attrEngineTraits<pre_data_init_fields, DRAM_GEN> static fapi2::ReturnCode get_value_to_set(const spd::facade& i_spd_data, attr_integral_type& o_setting) { - // ========================================================= - // DDR4 SPD Document Release 4 - // Byte 2 (0x002): Key Byte / DRAM Device Type - // ========================================================= - static const std::vector< std::pair<uint8_t, uint8_t> > DRAM_GEN_MAP = - { - //{key value, dram gen} - {0x0C, fapi2::ENUM_ATTR_MEM_EFF_DRAM_GEN_DDR4} - // Other key bytes reserved or not supported - }; - - uint8_t l_device_type = 0; - FAPI_TRY(i_spd_data.device_type(l_device_type)); - FAPI_TRY(lookup_table_check(i_spd_data.get_dimm_target(), DRAM_GEN_MAP, SET_ATTR_DRAM_GEN, l_device_type, o_setting)); - - fapi_try_exit: - return fapi2::current_err; + return get_dram_gen(i_spd_data, o_setting); } }; /// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, HYBRID specialization +/// @note pre_data_init_fields, HYBRID specialization /// template<> struct attrEngineTraits<pre_data_init_fields, HYBRID> @@ -193,26 +220,26 @@ struct attrEngineTraits<pre_data_init_fields, HYBRID> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_HYBRID, i_target, o_setting); + return mss::attr::get_hybrid(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_HYBRID, i_target, i_setting); + return mss::attr::set_hybrid(i_target, i_setting); } /// @@ -248,7 +275,7 @@ struct attrEngineTraits<pre_data_init_fields, HYBRID> /// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, HYBRID_MEDIA specialization +/// @note pre_data_init_fields, HYBRID_MEDIA specialization /// template<> struct attrEngineTraits<pre_data_init_fields, HYBRID_MEDIA> @@ -260,26 +287,26 @@ struct attrEngineTraits<pre_data_init_fields, HYBRID_MEDIA> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_HYBRID_MEMORY_TYPE, i_target, o_setting); + return mss::attr::get_hybrid_memory_type(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_HYBRID_MEMORY_TYPE, i_target, i_setting); + return mss::attr::set_hybrid_memory_type(i_target, i_setting); } /// @@ -350,7 +377,7 @@ fapi_try_exit: /// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, MRANKS specialization +/// @note pre_data_init_fields, MRANKS specialization /// template<> struct attrEngineTraits<pre_data_init_fields, MRANKS> @@ -362,26 +389,26 @@ struct attrEngineTraits<pre_data_init_fields, MRANKS> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, o_setting); + return mss::attr::get_num_master_ranks_per_dimm(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, i_setting); + return mss::attr::set_num_master_ranks_per_dimm(i_target, i_setting); } /// @@ -403,7 +430,7 @@ struct attrEngineTraits<pre_data_init_fields, MRANKS> /// /// @brief Traits for pre_data_engine /// @class attrEngineTraits -/// @note AXONE, DIMM_RANKS_CNFG specialization +/// @note pre_data_init_fields, DIMM_RANKS_CNFG specialization /// template<> struct attrEngineTraits<pre_data_init_fields, DIMM_RANKS_CNFG> @@ -415,26 +442,26 @@ struct attrEngineTraits<pre_data_init_fields, DIMM_RANKS_CNFG> /// /// @brief attribute getter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[out] o_setting array to populate /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& o_setting) { - return FAPI_ATTR_GET(fapi2::ATTR_MEM_EFF_DIMM_RANKS_CONFIGED, i_target, o_setting); + return mss::attr::get_dimm_ranks_configed(i_target, o_setting); } /// /// @brief attribute setter - /// @param[in] i_target the MCS target + /// @param[in] i_target the attr target /// @param[in] i_setting array to set /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, attr_type& i_setting) { - return FAPI_ATTR_SET(fapi2::ATTR_MEM_EFF_DIMM_RANKS_CONFIGED, i_target, i_setting); + return mss::attr::set_dimm_ranks_configed(i_target, i_setting); } /// diff --git a/src/import/generic/memory/lib/data_engine/p9n/p9n_data_init_traits.H b/src/import/generic/memory/lib/data_engine/p9n/p9n_data_init_traits.H index 02254790e..5f0207b14 100644 --- a/src/import/generic/memory/lib/data_engine/p9n/p9n_data_init_traits.H +++ b/src/import/generic/memory/lib/data_engine/p9n/p9n_data_init_traits.H @@ -38,6 +38,8 @@ #include <fapi2.H> #include <generic/memory/lib/data_engine/data_engine_traits_def.H> +#include <generic/memory/lib/data_engine/data_engine.H> +#include <lib/mss_attribute_accessors.H> namespace mss { @@ -77,14 +79,9 @@ class preDataInitTraits<mss::proc_type::NIMBUS, DIMM_TYPE> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_DIMM_TYPE, i_target, l_data) ); - - fapi_try_exit: - return fapi2::current_err; + return FAPI_ATTR_SET(fapi2::ATTR_EFF_DIMM_TYPE, i_target, i_setting); } }; @@ -123,15 +120,9 @@ class preDataInitTraits<mss::proc_type::NIMBUS, DRAM_GEN> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); - - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_DRAM_GEN, i_target, l_data) ); - - fapi_try_exit: - return fapi2::current_err; + return FAPI_ATTR_SET(fapi2::ATTR_EFF_DRAM_GEN, i_target, i_setting); } }; @@ -170,15 +161,9 @@ class preDataInitTraits<mss::proc_type::NIMBUS, HYBRID> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); - - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_HYBRID, i_target, l_data) ); - - fapi_try_exit: - return fapi2::current_err; + return FAPI_ATTR_SET(fapi2::ATTR_EFF_HYBRID, i_target, i_setting); } }; @@ -217,15 +202,9 @@ class preDataInitTraits<mss::proc_type::NIMBUS, HYBRID_MEDIA> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); - - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_HYBRID_MEMORY_TYPE, i_target, l_data) ); - - fapi_try_exit: - return fapi2::current_err; + return FAPI_ATTR_SET(fapi2::ATTR_EFF_HYBRID_MEMORY_TYPE, i_target, i_setting); } }; @@ -264,15 +243,9 @@ class preDataInitTraits<mss::proc_type::NIMBUS, MRANKS> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); - - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, l_data) ); - - fapi_try_exit: - return fapi2::current_err; + return FAPI_ATTR_SET(fapi2::ATTR_EFF_NUM_MASTER_RANKS_PER_DIMM, i_target, i_setting); } }; @@ -311,18 +284,205 @@ class preDataInitTraits<mss::proc_type::NIMBUS, DIMM_RANKS_CNFG> /// @return FAPI2_RC_SUCCESS iff okay /// static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, - const attr_type& i_setting) + attr_type& i_setting) { - attr_type l_data = {}; - memcpy(l_data, i_setting, sizeof(l_data)); + return FAPI_ATTR_SET(fapi2::ATTR_EFF_DIMM_RANKS_CONFIGED, i_target, i_setting); + } +}; - FAPI_TRY( FAPI_ATTR_SET(fapi2::ATTR_EFF_DIMM_RANKS_CONFIGED, i_target, l_data) ); +/// +/// @brief Traits for pre_data_engine +/// @class attrEngineTraits +/// @note AXONE, DIMM_TYPE_METADATA specialization +/// +template<> +struct attrEngineTraits<generic_metadata_fields, DIMM_TYPE_METADATA> +{ + using attr_type = fapi2::ATTR_MEM_DIMM_TYPE_METADATA_Type; + using attr_integral_type = std::remove_all_extents<attr_type>::type; + static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_DIMM_TYPE_METADATA_TargetType; + static constexpr generic_ffdc_codes FFDC_CODE = SET_DIMM_TYPE_METADATA; + + /// + /// @brief attribute getter + /// @param[in] i_target the MCS target + /// @param[out] o_setting array to populate + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& o_setting) + { + return FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_TYPE_METADATA, i_target, o_setting); + } + + /// + /// @brief attribute setter + /// @param[in] i_target the MCS target + /// @param[in] i_setting array to set + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& i_setting) + { + return FAPI_ATTR_SET(fapi2::ATTR_MEM_DIMM_TYPE_METADATA, i_target, i_setting); + } + + /// + /// @brief Computes setting for attribute + /// @param[in] i_spd_data SPD data + /// @param[in] i_setting value we want to set attr with + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_value_to_set(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + attr_integral_type& o_setting) + { + return mss::eff_dimm_type(i_target, o_setting); + } +}; - fapi_try_exit: - return fapi2::current_err; +/// +/// @brief Traits associated with DIMM positioning +/// @class dimmPosTraits - NIMBUS specializattion +/// +template<> +class dimmPosTraits<mss::mc_type::NIMBUS> +{ + private: + using PT = posTraits<fapi2::TARGET_TYPE_DIMM>; + using MT = mss::mcTypeTraits<mc_type::NIMBUS>; + + public: + // Public interface syntatic sugar + using pos_type = PT::pos_type; + + // Proc 0 is DIMM 0-15, proc 2 is 64-79. 64 is the stride between processors + static constexpr auto DIMM_STRIDE_PER_PROC = 64; + static constexpr auto TOTAL_DIMM = MT::MC_PER_MODULE * MT::MCS_PER_MC * MT::PORTS_PER_MCS * MT::DIMMS_PER_PORT; + + /// + /// @brief Return the PROC_CHIP parent of a DIMM + /// @param[in] i_target the dimm target + /// @return the fapi2 proc target + /// + static fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> get_proc(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) + { + // Using fapi2 rather than mss::find as this is pretty low level stuff. + return i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>(); } }; +/// +/// @brief Traits for pre_data_engine +/// @class attrEngineTraits +/// @note generic_metadata_fields, DRAM_GEN_METADATA specialization +/// +template<> +struct attrEngineTraits<generic_metadata_fields, DRAM_GEN_METADATA> +{ + using attr_type = fapi2::ATTR_MEM_DRAM_GEN_METADATA_Type; + using attr_integral_type = std::remove_all_extents<attr_type>::type; + static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_DRAM_GEN_METADATA_TargetType; + static constexpr generic_ffdc_codes FFDC_CODE = SET_DRAM_GEN_METADATA; + + /// + /// @brief attribute getter + /// @param[in] i_target the MCS target + /// @param[out] o_setting array to populate + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& o_setting) + { + return FAPI_ATTR_GET(fapi2::ATTR_MEM_DRAM_GEN_METADATA, i_target, o_setting); + } + + /// + /// @brief attribute setter + /// @param[in] i_target the MCS target + /// @param[in] i_setting array to set + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& i_setting) + { + return FAPI_ATTR_SET(fapi2::ATTR_MEM_DRAM_GEN_METADATA, i_target, i_setting); + } + + /// + /// @brief Computes setting for attribute + /// @param[in] i_spd_data SPD data + /// @param[in] i_setting value we want to set attr with + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_value_to_set(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + attr_integral_type& o_setting) + { + return mss::eff_dram_gen(i_target, o_setting); + } +}; + +/// +/// @brief Traits for pre_data_engine +/// @class attrEngineTraits +/// @note generic_metadata_fields, DIMM_POS_METADATA specialization +/// +template<> +struct attrEngineTraits<generic_metadata_fields, DIMM_POS_METADATA> +{ + using attr_type = fapi2::ATTR_MEM_DIMM_POS_METADATA_Type; + using attr_integral_type = std::remove_all_extents<attr_type>::type; + static constexpr fapi2::TargetType TARGET_TYPE = fapi2::ATTR_MEM_DIMM_POS_METADATA_TargetType; + static constexpr generic_ffdc_codes FFDC_CODE = SET_DIMM_POS_METADATA; + + /// + /// @brief attribute getter + /// @param[in] i_target the MCS target + /// @param[out] o_setting array to populate + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& o_setting) + { + return FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_POS_METADATA, i_target, o_setting); + } + + /// + /// @brief attribute setter + /// @param[in] i_target the MCS target + /// @param[in] i_setting array to set + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode set_attr(const fapi2::Target<TARGET_TYPE>& i_target, + attr_type& i_setting) + { + return FAPI_ATTR_SET(fapi2::ATTR_MEM_DIMM_POS_METADATA, i_target, i_setting); + } + + /// + /// @brief Computes setting for attribute + /// @param[in] i_spd_data SPD data + /// @param[in] i_setting value we want to set attr with + /// @return FAPI2_RC_SUCCESS iff okay + /// + static fapi2::ReturnCode get_value_to_set(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + attr_integral_type& o_setting) + { + using TT = mss::dimmPosTraits<mss::mc_type::NIMBUS>; + return gen::dimm_pos<TT>(i_target, o_setting); + } +}; + +/// +/// @brief Value traits for attr_eff_engine_fields +/// @class attrEngineTraits +/// @note attr_eff_engine_fields +/// +template < > +struct attrEnumTraits<generic_metadata_fields> +{ + static constexpr size_t DISPATCHER = ATTR_METADATA_DISPATCHER; +}; + }// mss #endif diff --git a/src/import/generic/memory/lib/data_engine/pre_data_init.H b/src/import/generic/memory/lib/data_engine/pre_data_init.H index b3e4de8ad..b8311f83e 100644 --- a/src/import/generic/memory/lib/data_engine/pre_data_init.H +++ b/src/import/generic/memory/lib/data_engine/pre_data_init.H @@ -250,10 +250,23 @@ class pre_data_engine /// @return FAPI2_RC_SUCCESS iff ok /// template <mss::proc_type P> -fapi2::ReturnCode set_pre_init_attrs( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, - const spd::facade& i_spd_decoder ) +inline fapi2::ReturnCode set_pre_init_attrs( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + const spd::facade& i_spd_decoder ); + +/// +/// @brief Sets pre_eff_config attributes - NIMBUS specialization +/// @param[in] i_target the DIMM target +/// @param[in] i_spd_decoder SPD decoder +/// @return FAPI2_RC_SUCCESS iff ok +/// +template <> +inline fapi2::ReturnCode set_pre_init_attrs<mss::proc_type::NIMBUS>( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& + i_target, + const spd::facade& i_spd_decoder ) { - mss::pre_data_engine<P> l_data_engine(i_target, i_spd_decoder); + // TK explicitly forcing this API to only run in Nimbus, need to move pre_data_engine to Nimbus chip path, + // using template recursive algorithm moving forward + mss::pre_data_engine<mss::proc_type::NIMBUS> l_data_engine(i_target, i_spd_decoder); // Set attributes needed before eff_config // DIMM type and DRAM gen are needed for c_str to aid debugging @@ -270,6 +283,8 @@ fapi2::ReturnCode set_pre_init_attrs( const fapi2::Target<fapi2::TARGET_TYPE_DIM FAPI_TRY(l_data_engine.set_dimm_ranks_configured(), "Failed to set DIMM ranks configured %s", mss::spd::c_str(i_target) ); + FAPI_TRY( mss::attr_derived_engine<mss::generic_metadata_fields>::set(i_target) ); + fapi_try_exit: return fapi2::current_err; } diff --git a/src/import/generic/memory/lib/mss_generic_attribute_getters.H b/src/import/generic/memory/lib/mss_generic_attribute_getters.H index 3b01d0c4a..613ddad0a 100644 --- a/src/import/generic/memory/lib/mss_generic_attribute_getters.H +++ b/src/import/generic/memory/lib/mss_generic_attribute_getters.H @@ -37,6 +37,77 @@ namespace mss namespace attr { /// +/// @brief ATTR_MEM_DIMM_POS_METADATA getter +/// @param[in] const ref to the TARGET_TYPE_DIMM +/// @param[out] uint32_t& reference to store the value +/// @note Generated by gen_accessors.pl generate_other_attr_params +/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK +/// @note To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos +/// value to the processor (stride across which ever processor we're on) and then add +/// in the delta per processor as ATTR_POS isn't processor relative (delta is the total +/// dimm on a processor) +/// +inline fapi2::ReturnCode get_dimm_pos_metadata(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + uint32_t& o_value) +{ + + FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_POS_METADATA, i_target, o_value) ); + return fapi2::current_err; + +fapi_try_exit: + FAPI_ERR("failed getting ATTR_MEM_DIMM_POS_METADATA: 0x%lx", + uint64_t(fapi2::current_err)); + return fapi2::current_err; +} + +/// +/// @brief ATTR_MEM_DRAM_GEN_METADATA getter +/// @param[in] const ref to the TARGET_TYPE_DIMM +/// @param[out] uint8_t& reference to store the value +/// @note Generated by gen_accessors.pl generate_other_attr_params +/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK +/// @note DRAM Device Type. Decodes SPD byte 2. Created for use by attributes that need this +/// data earlier than eff_config, such as c_str and the hypervisor. Not meant for direct +/// HWP use. This is just an abstraction of any chip specific EFF_DRAM_GEN attribute. +/// +inline fapi2::ReturnCode get_dram_gen_metadata(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, uint8_t& o_value) +{ + + FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MEM_DRAM_GEN_METADATA, i_target, o_value) ); + return fapi2::current_err; + +fapi_try_exit: + FAPI_ERR("failed getting ATTR_MEM_DRAM_GEN_METADATA: 0x%lx", + uint64_t(fapi2::current_err)); + return fapi2::current_err; +} + +/// +/// @brief ATTR_MEM_DIMM_TYPE_METADATA getter +/// @param[in] const ref to the TARGET_TYPE_DIMM +/// @param[out] uint8_t& reference to store the value +/// @note Generated by gen_accessors.pl generate_other_attr_params +/// @return fapi2::ReturnCode - FAPI2_RC_SUCCESS iff get is OK +/// @note Base Module Type. Decodes SPD Byte 3 (bits 3~0). Created for use by attributes that +/// need this data earlier than eff_config, such as c_str and the hypervisor. Not meant +/// for direct HWP use. This is just an abstraction of any chip specific EFF_DIMM_TYPE +/// attribute. +/// +inline fapi2::ReturnCode get_dimm_type_metadata(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target, + uint8_t& o_value) +{ + + FAPI_TRY( FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_TYPE_METADATA, i_target, o_value) ); + return fapi2::current_err; + +fapi_try_exit: + FAPI_ERR("failed getting ATTR_MEM_DIMM_TYPE_METADATA: 0x%lx", + uint64_t(fapi2::current_err)); + return fapi2::current_err; +} + + +/// /// @brief ATTR_MEM_DRAM_CWL getter /// @param[in] const ref to the TARGET_TYPE_MEM_PORT /// @param[out] uint8_t& reference to store the value diff --git a/src/import/generic/memory/lib/utils/c_str.C b/src/import/generic/memory/lib/utils/c_str.C index 9b0333e48..bea66ea2e 100644 --- a/src/import/generic/memory/lib/utils/c_str.C +++ b/src/import/generic/memory/lib/utils/c_str.C @@ -28,7 +28,7 @@ /// @brief Storage for the C-string name of a thing /// // *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> -// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> +// *HWP HWP Backup: Louis Stermole <stermole@us.ibm.com> // *HWP Team: Memory // *HWP Level: 3 // *HWP Consumed by: HB:FSP diff --git a/src/import/generic/memory/lib/utils/c_str.H b/src/import/generic/memory/lib/utils/c_str.H index ee1c044c2..d0e5eb6ae 100644 --- a/src/import/generic/memory/lib/utils/c_str.H +++ b/src/import/generic/memory/lib/utils/c_str.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -28,7 +28,7 @@ /// @brief Function to return the C-string name of a thing /// // *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> -// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> +// *HWP HWP Backup: Louis Stermole <stermole@us.ibm.com> // *HWP Team: Memory // *HWP Level: 3 // *HWP Consumed by: HB:FSP @@ -37,7 +37,6 @@ #define _MSS_C_STR_H_ #include <fapi2.H> -#include <generic/memory/lib/utils/index.H> namespace mss { @@ -72,36 +71,28 @@ inline const char* c_str( const fapi2::template Target<T>& i_target ) return c_str_storage; } +/// +/// @brief fapi2::Target c_str general declaration +/// @param[in] i_target - target you want the name for +/// @return const char * +/// @note DIMM specialization +/// template<> inline const char* c_str( const fapi2::template Target<fapi2::TARGET_TYPE_DIMM>& i_target ) { - const auto l_mca = i_target.getParent<fapi2::TARGET_TYPE_MCA>(); - const auto l_mcs = l_mca.getParent<fapi2::TARGET_TYPE_MCS>(); + static constexpr auto l_max_gen = 3; + static constexpr auto l_max_type = 5; - constexpr auto l_max_gen = 3; - constexpr auto l_max_type = 4; - const char* const l_map_gen_to_string[l_max_gen] = {"empty", "DDR3", "DDR4"}; - const char* const l_map_type_to_string[l_max_type] = {"empty", "RDIMM", "UDIMM", "LRDIMM"}; - - uint8_t l_type = 0; uint8_t l_gen = 0; - char l_buffer[fapi2::MAX_ECMD_STRING_LEN] = {}; - - fapi2::toString( i_target, c_str_storage, fapi2::MAX_ECMD_STRING_LEN ); + uint8_t l_type = 0; // Had to unroll FAPI_TRY so that fapi2::current_err doesn't get overwritten, causes errors // when calling c_str inside of a function that returns fapi2::ReturnCode - constexpr size_t PORTS_PER_MCS = 2; - constexpr size_t MAX_DIMM_PER_PORT = 2; - uint8_t l_value[PORTS_PER_MCS][MAX_DIMM_PER_PORT] = {}; - - if (FAPI_ATTR_GET(fapi2::ATTR_EFF_DIMM_TYPE, l_mcs, l_value) != fapi2::FAPI2_RC_SUCCESS) + if (FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_TYPE_METADATA, i_target, l_type) != fapi2::FAPI2_RC_SUCCESS) { goto fapi_try_exit; } - l_type = l_value[mss::index(l_mca)][mss::index(i_target)]; - if (l_type >= l_max_type) { goto fapi_try_exit; @@ -109,20 +100,26 @@ inline const char* c_str( const fapi2::template Target<fapi2::TARGET_TYPE_DIMM>& // Had to unroll FAPI_TRY so that fapi2::current_err doesn't get overwritten, causes errors // when calling c_str inside of a function that returns fapi2::ReturnCode - if (FAPI_ATTR_GET(fapi2::ATTR_EFF_DRAM_GEN, l_mcs, l_value) != fapi2::FAPI2_RC_SUCCESS) + if (FAPI_ATTR_GET(fapi2::ATTR_MEM_DRAM_GEN_METADATA, i_target, l_gen) != fapi2::FAPI2_RC_SUCCESS) { goto fapi_try_exit; } - l_gen = l_value[mss::index(l_mca)][mss::index(i_target)]; - if (l_gen >= l_max_gen) { goto fapi_try_exit; } - snprintf(l_buffer, fapi2::MAX_ECMD_STRING_LEN, " %s (%s)", l_map_type_to_string[l_type], l_map_gen_to_string[l_gen]); - return strncat( c_str_storage, l_buffer, fapi2::MAX_ECMD_STRING_LEN - strlen(c_str_storage) ); + { + const char* const l_map_gen_to_string[l_max_gen] = {"empty", "DDR3", "DDR4"}; + const char* const l_map_type_to_string[l_max_type] = {"empty", "RDIMM", "UDIMM", "LRDIMM", "DDIMM"}; + + char l_buffer[fapi2::MAX_ECMD_STRING_LEN] = {}; + fapi2::toString( i_target, c_str_storage, fapi2::MAX_ECMD_STRING_LEN ); + + snprintf(l_buffer, fapi2::MAX_ECMD_STRING_LEN, " %s (%s)", l_map_type_to_string[l_type], l_map_gen_to_string[l_gen]); + return strncat( c_str_storage, l_buffer, fapi2::MAX_ECMD_STRING_LEN - strlen(c_str_storage) ); + } fapi_try_exit: // Probably the best we're going to do ... diff --git a/src/import/generic/memory/lib/utils/find.H b/src/import/generic/memory/lib/utils/find.H index df7d55d41..c22199b6d 100644 --- a/src/import/generic/memory/lib/utils/find.H +++ b/src/import/generic/memory/lib/utils/find.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -38,120 +38,110 @@ #include <fapi2.H> #include <vector> -#include <generic/memory/lib/utils/pos.H> -#include <generic/memory/lib/utils/c_str.H> namespace mss { /// -/// @brief find a set of elements based on a fapi2 target +/// @brief Helper to find a set of elements based on a fapi2 target /// @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 +/// @param[in] std::false_type tag dispatch if T != M /// @param[in] i_state [optional] fapi2 target state (defaults to TARGET_STATE_FUNCTIONAL) /// @return a vector of M targets. -/// @note Only works for valid parent-child relationships -/// So calling find_targets<TARGET_TYPE_DIMM>(l_mca) will work here -/// but calling find_targets<TARGET_TYPE_DIMM>(l_mcs) will not work -/// Compiler will freak out and we'll never get a bad relationship/ error at runtime -/// If we do, it's on fapi2 /// template< fapi2::TargetType M, fapi2::TargetType T > -inline std::vector< fapi2::Target<M> > find_targets( const fapi2::Target<T>& i_target, - fapi2::TargetState i_state = fapi2::TARGET_STATE_FUNCTIONAL ) +static inline std::vector< fapi2::Target<M> > find_targets_impl( const fapi2::Target<T>& i_target, + std::false_type, + fapi2::TargetState i_state ) { return i_target.template getChildren<M>(i_state); } /// -/// @brief find an element based on a fapi2 target +/// @brief Helper to find a set of elements based on a fapi2 target /// @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 an M target. -/// @note Only works for valid parent-child relationships -/// Will work for MCA and DIMM -/// Will not work for MCS and DIMM -/// The compiler will let you know if it doesn't work +/// @param[in] std::true_type tag dispatch if T == M +/// @param[in] i_state [optional] fapi2 target state (defaults to TARGET_STATE_FUNCTIONAL) +/// @return a vector of M targets. /// template< fapi2::TargetType M, fapi2::TargetType T > -inline fapi2::Target<M> find_target( const fapi2::Target<T>& i_target ) +static inline std::vector< fapi2::Target<M> > find_targets_impl( const fapi2::Target<T>& i_target, + std::true_type, + fapi2::TargetState i_state ) { - return i_target.template getParent<M>(); + return std::vector< fapi2::Target<M> > {i_target}; } /// -/// @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. +/// @brief find a set of elements based on a fapi2 target /// @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 +/// @param[in] std::true_type tag dispatch if T == M +/// @param[in] i_state [optional] fapi2 target state (defaults to TARGET_STATE_FUNCTIONAL) /// @return a vector of M targets. +/// @note Only works for valid parent-child relationships +/// So calling find_targets<TARGET_TYPE_DIMM>(l_mca) will work here +/// but calling find_targets<TARGET_TYPE_DIMM>(l_mcs) will not work +/// Compiler will freak out and we'll never get a bad relationship/ error at runtime +/// If we do, it's on fapi2 /// template< fapi2::TargetType M, fapi2::TargetType T > -inline std::vector< fapi2::Target<M> > find_targets_with_magic( const fapi2::Target<T>& i_target); +inline std::vector< fapi2::Target<M> > find_targets( const fapi2::Target<T>& i_target, + fapi2::TargetState i_state = fapi2::TARGET_STATE_FUNCTIONAL ) +{ + return find_targets_impl<M>(i_target, std::integral_constant<bool, M == T> {}, i_state); +} /// -/// @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. +/// @brief Helper to find an element based on a fapi2 target /// @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. +/// @param[in] std::false_type tag dispatch if T != M +/// @return an M target. +/// @note Only works for valid parent-child relationships /// template< fapi2::TargetType M, fapi2::TargetType T > -inline std::vector< fapi2::Target<M> > find_magic_targets( const fapi2::Target<T>& i_target); - -/// -/// @brief find the McBIST given a McBIST -/// @param[in] i_self the fapi2 target mcBIST -/// @return a McBIST target. -/// -template<> -inline fapi2::Target<fapi2::TARGET_TYPE_MCBIST> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_self) -{ - return i_self; -} - -/// -/// @brief find the MCS given an MCS -/// @param[in] i_self the fapi2 target MCS -/// @return a MCS target. -/// -template<> -inline fapi2::Target<fapi2::TARGET_TYPE_MCS> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_self) +static inline fapi2::Target<M> find_target_impl( const fapi2::Target<T>& i_target, + std::false_type ) { - return i_self; + return i_target.template getParent<M>(); } /// -/// @brief find the MEM_PORT given a MEM_PORT -/// @param[in] i_self the fapi2 target MEM_PORT -/// @return a MEM_PORT target. +/// @brief Helper to find an element based on a fapi2 target +/// @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 an M target. +/// @note Only works for valid parent-child relationships /// -template<> -inline fapi2::Target<fapi2::TARGET_TYPE_MEM_PORT> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MEM_PORT>& - i_self) +template< fapi2::TargetType M, fapi2::TargetType T > +static inline fapi2::Target<M> find_target_impl( const fapi2::Target<T>& i_target, + std::true_type ) { - return i_self; + return i_target; } /// -/// @brief find the OCMB_CHIP given a OCMB_CHIP -/// @param[in] i_self the fapi2 target OCMB_CHIP -/// @return a OCMB_CHIP target. +/// @brief find an element based on a fapi2 target +/// @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 an M target. +/// @note Only works for valid parent-child relationships +/// Will work for MCA and DIMM +/// Will not work for MCS and DIMM +/// The compiler will let you know if it doesn't work /// -template<> -inline fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> find_target( const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& - i_self) +template< fapi2::TargetType M, fapi2::TargetType T > +inline fapi2::Target<M> find_target( const fapi2::Target<T>& i_target) { - return i_self; + return find_target_impl<M>(i_target, std::integral_constant<bool, M == T> {}); } /// @@ -160,7 +150,7 @@ inline fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP> find_target( const fapi2::Tar /// @return a McBIST target. /// template<> -inline fapi2::Target<fapi2::TARGET_TYPE_MCBIST> find_target( const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) +inline fapi2::Target<fapi2::TARGET_TYPE_MCBIST> find_target(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) { return i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_MCBIST>(); } @@ -171,7 +161,7 @@ inline fapi2::Target<fapi2::TARGET_TYPE_MCBIST> find_target( const fapi2::Target /// @return a DMI target. /// template<> -inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target) +inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target) { return i_target.getParent<fapi2::TARGET_TYPE_MEMBUF_CHIP>() .getParent<fapi2::TARGET_TYPE_DMI>() @@ -184,7 +174,7 @@ inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target( const fapi2::Tar /// @return a PROC_CHIP target. /// template<> -inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target( const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& +inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target(const fapi2::Target<fapi2::TARGET_TYPE_OCMB_CHIP>& i_target) { return i_target.getParent<fapi2::TARGET_TYPE_OMI>() @@ -198,48 +188,24 @@ inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target( const fapi2::Tar /// @return a DMI target. /// template<> -inline fapi2::Target<fapi2::TARGET_TYPE_DMI> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target) +inline fapi2::Target<fapi2::TARGET_TYPE_DMI> find_target(const fapi2::Target<fapi2::TARGET_TYPE_MBA>& i_target) { return i_target.getParent<fapi2::TARGET_TYPE_MEMBUF_CHIP>().getParent<fapi2::TARGET_TYPE_DMI>(); } /// -/// @brief find the DMI given a MEMBUF -/// @param[in] i_target the fapi2 target MEMBUF -/// @return a DMI target. -/// -template<> -inline fapi2::Target<fapi2::TARGET_TYPE_DMI> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP>& i_target) -{ - return i_target.getParent<fapi2::TARGET_TYPE_DMI>(); -} - -/// /// @brief find the PROC given a MEMBUF /// @param[in] i_target the fapi2 target MEMBUF /// @return a PROC target. /// template<> -inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target( const fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP>& +inline fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> find_target(const fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP>& i_target) { return i_target.getParent<fapi2::TARGET_TYPE_DMI>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>(); } /// -/// @brief find all the DMIs connected to an PROC_CHIP -/// @param[in] i_target a fapi2::Target DMI -/// @return a vector of fapi2::TARGET_TYPE_MBA -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_DMI> > -find_targets( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_DMI>(i_state); -} - -/// /// @brief find all the OCMB_CHIPs connected to a PROC_CHIP /// @param[in] i_target a fapi2::Target PROC_CHIP /// @return a vector of fapi2::TARGET_TYPE_OCMB_CHIP @@ -264,32 +230,6 @@ find_targets( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, } /// -/// @brief find all the MEMBUFs connected to an DMI -/// @param[in] i_target a fapi2::Target DMI -/// @return a vector of fapi2::TARGET_TYPE_MEMBUF_CHIP -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP> > -find_targets( const fapi2::Target<fapi2::TARGET_TYPE_DMI>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MEMBUF_CHIP>(i_state); -} - -/// -/// @brief find all the MBAs connected to an MEMBUF -/// @param[in] i_target a fapi2::Target MEMBUF_CHIP -/// @return a vector of fapi2::TARGET_TYPE_MBA -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MBA> > -find_targets( const fapi2::Target<fapi2::TARGET_TYPE_MEMBUF_CHIP>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MBA>(i_state); -} - -/// /// @brief find all the MBA connected to an DMI /// @param[in] i_target a fapi2::Target DMI /// @return a vector of fapi2::TARGET_TYPE_MBA @@ -343,7 +283,6 @@ find_targets( const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target, { std::vector< fapi2::Target<fapi2::TARGET_TYPE_DIMM> > l_dimms; - // At this time, fapi2 (cronus?) doesn't seem to recognize a DIMM is the child of an MCS. for (const auto& p : i_target.getChildren<fapi2::TARGET_TYPE_MCA>(i_state)) { auto l_these_dimms( p.getChildren<fapi2::TARGET_TYPE_DIMM>(i_state) ); @@ -375,176 +314,6 @@ find_targets( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target, } /// -/// @brief find all the MCS connected to a PROC_CHIP -/// @param[in] i_target a fapi2::Target PROC_CHIP -/// @return a vector of fapi2::TARGET_TYPE_MCS -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCS> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MCS>(i_state); -} - -/// -/// @brief find all the MCS connected to an MCBIST -/// @param[in] i_target a fapi2::Target MCBIST -/// @return a vector of fapi2::TARGET_TYPE_MCS -/// @note Cronus should support MCS children of an MCBIST - so this might be temporary -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCS> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target, - fapi2::TargetState i_state ) -{ - std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCS> > l_mcses; - - // At this time, fapi2 (cronus?) doesn't seem to recognize a MCS is the child of an MCBIST - for (const auto& p : i_target.getChildren<fapi2::TARGET_TYPE_MCA>(i_state)) - { - fapi2::Target<fapi2::TARGET_TYPE_MCS> l_mcs = p.getParent<fapi2::TARGET_TYPE_MCS>(); - - if ( l_mcses.end() == std::find_if( l_mcses.begin(), l_mcses.end(), - [l_mcs](const fapi2::Target<fapi2::TARGET_TYPE_MCS>& c) - { - return l_mcs == c; - }) ) - { - l_mcses.push_back(l_mcs); - } - } - - return l_mcses; -} - -/// -/// @brief find all the MCA connected to an MCBIST -/// @param[in] i_target a fapi2::Target MCBIST -/// @return a vector of fapi2::TARGET_TYPE_MCA -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MCA>(i_state); -} - -/// -/// @brief find all the MCA connected to an MCA -/// @param[in] i_target a fapi2::Target MCA -/// @return a vector of fapi2::TARGET_TYPE_MCA -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target, - fapi2::TargetState i_state ) -{ - // TODO - RTC:174905. Find out if we really need a find API that returns a vector of MCA from an MCA - std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > l_temp = {i_target}; - return l_temp; -} - -/// -/// @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<fapi2::TARGET_TYPE_MCA> > find_magic_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& 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<fapi2::Target<fapi2::TARGET_TYPE_MCA>> 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_TYPE_MCA>(fapi2::TARGET_STATE_PRESENT)) - { - if (mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(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<fapi2::TARGET_TYPE_MCA> -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > find_targets_with_magic -( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& 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<fapi2::TARGET_TYPE_MCA>(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<fapi2::TARGET_TYPE_MCA>(i_target); - const auto l_magic_pos = mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(l_magic_ports[0]); - const auto l_magic_port = std::find_if(l_ports.begin(), l_ports.end(), - [&l_magic_pos](const fapi2::Target<fapi2::TARGET_TYPE_MCA>& t) - { - // Check ports by relative position. - const auto l_pos = mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(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 find all the MCA connected to an MCS -/// @param[in] i_target a fapi2::Target MCS -/// @return a vector of fapi2::TARGET_TYPE_MCA -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MCA>(i_state); -} - -/// -/// @brief find all the DIMM connected to an MCA -/// @param[in] i_target a fapi2::Target MCA -/// @return a vector of fapi2::TARGET_TYPE_DIMM -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_DIMM> > find_targets -( const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_DIMM>(i_state); -} - -/// /// @brief find the MCS given a DIMM /// @param[in] i_target the fapi2 target DIMM /// @return a MCS target. @@ -556,19 +325,6 @@ inline fapi2::Target<fapi2::TARGET_TYPE_MCS> find_target( const fapi2::Target<fa } /// -/// @brief find all the MCBISTs connected to a PROC_CHIP -/// @param[in] i_target a fapi2::Target PROC_CHIP -/// @return a vector of fapi2::TARGET_TYPE_MCBIST -/// -template<> -inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCBIST> > find_targets( - const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target, - fapi2::TargetState i_state ) -{ - return i_target.getChildren<fapi2::TARGET_TYPE_MCBIST>(i_state); -} - -/// /// @brief find a key value from a vector of STL pairs /// @tparam T input type /// @tparam OT the output type to be returned @@ -676,30 +432,6 @@ bool find_value_from_key( const std::pair<T, OT> (&i_array)[N], return false; } -/// -/// @brief Determine if a thing is functional -/// @tparam P, the type of the parent which holds the things of interest -/// @tparam I, the type of the item we want to check for -/// @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<P>& 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<I>(fapi2::TARGET_STATE_FUNCTIONAL)) - { - if (mss::template relative_pos<P>(i) == i_rel_pos) - { - return true; - } - } - - return false; -} - }// mss #endif diff --git a/src/import/generic/memory/lib/utils/find_magic.H b/src/import/generic/memory/lib/utils/find_magic.H index 0e8a3f1ef..a67d4f2e8 100644 --- a/src/import/generic/memory/lib/utils/find_magic.H +++ b/src/import/generic/memory/lib/utils/find_magic.H @@ -22,3 +22,143 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ + +#ifndef _MSS_FIND_WITH_MAGIC_H +#define _MSS_FIND_WITH_MAGIC_H + +#include <fapi2.H> +#include <vector> +#include <generic/memory/lib/utils/pos.H> +#include <generic/memory/lib/utils/c_str.H> +#include <generic/memory/lib/utils/find.H> + +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<M> > find_targets_with_magic( const fapi2::Target<T>& 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<M> > find_magic_targets( const fapi2::Target<T>& 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<fapi2::TARGET_TYPE_MCA> > +find_magic_targets(const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& 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<fapi2::Target<fapi2::TARGET_TYPE_MCA>> 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_TYPE_MCA>(fapi2::TARGET_STATE_PRESENT)) + { + if (mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(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<fapi2::TARGET_TYPE_MCA> +/// +template<> +inline std::vector< fapi2::Target<fapi2::TARGET_TYPE_MCA> > +find_targets_with_magic( const fapi2::Target<fapi2::TARGET_TYPE_MCBIST>& 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<fapi2::TARGET_TYPE_MCA>(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<fapi2::TARGET_TYPE_MCA>(i_target); + const auto l_magic_pos = mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(l_magic_ports[0]); + const auto l_magic_port = std::find_if(l_ports.begin(), l_ports.end(), + [&l_magic_pos](const fapi2::Target<fapi2::TARGET_TYPE_MCA>& t) + { + // Check ports by relative position. + const auto l_pos = mss::relative_pos<fapi2::TARGET_TYPE_MCBIST>(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<P>& 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<I>(fapi2::TARGET_STATE_FUNCTIONAL)) + { + if (mss::template relative_pos<P>(i) == i_rel_pos) + { + return true; + } + } + + return false; +} + +}// mss + +#endif diff --git a/src/import/generic/memory/lib/utils/freq/mss_freq_scoreboard.H b/src/import/generic/memory/lib/utils/freq/mss_freq_scoreboard.H index 7b9adacdc..1cd31adc5 100644 --- a/src/import/generic/memory/lib/utils/freq/mss_freq_scoreboard.H +++ b/src/import/generic/memory/lib/utils/freq/mss_freq_scoreboard.H @@ -41,6 +41,7 @@ #include <generic/memory/lib/utils/freq/gen_mss_freq_traits.H> #include <generic/memory/lib/utils/c_str.H> #include <generic/memory/lib/utils/find.H> +#include <generic/memory/lib/utils/pos.H> namespace mss { diff --git a/src/import/generic/memory/lib/utils/index.H b/src/import/generic/memory/lib/utils/index.H index dc60b8c19..fde43f711 100644 --- a/src/import/generic/memory/lib/utils/index.H +++ b/src/import/generic/memory/lib/utils/index.H @@ -38,13 +38,10 @@ #include <fapi2.H> #include <generic/memory/lib/utils/shared/mss_generic_consts.H> -#include <generic/memory/lib/utils/pos.H> namespace mss { -// TODO Add mc_type template on mss::index API" - /// /// @brief Return an attribute array index from a fapi2 target /// @tparam T the fapi2::TargetType - derived @@ -52,55 +49,28 @@ namespace mss /// @return size_t the attribute array index. /// template< fapi2::TargetType T > -inline size_t index(const fapi2::Target<T>& i_target); - -/// -/// @brief Return an attribute array index from a DIMM target -/// @param[in] i_target a DIMM target representing the DIMM in question -/// @return size_t the attribute array index. -/// -template<> -inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) +inline size_t index(const fapi2::Target<T>& i_target) { - typedef procTraits<proc_type::NIMBUS> TT; - return mss::pos(i_target) % TT::DIMMS_PER_PORT; -} + // Unrolled c_str to avoid a circular include + char l_c_str_storage[fapi2::MAX_ECMD_STRING_LEN] = {}; + fapi2::toString( i_target, l_c_str_storage, fapi2::MAX_ECMD_STRING_LEN ); -/// -///@brief Return an attribute array index from a MCA target -/// @param[in] i_target a MCA target representing the MCA in question -/// @return size_t the attribute array index. -/// -template<> -inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return mss::pos(i_target) % TT::PORTS_PER_MCS; -} + uint8_t l_pos = 0; -/// -/// @brief Return an attribute array index from a MCS target -/// @param[in] i_target a MCS target representing the MCS in question -/// @return size_t the attribute array index. -/// -template<> -inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return mss::pos(i_target) % TT::MCS_PER_MC; -} + // Don't use FAPI_TRY as you'll mess up fapi2::current_err which + // lmits where this can be used. + if (FAPI_ATTR_GET(fapi2::ATTR_REL_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) + { + goto fapi_try_exit; + } -/// -/// @brief Return an attribute array index from a OCMB target -/// @param[in] i_target a MEM_PORT target representing the OCMB in question -/// @return size_t the attribute array index. -/// -template<> -inline size_t index(const fapi2::Target<fapi2::TARGET_TYPE_MEM_PORT>& i_target) -{ - typedef procTraits<proc_type::AXONE> TT; - // We may need to revisit this later if we get an OCMB that has more than one port. - return mss::pos(i_target) % TT::EXP_PORTS_PER_OCMB; + return l_pos; + +fapi_try_exit: + // If we can't get our relative position, we're in other trouble + FAPI_ERR("can't get ATTR_REL_POS for %s", l_c_str_storage); + fapi2::Assert(false); + return 0; } /// diff --git a/src/import/generic/memory/lib/utils/memory_size.H b/src/import/generic/memory/lib/utils/memory_size.H index dc2e73cc7..bf57c3d43 100644 --- a/src/import/generic/memory/lib/utils/memory_size.H +++ b/src/import/generic/memory/lib/utils/memory_size.H @@ -37,20 +37,11 @@ #define _MSS_EFF_MEMORY_SIZE_H_ #include <fapi2.H> +#include <generic/memory/lib/utils/shared/mss_generic_consts.H> #include <generic/memory/lib/utils/find.H> namespace mss { -/// -/// @brief Check if a given DIMM is functional -/// @param[in] i_valid_dimm_bitmap from ATTR_CEN_MSS_EFF_DIMM_FUNCTIONAL_VECTOR -/// @param[in] i_port port index [0:1] -/// @param[in] i_dimm dimm index [0:1] -/// @return true if dimm is functional, false otherwise -/// -bool is_dimm_functional(const uint8_t i_valid_dimm_bitmap, - const uint8_t i_port, - const uint8_t i_dimm); /// /// @brief Return the total memory size behind the target diff --git a/src/import/generic/memory/lib/utils/pos.H b/src/import/generic/memory/lib/utils/pos.H index be82d5385..b04e965f2 100644 --- a/src/import/generic/memory/lib/utils/pos.H +++ b/src/import/generic/memory/lib/utils/pos.H @@ -28,7 +28,7 @@ /// @brief Tools to return target's position from a fapi2 target /// // *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com> -// *HWP HWP Backup: Jacob Harvey <jlharvey@us.ibm.com> +// *HWP HWP Backup: Louis Stermole <stermole@us.ibm.com> // *HWP Team: Memory // *HWP Level: 3 // *HWP Consumed by: HB:FSP @@ -39,8 +39,6 @@ #include <fapi2.H> #include <generic/memory/lib/utils/shared/mss_generic_consts.H> -// TODO Add mc_type template on mss::pos API" - /// /// @brief Trait classes for the mss::pos functions /// @@ -89,7 +87,7 @@ inline typename TT::pos_type pos(const fapi2::Target<T>& i_target) typename TT::pos_type l_pos = 0; // Don't use FAPI_TRY as you'll mess up fapi2::current_err which - // lmits where this can be used. + // limits where this can be used. if (FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) { goto fapi_try_exit; @@ -134,130 +132,32 @@ fapi_try_exit: /// @brief Return a DIMM's position from a fapi2 target /// @param[in] i_target a target representing the target in question /// @return The position relative to the chip -/// @warning Nimbus implementation only +/// @warning assumes this attr is already set after pre_eff_config /// -template<> inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) { - typedef posTraits<fapi2::TARGET_TYPE_DIMM> TT; - typedef procTraits<proc_type::NIMBUS> T; - - // Proc 0 is DIMM 0-15, proc 2 is 64-79 - 64 is the stride between processors - constexpr uint64_t DIMM_STRIDE_PER_PROC = 64; - constexpr uint64_t TOTAL_DIMM = T::MC_PER_MODULE * T::MCS_PER_MC * T::PORTS_PER_MCS * T::DIMMS_PER_PORT; - - TT::pos_type l_pos = 0; - - // Using fapi2 rather than mss::find as this is pretty low level stuff. - const auto l_proc_pos = - mss::template pos(i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>()); + posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type l_pos = 0; + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_MEM_DIMM_POS_METADATA, i_target, l_pos)); - if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) - { - goto fapi_try_exit; - } - - // To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos value - // to the processor (stride across which ever processor we're on) and then add in the delta - // per processor as ATTR_POS isn't processor relative (delta is the total dimm on a processor) - return ((l_pos - (l_proc_pos * DIMM_STRIDE_PER_PROC)) % TOTAL_DIMM) + (TOTAL_DIMM * l_proc_pos); + return l_pos; fapi_try_exit: // If we can't get our position, we're in other trouble - FAPI_ERR("can't get our fapi position"); + FAPI_ERR("can't get our dimm position"); fapi2::Assert(false); return 0; } /// /// @brief Return a target's relative position from a fapi2 target -/// @tparam T the fapi2::TargetType /// @tparam R the fapi2::TargetType we want the position relative to +/// @tparam T the fapi2::TargetType /// @param[in] i_target a target representing the target in question /// @return The position relative to chiplet R /// template< fapi2::TargetType R, fapi2::TargetType T, typename TT = posTraits<T> > -inline typename TT::pos_type relative_pos(const fapi2::Target<T>& i_target); - -/// -/// @brief Return a MCA's relative position from an MCBIST -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_MCA>::pos_type -relative_pos<fapi2::TARGET_TYPE_MCBIST>(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target) -{ - - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::PORTS_PER_MCBIST; -} - -/// -/// @brief Return a DIMM's relative position from an MCS -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type -relative_pos<fapi2::TARGET_TYPE_MCS>(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::DIMMS_PER_MCS; -} - -/// -/// @brief Return a DIMM's relative position from an MCA -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type -relative_pos<fapi2::TARGET_TYPE_MCA>(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::DIMMS_PER_PORT; -} - -/// -/// @brief Return a DIMM's relative position from an MCBIST -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type -relative_pos<fapi2::TARGET_TYPE_MCBIST>(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::DIMMS_PER_MCBIST; -} - -/// -/// @brief Return an MCS's relative position from a processor -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_MCS>::pos_type -relative_pos<fapi2::TARGET_TYPE_PROC_CHIP>(const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::MCS_PER_PROC; -} - -/// -/// @brief Return an MCA's relative position from an MCS -/// @param[in] i_target a target representing the target in question -/// @return The position relative to chiplet R -/// -template<> -inline posTraits<fapi2::TARGET_TYPE_MCA>::pos_type -relative_pos<fapi2::TARGET_TYPE_MCS>(const fapi2::Target<fapi2::TARGET_TYPE_MCA>& i_target) -{ - typedef procTraits<proc_type::NIMBUS> TT; - return pos(i_target) % TT::PORTS_PER_MCS; -} +typename TT::pos_type relative_pos(const fapi2::Target<T>& i_target); /// /// @brief Return a target's fapi position from a fapi2 target @@ -271,7 +171,7 @@ inline uint32_t fapi_pos(const fapi2::Target<T>& i_target) uint32_t l_pos = 0; // Don't use FAPI_TRY as you'll mess up fapi2::current_err which - // lmits where this can be used. + // limits where this can be used. if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) { goto fapi_try_exit; @@ -286,6 +186,5 @@ fapi_try_exit: return 0; } - } #endif diff --git a/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H b/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H index 17fe87ac4..f7f2338fb 100644 --- a/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H +++ b/src/import/generic/memory/lib/utils/shared/mss_generic_consts.H @@ -164,7 +164,10 @@ enum generic_ffdc_codes SET_SI_ODT_WR = 0x1059, SET_SI_ODT_RD = 0x1060, SET_SI_GEARDOWN_MODE = 0x1061, - PRE_DATA_ENGINE_CTOR = 0x1062 + PRE_DATA_ENGINE_CTOR = 0x1062, + SET_DRAM_GEN_METADATA = 0x1063, + SET_DIMM_TYPE_METADATA = 0x1064, + SET_DIMM_POS_METADATA = 0x1065, }; /// @@ -343,16 +346,17 @@ enum class throttle_type }; /// -/// @brief Trait classes for proc_type +/// @brief Trait classes for mc_type +/// @tparam MC the mc_type /// -template< proc_type P > -class procTraits; +template< mc_type MC > +class mcTypeTraits; /// -/// @brief Trait classes for proc_type - NIMBUS specialization +/// @brief Trait classes for mc_type - NIMBUS specialization /// template< > -struct procTraits<proc_type::NIMBUS> +struct mcTypeTraits<mc_type::NIMBUS> { enum { @@ -368,15 +372,19 @@ struct procTraits<proc_type::NIMBUS> }; /// -/// @brief Trait classes for proc_type - AXONE specialization +/// @brief Trait classes for mc_type - EXPLORER specialization /// -/// TODO: Need to add mc_type template< > -struct procTraits<proc_type::AXONE> +struct mcTypeTraits<mc_type::EXPLORER> { enum { - EXP_PORTS_PER_OCMB = 1, + MC_PER_PROC = 2, + MI_PER_MC = 2, + MCC_PER_MI = 2, + OMI_PER_MCC = 2, + OCMB_PER_OMI = 1, + PORTS_PER_OCMB = 1, DIMMS_PER_PORT = 2, }; }; diff --git a/src/import/generic/memory/lib/utils/voltage/gen_mss_volt.H b/src/import/generic/memory/lib/utils/voltage/gen_mss_volt.H index 284995546..1b74f0028 100644 --- a/src/import/generic/memory/lib/utils/voltage/gen_mss_volt.H +++ b/src/import/generic/memory/lib/utils/voltage/gen_mss_volt.H @@ -37,8 +37,9 @@ #define _GEN_MSS_VOLT_H_ #include <fapi2.H> -#include <generic/memory/lib/utils/find.H> #include <generic/memory/lib/utils/shared/mss_generic_consts.H> +#include <generic/memory/lib/utils/find.H> +#include <generic/memory/lib/utils/c_str.H> #include <generic/memory/lib/utils/voltage/gen_mss_voltage_traits.H> namespace mss |