From 44d0f070400aabde3a06eb7b836923577a117cc0 Mon Sep 17 00:00:00 2001 From: Roland Veloz Date: Mon, 4 Dec 2017 17:37:05 -0600 Subject: Handles FSP reset-reload in HBRT messages For every instance where a firmware_request is made, it is possible to get an error if the FSP is doing a reset/reload. Now, if an error returned from the firmware_request call indicates that the FSP is doing a reset/reload, the firmware_request call will be made again. Also refactored the code. Consolidated the calls to firmware_request to another file to facilitate the adding/updating of messages. Change-Id: I5be440927ab255c55b40a0a0ed26f786d31a9317 RTC:182606 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/50505 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Reviewed-by: Daniel M. Crowell --- src/usr/isteps/pm/runtime/rt_pm.C | 139 +++--- .../isteps/pm/runtime/test/firmwareRequestTest.H | 11 +- src/usr/isteps/tod/runtime/makefile | 4 +- src/usr/isteps/tod/runtime/rt_todintf.C | 465 ++++++++------------- 4 files changed, 237 insertions(+), 382 deletions(-) (limited to 'src/usr/isteps') diff --git a/src/usr/isteps/pm/runtime/rt_pm.C b/src/usr/isteps/pm/runtime/rt_pm.C index 33d2014d1..ecddab2a2 100644 --- a/src/usr/isteps/pm/runtime/rt_pm.C +++ b/src/usr/isteps/pm/runtime/rt_pm.C @@ -28,16 +28,19 @@ #include #include #include + #include #include #include #include -#include +#include // g_hostInterfaces +#include // firmware_request_helper #include #include + #include // targeting support @@ -49,6 +52,7 @@ using namespace TARGETING; using namespace RUNTIME; +using namespace ERRORLOG; namespace ISTEPS_TRACE { @@ -342,6 +346,7 @@ namespace RTPM "/firmware_request interface not linked"); /*@ * @errortype + * @severity ERRL_SEV_INFORMATIONAL * @moduleid MOD_PM_RT_HCODE_UPDATE * @reasoncode RC_PM_RT_INTERFACE_ERR * @userdata1[0:31] Target HUID @@ -350,14 +355,13 @@ namespace RTPM * @devdesc HCODE scom update runtime * interface not linked. */ - l_err= new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PM_RT_HCODE_UPDATE, - RC_PM_RT_INTERFACE_ERR, - TWO_UINT32_TO_UINT64( - TARGETING::get_huid(i_target), - i_section), - i_rel_scom_addr); + l_err= new ErrlEntry(ERRL_SEV_INFORMATIONAL, + MOD_PM_RT_HCODE_UPDATE, + RC_PM_RT_INTERFACE_ERR, + TWO_UINT32_TO_UINT64( + TARGETING::get_huid(i_target), + i_section), + i_rel_scom_addr); break; } @@ -411,32 +415,37 @@ namespace RTPM TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK"hcode_update: " "HCODE scom update failed. " - "rc 0x%X target 0x%llX chipId 0x%llX section 0x%X " - "operation 0x%X scomAddr 0x%llX scomData 0x%llX", + "rc: 0x%X, target: 0x%llX, chipId: 0x%llX, " + "section: 0x%X, operation: 0x%X, scomAddr: 0x%llX, " + "scomData: 0x%llX", rc, get_huid(i_target), l_chipId, i_section, i_operation, l_scomAddr, i_scom_data); - // convert rc to error log /*@ * @errortype + * @severity ERRL_SEV_INFORMATIONAL * @moduleid MOD_PM_RT_HCODE_UPDATE * @reasoncode RC_PM_RT_HCODE_UPDATE_ERR * @userdata1 Hypervisor return code * @userdata2 SCOM address * @devdesc HCODE SCOM update error */ - l_err=new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PM_RT_HCODE_UPDATE, - RC_PM_RT_HCODE_UPDATE_ERR, - rc, - l_scomAddr); + l_err = new ErrlEntry( ERRL_SEV_INFORMATIONAL, + MOD_PM_RT_HCODE_UPDATE, + RC_PM_RT_HCODE_UPDATE_ERR, + rc, + l_scomAddr); break; } } else if (g_hostInterfaces->firmware_request != nullptr) { + // Create the firmware_request request struct to send data hostInterfaces::hbrt_fw_msg l_req_fw_msg; + uint64_t l_req_fw_msg_size = sizeof(l_req_fw_msg); + memset(&l_req_fw_msg, 0, l_req_fw_msg_size); + + // Populate the firmware_request request struct with given data l_req_fw_msg.io_type = hostInterfaces::HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE; l_req_fw_msg.req_hcode_update.i_chipId = l_chipId; @@ -445,82 +454,35 @@ namespace RTPM l_req_fw_msg.req_hcode_update.i_scomAddr = l_scomAddr; l_req_fw_msg.req_hcode_update.i_scomData = i_scom_data; + // Trace out firmware request info + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + INFO_MRK"HCODE update firmware request info: " + "io_type:%d, chipId:0x%llX, section:0x%X, " + "operation:0x%X, scomAddr:0x%llX, scomData:0x%llX", + l_req_fw_msg.io_type, + l_req_fw_msg.req_hcode_update.i_chipId, + l_req_fw_msg.req_hcode_update.i_section, + l_req_fw_msg.req_hcode_update.i_operation, + l_req_fw_msg.req_hcode_update.i_scomAddr, + l_req_fw_msg.req_hcode_update.i_scomData); + + // Create the firmware_request response struct to receive data hostInterfaces::hbrt_fw_msg l_resp_fw_msg; uint64_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg); - rc = g_hostInterfaces->firmware_request(sizeof(l_req_fw_msg), - &l_req_fw_msg, &l_resp_fw_msg_size, &l_resp_fw_msg); - if(rc) - { - TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, - ERR_MRK"firmware request: " - "firmware request for hcode scom update failed. " - "rc 0x%X target 0x%llX chipId 0x%llX section 0x%X " - "operation 0x%X scomAddr 0x%llX scomData 0x%llX", - rc, get_huid(i_target), l_chipId, i_section, - i_operation, l_scomAddr, i_scom_data); + memset(&l_resp_fw_msg, 0, l_resp_fw_msg_size); - // convert rc to error log - /*@ - * @errortype - * @moduleid MOD_PM_RT_FIRMWARE_REQUEST - * @reasoncode RC_PM_RT_HCODE_UPDATE_ERR - * @userdata1[0:31] Firmware Request return code - * @userdata1[32:63] SCOM address - * @userdata2[0:31] Generic response code - if it exists - * @userdata2[32:63] Firmware Response type - * @devdesc Firmware Request for - * HCODE SCOM update error - */ - // - // Pack the generic response code if the response - // is of type "RESP_GENERIC" - // else just send the response type alone - uint64_t l_userData2 = 0; - if (l_resp_fw_msg_size >= - hostInterfaces::HBRT_FW_MSG_BASE_SIZE) - { - // just assign the response type for now - l_userData2 = l_resp_fw_msg.io_type; - - // Pack the response code if it is available - if ((l_resp_fw_msg_size >= - (hostInterfaces::HBRT_FW_MSG_BASE_SIZE + - sizeof(l_resp_fw_msg.resp_generic))) && - hostInterfaces::HBRT_FW_MSG_TYPE_RESP_GENERIC == - l_resp_fw_msg.io_type) - { - l_userData2 = TWO_UINT32_TO_UINT64 - (l_resp_fw_msg.resp_generic.o_status, - l_resp_fw_msg.io_type); - } - } - - l_err=new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_INFORMATIONAL, - MOD_PM_RT_FIRMWARE_REQUEST, - RC_PM_RT_HCODE_UPDATE_ERR, - TWO_UINT32_TO_UINT64(rc, l_scomAddr), - l_userData2); - - if (l_resp_fw_msg_size > 0) - { - l_err->addFFDC( ISTEP_COMP_ID, - &l_resp_fw_msg, - l_resp_fw_msg_size, - 0, 0, false ); - } - - if (sizeof(l_req_fw_msg) > 0) - { - l_err->addFFDC( ISTEP_COMP_ID, - &l_req_fw_msg, - sizeof(l_req_fw_msg), - 0, 0, false ); - } + // Make the firmware_request call + l_err = firmware_request_helper(l_req_fw_msg_size, + &l_req_fw_msg, + &l_resp_fw_msg_size, + &l_resp_fw_msg); + if (l_err) + { + // If error, break out of encompassing while loop break; } - } + } // END else if (g_hostInterfaces->firmware_request != nullptr) // Disable special wakeup l_err = handleSpecialWakeup(i_target,false); @@ -572,3 +534,4 @@ namespace RTPM registerPm g_registerPm; }; + diff --git a/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H b/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H index 01085dbae..2e2abe25e 100644 --- a/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H +++ b/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H @@ -187,7 +187,8 @@ class FirmwareRequestTest : public CxxTest::TestSuite hostInterfaces::hbrt_fw_msg l_req_fw_msg; l_req_fw_msg.generic_msg.initialize(); - if (l_req_fw_msg.generic_msg.magic != GFMM_MAGIC_NUMBER) + if (l_req_fw_msg.generic_msg.magic != + GenericFspMboxMessage_t::MAGIC_NUMBER) { TS_FAIL("FirmwareRequestTest::testFirmwareRequestHbrtToFsp: " "magic was not properly initialized"); @@ -200,7 +201,8 @@ class FirmwareRequestTest : public CxxTest::TestSuite "dataSize was not properly initialized"); } - if (l_req_fw_msg.generic_msg.structVer != GFMM_VERSION) + if (l_req_fw_msg.generic_msg.structVer != + GenericFspMboxMessage_t::STRUCT_VERSION_LATEST) { TS_FAIL("FirmwareRequestTest::testFirmwareRequestHbrtToFsp: " "structVer was not properly initialized"); @@ -220,8 +222,9 @@ class FirmwareRequestTest : public CxxTest::TestSuite l_req_fw_msg.generic_msg.seqnum = 0x300; l_req_fw_msg.generic_msg.msgq = 0x400; l_req_fw_msg.generic_msg.msgType = 0x500; - l_req_fw_msg.generic_msg.__req = GFMM_REQUEST; - l_req_fw_msg.generic_msg.__onlyError = GFMM_ERROR_ONLY; + l_req_fw_msg.generic_msg.__req = GenericFspMboxMessage_t::REQUEST; + l_req_fw_msg.generic_msg.__onlyError = + GenericFspMboxMessage_t::ERROR_ONLY; uint32_t l_plid = 0x600; uint32_t l_huid = 0x700; l_req_fw_msg.generic_msg.data = diff --git a/src/usr/isteps/tod/runtime/makefile b/src/usr/isteps/tod/runtime/makefile index 5c65fd3ff..2d7946358 100644 --- a/src/usr/isteps/tod/runtime/makefile +++ b/src/usr/isteps/tod/runtime/makefile @@ -30,7 +30,9 @@ ROOTPATH = ../../../../.. MODULE = tod_rt EXTRAINCDIR += ${ROOTPATH}/src/usr/isteps/tod -EXTRAINCDIR += ${ROOTPATH}/src/include/usr/isteps/ +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/isteps +EXTRAINCDIR += ${ROOTPATH}/src/usr/errl +#EXTRAINCDIR += ${ROOTPATH}/src/include/usr/util OBJS += rt_todintf.o diff --git a/src/usr/isteps/tod/runtime/rt_todintf.C b/src/usr/isteps/tod/runtime/rt_todintf.C index c79419604..180049d18 100644 --- a/src/usr/isteps/tod/runtime/rt_todintf.C +++ b/src/usr/isteps/tod/runtime/rt_todintf.C @@ -28,8 +28,13 @@ #include // GETHUID #include // getMaxProcsOnSystem -#include // g_hostInterfaces -#include // TOD_RT_TOPOLOGY_RESET_BACKUP, etc +#include // g_hostInterfaces +#include // firmware_request_helper +#include // TOD_RT_TOPOLOGY_RESET_BACKUP, etc +#include // errlCommit + + +using namespace ERRORLOG; namespace TOD { @@ -51,38 +56,42 @@ errlHndl_t resetBackupTopology( TOD_ENTER("resetBackupTopology"); errlHndl_t l_err = nullptr; - // Put the handle to the firmware request out here - // so it is easier to free later + // Put the handle to the firmware_request request struct + // out here so it is easier to free later hostInterfaces::hbrt_fw_msg *l_req_fw_msg = nullptr; + hostInterfaces::hbrt_fw_msg *l_resp_fw_msg = nullptr; do { if ((nullptr == g_hostInterfaces) || (nullptr == g_hostInterfaces->firmware_request)) { + TOD_ERR("resetBackupTopology: " + "Hypervisor firmware_request interface not linked"); + /*@ * @errortype - * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE - * @moduleid TOD::TOD_RT_TOPOLOGY_RESET_BACKUP - * @reasoncode TOD::TOD_RT_NULL_FIRMWARE_REQUEST_PTR + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid TOD_RT_TOPOLOGY_RESET_BACKUP + * @reasoncode TOD_RT_NULL_FIRMWARE_REQUEST_PTR + * @userdata1 None + * @userdata2 None * @devdesc Host interfaces are not initialized - * @custdesc An internal error occurred. This will force the - * Time of Day function to run with complete - * redundancy. + * @custdesc An internal error occurred. This will + * force the Time of Day function to run + * with complete redundancy. */ - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - TOD::TOD_RT_TOPOLOGY_RESET_BACKUP, - TOD::TOD_RT_NULL_FIRMWARE_REQUEST_PTR, + l_err = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, + TOD_RT_TOPOLOGY_RESET_BACKUP, + TOD_RT_NULL_FIRMWARE_REQUEST_PTR, 0, 0, true); break; } - // First, I'll present the format of the data - // to help with the understanding of the code that follows // The format of the data to be sent, according to the document // "Handle PRD Request for resetting backup TOD topology" is as follows + // All data members below are 4 bytes long (32 bits) // Ordinal ID - 0xFFFFFFFF means no OSC to be avoided // HUID of the node - This field should be considered only if Ordinal // ID is NOT set to 0xFFFFFFFF otherwise it is set @@ -90,82 +99,89 @@ errlHndl_t resetBackupTopology( // HUID of the first processor // HUID of the second processor, etc + // Check if we get conflicting data, if so send a Trace out + if ((0xFFFFFFFF == i_oscPos) && (nullptr != i_procOscTgt)) + { + TOD_ERR("Conflicting input data, input oscillator position " + "(i_oscPos) has value 0xFFFFFFFF, meaning no oscillator " + "to be avoided but input oscillator target (i_procOscTgt) " + "has a valid value" ); + } + else if ((0xFFFFFFFF != i_oscPos) && (nullptr == i_procOscTgt)) + { + TOD_ERR("Conflicting input data, input oscillator position " + "(i_oscPos) has value 0x%X, meaning avoid oscillator " + "but input oscillator target (i_procOscTgt) " + "has a NULL value", i_oscPos); + } // Flag to determine if the OSC data will be added to the data bool l_addOscData = (0xFFFFFFFF != i_oscPos) && (nullptr != i_procOscTgt); - // Calculate the size of the data that is being added to the - // generic struct - size_t l_data_size = 0; + // Default the request data size to the size of the + // GenericFspMboxMessage_t minus the size of the + // GenericFspMboxMessage_t's data. The size of the + // GenericFspMboxMessage_t's data will be added later + uint32_t l_req_data_size = sizeof(GenericFspMboxMessage_t) - + sizeof(GenericFspMboxMessage_t::data); - // Add to the size iff there is data needing to be passed + // Add to the request data size iff there is data needing to be passed if (i_badChipList.size() > 0) { // if the bad chip list has any items then increase size to // accommodate for an ordinal ID and a HUID, regardless if // they have relevant data or not, because they are expected // before the HUID list. - l_data_size += (MSG_OSC_SIZE_OF_DETAILS * sizeof(uint32_t)) + - (i_badChipList.size() * sizeof(uint32_t)); + l_req_data_size += (MSG_OSC_SIZE_OF_DETAILS * sizeof(uint32_t)) + + (i_badChipList.size() * sizeof(uint32_t)); } else if (l_addOscData) { // if there is a valid OSC then accommodate for an ordinal ID // and HUID of node, but don't need space for HUID list because, // if we are here, the list is empty - l_data_size += (MSG_OSC_SIZE_OF_DETAILS * sizeof(uint32_t)); + l_req_data_size += (MSG_OSC_SIZE_OF_DETAILS * sizeof(uint32_t)); } - // Update the data size with the size of the generic msg struct - if (l_data_size < sizeof(hostInterfaces::hbrt_fw_msg::generic_msg.data)) - { - // If the current size of the data is less than the size of the - // data within the generic message (GenericFspMboxMessage_t.data), - // then default the data size to just the generic message because - // the size of the data to be passed in - // GenericFspMboxMessage_t.dataSize has be at the minimum - the - // size of the generic message (sizeof(GenericFspMboxMessage_t)). - l_data_size = sizeof(hostInterfaces::hbrt_fw_msg::generic_msg); - } - else + // The request data size must be at a minimum the size of the + // FSP generic message (sizeof(GenericFspMboxMessage_t)) + if (l_req_data_size < sizeof(GenericFspMboxMessage_t)) { - // If the current size of the data is greater than the size of the - // data within the generic message (GenericFspMboxMessage_t.data), - // then add the size of the generic message minus the size of - // generic message's data. - l_data_size += sizeof(hostInterfaces::hbrt_fw_msg::generic_msg) - - sizeof(hostInterfaces::hbrt_fw_msg::generic_msg.data); + l_req_data_size = sizeof(GenericFspMboxMessage_t); } - // At last. Calculate the TOTAL size of hostInterfaces::hbrt_fw_msg - // which means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to - // the previous calculated data size - size_t l_req_fw_msg_size = hostInterfaces::HBRT_FW_MSG_BASE_SIZE + - l_data_size; + // Calculate the TOTAL size of hostInterfaces::hbrt_fw_msg which + // means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to + // the previous calculated request data size + uint64_t l_req_fw_msg_size = hostInterfaces::HBRT_FW_MSG_BASE_SIZE + + l_req_data_size; - // Create the firmware request structure to carry the TOD data - l_req_fw_msg =(hostInterfaces::hbrt_fw_msg *)malloc(l_req_fw_msg_size); + // Create the firmware_request request struct to send data + l_req_fw_msg = + (hostInterfaces::hbrt_fw_msg *)malloc(l_req_fw_msg_size); - // Set the data for the request - l_req_fw_msg->io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; + // Initialize the firmware_request request struct l_req_fw_msg->generic_msg.initialize(); - l_req_fw_msg->generic_msg.dataSize = l_data_size; + + // Populate the firmware_request request struct with given data + l_req_fw_msg->io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; + l_req_fw_msg->generic_msg.dataSize = l_req_data_size; l_req_fw_msg->generic_msg.msgq = MBOX::FSP_TOD_MSGQ; l_req_fw_msg->generic_msg.msgType = (false == i_informPhyp ? - GFMM_MSG_TOD_BACKUP_RESET: - GFMM_MSG_TOD_BACKUP_RESET_INFORM_PHYP); - l_req_fw_msg->generic_msg.__req = GFMM_REQUEST; - l_req_fw_msg->generic_msg.__onlyError = GFMM_NOT_ERROR_ONLY; + GenericFspMboxMessage_t::MSG_TOD_BACKUP_RESET: + GenericFspMboxMessage_t::MSG_TOD_BACKUP_RESET_INFORM_PHYP); + l_req_fw_msg->generic_msg.__req = GenericFspMboxMessage_t::REQUEST; // A convenient way to populate the data - uint32_t* l_dataPtr = (uint32_t*)&(l_req_fw_msg->generic_msg.data); + uint32_t* l_dataPtr = + reinterpret_cast(&(l_req_fw_msg->generic_msg.data)); if (i_badChipList.size() > 0) { // set the ordinal ID l_dataPtr[MSG_OSC_ORDINAL_ID_LOC] = i_oscPos; - // attach the HUIDs from bad chip list to end of structure + // attach the HUIDs from bad chip list to end of struct size_t i = MSG_OSC_HUIDS_LOC; for (auto l_target : i_badChipList) { @@ -194,120 +210,59 @@ errlHndl_t resetBackupTopology( { /*@ * @errortype - * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE - * @moduleid TOD::TOD_RT_TOPOLOGY_RESET_BACKUP - * @reasoncode TOD::TOD_INVALID_TARGET - * @devdesc No parent for processor osc target - * @custdesc An internal error occurred. This will force - * the Time of Day function to run with complete - * redundancy. + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid TOD_RT_TOPOLOGY_RESET_BACKUP + * @reasoncode TOD_INVALID_TARGET + * @userdata1 The number of parents found osc target + * @userdata2 None + * @devdesc No/Multiple parent(s) found for + * processor osc target + * @custdesc An internal error occurred. This will + * force the Time of Day function to run + * with complete redundancy. */ - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - TOD::TOD_RT_TOPOLOGY_RESET_BACKUP, - TOD::TOD_INVALID_TARGET, - 0, 0, true); + l_err = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, + TOD_RT_TOPOLOGY_RESET_BACKUP, + TOD_INVALID_TARGET, + l_list.size(), 0, true); break; } } - // No data is returning from the call, just capture any errors - hostInterfaces::hbrt_fw_msg l_resp_fw_msg; - size_t l_resp_fw_msg_size = sizeof(l_resp_fw_msg); - - // Clear the response structure - memset(&l_resp_fw_msg, 0, l_resp_fw_msg_size); - - // Send the data via a firmware request - size_t rc = g_hostInterfaces->firmware_request( - l_req_fw_msg_size, l_req_fw_msg, - &l_resp_fw_msg_size, &l_resp_fw_msg); + // Create the firmware_request response struct to receive data + // NOTE: For messages to the FSP the response size must match + // the request size + uint64_t l_resp_fw_msg_size = l_req_fw_msg_size; + l_resp_fw_msg = + (hostInterfaces::hbrt_fw_msg *)malloc(l_resp_fw_msg_size); + memset(l_resp_fw_msg, 0, l_resp_fw_msg_size); - // Error log id - uint32_t l_errPlid(0); + // Trace out the request structure + TRACFBIN(ISTEPS_TRACE::g_trac_isteps_trace, + INFO_MRK"TOD::Sending firmware_request", + l_req_fw_msg, + l_req_fw_msg_size); - // Create a useful structure to get to the PLID - // The PLID is expected to be in the first 4 bytes of the data - // if it exists - struct hbrtFspRespData_t - { - uint32_t plid; - uint32_t otherData; - } PACKED ; - - hbrtFspRespData_t *l_hbrtFspRespData = - (hbrtFspRespData_t*)&(l_resp_fw_msg.generic_msg.data); - - // Capture the error log ID if any - // The return code (rc) may return OK, but there still may be an issue - // with the HWSV code on the FSP. - if ((hostInterfaces::HBRT_FW_MSG_HBRT_FSP_RESP - == l_resp_fw_msg.io_type) && - (GFMM_ERROR_ONLY == l_resp_fw_msg.generic_msg.__onlyError) && - (0 != l_hbrtFspRespData->plid) ) - { - l_errPlid = l_hbrtFspRespData->plid; - } + // Make the firmware_request call + l_err = firmware_request_helper(l_req_fw_msg_size, + l_req_fw_msg, + &l_resp_fw_msg_size, + l_resp_fw_msg); - // Gather up the error data and create an error log out of it - if (rc || l_errPlid) + if (l_err) { - /*@ - * @errortype - * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE - * @moduleid TOD::TOD_RT_TOPOLOGY_RESET_BACKUP - * @reasoncode TOD::TOD_RT_TOPOLOGY_RESET_BACKUP_ERR - * @userdata1[0..31] Hypervisor return code - * @userdata1[32:63] HWSV error log id (if any) - * @userdata2[0:31] MBOX message type - * @userdata2[32:63] TOD message type - * @devdesc TOD reset backup topology failed - * @custdesc An internal error occurred. This will force - * the Time of Day function to run with complete - * redundancy. - */ - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - TOD::TOD_RT_TOPOLOGY_RESET_BACKUP, - TOD::TOD_RT_TOPOLOGY_RESET_BACKUP_ERR, - TWO_UINT32_TO_UINT64(rc, l_errPlid), - TWO_UINT32_TO_UINT64( - l_req_fw_msg->generic_msg.msgq, - l_req_fw_msg->generic_msg.msgType), - true); - - l_err->addFFDC( ISTEP_COMP_ID, - &l_resp_fw_msg, - l_resp_fw_msg_size, - 0, 0, false ); - - if (sizeof(l_req_fw_msg) > 0) - { - l_err->addFFDC( ISTEP_COMP_ID, - l_req_fw_msg, - sizeof(l_req_fw_msg), - 0, 0, false ); - } - - l_err->collectTrace( "TOD", 256); - - if (l_errPlid) - { - l_err->plid(l_errPlid); - } - break; } - } - while (0); + } while (0); - // The firmware request message is no longer needed - free the data + // Release the firmware messages free(l_req_fw_msg); + free(l_resp_fw_msg); + l_req_fw_msg = l_resp_fw_msg = nullptr; TOD_EXIT("resetBackupTopology"); return l_err; - } // end resetBackupTopology @@ -319,170 +274,100 @@ errlHndl_t readTodProcDataFromFile(TodChipDataContainer& o_todChipData) TOD_ENTER("readTodProcDataFromFile"); errlHndl_t l_err = nullptr; - // Put the handle to the firmware response out here + // Put the handle to the firmware messages out here // so it is easier to free later + hostInterfaces::hbrt_fw_msg *l_req_fw_msg = nullptr; hostInterfaces::hbrt_fw_msg *l_resp_fw_msg = nullptr; + // clear the out data, regardless of the code to follow + o_todChipData.clear(); + do { - // clear the out data, regardless of the code to follow - o_todChipData.clear(); - if ((nullptr == g_hostInterfaces) || (nullptr == g_hostInterfaces->firmware_request)) { + TOD_ERR("readTodProcDataFromFile: " + "Hypervisor firmware_request interface not linked"); + /*@ * @errortype - * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE - * @moduleid TOD::TOD_RT_TOPOLOGY_DATA - * @reasoncode TOD::TOD_RT_NULL_FIRMWARE_REQUEST_PTR + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid TOD_RT_TOPOLOGY_DATA + * @reasoncode TOD_RT_NULL_FIRMWARE_REQUEST_PTR * @devdesc Host interfaces are not initialized - * @custdesc An internal error occurred. This will force the - * Time of Day function to run with complete - * redundancy. + * @custdesc An internal error occurred. This will + * force the Time of Day function to run + * with complete redundancy. */ - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - TOD::TOD_RT_TOPOLOGY_DATA, - TOD::TOD_RT_NULL_FIRMWARE_REQUEST_PTR, + l_err = new ErrlEntry( ERRL_SEV_UNRECOVERABLE, + TOD_RT_TOPOLOGY_DATA, + TOD_RT_NULL_FIRMWARE_REQUEST_PTR, 0, 0, true); break; } - // Create the firmware request structure. No data is being - // passed via this structure so this step may be moot. - // Maybe just passing size of 0 and a null pointer would be better? - hostInterfaces::hbrt_fw_msg l_req_fw_msg; - size_t l_req_fw_msg_size = sizeof(l_req_fw_msg); - - // Set the data for the request - l_req_fw_msg.io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; - l_req_fw_msg.generic_msg.initialize(); - l_req_fw_msg.generic_msg.msgq = MBOX::FSP_TOD_MSGQ; - l_req_fw_msg.generic_msg.msgType = GFMM_MSG_TOD_TOPOLOGY_DATA; - l_req_fw_msg.generic_msg.__req = GFMM_REQUEST; - l_req_fw_msg.generic_msg.__onlyError = GFMM_NOT_ERROR_ONLY; - - // Calculate the size of the response - the number - // of TodChipData items that will be returned. + // Default the response data size to the size of the + // GenericFspMboxMessage_t minus the size of the + // GenericFspMboxMessage_t's data. The size of the + // GenericFspMboxMessage_t's data will be added later + uint32_t l_resp_data_size = sizeof(GenericFspMboxMessage_t) - + sizeof(GenericFspMboxMessage_t::data); + + // Get the number of TodChipData items that will be returned. uint32_t l_nTodChips = TodSvcUtil::getMaxProcsOnSystem(); - // Calculate the size of the data that is being added to the - // generic struct - size_t l_data_size = (l_nTodChips * sizeof(TodChipData)); + // Add to the response data size iff there is data needing to be passed + l_resp_data_size += (l_nTodChips * sizeof(TodChipData)); - // Update the data size with the size of the generic msg struct - if (l_data_size < sizeof(hostInterfaces::hbrt_fw_msg::generic_msg.data)) - { - // If the current size of the data is less than the size of the - // data within the generic message (GenericFspMboxMessage_t.data), - // then default the data size to just the generic message because - // the size of the data to be passed in - // GenericFspMboxMessage_t.dataSize has be at the minimum - the - // size of the generic message (sizeof(GenericFspMboxMessage_t)). - l_data_size = sizeof(hostInterfaces::hbrt_fw_msg::generic_msg); - } - else + // The response data size must be at a minimum the size of the + // FSP generic message (sizeof(GenericFspMboxMessage_t)) + if (l_resp_data_size < sizeof(GenericFspMboxMessage_t)) { - // If the current size of the data is greater than the size of the - // data within the generic message (GenericFspMboxMessage_t.data), - // then add the size of the generic message minus the size of - // generic message's data. - l_data_size += sizeof(hostInterfaces::hbrt_fw_msg::generic_msg) - - sizeof(hostInterfaces::hbrt_fw_msg::generic_msg.data); + l_resp_data_size = sizeof(GenericFspMboxMessage_t); } - // At last. Calculate the TOTAL size of hostInterfaces::hbrt_fw_msg - // which means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to - // the previous calculated data size - size_t l_resp_fw_msg_size = hostInterfaces::HBRT_FW_MSG_BASE_SIZE + - l_data_size; + // Calculate the TOTAL size of hostInterfaces::hbrt_fw_msg which + // means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to + // the previous calculated response data size + uint64_t l_resp_fw_msg_size = hostInterfaces::HBRT_FW_MSG_BASE_SIZE + + l_resp_data_size; - // Create the firmware response structure to return the data + // Create the firmware_request response struct to receive data l_resp_fw_msg = (hostInterfaces::hbrt_fw_msg *)malloc(l_resp_fw_msg_size); - - // Clear the response structure memset(l_resp_fw_msg, 0, l_resp_fw_msg_size); - // Send the data via a firmware request - size_t rc = g_hostInterfaces->firmware_request( - l_req_fw_msg_size, &l_req_fw_msg, - &l_resp_fw_msg_size, l_resp_fw_msg); + // Create the firmware_request request struct to send data + uint64_t l_req_fw_msg_size = l_resp_fw_msg_size; + l_req_fw_msg = + (hostInterfaces::hbrt_fw_msg *)malloc(l_req_fw_msg_size); - // Error log id - uint32_t l_errPlid(0); - - // Create a useful structure to get to the PLID - // The PLID is expected to be in the first 4 bytes of the data - struct hbrtFspRespData_t - { - uint32_t plid; - uint32_t otherData; - } PACKED ; - - hbrtFspRespData_t *l_hbrtFspRespData = - (hbrtFspRespData_t*)&(l_resp_fw_msg->generic_msg.data); - - // Capture the error log ID if any - // The return code (rc) may return OK, but there still may be an issue - // with the HWSV code on the FSP. - if ((hostInterfaces::HBRT_FW_MSG_HBRT_FSP_RESP - == l_resp_fw_msg->io_type) && - (GFMM_ERROR_ONLY == l_resp_fw_msg->generic_msg.__onlyError) && - (0 != l_hbrtFspRespData->plid) ) - { - l_errPlid = l_hbrtFspRespData->plid; - } + // Initialize the firmware_request request struct + l_req_fw_msg->generic_msg.initialize(); - // Gather up the error data and create an error log out of it - if (rc || l_errPlid) + // Populate the firmware_request request struct with given data + l_req_fw_msg->io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; + l_req_fw_msg->generic_msg.msgq = MBOX::FSP_TOD_MSGQ; + l_req_fw_msg->generic_msg.msgType = + GenericFspMboxMessage_t::MSG_TOD_TOPOLOGY_DATA; + l_req_fw_msg->generic_msg.__req = GenericFspMboxMessage_t::REQUEST; + + // Trace out the request structure + TRACFBIN(ISTEPS_TRACE::g_trac_isteps_trace, + INFO_MRK"TOD::Sending firmware_request", + l_req_fw_msg, + l_req_fw_msg_size); + + // Make the firmware_request call + l_err = firmware_request_helper(l_req_fw_msg_size, + l_req_fw_msg, + &l_resp_fw_msg_size, + l_resp_fw_msg); + + if (l_err) { - /*@ - * @errortype - * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE - * @moduleid TOD::TOD_RT_TOPOLOGY_DATA - * @reasoncode TOD::TOD_RT_TOPOLOGY_DATA_ERR - * @userdata1[0..31] Hypervisor return code - * @userdata1[32:63] HWSV error log id (if any) - * @userdata2[0:31] MBOX message type - * @userdata2[32:63] TOD message type - * @devdesc TOD read proc data failed - * @custdesc An internal error occurred. This will force - * the Time of Day function to run with complete - * redundancy. - */ - l_err = new ERRORLOG::ErrlEntry( - ERRORLOG::ERRL_SEV_UNRECOVERABLE, - TOD::TOD_RT_TOPOLOGY_DATA, - TOD::TOD_RT_TOPOLOGY_DATA_ERR, - TWO_UINT32_TO_UINT64(rc, l_errPlid), - TWO_UINT32_TO_UINT64( - l_req_fw_msg.generic_msg.msgq, - l_req_fw_msg.generic_msg.msgType), - true); - - if (l_resp_fw_msg_size > 0) - { - l_err->addFFDC( ISTEP_COMP_ID, - l_resp_fw_msg, - l_resp_fw_msg_size, - 0, 0, false ); - } - - l_err->addFFDC( ISTEP_COMP_ID, - &l_req_fw_msg, - sizeof(l_req_fw_msg), - 0, 0, false ); - - l_err->collectTrace( "TOD", 256); - - if (l_errPlid) - { - l_err->plid(l_errPlid); - } - break; } @@ -500,15 +385,17 @@ errlHndl_t readTodProcDataFromFile(TodChipDataContainer& o_todChipData) } while (0); - // Free the memory associated with the response + // Release the firmware messages + free(l_req_fw_msg); free(l_resp_fw_msg); + l_req_fw_msg = l_resp_fw_msg = nullptr; TOD_EXIT("readTodProcDataFromFile"); return l_err; } // end readTodProcDataFromFile // This code was ported over from the FIPS code - -// /esw/fips910/Builds/b1005a_1742.910/ +// fips910/Builds/b1005a_1742.910/ // src/hwsv/server/services/todservice/hwsvTodSvc.C // It was decided that a port of the code is not needed but to hold onto // the code since the majority of it has been ported. -- cgit v1.2.1