blob: faca59459cfefc1cc85a497b6f5b202044941620 [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
Tom Joseph568e4702021-06-07 22:15:49 -0700211/** @struct pldm_package_header_information
212 *
213 * Structure representing fixed part of package header information
214 */
215struct pldm_package_header_information {
216 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
217 uint8_t package_header_format_version;
218 uint16_t package_header_size;
219 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
220 uint16_t component_bitmap_bit_length;
221 uint8_t package_version_string_type;
222 uint8_t package_version_string_length;
223} __attribute__((packed));
224
Tom Joseph64af3452021-06-08 04:05:28 -0700225/** @struct pldm_firmware_device_id_record
226 *
227 * Structure representing firmware device ID record
228 */
229struct pldm_firmware_device_id_record {
230 uint16_t record_length;
231 uint8_t descriptor_count;
232 bitfield32_t device_update_option_flags;
233 uint8_t comp_image_set_version_string_type;
234 uint8_t comp_image_set_version_string_length;
235 uint16_t fw_device_pkg_data_length;
236} __attribute__((packed));
237
Tom Joseph763b51e2021-06-05 04:50:47 -0700238/** @struct pldm_descriptor_tlv
239 *
240 * Structure representing descriptor type, length and value
241 */
242struct pldm_descriptor_tlv {
243 uint16_t descriptor_type;
244 uint16_t descriptor_length;
245 uint8_t descriptor_data[1];
246} __attribute__((packed));
247
248/** @struct pldm_vendor_defined_descriptor_title_data
249 *
250 * Structure representing vendor defined descriptor title sections
251 */
252struct pldm_vendor_defined_descriptor_title_data {
253 uint8_t vendor_defined_descriptor_title_str_type;
254 uint8_t vendor_defined_descriptor_title_str_len;
255 uint8_t vendor_defined_descriptor_title_str[1];
256} __attribute__((packed));
257
Tom Joseph58cc1722021-06-09 07:15:49 -0700258/** @struct pldm_component_image_information
259 *
260 * Structure representing fixed part of individual component information in
261 * PLDM firmware update package
262 */
263struct pldm_component_image_information {
264 uint16_t comp_classification;
265 uint16_t comp_identifier;
266 uint32_t comp_comparison_stamp;
267 bitfield16_t comp_options;
268 bitfield16_t requested_comp_activation_method;
269 uint32_t comp_location_offset;
270 uint32_t comp_size;
271 uint8_t comp_version_string_type;
272 uint8_t comp_version_string_length;
273} __attribute__((packed));
274
gokulsankereca3e192021-04-05 14:57:41 +0530275/** @struct pldm_query_device_identifiers_resp
276 *
277 * Structure representing query device identifiers response.
278 */
279struct pldm_query_device_identifiers_resp {
280 uint8_t completion_code;
281 uint32_t device_identifiers_len;
282 uint8_t descriptor_count;
283} __attribute__((packed));
284
gokulsanker22fbb342021-04-05 15:55:06 +0530285/** @struct pldm_get_firmware_parameters_resp
286 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700287 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530288 */
289struct pldm_get_firmware_parameters_resp {
290 uint8_t completion_code;
291 bitfield32_t capabilities_during_update;
292 uint16_t comp_count;
293 uint8_t active_comp_image_set_ver_str_type;
294 uint8_t active_comp_image_set_ver_str_len;
295 uint8_t pending_comp_image_set_ver_str_type;
296 uint8_t pending_comp_image_set_ver_str_len;
297} __attribute__((packed));
298
gokulsankere1fb7a82021-04-05 16:09:29 +0530299/** @struct pldm_component_parameter_entry
300 *
301 * Structure representing component parameter table entry.
302 */
303struct pldm_component_parameter_entry {
304 uint16_t comp_classification;
305 uint16_t comp_identifier;
306 uint8_t comp_classification_index;
307 uint32_t active_comp_comparison_stamp;
308 uint8_t active_comp_ver_str_type;
309 uint8_t active_comp_ver_str_len;
310 uint8_t active_comp_release_date[8];
311 uint32_t pending_comp_comparison_stamp;
312 uint8_t pending_comp_ver_str_type;
313 uint8_t pending_comp_ver_str_len;
314 uint8_t pending_comp_release_date[8];
315 bitfield16_t comp_activation_methods;
316 bitfield32_t capabilities_during_update;
317} __attribute__((packed));
318
gokulsankerd434edc2021-04-05 16:36:04 +0530319/** @struct pldm_request_update_req
320 *
321 * Structure representing fixed part of Request Update request
322 */
323struct pldm_request_update_req {
324 uint32_t max_transfer_size;
325 uint16_t num_of_comp;
326 uint8_t max_outstanding_transfer_req;
327 uint16_t pkg_data_len;
328 uint8_t comp_image_set_ver_str_type;
329 uint8_t comp_image_set_ver_str_len;
330} __attribute__((packed));
331
gokulsanker611238c2021-04-05 16:50:44 +0530332/** @struct pldm_request_update_resp
333 *
334 * Structure representing Request Update response
335 */
336struct pldm_request_update_resp {
337 uint8_t completion_code;
338 uint16_t fd_meta_data_len;
339 uint8_t fd_will_send_pkg_data;
340} __attribute__((packed));
341
gokulsanker1b909d82021-04-05 17:26:02 +0530342/** @struct pldm_pass_component_table_req
343 *
344 * Structure representing PassComponentTable request
345 */
346struct pldm_pass_component_table_req {
347 uint8_t transfer_flag;
348 uint16_t comp_classification;
349 uint16_t comp_identifier;
350 uint8_t comp_classification_index;
351 uint32_t comp_comparison_stamp;
352 uint8_t comp_ver_str_type;
353 uint8_t comp_ver_str_len;
354} __attribute__((packed));
355
gokulsanker566784b2021-04-05 17:47:04 +0530356/** @struct pldm_pass_component_table_resp
357 *
358 * Structure representing PassComponentTable response
359 */
360struct pldm_pass_component_table_resp {
361 uint8_t completion_code;
362 uint8_t comp_resp;
363 uint8_t comp_resp_code;
364} __attribute__((packed));
365
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530366/** @struct pldm_update_component_req
367 *
368 * Structure representing UpdateComponent request
369 */
370struct pldm_update_component_req {
371 uint16_t comp_classification;
372 uint16_t comp_identifier;
373 uint8_t comp_classification_index;
374 uint32_t comp_comparison_stamp;
375 uint32_t comp_image_size;
376 bitfield32_t update_option_flags;
377 uint8_t comp_ver_str_type;
378 uint8_t comp_ver_str_len;
379} __attribute__((packed));
380
gokulsanker4b533f22021-04-22 12:53:00 +0530381/** @struct pldm_update_component_resp
382 *
383 * Structure representing UpdateComponent response
384 */
385struct pldm_update_component_resp {
386 uint8_t completion_code;
387 uint8_t comp_compatability_resp;
388 uint8_t comp_compatability_resp_code;
389 bitfield32_t update_option_flags_enabled;
390 uint16_t time_before_req_fw_data;
391} __attribute__((packed));
392
gokulsankera4e6b292021-06-02 16:35:39 +0530393/** @struct pldm_request_firmware_data_req
394 *
395 * Structure representing RequestFirmwareData request.
396 */
397struct pldm_request_firmware_data_req {
398 uint32_t offset;
399 uint32_t length;
400} __attribute__((packed));
401
Tom Joseph568e4702021-06-07 22:15:49 -0700402/** @brief Decode the PLDM package header information
403 *
404 * @param[in] data - pointer to package header information
405 * @param[in] length - available length in the firmware update package
406 * @param[out] package_header_info - pointer to fixed part of PLDM package
407 * header information
408 * @param[out] package_version_str - pointer to package version string
409 *
410 * @return pldm_completion_codes
411 */
412int decode_pldm_package_header_info(
413 const uint8_t *data, size_t length,
414 struct pldm_package_header_information *package_header_info,
415 struct variable_field *package_version_str);
416
Tom Joseph64af3452021-06-08 04:05:28 -0700417/** @brief Decode individual firmware device ID record
418 *
419 * @param[in] data - pointer to firmware device ID record
420 * @param[in] length - available length in the firmware update package
421 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
422 * parsed from the package header info
423 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
424 * id record
425 * @param[out] applicable_components - pointer to ApplicableComponents
426 * @param[out] comp_image_set_version_str - pointer to
427 * ComponentImageSetVersionString
428 * @param[out] record_descriptors - pointer to RecordDescriptors
429 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
430 *
431 * @return pldm_completion_codes
432 */
433int decode_firmware_device_id_record(
434 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
435 struct pldm_firmware_device_id_record *fw_device_id_record,
436 struct variable_field *applicable_components,
437 struct variable_field *comp_image_set_version_str,
438 struct variable_field *record_descriptors,
439 struct variable_field *fw_device_pkg_data);
440
Tom Joseph763b51e2021-06-05 04:50:47 -0700441/** @brief Decode the record descriptor entries in the firmware update package
442 * and the Descriptors in the QueryDeviceIDentifiers command
443 *
444 * @param[in] data - pointer to descriptor entry
445 * @param[in] length - remaining length of the descriptor data
446 * @param[out] descriptor_type - pointer to descriptor type
447 * @param[out] descriptor_data - pointer to descriptor data
448 *
449 * @return pldm_completion_codes
450 */
451int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
452 uint16_t *descriptor_type,
453 struct variable_field *descriptor_data);
454
455/** @brief Decode the vendor defined descriptor value
456 *
457 * @param[in] data - pointer to vendor defined descriptor value
458 * @param[in] length - length of the vendor defined descriptor value
459 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
460 * title string type
461 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
462 * title string
463 * @param[out] descriptor_data - pointer to vendor defined descriptor data
464 *
465 * @return pldm_completion_codes
466 */
467int decode_vendor_defined_descriptor_value(
468 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
469 struct variable_field *descriptor_title_str,
470 struct variable_field *descriptor_data);
471
Tom Joseph58cc1722021-06-09 07:15:49 -0700472/** @brief Decode individual component image information
473 *
474 * @param[in] data - pointer to component image information
475 * @param[in] length - available length in the firmware update package
476 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
477 * information
478 * @param[out] comp_version_str - pointer to component version string
479 *
480 * @return pldm_completion_codes
481 */
482int decode_pldm_comp_image_info(
483 const uint8_t *data, size_t length,
484 struct pldm_component_image_information *pldm_comp_image_info,
485 struct variable_field *comp_version_str);
486
gokulsanker138ceba2021-04-05 13:25:25 +0530487/** @brief Create a PLDM request message for QueryDeviceIdentifiers
488 *
489 * @param[in] instance_id - Message's instance id
490 * @param[in] payload_length - Length of the request message payload
491 * @param[in,out] msg - Message will be written to this
492 *
493 * @return pldm_completion_codes
494 *
495 * @note Caller is responsible for memory alloc and dealloc of param
496 * 'msg.payload'
497 */
498int encode_query_device_identifiers_req(uint8_t instance_id,
499 size_t payload_length,
500 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530501
502/** @brief Decode QueryDeviceIdentifiers response message
503 *
504 * @param[in] msg - Response message
505 * @param[in] payload_length - Length of response message payload
506 * @param[out] completion_code - Pointer to response msg's PLDM completion code
507 * @param[out] device_identifiers_len - Pointer to device identifiers length
508 * @param[out] descriptor_count - Pointer to descriptor count
509 * @param[out] descriptor_data - Pointer to descriptor data
510 *
511 * @return pldm_completion_codes
512 */
513int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
514 size_t payload_length,
515 uint8_t *completion_code,
516 uint32_t *device_identifiers_len,
517 uint8_t *descriptor_count,
518 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530519
520/** @brief Create a PLDM request message for GetFirmwareParameters
521 *
522 * @param[in] instance_id - Message's instance id
523 * @param[in] payload_length - Length of the request message payload
524 * @param[in,out] msg - Message will be written to this
525 *
526 * @return pldm_completion_codes
527 *
528 * @note Caller is responsible for memory alloc and dealloc of param
529 * 'msg.payload'
530 */
531int encode_get_firmware_parameters_req(uint8_t instance_id,
532 size_t payload_length,
533 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530534
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700535/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530536 *
537 * @param[in] msg - Response message
538 * @param[in] payload_length - Length of response message payload
539 * @param[out] resp_data - Pointer to get firmware parameters response
540 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700541 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530542 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700543 * image set version string
544 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530545 *
546 * @return pldm_completion_codes
547 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700548int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530549 const struct pldm_msg *msg, size_t payload_length,
550 struct pldm_get_firmware_parameters_resp *resp_data,
551 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700552 struct variable_field *pending_comp_image_set_ver_str,
553 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530554
gokulsankere1fb7a82021-04-05 16:09:29 +0530555/** @brief Decode component entries in the component parameter table which is
556 * part of the response of GetFirmwareParameters command
557 *
558 * @param[in] data - Component entry
559 * @param[in] length - Length of component entry
560 * @param[out] component_data - Pointer to component parameter table
561 * @param[out] active_comp_ver_str - Pointer to active component version string
562 * @param[out] pending_comp_ver_str - Pointer to pending component version
563 * string
564 *
565 * @return pldm_completion_codes
566 */
567int decode_get_firmware_parameters_resp_comp_entry(
568 const uint8_t *data, size_t length,
569 struct pldm_component_parameter_entry *component_data,
570 struct variable_field *active_comp_ver_str,
571 struct variable_field *pending_comp_ver_str);
572
gokulsankerd434edc2021-04-05 16:36:04 +0530573/** @brief Create PLDM request message for RequestUpdate
574 *
575 * @param[in] instance_id - Message's instance id
576 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
577 * to be requested via RequestFirmwareData
578 * command
579 * @param[in] num_of_comp - Total number of components that will be passed to
580 * the FD during the update
581 * @param[in] max_outstanding_transfer_req - Total number of outstanding
582 * RequestFirmwareData
583 * commands that can be sent by the FD
584 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
585 * present in firmware package header
586 * @param[in] comp_image_set_ver_str_type - StringType of
587 * ComponentImageSetVersionString
588 * @param[in] comp_image_set_ver_str_len - The length of the
589 * ComponentImageSetVersionString
590 * @param[in] comp_img_set_ver_str - Component Image Set version information
591 * @param[in,out] msg - Message will be written to this
592 * @param[in] payload_length - Length of request message payload
593 *
594 * @return pldm_completion_codes
595 *
596 * @note Caller is responsible for memory alloc and dealloc of param
597 * 'msg.payload'
598 */
599int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
600 uint16_t num_of_comp,
601 uint8_t max_outstanding_transfer_req,
602 uint16_t pkg_data_len,
603 uint8_t comp_image_set_ver_str_type,
604 uint8_t comp_image_set_ver_str_len,
605 const struct variable_field *comp_img_set_ver_str,
606 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530607
608/** @brief Decode a RequestUpdate response message
609 *
610 * @param[in] msg - Response message
611 * @param[in] payload_length - Length of response message payload
612 * @param[out] completion_code - Pointer to hold the completion code
613 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
614 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
615 * will send GetPackageData command
616 * @return pldm_completion_codes
617 */
618int decode_request_update_resp(const struct pldm_msg *msg,
619 size_t payload_length, uint8_t *completion_code,
620 uint16_t *fd_meta_data_len,
621 uint8_t *fd_will_send_pkg_data);
622
gokulsanker1b909d82021-04-05 17:26:02 +0530623/** @brief Create PLDM request message for PassComponentTable
624 *
625 * @param[in] instance_id - Message's instance id
626 * @param[in] transfer_flag - TransferFlag
627 * @param[in] comp_classification - ComponentClassification
628 * @param[in] comp_identifier - ComponentIdentifier
629 * @param[in] comp_classification_index - ComponentClassificationIndex
630 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
631 * @param[in] comp_ver_str_type - ComponentVersionStringType
632 * @param[in] comp_ver_str_len - ComponentVersionStringLength
633 * @param[in] comp_ver_str - ComponentVersionString
634 * @param[in,out] msg - Message will be written to this
635 * @param[in] payload_length - Length of request message payload
636 * information
637 *
638 * @return pldm_completion_codes
639 *
640 * @note Caller is responsible for memory alloc and dealloc of param
641 * 'msg.payload'
642 */
643int encode_pass_component_table_req(
644 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
645 uint16_t comp_identifier, uint8_t comp_classification_index,
646 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
647 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
648 struct pldm_msg *msg, size_t payload_length);
649
gokulsanker566784b2021-04-05 17:47:04 +0530650/** @brief Decode PassComponentTable response message
651 *
652 * @param[in] msg - Response message
653 * @param[in] payload_length - Length of response message payload
654 * @param[out] completion_code - Pointer to hold completion code
655 * @param[out] comp_resp - Pointer to hold component response
656 * @param[out] comp_resp_code - Pointer to hold component response code
657 *
658 * @return pldm_completion_codes
659 */
660int decode_pass_component_table_resp(const struct pldm_msg *msg,
661 size_t payload_length,
662 uint8_t *completion_code,
663 uint8_t *comp_resp,
664 uint8_t *comp_resp_code);
665
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530666/** @brief Create PLDM request message for UpdateComponent
667 *
668 * @param[in] instance_id - Message's instance id
669 * @param[in] comp_classification - ComponentClassification
670 * @param[in] comp_identifier - ComponentIdentifier
671 * @param[in] comp_classification_index - ComponentClassificationIndex
672 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
673 * @param[in] comp_image_size - ComponentImageSize
674 * @param[in] update_option_flags - UpdateOptionFlags
675 * @param[in] comp_ver_str_type - ComponentVersionStringType
676 * @param[in] comp_ver_str_len - ComponentVersionStringLength
677 * @param[in] comp_ver_str - ComponentVersionString
678 * @param[in,out] msg - Message will be written to this
679 * @param[in] payload_length - Length of request message payload
680 * information
681 *
682 * @return pldm_completion_codes
683 *
684 * @note Caller is responsible for memory alloc and dealloc of param
685 * 'msg.payload'
686 */
687int encode_update_component_req(
688 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
689 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
690 uint32_t comp_image_size, bitfield32_t update_option_flags,
691 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
692 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
693 size_t payload_length);
694
gokulsanker4b533f22021-04-22 12:53:00 +0530695/** @brief Decode UpdateComponent response message
696 *
697 * @param[in] msg - Response message
698 * @param[in] payload_length - Length of response message payload
699 * @param[out] completion_code - Pointer to hold completion code
700 * @param[out] comp_compatability_resp - Pointer to hold component
701 * compatibility response
702 * @param[out] comp_compatability_resp_code - Pointer to hold component
703 * compatibility response code
704 * @param[out] update_option_flags_enabled - Pointer to hold
705 * UpdateOptionsFlagEnabled
706 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
707 * before sending RequestFirmwareData
708 *
709 * @return pldm_completion_codes
710 */
711int decode_update_component_resp(const struct pldm_msg *msg,
712 size_t payload_length,
713 uint8_t *completion_code,
714 uint8_t *comp_compatability_resp,
715 uint8_t *comp_compatability_resp_code,
716 bitfield32_t *update_option_flags_enabled,
717 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530718
719/** @brief Decode RequestFirmwareData request message
720 *
721 * @param[in] msg - Request message
722 * @param[in] payload_length - Length of request message payload
723 * @param[out] offset - Pointer to hold offset
724 * @param[out] length - Pointer to hold the size of the component image
725 * segment requested by the FD/FDP
726 *
727 * @return pldm_completion_codes
728 */
729int decode_request_firmware_data_req(const struct pldm_msg *msg,
730 size_t payload_length, uint32_t *offset,
731 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530732
733/** @brief Create PLDM response message for RequestFirmwareData
734 *
735 * The ComponentImagePortion is not encoded in the PLDM response message
736 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
737 * ComponentImagePortion in the PLDM response message is handled by the user
738 * of this API. The payload_length validation considers only the
739 * CompletionCode.
740 *
741 * @param[in] instance_id - Message's instance id
742 * @param[in] completion_code - CompletionCode
743 * @param[in,out] msg - Message will be written to this
744 * @param[in] payload_length - Length of response message payload
745 *
746 * @return pldm_completion_codes
747 *
748 * @note Caller is responsible for memory alloc and dealloc of param
749 * 'msg.payload'
750 */
751int encode_request_firmware_data_resp(uint8_t instance_id,
752 uint8_t completion_code,
753 struct pldm_msg *msg,
754 size_t payload_length);
755
gokulsankere3807022021-06-26 19:12:01 +0530756/** @brief Decode TransferComplete request message
757 *
758 * @param[in] msg - Request message
759 * @param[in] payload_length - Length of request message payload
760 * @param[out] transfer_result - Pointer to hold TransferResult
761 *
762 * @return pldm_completion_codes
763 */
764int decode_transfer_complete_req(const struct pldm_msg *msg,
765 size_t payload_length,
766 uint8_t *transfer_result);
gokulsanker50107cf2021-06-27 09:44:12 +0530767
768/** @brief Create PLDM response message for TransferComplete
769 *
770 * @param[in] instance_id - Message's instance id
771 * @param[in] completion_code - CompletionCode
772 * @param[in,out] msg - Message will be written to this
773 * @param[in] payload_length - Length of response message payload
774 *
775 * @return pldm_completion_codes
776 *
777 * @note Caller is responsible for memory alloc and dealloc of param
778 * 'msg.payload'
779 */
780int encode_transfer_complete_resp(uint8_t instance_id, uint8_t completion_code,
781 struct pldm_msg *msg, size_t payload_length);
gokulsanker138ceba2021-04-05 13:25:25 +0530782#ifdef __cplusplus
783}
784#endif
785
786#endif // End of FW_UPDATE_H