Skip to content

Commit

Permalink
Update attributes based on message from the FSP
Browse files Browse the repository at this point in the history
At least one usecase exists where code on the FSP
needs to update an attribute and have that value
reflected inside of HBRT.

Change-Id: Iad5057ecbb182f6f58879ba694d4b8adea485248
RTC:186991
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/53486
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mderkse1 authored and dcrowell77 committed Feb 11, 2018
1 parent c9ad324 commit 27bddb0
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 36 deletions.
20 changes: 20 additions & 0 deletions src/include/runtime/generic_hbrt_fsp_message.H
Expand Up @@ -26,6 +26,8 @@
#define __RUNTIME__GENERIC_HBRT_FSP_MESSAGE_H

#include <targeting/common/attributes.H> // TARGETING::HwasState
#include <attributeenums.H> // ATTRIBUTE_ID


/** @file generic_hbrt_fsp_message.H
* @brief A generic structure for passing data
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/include/usr/runtime/runtime_reasoncodes.H
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions src/include/usr/targeting/common/target.H
Expand Up @@ -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

/**
Expand Down
146 changes: 110 additions & 36 deletions src/usr/util/runtime/rt_fwnotify.C
Expand Up @@ -24,13 +24,14 @@
/* IBM_PROLOG_END_TAG */

#include <sbeio/sbe_retry_handler.H> // SbeRetryHandler
#include <util/runtime/rt_fwreq_helper.H> // firmware_request_helper
#include <util/runtime/rt_fwreq_helper.H> // firmware_request_helper
#include <runtime/interface.h> // g_hostInterfaces
#include <runtime/runtime_reasoncodes.H> // MOD_RT_FIRMWARE_NOTIFY, etc
#include <errl/errlentry.H> // ErrlEntry
#include <errl/errlmanager.H> // errlCommit
#include <errl/hberrltypes.H> // TWO_UINT32_TO_UINT64
#include <targeting/common/target.H> // TargetHandle_t, getTargetFromHuid
#include <attributeenums.H> // ATTRIBUTE_ID

using namespace TARGETING;
using namespace RUNTIME;
Expand Down Expand Up @@ -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<HbrtAttrSyncData_t*>(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<const void*>(&(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
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 27bddb0

Please sign in to comment.