libpldm: Add encode API for CancelUpdate request
Update agent send this command to FD/FDP to exit from update mode
even if activation is required to begin operating at the new firmware
level. FD/FDP will transition to IDLE state on CancelUpdate. 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: Iab9c2f078c216c20c2432ac5ec0438fdae8da27d
diff --git a/libpldm/firmware_update.c b/libpldm/firmware_update.c
index 6714136..53c1387 100644
--- a/libpldm/firmware_update.c
+++ b/libpldm/firmware_update.c
@@ -1483,3 +1483,27 @@
*completion_code = msg->payload[0];
return PLDM_SUCCESS;
}
+
+int encode_cancel_update_req(uint8_t instance_id, struct pldm_msg *msg,
+ size_t payload_length)
+{
+ if (msg == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ if (payload_length != PLDM_CANCEL_UPDATE_REQ_BYTES) {
+ return PLDM_ERROR_INVALID_LENGTH;
+ }
+
+ struct pldm_header_info header = {0};
+ header.instance = instance_id;
+ header.msg_type = PLDM_REQUEST;
+ header.pldm_type = PLDM_FWUP;
+ header.command = PLDM_CANCEL_UPDATE;
+ uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+ if (rc) {
+ return rc;
+ }
+
+ return PLDM_SUCCESS;
+}