blob: e213ea01392a648cde3caf95d153e8c2f4cf31fa [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,
28 PLDM_UPDATE_COMPONENT = 0x14
gokulsanker981fbfb2021-04-05 15:17:25 +053029};
gokulsanker138ceba2021-04-05 13:25:25 +053030
gokulsanker611238c2021-04-05 16:50:44 +053031/** @brief PLDM Firmware update completion codes
32 */
33enum pldm_firmware_update_completion_codes {
34 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
35 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
36 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
37 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
38 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
39 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
40 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
41 PLDM_FWUP_CANCEL_PENDING = 0x87,
42 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
43 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
44 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
45 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
46 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
47 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
48 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
49 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
50 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
51 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
52 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
53 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
54};
55
Tom Joseph763b51e2021-06-05 04:50:47 -070056/** @brief String type values defined in the PLDM firmware update specification
57 */
58enum pldm_firmware_update_string_type {
59 PLDM_STR_TYPE_UNKNOWN = 0,
60 PLDM_STR_TYPE_ASCII = 1,
61 PLDM_STR_TYPE_UTF_8 = 2,
62 PLDM_STR_TYPE_UTF_16 = 3,
63 PLDM_STR_TYPE_UTF_16LE = 4,
64 PLDM_STR_TYPE_UTF_16BE = 5
65};
66
67/** @brief Descriptor types defined in PLDM firmware update specification
68 */
69enum pldm_firmware_update_descriptor_types {
70 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
71 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
72 PLDM_FWUP_UUID = 0x0002,
73 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
74 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
75 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
76 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
77 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
78 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
79 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
80 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
81 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
82 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
83 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
84 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
85 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
86 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
87 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
88};
89
90/** @brief Descriptor types length defined in PLDM firmware update specification
91 */
92enum pldm_firmware_update_descriptor_types_length {
93 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
94 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
95 PLDM_FWUP_UUID_LENGTH = 16,
96 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
97 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
98 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
99 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
100 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
101 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
102 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
103 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
104 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
105 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
106 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
107 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
108 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
109 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
110};
111
gokulsanker1b909d82021-04-05 17:26:02 +0530112/** @brief ComponentClassification values defined in firmware update
113 * specification
114 */
115enum pldm_component_classification_values {
116 PLDM_COMP_UNKNOWN = 0x0000,
117 PLDM_COMP_OTHER = 0x0001,
118 PLDM_COMP_DRIVER = 0x0002,
119 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
120 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
121 PLDM_COMP_INSTRUMENTATION = 0x0005,
122 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
123 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
124 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
125 PLDM_COMP_MIDDLEWARE = 0x0009,
126 PLDM_COMP_FIRMWARE = 0x000A,
127 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
128 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
129 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
130 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
131};
132
gokulsanker566784b2021-04-05 17:47:04 +0530133/** @brief ComponentResponse values in the response of PassComponentTable
134 */
135enum pldm_component_responses {
136 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
137 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
138};
139
140/** @brief ComponentResponseCode values in the response of PassComponentTable
141 */
142enum pldm_component_response_codes {
143 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
144 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
145 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
146 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
147 PLDM_CRC_COMP_CONFLICT = 0x04,
148 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
149 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
150 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
151 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
152 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
153 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
154 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
155 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
156 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
157};
158
gokulsanker4b533f22021-04-22 12:53:00 +0530159/** @brief ComponentCompatibilityResponse values in the response of
160 * UpdateComponent
161 */
162enum pldm_component_compatability_responses {
163 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
164 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
165};
166
167/** @brief ComponentCompatibilityResponse Code values in the response of
168 * UpdateComponent
169 */
170enum pldm_component_compatability_response_codes {
171 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
172 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
173 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
174 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
175 PLDM_CCRC_COMP_CONFLICT = 0x04,
176 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
177 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
178 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
179 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
180 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
181 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
182 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
183 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
184 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
185};
186
Tom Joseph568e4702021-06-07 22:15:49 -0700187/** @struct pldm_package_header_information
188 *
189 * Structure representing fixed part of package header information
190 */
191struct pldm_package_header_information {
192 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
193 uint8_t package_header_format_version;
194 uint16_t package_header_size;
195 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
196 uint16_t component_bitmap_bit_length;
197 uint8_t package_version_string_type;
198 uint8_t package_version_string_length;
199} __attribute__((packed));
200
Tom Joseph64af3452021-06-08 04:05:28 -0700201/** @struct pldm_firmware_device_id_record
202 *
203 * Structure representing firmware device ID record
204 */
205struct pldm_firmware_device_id_record {
206 uint16_t record_length;
207 uint8_t descriptor_count;
208 bitfield32_t device_update_option_flags;
209 uint8_t comp_image_set_version_string_type;
210 uint8_t comp_image_set_version_string_length;
211 uint16_t fw_device_pkg_data_length;
212} __attribute__((packed));
213
Tom Joseph763b51e2021-06-05 04:50:47 -0700214/** @struct pldm_descriptor_tlv
215 *
216 * Structure representing descriptor type, length and value
217 */
218struct pldm_descriptor_tlv {
219 uint16_t descriptor_type;
220 uint16_t descriptor_length;
221 uint8_t descriptor_data[1];
222} __attribute__((packed));
223
224/** @struct pldm_vendor_defined_descriptor_title_data
225 *
226 * Structure representing vendor defined descriptor title sections
227 */
228struct pldm_vendor_defined_descriptor_title_data {
229 uint8_t vendor_defined_descriptor_title_str_type;
230 uint8_t vendor_defined_descriptor_title_str_len;
231 uint8_t vendor_defined_descriptor_title_str[1];
232} __attribute__((packed));
233
Tom Joseph58cc1722021-06-09 07:15:49 -0700234/** @struct pldm_component_image_information
235 *
236 * Structure representing fixed part of individual component information in
237 * PLDM firmware update package
238 */
239struct pldm_component_image_information {
240 uint16_t comp_classification;
241 uint16_t comp_identifier;
242 uint32_t comp_comparison_stamp;
243 bitfield16_t comp_options;
244 bitfield16_t requested_comp_activation_method;
245 uint32_t comp_location_offset;
246 uint32_t comp_size;
247 uint8_t comp_version_string_type;
248 uint8_t comp_version_string_length;
249} __attribute__((packed));
250
gokulsankereca3e192021-04-05 14:57:41 +0530251/** @struct pldm_query_device_identifiers_resp
252 *
253 * Structure representing query device identifiers response.
254 */
255struct pldm_query_device_identifiers_resp {
256 uint8_t completion_code;
257 uint32_t device_identifiers_len;
258 uint8_t descriptor_count;
259} __attribute__((packed));
260
gokulsanker22fbb342021-04-05 15:55:06 +0530261/** @struct pldm_get_firmware_parameters_resp
262 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700263 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530264 */
265struct pldm_get_firmware_parameters_resp {
266 uint8_t completion_code;
267 bitfield32_t capabilities_during_update;
268 uint16_t comp_count;
269 uint8_t active_comp_image_set_ver_str_type;
270 uint8_t active_comp_image_set_ver_str_len;
271 uint8_t pending_comp_image_set_ver_str_type;
272 uint8_t pending_comp_image_set_ver_str_len;
273} __attribute__((packed));
274
gokulsankere1fb7a82021-04-05 16:09:29 +0530275/** @struct pldm_component_parameter_entry
276 *
277 * Structure representing component parameter table entry.
278 */
279struct pldm_component_parameter_entry {
280 uint16_t comp_classification;
281 uint16_t comp_identifier;
282 uint8_t comp_classification_index;
283 uint32_t active_comp_comparison_stamp;
284 uint8_t active_comp_ver_str_type;
285 uint8_t active_comp_ver_str_len;
286 uint8_t active_comp_release_date[8];
287 uint32_t pending_comp_comparison_stamp;
288 uint8_t pending_comp_ver_str_type;
289 uint8_t pending_comp_ver_str_len;
290 uint8_t pending_comp_release_date[8];
291 bitfield16_t comp_activation_methods;
292 bitfield32_t capabilities_during_update;
293} __attribute__((packed));
294
gokulsankerd434edc2021-04-05 16:36:04 +0530295/** @struct pldm_request_update_req
296 *
297 * Structure representing fixed part of Request Update request
298 */
299struct pldm_request_update_req {
300 uint32_t max_transfer_size;
301 uint16_t num_of_comp;
302 uint8_t max_outstanding_transfer_req;
303 uint16_t pkg_data_len;
304 uint8_t comp_image_set_ver_str_type;
305 uint8_t comp_image_set_ver_str_len;
306} __attribute__((packed));
307
gokulsanker611238c2021-04-05 16:50:44 +0530308/** @struct pldm_request_update_resp
309 *
310 * Structure representing Request Update response
311 */
312struct pldm_request_update_resp {
313 uint8_t completion_code;
314 uint16_t fd_meta_data_len;
315 uint8_t fd_will_send_pkg_data;
316} __attribute__((packed));
317
gokulsanker1b909d82021-04-05 17:26:02 +0530318/** @struct pldm_pass_component_table_req
319 *
320 * Structure representing PassComponentTable request
321 */
322struct pldm_pass_component_table_req {
323 uint8_t transfer_flag;
324 uint16_t comp_classification;
325 uint16_t comp_identifier;
326 uint8_t comp_classification_index;
327 uint32_t comp_comparison_stamp;
328 uint8_t comp_ver_str_type;
329 uint8_t comp_ver_str_len;
330} __attribute__((packed));
331
gokulsanker566784b2021-04-05 17:47:04 +0530332/** @struct pldm_pass_component_table_resp
333 *
334 * Structure representing PassComponentTable response
335 */
336struct pldm_pass_component_table_resp {
337 uint8_t completion_code;
338 uint8_t comp_resp;
339 uint8_t comp_resp_code;
340} __attribute__((packed));
341
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530342/** @struct pldm_update_component_req
343 *
344 * Structure representing UpdateComponent request
345 */
346struct pldm_update_component_req {
347 uint16_t comp_classification;
348 uint16_t comp_identifier;
349 uint8_t comp_classification_index;
350 uint32_t comp_comparison_stamp;
351 uint32_t comp_image_size;
352 bitfield32_t update_option_flags;
353 uint8_t comp_ver_str_type;
354 uint8_t comp_ver_str_len;
355} __attribute__((packed));
356
gokulsanker4b533f22021-04-22 12:53:00 +0530357/** @struct pldm_update_component_resp
358 *
359 * Structure representing UpdateComponent response
360 */
361struct pldm_update_component_resp {
362 uint8_t completion_code;
363 uint8_t comp_compatability_resp;
364 uint8_t comp_compatability_resp_code;
365 bitfield32_t update_option_flags_enabled;
366 uint16_t time_before_req_fw_data;
367} __attribute__((packed));
368
Tom Joseph568e4702021-06-07 22:15:49 -0700369/** @brief Decode the PLDM package header information
370 *
371 * @param[in] data - pointer to package header information
372 * @param[in] length - available length in the firmware update package
373 * @param[out] package_header_info - pointer to fixed part of PLDM package
374 * header information
375 * @param[out] package_version_str - pointer to package version string
376 *
377 * @return pldm_completion_codes
378 */
379int decode_pldm_package_header_info(
380 const uint8_t *data, size_t length,
381 struct pldm_package_header_information *package_header_info,
382 struct variable_field *package_version_str);
383
Tom Joseph64af3452021-06-08 04:05:28 -0700384/** @brief Decode individual firmware device ID record
385 *
386 * @param[in] data - pointer to firmware device ID record
387 * @param[in] length - available length in the firmware update package
388 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
389 * parsed from the package header info
390 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
391 * id record
392 * @param[out] applicable_components - pointer to ApplicableComponents
393 * @param[out] comp_image_set_version_str - pointer to
394 * ComponentImageSetVersionString
395 * @param[out] record_descriptors - pointer to RecordDescriptors
396 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
397 *
398 * @return pldm_completion_codes
399 */
400int decode_firmware_device_id_record(
401 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
402 struct pldm_firmware_device_id_record *fw_device_id_record,
403 struct variable_field *applicable_components,
404 struct variable_field *comp_image_set_version_str,
405 struct variable_field *record_descriptors,
406 struct variable_field *fw_device_pkg_data);
407
Tom Joseph763b51e2021-06-05 04:50:47 -0700408/** @brief Decode the record descriptor entries in the firmware update package
409 * and the Descriptors in the QueryDeviceIDentifiers command
410 *
411 * @param[in] data - pointer to descriptor entry
412 * @param[in] length - remaining length of the descriptor data
413 * @param[out] descriptor_type - pointer to descriptor type
414 * @param[out] descriptor_data - pointer to descriptor data
415 *
416 * @return pldm_completion_codes
417 */
418int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
419 uint16_t *descriptor_type,
420 struct variable_field *descriptor_data);
421
422/** @brief Decode the vendor defined descriptor value
423 *
424 * @param[in] data - pointer to vendor defined descriptor value
425 * @param[in] length - length of the vendor defined descriptor value
426 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
427 * title string type
428 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
429 * title string
430 * @param[out] descriptor_data - pointer to vendor defined descriptor data
431 *
432 * @return pldm_completion_codes
433 */
434int decode_vendor_defined_descriptor_value(
435 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
436 struct variable_field *descriptor_title_str,
437 struct variable_field *descriptor_data);
438
Tom Joseph58cc1722021-06-09 07:15:49 -0700439/** @brief Decode individual component image information
440 *
441 * @param[in] data - pointer to component image information
442 * @param[in] length - available length in the firmware update package
443 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
444 * information
445 * @param[out] comp_version_str - pointer to component version string
446 *
447 * @return pldm_completion_codes
448 */
449int decode_pldm_comp_image_info(
450 const uint8_t *data, size_t length,
451 struct pldm_component_image_information *pldm_comp_image_info,
452 struct variable_field *comp_version_str);
453
gokulsanker138ceba2021-04-05 13:25:25 +0530454/** @brief Create a PLDM request message for QueryDeviceIdentifiers
455 *
456 * @param[in] instance_id - Message's instance id
457 * @param[in] payload_length - Length of the request message payload
458 * @param[in,out] msg - Message will be written to this
459 *
460 * @return pldm_completion_codes
461 *
462 * @note Caller is responsible for memory alloc and dealloc of param
463 * 'msg.payload'
464 */
465int encode_query_device_identifiers_req(uint8_t instance_id,
466 size_t payload_length,
467 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530468
469/** @brief Decode QueryDeviceIdentifiers response message
470 *
471 * @param[in] msg - Response message
472 * @param[in] payload_length - Length of response message payload
473 * @param[out] completion_code - Pointer to response msg's PLDM completion code
474 * @param[out] device_identifiers_len - Pointer to device identifiers length
475 * @param[out] descriptor_count - Pointer to descriptor count
476 * @param[out] descriptor_data - Pointer to descriptor data
477 *
478 * @return pldm_completion_codes
479 */
480int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
481 size_t payload_length,
482 uint8_t *completion_code,
483 uint32_t *device_identifiers_len,
484 uint8_t *descriptor_count,
485 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530486
487/** @brief Create a PLDM request message for GetFirmwareParameters
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_get_firmware_parameters_req(uint8_t instance_id,
499 size_t payload_length,
500 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530501
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700502/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530503 *
504 * @param[in] msg - Response message
505 * @param[in] payload_length - Length of response message payload
506 * @param[out] resp_data - Pointer to get firmware parameters response
507 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700508 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530509 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700510 * image set version string
511 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530512 *
513 * @return pldm_completion_codes
514 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700515int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530516 const struct pldm_msg *msg, size_t payload_length,
517 struct pldm_get_firmware_parameters_resp *resp_data,
518 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700519 struct variable_field *pending_comp_image_set_ver_str,
520 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530521
gokulsankere1fb7a82021-04-05 16:09:29 +0530522/** @brief Decode component entries in the component parameter table which is
523 * part of the response of GetFirmwareParameters command
524 *
525 * @param[in] data - Component entry
526 * @param[in] length - Length of component entry
527 * @param[out] component_data - Pointer to component parameter table
528 * @param[out] active_comp_ver_str - Pointer to active component version string
529 * @param[out] pending_comp_ver_str - Pointer to pending component version
530 * string
531 *
532 * @return pldm_completion_codes
533 */
534int decode_get_firmware_parameters_resp_comp_entry(
535 const uint8_t *data, size_t length,
536 struct pldm_component_parameter_entry *component_data,
537 struct variable_field *active_comp_ver_str,
538 struct variable_field *pending_comp_ver_str);
539
gokulsankerd434edc2021-04-05 16:36:04 +0530540/** @brief Create PLDM request message for RequestUpdate
541 *
542 * @param[in] instance_id - Message's instance id
543 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
544 * to be requested via RequestFirmwareData
545 * command
546 * @param[in] num_of_comp - Total number of components that will be passed to
547 * the FD during the update
548 * @param[in] max_outstanding_transfer_req - Total number of outstanding
549 * RequestFirmwareData
550 * commands that can be sent by the FD
551 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
552 * present in firmware package header
553 * @param[in] comp_image_set_ver_str_type - StringType of
554 * ComponentImageSetVersionString
555 * @param[in] comp_image_set_ver_str_len - The length of the
556 * ComponentImageSetVersionString
557 * @param[in] comp_img_set_ver_str - Component Image Set version information
558 * @param[in,out] msg - Message will be written to this
559 * @param[in] payload_length - Length of request message payload
560 *
561 * @return pldm_completion_codes
562 *
563 * @note Caller is responsible for memory alloc and dealloc of param
564 * 'msg.payload'
565 */
566int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
567 uint16_t num_of_comp,
568 uint8_t max_outstanding_transfer_req,
569 uint16_t pkg_data_len,
570 uint8_t comp_image_set_ver_str_type,
571 uint8_t comp_image_set_ver_str_len,
572 const struct variable_field *comp_img_set_ver_str,
573 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530574
575/** @brief Decode a RequestUpdate response message
576 *
577 * @param[in] msg - Response message
578 * @param[in] payload_length - Length of response message payload
579 * @param[out] completion_code - Pointer to hold the completion code
580 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
581 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
582 * will send GetPackageData command
583 * @return pldm_completion_codes
584 */
585int decode_request_update_resp(const struct pldm_msg *msg,
586 size_t payload_length, uint8_t *completion_code,
587 uint16_t *fd_meta_data_len,
588 uint8_t *fd_will_send_pkg_data);
589
gokulsanker1b909d82021-04-05 17:26:02 +0530590/** @brief Create PLDM request message for PassComponentTable
591 *
592 * @param[in] instance_id - Message's instance id
593 * @param[in] transfer_flag - TransferFlag
594 * @param[in] comp_classification - ComponentClassification
595 * @param[in] comp_identifier - ComponentIdentifier
596 * @param[in] comp_classification_index - ComponentClassificationIndex
597 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
598 * @param[in] comp_ver_str_type - ComponentVersionStringType
599 * @param[in] comp_ver_str_len - ComponentVersionStringLength
600 * @param[in] comp_ver_str - ComponentVersionString
601 * @param[in,out] msg - Message will be written to this
602 * @param[in] payload_length - Length of request message payload
603 * information
604 *
605 * @return pldm_completion_codes
606 *
607 * @note Caller is responsible for memory alloc and dealloc of param
608 * 'msg.payload'
609 */
610int encode_pass_component_table_req(
611 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
612 uint16_t comp_identifier, uint8_t comp_classification_index,
613 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
614 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
615 struct pldm_msg *msg, size_t payload_length);
616
gokulsanker566784b2021-04-05 17:47:04 +0530617/** @brief Decode PassComponentTable response message
618 *
619 * @param[in] msg - Response message
620 * @param[in] payload_length - Length of response message payload
621 * @param[out] completion_code - Pointer to hold completion code
622 * @param[out] comp_resp - Pointer to hold component response
623 * @param[out] comp_resp_code - Pointer to hold component response code
624 *
625 * @return pldm_completion_codes
626 */
627int decode_pass_component_table_resp(const struct pldm_msg *msg,
628 size_t payload_length,
629 uint8_t *completion_code,
630 uint8_t *comp_resp,
631 uint8_t *comp_resp_code);
632
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530633/** @brief Create PLDM request message for UpdateComponent
634 *
635 * @param[in] instance_id - Message's instance id
636 * @param[in] comp_classification - ComponentClassification
637 * @param[in] comp_identifier - ComponentIdentifier
638 * @param[in] comp_classification_index - ComponentClassificationIndex
639 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
640 * @param[in] comp_image_size - ComponentImageSize
641 * @param[in] update_option_flags - UpdateOptionFlags
642 * @param[in] comp_ver_str_type - ComponentVersionStringType
643 * @param[in] comp_ver_str_len - ComponentVersionStringLength
644 * @param[in] comp_ver_str - ComponentVersionString
645 * @param[in,out] msg - Message will be written to this
646 * @param[in] payload_length - Length of request message payload
647 * information
648 *
649 * @return pldm_completion_codes
650 *
651 * @note Caller is responsible for memory alloc and dealloc of param
652 * 'msg.payload'
653 */
654int encode_update_component_req(
655 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
656 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
657 uint32_t comp_image_size, bitfield32_t update_option_flags,
658 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
659 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
660 size_t payload_length);
661
gokulsanker4b533f22021-04-22 12:53:00 +0530662/** @brief Decode UpdateComponent 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_compatability_resp - Pointer to hold component
668 * compatibility response
669 * @param[out] comp_compatability_resp_code - Pointer to hold component
670 * compatibility response code
671 * @param[out] update_option_flags_enabled - Pointer to hold
672 * UpdateOptionsFlagEnabled
673 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
674 * before sending RequestFirmwareData
675 *
676 * @return pldm_completion_codes
677 */
678int decode_update_component_resp(const struct pldm_msg *msg,
679 size_t payload_length,
680 uint8_t *completion_code,
681 uint8_t *comp_compatability_resp,
682 uint8_t *comp_compatability_resp_code,
683 bitfield32_t *update_option_flags_enabled,
684 uint16_t *time_before_req_fw_data);
gokulsanker138ceba2021-04-05 13:25:25 +0530685#ifdef __cplusplus
686}
687#endif
688
689#endif // End of FW_UPDATE_H