1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 #ifndef BASE_H 3 #define BASE_H 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 #include <libpldm/pldm_types.h> 10 11 #include <asm/byteorder.h> 12 #include <stdalign.h> 13 #include <stdbool.h> 14 #include <stddef.h> 15 #include <stdint.h> 16 17 typedef uint8_t pldm_tid_t; 18 19 /** @brief PLDM Types 20 */ 21 enum pldm_supported_types { 22 PLDM_BASE = 0x00, 23 PLDM_SMBIOS = 0x01, 24 PLDM_PLATFORM = 0x02, 25 PLDM_BIOS = 0x03, 26 PLDM_FRU = 0x04, 27 PLDM_FWUP = 0x05, 28 PLDM_RDE = 0x06, 29 PLDM_OEM = 0x3f, 30 }; 31 32 /** @brief PLDM Commands 33 */ 34 enum pldm_supported_commands { 35 PLDM_SET_TID = 0x1, 36 PLDM_GET_TID = 0x2, 37 PLDM_GET_PLDM_VERSION = 0x3, 38 PLDM_GET_PLDM_TYPES = 0x4, 39 PLDM_GET_PLDM_COMMANDS = 0x5, 40 PLDM_SELECT_PLDM_VERSION = 0x6, 41 PLDM_NEGOTIATE_TRANSFER_PARAMETERS = 0x7, 42 PLDM_MULTIPART_SEND = 0x8, 43 PLDM_MULTIPART_RECEIVE = 0x9, 44 PLDM_GET_MULTIPART_TRANSFER_SUPPORT = 0xa, 45 }; 46 47 /** @brief PLDM base codes 48 */ 49 enum pldm_completion_codes { 50 PLDM_SUCCESS = 0x00, 51 PLDM_ERROR = 0x01, 52 PLDM_ERROR_INVALID_DATA = 0x02, 53 PLDM_ERROR_INVALID_LENGTH = 0x03, 54 PLDM_ERROR_NOT_READY = 0x04, 55 PLDM_ERROR_UNSUPPORTED_PLDM_CMD = 0x05, 56 PLDM_ERROR_INVALID_PLDM_TYPE = 0x20, 57 PLDM_INVALID_TRANSFER_OPERATION_FLAG = 0x21 58 }; 59 60 enum transfer_op_flag { 61 PLDM_GET_NEXTPART = 0, 62 PLDM_GET_FIRSTPART = 1, 63 PLDM_ACKNOWLEDGEMENT_ONLY = 2, 64 }; 65 66 enum transfer_multipart_op_flag { 67 PLDM_XFER_FIRST_PART = 0, 68 PLDM_XFER_NEXT_PART = 1, 69 PLDM_XFER_ABORT = 2, 70 PLDM_XFER_COMPLETE = 3, 71 PLDM_XFER_CURRENT_PART = 4, 72 }; 73 74 enum transfer_resp_flag { 75 PLDM_START = 0x01, 76 PLDM_MIDDLE = 0x02, 77 PLDM_END = 0x04, 78 PLDM_START_AND_END = 0x05, 79 }; 80 81 /** @brief PLDM transport protocol type 82 */ 83 enum pldm_transport_protocol_type { 84 PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP = 0x00, 85 PLDM_TRANSPORT_PROTOCOL_TYPE_OEM = 0xff, 86 }; 87 88 /** @enum MessageType 89 * 90 * The different message types supported by the PLDM specification. 91 */ 92 typedef enum { 93 PLDM_RESPONSE, //!< PLDM response 94 PLDM_REQUEST, //!< PLDM request 95 PLDM_RESERVED, //!< Reserved 96 PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages 97 } MessageType; 98 99 #define PLDM_INSTANCE_MAX 31 100 #define PLDM_MAX_TYPES 64 101 #define PLDM_MAX_CMDS_PER_TYPE 256 102 #define PLDM_MAX_TIDS 256 103 #define PLDM_TID_UNASSIGNED 0x00 104 #define PLDM_TID_RESERVED 0xff 105 106 /* Message payload lengths */ 107 #define PLDM_GET_COMMANDS_REQ_BYTES 5 108 #define PLDM_GET_VERSION_REQ_BYTES 6 109 110 /* Response lengths are inclusive of completion code */ 111 #define PLDM_GET_TYPES_RESP_BYTES 9 112 #define PLDM_GET_TID_RESP_BYTES 2 113 #define PLDM_SET_TID_RESP_BYTES 1 114 #define PLDM_GET_COMMANDS_RESP_BYTES 33 115 /* Response data has only one version and does not contain the checksum */ 116 #define PLDM_GET_VERSION_RESP_BYTES 10 117 #define PLDM_MULTIPART_RECEIVE_REQ_BYTES 18 118 119 #define PLDM_VERSION_0 0 120 #define PLDM_CURRENT_VERSION PLDM_VERSION_0 121 122 #define PLDM_TIMESTAMP104_SIZE 13 123 124 /** @brief Minimum length of response for a optional PLDM command 125 * 126 * For a optional PLDM command, the command handler might not be 127 * implemented in a device's firmware, a response contains only CC 128 * might come in, such as ERROR_UNSUPPORTED_PLDM_CMD. 129 * 130 * The description can be found in DSP0240: 131 * > For an unsupported PLDM command, the ERROR_UNSUPPORTED_PLDM_CMD 132 * > completion code shall be returned unless the responder is in a 133 * > transient state (not ready), in which it cannot process the PLDM 134 * > command. If the responder is in a transient state, it may return 135 * > the ERROR_NOT_READY completion code. 136 */ 137 #define PLDM_OPTIONAL_COMMAND_RESP_MIN_LEN 1 138 139 /** @struct pldm_msg_hdr 140 * 141 * Structure representing PLDM message header fields 142 */ 143 struct pldm_msg_hdr { 144 #if defined(__LITTLE_ENDIAN_BITFIELD) 145 uint8_t instance_id : 5; //!< Instance ID 146 uint8_t reserved : 1; //!< Reserved 147 uint8_t datagram : 1; //!< Datagram bit 148 uint8_t request : 1; //!< Request bit 149 #elif defined(__BIG_ENDIAN_BITFIELD) 150 uint8_t request : 1; //!< Request bit 151 uint8_t datagram : 1; //!< Datagram bit 152 uint8_t reserved : 1; //!< Reserved 153 uint8_t instance_id : 5; //!< Instance ID 154 #endif 155 156 #if defined(__LITTLE_ENDIAN_BITFIELD) 157 uint8_t type : 6; //!< PLDM type 158 uint8_t header_ver : 2; //!< Header version 159 #elif defined(__BIG_ENDIAN_BITFIELD) 160 uint8_t header_ver : 2; //!< Header version 161 uint8_t type : 6; //!< PLDM type 162 #endif 163 uint8_t command; //!< PLDM command code 164 } __attribute__((packed)); 165 166 // Macros for byte-swapping variables in-place 167 #define HTOLE32(X) ((X) = htole32(X)) 168 #define HTOLE16(X) ((X) = htole16(X)) 169 #define LE32TOH(X) ((X) = le32toh(X)) 170 #define LE16TOH(X) ((X) = le16toh(X)) 171 172 /** @struct pldm_msg 173 * 174 * Structure representing PLDM message 175 */ 176 struct pldm_msg { 177 struct pldm_msg_hdr hdr; //!< PLDM message header 178 uint8_t payload[1]; //!< &payload[0] is the beginning of the payload 179 } __attribute__((packed)); 180 181 /** @brief Determine the underlying object size for a @struct pldm_msg 182 * 183 * @pre @p size must be a constant expression 184 * 185 * @note Providing an expression for @p size that is not an integer constant 186 * expression will force a compilation failure. 187 * 188 * @param size The desired size of the @struct pldm_msg payload 189 */ 190 #define PLDM_MSG_SIZE(size) \ 191 (sizeof(char[(__builtin_constant_p(size)) ? 1 : -1])) * \ 192 (sizeof(struct pldm_msg) - \ 193 sizeof(((struct pldm_msg *)NULL)->payload) + (size)) 194 195 /** @brief Stack-allocate a buffer to hold a @struct pldm_msg 196 * 197 * Allocate an appropriately aligned array named @p name of type unsigned char 198 * with the necessary length to hold a payload of the requested size. 199 * 200 * @param name - The variable name used to define the buffer 201 * @param size - The desired payload length for the intended @struct pldm_msg 202 */ 203 #define PLDM_MSG_BUFFER(name, size) \ 204 alignas(struct pldm_msg) unsigned char(name)[PLDM_MSG_SIZE(size)] 205 206 /** @brief Create a pointer to a stack-allocated @struct pldm_msg 207 * 208 * Define a pointer named @p name of type @struct pldm_msg to an object on the 209 * stack of appropriate alignment and length to hold a @struct pldm_msg with a 210 * payload of @p size. 211 * 212 * @param name - The variable name for pointer 213 * @param size - The desired payload length for the underlying @struct pldm_msg 214 * buffer 215 */ 216 #ifdef __cplusplus 217 #define PLDM_MSG_DEFINE_P(name, size) \ 218 PLDM_MSG_BUFFER(name##_buf, size); \ 219 auto *(name) = new (name##_buf) pldm_msg 220 #endif 221 222 /** 223 * @brief Compare the headers from two PLDM messages to determine if the latter 224 * is a message representing a response to the former, where the former must be 225 * a request. 226 * 227 * @param[in] req - A pointer to a PLDM header object, which must represent a 228 * request 229 * @param[in] resp - A pointer to a PLDM header object, which may represent a 230 * response to the provided request. 231 * 232 * @return true if the header pointed to by resp represents a message that is a 233 * response to the header pointed to by req, otherwise false. 234 */ 235 bool pldm_msg_hdr_correlate_response(const struct pldm_msg_hdr *req, 236 const struct pldm_msg_hdr *resp); 237 238 /** @struct pldm_header_info 239 * 240 * The information needed to prepare PLDM header and this is passed to the 241 * pack_pldm_header and unpack_pldm_header API. 242 */ 243 struct pldm_header_info { 244 MessageType msg_type; //!< PLDM message type 245 uint8_t instance; //!< PLDM instance id 246 uint8_t pldm_type; //!< PLDM type 247 uint8_t command; //!< PLDM command code 248 uint8_t completion_code; //!< PLDM completion code, applies for response 249 }; 250 251 /** @struct pldm_get_types_resp 252 * 253 * Structure representing PLDM get types response. 254 */ 255 struct pldm_get_types_resp { 256 uint8_t completion_code; //!< completion code 257 bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type 258 //!< is supported 259 } __attribute__((packed)); 260 261 /** @struct pldm_get_commands_req 262 * 263 * Structure representing PLDM get commands request. 264 */ 265 struct pldm_get_commands_req { 266 uint8_t type; //!< PLDM Type for which command support information is 267 //!< being requested 268 ver32_t version; //!< version for the specified PLDM Type 269 } __attribute__((packed)); 270 271 /** @struct pldm_get_commands_resp 272 * 273 * Structure representing PLDM get commands response. 274 */ 275 struct pldm_get_commands_resp { 276 uint8_t completion_code; //!< completion code 277 bitfield8_t commands[32]; //!< each bit represents whether a given PLDM 278 //!< command is supported 279 } __attribute__((packed)); 280 281 /** @struct pldm_get_version_req 282 * 283 * Structure representing PLDM get version request. 284 */ 285 struct pldm_get_version_req { 286 uint32_t transfer_handle; //!< handle to identify PLDM version data transfer 287 uint8_t transfer_opflag; //!< PLDM GetVersion operation flag 288 uint8_t type; //!< PLDM Type for which version information is being requested 289 } __attribute__((packed)); 290 291 /** @struct pldm_get_version_resp 292 * 293 * Structure representing PLDM get version response. 294 */ 295 296 struct pldm_get_version_resp { 297 uint8_t completion_code; //!< completion code 298 uint32_t next_transfer_handle; //!< next portion of PLDM version data 299 //!< transfer 300 uint8_t transfer_flag; //!< PLDM GetVersion transfer flag 301 uint8_t version_data[1]; //!< PLDM GetVersion version field 302 } __attribute__((packed)); 303 304 /** @struct pldm_set_tid_req 305 * 306 * Structure representing PLDM set tid request. 307 */ 308 309 struct pldm_set_tid_req { 310 uint8_t tid; //!< PLDM SetTID TID field 311 } __attribute__((packed)); 312 313 /** @struct pldm_get_tid_resp 314 * 315 * Structure representing PLDM get tid response. 316 */ 317 318 struct pldm_get_tid_resp { 319 uint8_t completion_code; //!< completion code 320 uint8_t tid; //!< PLDM GetTID TID field 321 } __attribute__((packed)); 322 323 /** @struct pldm_multipart_receive_req 324 * 325 * Structure representing PLDM multipart receive request. 326 */ 327 struct pldm_multipart_receive_req { 328 uint8_t pldm_type; //!< PLDM Type for the MultipartReceive 329 //!< command. 330 uint8_t transfer_opflag; //!< PLDM MultipartReceive operation flag. 331 uint32_t transfer_ctx; //!< Protocol-specifc context for this 332 //!< transfer. 333 uint32_t transfer_handle; //!< handle to identify the part of data to be 334 //!< received. 335 uint32_t section_offset; //!< The start offset for the requested 336 //!< section. 337 uint32_t section_length; //!< The length (in bytes) of the section 338 //!< requested. 339 } __attribute__((packed)); 340 /** 341 * @brief Populate the PLDM message with the PLDM header.The caller of this API 342 * allocates buffer for the PLDM header when forming the PLDM message. 343 * The buffer is passed to this API to pack the PLDM header. 344 * 345 * @param[in] hdr - Pointer to the PLDM header information 346 * @param[out] msg - Pointer to PLDM message header 347 * 348 * @return 0 on success, otherwise PLDM error codes. 349 * @note Caller is responsible for alloc and dealloc of msg 350 * and hdr params 351 */ 352 uint8_t pack_pldm_header(const struct pldm_header_info *hdr, 353 struct pldm_msg_hdr *msg); 354 355 /** 356 * @brief Unpack the PLDM header from the PLDM message. 357 * 358 * @param[in] msg - Pointer to the PLDM message header 359 * @param[out] hdr - Pointer to the PLDM header information 360 * 361 * @return 0 on success, otherwise PLDM error codes. 362 * @note Caller is responsible for alloc and dealloc of msg 363 * and hdr params 364 */ 365 uint8_t unpack_pldm_header(const struct pldm_msg_hdr *msg, 366 struct pldm_header_info *hdr); 367 368 /* Requester */ 369 370 /* GetPLDMTypes */ 371 372 /** @brief Create a PLDM request message for GetPLDMTypes 373 * 374 * @param[in] instance_id - Message's instance id 375 * @param[in,out] msg - Message will be written to this 376 * @return pldm_completion_codes 377 * @note Caller is responsible for memory alloc and dealloc of param 378 * 'msg.payload' 379 */ 380 int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg); 381 382 /** @brief Decode a GetPLDMTypes response message 383 * 384 * Note: 385 * * If the return value is not PLDM_SUCCESS, it represents a 386 * transport layer error. 387 * * If the completion_code value is not PLDM_SUCCESS, it represents a 388 * protocol layer error and all the out-parameters are invalid. 389 * 390 * @param[in] msg - Response message 391 * @param[in] payload_length - Length of response message payload 392 * @param[out] completion_code - Pointer to response msg's PLDM completion code 393 * @param[out] types - pointer to array bitfield8_t[8] containing supported 394 * types (MAX_TYPES/8) = 8), as per DSP0240 395 * @return pldm_completion_codes 396 */ 397 int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length, 398 uint8_t *completion_code, bitfield8_t *types); 399 400 /* GetPLDMCommands */ 401 402 /** @brief Create a PLDM request message for GetPLDMCommands 403 * 404 * @param[in] instance_id - Message's instance id 405 * @param[in] type - PLDM Type 406 * @param[in] version - Version for PLDM Type 407 * @param[in,out] msg - Message will be written to this 408 * @return pldm_completion_codes 409 * @note Caller is responsible for memory alloc and dealloc of param 410 * 'msg.payload' 411 */ 412 int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version, 413 struct pldm_msg *msg); 414 415 /** @brief Decode a GetPLDMCommands response message 416 * 417 * Note: 418 * * If the return value is not PLDM_SUCCESS, it represents a 419 * transport layer error. 420 * * If the completion_code value is not PLDM_SUCCESS, it represents a 421 * protocol layer error and all the out-parameters are invalid. 422 * 423 * @param[in] msg - Response message 424 * @param[in] payload_length - Length of response message payload 425 * @param[out] completion_code - Pointer to response msg's PLDM completion code 426 * @param[in] commands - pointer to array bitfield8_t[32] containing supported 427 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 428 * @return pldm_completion_codes 429 */ 430 int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length, 431 uint8_t *completion_code, bitfield8_t *commands); 432 433 /* GetPLDMVersion */ 434 435 /** @brief Create a PLDM request for GetPLDMVersion 436 * 437 * @param[in] instance_id - Message's instance id 438 * @param[in] transfer_handle - Handle to identify PLDM version data transfer. 439 * This handle is ignored by the responder when the 440 * transferop_flag is set to getFirstPart. 441 * @param[in] transfer_opflag - flag to indicate whether it is start of 442 * transfer 443 * @param[in] type - PLDM Type for which version is requested 444 * @param[in,out] msg - Message will be written to this 445 * @return pldm_completion_codes 446 * @note Caller is responsible for memory alloc and dealloc of param 447 * 'msg.payload' 448 */ 449 int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle, 450 uint8_t transfer_opflag, uint8_t type, 451 struct pldm_msg *msg); 452 453 /** @brief Decode a GetPLDMVersion response message 454 * 455 * Note: 456 * * If the return value is not PLDM_SUCCESS, it represents a 457 * transport layer error. 458 * * If the completion_code value is not PLDM_SUCCESS, it represents a 459 * protocol layer error and all the out-parameters are invalid. 460 * 461 * @param[in] msg - Response message 462 * @param[in] payload_length - Length of response message payload 463 * @param[out] completion_code - Pointer to response msg's PLDM completion code 464 * @param[out] next_transfer_handle - the next handle for the next part of data 465 * @param[out] transfer_flag - flag to indicate the part of data 466 * @return pldm_completion_codes 467 */ 468 int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length, 469 uint8_t *completion_code, 470 uint32_t *next_transfer_handle, 471 uint8_t *transfer_flag, ver32_t *version); 472 473 /* GetTID */ 474 475 /** @brief Decode a GetTID response message 476 * 477 * Note: 478 * * If the return value is not PLDM_SUCCESS, it represents a 479 * transport layer error. 480 * * If the completion_code value is not PLDM_SUCCESS, it represents a 481 * protocol layer error and all the out-parameters are invalid. 482 * 483 * @param[in] msg - Response message 484 * @param[in] payload_length - Length of response message payload 485 * @param[out] completion_code - Pointer to response msg's PLDM completion code 486 * @param[out] tid - Pointer to the terminus id 487 * @return pldm_completion_codes 488 */ 489 int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length, 490 uint8_t *completion_code, uint8_t *tid); 491 492 /* Responder */ 493 494 /* GetPLDMTypes */ 495 496 /** @brief Create a PLDM response message for GetPLDMTypes 497 * 498 * @param[in] instance_id - Message's instance id 499 * @param[in] completion_code - PLDM completion code 500 * @param[in] types - pointer to array bitfield8_t[8] containing supported 501 * types (MAX_TYPES/8) = 8), as per DSP0240 502 * @param[in,out] msg - Message will be written to this 503 * @return pldm_completion_codes 504 * @note Caller is responsible for memory alloc and dealloc of param 505 * 'msg.payload' 506 */ 507 int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code, 508 const bitfield8_t *types, struct pldm_msg *msg); 509 510 /* GetPLDMCommands */ 511 512 /** @brief Decode GetPLDMCommands' request data 513 * 514 * @param[in] msg - Request message 515 * @param[in] payload_length - Length of request message payload 516 * @param[out] type - PLDM Type 517 * @param[out] version - Version for PLDM Type 518 * @return pldm_completion_codes 519 */ 520 int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length, 521 uint8_t *type, ver32_t *version); 522 523 /** @brief Create a PLDM response message for GetPLDMCommands 524 * 525 * @param[in] instance_id - Message's instance id 526 * @param[in] completion_code - PLDM completion code 527 * @param[in] commands - pointer to array bitfield8_t[32] containing supported 528 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 529 * @param[in,out] msg - Message will be written to this 530 * @return pldm_completion_codes 531 * @note Caller is responsible for memory alloc and dealloc of param 532 * 'msg.payload' 533 */ 534 int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code, 535 const bitfield8_t *commands, struct pldm_msg *msg); 536 537 /* GetPLDMVersion */ 538 539 /** @brief Create a PLDM response for GetPLDMVersion 540 * 541 * @param[in] instance_id - Message's instance id 542 * @param[in] completion_code - PLDM completion code 543 * @param[in] next_transfer_handle - Handle to identify next portion of 544 * data transfer 545 * @param[in] transfer_flag - Represents the part of transfer 546 * @param[in] version_data - the version data 547 * @param[in] version_size - size of version data 548 * @param[in,out] msg - Message will be written to this 549 * @return pldm_completion_codes 550 * @note Caller is responsible for memory alloc and dealloc of param 551 * 'msg.payload' 552 */ 553 int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code, 554 uint32_t next_transfer_handle, 555 uint8_t transfer_flag, const ver32_t *version_data, 556 size_t version_size, struct pldm_msg *msg); 557 558 /** @brief Decode a GetPLDMVersion request message 559 * 560 * @param[in] msg - Request message 561 * @param[in] payload_length - length of request message payload 562 * @param[out] transfer_handle - the handle of data 563 * @param[out] transfer_opflag - Transfer Flag 564 * @param[out] type - PLDM type for which version is requested 565 * @return pldm_completion_codes 566 */ 567 int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length, 568 uint32_t *transfer_handle, uint8_t *transfer_opflag, 569 uint8_t *type); 570 571 /* Requester */ 572 573 /* GetTID */ 574 575 /** @brief Create a PLDM request message for GetTID 576 * 577 * @param[in] instance_id - Message's instance id 578 * @param[in,out] msg - Message will be written to this 579 * @return pldm_completion_codes 580 * @note Caller is responsible for memory alloc and dealloc of param 581 * 'msg.payload' 582 */ 583 int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg); 584 585 /** @brief Create a PLDM response message for GetTID 586 * 587 * @param[in] instance_id - Message's instance id 588 * @param[in] completion_code - PLDM completion code 589 * @param[in] tid - Terminus ID 590 * @param[in,out] msg - Message will be written to this 591 * @return pldm_completion_codes 592 * @note Caller is responsible for memory alloc and dealloc of param 593 * 'msg.payload' 594 */ 595 int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code, 596 uint8_t tid, struct pldm_msg *msg); 597 598 /** @brief Create a PLDM request message for SetTID 599 * 600 * @param[in] instance_id - Message's instance id 601 * @param[in] tid - Terminus ID 602 * @param[in,out] msg - Message will be written to this 603 * @return pldm_completion_codes 604 * @note Caller is responsible for memory alloc and dealloc of param 605 * 'msg.payload' 606 */ 607 int encode_set_tid_req(uint8_t instance_id, uint8_t tid, struct pldm_msg *msg); 608 609 /* Responder */ 610 611 /* MultipartRecieve */ 612 613 /** @brief Decode a PLDM MultipartReceive request message 614 * 615 * @param[in] msg - Request message 616 * @param[in] payload_length - length of request message payload 617 * @param[out] pldm_type - PLDM type for which version is requested 618 * @param[out] transfer_opflag - Transfer Flag 619 * @param[out] transfer_ctx - The context of the packet 620 * @param[out] transfer_handle - The handle of data 621 * @param[out] section_offset - The start of the requested section 622 * @param[out] section_length - The length of the requested section 623 * @return pldm_completion_codes 624 */ 625 int decode_multipart_receive_req(const struct pldm_msg *msg, 626 size_t payload_length, uint8_t *pldm_type, 627 uint8_t *transfer_opflag, 628 uint32_t *transfer_ctx, 629 uint32_t *transfer_handle, 630 uint32_t *section_offset, 631 uint32_t *section_length); 632 633 /** @brief Create a PLDM response message containing only cc 634 * 635 * @param[in] instance_id - Message's instance id 636 * @param[in] type - PLDM Type 637 * @param[in] command - PLDM Command 638 * @param[in] cc - PLDM Completion Code 639 * @param[out] msg - Message will be written to this 640 * @return pldm_completion_codes 641 */ 642 int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command, 643 uint8_t cc, struct pldm_msg *msg); 644 645 /** @brief Create a PLDM message only with the header 646 * 647 * @param[in] msg_type - PLDM message type 648 * @param[in] instance_id - Message's instance id 649 * @param[in] pldm_type - PLDM Type 650 * @param[in] command - PLDM Command 651 * @param[out] msg - Message will be written to this 652 * 653 * @return pldm_completion_codes 654 */ 655 int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id, 656 uint8_t pldm_type, uint8_t command, 657 struct pldm_msg *msg); 658 659 #ifdef __cplusplus 660 } 661 #endif 662 663 #endif /* BASE_H */ 664