blob: afa87fe0a88605a384cb41ab509f6ed0de835448 [file] [log] [blame]
gokulsanker138ceba2021-04-05 13:25:25 +05301#ifndef FW_UPDATE_H
2#define FW_UPDATE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7#include "base.h"
gokulsanker22fbb342021-04-05 15:55:06 +05308#include "utils.h"
gokulsanker138ceba2021-04-05 13:25:25 +05309
Tom Joseph568e4702021-06-07 22:15:49 -070010#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
Tom Joseph58cc1722021-06-09 07:15:49 -070011#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
gokulsanker138ceba2021-04-05 13:25:25 +053012#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
gokulsankereca3e192021-04-05 14:57:41 +053013/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
14 * 2 bytes for descriptor length and atleast 1 byte of descriptor data
15 */
16#define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5
gokulsanker981fbfb2021-04-05 15:17:25 +053017#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
gokulsankerd434edc2021-04-05 16:36:04 +053018#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
19#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
gokulsanker138ceba2021-04-05 13:25:25 +053020
21/** @brief PLDM Firmware update commands
22 */
gokulsanker981fbfb2021-04-05 15:17:25 +053023enum pldm_firmware_update_commands {
24 PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
gokulsankerd434edc2021-04-05 16:36:04 +053025 PLDM_GET_FIRMWARE_PARAMETERS = 0x02,
gokulsanker1b909d82021-04-05 17:26:02 +053026 PLDM_REQUEST_UPDATE = 0x10,
gokulsankeraa3a5cd2021-04-22 11:06:42 +053027 PLDM_PASS_COMPONENT_TABLE = 0x13,
gokulsanker9c440d02021-06-03 09:54:02 +053028 PLDM_UPDATE_COMPONENT = 0x14,
gokulsanker50107cf2021-06-27 09:44:12 +053029 PLDM_REQUEST_FIRMWARE_DATA = 0x15,
gokulsanker9a693582021-06-27 11:35:09 +053030 PLDM_TRANSFER_COMPLETE = 0x16,
gokulsankerd6f79b82021-06-27 12:00:25 +053031 PLDM_VERIFY_COMPLETE = 0x17,
32 PLDM_APPLY_COMPLETE = 0x18
gokulsanker981fbfb2021-04-05 15:17:25 +053033};
gokulsanker138ceba2021-04-05 13:25:25 +053034
gokulsanker611238c2021-04-05 16:50:44 +053035/** @brief PLDM Firmware update completion codes
36 */
37enum pldm_firmware_update_completion_codes {
38 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
39 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
40 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
41 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
42 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
43 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
44 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
45 PLDM_FWUP_CANCEL_PENDING = 0x87,
46 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
47 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
48 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
49 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
50 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
51 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
52 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
53 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
54 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
55 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
56 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
57 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
58};
59
Tom Joseph763b51e2021-06-05 04:50:47 -070060/** @brief String type values defined in the PLDM firmware update specification
61 */
62enum pldm_firmware_update_string_type {
63 PLDM_STR_TYPE_UNKNOWN = 0,
64 PLDM_STR_TYPE_ASCII = 1,
65 PLDM_STR_TYPE_UTF_8 = 2,
66 PLDM_STR_TYPE_UTF_16 = 3,
67 PLDM_STR_TYPE_UTF_16LE = 4,
68 PLDM_STR_TYPE_UTF_16BE = 5
69};
70
71/** @brief Descriptor types defined in PLDM firmware update specification
72 */
73enum pldm_firmware_update_descriptor_types {
74 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
75 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
76 PLDM_FWUP_UUID = 0x0002,
77 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
78 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
79 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
80 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
81 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
82 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
83 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
84 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
85 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
86 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
87 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
88 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
89 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
90 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
91 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
92};
93
94/** @brief Descriptor types length defined in PLDM firmware update specification
95 */
96enum pldm_firmware_update_descriptor_types_length {
97 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
98 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
99 PLDM_FWUP_UUID_LENGTH = 16,
100 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
101 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
102 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
103 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
104 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
105 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
106 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
107 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
108 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
109 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
110 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
111 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
112 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
113 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
114};
115
gokulsanker1b909d82021-04-05 17:26:02 +0530116/** @brief ComponentClassification values defined in firmware update
117 * specification
118 */
119enum pldm_component_classification_values {
120 PLDM_COMP_UNKNOWN = 0x0000,
121 PLDM_COMP_OTHER = 0x0001,
122 PLDM_COMP_DRIVER = 0x0002,
123 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
124 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
125 PLDM_COMP_INSTRUMENTATION = 0x0005,
126 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
127 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
128 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
129 PLDM_COMP_MIDDLEWARE = 0x0009,
130 PLDM_COMP_FIRMWARE = 0x000A,
131 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
132 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
133 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
134 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
135};
136
gokulsanker4687f242021-06-27 11:50:26 +0530137/** @brief ComponentActivationMethods is the bit position in the bitfield that
138 * provides the capability of the FD for firmware activation. Multiple
139 * activation methods can be supported.
140 */
141enum pldm_comp_activation_methods {
142 PLDM_ACTIVATION_AUTOMATIC = 0,
143 PLDM_ACTIVATION_SELF_CONTAINED = 1,
144 PLDM_ACTIVATION_MEDIUM_SPECIFIC_RESET = 2,
145 PLDM_ACTIVATION_SYSTEM_REBOOT = 3,
146 PLDM_ACTIVATION_DC_POWER_CYCLE = 4,
147 PLDM_ACTIVATION_AC_POWER_CYCLE = 5,
148 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE = 6,
149 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE_SET = 7
150};
151
gokulsanker566784b2021-04-05 17:47:04 +0530152/** @brief ComponentResponse values in the response of PassComponentTable
153 */
154enum pldm_component_responses {
155 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
156 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
157};
158
159/** @brief ComponentResponseCode values in the response of PassComponentTable
160 */
161enum pldm_component_response_codes {
162 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
163 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
164 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
165 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
166 PLDM_CRC_COMP_CONFLICT = 0x04,
167 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
168 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
169 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
170 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
171 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
172 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
173 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
174 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
175 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
176};
177
gokulsanker4b533f22021-04-22 12:53:00 +0530178/** @brief ComponentCompatibilityResponse values in the response of
179 * UpdateComponent
180 */
181enum pldm_component_compatability_responses {
182 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
183 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
184};
185
186/** @brief ComponentCompatibilityResponse Code values in the response of
187 * UpdateComponent
188 */
189enum pldm_component_compatability_response_codes {
190 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
191 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
192 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
193 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
194 PLDM_CCRC_COMP_CONFLICT = 0x04,
195 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
196 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
197 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
198 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
199 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
200 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
201 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
202 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
203 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
204};
205
gokulsankere3807022021-06-26 19:12:01 +0530206/** @brief Common error codes in TransferComplete, VerifyComplete and
207 * ApplyComplete request
208 */
209enum pldm_firmware_update_common_error_codes {
210 PLDM_FWUP_TIME_OUT = 0x09,
211 PLDM_FWUP_GENERIC_ERROR = 0x0A
212};
213
gokulsanker50107cf2021-06-27 09:44:12 +0530214/** @brief TransferResult values in the request of TransferComplete
gokulsankere3807022021-06-26 19:12:01 +0530215 */
gokulsanker50107cf2021-06-27 09:44:12 +0530216enum pldm_firmware_update_transfer_result_values {
gokulsankere3807022021-06-26 19:12:01 +0530217 PLDM_FWUP_TRANSFER_SUCCESS = 0x00,
218 PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02,
219 PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02,
220 PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03,
221 PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B,
222 PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C,
223 PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D,
224 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70,
225 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F
226};
227
gokulsanker9a693582021-06-27 11:35:09 +0530228/**@brief VerifyResult values in the request of VerifyComplete
gokulsankerb79b91a2021-06-27 11:26:36 +0530229 */
230enum pldm_firmware_update_verify_result_values {
231 PLDM_FWUP_VERIFY_SUCCESS = 0x00,
232 PLDM_FWUP_VERIFY_ERROR_VERIFICATION_FAILURE = 0x01,
233 PLDM_FWUP_VERIFY_ERROR_VERSION_MISMATCH = 0x02,
234 PLDM_FWUP_VERIFY_FAILED_FD_SECURITY_CHECKS = 0x03,
235 PLDM_FWUP_VERIFY_ERROR_IMAGE_INCOMPLETE = 0x04,
236 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MIN = 0x90,
237 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MAX = 0xAF
238};
239
gokulsankerd6f79b82021-06-27 12:00:25 +0530240/**@brief ApplyResult values in the request of ApplyComplete
gokulsanker4687f242021-06-27 11:50:26 +0530241 */
242enum pldm_firmware_update_apply_result_values {
243 PLDM_FWUP_APPLY_SUCCESS = 0x00,
244 PLDM_FWUP_APPLY_SUCCESS_WITH_ACTIVATION_METHOD = 0x01,
245 PLDM_FWUP_APPLY_FAILURE_MEMORY_ISSUE = 0x02,
246 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MIN = 0xB0,
247 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MAX = 0xCF
248};
249
Tom Joseph568e4702021-06-07 22:15:49 -0700250/** @struct pldm_package_header_information
251 *
252 * Structure representing fixed part of package header information
253 */
254struct pldm_package_header_information {
255 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
256 uint8_t package_header_format_version;
257 uint16_t package_header_size;
258 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
259 uint16_t component_bitmap_bit_length;
260 uint8_t package_version_string_type;
261 uint8_t package_version_string_length;
262} __attribute__((packed));
263
Tom Joseph64af3452021-06-08 04:05:28 -0700264/** @struct pldm_firmware_device_id_record
265 *
266 * Structure representing firmware device ID record
267 */
268struct pldm_firmware_device_id_record {
269 uint16_t record_length;
270 uint8_t descriptor_count;
271 bitfield32_t device_update_option_flags;
272 uint8_t comp_image_set_version_string_type;
273 uint8_t comp_image_set_version_string_length;
274 uint16_t fw_device_pkg_data_length;
275} __attribute__((packed));
276
Tom Joseph763b51e2021-06-05 04:50:47 -0700277/** @struct pldm_descriptor_tlv
278 *
279 * Structure representing descriptor type, length and value
280 */
281struct pldm_descriptor_tlv {
282 uint16_t descriptor_type;
283 uint16_t descriptor_length;
284 uint8_t descriptor_data[1];
285} __attribute__((packed));
286
287/** @struct pldm_vendor_defined_descriptor_title_data
288 *
289 * Structure representing vendor defined descriptor title sections
290 */
291struct pldm_vendor_defined_descriptor_title_data {
292 uint8_t vendor_defined_descriptor_title_str_type;
293 uint8_t vendor_defined_descriptor_title_str_len;
294 uint8_t vendor_defined_descriptor_title_str[1];
295} __attribute__((packed));
296
Tom Joseph58cc1722021-06-09 07:15:49 -0700297/** @struct pldm_component_image_information
298 *
299 * Structure representing fixed part of individual component information in
300 * PLDM firmware update package
301 */
302struct pldm_component_image_information {
303 uint16_t comp_classification;
304 uint16_t comp_identifier;
305 uint32_t comp_comparison_stamp;
306 bitfield16_t comp_options;
307 bitfield16_t requested_comp_activation_method;
308 uint32_t comp_location_offset;
309 uint32_t comp_size;
310 uint8_t comp_version_string_type;
311 uint8_t comp_version_string_length;
312} __attribute__((packed));
313
gokulsankereca3e192021-04-05 14:57:41 +0530314/** @struct pldm_query_device_identifiers_resp
315 *
316 * Structure representing query device identifiers response.
317 */
318struct pldm_query_device_identifiers_resp {
319 uint8_t completion_code;
320 uint32_t device_identifiers_len;
321 uint8_t descriptor_count;
322} __attribute__((packed));
323
gokulsanker22fbb342021-04-05 15:55:06 +0530324/** @struct pldm_get_firmware_parameters_resp
325 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700326 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530327 */
328struct pldm_get_firmware_parameters_resp {
329 uint8_t completion_code;
330 bitfield32_t capabilities_during_update;
331 uint16_t comp_count;
332 uint8_t active_comp_image_set_ver_str_type;
333 uint8_t active_comp_image_set_ver_str_len;
334 uint8_t pending_comp_image_set_ver_str_type;
335 uint8_t pending_comp_image_set_ver_str_len;
336} __attribute__((packed));
337
gokulsankere1fb7a82021-04-05 16:09:29 +0530338/** @struct pldm_component_parameter_entry
339 *
340 * Structure representing component parameter table entry.
341 */
342struct pldm_component_parameter_entry {
343 uint16_t comp_classification;
344 uint16_t comp_identifier;
345 uint8_t comp_classification_index;
346 uint32_t active_comp_comparison_stamp;
347 uint8_t active_comp_ver_str_type;
348 uint8_t active_comp_ver_str_len;
349 uint8_t active_comp_release_date[8];
350 uint32_t pending_comp_comparison_stamp;
351 uint8_t pending_comp_ver_str_type;
352 uint8_t pending_comp_ver_str_len;
353 uint8_t pending_comp_release_date[8];
354 bitfield16_t comp_activation_methods;
355 bitfield32_t capabilities_during_update;
356} __attribute__((packed));
357
gokulsankerd434edc2021-04-05 16:36:04 +0530358/** @struct pldm_request_update_req
359 *
360 * Structure representing fixed part of Request Update request
361 */
362struct pldm_request_update_req {
363 uint32_t max_transfer_size;
364 uint16_t num_of_comp;
365 uint8_t max_outstanding_transfer_req;
366 uint16_t pkg_data_len;
367 uint8_t comp_image_set_ver_str_type;
368 uint8_t comp_image_set_ver_str_len;
369} __attribute__((packed));
370
gokulsanker611238c2021-04-05 16:50:44 +0530371/** @struct pldm_request_update_resp
372 *
373 * Structure representing Request Update response
374 */
375struct pldm_request_update_resp {
376 uint8_t completion_code;
377 uint16_t fd_meta_data_len;
378 uint8_t fd_will_send_pkg_data;
379} __attribute__((packed));
380
gokulsanker1b909d82021-04-05 17:26:02 +0530381/** @struct pldm_pass_component_table_req
382 *
383 * Structure representing PassComponentTable request
384 */
385struct pldm_pass_component_table_req {
386 uint8_t transfer_flag;
387 uint16_t comp_classification;
388 uint16_t comp_identifier;
389 uint8_t comp_classification_index;
390 uint32_t comp_comparison_stamp;
391 uint8_t comp_ver_str_type;
392 uint8_t comp_ver_str_len;
393} __attribute__((packed));
394
gokulsanker566784b2021-04-05 17:47:04 +0530395/** @struct pldm_pass_component_table_resp
396 *
397 * Structure representing PassComponentTable response
398 */
399struct pldm_pass_component_table_resp {
400 uint8_t completion_code;
401 uint8_t comp_resp;
402 uint8_t comp_resp_code;
403} __attribute__((packed));
404
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530405/** @struct pldm_update_component_req
406 *
407 * Structure representing UpdateComponent request
408 */
409struct pldm_update_component_req {
410 uint16_t comp_classification;
411 uint16_t comp_identifier;
412 uint8_t comp_classification_index;
413 uint32_t comp_comparison_stamp;
414 uint32_t comp_image_size;
415 bitfield32_t update_option_flags;
416 uint8_t comp_ver_str_type;
417 uint8_t comp_ver_str_len;
418} __attribute__((packed));
419
gokulsanker4b533f22021-04-22 12:53:00 +0530420/** @struct pldm_update_component_resp
421 *
422 * Structure representing UpdateComponent response
423 */
424struct pldm_update_component_resp {
425 uint8_t completion_code;
426 uint8_t comp_compatability_resp;
427 uint8_t comp_compatability_resp_code;
428 bitfield32_t update_option_flags_enabled;
429 uint16_t time_before_req_fw_data;
430} __attribute__((packed));
431
gokulsankera4e6b292021-06-02 16:35:39 +0530432/** @struct pldm_request_firmware_data_req
433 *
434 * Structure representing RequestFirmwareData request.
435 */
436struct pldm_request_firmware_data_req {
437 uint32_t offset;
438 uint32_t length;
439} __attribute__((packed));
440
gokulsanker4687f242021-06-27 11:50:26 +0530441/** @struct pldm_apply_complete_req
442 *
443 * Structure representing ApplyComplete request.
444 */
445struct pldm_apply_complete_req {
446 uint8_t apply_result;
447 bitfield16_t comp_activation_methods_modification;
448} __attribute__((packed));
449
Tom Joseph568e4702021-06-07 22:15:49 -0700450/** @brief Decode the PLDM package header information
451 *
452 * @param[in] data - pointer to package header information
453 * @param[in] length - available length in the firmware update package
454 * @param[out] package_header_info - pointer to fixed part of PLDM package
455 * header information
456 * @param[out] package_version_str - pointer to package version string
457 *
458 * @return pldm_completion_codes
459 */
460int decode_pldm_package_header_info(
461 const uint8_t *data, size_t length,
462 struct pldm_package_header_information *package_header_info,
463 struct variable_field *package_version_str);
464
Tom Joseph64af3452021-06-08 04:05:28 -0700465/** @brief Decode individual firmware device ID record
466 *
467 * @param[in] data - pointer to firmware device ID record
468 * @param[in] length - available length in the firmware update package
469 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
470 * parsed from the package header info
471 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
472 * id record
473 * @param[out] applicable_components - pointer to ApplicableComponents
474 * @param[out] comp_image_set_version_str - pointer to
475 * ComponentImageSetVersionString
476 * @param[out] record_descriptors - pointer to RecordDescriptors
477 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
478 *
479 * @return pldm_completion_codes
480 */
481int decode_firmware_device_id_record(
482 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
483 struct pldm_firmware_device_id_record *fw_device_id_record,
484 struct variable_field *applicable_components,
485 struct variable_field *comp_image_set_version_str,
486 struct variable_field *record_descriptors,
487 struct variable_field *fw_device_pkg_data);
488
Tom Joseph763b51e2021-06-05 04:50:47 -0700489/** @brief Decode the record descriptor entries in the firmware update package
490 * and the Descriptors in the QueryDeviceIDentifiers command
491 *
492 * @param[in] data - pointer to descriptor entry
493 * @param[in] length - remaining length of the descriptor data
494 * @param[out] descriptor_type - pointer to descriptor type
495 * @param[out] descriptor_data - pointer to descriptor data
496 *
497 * @return pldm_completion_codes
498 */
499int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
500 uint16_t *descriptor_type,
501 struct variable_field *descriptor_data);
502
503/** @brief Decode the vendor defined descriptor value
504 *
505 * @param[in] data - pointer to vendor defined descriptor value
506 * @param[in] length - length of the vendor defined descriptor value
507 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
508 * title string type
509 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
510 * title string
511 * @param[out] descriptor_data - pointer to vendor defined descriptor data
512 *
513 * @return pldm_completion_codes
514 */
515int decode_vendor_defined_descriptor_value(
516 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
517 struct variable_field *descriptor_title_str,
518 struct variable_field *descriptor_data);
519
Tom Joseph58cc1722021-06-09 07:15:49 -0700520/** @brief Decode individual component image information
521 *
522 * @param[in] data - pointer to component image information
523 * @param[in] length - available length in the firmware update package
524 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
525 * information
526 * @param[out] comp_version_str - pointer to component version string
527 *
528 * @return pldm_completion_codes
529 */
530int decode_pldm_comp_image_info(
531 const uint8_t *data, size_t length,
532 struct pldm_component_image_information *pldm_comp_image_info,
533 struct variable_field *comp_version_str);
534
gokulsanker138ceba2021-04-05 13:25:25 +0530535/** @brief Create a PLDM request message for QueryDeviceIdentifiers
536 *
537 * @param[in] instance_id - Message's instance id
538 * @param[in] payload_length - Length of the request message payload
539 * @param[in,out] msg - Message will be written to this
540 *
541 * @return pldm_completion_codes
542 *
543 * @note Caller is responsible for memory alloc and dealloc of param
544 * 'msg.payload'
545 */
546int encode_query_device_identifiers_req(uint8_t instance_id,
547 size_t payload_length,
548 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530549
550/** @brief Decode QueryDeviceIdentifiers response message
551 *
552 * @param[in] msg - Response message
553 * @param[in] payload_length - Length of response message payload
554 * @param[out] completion_code - Pointer to response msg's PLDM completion code
555 * @param[out] device_identifiers_len - Pointer to device identifiers length
556 * @param[out] descriptor_count - Pointer to descriptor count
557 * @param[out] descriptor_data - Pointer to descriptor data
558 *
559 * @return pldm_completion_codes
560 */
561int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
562 size_t payload_length,
563 uint8_t *completion_code,
564 uint32_t *device_identifiers_len,
565 uint8_t *descriptor_count,
566 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530567
568/** @brief Create a PLDM request message for GetFirmwareParameters
569 *
570 * @param[in] instance_id - Message's instance id
571 * @param[in] payload_length - Length of the request message payload
572 * @param[in,out] msg - Message will be written to this
573 *
574 * @return pldm_completion_codes
575 *
576 * @note Caller is responsible for memory alloc and dealloc of param
577 * 'msg.payload'
578 */
579int encode_get_firmware_parameters_req(uint8_t instance_id,
580 size_t payload_length,
581 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530582
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700583/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530584 *
585 * @param[in] msg - Response message
586 * @param[in] payload_length - Length of response message payload
587 * @param[out] resp_data - Pointer to get firmware parameters response
588 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700589 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530590 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700591 * image set version string
592 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530593 *
594 * @return pldm_completion_codes
595 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700596int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530597 const struct pldm_msg *msg, size_t payload_length,
598 struct pldm_get_firmware_parameters_resp *resp_data,
599 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700600 struct variable_field *pending_comp_image_set_ver_str,
601 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530602
gokulsankere1fb7a82021-04-05 16:09:29 +0530603/** @brief Decode component entries in the component parameter table which is
604 * part of the response of GetFirmwareParameters command
605 *
606 * @param[in] data - Component entry
607 * @param[in] length - Length of component entry
608 * @param[out] component_data - Pointer to component parameter table
609 * @param[out] active_comp_ver_str - Pointer to active component version string
610 * @param[out] pending_comp_ver_str - Pointer to pending component version
611 * string
612 *
613 * @return pldm_completion_codes
614 */
615int decode_get_firmware_parameters_resp_comp_entry(
616 const uint8_t *data, size_t length,
617 struct pldm_component_parameter_entry *component_data,
618 struct variable_field *active_comp_ver_str,
619 struct variable_field *pending_comp_ver_str);
620
gokulsankerd434edc2021-04-05 16:36:04 +0530621/** @brief Create PLDM request message for RequestUpdate
622 *
623 * @param[in] instance_id - Message's instance id
624 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
625 * to be requested via RequestFirmwareData
626 * command
627 * @param[in] num_of_comp - Total number of components that will be passed to
628 * the FD during the update
629 * @param[in] max_outstanding_transfer_req - Total number of outstanding
630 * RequestFirmwareData
631 * commands that can be sent by the FD
632 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
633 * present in firmware package header
634 * @param[in] comp_image_set_ver_str_type - StringType of
635 * ComponentImageSetVersionString
636 * @param[in] comp_image_set_ver_str_len - The length of the
637 * ComponentImageSetVersionString
638 * @param[in] comp_img_set_ver_str - Component Image Set version information
639 * @param[in,out] msg - Message will be written to this
640 * @param[in] payload_length - Length of request message payload
641 *
642 * @return pldm_completion_codes
643 *
644 * @note Caller is responsible for memory alloc and dealloc of param
645 * 'msg.payload'
646 */
647int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
648 uint16_t num_of_comp,
649 uint8_t max_outstanding_transfer_req,
650 uint16_t pkg_data_len,
651 uint8_t comp_image_set_ver_str_type,
652 uint8_t comp_image_set_ver_str_len,
653 const struct variable_field *comp_img_set_ver_str,
654 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530655
656/** @brief Decode a RequestUpdate response message
657 *
658 * @param[in] msg - Response message
659 * @param[in] payload_length - Length of response message payload
660 * @param[out] completion_code - Pointer to hold the completion code
661 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
662 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
663 * will send GetPackageData command
664 * @return pldm_completion_codes
665 */
666int decode_request_update_resp(const struct pldm_msg *msg,
667 size_t payload_length, uint8_t *completion_code,
668 uint16_t *fd_meta_data_len,
669 uint8_t *fd_will_send_pkg_data);
670
gokulsanker1b909d82021-04-05 17:26:02 +0530671/** @brief Create PLDM request message for PassComponentTable
672 *
673 * @param[in] instance_id - Message's instance id
674 * @param[in] transfer_flag - TransferFlag
675 * @param[in] comp_classification - ComponentClassification
676 * @param[in] comp_identifier - ComponentIdentifier
677 * @param[in] comp_classification_index - ComponentClassificationIndex
678 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
679 * @param[in] comp_ver_str_type - ComponentVersionStringType
680 * @param[in] comp_ver_str_len - ComponentVersionStringLength
681 * @param[in] comp_ver_str - ComponentVersionString
682 * @param[in,out] msg - Message will be written to this
683 * @param[in] payload_length - Length of request message payload
684 * information
685 *
686 * @return pldm_completion_codes
687 *
688 * @note Caller is responsible for memory alloc and dealloc of param
689 * 'msg.payload'
690 */
691int encode_pass_component_table_req(
692 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
693 uint16_t comp_identifier, uint8_t comp_classification_index,
694 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
695 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
696 struct pldm_msg *msg, size_t payload_length);
697
gokulsanker566784b2021-04-05 17:47:04 +0530698/** @brief Decode PassComponentTable response message
699 *
700 * @param[in] msg - Response message
701 * @param[in] payload_length - Length of response message payload
702 * @param[out] completion_code - Pointer to hold completion code
703 * @param[out] comp_resp - Pointer to hold component response
704 * @param[out] comp_resp_code - Pointer to hold component response code
705 *
706 * @return pldm_completion_codes
707 */
708int decode_pass_component_table_resp(const struct pldm_msg *msg,
709 size_t payload_length,
710 uint8_t *completion_code,
711 uint8_t *comp_resp,
712 uint8_t *comp_resp_code);
713
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530714/** @brief Create PLDM request message for UpdateComponent
715 *
716 * @param[in] instance_id - Message's instance id
717 * @param[in] comp_classification - ComponentClassification
718 * @param[in] comp_identifier - ComponentIdentifier
719 * @param[in] comp_classification_index - ComponentClassificationIndex
720 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
721 * @param[in] comp_image_size - ComponentImageSize
722 * @param[in] update_option_flags - UpdateOptionFlags
723 * @param[in] comp_ver_str_type - ComponentVersionStringType
724 * @param[in] comp_ver_str_len - ComponentVersionStringLength
725 * @param[in] comp_ver_str - ComponentVersionString
726 * @param[in,out] msg - Message will be written to this
727 * @param[in] payload_length - Length of request message payload
728 * information
729 *
730 * @return pldm_completion_codes
731 *
732 * @note Caller is responsible for memory alloc and dealloc of param
733 * 'msg.payload'
734 */
735int encode_update_component_req(
736 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
737 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
738 uint32_t comp_image_size, bitfield32_t update_option_flags,
739 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
740 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
741 size_t payload_length);
742
gokulsanker4b533f22021-04-22 12:53:00 +0530743/** @brief Decode UpdateComponent response message
744 *
745 * @param[in] msg - Response message
746 * @param[in] payload_length - Length of response message payload
747 * @param[out] completion_code - Pointer to hold completion code
748 * @param[out] comp_compatability_resp - Pointer to hold component
749 * compatibility response
750 * @param[out] comp_compatability_resp_code - Pointer to hold component
751 * compatibility response code
752 * @param[out] update_option_flags_enabled - Pointer to hold
753 * UpdateOptionsFlagEnabled
754 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
755 * before sending RequestFirmwareData
756 *
757 * @return pldm_completion_codes
758 */
759int decode_update_component_resp(const struct pldm_msg *msg,
760 size_t payload_length,
761 uint8_t *completion_code,
762 uint8_t *comp_compatability_resp,
763 uint8_t *comp_compatability_resp_code,
764 bitfield32_t *update_option_flags_enabled,
765 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530766
767/** @brief Decode RequestFirmwareData request message
768 *
769 * @param[in] msg - Request message
770 * @param[in] payload_length - Length of request message payload
771 * @param[out] offset - Pointer to hold offset
772 * @param[out] length - Pointer to hold the size of the component image
773 * segment requested by the FD/FDP
774 *
775 * @return pldm_completion_codes
776 */
777int decode_request_firmware_data_req(const struct pldm_msg *msg,
778 size_t payload_length, uint32_t *offset,
779 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530780
781/** @brief Create PLDM response message for RequestFirmwareData
782 *
783 * The ComponentImagePortion is not encoded in the PLDM response message
784 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
785 * ComponentImagePortion in the PLDM response message is handled by the user
786 * of this API. The payload_length validation considers only the
787 * CompletionCode.
788 *
789 * @param[in] instance_id - Message's instance id
790 * @param[in] completion_code - CompletionCode
791 * @param[in,out] msg - Message will be written to this
792 * @param[in] payload_length - Length of response message payload
793 *
794 * @return pldm_completion_codes
795 *
796 * @note Caller is responsible for memory alloc and dealloc of param
797 * 'msg.payload'
798 */
799int encode_request_firmware_data_resp(uint8_t instance_id,
800 uint8_t completion_code,
801 struct pldm_msg *msg,
802 size_t payload_length);
803
gokulsankere3807022021-06-26 19:12:01 +0530804/** @brief Decode TransferComplete request message
805 *
806 * @param[in] msg - Request message
807 * @param[in] payload_length - Length of request message payload
808 * @param[out] transfer_result - Pointer to hold TransferResult
809 *
810 * @return pldm_completion_codes
811 */
812int decode_transfer_complete_req(const struct pldm_msg *msg,
813 size_t payload_length,
814 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530815
816/** @brief Create PLDM response message for TransferComplete
817 *
818 * @param[in] instance_id - Message's instance id
819 * @param[in] completion_code - CompletionCode
820 * @param[in,out] msg - Message will be written to this
821 * @param[in] payload_length - Length of response message payload
822 *
823 * @return pldm_completion_codes
824 *
825 * @note Caller is responsible for memory alloc and dealloc of param
826 * 'msg.payload'
827 */
828int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
829 struct pldm_msg *msg, size_t payload_length);
gokulsankerb79b91a2021-06-27 11:26:36 +0530830
831/** @brief Decode VerifyComplete request message
832 *
833 * @param[in] msg - Request message
834 * @param[in] payload_length - Length of request message payload
835 * @param[in] verify_result - Pointer to hold VerifyResult
836 *
837 * @return pldm_completion_codes
838 */
839int decode_verify_complete_req(const struct pldm_msg *msg,
840 size_t payload_length, uint8_t *verify_result);
841
gokulsanker9a693582021-06-27 11:35:09 +0530842/** @brief Create PLDM response message for VerifyComplete
843 *
844 * @param[in] instance_id - Message's instance id
845 * @param[in] completion_code - CompletionCode
846 * @param[in,out] msg - Message will be written to this
847 * @param[in] payload_length - Length of response message payload
848 *
849 * @return pldm_completion_codes
850 *
851 * @note Caller is responsible for memory alloc and dealloc of param
852 * 'msg.payload'
853 */
854int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code,
855 struct pldm_msg *msg, size_t payload_length);
856
gokulsanker4687f242021-06-27 11:50:26 +0530857/** @brief Decode ApplyComplete request message
858 *
859 * @param[in] msg - Request message
860 * @param[in] payload_length - Length of request message payload
861 * @param[in] apply_result - Pointer to hold ApplyResult
862 * @param[in] comp_activation_methods_modification - Pointer to hold the
863 * ComponentActivationMethodsModification
864 *
865 * @return pldm_completion_codes
866 */
867int decode_apply_complete_req(
868 const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result,
869 bitfield16_t *comp_activation_methods_modification);
870
gokulsankerd6f79b82021-06-27 12:00:25 +0530871/** @brief Create PLDM response message for ApplyComplete
872 *
873 * @param[in] instance_id - Message's instance id
874 * @param[in] completion_code - CompletionCode
875 * @param[in,out] msg - Message will be written to this
876 * @param[in] payload_length - Length of response message payload
877 *
878 * @return pldm_completion_codes
879 *
880 * @note Caller is responsible for memory alloc and dealloc of param
881 * 'msg.payload'
882 */
883int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code,
884 struct pldm_msg *msg, size_t payload_length);
885
gokulsanker138ceba2021-04-05 13:25:25 +0530886#ifdef __cplusplus
887}
888#endif
889
890#endif // End of FW_UPDATE_H