Skip to content

Commit

Permalink
Reworked the AttributeTank::Attribute API
Browse files Browse the repository at this point in the history
Once I made the Attribute structure public, I exposed the API.
It was no longer sufferance to allow users to just modify the properties
of the structure openly.  It was time to encapsulate the data and
provide a proper API.

Removed the 'virtual' keyword from the class AttributeTank.  This
class is not being used polymorphically any where, therefore the
keyword 'virtual' was just adding to it's memory size foot print
for no reason.

Change-Id: I073aa5dbef1eba911afb95392de5e580f6aac100
RTC:208343
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/78756
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Zachary Clark <zach@ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
velozr authored and dcrowell77 committed Jun 12, 2019
1 parent 12ef1ff commit 9192b12
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 191 deletions.
122 changes: 86 additions & 36 deletions src/include/runtime/hbrt_utilities.H
Expand Up @@ -184,8 +184,8 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>
// If caller passes in an empty list, then nothing to do
if (!i_attributeList.size())
{
TRACFCOMP(g_trac_runtime, "sendAttributes: attribute list is empty,"
"nothing to do ...");
TRACFCOMP(g_trac_runtime, "sendAttributes: attribute list is "
"empty,nothing to do ...");
break;
}

Expand All @@ -210,28 +210,29 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>
* @custdesc Internal firmware error
*/
l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
RUNTIME::MOD_RT_FIRMWARE_REQUEST,
RUNTIME::RC_FW_REQUEST_RT_NULL_PTR,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
RUNTIME::MOD_RT_FIRMWARE_REQUEST,
RUNTIME::RC_FW_REQUEST_RT_NULL_PTR,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);

break;
}

/// Calculate the size requirements needed to serialize the Attribute info
// Start with the size of 'struct AttributeSetter_t' itself
uint16_t l_dataSize(sizeof(AttributeSetter_t));

// Then add in the individual attributes themselves
/// Calculate the size requirements needed to serialize
/// the Attribute info
// Aggregate the size of the incoming Attributes
uint32_t l_aggregatedAttributeSize(0);
for (auto l_attribute: i_attributeList)
{
// Add in the size of `struct AttributeHeader`
l_dataSize += sizeof(l_attribute.iv_hdr);
// Finally add in the size of the attribute value
l_dataSize += l_attribute.iv_hdr.iv_valSize;
l_aggregatedAttributeSize += l_attribute.getSize();
}

// Combine the size of the AttributeSetter_t itself to the size of
// incoming Attributes to get the full size requirement needed
uint32_t l_dataSize(sizeof(AttributeSetter_t) +
l_aggregatedAttributeSize);

// Create and initialize to zero a few needed variables
uint32_t l_fullFspDataSize(0);
uint64_t l_fwRequestMsgSize(0), l_fwResponseMsgSize(0);
Expand All @@ -257,19 +258,19 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>
* @custdesc Internal firmware error
*/
l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP,
RUNTIME::RC_NULL_FIRMWARE_MSG_PTR,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);
RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP,
RUNTIME::RC_NULL_FIRMWARE_MSG_PTR,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);

break;
}

// Populate the 'message queue' and 'message type' for this message
l_fwRequestMsg->generic_msg.msgq = MBOX::FSP_NVDIMM_KEYS_MSGQ_ID;
l_fwRequestMsg->generic_msg.msgType =
GenericFspMboxMessage_t::MSG_DECONFIG_TARGET;
GenericFspMboxMessage_t::MSG_DECONFIG_TARGET;

// Create a useful struct to populate the generic_msg::data field
AttributeSetter_t* l_attributeSetter =
Expand All @@ -286,22 +287,71 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>
// Retrieve the individual attributes (header and value)
// Create a useful struct to poulate attribute data
uint8_t* l_attributeData = l_attributeSetter->iv_attrData;
uint32_t l_sizeOfDataCopied(0);
for (const auto & l_attribute: i_attributeList)
{
// Copy the attribute header
memcpy(l_attributeData,
&(l_attribute.iv_hdr),
sizeof(l_attribute.iv_hdr));
// Advance pointer, one beyond the attribute header
l_attributeData += sizeof(l_attribute.iv_hdr);

// Copy the attribute value
memcpy(l_attributeData,
l_attribute.iv_pVal,
l_attribute.iv_hdr.iv_valSize);
// Advance pointer, one beyond the attribute value
l_attributeData += l_attribute.iv_hdr.iv_valSize;
}
if (l_aggregatedAttributeSize >= l_attribute.getSize())
{
l_sizeOfDataCopied = l_attribute.serialize(
l_attributeData, l_aggregatedAttributeSize);

if (!l_sizeOfDataCopied)
{
TRACFCOMP(g_trac_runtime, ERR_MRK"sendAttributes: "
"Serialization of an Attribute failed, "
"should never happen")

/*@
* @errortype
* @severity ERRL_SEV_UNRECOVERABLE
* @moduleid MOD_SEND_ATTRIBUTES_TO_FSP
* @reasoncode RC_SERIALIZE_ATTRIBUTE_FAILED
* @userdata1 Number of Attributes to serialize and send
* @devdesc Serialization of an Attribute Failed
* @custdesc Internal firmware error
*/
l_err = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP,
RUNTIME::RC_SERIALIZE_ATTRIBUTE_FAILED,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);

break;
} // end if (!l_sizeOfDataCopied)
}
else
{
TRACFCOMP(g_trac_runtime, ERR_MRK"sendAttributes: "
"Miscalculation of aggregated size of attributes, "
"should never happen")

/*@
* @errortype
* @severity ERRL_SEV_UNRECOVERABLE
* @moduleid MOD_SEND_ATTRIBUTES_TO_FSP
* @reasoncode RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION
* @userdata1 Number of Attributes to serialize and send
* @devdesc Serialization data of Attribute to large
* for given buffer
* @custdesc Internal firmware error
*/
l_err = new ERRORLOG::ErrlEntry(
ERRORLOG::ERRL_SEV_UNRECOVERABLE,
RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP,
RUNTIME::RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION,
i_attributeList.size(),
0,
ERRORLOG::ErrlEntry::ADD_SW_CALLOUT);

break;
}

// Decrement/increment our counters/pointers
l_aggregatedAttributeSize -= l_sizeOfDataCopied;
l_attributeData += l_sizeOfDataCopied;
} // end for (const auto & l_attribute: i_attributeList)

// Make the firmware_request call
l_err = firmware_request_helper(l_fwRequestMsgSize,
Expand Down
2 changes: 2 additions & 0 deletions src/include/usr/runtime/runtime_reasoncodes.H
Expand Up @@ -141,6 +141,8 @@ namespace RUNTIME
RC_SP_ATTN_AREA1_SIZE_OVERFLOW = RUNTIME_COMP_ID | 0x43,
RC_UNKNOWN_LABEL = RUNTIME_COMP_ID | 0x44,
RC_NULL_FIRMWARE_MSG_PTR = RUNTIME_COMP_ID | 0x45,
RC_SERIALIZE_ATTRIBUTE_FAILED = RUNTIME_COMP_ID | 0x46,
RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION = RUNTIME_COMP_ID | 0x47,
};

enum UserDetailsTypes
Expand Down

0 comments on commit 9192b12

Please sign in to comment.