diff --git a/src/include/runtime/generic_hbrt_fsp_message.H b/src/include/runtime/generic_hbrt_fsp_message.H index 5c9ca7eb0bd..0f28b564047 100644 --- a/src/include/runtime/generic_hbrt_fsp_message.H +++ b/src/include/runtime/generic_hbrt_fsp_message.H @@ -26,6 +26,8 @@ #define __RUNTIME__GENERIC_HBRT_FSP_MESSAGE_H #include // TARGETING::HwasState +#include // ATTRIBUTE_ID + /** @file generic_hbrt_fsp_message.H * @brief A generic structure for passing data @@ -71,6 +73,23 @@ struct HbrtFspData_t uint32_t userData; } PACKED ; + +/** + * A useful struct to access the HUID, attribute ID and attribute data + * from the GenericFspMboxMessage_t.data + * + * The HUID will be the first 4 bytes followed by a 4-byte attribute ID, + * then a 4-byte size of attribute data, and finally the attribute's data + * + */ +struct HbrtAttrSyncData_t +{ + uint32_t huid; + TARGETING::ATTRIBUTE_ID attrID; + uint32_t sizeOfAttrData; + uint8_t attrDataStart; +} PACKED ; + /** * This struct sends/receives an MBox message to the FSP */ @@ -119,6 +138,7 @@ struct GenericFspMboxMessage_t MSG_TOD_BACKUP_RESET_INFORM_PHYP = 0x0002, MSG_TOD_TOPOLOGY_DATA = 0x0003, MSG_DECONFIG_TARGET = 0x0004, + MSG_ATTR_SYNC_REQUEST = 0x000000A5, MSG_SBE_ERROR = 0x000000E1, MSG_SBE_RECOVERY_SUCCESS = 0x000000E2, MSG_SBE_RECOVERY_FAILED = 0x000000E3, diff --git a/src/include/usr/runtime/runtime_reasoncodes.H b/src/include/usr/runtime/runtime_reasoncodes.H index e909c0152ae..19799c51acd 100644 --- a/src/include/usr/runtime/runtime_reasoncodes.H +++ b/src/include/usr/runtime/runtime_reasoncodes.H @@ -61,6 +61,7 @@ namespace RUNTIME MOD_ATTR_RUNTIME_CHECK_PREP_FAIL = 0x21, /**< populate_hbruntime.C */ MOD_RT_FIRMWARE_NOTIFY = 0x23, /**< rt_fwnotify.C */ MOD_RT_FIRMWARE_REQUEST = 0x24, /**< rt_fwreq_helper.C */ + MOD_RT_ATTR_SYNC_REQUEST = 0x25, /**< rt_fwnotify.C */ }; enum RuntimeReasonCode @@ -125,6 +126,7 @@ namespace RUNTIME RC_FW_REQUEST_ERR = RUNTIME_COMP_ID | 0x39, RC_TPM_HDAT_VIRT_TO_PHYS_ERR = RUNTIME_COMP_ID | 0x3A, RC_TPM_HDAT_MAP_BLOCK_ERR = RUNTIME_COMP_ID | 0x3B, + RC_ATTR_UPDATE_FAILED = RUNTIME_COMP_ID | 0x3C, }; enum UserDetailsTypes diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index 1c8ad34412b..cc5f4a1f11b 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -373,6 +373,43 @@ class Target void getAttrTankTargetPosData(uint16_t & o_pos, uint8_t & o_unitPos, uint8_t & o_node) const; + + + /** + * @brief Tries to set the target's specified attribute value + * Only use if template attribute system can't be used + * Relies on assumptions instead of enforcing them. + * Assumes it is a writeable attribute + * Assumes i_size matches the size of the attribute + * + * Tries to set the target's specified attribute value + * + * @param[in] i_attr Attribute to retrieve + * @param[in] i_size Size of the attribute + * @param[in] i_pAttrData Location holding the attribute data to set + * + * @pre Target service must be initialized + * + * @post If attribute exists for the associated target, attribute value + * updated and success (true) returned. Otherwise, attribute value + * not updated and failure (false) returned. + * + * @return bool indicating if attribute update succeeded or not + * + * @retval true Attribute update succeeded + * @retval false Attribute update failed + */ + bool unsafeTrySetAttr( + ATTRIBUTE_ID i_attr, + uint32_t i_size, + const void* i_pAttrData) const + { + // no check for size or if attribute is writable + return _trySetAttr(i_attr, i_size, i_pAttrData); + } + + + private: // Private helper interfaces /** diff --git a/src/usr/util/runtime/rt_fwnotify.C b/src/usr/util/runtime/rt_fwnotify.C index 9bd4e9c416d..a0ec0f5e0b4 100644 --- a/src/usr/util/runtime/rt_fwnotify.C +++ b/src/usr/util/runtime/rt_fwnotify.C @@ -24,13 +24,14 @@ /* IBM_PROLOG_END_TAG */ #include // SbeRetryHandler -#include // firmware_request_helper +#include // firmware_request_helper #include // g_hostInterfaces #include // MOD_RT_FIRMWARE_NOTIFY, etc #include // ErrlEntry #include // errlCommit #include // TWO_UINT32_TO_UINT64 #include // TargetHandle_t, getTargetFromHuid +#include // ATTRIBUTE_ID using namespace TARGETING; using namespace RUNTIME; @@ -227,6 +228,80 @@ void sbeAttemptRecovery(uint64_t i_data) TRACFCOMP(g_trac_runtime, EXIT_MRK"sbeAttemptRecovery"); } + +/** + * @brief Attempt to sync attribute setting with the FSP + * @param[in] void * i_data - contains a target huid, attribute id, + * attribute data length, and attribute data + * @platform FSP + **/ +void attrSyncRequest( void * i_data) +{ + HbrtAttrSyncData_t * l_hbrtAttrData = + reinterpret_cast(i_data); + TRACFCOMP(g_trac_runtime, ENTER_MRK"attrSyncRequest: Target HUID 0x%0X " + "for AttrID: 0x%0X with AttrSize: %lld", l_hbrtAttrData->huid, + l_hbrtAttrData->attrID, l_hbrtAttrData->sizeOfAttrData); + + TRACFBIN(g_trac_runtime, "Attribute data: ", + &(l_hbrtAttrData->attrDataStart), + l_hbrtAttrData->sizeOfAttrData); + + // extract the target from the given HUID + TargetHandle_t l_target = Target::getTargetFromHuid(l_hbrtAttrData->huid); + + // Assumes the attribute is writeable + bool attr_updated = l_target->unsafeTrySetAttr( + l_hbrtAttrData->attrID, + l_hbrtAttrData->sizeOfAttrData, + reinterpret_cast(&(l_hbrtAttrData->attrDataStart))); + + if (!attr_updated) + { + TRACFCOMP(g_trac_runtime,ERR_MRK"attrSyncRequest: " + "Unable to update attribute"); + + // Copy the first couple bytes of new attribute data (up to 4 bytes) + uint32_t l_attrData = 0; + uint32_t l_attrSize = l_hbrtAttrData->sizeOfAttrData; + if (l_attrSize > sizeof(l_attrData)) + { + l_attrSize = sizeof(l_attrData); + } + memcpy(&l_attrData, &(l_hbrtAttrData->attrDataStart), l_attrSize); + + /*@ + * @errortype + * @severity ERRL_SEV_PREDICTIVE + * @moduleid MOD_RT_ATTR_SYNC_REQUEST + * @reasoncode RC_ATTR_UPDATE_FAILED + * @userdata1[0:31] Target HUID + * @userdata1[32:63] Attribute ID + * @userdata2[0:31] Data Size + * @userdata2[32:63] Up to 4 bytes of attribute data + * @devdesc Attribute failed to update on HBRT side + */ + errlHndl_t l_err = new ErrlEntry(ERRL_SEV_PREDICTIVE, + MOD_RT_ATTR_SYNC_REQUEST, + RC_ATTR_UPDATE_FAILED, + TWO_UINT32_TO_UINT64( + l_hbrtAttrData->huid, + l_hbrtAttrData->attrID), + TWO_UINT32_TO_UINT64( + l_hbrtAttrData->sizeOfAttrData, + l_attrData), + true); + + l_err->collectTrace(RUNTIME_COMP_NAME, 256); + + //Commit the error + errlCommit(l_err, RUNTIME_COMP_ID); + } + + TRACFCOMP(g_trac_runtime, EXIT_MRK"attrSyncRequest"); +} + + /** * @see src/include/runtime/interface.h for definition of call * @@ -268,42 +343,41 @@ void firmware_notify( uint64_t i_len, void *i_data ) case hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ: { - - // Extract the message type - switch(l_hbrt_fw_msg->generic_msg.msgType) + // Distinguish based on msgType and msgq + if (l_hbrt_fw_msg->generic_msg.msgType == + GenericFspMboxMessage_t::MSG_SBE_ERROR) { - - case GenericFspMboxMessage_t::MSG_SBE_ERROR: - sbeAttemptRecovery(l_hbrt_fw_msg->generic_msg.data); - - break; - - default: - { - l_badMessage = true; - - TRACFCOMP(g_trac_runtime, ERR_MRK"firmware_notify: " - "Unknown FSP message type:0x%.8X, " - "message queue id:0x%.8X, seqNum:%d ", - l_hbrt_fw_msg->generic_msg.msgq, - l_hbrt_fw_msg->generic_msg.msgType, - l_hbrt_fw_msg->generic_msg.seqnum); - - // Pack user data 1 with message input type and - // firmware request message sequence number - l_userData1 = TWO_UINT32_TO_UINT64( - l_hbrt_fw_msg->io_type, - l_hbrt_fw_msg->generic_msg.seqnum); - - // Pack user data 2 with message queue and message type - l_userData2 = TWO_UINT32_TO_UINT64( - l_hbrt_fw_msg->generic_msg.msgq, - l_hbrt_fw_msg->generic_msg.msgType); - } - - break; // END default - - } // END switch(l_genericMsg->msgType) + sbeAttemptRecovery(l_hbrt_fw_msg->generic_msg.data); + } + else if ( (l_hbrt_fw_msg->generic_msg.msgType == + GenericFspMboxMessage_t::MSG_ATTR_SYNC_REQUEST) && + (l_hbrt_fw_msg->generic_msg.msgq == + MBOX::HB_ATTR_SYNC_MSGQ) ) + { + attrSyncRequest((void*)&(l_hbrt_fw_msg->generic_msg.data)); + } + else + { + l_badMessage = true; + + TRACFCOMP(g_trac_runtime, ERR_MRK"firmware_notify: " + "Unknown FSP message type:0x%.8X, " + "message queue id:0x%.8X, seqNum:%d ", + l_hbrt_fw_msg->generic_msg.msgq, + l_hbrt_fw_msg->generic_msg.msgType, + l_hbrt_fw_msg->generic_msg.seqnum); + + // Pack user data 1 with message input type and + // firmware request message sequence number + l_userData1 = TWO_UINT32_TO_UINT64( + l_hbrt_fw_msg->io_type, + l_hbrt_fw_msg->generic_msg.seqnum); + + // Pack user data 2 with message queue and message type + l_userData2 = TWO_UINT32_TO_UINT64( + l_hbrt_fw_msg->generic_msg.msgq, + l_hbrt_fw_msg->generic_msg.msgType); + } } // END case HBRT_FW_MSG_HBRT_FSP_REQ: break;