blob: 7b1c9f1ceaad7c8e06c4a880203f7834bcd10c24 [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,
29 PLDM_REQUEST_FIRMWARE_DATA = 0x15
gokulsanker981fbfb2021-04-05 15:17:25 +053030};
gokulsanker138ceba2021-04-05 13:25:25 +053031
gokulsanker611238c2021-04-05 16:50:44 +053032/** @brief PLDM Firmware update completion codes
33 */
34enum pldm_firmware_update_completion_codes {
35 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
36 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
37 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
38 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
39 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
40 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
41 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
42 PLDM_FWUP_CANCEL_PENDING = 0x87,
43 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
44 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
45 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
46 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
47 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
48 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
49 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
50 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
51 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
52 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
53 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
54 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
55};
56
Tom Joseph763b51e2021-06-05 04:50:47 -070057/** @brief String type values defined in the PLDM firmware update specification
58 */
59enum pldm_firmware_update_string_type {
60 PLDM_STR_TYPE_UNKNOWN = 0,
61 PLDM_STR_TYPE_ASCII = 1,
62 PLDM_STR_TYPE_UTF_8 = 2,
63 PLDM_STR_TYPE_UTF_16 = 3,
64 PLDM_STR_TYPE_UTF_16LE = 4,
65 PLDM_STR_TYPE_UTF_16BE = 5
66};
67
68/** @brief Descriptor types defined in PLDM firmware update specification
69 */
70enum pldm_firmware_update_descriptor_types {
71 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
72 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
73 PLDM_FWUP_UUID = 0x0002,
74 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
75 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
76 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
77 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
78 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
79 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
80 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
81 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
82 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
83 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
84 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
85 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
86 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
87 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
88 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
89};
90
91/** @brief Descriptor types length defined in PLDM firmware update specification
92 */
93enum pldm_firmware_update_descriptor_types_length {
94 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
95 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
96 PLDM_FWUP_UUID_LENGTH = 16,
97 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
98 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
99 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
100 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
101 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
102 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
103 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
104 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
105 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
106 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
107 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
108 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
109 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
110 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
111};
112
gokulsanker1b909d82021-04-05 17:26:02 +0530113/** @brief ComponentClassification values defined in firmware update
114 * specification
115 */
116enum pldm_component_classification_values {
117 PLDM_COMP_UNKNOWN = 0x0000,
118 PLDM_COMP_OTHER = 0x0001,
119 PLDM_COMP_DRIVER = 0x0002,
120 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
121 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
122 PLDM_COMP_INSTRUMENTATION = 0x0005,
123 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
124 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
125 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
126 PLDM_COMP_MIDDLEWARE = 0x0009,
127 PLDM_COMP_FIRMWARE = 0x000A,
128 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
129 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
130 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
131 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
132};
133
gokulsanker566784b2021-04-05 17:47:04 +0530134/** @brief ComponentResponse values in the response of PassComponentTable
135 */
136enum pldm_component_responses {
137 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
138 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
139};
140
141/** @brief ComponentResponseCode values in the response of PassComponentTable
142 */
143enum pldm_component_response_codes {
144 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
145 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
146 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
147 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
148 PLDM_CRC_COMP_CONFLICT = 0x04,
149 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
150 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
151 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
152 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
153 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
154 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
155 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
156 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
157 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
158};
159
gokulsanker4b533f22021-04-22 12:53:00 +0530160/** @brief ComponentCompatibilityResponse values in the response of
161 * UpdateComponent
162 */
163enum pldm_component_compatability_responses {
164 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
165 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
166};
167
168/** @brief ComponentCompatibilityResponse Code values in the response of
169 * UpdateComponent
170 */
171enum pldm_component_compatability_response_codes {
172 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
173 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
174 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
175 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
176 PLDM_CCRC_COMP_CONFLICT = 0x04,
177 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
178 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
179 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
180 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
181 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
182 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
183 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
184 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
185 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
186};
187
gokulsankere3807022021-06-26 19:12:01 +0530188/** @brief Common error codes in TransferComplete, VerifyComplete and
189 * ApplyComplete request
190 */
191enum pldm_firmware_update_common_error_codes {
192 PLDM_FWUP_TIME_OUT = 0x09,
193 PLDM_FWUP_GENERIC_ERROR = 0x0A
194};
195
196/** @brief TransferResult values in the response of TransferComplete
197 */
198enum pldm_firmware_update_transfer_result {
199 PLDM_FWUP_TRANSFER_SUCCESS = 0x00,
200 PLDM_FWUP_TRANSFER_ERROR_IMAGE_CORRUPT = 0x02,
201 PLDM_FWUP_TRANSFER_ERROR_VERSION_MISMATCH = 0x02,
202 PLDM_FWUP_FD_ABORTED_TRANSFER = 0x03,
203 PLDM_FWUP_FD_ABORTED_TRANSFER_LOW_POWER_STATE = 0x0B,
204 PLDM_FWUP_FD_ABORTED_TRANSFER_RESET_NEEDED = 0x0C,
205 PLDM_FWUP_FD_ABORTED_TRANSFER_STORAGE_ISSUE = 0x0D,
206 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MIN = 0x70,
207 PLDM_FWUP_VENDOR_TRANSFER_RESULT_RANGE_MAX = 0x8F
208};
209
Tom Joseph568e4702021-06-07 22:15:49 -0700210/** @struct pldm_package_header_information
211 *
212 * Structure representing fixed part of package header information
213 */
214struct pldm_package_header_information {
215 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
216 uint8_t package_header_format_version;
217 uint16_t package_header_size;
218 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
219 uint16_t component_bitmap_bit_length;
220 uint8_t package_version_string_type;
221 uint8_t package_version_string_length;
222} __attribute__((packed));
223
Tom Joseph64af3452021-06-08 04:05:28 -0700224/** @struct pldm_firmware_device_id_record
225 *
226 * Structure representing firmware device ID record
227 */
228struct pldm_firmware_device_id_record {
229 uint16_t record_length;
230 uint8_t descriptor_count;
231 bitfield32_t device_update_option_flags;
232 uint8_t comp_image_set_version_string_type;
233 uint8_t comp_image_set_version_string_length;
234 uint16_t fw_device_pkg_data_length;
235} __attribute__((packed));
236
Tom Joseph763b51e2021-06-05 04:50:47 -0700237/** @struct pldm_descriptor_tlv
238 *
239 * Structure representing descriptor type, length and value
240 */
241struct pldm_descriptor_tlv {
242 uint16_t descriptor_type;
243 uint16_t descriptor_length;
244 uint8_t descriptor_data[1];
245} __attribute__((packed));
246
247/** @struct pldm_vendor_defined_descriptor_title_data
248 *
249 * Structure representing vendor defined descriptor title sections
250 */
251struct pldm_vendor_defined_descriptor_title_data {
252 uint8_t vendor_defined_descriptor_title_str_type;
253 uint8_t vendor_defined_descriptor_title_str_len;
254 uint8_t vendor_defined_descriptor_title_str[1];
255} __attribute__((packed));
256
Tom Joseph58cc1722021-06-09 07:15:49 -0700257/** @struct pldm_component_image_information
258 *
259 * Structure representing fixed part of individual component information in
260 * PLDM firmware update package
261 */
262struct pldm_component_image_information {
263 uint16_t comp_classification;
264 uint16_t comp_identifier;
265 uint32_t comp_comparison_stamp;
266 bitfield16_t comp_options;
267 bitfield16_t requested_comp_activation_method;
268 uint32_t comp_location_offset;
269 uint32_t comp_size;
270 uint8_t comp_version_string_type;
271 uint8_t comp_version_string_length;
272} __attribute__((packed));
273
gokulsankereca3e192021-04-05 14:57:41 +0530274/** @struct pldm_query_device_identifiers_resp
275 *
276 * Structure representing query device identifiers response.
277 */
278struct pldm_query_device_identifiers_resp {
279 uint8_t completion_code;
280 uint32_t device_identifiers_len;
281 uint8_t descriptor_count;
282} __attribute__((packed));
283
gokulsanker22fbb342021-04-05 15:55:06 +0530284/** @struct pldm_get_firmware_parameters_resp
285 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700286 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530287 */
288struct pldm_get_firmware_parameters_resp {
289 uint8_t completion_code;
290 bitfield32_t capabilities_during_update;
291 uint16_t comp_count;
292 uint8_t active_comp_image_set_ver_str_type;
293 uint8_t active_comp_image_set_ver_str_len;
294 uint8_t pending_comp_image_set_ver_str_type;
295 uint8_t pending_comp_image_set_ver_str_len;
296} __attribute__((packed));
297
gokulsankere1fb7a82021-04-05 16:09:29 +0530298/** @struct pldm_component_parameter_entry
299 *
300 * Structure representing component parameter table entry.
301 */
302struct pldm_component_parameter_entry {
303 uint16_t comp_classification;
304 uint16_t comp_identifier;
305 uint8_t comp_classification_index;
306 uint32_t active_comp_comparison_stamp;
307 uint8_t active_comp_ver_str_type;
308 uint8_t active_comp_ver_str_len;
309 uint8_t active_comp_release_date[8];
310 uint32_t pending_comp_comparison_stamp;
311 uint8_t pending_comp_ver_str_type;
312 uint8_t pending_comp_ver_str_len;
313 uint8_t pending_comp_release_date[8];
314 bitfield16_t comp_activation_methods;
315 bitfield32_t capabilities_during_update;
316} __attribute__((packed));
317
gokulsankerd434edc2021-04-05 16:36:04 +0530318/** @struct pldm_request_update_req
319 *
320 * Structure representing fixed part of Request Update request
321 */
322struct pldm_request_update_req {
323 uint32_t max_transfer_size;
324 uint16_t num_of_comp;
325 uint8_t max_outstanding_transfer_req;
326 uint16_t pkg_data_len;
327 uint8_t comp_image_set_ver_str_type;
328 uint8_t comp_image_set_ver_str_len;
329} __attribute__((packed));
330
gokulsanker611238c2021-04-05 16:50:44 +0530331/** @struct pldm_request_update_resp
332 *
333 * Structure representing Request Update response
334 */
335struct pldm_request_update_resp {
336 uint8_t completion_code;
337 uint16_t fd_meta_data_len;
338 uint8_t fd_will_send_pkg_data;
339} __attribute__((packed));
340
gokulsanker1b909d82021-04-05 17:26:02 +0530341/** @struct pldm_pass_component_table_req
342 *
343 * Structure representing PassComponentTable request
344 */
345struct pldm_pass_component_table_req {
346 uint8_t transfer_flag;
347 uint16_t comp_classification;
348 uint16_t comp_identifier;
349 uint8_t comp_classification_index;
350 uint32_t comp_comparison_stamp;
351 uint8_t comp_ver_str_type;
352 uint8_t comp_ver_str_len;
353} __attribute__((packed));
354
gokulsanker566784b2021-04-05 17:47:04 +0530355/** @struct pldm_pass_component_table_resp
356 *
357 * Structure representing PassComponentTable response
358 */
359struct pldm_pass_component_table_resp {
360 uint8_t completion_code;
361 uint8_t comp_resp;
362 uint8_t comp_resp_code;
363} __attribute__((packed));
364
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530365/** @struct pldm_update_component_req
366 *
367 * Structure representing UpdateComponent request
368 */
369struct pldm_update_component_req {
370 uint16_t comp_classification;
371 uint16_t comp_identifier;
372 uint8_t comp_classification_index;
373 uint32_t comp_comparison_stamp;
374 uint32_t comp_image_size;
375 bitfield32_t update_option_flags;
376 uint8_t comp_ver_str_type;
377 uint8_t comp_ver_str_len;
378} __attribute__((packed));
379
gokulsanker4b533f22021-04-22 12:53:00 +0530380/** @struct pldm_update_component_resp
381 *
382 * Structure representing UpdateComponent response
383 */
384struct pldm_update_component_resp {
385 uint8_t completion_code;
386 uint8_t comp_compatability_resp;
387 uint8_t comp_compatability_resp_code;
388 bitfield32_t update_option_flags_enabled;
389 uint16_t time_before_req_fw_data;
390} __attribute__((packed));
391
gokulsankera4e6b292021-06-02 16:35:39 +0530392/** @struct pldm_request_firmware_data_req
393 *
394 * Structure representing RequestFirmwareData request.
395 */
396struct pldm_request_firmware_data_req {
397 uint32_t offset;
398 uint32_t length;
399} __attribute__((packed));
400
Tom Joseph568e4702021-06-07 22:15:49 -0700401/** @brief Decode the PLDM package header information
402 *
403 * @param[in] data - pointer to package header information
404 * @param[in] length - available length in the firmware update package
405 * @param[out] package_header_info - pointer to fixed part of PLDM package
406 * header information
407 * @param[out] package_version_str - pointer to package version string
408 *
409 * @return pldm_completion_codes
410 */
411int decode_pldm_package_header_info(
412 const uint8_t *data, size_t length,
413 struct pldm_package_header_information *package_header_info,
414 struct variable_field *package_version_str);
415
Tom Joseph64af3452021-06-08 04:05:28 -0700416/** @brief Decode individual firmware device ID record
417 *
418 * @param[in] data - pointer to firmware device ID record
419 * @param[in] length - available length in the firmware update package
420 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
421 * parsed from the package header info
422 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
423 * id record
424 * @param[out] applicable_components - pointer to ApplicableComponents
425 * @param[out] comp_image_set_version_str - pointer to
426 * ComponentImageSetVersionString
427 * @param[out] record_descriptors - pointer to RecordDescriptors
428 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
429 *
430 * @return pldm_completion_codes
431 */
432int decode_firmware_device_id_record(
433 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
434 struct pldm_firmware_device_id_record *fw_device_id_record,
435 struct variable_field *applicable_components,
436 struct variable_field *comp_image_set_version_str,
437 struct variable_field *record_descriptors,
438 struct variable_field *fw_device_pkg_data);
439
Tom Joseph763b51e2021-06-05 04:50:47 -0700440/** @brief Decode the record descriptor entries in the firmware update package
441 * and the Descriptors in the QueryDeviceIDentifiers command
442 *
443 * @param[in] data - pointer to descriptor entry
444 * @param[in] length - remaining length of the descriptor data
445 * @param[out] descriptor_type - pointer to descriptor type
446 * @param[out] descriptor_data - pointer to descriptor data
447 *
448 * @return pldm_completion_codes
449 */
450int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
451 uint16_t *descriptor_type,
452 struct variable_field *descriptor_data);
453
454/** @brief Decode the vendor defined descriptor value
455 *
456 * @param[in] data - pointer to vendor defined descriptor value
457 * @param[in] length - length of the vendor defined descriptor value
458 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
459 * title string type
460 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
461 * title string
462 * @param[out] descriptor_data - pointer to vendor defined descriptor data
463 *
464 * @return pldm_completion_codes
465 */
466int decode_vendor_defined_descriptor_value(
467 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
468 struct variable_field *descriptor_title_str,
469 struct variable_field *descriptor_data);
470
Tom Joseph58cc1722021-06-09 07:15:49 -0700471/** @brief Decode individual component image information
472 *
473 * @param[in] data - pointer to component image information
474 * @param[in] length - available length in the firmware update package
475 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
476 * information
477 * @param[out] comp_version_str - pointer to component version string
478 *
479 * @return pldm_completion_codes
480 */
481int decode_pldm_comp_image_info(
482 const uint8_t *data, size_t length,
483 struct pldm_component_image_information *pldm_comp_image_info,
484 struct variable_field *comp_version_str);
485
gokulsanker138ceba2021-04-05 13:25:25 +0530486/** @brief Create a PLDM request message for QueryDeviceIdentifiers
487 *
488 * @param[in] instance_id - Message's instance id
489 * @param[in] payload_length - Length of the request message payload
490 * @param[in,out] msg - Message will be written to this
491 *
492 * @return pldm_completion_codes
493 *
494 * @note Caller is responsible for memory alloc and dealloc of param
495 * 'msg.payload'
496 */
497int encode_query_device_identifiers_req(uint8_t instance_id,
498 size_t payload_length,
499 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530500
501/** @brief Decode QueryDeviceIdentifiers response message
502 *
503 * @param[in] msg - Response message
504 * @param[in] payload_length - Length of response message payload
505 * @param[out] completion_code - Pointer to response msg's PLDM completion code
506 * @param[out] device_identifiers_len - Pointer to device identifiers length
507 * @param[out] descriptor_count - Pointer to descriptor count
508 * @param[out] descriptor_data - Pointer to descriptor data
509 *
510 * @return pldm_completion_codes
511 */
512int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
513 size_t payload_length,
514 uint8_t *completion_code,
515 uint32_t *device_identifiers_len,
516 uint8_t *descriptor_count,
517 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530518
519/** @brief Create a PLDM request message for GetFirmwareParameters
520 *
521 * @param[in] instance_id - Message's instance id
522 * @param[in] payload_length - Length of the request message payload
523 * @param[in,out] msg - Message will be written to this
524 *
525 * @return pldm_completion_codes
526 *
527 * @note Caller is responsible for memory alloc and dealloc of param
528 * 'msg.payload'
529 */
530int encode_get_firmware_parameters_req(uint8_t instance_id,
531 size_t payload_length,
532 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530533
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700534/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530535 *
536 * @param[in] msg - Response message
537 * @param[in] payload_length - Length of response message payload
538 * @param[out] resp_data - Pointer to get firmware parameters response
539 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700540 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530541 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700542 * image set version string
543 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530544 *
545 * @return pldm_completion_codes
546 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700547int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530548 const struct pldm_msg *msg, size_t payload_length,
549 struct pldm_get_firmware_parameters_resp *resp_data,
550 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700551 struct variable_field *pending_comp_image_set_ver_str,
552 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530553
gokulsankere1fb7a82021-04-05 16:09:29 +0530554/** @brief Decode component entries in the component parameter table which is
555 * part of the response of GetFirmwareParameters command
556 *
557 * @param[in] data - Component entry
558 * @param[in] length - Length of component entry
559 * @param[out] component_data - Pointer to component parameter table
560 * @param[out] active_comp_ver_str - Pointer to active component version string
561 * @param[out] pending_comp_ver_str - Pointer to pending component version
562 * string
563 *
564 * @return pldm_completion_codes
565 */
566int decode_get_firmware_parameters_resp_comp_entry(
567 const uint8_t *data, size_t length,
568 struct pldm_component_parameter_entry *component_data,
569 struct variable_field *active_comp_ver_str,
570 struct variable_field *pending_comp_ver_str);
571
gokulsankerd434edc2021-04-05 16:36:04 +0530572/** @brief Create PLDM request message for RequestUpdate
573 *
574 * @param[in] instance_id - Message's instance id
575 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
576 * to be requested via RequestFirmwareData
577 * command
578 * @param[in] num_of_comp - Total number of components that will be passed to
579 * the FD during the update
580 * @param[in] max_outstanding_transfer_req - Total number of outstanding
581 * RequestFirmwareData
582 * commands that can be sent by the FD
583 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
584 * present in firmware package header
585 * @param[in] comp_image_set_ver_str_type - StringType of
586 * ComponentImageSetVersionString
587 * @param[in] comp_image_set_ver_str_len - The length of the
588 * ComponentImageSetVersionString
589 * @param[in] comp_img_set_ver_str - Component Image Set version information
590 * @param[in,out] msg - Message will be written to this
591 * @param[in] payload_length - Length of request message payload
592 *
593 * @return pldm_completion_codes
594 *
595 * @note Caller is responsible for memory alloc and dealloc of param
596 * 'msg.payload'
597 */
598int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
599 uint16_t num_of_comp,
600 uint8_t max_outstanding_transfer_req,
601 uint16_t pkg_data_len,
602 uint8_t comp_image_set_ver_str_type,
603 uint8_t comp_image_set_ver_str_len,
604 const struct variable_field *comp_img_set_ver_str,
605 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530606
607/** @brief Decode a RequestUpdate response message
608 *
609 * @param[in] msg - Response message
610 * @param[in] payload_length - Length of response message payload
611 * @param[out] completion_code - Pointer to hold the completion code
612 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
613 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
614 * will send GetPackageData command
615 * @return pldm_completion_codes
616 */
617int decode_request_update_resp(const struct pldm_msg *msg,
618 size_t payload_length, uint8_t *completion_code,
619 uint16_t *fd_meta_data_len,
620 uint8_t *fd_will_send_pkg_data);
621
gokulsanker1b909d82021-04-05 17:26:02 +0530622/** @brief Create PLDM request message for PassComponentTable
623 *
624 * @param[in] instance_id - Message's instance id
625 * @param[in] transfer_flag - TransferFlag
626 * @param[in] comp_classification - ComponentClassification
627 * @param[in] comp_identifier - ComponentIdentifier
628 * @param[in] comp_classification_index - ComponentClassificationIndex
629 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
630 * @param[in] comp_ver_str_type - ComponentVersionStringType
631 * @param[in] comp_ver_str_len - ComponentVersionStringLength
632 * @param[in] comp_ver_str - ComponentVersionString
633 * @param[in,out] msg - Message will be written to this
634 * @param[in] payload_length - Length of request message payload
635 * information
636 *
637 * @return pldm_completion_codes
638 *
639 * @note Caller is responsible for memory alloc and dealloc of param
640 * 'msg.payload'
641 */
642int encode_pass_component_table_req(
643 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
644 uint16_t comp_identifier, uint8_t comp_classification_index,
645 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
646 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
647 struct pldm_msg *msg, size_t payload_length);
648
gokulsanker566784b2021-04-05 17:47:04 +0530649/** @brief Decode PassComponentTable response message
650 *
651 * @param[in] msg - Response message
652 * @param[in] payload_length - Length of response message payload
653 * @param[out] completion_code - Pointer to hold completion code
654 * @param[out] comp_resp - Pointer to hold component response
655 * @param[out] comp_resp_code - Pointer to hold component response code
656 *
657 * @return pldm_completion_codes
658 */
659int decode_pass_component_table_resp(const struct pldm_msg *msg,
660 size_t payload_length,
661 uint8_t *completion_code,
662 uint8_t *comp_resp,
663 uint8_t *comp_resp_code);
664
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530665/** @brief Create PLDM request message for UpdateComponent
666 *
667 * @param[in] instance_id - Message's instance id
668 * @param[in] comp_classification - ComponentClassification
669 * @param[in] comp_identifier - ComponentIdentifier
670 * @param[in] comp_classification_index - ComponentClassificationIndex
671 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
672 * @param[in] comp_image_size - ComponentImageSize
673 * @param[in] update_option_flags - UpdateOptionFlags
674 * @param[in] comp_ver_str_type - ComponentVersionStringType
675 * @param[in] comp_ver_str_len - ComponentVersionStringLength
676 * @param[in] comp_ver_str - ComponentVersionString
677 * @param[in,out] msg - Message will be written to this
678 * @param[in] payload_length - Length of request message payload
679 * information
680 *
681 * @return pldm_completion_codes
682 *
683 * @note Caller is responsible for memory alloc and dealloc of param
684 * 'msg.payload'
685 */
686int encode_update_component_req(
687 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
688 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
689 uint32_t comp_image_size, bitfield32_t update_option_flags,
690 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
691 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
692 size_t payload_length);
693
gokulsanker4b533f22021-04-22 12:53:00 +0530694/** @brief Decode UpdateComponent response message
695 *
696 * @param[in] msg - Response message
697 * @param[in] payload_length - Length of response message payload
698 * @param[out] completion_code - Pointer to hold completion code
699 * @param[out] comp_compatability_resp - Pointer to hold component
700 * compatibility response
701 * @param[out] comp_compatability_resp_code - Pointer to hold component
702 * compatibility response code
703 * @param[out] update_option_flags_enabled - Pointer to hold
704 * UpdateOptionsFlagEnabled
705 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
706 * before sending RequestFirmwareData
707 *
708 * @return pldm_completion_codes
709 */
710int decode_update_component_resp(const struct pldm_msg *msg,
711 size_t payload_length,
712 uint8_t *completion_code,
713 uint8_t *comp_compatability_resp,
714 uint8_t *comp_compatability_resp_code,
715 bitfield32_t *update_option_flags_enabled,
716 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530717
718/** @brief Decode RequestFirmwareData request message
719 *
720 * @param[in] msg - Request message
721 * @param[in] payload_length - Length of request message payload
722 * @param[out] offset - Pointer to hold offset
723 * @param[out] length - Pointer to hold the size of the component image
724 * segment requested by the FD/FDP
725 *
726 * @return pldm_completion_codes
727 */
728int decode_request_firmware_data_req(const struct pldm_msg *msg,
729 size_t payload_length, uint32_t *offset,
730 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530731
732/** @brief Create PLDM response message for RequestFirmwareData
733 *
734 * The ComponentImagePortion is not encoded in the PLDM response message
735 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
736 * ComponentImagePortion in the PLDM response message is handled by the user
737 * of this API. The payload_length validation considers only the
738 * CompletionCode.
739 *
740 * @param[in] instance_id - Message's instance id
741 * @param[in] completion_code - CompletionCode
742 * @param[in,out] msg - Message will be written to this
743 * @param[in] payload_length - Length of response message payload
744 *
745 * @return pldm_completion_codes
746 *
747 * @note Caller is responsible for memory alloc and dealloc of param
748 * 'msg.payload'
749 */
750int encode_request_firmware_data_resp(uint8_t instance_id,
751 uint8_t completion_code,
752 struct pldm_msg *msg,
753 size_t payload_length);
754
gokulsankere3807022021-06-26 19:12:01 +0530755/** @brief Decode TransferComplete request message
756 *
757 * @param[in] msg - Request message
758 * @param[in] payload_length - Length of request message payload
759 * @param[out] transfer_result - Pointer to hold TransferResult
760 *
761 * @return pldm_completion_codes
762 */
763int decode_transfer_complete_req(const struct pldm_msg *msg,
764 size_t payload_length,
765 uint8_t *transfer_result);
gokulsanker138ceba2021-04-05 13:25:25 +0530766#ifdef __cplusplus
767}
768#endif
769
770#endif // End of FW_UPDATE_H