Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 1 | #ifndef BASE_H |
| 2 | #define BASE_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <asm/byteorder.h> |
| 9 | #include <stddef.h> |
| 10 | #include <stdint.h> |
| 11 | |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 12 | #include "pldm_types.h" |
| 13 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 14 | /** @brief PLDM Types |
| 15 | */ |
| 16 | enum pldm_supported_types { |
| 17 | PLDM_BASE = 0x00, |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 18 | PLDM_PLATFORM = 0x02, |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 19 | PLDM_BIOS = 0x03, |
Jinu Joy Thomas | 8e92c6c | 2019-08-06 12:22:34 +0530 | [diff] [blame] | 20 | PLDM_FRU = 0x04, |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 21 | PLDM_OEM = 0x3F, |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | /** @brief PLDM Commands |
| 25 | */ |
| 26 | enum pldm_supported_commands { |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 27 | PLDM_GET_TID = 0x2, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 28 | PLDM_GET_PLDM_VERSION = 0x3, |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 29 | PLDM_GET_PLDM_TYPES = 0x4, |
| 30 | PLDM_GET_PLDM_COMMANDS = 0x5 |
| 31 | }; |
| 32 | |
| 33 | /** @brief PLDM base codes |
| 34 | */ |
| 35 | enum pldm_completion_codes { |
| 36 | PLDM_SUCCESS = 0x00, |
| 37 | PLDM_ERROR = 0x01, |
| 38 | PLDM_ERROR_INVALID_DATA = 0x02, |
| 39 | PLDM_ERROR_INVALID_LENGTH = 0x03, |
| 40 | PLDM_ERROR_NOT_READY = 0x04, |
| 41 | PLDM_ERROR_UNSUPPORTED_PLDM_CMD = 0x05, |
| 42 | PLDM_ERROR_INVALID_PLDM_TYPE = 0x20 |
| 43 | }; |
| 44 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 45 | enum transfer_op_flag { |
| 46 | PLDM_GET_NEXTPART = 0, |
| 47 | PLDM_GET_FIRSTPART = 1, |
| 48 | }; |
| 49 | |
| 50 | enum transfer_resp_flag { |
| 51 | PLDM_START = 0x01, |
| 52 | PLDM_MIDDLE = 0x02, |
| 53 | PLDM_END = 0x04, |
| 54 | PLDM_START_AND_END = 0x05, |
| 55 | }; |
| 56 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 57 | /** @enum MessageType |
| 58 | * |
| 59 | * The different message types supported by the PLDM specification. |
| 60 | */ |
| 61 | typedef enum { |
| 62 | PLDM_RESPONSE, //!< PLDM response |
| 63 | PLDM_REQUEST, //!< PLDM request |
| 64 | PLDM_RESERVED, //!< Reserved |
| 65 | PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages |
| 66 | } MessageType; |
| 67 | |
| 68 | #define PLDM_INSTANCE_MAX 31 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 69 | #define PLDM_MAX_TYPES 64 |
| 70 | #define PLDM_MAX_CMDS_PER_TYPE 256 |
| 71 | |
| 72 | /* Message payload lengths */ |
| 73 | #define PLDM_GET_COMMANDS_REQ_BYTES 5 |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 74 | #define PLDM_GET_VERSION_REQ_BYTES 6 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 75 | |
| 76 | /* Response lengths are inclusive of completion code */ |
| 77 | #define PLDM_GET_TYPES_RESP_BYTES 9 |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 78 | #define PLDM_GET_TID_RESP_BYTES 2 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 79 | #define PLDM_GET_COMMANDS_RESP_BYTES 33 |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 80 | /* Response data has only one version and does not contain the checksum */ |
| 81 | #define PLDM_GET_VERSION_RESP_BYTES 10 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 82 | |
Christian Geddes | 6c146f1 | 2020-05-01 14:48:23 -0500 | [diff] [blame] | 83 | #define PLDM_VERSION_0 0 |
| 84 | #define PLDM_CURRENT_VERSION PLDM_VERSION_0 |
| 85 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 86 | /** @struct pldm_msg_hdr |
| 87 | * |
| 88 | * Structure representing PLDM message header fields |
| 89 | */ |
| 90 | struct pldm_msg_hdr { |
| 91 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 92 | uint8_t instance_id : 5; //!< Instance ID |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 93 | uint8_t reserved : 1; //!< Reserved |
| 94 | uint8_t datagram : 1; //!< Datagram bit |
| 95 | uint8_t request : 1; //!< Request bit |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 96 | #elif defined(__BIG_ENDIAN_BITFIELD) |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 97 | uint8_t request : 1; //!< Request bit |
| 98 | uint8_t datagram : 1; //!< Datagram bit |
| 99 | uint8_t reserved : 1; //!< Reserved |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 100 | uint8_t instance_id : 5; //!< Instance ID |
| 101 | #endif |
| 102 | |
| 103 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 104 | uint8_t type : 6; //!< PLDM type |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 105 | uint8_t header_ver : 2; //!< Header version |
| 106 | #elif defined(__BIG_ENDIAN_BITFIELD) |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 107 | uint8_t header_ver : 2; //!< Header version |
| 108 | uint8_t type : 6; //!< PLDM type |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 109 | #endif |
| 110 | uint8_t command; //!< PLDM command code |
| 111 | } __attribute__((packed)); |
| 112 | |
Zach Clark | b728eee | 2020-06-18 10:01:31 -0500 | [diff] [blame] | 113 | // Macros for byte-swapping variables in-place |
| 114 | #define HTOLE32(X) (X = htole32(X)) |
| 115 | #define HTOLE16(X) (X = htole16(X)) |
George Liu | cae1866 | 2020-05-15 09:32:57 +0800 | [diff] [blame] | 116 | #define LE32TOH(X) (X = le32toh(X)) |
| 117 | #define LE16TOH(X) (X = le16toh(X)) |
Zach Clark | b728eee | 2020-06-18 10:01:31 -0500 | [diff] [blame] | 118 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 119 | /** @struct pldm_msg |
| 120 | * |
| 121 | * Structure representing PLDM message |
| 122 | */ |
| 123 | struct pldm_msg { |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 124 | struct pldm_msg_hdr hdr; //!< PLDM message header |
| 125 | uint8_t payload[1]; //!< &payload[0] is the beginning of the payload |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 126 | } __attribute__((packed)); |
| 127 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 128 | /** @struct pldm_header_info |
| 129 | * |
| 130 | * The information needed to prepare PLDM header and this is passed to the |
| 131 | * pack_pldm_header and unpack_pldm_header API. |
| 132 | */ |
| 133 | struct pldm_header_info { |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 134 | MessageType msg_type; //!< PLDM message type |
| 135 | uint8_t instance; //!< PLDM instance id |
| 136 | uint8_t pldm_type; //!< PLDM type |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 137 | uint8_t command; //!< PLDM command code |
| 138 | uint8_t completion_code; //!< PLDM completion code, applies for response |
| 139 | }; |
| 140 | |
Priyanga | 4b790ce | 2019-06-10 01:30:09 -0500 | [diff] [blame] | 141 | /** @struct pldm_get_types_resp |
| 142 | * |
| 143 | * Structure representing PLDM get types response. |
| 144 | */ |
| 145 | struct pldm_get_types_resp { |
| 146 | uint8_t completion_code; //!< completion code |
| 147 | bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type |
| 148 | //!< is supported |
| 149 | } __attribute__((packed)); |
| 150 | |
| 151 | /** @struct pldm_get_commands_req |
| 152 | * |
| 153 | * Structure representing PLDM get commands request. |
| 154 | */ |
| 155 | struct pldm_get_commands_req { |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 156 | uint8_t type; //!< PLDM Type for which command support information is |
Priyanga | 4b790ce | 2019-06-10 01:30:09 -0500 | [diff] [blame] | 157 | //!< being requested |
| 158 | ver32_t version; //!< version for the specified PLDM Type |
| 159 | } __attribute__((packed)); |
| 160 | |
| 161 | /** @struct pldm_get_commands_resp |
| 162 | * |
| 163 | * Structure representing PLDM get commands response. |
| 164 | */ |
| 165 | struct pldm_get_commands_resp { |
| 166 | uint8_t completion_code; //!< completion code |
| 167 | bitfield8_t commands[32]; //!< each bit represents whether a given PLDM |
| 168 | //!< command is supported |
| 169 | } __attribute__((packed)); |
| 170 | |
| 171 | /** @struct pldm_get_version_req |
| 172 | * |
| 173 | * Structure representing PLDM get version request. |
| 174 | */ |
| 175 | struct pldm_get_version_req { |
| 176 | uint32_t |
| 177 | transfer_handle; //!< handle to identify PLDM version data transfer |
| 178 | uint8_t transfer_opflag; //!< PLDM GetVersion operation flag |
| 179 | uint8_t type; //!< PLDM Type for which version information is being |
| 180 | //!< requested |
| 181 | } __attribute__((packed)); |
| 182 | |
| 183 | /** @struct pldm_get_version_resp |
| 184 | * |
| 185 | * Structure representing PLDM get version response. |
| 186 | */ |
| 187 | |
| 188 | struct pldm_get_version_resp { |
| 189 | uint8_t completion_code; //!< completion code |
| 190 | uint32_t next_transfer_handle; //!< next portion of PLDM version data |
| 191 | //!< transfer |
Deepak Kodihalli | 826c9d4 | 2020-05-26 01:58:06 -0500 | [diff] [blame] | 192 | uint8_t transfer_flag; //!< PLDM GetVersion transfer flag |
Priyanga | 4b790ce | 2019-06-10 01:30:09 -0500 | [diff] [blame] | 193 | uint8_t version_data[1]; //!< PLDM GetVersion version field |
| 194 | } __attribute__((packed)); |
| 195 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 196 | /** @struct pldm_get_tid_resp |
| 197 | * |
| 198 | * Structure representing PLDM get tid response. |
| 199 | */ |
| 200 | |
| 201 | struct pldm_get_tid_resp { |
| 202 | uint8_t completion_code; //!< completion code |
| 203 | uint8_t tid; //!< PLDM GetTID TID field |
| 204 | } __attribute__((packed)); |
| 205 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 206 | /** |
| 207 | * @brief Populate the PLDM message with the PLDM header.The caller of this API |
| 208 | * allocates buffer for the PLDM header when forming the PLDM message. |
| 209 | * The buffer is passed to this API to pack the PLDM header. |
| 210 | * |
| 211 | * @param[in] hdr - Pointer to the PLDM header information |
| 212 | * @param[out] msg - Pointer to PLDM message header |
| 213 | * |
| 214 | * @return 0 on success, otherwise PLDM error codes. |
Christian Geddes | 6c146f1 | 2020-05-01 14:48:23 -0500 | [diff] [blame] | 215 | * @note Caller is responsible for alloc and dealloc of msg |
| 216 | * and hdr params |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 217 | */ |
| 218 | int pack_pldm_header(const struct pldm_header_info *hdr, |
| 219 | struct pldm_msg_hdr *msg); |
| 220 | |
| 221 | /** |
| 222 | * @brief Unpack the PLDM header from the PLDM message. |
| 223 | * |
| 224 | * @param[in] msg - Pointer to the PLDM message header |
| 225 | * @param[out] hdr - Pointer to the PLDM header information |
| 226 | * |
| 227 | * @return 0 on success, otherwise PLDM error codes. |
Christian Geddes | 6c146f1 | 2020-05-01 14:48:23 -0500 | [diff] [blame] | 228 | * @note Caller is responsible for alloc and dealloc of msg |
| 229 | * and hdr params |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 230 | */ |
| 231 | int unpack_pldm_header(const struct pldm_msg_hdr *msg, |
| 232 | struct pldm_header_info *hdr); |
| 233 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 234 | /* Requester */ |
| 235 | |
| 236 | /* GetPLDMTypes */ |
| 237 | |
| 238 | /** @brief Create a PLDM request message for GetPLDMTypes |
| 239 | * |
| 240 | * @param[in] instance_id - Message's instance id |
| 241 | * @param[in,out] msg - Message will be written to this |
| 242 | * @return pldm_completion_codes |
| 243 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 244 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 245 | */ |
| 246 | int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg); |
| 247 | |
| 248 | /** @brief Decode a GetPLDMTypes response message |
| 249 | * |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 250 | * Note: |
| 251 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 252 | * transport layer error. |
| 253 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 254 | * protocol layer error and all the out-parameters are invalid. |
| 255 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 256 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 257 | * @param[in] payload_length - Length of response message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 258 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 259 | * @param[out] types - pointer to array bitfield8_t[8] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 260 | * types (MAX_TYPES/8) = 8), as per DSP0240 |
| 261 | * @return pldm_completion_codes |
| 262 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 263 | int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 264 | uint8_t *completion_code, bitfield8_t *types); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 265 | |
| 266 | /* GetPLDMCommands */ |
| 267 | |
| 268 | /** @brief Create a PLDM request message for GetPLDMCommands |
| 269 | * |
| 270 | * @param[in] instance_id - Message's instance id |
| 271 | * @param[in] type - PLDM Type |
| 272 | * @param[in] version - Version for PLDM Type |
| 273 | * @param[in,out] msg - Message will be written to this |
| 274 | * @return pldm_completion_codes |
| 275 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 276 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 277 | */ |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 278 | int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version, |
| 279 | struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 280 | |
| 281 | /** @brief Decode a GetPLDMCommands response message |
| 282 | * |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 283 | * Note: |
| 284 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 285 | * transport layer error. |
| 286 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 287 | * protocol layer error and all the out-parameters are invalid. |
| 288 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 289 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 290 | * @param[in] payload_length - Length of reponse message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 291 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 292 | * @param[in] commands - pointer to array bitfield8_t[32] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 293 | * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 |
| 294 | * @return pldm_completion_codes |
| 295 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 296 | int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 297 | uint8_t *completion_code, bitfield8_t *commands); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 298 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 299 | /* GetPLDMVersion */ |
| 300 | |
| 301 | /** @brief Create a PLDM request for GetPLDMVersion |
| 302 | * |
| 303 | * @param[in] instance_id - Message's instance id |
| 304 | * @param[in] transfer_handle - Handle to identify PLDM version data transfer. |
| 305 | * This handle is ignored by the responder when the |
| 306 | * transferop_flag is set to getFirstPart. |
| 307 | * @param[in] transfer_opflag - flag to indicate whether it is start of |
| 308 | * transfer |
| 309 | * @param[in] type - PLDM Type for which version is requested |
| 310 | * @param[in,out] msg - Message will be written to this |
| 311 | * @return pldm_completion_codes |
| 312 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 313 | * 'msg.payload' |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 314 | */ |
| 315 | int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle, |
| 316 | uint8_t transfer_opflag, uint8_t type, |
| 317 | struct pldm_msg *msg); |
| 318 | |
| 319 | /** @brief Decode a GetPLDMVersion response message |
| 320 | * |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 321 | * Note: |
| 322 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 323 | * transport layer error. |
| 324 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 325 | * protocol layer error and all the out-parameters are invalid. |
| 326 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 327 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 328 | * @param[in] payload_length - Length of reponse message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 329 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 330 | * @param[out] next_transfer_handle - the next handle for the next part of data |
| 331 | * @param[out] transfer_flag - flag to indicate the part of data |
| 332 | * @return pldm_completion_codes |
| 333 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 334 | int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 335 | uint8_t *completion_code, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 336 | uint32_t *next_transfer_handle, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 337 | uint8_t *transfer_flag, ver32_t *version); |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 338 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 339 | /* GetTID */ |
| 340 | |
| 341 | /** @brief Decode a GetTID response message |
| 342 | * |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 343 | * Note: |
| 344 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 345 | * transport layer error. |
| 346 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 347 | * protocol layer error and all the out-parameters are invalid. |
| 348 | * |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 349 | * @param[in] msg - Response message |
| 350 | * @param[in] payload_length - Length of response message payload |
| 351 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
| 352 | * @param[out] tid - Pointer to the terminus id |
| 353 | * @return pldm_completion_codes |
| 354 | */ |
| 355 | int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length, |
| 356 | uint8_t *completion_code, uint8_t *tid); |
| 357 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 358 | /* Responder */ |
| 359 | |
| 360 | /* GetPLDMTypes */ |
| 361 | |
| 362 | /** @brief Create a PLDM response message for GetPLDMTypes |
| 363 | * |
| 364 | * @param[in] instance_id - Message's instance id |
| 365 | * @param[in] completion_code - PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 366 | * @param[in] types - pointer to array bitfield8_t[8] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 367 | * types (MAX_TYPES/8) = 8), as per DSP0240 |
| 368 | * @param[in,out] msg - Message will be written to this |
| 369 | * @return pldm_completion_codes |
| 370 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 371 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 372 | */ |
| 373 | int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 374 | const bitfield8_t *types, struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 375 | |
| 376 | /* GetPLDMCommands */ |
| 377 | |
| 378 | /** @brief Decode GetPLDMCommands' request data |
| 379 | * |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 380 | * @param[in] msg - Request message |
| 381 | * @param[in] payload_length - Length of request message payload |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 382 | * @param[out] type - PLDM Type |
| 383 | * @param[out] version - Version for PLDM Type |
| 384 | * @return pldm_completion_codes |
| 385 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 386 | int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length, |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 387 | uint8_t *type, ver32_t *version); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 388 | |
| 389 | /** @brief Create a PLDM response message for GetPLDMCommands |
| 390 | * |
| 391 | * @param[in] instance_id - Message's instance id |
| 392 | * @param[in] completion_code - PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 393 | * @param[in] commands - pointer to array bitfield8_t[32] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 394 | * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 |
| 395 | * @param[in,out] msg - Message will be written to this |
| 396 | * @return pldm_completion_codes |
| 397 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 398 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 399 | */ |
| 400 | int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 401 | const bitfield8_t *commands, struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 402 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 403 | /* GetPLDMVersion */ |
| 404 | |
| 405 | /** @brief Create a PLDM response for GetPLDMVersion |
| 406 | * |
| 407 | * @param[in] instance_id - Message's instance id |
| 408 | * @param[in] completion_code - PLDM completion code |
| 409 | * @param[in] next_transfer_handle - Handle to identify next portion of |
| 410 | * data transfer |
| 411 | * @param[in] transfer_flag - Represents the part of transfer |
| 412 | * @param[in] version_data - the version data |
| 413 | * @param[in] version_size - size of version data |
| 414 | * @param[in,out] msg - Message will be written to this |
| 415 | * @return pldm_completion_codes |
| 416 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 417 | * 'msg.payload' |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 418 | */ |
| 419 | int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code, |
| 420 | uint32_t next_transfer_handle, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 421 | uint8_t transfer_flag, const ver32_t *version_data, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 422 | size_t version_size, struct pldm_msg *msg); |
| 423 | |
| 424 | /** @brief Decode a GetPLDMVersion request message |
| 425 | * |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 426 | * @param[in] msg - Request message |
| 427 | * @param[in] payload_length - length of request message payload |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 428 | * @param[out] transfer_handle - the handle of data |
| 429 | * @param[out] transfer_opflag - Transfer Flag |
| 430 | * @param[out] type - PLDM type for which version is requested |
| 431 | * @return pldm_completion_codes |
| 432 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 433 | int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 434 | uint32_t *transfer_handle, uint8_t *transfer_opflag, |
| 435 | uint8_t *type); |
| 436 | |
Sridevi Ramesh | bc6ff26 | 2019-12-12 04:58:35 -0600 | [diff] [blame] | 437 | /* Requester */ |
| 438 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 439 | /* GetTID */ |
| 440 | |
Sridevi Ramesh | bc6ff26 | 2019-12-12 04:58:35 -0600 | [diff] [blame] | 441 | /** @brief Create a PLDM request message for GetTID |
| 442 | * |
| 443 | * @param[in] instance_id - Message's instance id |
| 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_tid_req(uint8_t instance_id, struct pldm_msg *msg); |
| 450 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 451 | /** @brief Create a PLDM response message for GetTID |
| 452 | * |
| 453 | * @param[in] instance_id - Message's instance id |
| 454 | * @param[in] completion_code - PLDM completion code |
| 455 | * @param[in] tid - Terminus ID |
| 456 | * @param[in,out] msg - Message will be written to this |
| 457 | * @return pldm_completion_codes |
| 458 | * @note Caller is responsible for memory alloc and dealloc of param |
| 459 | * 'msg.payload' |
| 460 | */ |
| 461 | int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code, |
| 462 | uint8_t tid, struct pldm_msg *msg); |
| 463 | |
John Wang | 7f02d70 | 2019-12-03 13:38:14 +0800 | [diff] [blame] | 464 | /** @brief Create a PLDM response message containing only cc |
| 465 | * |
| 466 | * @param[in] instance_id - Message's instance id |
| 467 | * @param[in] type - PLDM Type |
| 468 | * @param[in] command - PLDM Command |
| 469 | * @param[in] cc - PLDM Completion Code |
| 470 | * @param[out] msg - Message will be written to this |
| 471 | * @return pldm_completion_codes |
| 472 | */ |
| 473 | int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command, |
| 474 | uint8_t cc, struct pldm_msg *msg); |
| 475 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 476 | #ifdef __cplusplus |
| 477 | } |
| 478 | #endif |
| 479 | |
| 480 | #endif /* BASE_H */ |