PLDM Message Structure Change
With this change, PLDM code is optimised. The PLDM payload message
structure previously consisted of a pointer to the payload message and
the payload length, this structure is removed with this commit and the
PLDM message structure now has the PLDM header structure and an array of
size 1 whose address is the starting byte of message payload. Therefore,
pldm msg struct can represent a request/response message in contiguous
memory, thereby enabling simple casts and avoiding memcpys to get from a
uint8_t* to pldm msg or vice versa.
This commit also introduces a change to have the response handlers allocate
memory for responses. This is aligned with the message struct change, and
enables varying length responses.
Change-Id: Ia46d852b8b16bfc7cf04f38435bd4079ad33c66b
Signed-off-by: vkaverap <vkaverap@in.ibm.com>
diff --git a/libpldmresponder/base.hpp b/libpldmresponder/base.hpp
index 74bc4af..466559a 100644
--- a/libpldmresponder/base.hpp
+++ b/libpldmresponder/base.hpp
@@ -11,29 +11,33 @@
using Type = uint8_t;
+using Response = std::vector<uint8_t>;
+
namespace responder
{
/** @brief Handler for getPLDMTypes
*
* @param[in] request - Request message payload
- * @param[out] response - Response message written here
+ * @param[in] payload_length - Request message payload length
+ * @param[return] Response - PLDM Response message
*/
-void getPLDMTypes(const pldm_msg_payload* request, pldm_msg* response);
+Response getPLDMTypes(const pldm_msg* request, size_t payloadLength);
/** @brief Handler for getPLDMCommands
*
* @param[in] request - Request message payload
- * @param[out] response - Response message written here
+ * @param[in] payload_length - Request message payload length
+ * @param[return] Response - PLDM Response message
*/
-void getPLDMCommands(const pldm_msg_payload* request, pldm_msg* response);
+Response getPLDMCommands(const pldm_msg* request, size_t payloadLength);
/** @brief Handler for getPLDMCommands
*
* @param[in] request - Request message payload
- * @param[out] response - Response messsage written here
+ * @param[in] payload_length - Request message payload length
+ * @param[return] Response - PLDM Response message
*/
-void getPLDMVersion(const pldm_msg_payload* request, pldm_msg* response);
-
+Response getPLDMVersion(const pldm_msg* request, size_t payloadLength);
} // namespace responder
} // namespace pldm