blob: 64e023a2d98ec36c4fe573b24ae4e4ba4bccf436 [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
Tom Joseph568e4702021-06-07 22:15:49 -0700159/** @struct pldm_package_header_information
160 *
161 * Structure representing fixed part of package header information
162 */
163struct pldm_package_header_information {
164 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
165 uint8_t package_header_format_version;
166 uint16_t package_header_size;
167 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
168 uint16_t component_bitmap_bit_length;
169 uint8_t package_version_string_type;
170 uint8_t package_version_string_length;
171} __attribute__((packed));
172
Tom Joseph64af3452021-06-08 04:05:28 -0700173/** @struct pldm_firmware_device_id_record
174 *
175 * Structure representing firmware device ID record
176 */
177struct pldm_firmware_device_id_record {
178 uint16_t record_length;
179 uint8_t descriptor_count;
180 bitfield32_t device_update_option_flags;
181 uint8_t comp_image_set_version_string_type;
182 uint8_t comp_image_set_version_string_length;
183 uint16_t fw_device_pkg_data_length;
184} __attribute__((packed));
185
Tom Joseph763b51e2021-06-05 04:50:47 -0700186/** @struct pldm_descriptor_tlv
187 *
188 * Structure representing descriptor type, length and value
189 */
190struct pldm_descriptor_tlv {
191 uint16_t descriptor_type;
192 uint16_t descriptor_length;
193 uint8_t descriptor_data[1];
194} __attribute__((packed));
195
196/** @struct pldm_vendor_defined_descriptor_title_data
197 *
198 * Structure representing vendor defined descriptor title sections
199 */
200struct pldm_vendor_defined_descriptor_title_data {
201 uint8_t vendor_defined_descriptor_title_str_type;
202 uint8_t vendor_defined_descriptor_title_str_len;
203 uint8_t vendor_defined_descriptor_title_str[1];
204} __attribute__((packed));
205
Tom Joseph58cc1722021-06-09 07:15:49 -0700206/** @struct pldm_component_image_information
207 *
208 * Structure representing fixed part of individual component information in
209 * PLDM firmware update package
210 */
211struct pldm_component_image_information {
212 uint16_t comp_classification;
213 uint16_t comp_identifier;
214 uint32_t comp_comparison_stamp;
215 bitfield16_t comp_options;
216 bitfield16_t requested_comp_activation_method;
217 uint32_t comp_location_offset;
218 uint32_t comp_size;
219 uint8_t comp_version_string_type;
220 uint8_t comp_version_string_length;
221} __attribute__((packed));
222
gokulsankereca3e192021-04-05 14:57:41 +0530223/** @struct pldm_query_device_identifiers_resp
224 *
225 * Structure representing query device identifiers response.
226 */
227struct pldm_query_device_identifiers_resp {
228 uint8_t completion_code;
229 uint32_t device_identifiers_len;
230 uint8_t descriptor_count;
231} __attribute__((packed));
232
gokulsanker22fbb342021-04-05 15:55:06 +0530233/** @struct pldm_get_firmware_parameters_resp
234 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700235 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530236 */
237struct pldm_get_firmware_parameters_resp {
238 uint8_t completion_code;
239 bitfield32_t capabilities_during_update;
240 uint16_t comp_count;
241 uint8_t active_comp_image_set_ver_str_type;
242 uint8_t active_comp_image_set_ver_str_len;
243 uint8_t pending_comp_image_set_ver_str_type;
244 uint8_t pending_comp_image_set_ver_str_len;
245} __attribute__((packed));
246
gokulsankere1fb7a82021-04-05 16:09:29 +0530247/** @struct pldm_component_parameter_entry
248 *
249 * Structure representing component parameter table entry.
250 */
251struct pldm_component_parameter_entry {
252 uint16_t comp_classification;
253 uint16_t comp_identifier;
254 uint8_t comp_classification_index;
255 uint32_t active_comp_comparison_stamp;
256 uint8_t active_comp_ver_str_type;
257 uint8_t active_comp_ver_str_len;
258 uint8_t active_comp_release_date[8];
259 uint32_t pending_comp_comparison_stamp;
260 uint8_t pending_comp_ver_str_type;
261 uint8_t pending_comp_ver_str_len;
262 uint8_t pending_comp_release_date[8];
263 bitfield16_t comp_activation_methods;
264 bitfield32_t capabilities_during_update;
265} __attribute__((packed));
266
gokulsankerd434edc2021-04-05 16:36:04 +0530267/** @struct pldm_request_update_req
268 *
269 * Structure representing fixed part of Request Update request
270 */
271struct pldm_request_update_req {
272 uint32_t max_transfer_size;
273 uint16_t num_of_comp;
274 uint8_t max_outstanding_transfer_req;
275 uint16_t pkg_data_len;
276 uint8_t comp_image_set_ver_str_type;
277 uint8_t comp_image_set_ver_str_len;
278} __attribute__((packed));
279
gokulsanker611238c2021-04-05 16:50:44 +0530280/** @struct pldm_request_update_resp
281 *
282 * Structure representing Request Update response
283 */
284struct pldm_request_update_resp {
285 uint8_t completion_code;
286 uint16_t fd_meta_data_len;
287 uint8_t fd_will_send_pkg_data;
288} __attribute__((packed));
289
gokulsanker1b909d82021-04-05 17:26:02 +0530290/** @struct pldm_pass_component_table_req
291 *
292 * Structure representing PassComponentTable request
293 */
294struct pldm_pass_component_table_req {
295 uint8_t transfer_flag;
296 uint16_t comp_classification;
297 uint16_t comp_identifier;
298 uint8_t comp_classification_index;
299 uint32_t comp_comparison_stamp;
300 uint8_t comp_ver_str_type;
301 uint8_t comp_ver_str_len;
302} __attribute__((packed));
303
gokulsanker566784b2021-04-05 17:47:04 +0530304/** @struct pldm_pass_component_table_resp
305 *
306 * Structure representing PassComponentTable response
307 */
308struct pldm_pass_component_table_resp {
309 uint8_t completion_code;
310 uint8_t comp_resp;
311 uint8_t comp_resp_code;
312} __attribute__((packed));
313
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530314/** @struct pldm_update_component_req
315 *
316 * Structure representing UpdateComponent request
317 */
318struct pldm_update_component_req {
319 uint16_t comp_classification;
320 uint16_t comp_identifier;
321 uint8_t comp_classification_index;
322 uint32_t comp_comparison_stamp;
323 uint32_t comp_image_size;
324 bitfield32_t update_option_flags;
325 uint8_t comp_ver_str_type;
326 uint8_t comp_ver_str_len;
327} __attribute__((packed));
328
Tom Joseph568e4702021-06-07 22:15:49 -0700329/** @brief Decode the PLDM package header information
330 *
331 * @param[in] data - pointer to package header information
332 * @param[in] length - available length in the firmware update package
333 * @param[out] package_header_info - pointer to fixed part of PLDM package
334 * header information
335 * @param[out] package_version_str - pointer to package version string
336 *
337 * @return pldm_completion_codes
338 */
339int decode_pldm_package_header_info(
340 const uint8_t *data, size_t length,
341 struct pldm_package_header_information *package_header_info,
342 struct variable_field *package_version_str);
343
Tom Joseph64af3452021-06-08 04:05:28 -0700344/** @brief Decode individual firmware device ID record
345 *
346 * @param[in] data - pointer to firmware device ID record
347 * @param[in] length - available length in the firmware update package
348 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
349 * parsed from the package header info
350 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
351 * id record
352 * @param[out] applicable_components - pointer to ApplicableComponents
353 * @param[out] comp_image_set_version_str - pointer to
354 * ComponentImageSetVersionString
355 * @param[out] record_descriptors - pointer to RecordDescriptors
356 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
357 *
358 * @return pldm_completion_codes
359 */
360int decode_firmware_device_id_record(
361 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
362 struct pldm_firmware_device_id_record *fw_device_id_record,
363 struct variable_field *applicable_components,
364 struct variable_field *comp_image_set_version_str,
365 struct variable_field *record_descriptors,
366 struct variable_field *fw_device_pkg_data);
367
Tom Joseph763b51e2021-06-05 04:50:47 -0700368/** @brief Decode the record descriptor entries in the firmware update package
369 * and the Descriptors in the QueryDeviceIDentifiers command
370 *
371 * @param[in] data - pointer to descriptor entry
372 * @param[in] length - remaining length of the descriptor data
373 * @param[out] descriptor_type - pointer to descriptor type
374 * @param[out] descriptor_data - pointer to descriptor data
375 *
376 * @return pldm_completion_codes
377 */
378int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
379 uint16_t *descriptor_type,
380 struct variable_field *descriptor_data);
381
382/** @brief Decode the vendor defined descriptor value
383 *
384 * @param[in] data - pointer to vendor defined descriptor value
385 * @param[in] length - length of the vendor defined descriptor value
386 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
387 * title string type
388 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
389 * title string
390 * @param[out] descriptor_data - pointer to vendor defined descriptor data
391 *
392 * @return pldm_completion_codes
393 */
394int decode_vendor_defined_descriptor_value(
395 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
396 struct variable_field *descriptor_title_str,
397 struct variable_field *descriptor_data);
398
Tom Joseph58cc1722021-06-09 07:15:49 -0700399/** @brief Decode individual component image information
400 *
401 * @param[in] data - pointer to component image information
402 * @param[in] length - available length in the firmware update package
403 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
404 * information
405 * @param[out] comp_version_str - pointer to component version string
406 *
407 * @return pldm_completion_codes
408 */
409int decode_pldm_comp_image_info(
410 const uint8_t *data, size_t length,
411 struct pldm_component_image_information *pldm_comp_image_info,
412 struct variable_field *comp_version_str);
413
gokulsanker138ceba2021-04-05 13:25:25 +0530414/** @brief Create a PLDM request message for QueryDeviceIdentifiers
415 *
416 * @param[in] instance_id - Message's instance id
417 * @param[in] payload_length - Length of the request message payload
418 * @param[in,out] msg - Message will be written to this
419 *
420 * @return pldm_completion_codes
421 *
422 * @note Caller is responsible for memory alloc and dealloc of param
423 * 'msg.payload'
424 */
425int encode_query_device_identifiers_req(uint8_t instance_id,
426 size_t payload_length,
427 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530428
429/** @brief Decode QueryDeviceIdentifiers response message
430 *
431 * @param[in] msg - Response message
432 * @param[in] payload_length - Length of response message payload
433 * @param[out] completion_code - Pointer to response msg's PLDM completion code
434 * @param[out] device_identifiers_len - Pointer to device identifiers length
435 * @param[out] descriptor_count - Pointer to descriptor count
436 * @param[out] descriptor_data - Pointer to descriptor data
437 *
438 * @return pldm_completion_codes
439 */
440int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
441 size_t payload_length,
442 uint8_t *completion_code,
443 uint32_t *device_identifiers_len,
444 uint8_t *descriptor_count,
445 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530446
447/** @brief Create a PLDM request message for GetFirmwareParameters
448 *
449 * @param[in] instance_id - Message's instance id
450 * @param[in] payload_length - Length of the request message payload
451 * @param[in,out] msg - Message will be written to this
452 *
453 * @return pldm_completion_codes
454 *
455 * @note Caller is responsible for memory alloc and dealloc of param
456 * 'msg.payload'
457 */
458int encode_get_firmware_parameters_req(uint8_t instance_id,
459 size_t payload_length,
460 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530461
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700462/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530463 *
464 * @param[in] msg - Response message
465 * @param[in] payload_length - Length of response message payload
466 * @param[out] resp_data - Pointer to get firmware parameters response
467 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700468 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530469 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700470 * image set version string
471 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530472 *
473 * @return pldm_completion_codes
474 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700475int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530476 const struct pldm_msg *msg, size_t payload_length,
477 struct pldm_get_firmware_parameters_resp *resp_data,
478 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700479 struct variable_field *pending_comp_image_set_ver_str,
480 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530481
gokulsankere1fb7a82021-04-05 16:09:29 +0530482/** @brief Decode component entries in the component parameter table which is
483 * part of the response of GetFirmwareParameters command
484 *
485 * @param[in] data - Component entry
486 * @param[in] length - Length of component entry
487 * @param[out] component_data - Pointer to component parameter table
488 * @param[out] active_comp_ver_str - Pointer to active component version string
489 * @param[out] pending_comp_ver_str - Pointer to pending component version
490 * string
491 *
492 * @return pldm_completion_codes
493 */
494int decode_get_firmware_parameters_resp_comp_entry(
495 const uint8_t *data, size_t length,
496 struct pldm_component_parameter_entry *component_data,
497 struct variable_field *active_comp_ver_str,
498 struct variable_field *pending_comp_ver_str);
499
gokulsankerd434edc2021-04-05 16:36:04 +0530500/** @brief Create PLDM request message for RequestUpdate
501 *
502 * @param[in] instance_id - Message's instance id
503 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
504 * to be requested via RequestFirmwareData
505 * command
506 * @param[in] num_of_comp - Total number of components that will be passed to
507 * the FD during the update
508 * @param[in] max_outstanding_transfer_req - Total number of outstanding
509 * RequestFirmwareData
510 * commands that can be sent by the FD
511 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
512 * present in firmware package header
513 * @param[in] comp_image_set_ver_str_type - StringType of
514 * ComponentImageSetVersionString
515 * @param[in] comp_image_set_ver_str_len - The length of the
516 * ComponentImageSetVersionString
517 * @param[in] comp_img_set_ver_str - Component Image Set version information
518 * @param[in,out] msg - Message will be written to this
519 * @param[in] payload_length - Length of request message payload
520 *
521 * @return pldm_completion_codes
522 *
523 * @note Caller is responsible for memory alloc and dealloc of param
524 * 'msg.payload'
525 */
526int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
527 uint16_t num_of_comp,
528 uint8_t max_outstanding_transfer_req,
529 uint16_t pkg_data_len,
530 uint8_t comp_image_set_ver_str_type,
531 uint8_t comp_image_set_ver_str_len,
532 const struct variable_field *comp_img_set_ver_str,
533 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530534
535/** @brief Decode a RequestUpdate response message
536 *
537 * @param[in] msg - Response message
538 * @param[in] payload_length - Length of response message payload
539 * @param[out] completion_code - Pointer to hold the completion code
540 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
541 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
542 * will send GetPackageData command
543 * @return pldm_completion_codes
544 */
545int decode_request_update_resp(const struct pldm_msg *msg,
546 size_t payload_length, uint8_t *completion_code,
547 uint16_t *fd_meta_data_len,
548 uint8_t *fd_will_send_pkg_data);
549
gokulsanker1b909d82021-04-05 17:26:02 +0530550/** @brief Create PLDM request message for PassComponentTable
551 *
552 * @param[in] instance_id - Message's instance id
553 * @param[in] transfer_flag - TransferFlag
554 * @param[in] comp_classification - ComponentClassification
555 * @param[in] comp_identifier - ComponentIdentifier
556 * @param[in] comp_classification_index - ComponentClassificationIndex
557 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
558 * @param[in] comp_ver_str_type - ComponentVersionStringType
559 * @param[in] comp_ver_str_len - ComponentVersionStringLength
560 * @param[in] comp_ver_str - ComponentVersionString
561 * @param[in,out] msg - Message will be written to this
562 * @param[in] payload_length - Length of request message payload
563 * information
564 *
565 * @return pldm_completion_codes
566 *
567 * @note Caller is responsible for memory alloc and dealloc of param
568 * 'msg.payload'
569 */
570int encode_pass_component_table_req(
571 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
572 uint16_t comp_identifier, uint8_t comp_classification_index,
573 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
574 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
575 struct pldm_msg *msg, size_t payload_length);
576
gokulsanker566784b2021-04-05 17:47:04 +0530577/** @brief Decode PassComponentTable response message
578 *
579 * @param[in] msg - Response message
580 * @param[in] payload_length - Length of response message payload
581 * @param[out] completion_code - Pointer to hold completion code
582 * @param[out] comp_resp - Pointer to hold component response
583 * @param[out] comp_resp_code - Pointer to hold component response code
584 *
585 * @return pldm_completion_codes
586 */
587int decode_pass_component_table_resp(const struct pldm_msg *msg,
588 size_t payload_length,
589 uint8_t *completion_code,
590 uint8_t *comp_resp,
591 uint8_t *comp_resp_code);
592
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530593/** @brief Create PLDM request message for UpdateComponent
594 *
595 * @param[in] instance_id - Message's instance id
596 * @param[in] comp_classification - ComponentClassification
597 * @param[in] comp_identifier - ComponentIdentifier
598 * @param[in] comp_classification_index - ComponentClassificationIndex
599 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
600 * @param[in] comp_image_size - ComponentImageSize
601 * @param[in] update_option_flags - UpdateOptionFlags
602 * @param[in] comp_ver_str_type - ComponentVersionStringType
603 * @param[in] comp_ver_str_len - ComponentVersionStringLength
604 * @param[in] comp_ver_str - ComponentVersionString
605 * @param[in,out] msg - Message will be written to this
606 * @param[in] payload_length - Length of request message payload
607 * information
608 *
609 * @return pldm_completion_codes
610 *
611 * @note Caller is responsible for memory alloc and dealloc of param
612 * 'msg.payload'
613 */
614int encode_update_component_req(
615 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
616 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
617 uint32_t comp_image_size, bitfield32_t update_option_flags,
618 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
619 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
620 size_t payload_length);
621
gokulsanker138ceba2021-04-05 13:25:25 +0530622#ifdef __cplusplus
623}
624#endif
625
626#endif // End of FW_UPDATE_H