OEM-IBM: Implement encode response & decode request API for
FileAckWithMetadata
Tested with latest SDK environment.
Change-Id: Ib62f1ea86f753e478ee7c820fda9bbb82bc2a745
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/oem/ibm/libpldm/file_io.c b/oem/ibm/libpldm/file_io.c
index 262af47..6c045a9 100644
--- a/oem/ibm/libpldm/file_io.c
+++ b/oem/ibm/libpldm/file_io.c
@@ -839,3 +839,106 @@
return PLDM_SUCCESS;
}
+
+int encode_file_ack_with_meta_data_req(
+ uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
+ uint8_t file_status, uint32_t file_meta_data_1, uint32_t file_meta_data_2,
+ uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg)
+{
+ if (msg == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ struct pldm_header_info header = {0};
+ header.msg_type = PLDM_REQUEST;
+ header.instance = instance_id;
+ header.pldm_type = PLDM_OEM;
+ header.command = PLDM_FILE_ACK_WITH_META_DATA;
+ uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+ if (rc != PLDM_SUCCESS) {
+ return rc;
+ }
+
+ struct pldm_file_ack_with_meta_data_req *req =
+ (struct pldm_file_ack_with_meta_data_req *)msg->payload;
+ req->file_type = htole16(file_type);
+ req->file_handle = htole32(file_handle);
+ req->file_status = file_status;
+ req->file_meta_data_1 = htole32(file_meta_data_1);
+ req->file_meta_data_2 = htole32(file_meta_data_2);
+ req->file_meta_data_3 = htole32(file_meta_data_3);
+ req->file_meta_data_4 = htole32(file_meta_data_4);
+
+ return PLDM_SUCCESS;
+}
+
+int decode_file_ack_with_meta_data_resp(const struct pldm_msg *msg,
+ size_t payload_length,
+ uint8_t *completion_code)
+{
+ if (msg == NULL || completion_code == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ if (payload_length != PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES) {
+ return PLDM_ERROR_INVALID_LENGTH;
+ }
+
+ struct pldm_file_ack_with_meta_data_resp *response =
+ (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
+ *completion_code = response->completion_code;
+
+ return PLDM_SUCCESS;
+}
+
+int decode_file_ack_with_meta_data_req(
+ const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
+ uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1,
+ uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
+ uint32_t *file_meta_data_4)
+{
+ if (msg == NULL || file_type == NULL || file_handle == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ if (payload_length != PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES) {
+ return PLDM_ERROR_INVALID_LENGTH;
+ }
+
+ struct pldm_file_ack_with_meta_data_req *request =
+ (struct pldm_file_ack_with_meta_data_req *)msg->payload;
+ *file_type = le16toh(request->file_type);
+ *file_handle = le32toh(request->file_handle);
+ *file_status = request->file_status;
+ *file_meta_data_1 = le32toh(request->file_meta_data_1);
+ *file_meta_data_2 = le32toh(request->file_meta_data_2);
+ *file_meta_data_3 = le32toh(request->file_meta_data_3);
+ *file_meta_data_4 = le32toh(request->file_meta_data_4);
+
+ return PLDM_SUCCESS;
+}
+
+int encode_file_ack_with_meta_data_resp(uint8_t instance_id,
+ uint8_t completion_code,
+ struct pldm_msg *msg)
+{
+ if (msg == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ struct pldm_header_info header = {0};
+ header.msg_type = PLDM_RESPONSE;
+ header.instance = instance_id;
+ header.pldm_type = PLDM_OEM;
+ header.command = PLDM_FILE_ACK_WITH_META_DATA;
+ uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
+ if (rc != PLDM_SUCCESS) {
+ return rc;
+ }
+
+ struct pldm_file_ack_with_meta_data_resp *response =
+ (struct pldm_file_ack_with_meta_data_resp *)msg->payload;
+ response->completion_code = completion_code;
+
+ return PLDM_SUCCESS;
+}
diff --git a/oem/ibm/libpldm/file_io.h b/oem/ibm/libpldm/file_io.h
index 07db4ed..72892da 100644
--- a/oem/ibm/libpldm/file_io.h
+++ b/oem/ibm/libpldm/file_io.h
@@ -24,6 +24,8 @@
PLDM_READ_FILE_BY_TYPE = 0xB,
PLDM_WRITE_FILE_BY_TYPE = 0xC,
PLDM_FILE_ACK = 0xD,
+ PLDM_NEW_FILE_AVAILABLE_WITH_META_DATA = 0xE,
+ PLDM_FILE_ACK_WITH_META_DATA = 0xF,
};
/** @brief PLDM Command specific codes
@@ -75,6 +77,8 @@
#define PLDM_RW_FILE_BY_TYPE_RESP_BYTES 5
#define PLDM_FILE_ACK_REQ_BYTES 7
#define PLDM_FILE_ACK_RESP_BYTES 1
+#define PLDM_FILE_ACK_WITH_META_DATA_REQ_BYTES 23
+#define PLDM_FILE_ACK_WITH_META_DATA_RESP_BYTES 1
/** @struct pldm_read_write_file_memory_req
*
@@ -718,6 +722,89 @@
int decode_file_ack_resp(const struct pldm_msg *msg, size_t payload_length,
uint8_t *completion_code);
+/* FileAckWithMetadata */
+
+/** @struct pldm_file_ack_with_meta_data_req
+ *
+ * Structure representing FileAckWithMetadata request
+ */
+struct pldm_file_ack_with_meta_data_req {
+ uint16_t file_type; //!< Type of file
+ uint32_t file_handle; //!< Handle to file
+ uint8_t file_status; //!< Status of file processing
+ uint32_t file_meta_data_1; //!< Meta data specific to file type 1
+ uint32_t file_meta_data_2; //!< Meta data specific to file type 2
+ uint32_t file_meta_data_3; //!< Meta data specific to file type 3
+ uint32_t file_meta_data_4; //!< meta data specific to file type 4
+} __attribute__((packed));
+
+/** @struct pldm_file_ack_with_meta_data_resp
+ *
+ * Structure representing FileAckWithMetadata response
+ */
+struct pldm_file_ack_with_meta_data_resp {
+ uint8_t completion_code; //!< Completion code
+} __attribute__((packed));
+
+/** @brief Encode FileAckWithMetadata request data
+ *
+ * @param[in] instance_id - Message's instance id
+ * @param[in] file_type - Type of the file
+ * @param[in] file_handle - A handle to the file
+ * @param[in] file_status - Status of file processing
+ * @param[in] file_meta_data_1 - meta data specific to file type 1
+ * @param[in] file_meta_data_2 - meta data specific to file type 2
+ * @param[in] file_meta_data_3 - meta data specific to file type 3
+ * @param[in] file_meta_data_4 - Meta data specific to file type 4
+ * @param[out] msg - Message will be written to this
+ * @return pldm_completion_codes
+ */
+int encode_file_ack_with_meta_data_req(
+ uint8_t instance_id, uint16_t file_type, uint32_t file_handle,
+ uint8_t file_status, uint32_t file_meta_data_1, uint32_t file_meta_data_2,
+ uint32_t file_meta_data_3, uint32_t file_meta_data_4, struct pldm_msg *msg);
+
+/** @brief Decode FileAckWithMetadata command response data
+ *
+ * @param[in] msg - pointer to PLDM response message
+ * @param[in] payload_length - Length of response payload
+ * @param[out] completion_code - PLDM completion code
+ * @return pldm_completion_codes
+ */
+int decode_file_ack_with_meta_data_resp(const struct pldm_msg *msg,
+ size_t payload_length,
+ uint8_t *completion_code);
+
+/** @brief Decode FileAckWithMetadata request data
+ *
+ * @param[in] msg - Pointer to PLDM request message
+ * @param[in] payload_length - Length of request payload
+ * @param[out] file_type - Type of the file
+ * @param[out] file_handle - A handle to the file
+ * @param[out] file_status - Status of file processing
+ * @param[out] file_meta_data_1 - meta data specific to file type 1
+ * @param[out] file_meta_data_2 - meta data specific to file type 2
+ * @param[out] file_meta_data_3 - meta data specific to file type 3
+ * @param[out] file_meta_data_4 - Meta data specific to file type 4
+ * @return pldm_completion_codes
+ */
+int decode_file_ack_with_meta_data_req(
+ const struct pldm_msg *msg, size_t payload_length, uint16_t *file_type,
+ uint32_t *file_handle, uint8_t *file_status, uint32_t *file_meta_data_1,
+ uint32_t *file_meta_data_2, uint32_t *file_meta_data_3,
+ uint32_t *file_meta_data_4);
+
+/** @brief Create a PLDM response message for FileAckWithMetadata
+ *
+ * @param[in] instance_id - Message's instance id
+ * @param[in] completion_code - PLDM completion code
+ * @param[in,out] msg - Message will be written to this
+ * @return pldm_completion_codes
+ */
+int encode_file_ack_with_meta_data_resp(uint8_t instance_id,
+ uint8_t completion_code,
+ struct pldm_msg *msg);
+
#ifdef __cplusplus
}
#endif