OEM IBM: Platform: event framework to send events to PHYP
This commit consists of APIs that will be used to send code update
event change/update PlatformEventMessage to Phyp for different
stages of inband code update progress.
The event is a state sensor event.
Signed-off-by: Varsha Kaverappa <vkaverap@in.ibm.com>
Change-Id: I9b4b0493dd6886805044011d994df58b31f80a6e
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index 2220adb..bacc3f0 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -1,7 +1,10 @@
#pragma once
+#include "libpldm/platform.h"
+
#include "inband_code_update.hpp"
#include "libpldmresponder/oem_handler.hpp"
+#include "libpldmresponder/pdr_utils.hpp"
#include "libpldmresponder/platform.hpp"
namespace pldm
@@ -18,13 +21,25 @@
constexpr uint16_t ENTITY_INSTANCE_0 = 0;
constexpr uint16_t ENTITY_INSTANCE_1 = 1;
+enum class CodeUpdateState : uint8_t
+{
+ START = 0x1,
+ END = 0x2,
+ FAIL = 0x3,
+ ABORT = 0x4,
+ ACCEPT = 0x5,
+ REJECT = 0x6
+};
+
class Handler : public oem_platform::Handler
{
public:
Handler(const pldm::utils::DBusHandler* dBusIntf,
- pldm::responder::CodeUpdate* codeUpdate) :
+ pldm::responder::CodeUpdate* codeUpdate, int mctp_fd,
+ uint8_t mctp_eid, Requester& requester) :
oem_platform::Handler(dBusIntf),
- codeUpdate(codeUpdate), platformHandler(nullptr)
+ codeUpdate(codeUpdate), platformHandler(nullptr), mctp_fd(mctp_fd),
+ mctp_eid(mctp_eid), requester(requester)
{
codeUpdate->setVersions();
}
@@ -71,13 +86,53 @@
*/
void buildOEMPDR(pdr_utils::Repo& repo);
+ /** @brief Method to send code update event to host
+ * @param[in] sensorId - sendor ID
+ * @param[in] sensorEventClass - event class of sensor
+ * @param[in] sensorOffset - sensor offset
+ * @param[in] eventState - new code update event state
+ * @param[in] prevEventState - previous code update event state
+ * @return none
+ */
+ void sendStateSensorEvent(uint16_t sensorId,
+ enum sensor_event_class_states sensorEventClass,
+ uint8_t sensorOffset, uint8_t eventState,
+ uint8_t prevEventState);
+
+ /** @brief Method to send encoded request msg of code update event to host
+ * @param[in] requestMsg - encoded request msg
+ * @return PLDM status code
+ */
+ int sendEventToHost(std::vector<uint8_t>& requestMsg);
+
~Handler() = default;
pldm::responder::CodeUpdate* codeUpdate; //!< pointer to CodeUpdate object
pldm::responder::platform::Handler*
platformHandler; //!< pointer to PLDM platform handler
+
+ /** @brief fd of MCTP communications socket */
+ int mctp_fd;
+
+ /** @brief MCTP EID of host firmware */
+ uint8_t mctp_eid;
+
+ /** @brief reference to Requester object, primarily used to access API to
+ * obtain PLDM instance id.
+ */
+ Requester& requester;
};
+/** @brief Method to encode code update event msg
+ * @param[in] eventType - type of event
+ * @param[in] eventDataVec - vector of event data to be sent to host
+ * @param[in/out] requestMsg - request msg to be encoded
+ * @param[in] instanceId - instance ID
+ * @return PLDM status code
+ */
+int encodeEventMsg(uint8_t eventType, const std::vector<uint8_t>& eventDataVec,
+ std::vector<uint8_t>& requestMsg, uint8_t instanceId);
+
} // namespace oem_ibm_platform
} // namespace responder