libpldm: Add decode API for GetStatus response
The UA sends this command to acquire the status of the FD/FDP. This
implementation works with DSP0267_1.1.0, DSP0267_1.0.1 and
DSP0267_1.0.0.
Tested: Unit tests passed
Signed-off-by: gokulsanker <gokul.sanker.v.g@intel.com>
Change-Id: Ia7e3600d6847cc76ee2d37c61e6d0166315f6490
diff --git a/libpldm/firmware_update.h b/libpldm/firmware_update.h
index 231aaa0..a7e5023 100644
--- a/libpldm/firmware_update.h
+++ b/libpldm/firmware_update.h
@@ -19,6 +19,8 @@
#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
#define PLDM_GET_STATUS_REQ_BYTES 0
+/* Maximum progress percentage value*/
+#define PLDM_FWUP_MAX_PROGRESS_PERCENT 0x65
/** @brief PLDM Firmware update commands
*/
@@ -258,6 +260,53 @@
PLDM_ACTIVATE_SELF_CONTAINED_COMPONENTS = true
};
+/** @brief Current state/previous state of the FD or FDP returned in GetStatus
+ * response
+ */
+enum pldm_firmware_device_states {
+ PLDM_FD_STATE_IDLE = 0,
+ PLDM_FD_STATE_LEARN_COMPONENTS = 1,
+ PLDM_FD_STATE_READY_XFER = 2,
+ PLDM_FD_STATE_DOWNLOAD = 3,
+ PLDM_FD_STATE_VERIFY = 4,
+ PLDM_FD_STATE_APPLY = 5,
+ PLDM_FD_STATE_ACTIVATE = 6
+};
+
+/** @brief Firmware device aux state in GetStatus response
+ */
+enum pldm_get_status_aux_states {
+ PLDM_FD_OPERATION_IN_PROGRESS = 0,
+ PLDM_FD_OPERATION_SUCCESSFUL = 1,
+ PLDM_FD_OPERATION_FAILED = 2,
+ PLDM_FD_IDLE_LEARN_COMPONENTS_READ_XFER = 3
+};
+
+/** @brief Firmware device aux state status in GetStatus response
+ */
+enum pldm_get_status_aux_state_status_values {
+ PLDM_FD_AUX_STATE_IN_PROGRESS_OR_SUCCESS = 0x00,
+ PLDM_FD_TIMEOUT = 0x09,
+ PLDM_FD_GENERIC_ERROR = 0x0A,
+ PLDM_FD_VENDOR_DEFINED_STATUS_CODE_START = 0x70,
+ PLDM_FD_VENDOR_DEFINED_STATUS_CODE_END = 0xEF
+};
+
+/** @brief Firmware device reason code in GetStatus response
+ */
+enum pldm_get_status_reason_code_values {
+ PLDM_FD_INITIALIZATION = 0,
+ PLDM_FD_ACTIVATE_FW = 1,
+ PLDM_FD_CANCEL_UPDATE = 2,
+ PLDM_FD_TIMEOUT_LEARN_COMPONENT = 3,
+ PLDM_FD_TIMEOUT_READY_XFER = 4,
+ PLDM_FD_TIMEOUT_DOWNLOAD = 5,
+ PLDM_FD_TIMEOUT_VERIFY = 6,
+ PLDM_FD_TIMEOUT_APPLY = 7,
+ PLDM_FD_STATUS_VENDOR_DEFINED_MIN = 200,
+ PLDM_FD_STATUS_VENDOR_DEFINED_MAX = 255
+};
+
/** @struct pldm_package_header_information
*
* Structure representing fixed part of package header information
@@ -475,6 +524,21 @@
uint16_t estimated_time_activation;
} __attribute__((packed));
+/** @struct pldm_get_status_resp
+ *
+ * Structure representing GetStatus response.
+ */
+struct pldm_get_status_resp {
+ uint8_t completion_code;
+ uint8_t current_state;
+ uint8_t previous_state;
+ uint8_t aux_state;
+ uint8_t aux_state_status;
+ uint8_t progress_percent;
+ uint8_t reason_code;
+ bitfield32_t update_option_flags_enabled;
+} __attribute__((packed));
+
/** @brief Decode the PLDM package header information
*
* @param[in] data - pointer to package header information
@@ -956,6 +1020,30 @@
int encode_get_status_req(uint8_t instance_id, struct pldm_msg *msg,
size_t payload_length);
+/** @brief Decode GetStatus response message
+ *
+ * @param[in] msg - Response message
+ * @param[in] payload_length - Length of response message payload
+ * @param[out] completion_code - Pointer to completion code
+ * @param[out] current_state - Pointer to current state machine state
+ * @param[out] previous_state - Pointer to previous different state machine
+ * state
+ * @param[out] aux_state - Pointer to current operation state of FD/FDP
+ * @param[out] aux_state_status - Pointer to aux state status
+ * @param[out] progress_percent - Pointer to progress percentage
+ * @param[out] reason_code - Pointer to reason for entering current state
+ * @param[out] update_option_flags_enabled - Pointer to update option flags
+ * enabled
+ *
+ * @return pldm_completion_codes
+ */
+int decode_get_status_resp(const struct pldm_msg *msg, size_t payload_length,
+ uint8_t *completion_code, uint8_t *current_state,
+ uint8_t *previous_state, uint8_t *aux_state,
+ uint8_t *aux_state_status, uint8_t *progress_percent,
+ uint8_t *reason_code,
+ bitfield32_t *update_option_flags_enabled);
+
#ifdef __cplusplus
}
#endif