summaryrefslogtreecommitdiffstats
path: root/src/include/runtime
diff options
context:
space:
mode:
authorRoland Veloz <rveloz@us.ibm.com>2019-06-11 12:41:40 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2019-06-12 13:35:26 -0500
commit9192b12a33dc07d4a4f3d88c323ac373dd8f6367 (patch)
treebe3f1d39bbb75fefeb4129a69c7247bfc594c7e6 /src/include/runtime
parent12ef1ffdc34ad61b2442f369163fbef55c8a8802 (diff)
downloadtalos-hostboot-9192b12a33dc07d4a4f3d88c323ac373dd8f6367.tar.gz
talos-hostboot-9192b12a33dc07d4a4f3d88c323ac373dd8f6367.zip
Reworked the AttributeTank::Attribute API
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>
Diffstat (limited to 'src/include/runtime')
-rw-r--r--src/include/runtime/hbrt_utilities.H122
1 files changed, 86 insertions, 36 deletions
diff --git a/src/include/runtime/hbrt_utilities.H b/src/include/runtime/hbrt_utilities.H
index 87a9cc708..1764dedb1 100644
--- a/src/include/runtime/hbrt_utilities.H
+++ b/src/include/runtime/hbrt_utilities.H
@@ -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;
}
@@ -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);
@@ -257,11 +258,11 @@ 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;
}
@@ -269,7 +270,7 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>
// 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 =
@@ -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,
OpenPOWER on IntegriCloud