From 4b9dc024e961a5b230a9cf345fb6a7cfdf73cf63 Mon Sep 17 00:00:00 2001 From: Mark Pizzutillo Date: Tue, 22 Oct 2019 17:29:46 -0400 Subject: Add assert for RSP extended data buffer size in exp_draminit Change-Id: If924286f31c31bb66b5191d51afce43c8a1e50d2 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/85774 Tested-by: FSP CI Jenkins Tested-by: Jenkins Server Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Louis Stermole Reviewed-by: STEPHEN GLANCY Dev-Ready: STEPHEN GLANCY Reviewed-by: Jennifer A Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/85790 Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Daniel M Crowell --- .../procedures/hwp/memory/lib/exp_draminit_utils.C | 89 ++++++++++++++++++++-- .../procedures/hwp/memory/lib/exp_draminit_utils.H | 13 ++++ 2 files changed, 96 insertions(+), 6 deletions(-) (limited to 'src/import/chips/ocmb/explorer/procedures/hwp/memory') diff --git a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.C b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.C index de8d0cfad..bb4595806 100644 --- a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.C +++ b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.C @@ -43,6 +43,61 @@ namespace mss namespace exp { +/// +/// @brief Check that the rsp_data size returned from the PHY_INIT command matches the expected size +/// +/// @param[in] i_target OCMB target +/// @param[in] i_actual_size size enum expected for the given phy init mode +/// @param[in] i_mode phy init mode. Expected to be a valid enum value since we asserted as such in exp_draminit.C +/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff matching, else MSS_EXP_INVALID_PHY_INIT_RSP_DATA_LENGTH +/// +fapi2::ReturnCode check_rsp_data_size( + const fapi2::Target& i_target, + const uint16_t i_actual_size, + const phy_init_mode i_mode) +{ + uint16_t l_expected_size = 0; + + switch (i_mode) + { + case phy_init_mode::NORMAL: + l_expected_size = sizeof(user_response_msdg_t); + break; + + case phy_init_mode::EYE_CAPTURE_STEP_1: + l_expected_size = sizeof(user_2d_eye_response_1_msdg_t); + break; + + case phy_init_mode::EYE_CAPTURE_STEP_2: + l_expected_size = sizeof(user_2d_eye_response_2_msdg_t); + break; + + default: + // This really can't occur since we asserted phy_init_mode was valid in exp_draminit.C + // We have bigger problems if we get here, implying somehow this bad value was passed to explorer + FAPI_ASSERT(false, + fapi2::MSS_EXP_UNKNOWN_PHY_INIT_MODE() + .set_TARGET(i_target) + .set_VALUE(i_mode), + "%s Value for phy init mode for exp_draminit is unknown: %u expected 0 (NORMAL), 1 (EYE_CAPTURE_STEP_1), 2 (EYE_CAPTURE_STEP_2)", + mss::c_str(i_target), i_mode); + break; + } + + FAPI_ASSERT(l_expected_size == i_actual_size, + fapi2::MSS_EXP_INVALID_PHY_INIT_RSP_DATA_LENGTH() + .set_OCMB_TARGET(i_target) + .set_PHY_INIT_MODE(i_mode) + .set_EXPECTED_LENGTH(l_expected_size) + .set_ACTUAL_LENGTH(i_actual_size), + "%s PHY INIT response data buffer size 0x%x did not match expected size 0x%x for phy_init_mode %u", + mss::c_str(i_target), i_actual_size, l_expected_size, i_mode); + + return fapi2::FAPI2_RC_SUCCESS; +fapi_try_exit: + return fapi2::current_err; +} + /// /// @brief Perform normal host FW phy init /// @@ -60,6 +115,8 @@ fapi2::ReturnCode host_fw_phy_normal_init(const fapi2::Target 0, data exists in the extended data buffer. Must set cmd_flags to 1. However, + // eye capture step 2 needs cmd_flags to be set to zero as defined in MCHP spec section 5.4.3 Eye Capture + // despite having data in the extended data buffer + o_cmd.cmd_flags = ((i_cmd_length > 0) && (i_phy_init_mode != phy_init_mode::EYE_CAPTURE_STEP_2)) ? 1 : 0; o_cmd.cmd_length = i_cmd_length; o_cmd.cmd_crc = i_cmd_data_crc; diff --git a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.H b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.H index 39598303d..1e279f766 100644 --- a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.H +++ b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/exp_draminit_utils.H @@ -161,6 +161,19 @@ enum odt_fields RANK0 = 0, }; +/// +/// @brief Check that the rsp_data size returned from the PHY_INIT command matches the expected size +/// +/// @param[in] i_target OCMB target +/// @param[in] i_actual_size size enum expected for the given phy init mode +/// @param[in] i_mode phy init mode. Expected to be a valid enum value since we asserted as such in exp_draminit.C +/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff matching, else MSS_EXP_INVALID_PHY_INIT_RSP_DATA_LENGTH +/// +fapi2::ReturnCode check_rsp_data_size( + const fapi2::Target& i_target, + const uint16_t i_actual_size, + const phy_init_mode i_mode); + /// /// @brief Perform normal host FW phy init /// -- cgit v1.2.1