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