blob: 231aaa00feb697fb7c3a40bde164a9c7e79b3497 [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"
gokulsanker773cd1f2021-04-27 17:59:15 +05308#include "stdbool.h"
gokulsanker22fbb342021-04-05 15:55:06 +05309#include "utils.h"
gokulsanker138ceba2021-04-05 13:25:25 +053010
Tom Joseph568e4702021-06-07 22:15:49 -070011#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
Tom Joseph58cc1722021-06-09 07:15:49 -070012#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
gokulsanker138ceba2021-04-05 13:25:25 +053013#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
gokulsankereca3e192021-04-05 14:57:41 +053014/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
15 * 2 bytes for descriptor length and atleast 1 byte of descriptor data
16 */
17#define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5
gokulsanker981fbfb2021-04-05 15:17:25 +053018#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
gokulsankerd434edc2021-04-05 16:36:04 +053019#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
20#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
gokulsanker42254422021-04-22 19:43:23 +053021#define PLDM_GET_STATUS_REQ_BYTES 0
gokulsanker138ceba2021-04-05 13:25:25 +053022
23/** @brief PLDM Firmware update commands
24 */
gokulsanker981fbfb2021-04-05 15:17:25 +053025enum pldm_firmware_update_commands {
26 PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
gokulsankerd434edc2021-04-05 16:36:04 +053027 PLDM_GET_FIRMWARE_PARAMETERS = 0x02,
gokulsanker1b909d82021-04-05 17:26:02 +053028 PLDM_REQUEST_UPDATE = 0x10,
gokulsankeraa3a5cd2021-04-22 11:06:42 +053029 PLDM_PASS_COMPONENT_TABLE = 0x13,
gokulsanker9c440d02021-06-03 09:54:02 +053030 PLDM_UPDATE_COMPONENT = 0x14,
gokulsanker50107cf2021-06-27 09:44:12 +053031 PLDM_REQUEST_FIRMWARE_DATA = 0x15,
gokulsanker9a693582021-06-27 11:35:09 +053032 PLDM_TRANSFER_COMPLETE = 0x16,
gokulsankerd6f79b82021-06-27 12:00:25 +053033 PLDM_VERIFY_COMPLETE = 0x17,
gokulsanker773cd1f2021-04-27 17:59:15 +053034 PLDM_APPLY_COMPLETE = 0x18,
gokulsanker42254422021-04-22 19:43:23 +053035 PLDM_ACTIVATE_FIRMWARE = 0x1A,
36 PLDM_GET_STATUS = 0x1B
gokulsanker981fbfb2021-04-05 15:17:25 +053037};
gokulsanker138ceba2021-04-05 13:25:25 +053038
gokulsanker611238c2021-04-05 16:50:44 +053039/** @brief PLDM Firmware update completion codes
40 */
41enum pldm_firmware_update_completion_codes {
42 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
43 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
44 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
45 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
46 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
47 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
48 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
49 PLDM_FWUP_CANCEL_PENDING = 0x87,
50 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
51 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
52 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
53 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
54 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
55 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
56 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
57 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
58 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
59 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
60 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
61 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
62};
63
Tom Joseph763b51e2021-06-05 04:50:47 -070064/** @brief String type values defined in the PLDM firmware update specification
65 */
66enum pldm_firmware_update_string_type {
67 PLDM_STR_TYPE_UNKNOWN = 0,
68 PLDM_STR_TYPE_ASCII = 1,
69 PLDM_STR_TYPE_UTF_8 = 2,
70 PLDM_STR_TYPE_UTF_16 = 3,
71 PLDM_STR_TYPE_UTF_16LE = 4,
72 PLDM_STR_TYPE_UTF_16BE = 5
73};
74
75/** @brief Descriptor types defined in PLDM firmware update specification
76 */
77enum pldm_firmware_update_descriptor_types {
78 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
79 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
80 PLDM_FWUP_UUID = 0x0002,
81 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
82 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
83 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
84 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
85 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
86 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
87 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
88 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
89 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
90 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
91 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
92 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
93 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
94 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
95 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
96};
97
98/** @brief Descriptor types length defined in PLDM firmware update specification
99 */
100enum pldm_firmware_update_descriptor_types_length {
101 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
102 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
103 PLDM_FWUP_UUID_LENGTH = 16,
104 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
105 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
106 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
107 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
108 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
109 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
110 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
111 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
112 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
113 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
114 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
115 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
116 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
117 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
118};
119
gokulsanker1b909d82021-04-05 17:26:02 +0530120/** @brief ComponentClassification values defined in firmware update
121 * specification
122 */
123enum pldm_component_classification_values {
124 PLDM_COMP_UNKNOWN = 0x0000,
125 PLDM_COMP_OTHER = 0x0001,
126 PLDM_COMP_DRIVER = 0x0002,
127 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
128 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
129 PLDM_COMP_INSTRUMENTATION = 0x0005,
130 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
131 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
132 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
133 PLDM_COMP_MIDDLEWARE = 0x0009,
134 PLDM_COMP_FIRMWARE = 0x000A,
135 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
136 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
137 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
138 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
139};
140
gokulsanker4687f242021-06-27 11:50:26 +0530141/** @brief ComponentActivationMethods is the bit position in the bitfield that
142 * provides the capability of the FD for firmware activation. Multiple
143 * activation methods can be supported.
144 */
145enum pldm_comp_activation_methods {
146 PLDM_ACTIVATION_AUTOMATIC = 0,
147 PLDM_ACTIVATION_SELF_CONTAINED = 1,
148 PLDM_ACTIVATION_MEDIUM_SPECIFIC_RESET = 2,
149 PLDM_ACTIVATION_SYSTEM_REBOOT = 3,
150 PLDM_ACTIVATION_DC_POWER_CYCLE = 4,
151 PLDM_ACTIVATION_AC_POWER_CYCLE = 5,
152 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE = 6,
153 PLDM_SUPPORTS_ACTIVATE_PENDING_IMAGE_SET = 7
154};
155
gokulsanker566784b2021-04-05 17:47:04 +0530156/** @brief ComponentResponse values in the response of PassComponentTable
157 */
158enum pldm_component_responses {
159 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
160 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
161};
162
163/** @brief ComponentResponseCode values in the response of PassComponentTable
164 */
165enum pldm_component_response_codes {
166 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
167 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
168 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
169 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
170 PLDM_CRC_COMP_CONFLICT = 0x04,
171 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
172 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
173 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
174 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
175 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
176 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
177 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
178 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
179 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
180};
181
gokulsanker4b533f22021-04-22 12:53:00 +0530182/** @brief ComponentCompatibilityResponse values in the response of
183 * UpdateComponent
184 */
185enum pldm_component_compatability_responses {
186 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
187 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
188};
189
190/** @brief ComponentCompatibilityResponse Code values in the response of
191 * UpdateComponent
192 */
193enum pldm_component_compatability_response_codes {
194 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
195 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
196 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
197 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
198 PLDM_CCRC_COMP_CONFLICT = 0x04,
199 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
200 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
201 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
202 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
203 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
204 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
205 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
206 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
207 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
208};
209
gokulsankere3807022021-06-26 19:12:01 +0530210/** @brief Common error codes in TransferComplete, VerifyComplete and
211 * ApplyComplete request
212 */
213enum pldm_firmware_update_common_error_codes {
214 PLDM_FWUP_TIME_OUT = 0x09,
215 PLDM_FWUP_GENERIC_ERROR = 0x0A
216};
217
gokulsanker50107cf2021-06-27 09:44:12 +0530218/** @brief TransferResult values in the request of TransferComplete
gokulsankere3807022021-06-26 19:12:01 +0530219 */
gokulsanker50107cf2021-06-27 09:44:12 +0530220enum pldm_firmware_update_transfer_result_values {
gokulsankere3807022021-06-26 19:12:01 +0530221 PLDM_FWUP_TRANSFER_SUCCESS = 0x00,
222 PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02,
223 PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02,
224 PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03,
225 PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B,
226 PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C,
227 PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D,
228 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70,
229 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F
230};
231
gokulsanker9a693582021-06-27 11:35:09 +0530232/**@brief VerifyResult values in the request of VerifyComplete
gokulsankerb79b91a2021-06-27 11:26:36 +0530233 */
234enum pldm_firmware_update_verify_result_values {
235 PLDM_FWUP_VERIFY_SUCCESS = 0x00,
236 PLDM_FWUP_VERIFY_ERROR_VERIFICATION_FAILURE = 0x01,
237 PLDM_FWUP_VERIFY_ERROR_VERSION_MISMATCH = 0x02,
238 PLDM_FWUP_VERIFY_FAILED_FD_SECURITY_CHECKS = 0x03,
239 PLDM_FWUP_VERIFY_ERROR_IMAGE_INCOMPLETE = 0x04,
240 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MIN = 0x90,
241 PLDM_FWUP_VENDOR_VERIFY_RESULT_RANGE_MAX = 0xAF
242};
243
gokulsankerd6f79b82021-06-27 12:00:25 +0530244/**@brief ApplyResult values in the request of ApplyComplete
gokulsanker4687f242021-06-27 11:50:26 +0530245 */
246enum pldm_firmware_update_apply_result_values {
247 PLDM_FWUP_APPLY_SUCCESS = 0x00,
248 PLDM_FWUP_APPLY_SUCCESS_WITH_ACTIVATION_METHOD = 0x01,
249 PLDM_FWUP_APPLY_FAILURE_MEMORY_ISSUE = 0x02,
250 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MIN = 0xB0,
251 PLDM_FWUP_VENDOR_APPLY_RESULT_RANGE_MAX = 0xCF
252};
253
gokulsanker773cd1f2021-04-27 17:59:15 +0530254/** @brief SelfContainedActivationRequest in the request of ActivateFirmware
255 */
256enum pldm_self_contained_activation_req {
257 PLDM_NOT_ACTIVATE_SELF_CONTAINED_COMPONENTS = false,
258 PLDM_ACTIVATE_SELF_CONTAINED_COMPONENTS = true
259};
260
Tom Joseph568e4702021-06-07 22:15:49 -0700261/** @struct pldm_package_header_information
262 *
263 * Structure representing fixed part of package header information
264 */
265struct pldm_package_header_information {
266 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
267 uint8_t package_header_format_version;
268 uint16_t package_header_size;
269 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
270 uint16_t component_bitmap_bit_length;
271 uint8_t package_version_string_type;
272 uint8_t package_version_string_length;
273} __attribute__((packed));
274
Tom Joseph64af3452021-06-08 04:05:28 -0700275/** @struct pldm_firmware_device_id_record
276 *
277 * Structure representing firmware device ID record
278 */
279struct pldm_firmware_device_id_record {
280 uint16_t record_length;
281 uint8_t descriptor_count;
282 bitfield32_t device_update_option_flags;
283 uint8_t comp_image_set_version_string_type;
284 uint8_t comp_image_set_version_string_length;
285 uint16_t fw_device_pkg_data_length;
286} __attribute__((packed));
287
Tom Joseph763b51e2021-06-05 04:50:47 -0700288/** @struct pldm_descriptor_tlv
289 *
290 * Structure representing descriptor type, length and value
291 */
292struct pldm_descriptor_tlv {
293 uint16_t descriptor_type;
294 uint16_t descriptor_length;
295 uint8_t descriptor_data[1];
296} __attribute__((packed));
297
298/** @struct pldm_vendor_defined_descriptor_title_data
299 *
300 * Structure representing vendor defined descriptor title sections
301 */
302struct pldm_vendor_defined_descriptor_title_data {
303 uint8_t vendor_defined_descriptor_title_str_type;
304 uint8_t vendor_defined_descriptor_title_str_len;
305 uint8_t vendor_defined_descriptor_title_str[1];
306} __attribute__((packed));
307
Tom Joseph58cc1722021-06-09 07:15:49 -0700308/** @struct pldm_component_image_information
309 *
310 * Structure representing fixed part of individual component information in
311 * PLDM firmware update package
312 */
313struct pldm_component_image_information {
314 uint16_t comp_classification;
315 uint16_t comp_identifier;
316 uint32_t comp_comparison_stamp;
317 bitfield16_t comp_options;
318 bitfield16_t requested_comp_activation_method;
319 uint32_t comp_location_offset;
320 uint32_t comp_size;
321 uint8_t comp_version_string_type;
322 uint8_t comp_version_string_length;
323} __attribute__((packed));
324
gokulsankereca3e192021-04-05 14:57:41 +0530325/** @struct pldm_query_device_identifiers_resp
326 *
327 * Structure representing query device identifiers response.
328 */
329struct pldm_query_device_identifiers_resp {
330 uint8_t completion_code;
331 uint32_t device_identifiers_len;
332 uint8_t descriptor_count;
333} __attribute__((packed));
334
gokulsanker22fbb342021-04-05 15:55:06 +0530335/** @struct pldm_get_firmware_parameters_resp
336 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700337 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530338 */
339struct pldm_get_firmware_parameters_resp {
340 uint8_t completion_code;
341 bitfield32_t capabilities_during_update;
342 uint16_t comp_count;
343 uint8_t active_comp_image_set_ver_str_type;
344 uint8_t active_comp_image_set_ver_str_len;
345 uint8_t pending_comp_image_set_ver_str_type;
346 uint8_t pending_comp_image_set_ver_str_len;
347} __attribute__((packed));
348
gokulsankere1fb7a82021-04-05 16:09:29 +0530349/** @struct pldm_component_parameter_entry
350 *
351 * Structure representing component parameter table entry.
352 */
353struct pldm_component_parameter_entry {
354 uint16_t comp_classification;
355 uint16_t comp_identifier;
356 uint8_t comp_classification_index;
357 uint32_t active_comp_comparison_stamp;
358 uint8_t active_comp_ver_str_type;
359 uint8_t active_comp_ver_str_len;
360 uint8_t active_comp_release_date[8];
361 uint32_t pending_comp_comparison_stamp;
362 uint8_t pending_comp_ver_str_type;
363 uint8_t pending_comp_ver_str_len;
364 uint8_t pending_comp_release_date[8];
365 bitfield16_t comp_activation_methods;
366 bitfield32_t capabilities_during_update;
367} __attribute__((packed));
368
gokulsankerd434edc2021-04-05 16:36:04 +0530369/** @struct pldm_request_update_req
370 *
371 * Structure representing fixed part of Request Update request
372 */
373struct pldm_request_update_req {
374 uint32_t max_transfer_size;
375 uint16_t num_of_comp;
376 uint8_t max_outstanding_transfer_req;
377 uint16_t pkg_data_len;
378 uint8_t comp_image_set_ver_str_type;
379 uint8_t comp_image_set_ver_str_len;
380} __attribute__((packed));
381
gokulsanker611238c2021-04-05 16:50:44 +0530382/** @struct pldm_request_update_resp
383 *
384 * Structure representing Request Update response
385 */
386struct pldm_request_update_resp {
387 uint8_t completion_code;
388 uint16_t fd_meta_data_len;
389 uint8_t fd_will_send_pkg_data;
390} __attribute__((packed));
391
gokulsanker1b909d82021-04-05 17:26:02 +0530392/** @struct pldm_pass_component_table_req
393 *
394 * Structure representing PassComponentTable request
395 */
396struct pldm_pass_component_table_req {
397 uint8_t transfer_flag;
398 uint16_t comp_classification;
399 uint16_t comp_identifier;
400 uint8_t comp_classification_index;
401 uint32_t comp_comparison_stamp;
402 uint8_t comp_ver_str_type;
403 uint8_t comp_ver_str_len;
404} __attribute__((packed));
405
gokulsanker566784b2021-04-05 17:47:04 +0530406/** @struct pldm_pass_component_table_resp
407 *
408 * Structure representing PassComponentTable response
409 */
410struct pldm_pass_component_table_resp {
411 uint8_t completion_code;
412 uint8_t comp_resp;
413 uint8_t comp_resp_code;
414} __attribute__((packed));
415
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530416/** @struct pldm_update_component_req
417 *
418 * Structure representing UpdateComponent request
419 */
420struct pldm_update_component_req {
421 uint16_t comp_classification;
422 uint16_t comp_identifier;
423 uint8_t comp_classification_index;
424 uint32_t comp_comparison_stamp;
425 uint32_t comp_image_size;
426 bitfield32_t update_option_flags;
427 uint8_t comp_ver_str_type;
428 uint8_t comp_ver_str_len;
429} __attribute__((packed));
430
gokulsanker4b533f22021-04-22 12:53:00 +0530431/** @struct pldm_update_component_resp
432 *
433 * Structure representing UpdateComponent response
434 */
435struct pldm_update_component_resp {
436 uint8_t completion_code;
437 uint8_t comp_compatability_resp;
438 uint8_t comp_compatability_resp_code;
439 bitfield32_t update_option_flags_enabled;
440 uint16_t time_before_req_fw_data;
441} __attribute__((packed));
442
gokulsankera4e6b292021-06-02 16:35:39 +0530443/** @struct pldm_request_firmware_data_req
444 *
445 * Structure representing RequestFirmwareData request.
446 */
447struct pldm_request_firmware_data_req {
448 uint32_t offset;
449 uint32_t length;
450} __attribute__((packed));
451
gokulsanker4687f242021-06-27 11:50:26 +0530452/** @struct pldm_apply_complete_req
453 *
454 * Structure representing ApplyComplete request.
455 */
456struct pldm_apply_complete_req {
457 uint8_t apply_result;
458 bitfield16_t comp_activation_methods_modification;
459} __attribute__((packed));
460
gokulsanker773cd1f2021-04-27 17:59:15 +0530461/** @struct pldm_activate_firmware_req
462 *
463 * Structure representing ActivateFirmware request
464 */
465struct pldm_activate_firmware_req {
466 bool8_t self_contained_activation_req;
467} __attribute__((packed));
468
gokulsanker630f76a2021-04-27 18:41:28 +0530469/** @struct activate_firmware_resp
470 *
471 * Structure representing Activate Firmware response
472 */
473struct pldm_activate_firmware_resp {
474 uint8_t completion_code;
475 uint16_t estimated_time_activation;
476} __attribute__((packed));
477
Tom Joseph568e4702021-06-07 22:15:49 -0700478/** @brief Decode the PLDM package header information
479 *
480 * @param[in] data - pointer to package header information
481 * @param[in] length - available length in the firmware update package
482 * @param[out] package_header_info - pointer to fixed part of PLDM package
483 * header information
484 * @param[out] package_version_str - pointer to package version string
485 *
486 * @return pldm_completion_codes
487 */
488int decode_pldm_package_header_info(
489 const uint8_t *data, size_t length,
490 struct pldm_package_header_information *package_header_info,
491 struct variable_field *package_version_str);
492
Tom Joseph64af3452021-06-08 04:05:28 -0700493/** @brief Decode individual firmware device ID record
494 *
495 * @param[in] data - pointer to firmware device ID record
496 * @param[in] length - available length in the firmware update package
497 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
498 * parsed from the package header info
499 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
500 * id record
501 * @param[out] applicable_components - pointer to ApplicableComponents
502 * @param[out] comp_image_set_version_str - pointer to
503 * ComponentImageSetVersionString
504 * @param[out] record_descriptors - pointer to RecordDescriptors
505 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
506 *
507 * @return pldm_completion_codes
508 */
509int decode_firmware_device_id_record(
510 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
511 struct pldm_firmware_device_id_record *fw_device_id_record,
512 struct variable_field *applicable_components,
513 struct variable_field *comp_image_set_version_str,
514 struct variable_field *record_descriptors,
515 struct variable_field *fw_device_pkg_data);
516
Tom Joseph763b51e2021-06-05 04:50:47 -0700517/** @brief Decode the record descriptor entries in the firmware update package
518 * and the Descriptors in the QueryDeviceIDentifiers command
519 *
520 * @param[in] data - pointer to descriptor entry
521 * @param[in] length - remaining length of the descriptor data
522 * @param[out] descriptor_type - pointer to descriptor type
523 * @param[out] descriptor_data - pointer to descriptor data
524 *
525 * @return pldm_completion_codes
526 */
527int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
528 uint16_t *descriptor_type,
529 struct variable_field *descriptor_data);
530
531/** @brief Decode the vendor defined descriptor value
532 *
533 * @param[in] data - pointer to vendor defined descriptor value
534 * @param[in] length - length of the vendor defined descriptor value
535 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
536 * title string type
537 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
538 * title string
539 * @param[out] descriptor_data - pointer to vendor defined descriptor data
540 *
541 * @return pldm_completion_codes
542 */
543int decode_vendor_defined_descriptor_value(
544 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
545 struct variable_field *descriptor_title_str,
546 struct variable_field *descriptor_data);
547
Tom Joseph58cc1722021-06-09 07:15:49 -0700548/** @brief Decode individual component image information
549 *
550 * @param[in] data - pointer to component image information
551 * @param[in] length - available length in the firmware update package
552 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
553 * information
554 * @param[out] comp_version_str - pointer to component version string
555 *
556 * @return pldm_completion_codes
557 */
558int decode_pldm_comp_image_info(
559 const uint8_t *data, size_t length,
560 struct pldm_component_image_information *pldm_comp_image_info,
561 struct variable_field *comp_version_str);
562
gokulsanker138ceba2021-04-05 13:25:25 +0530563/** @brief Create a PLDM request message for QueryDeviceIdentifiers
564 *
565 * @param[in] instance_id - Message's instance id
566 * @param[in] payload_length - Length of the request message payload
567 * @param[in,out] msg - Message will be written to this
568 *
569 * @return pldm_completion_codes
570 *
571 * @note Caller is responsible for memory alloc and dealloc of param
572 * 'msg.payload'
573 */
574int encode_query_device_identifiers_req(uint8_t instance_id,
575 size_t payload_length,
576 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530577
578/** @brief Decode QueryDeviceIdentifiers response message
579 *
580 * @param[in] msg - Response message
581 * @param[in] payload_length - Length of response message payload
582 * @param[out] completion_code - Pointer to response msg's PLDM completion code
583 * @param[out] device_identifiers_len - Pointer to device identifiers length
584 * @param[out] descriptor_count - Pointer to descriptor count
585 * @param[out] descriptor_data - Pointer to descriptor data
586 *
587 * @return pldm_completion_codes
588 */
589int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
590 size_t payload_length,
591 uint8_t *completion_code,
592 uint32_t *device_identifiers_len,
593 uint8_t *descriptor_count,
594 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530595
596/** @brief Create a PLDM request message for GetFirmwareParameters
597 *
598 * @param[in] instance_id - Message's instance id
599 * @param[in] payload_length - Length of the request message payload
600 * @param[in,out] msg - Message will be written to this
601 *
602 * @return pldm_completion_codes
603 *
604 * @note Caller is responsible for memory alloc and dealloc of param
605 * 'msg.payload'
606 */
607int encode_get_firmware_parameters_req(uint8_t instance_id,
608 size_t payload_length,
609 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530610
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700611/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530612 *
613 * @param[in] msg - Response message
614 * @param[in] payload_length - Length of response message payload
615 * @param[out] resp_data - Pointer to get firmware parameters response
616 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700617 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530618 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700619 * image set version string
620 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530621 *
622 * @return pldm_completion_codes
623 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700624int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530625 const struct pldm_msg *msg, size_t payload_length,
626 struct pldm_get_firmware_parameters_resp *resp_data,
627 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700628 struct variable_field *pending_comp_image_set_ver_str,
629 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530630
gokulsankere1fb7a82021-04-05 16:09:29 +0530631/** @brief Decode component entries in the component parameter table which is
632 * part of the response of GetFirmwareParameters command
633 *
634 * @param[in] data - Component entry
635 * @param[in] length - Length of component entry
636 * @param[out] component_data - Pointer to component parameter table
637 * @param[out] active_comp_ver_str - Pointer to active component version string
638 * @param[out] pending_comp_ver_str - Pointer to pending component version
639 * string
640 *
641 * @return pldm_completion_codes
642 */
643int decode_get_firmware_parameters_resp_comp_entry(
644 const uint8_t *data, size_t length,
645 struct pldm_component_parameter_entry *component_data,
646 struct variable_field *active_comp_ver_str,
647 struct variable_field *pending_comp_ver_str);
648
gokulsankerd434edc2021-04-05 16:36:04 +0530649/** @brief Create PLDM request message for RequestUpdate
650 *
651 * @param[in] instance_id - Message's instance id
652 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
653 * to be requested via RequestFirmwareData
654 * command
655 * @param[in] num_of_comp - Total number of components that will be passed to
656 * the FD during the update
657 * @param[in] max_outstanding_transfer_req - Total number of outstanding
658 * RequestFirmwareData
659 * commands that can be sent by the FD
660 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
661 * present in firmware package header
662 * @param[in] comp_image_set_ver_str_type - StringType of
663 * ComponentImageSetVersionString
664 * @param[in] comp_image_set_ver_str_len - The length of the
665 * ComponentImageSetVersionString
666 * @param[in] comp_img_set_ver_str - Component Image Set version information
667 * @param[in,out] msg - Message will be written to this
668 * @param[in] payload_length - Length of request message payload
669 *
670 * @return pldm_completion_codes
671 *
672 * @note Caller is responsible for memory alloc and dealloc of param
673 * 'msg.payload'
674 */
675int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
676 uint16_t num_of_comp,
677 uint8_t max_outstanding_transfer_req,
678 uint16_t pkg_data_len,
679 uint8_t comp_image_set_ver_str_type,
680 uint8_t comp_image_set_ver_str_len,
681 const struct variable_field *comp_img_set_ver_str,
682 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530683
684/** @brief Decode a RequestUpdate response message
685 *
686 * @param[in] msg - Response message
687 * @param[in] payload_length - Length of response message payload
688 * @param[out] completion_code - Pointer to hold the completion code
689 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
690 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
691 * will send GetPackageData command
692 * @return pldm_completion_codes
693 */
694int decode_request_update_resp(const struct pldm_msg *msg,
695 size_t payload_length, uint8_t *completion_code,
696 uint16_t *fd_meta_data_len,
697 uint8_t *fd_will_send_pkg_data);
698
gokulsanker1b909d82021-04-05 17:26:02 +0530699/** @brief Create PLDM request message for PassComponentTable
700 *
701 * @param[in] instance_id - Message's instance id
702 * @param[in] transfer_flag - TransferFlag
703 * @param[in] comp_classification - ComponentClassification
704 * @param[in] comp_identifier - ComponentIdentifier
705 * @param[in] comp_classification_index - ComponentClassificationIndex
706 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
707 * @param[in] comp_ver_str_type - ComponentVersionStringType
708 * @param[in] comp_ver_str_len - ComponentVersionStringLength
709 * @param[in] comp_ver_str - ComponentVersionString
710 * @param[in,out] msg - Message will be written to this
711 * @param[in] payload_length - Length of request message payload
712 * information
713 *
714 * @return pldm_completion_codes
715 *
716 * @note Caller is responsible for memory alloc and dealloc of param
717 * 'msg.payload'
718 */
719int encode_pass_component_table_req(
720 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
721 uint16_t comp_identifier, uint8_t comp_classification_index,
722 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
723 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
724 struct pldm_msg *msg, size_t payload_length);
725
gokulsanker566784b2021-04-05 17:47:04 +0530726/** @brief Decode PassComponentTable response message
727 *
728 * @param[in] msg - Response message
729 * @param[in] payload_length - Length of response message payload
730 * @param[out] completion_code - Pointer to hold completion code
731 * @param[out] comp_resp - Pointer to hold component response
732 * @param[out] comp_resp_code - Pointer to hold component response code
733 *
734 * @return pldm_completion_codes
735 */
736int decode_pass_component_table_resp(const struct pldm_msg *msg,
737 size_t payload_length,
738 uint8_t *completion_code,
739 uint8_t *comp_resp,
740 uint8_t *comp_resp_code);
741
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530742/** @brief Create PLDM request message for UpdateComponent
743 *
744 * @param[in] instance_id - Message's instance id
745 * @param[in] comp_classification - ComponentClassification
746 * @param[in] comp_identifier - ComponentIdentifier
747 * @param[in] comp_classification_index - ComponentClassificationIndex
748 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
749 * @param[in] comp_image_size - ComponentImageSize
750 * @param[in] update_option_flags - UpdateOptionFlags
751 * @param[in] comp_ver_str_type - ComponentVersionStringType
752 * @param[in] comp_ver_str_len - ComponentVersionStringLength
753 * @param[in] comp_ver_str - ComponentVersionString
754 * @param[in,out] msg - Message will be written to this
755 * @param[in] payload_length - Length of request message payload
756 * information
757 *
758 * @return pldm_completion_codes
759 *
760 * @note Caller is responsible for memory alloc and dealloc of param
761 * 'msg.payload'
762 */
763int encode_update_component_req(
764 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
765 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
766 uint32_t comp_image_size, bitfield32_t update_option_flags,
767 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
768 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
769 size_t payload_length);
770
gokulsanker4b533f22021-04-22 12:53:00 +0530771/** @brief Decode UpdateComponent response message
772 *
773 * @param[in] msg - Response message
774 * @param[in] payload_length - Length of response message payload
775 * @param[out] completion_code - Pointer to hold completion code
776 * @param[out] comp_compatability_resp - Pointer to hold component
777 * compatibility response
778 * @param[out] comp_compatability_resp_code - Pointer to hold component
779 * compatibility response code
780 * @param[out] update_option_flags_enabled - Pointer to hold
781 * UpdateOptionsFlagEnabled
782 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
783 * before sending RequestFirmwareData
784 *
785 * @return pldm_completion_codes
786 */
787int decode_update_component_resp(const struct pldm_msg *msg,
788 size_t payload_length,
789 uint8_t *completion_code,
790 uint8_t *comp_compatability_resp,
791 uint8_t *comp_compatability_resp_code,
792 bitfield32_t *update_option_flags_enabled,
793 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530794
795/** @brief Decode RequestFirmwareData request message
796 *
797 * @param[in] msg - Request message
798 * @param[in] payload_length - Length of request message payload
799 * @param[out] offset - Pointer to hold offset
800 * @param[out] length - Pointer to hold the size of the component image
801 * segment requested by the FD/FDP
802 *
803 * @return pldm_completion_codes
804 */
805int decode_request_firmware_data_req(const struct pldm_msg *msg,
806 size_t payload_length, uint32_t *offset,
807 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530808
809/** @brief Create PLDM response message for RequestFirmwareData
810 *
811 * The ComponentImagePortion is not encoded in the PLDM response message
812 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
813 * ComponentImagePortion in the PLDM response message is handled by the user
814 * of this API. The payload_length validation considers only the
815 * CompletionCode.
816 *
817 * @param[in] instance_id - Message's instance id
818 * @param[in] completion_code - CompletionCode
819 * @param[in,out] msg - Message will be written to this
820 * @param[in] payload_length - Length of response message payload
821 *
822 * @return pldm_completion_codes
823 *
824 * @note Caller is responsible for memory alloc and dealloc of param
825 * 'msg.payload'
826 */
827int encode_request_firmware_data_resp(uint8_t instance_id,
828 uint8_t completion_code,
829 struct pldm_msg *msg,
830 size_t payload_length);
831
gokulsankere3807022021-06-26 19:12:01 +0530832/** @brief Decode TransferComplete request message
833 *
834 * @param[in] msg - Request message
835 * @param[in] payload_length - Length of request message payload
836 * @param[out] transfer_result - Pointer to hold TransferResult
837 *
838 * @return pldm_completion_codes
839 */
840int decode_transfer_complete_req(const struct pldm_msg *msg,
841 size_t payload_length,
842 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530843
844/** @brief Create PLDM response message for TransferComplete
845 *
846 * @param[in] instance_id - Message's instance id
847 * @param[in] completion_code - CompletionCode
848 * @param[in,out] msg - Message will be written to this
849 * @param[in] payload_length - Length of response message payload
850 *
851 * @return pldm_completion_codes
852 *
853 * @note Caller is responsible for memory alloc and dealloc of param
854 * 'msg.payload'
855 */
856int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
857 struct pldm_msg *msg, size_t payload_length);
gokulsankerb79b91a2021-06-27 11:26:36 +0530858
859/** @brief Decode VerifyComplete request message
860 *
861 * @param[in] msg - Request message
862 * @param[in] payload_length - Length of request message payload
863 * @param[in] verify_result - Pointer to hold VerifyResult
864 *
865 * @return pldm_completion_codes
866 */
867int decode_verify_complete_req(const struct pldm_msg *msg,
868 size_t payload_length, uint8_t *verify_result);
869
gokulsanker9a693582021-06-27 11:35:09 +0530870/** @brief Create PLDM response message for VerifyComplete
871 *
872 * @param[in] instance_id - Message's instance id
873 * @param[in] completion_code - CompletionCode
874 * @param[in,out] msg - Message will be written to this
875 * @param[in] payload_length - Length of response message payload
876 *
877 * @return pldm_completion_codes
878 *
879 * @note Caller is responsible for memory alloc and dealloc of param
880 * 'msg.payload'
881 */
882int encode_verify_complete_resp(uint8_t instance_id, uint8_t completion_code,
883 struct pldm_msg *msg, size_t payload_length);
884
gokulsanker4687f242021-06-27 11:50:26 +0530885/** @brief Decode ApplyComplete request message
886 *
887 * @param[in] msg - Request message
888 * @param[in] payload_length - Length of request message payload
889 * @param[in] apply_result - Pointer to hold ApplyResult
890 * @param[in] comp_activation_methods_modification - Pointer to hold the
891 * ComponentActivationMethodsModification
892 *
893 * @return pldm_completion_codes
894 */
895int decode_apply_complete_req(
896 const struct pldm_msg *msg, size_t payload_length, uint8_t *apply_result,
897 bitfield16_t *comp_activation_methods_modification);
898
gokulsankerd6f79b82021-06-27 12:00:25 +0530899/** @brief Create PLDM response message for ApplyComplete
900 *
901 * @param[in] instance_id - Message's instance id
902 * @param[in] completion_code - CompletionCode
903 * @param[in,out] msg - Message will be written to this
904 * @param[in] payload_length - Length of response message payload
905 *
906 * @return pldm_completion_codes
907 *
908 * @note Caller is responsible for memory alloc and dealloc of param
909 * 'msg.payload'
910 */
911int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code,
912 struct pldm_msg *msg, size_t payload_length);
913
gokulsanker773cd1f2021-04-27 17:59:15 +0530914/** @brief Create PLDM request message for ActivateFirmware
915 *
916 * @param[in] instance_id - Message's instance id
917 * @param[in] self_contained_activation_req SelfContainedActivationRequest
918 * @param[in,out] msg - Message will be written to this
919 * @param[in] payload_length - Length of request message payload
920 *
921 * @return pldm_completion_codes
922 *
923 * @note Caller is responsible for memory alloc and dealloc of param
924 * 'msg.payload'
925 */
926int encode_activate_firmware_req(uint8_t instance_id,
927 bool8_t self_contained_activation_req,
928 struct pldm_msg *msg, size_t payload_length);
929
gokulsanker630f76a2021-04-27 18:41:28 +0530930/** @brief Decode ActivateFirmware response message
931 *
932 * @param[in] msg - Response message
933 * @param[in] payload_length - Length of response message payload
934 * @param[out] completion_code - Pointer to hold CompletionCode
935 * @param[out] estimated_time_activation - Pointer to hold
936 * EstimatedTimeForSelfContainedActivation
937 *
938 * @return pldm_completion_codes
939 */
940int decode_activate_firmware_resp(const struct pldm_msg *msg,
941 size_t payload_length,
942 uint8_t *completion_code,
943 uint16_t *estimated_time_activation);
944
gokulsanker42254422021-04-22 19:43:23 +0530945/** @brief Create PLDM request message for GetStatus
946 *
947 * @param[in] instance_id - Message's instance id
948 * @param[in,out] msg - Message will be written to this
949 * @param[in] payload_length - Length of request message payload
950 *
951 * @return pldm_completion_codes
952 *
953 * @note Caller is responsible for memory alloc and dealloc of param
954 * 'msg.payload'
955 */
956int encode_get_status_req(uint8_t instance_id, struct pldm_msg *msg,
957 size_t payload_length);
958
gokulsanker138ceba2021-04-05 13:25:25 +0530959#ifdef __cplusplus
960}
961#endif
962
963#endif // End of FW_UPDATE_H