blob: 99fd6afbb6b86ab6a1d3dd0cbe62acfae488d8df [file] [log] [blame]
Deepak Kodihalli1b24f972019-02-01 04:09:13 -06001#ifndef BASE_H
2#define BASE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <asm/byteorder.h>
9#include <stddef.h>
10#include <stdint.h>
11
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -060012#include "pldm_types.h"
13
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060014/** @brief PLDM Types
15 */
16enum pldm_supported_types {
17 PLDM_BASE = 0x00,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050018 PLDM_PLATFORM = 0x02,
Sampa Misra032bd502019-03-06 05:03:22 -060019 PLDM_BIOS = 0x03,
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053020 PLDM_FRU = 0x04,
gokulsanker138ceba2021-04-05 13:25:25 +053021 PLDM_FWUP = 0x05,
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050022 PLDM_OEM = 0x3F,
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060023};
24
25/** @brief PLDM Commands
26 */
27enum pldm_supported_commands {
John Wang5c4f80d2019-07-29 11:12:18 +080028 PLDM_GET_TID = 0x2,
Sampa Misra432e1872019-02-13 03:49:43 -060029 PLDM_GET_PLDM_VERSION = 0x3,
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060030 PLDM_GET_PLDM_TYPES = 0x4,
31 PLDM_GET_PLDM_COMMANDS = 0x5
32};
33
34/** @brief PLDM base codes
35 */
36enum pldm_completion_codes {
37 PLDM_SUCCESS = 0x00,
38 PLDM_ERROR = 0x01,
39 PLDM_ERROR_INVALID_DATA = 0x02,
40 PLDM_ERROR_INVALID_LENGTH = 0x03,
41 PLDM_ERROR_NOT_READY = 0x04,
42 PLDM_ERROR_UNSUPPORTED_PLDM_CMD = 0x05,
gokulsanker1b909d82021-04-05 17:26:02 +053043 PLDM_ERROR_INVALID_PLDM_TYPE = 0x20,
44 PLDM_INVALID_TRANSFER_OPERATION_FLAG = 0x21
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060045};
46
Sampa Misra432e1872019-02-13 03:49:43 -060047enum transfer_op_flag {
48 PLDM_GET_NEXTPART = 0,
49 PLDM_GET_FIRSTPART = 1,
50};
51
52enum transfer_resp_flag {
53 PLDM_START = 0x01,
54 PLDM_MIDDLE = 0x02,
55 PLDM_END = 0x04,
56 PLDM_START_AND_END = 0x05,
57};
58
Sagar Srinivas535bccd2021-03-24 12:18:26 -050059/** @brief PLDM transport protocol type
60 */
61enum pldm_transport_protocol_type {
62 PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP = 0x00,
63 PLDM_TRANSPORT_PROTOCOL_TYPE_OEM = 0xFF,
64};
65
Tom Joseph41251042019-02-07 16:17:07 +053066/** @enum MessageType
67 *
68 * The different message types supported by the PLDM specification.
69 */
70typedef enum {
71 PLDM_RESPONSE, //!< PLDM response
72 PLDM_REQUEST, //!< PLDM request
73 PLDM_RESERVED, //!< Reserved
74 PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages
75} MessageType;
76
77#define PLDM_INSTANCE_MAX 31
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060078#define PLDM_MAX_TYPES 64
79#define PLDM_MAX_CMDS_PER_TYPE 256
80
81/* Message payload lengths */
82#define PLDM_GET_COMMANDS_REQ_BYTES 5
Sampa Misra432e1872019-02-13 03:49:43 -060083#define PLDM_GET_VERSION_REQ_BYTES 6
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060084
85/* Response lengths are inclusive of completion code */
86#define PLDM_GET_TYPES_RESP_BYTES 9
John Wang5c4f80d2019-07-29 11:12:18 +080087#define PLDM_GET_TID_RESP_BYTES 2
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060088#define PLDM_GET_COMMANDS_RESP_BYTES 33
Sampa Misra432e1872019-02-13 03:49:43 -060089/* Response data has only one version and does not contain the checksum */
90#define PLDM_GET_VERSION_RESP_BYTES 10
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060091
Christian Geddes6c146f12020-05-01 14:48:23 -050092#define PLDM_VERSION_0 0
93#define PLDM_CURRENT_VERSION PLDM_VERSION_0
94
Tom Joseph568e4702021-06-07 22:15:49 -070095#define PLDM_TIMESTAMP104_SIZE 13
96
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060097/** @struct pldm_msg_hdr
98 *
99 * Structure representing PLDM message header fields
100 */
101struct pldm_msg_hdr {
102#if defined(__LITTLE_ENDIAN_BITFIELD)
103 uint8_t instance_id : 5; //!< Instance ID
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500104 uint8_t reserved : 1; //!< Reserved
105 uint8_t datagram : 1; //!< Datagram bit
106 uint8_t request : 1; //!< Request bit
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600107#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500108 uint8_t request : 1; //!< Request bit
109 uint8_t datagram : 1; //!< Datagram bit
110 uint8_t reserved : 1; //!< Reserved
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600111 uint8_t instance_id : 5; //!< Instance ID
112#endif
113
114#if defined(__LITTLE_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500115 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600116 uint8_t header_ver : 2; //!< Header version
117#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500118 uint8_t header_ver : 2; //!< Header version
119 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600120#endif
121 uint8_t command; //!< PLDM command code
122} __attribute__((packed));
123
Zach Clarkb728eee2020-06-18 10:01:31 -0500124// Macros for byte-swapping variables in-place
125#define HTOLE32(X) (X = htole32(X))
126#define HTOLE16(X) (X = htole16(X))
George Liucae18662020-05-15 09:32:57 +0800127#define LE32TOH(X) (X = le32toh(X))
128#define LE16TOH(X) (X = le16toh(X))
Zach Clarkb728eee2020-06-18 10:01:31 -0500129
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600130/** @struct pldm_msg
131 *
132 * Structure representing PLDM message
133 */
134struct pldm_msg {
vkaverapa6575b82019-04-03 05:33:52 -0500135 struct pldm_msg_hdr hdr; //!< PLDM message header
136 uint8_t payload[1]; //!< &payload[0] is the beginning of the payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600137} __attribute__((packed));
138
Tom Joseph41251042019-02-07 16:17:07 +0530139/** @struct pldm_header_info
140 *
141 * The information needed to prepare PLDM header and this is passed to the
142 * pack_pldm_header and unpack_pldm_header API.
143 */
144struct pldm_header_info {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500145 MessageType msg_type; //!< PLDM message type
146 uint8_t instance; //!< PLDM instance id
147 uint8_t pldm_type; //!< PLDM type
Tom Joseph41251042019-02-07 16:17:07 +0530148 uint8_t command; //!< PLDM command code
149 uint8_t completion_code; //!< PLDM completion code, applies for response
150};
151
Priyanga4b790ce2019-06-10 01:30:09 -0500152/** @struct pldm_get_types_resp
153 *
154 * Structure representing PLDM get types response.
155 */
156struct pldm_get_types_resp {
157 uint8_t completion_code; //!< completion code
158 bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type
159 //!< is supported
160} __attribute__((packed));
161
162/** @struct pldm_get_commands_req
163 *
164 * Structure representing PLDM get commands request.
165 */
166struct pldm_get_commands_req {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500167 uint8_t type; //!< PLDM Type for which command support information is
Priyanga4b790ce2019-06-10 01:30:09 -0500168 //!< being requested
169 ver32_t version; //!< version for the specified PLDM Type
170} __attribute__((packed));
171
172/** @struct pldm_get_commands_resp
173 *
174 * Structure representing PLDM get commands response.
175 */
176struct pldm_get_commands_resp {
177 uint8_t completion_code; //!< completion code
178 bitfield8_t commands[32]; //!< each bit represents whether a given PLDM
179 //!< command is supported
180} __attribute__((packed));
181
182/** @struct pldm_get_version_req
183 *
184 * Structure representing PLDM get version request.
185 */
186struct pldm_get_version_req {
187 uint32_t
188 transfer_handle; //!< handle to identify PLDM version data transfer
189 uint8_t transfer_opflag; //!< PLDM GetVersion operation flag
190 uint8_t type; //!< PLDM Type for which version information is being
191 //!< requested
192} __attribute__((packed));
193
194/** @struct pldm_get_version_resp
195 *
196 * Structure representing PLDM get version response.
197 */
198
199struct pldm_get_version_resp {
200 uint8_t completion_code; //!< completion code
201 uint32_t next_transfer_handle; //!< next portion of PLDM version data
202 //!< transfer
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500203 uint8_t transfer_flag; //!< PLDM GetVersion transfer flag
Priyanga4b790ce2019-06-10 01:30:09 -0500204 uint8_t version_data[1]; //!< PLDM GetVersion version field
205} __attribute__((packed));
206
John Wang5c4f80d2019-07-29 11:12:18 +0800207/** @struct pldm_get_tid_resp
208 *
209 * Structure representing PLDM get tid response.
210 */
211
212struct pldm_get_tid_resp {
213 uint8_t completion_code; //!< completion code
214 uint8_t tid; //!< PLDM GetTID TID field
215} __attribute__((packed));
216
Tom Joseph41251042019-02-07 16:17:07 +0530217/**
218 * @brief Populate the PLDM message with the PLDM header.The caller of this API
219 * allocates buffer for the PLDM header when forming the PLDM message.
220 * The buffer is passed to this API to pack the PLDM header.
221 *
222 * @param[in] hdr - Pointer to the PLDM header information
223 * @param[out] msg - Pointer to PLDM message header
224 *
225 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500226 * @note Caller is responsible for alloc and dealloc of msg
227 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530228 */
George Liub7095ff2021-06-14 16:01:57 +0800229uint8_t pack_pldm_header(const struct pldm_header_info *hdr,
230 struct pldm_msg_hdr *msg);
Tom Joseph41251042019-02-07 16:17:07 +0530231
232/**
233 * @brief Unpack the PLDM header from the PLDM message.
234 *
235 * @param[in] msg - Pointer to the PLDM message header
236 * @param[out] hdr - Pointer to the PLDM header information
237 *
238 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500239 * @note Caller is responsible for alloc and dealloc of msg
240 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530241 */
George Liub7095ff2021-06-14 16:01:57 +0800242uint8_t unpack_pldm_header(const struct pldm_msg_hdr *msg,
243 struct pldm_header_info *hdr);
Tom Joseph41251042019-02-07 16:17:07 +0530244
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600245/* Requester */
246
247/* GetPLDMTypes */
248
249/** @brief Create a PLDM request message for GetPLDMTypes
250 *
251 * @param[in] instance_id - Message's instance id
252 * @param[in,out] msg - Message will be written to this
253 * @return pldm_completion_codes
254 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500255 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600256 */
257int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg);
258
259/** @brief Decode a GetPLDMTypes response message
260 *
George Liu684a7162019-12-06 15:10:52 +0800261 * Note:
262 * * If the return value is not PLDM_SUCCESS, it represents a
263 * transport layer error.
264 * * If the completion_code value is not PLDM_SUCCESS, it represents a
265 * protocol layer error and all the out-parameters are invalid.
266 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500267 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500268 * @param[in] payload_length - Length of response message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600269 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600270 * @param[out] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600271 * types (MAX_TYPES/8) = 8), as per DSP0240
272 * @return pldm_completion_codes
273 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500274int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600275 uint8_t *completion_code, bitfield8_t *types);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600276
277/* GetPLDMCommands */
278
279/** @brief Create a PLDM request message for GetPLDMCommands
280 *
281 * @param[in] instance_id - Message's instance id
282 * @param[in] type - PLDM Type
283 * @param[in] version - Version for PLDM Type
284 * @param[in,out] msg - Message will be written to this
285 * @return pldm_completion_codes
286 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500287 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600288 */
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600289int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version,
290 struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600291
292/** @brief Decode a GetPLDMCommands response message
293 *
George Liu684a7162019-12-06 15:10:52 +0800294 * Note:
295 * * If the return value is not PLDM_SUCCESS, it represents a
296 * transport layer error.
297 * * If the completion_code value is not PLDM_SUCCESS, it represents a
298 * protocol layer error and all the out-parameters are invalid.
299 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500300 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500301 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600302 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600303 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600304 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
305 * @return pldm_completion_codes
306 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500307int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600308 uint8_t *completion_code, bitfield8_t *commands);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600309
Sampa Misra432e1872019-02-13 03:49:43 -0600310/* GetPLDMVersion */
311
312/** @brief Create a PLDM request for GetPLDMVersion
313 *
314 * @param[in] instance_id - Message's instance id
315 * @param[in] transfer_handle - Handle to identify PLDM version data transfer.
316 * This handle is ignored by the responder when the
317 * transferop_flag is set to getFirstPart.
318 * @param[in] transfer_opflag - flag to indicate whether it is start of
319 * transfer
320 * @param[in] type - PLDM Type for which version is requested
321 * @param[in,out] msg - Message will be written to this
322 * @return pldm_completion_codes
323 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500324 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600325 */
326int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle,
327 uint8_t transfer_opflag, uint8_t type,
328 struct pldm_msg *msg);
329
330/** @brief Decode a GetPLDMVersion response message
331 *
George Liu684a7162019-12-06 15:10:52 +0800332 * Note:
333 * * If the return value is not PLDM_SUCCESS, it represents a
334 * transport layer error.
335 * * If the completion_code value is not PLDM_SUCCESS, it represents a
336 * protocol layer error and all the out-parameters are invalid.
337 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500338 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500339 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600340 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Sampa Misra432e1872019-02-13 03:49:43 -0600341 * @param[out] next_transfer_handle - the next handle for the next part of data
342 * @param[out] transfer_flag - flag to indicate the part of data
343 * @return pldm_completion_codes
344 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500345int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600346 uint8_t *completion_code,
Sampa Misra432e1872019-02-13 03:49:43 -0600347 uint32_t *next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600348 uint8_t *transfer_flag, ver32_t *version);
Sampa Misra432e1872019-02-13 03:49:43 -0600349
John Wang5c4f80d2019-07-29 11:12:18 +0800350/* GetTID */
351
352/** @brief Decode a GetTID response message
353 *
George Liu684a7162019-12-06 15:10:52 +0800354 * Note:
355 * * If the return value is not PLDM_SUCCESS, it represents a
356 * transport layer error.
357 * * If the completion_code value is not PLDM_SUCCESS, it represents a
358 * protocol layer error and all the out-parameters are invalid.
359 *
John Wang5c4f80d2019-07-29 11:12:18 +0800360 * @param[in] msg - Response message
361 * @param[in] payload_length - Length of response message payload
362 * @param[out] completion_code - Pointer to response msg's PLDM completion code
363 * @param[out] tid - Pointer to the terminus id
364 * @return pldm_completion_codes
365 */
366int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
367 uint8_t *completion_code, uint8_t *tid);
368
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600369/* Responder */
370
371/* GetPLDMTypes */
372
373/** @brief Create a PLDM response message for GetPLDMTypes
374 *
375 * @param[in] instance_id - Message's instance id
376 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600377 * @param[in] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600378 * types (MAX_TYPES/8) = 8), as per DSP0240
379 * @param[in,out] msg - Message will be written to this
380 * @return pldm_completion_codes
381 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500382 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600383 */
384int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600385 const bitfield8_t *types, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600386
387/* GetPLDMCommands */
388
389/** @brief Decode GetPLDMCommands' request data
390 *
vkaverapa6575b82019-04-03 05:33:52 -0500391 * @param[in] msg - Request message
392 * @param[in] payload_length - Length of request message payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600393 * @param[out] type - PLDM Type
394 * @param[out] version - Version for PLDM Type
395 * @return pldm_completion_codes
396 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500397int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length,
vkaverapa6575b82019-04-03 05:33:52 -0500398 uint8_t *type, ver32_t *version);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600399
400/** @brief Create a PLDM response message for GetPLDMCommands
401 *
402 * @param[in] instance_id - Message's instance id
403 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600404 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600405 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
406 * @param[in,out] msg - Message will be written to this
407 * @return pldm_completion_codes
408 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500409 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600410 */
411int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600412 const bitfield8_t *commands, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600413
Sampa Misra432e1872019-02-13 03:49:43 -0600414/* GetPLDMVersion */
415
416/** @brief Create a PLDM response for GetPLDMVersion
417 *
418 * @param[in] instance_id - Message's instance id
419 * @param[in] completion_code - PLDM completion code
420 * @param[in] next_transfer_handle - Handle to identify next portion of
421 * data transfer
422 * @param[in] transfer_flag - Represents the part of transfer
423 * @param[in] version_data - the version data
424 * @param[in] version_size - size of version data
425 * @param[in,out] msg - Message will be written to this
426 * @return pldm_completion_codes
427 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500428 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600429 */
430int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code,
431 uint32_t next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600432 uint8_t transfer_flag, const ver32_t *version_data,
Sampa Misra432e1872019-02-13 03:49:43 -0600433 size_t version_size, struct pldm_msg *msg);
434
435/** @brief Decode a GetPLDMVersion request message
436 *
vkaverapa6575b82019-04-03 05:33:52 -0500437 * @param[in] msg - Request message
438 * @param[in] payload_length - length of request message payload
Sampa Misra432e1872019-02-13 03:49:43 -0600439 * @param[out] transfer_handle - the handle of data
440 * @param[out] transfer_opflag - Transfer Flag
441 * @param[out] type - PLDM type for which version is requested
442 * @return pldm_completion_codes
443 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500444int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra432e1872019-02-13 03:49:43 -0600445 uint32_t *transfer_handle, uint8_t *transfer_opflag,
446 uint8_t *type);
447
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600448/* Requester */
449
John Wang5c4f80d2019-07-29 11:12:18 +0800450/* GetTID */
451
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600452/** @brief Create a PLDM request message for GetTID
453 *
454 * @param[in] instance_id - Message's instance id
455 * @param[in,out] msg - Message will be written to this
456 * @return pldm_completion_codes
457 * @note Caller is responsible for memory alloc and dealloc of param
458 * 'msg.payload'
459 */
460int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg);
461
John Wang5c4f80d2019-07-29 11:12:18 +0800462/** @brief Create a PLDM response message for GetTID
463 *
464 * @param[in] instance_id - Message's instance id
465 * @param[in] completion_code - PLDM completion code
466 * @param[in] tid - Terminus ID
467 * @param[in,out] msg - Message will be written to this
468 * @return pldm_completion_codes
469 * @note Caller is responsible for memory alloc and dealloc of param
470 * 'msg.payload'
471 */
472int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
473 uint8_t tid, struct pldm_msg *msg);
474
John Wang7f02d702019-12-03 13:38:14 +0800475/** @brief Create a PLDM response message containing only cc
476 *
477 * @param[in] instance_id - Message's instance id
478 * @param[in] type - PLDM Type
479 * @param[in] command - PLDM Command
480 * @param[in] cc - PLDM Completion Code
481 * @param[out] msg - Message will be written to this
482 * @return pldm_completion_codes
483 */
484int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
485 uint8_t cc, struct pldm_msg *msg);
486
gokulsanker138ceba2021-04-05 13:25:25 +0530487/** @brief Create a PLDM message only with the header
488 *
489 * @param[in] msg_type - PLDM message type
490 * @param[in] instance_id - Message's instance id
491 * @param[in] pldm_type - PLDM Type
492 * @param[in] command - PLDM Command
493 * @param[out] msg - Message will be written to this
494 *
495 * @return pldm_completion_codes
496 */
497int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id,
498 uint8_t pldm_type, uint8_t command,
499 struct pldm_msg *msg);
gokulsankerfc370e92021-04-27 12:57:47 +0530500
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600501#ifdef __cplusplus
502}
503#endif
504
505#endif /* BASE_H */