blob: 8644a5ae7e558a828484a50306e464f06fcba7fc [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,
43 PLDM_ERROR_INVALID_PLDM_TYPE = 0x20
44};
45
Sampa Misra432e1872019-02-13 03:49:43 -060046enum transfer_op_flag {
47 PLDM_GET_NEXTPART = 0,
48 PLDM_GET_FIRSTPART = 1,
49};
50
51enum transfer_resp_flag {
52 PLDM_START = 0x01,
53 PLDM_MIDDLE = 0x02,
54 PLDM_END = 0x04,
55 PLDM_START_AND_END = 0x05,
56};
57
Sagar Srinivas535bccd2021-03-24 12:18:26 -050058/** @brief PLDM transport protocol type
59 */
60enum pldm_transport_protocol_type {
61 PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP = 0x00,
62 PLDM_TRANSPORT_PROTOCOL_TYPE_OEM = 0xFF,
63};
64
Tom Joseph41251042019-02-07 16:17:07 +053065/** @enum MessageType
66 *
67 * The different message types supported by the PLDM specification.
68 */
69typedef enum {
70 PLDM_RESPONSE, //!< PLDM response
71 PLDM_REQUEST, //!< PLDM request
72 PLDM_RESERVED, //!< Reserved
73 PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages
74} MessageType;
75
76#define PLDM_INSTANCE_MAX 31
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060077#define PLDM_MAX_TYPES 64
78#define PLDM_MAX_CMDS_PER_TYPE 256
79
80/* Message payload lengths */
81#define PLDM_GET_COMMANDS_REQ_BYTES 5
Sampa Misra432e1872019-02-13 03:49:43 -060082#define PLDM_GET_VERSION_REQ_BYTES 6
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060083
84/* Response lengths are inclusive of completion code */
85#define PLDM_GET_TYPES_RESP_BYTES 9
John Wang5c4f80d2019-07-29 11:12:18 +080086#define PLDM_GET_TID_RESP_BYTES 2
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060087#define PLDM_GET_COMMANDS_RESP_BYTES 33
Sampa Misra432e1872019-02-13 03:49:43 -060088/* Response data has only one version and does not contain the checksum */
89#define PLDM_GET_VERSION_RESP_BYTES 10
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060090
Christian Geddes6c146f12020-05-01 14:48:23 -050091#define PLDM_VERSION_0 0
92#define PLDM_CURRENT_VERSION PLDM_VERSION_0
93
Tom Joseph568e4702021-06-07 22:15:49 -070094#define PLDM_TIMESTAMP104_SIZE 13
95
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060096/** @struct pldm_msg_hdr
97 *
98 * Structure representing PLDM message header fields
99 */
100struct pldm_msg_hdr {
101#if defined(__LITTLE_ENDIAN_BITFIELD)
102 uint8_t instance_id : 5; //!< Instance ID
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500103 uint8_t reserved : 1; //!< Reserved
104 uint8_t datagram : 1; //!< Datagram bit
105 uint8_t request : 1; //!< Request bit
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600106#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500107 uint8_t request : 1; //!< Request bit
108 uint8_t datagram : 1; //!< Datagram bit
109 uint8_t reserved : 1; //!< Reserved
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600110 uint8_t instance_id : 5; //!< Instance ID
111#endif
112
113#if defined(__LITTLE_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500114 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600115 uint8_t header_ver : 2; //!< Header version
116#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500117 uint8_t header_ver : 2; //!< Header version
118 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600119#endif
120 uint8_t command; //!< PLDM command code
121} __attribute__((packed));
122
Zach Clarkb728eee2020-06-18 10:01:31 -0500123// Macros for byte-swapping variables in-place
124#define HTOLE32(X) (X = htole32(X))
125#define HTOLE16(X) (X = htole16(X))
George Liucae18662020-05-15 09:32:57 +0800126#define LE32TOH(X) (X = le32toh(X))
127#define LE16TOH(X) (X = le16toh(X))
Zach Clarkb728eee2020-06-18 10:01:31 -0500128
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600129/** @struct pldm_msg
130 *
131 * Structure representing PLDM message
132 */
133struct pldm_msg {
vkaverapa6575b82019-04-03 05:33:52 -0500134 struct pldm_msg_hdr hdr; //!< PLDM message header
135 uint8_t payload[1]; //!< &payload[0] is the beginning of the payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600136} __attribute__((packed));
137
Tom Joseph41251042019-02-07 16:17:07 +0530138/** @struct pldm_header_info
139 *
140 * The information needed to prepare PLDM header and this is passed to the
141 * pack_pldm_header and unpack_pldm_header API.
142 */
143struct pldm_header_info {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500144 MessageType msg_type; //!< PLDM message type
145 uint8_t instance; //!< PLDM instance id
146 uint8_t pldm_type; //!< PLDM type
Tom Joseph41251042019-02-07 16:17:07 +0530147 uint8_t command; //!< PLDM command code
148 uint8_t completion_code; //!< PLDM completion code, applies for response
149};
150
Priyanga4b790ce2019-06-10 01:30:09 -0500151/** @struct pldm_get_types_resp
152 *
153 * Structure representing PLDM get types response.
154 */
155struct pldm_get_types_resp {
156 uint8_t completion_code; //!< completion code
157 bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type
158 //!< is supported
159} __attribute__((packed));
160
161/** @struct pldm_get_commands_req
162 *
163 * Structure representing PLDM get commands request.
164 */
165struct pldm_get_commands_req {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500166 uint8_t type; //!< PLDM Type for which command support information is
Priyanga4b790ce2019-06-10 01:30:09 -0500167 //!< being requested
168 ver32_t version; //!< version for the specified PLDM Type
169} __attribute__((packed));
170
171/** @struct pldm_get_commands_resp
172 *
173 * Structure representing PLDM get commands response.
174 */
175struct pldm_get_commands_resp {
176 uint8_t completion_code; //!< completion code
177 bitfield8_t commands[32]; //!< each bit represents whether a given PLDM
178 //!< command is supported
179} __attribute__((packed));
180
181/** @struct pldm_get_version_req
182 *
183 * Structure representing PLDM get version request.
184 */
185struct pldm_get_version_req {
186 uint32_t
187 transfer_handle; //!< handle to identify PLDM version data transfer
188 uint8_t transfer_opflag; //!< PLDM GetVersion operation flag
189 uint8_t type; //!< PLDM Type for which version information is being
190 //!< requested
191} __attribute__((packed));
192
193/** @struct pldm_get_version_resp
194 *
195 * Structure representing PLDM get version response.
196 */
197
198struct pldm_get_version_resp {
199 uint8_t completion_code; //!< completion code
200 uint32_t next_transfer_handle; //!< next portion of PLDM version data
201 //!< transfer
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500202 uint8_t transfer_flag; //!< PLDM GetVersion transfer flag
Priyanga4b790ce2019-06-10 01:30:09 -0500203 uint8_t version_data[1]; //!< PLDM GetVersion version field
204} __attribute__((packed));
205
John Wang5c4f80d2019-07-29 11:12:18 +0800206/** @struct pldm_get_tid_resp
207 *
208 * Structure representing PLDM get tid response.
209 */
210
211struct pldm_get_tid_resp {
212 uint8_t completion_code; //!< completion code
213 uint8_t tid; //!< PLDM GetTID TID field
214} __attribute__((packed));
215
Tom Joseph41251042019-02-07 16:17:07 +0530216/**
217 * @brief Populate the PLDM message with the PLDM header.The caller of this API
218 * allocates buffer for the PLDM header when forming the PLDM message.
219 * The buffer is passed to this API to pack the PLDM header.
220 *
221 * @param[in] hdr - Pointer to the PLDM header information
222 * @param[out] msg - Pointer to PLDM message header
223 *
224 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500225 * @note Caller is responsible for alloc and dealloc of msg
226 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530227 */
George Liub7095ff2021-06-14 16:01:57 +0800228uint8_t pack_pldm_header(const struct pldm_header_info *hdr,
229 struct pldm_msg_hdr *msg);
Tom Joseph41251042019-02-07 16:17:07 +0530230
231/**
232 * @brief Unpack the PLDM header from the PLDM message.
233 *
234 * @param[in] msg - Pointer to the PLDM message header
235 * @param[out] hdr - Pointer to the PLDM header information
236 *
237 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500238 * @note Caller is responsible for alloc and dealloc of msg
239 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530240 */
George Liub7095ff2021-06-14 16:01:57 +0800241uint8_t unpack_pldm_header(const struct pldm_msg_hdr *msg,
242 struct pldm_header_info *hdr);
Tom Joseph41251042019-02-07 16:17:07 +0530243
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600244/* Requester */
245
246/* GetPLDMTypes */
247
248/** @brief Create a PLDM request message for GetPLDMTypes
249 *
250 * @param[in] instance_id - Message's instance id
251 * @param[in,out] msg - Message will be written to this
252 * @return pldm_completion_codes
253 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500254 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600255 */
256int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg);
257
258/** @brief Decode a GetPLDMTypes response message
259 *
George Liu684a7162019-12-06 15:10:52 +0800260 * Note:
261 * * If the return value is not PLDM_SUCCESS, it represents a
262 * transport layer error.
263 * * If the completion_code value is not PLDM_SUCCESS, it represents a
264 * protocol layer error and all the out-parameters are invalid.
265 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500266 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500267 * @param[in] payload_length - Length of response message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600268 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600269 * @param[out] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600270 * types (MAX_TYPES/8) = 8), as per DSP0240
271 * @return pldm_completion_codes
272 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500273int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600274 uint8_t *completion_code, bitfield8_t *types);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600275
276/* GetPLDMCommands */
277
278/** @brief Create a PLDM request message for GetPLDMCommands
279 *
280 * @param[in] instance_id - Message's instance id
281 * @param[in] type - PLDM Type
282 * @param[in] version - Version for PLDM Type
283 * @param[in,out] msg - Message will be written to this
284 * @return pldm_completion_codes
285 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500286 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600287 */
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600288int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version,
289 struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600290
291/** @brief Decode a GetPLDMCommands response message
292 *
George Liu684a7162019-12-06 15:10:52 +0800293 * Note:
294 * * If the return value is not PLDM_SUCCESS, it represents a
295 * transport layer error.
296 * * If the completion_code value is not PLDM_SUCCESS, it represents a
297 * protocol layer error and all the out-parameters are invalid.
298 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500299 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500300 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600301 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600302 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600303 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
304 * @return pldm_completion_codes
305 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500306int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600307 uint8_t *completion_code, bitfield8_t *commands);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600308
Sampa Misra432e1872019-02-13 03:49:43 -0600309/* GetPLDMVersion */
310
311/** @brief Create a PLDM request for GetPLDMVersion
312 *
313 * @param[in] instance_id - Message's instance id
314 * @param[in] transfer_handle - Handle to identify PLDM version data transfer.
315 * This handle is ignored by the responder when the
316 * transferop_flag is set to getFirstPart.
317 * @param[in] transfer_opflag - flag to indicate whether it is start of
318 * transfer
319 * @param[in] type - PLDM Type for which version is requested
320 * @param[in,out] msg - Message will be written to this
321 * @return pldm_completion_codes
322 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500323 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600324 */
325int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle,
326 uint8_t transfer_opflag, uint8_t type,
327 struct pldm_msg *msg);
328
329/** @brief Decode a GetPLDMVersion response message
330 *
George Liu684a7162019-12-06 15:10:52 +0800331 * Note:
332 * * If the return value is not PLDM_SUCCESS, it represents a
333 * transport layer error.
334 * * If the completion_code value is not PLDM_SUCCESS, it represents a
335 * protocol layer error and all the out-parameters are invalid.
336 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500337 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500338 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600339 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Sampa Misra432e1872019-02-13 03:49:43 -0600340 * @param[out] next_transfer_handle - the next handle for the next part of data
341 * @param[out] transfer_flag - flag to indicate the part of data
342 * @return pldm_completion_codes
343 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500344int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600345 uint8_t *completion_code,
Sampa Misra432e1872019-02-13 03:49:43 -0600346 uint32_t *next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600347 uint8_t *transfer_flag, ver32_t *version);
Sampa Misra432e1872019-02-13 03:49:43 -0600348
John Wang5c4f80d2019-07-29 11:12:18 +0800349/* GetTID */
350
351/** @brief Decode a GetTID response message
352 *
George Liu684a7162019-12-06 15:10:52 +0800353 * Note:
354 * * If the return value is not PLDM_SUCCESS, it represents a
355 * transport layer error.
356 * * If the completion_code value is not PLDM_SUCCESS, it represents a
357 * protocol layer error and all the out-parameters are invalid.
358 *
John Wang5c4f80d2019-07-29 11:12:18 +0800359 * @param[in] msg - Response message
360 * @param[in] payload_length - Length of response message payload
361 * @param[out] completion_code - Pointer to response msg's PLDM completion code
362 * @param[out] tid - Pointer to the terminus id
363 * @return pldm_completion_codes
364 */
365int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
366 uint8_t *completion_code, uint8_t *tid);
367
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600368/* Responder */
369
370/* GetPLDMTypes */
371
372/** @brief Create a PLDM response message for GetPLDMTypes
373 *
374 * @param[in] instance_id - Message's instance id
375 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600376 * @param[in] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600377 * types (MAX_TYPES/8) = 8), as per DSP0240
378 * @param[in,out] msg - Message will be written to this
379 * @return pldm_completion_codes
380 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500381 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600382 */
383int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600384 const bitfield8_t *types, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600385
386/* GetPLDMCommands */
387
388/** @brief Decode GetPLDMCommands' request data
389 *
vkaverapa6575b82019-04-03 05:33:52 -0500390 * @param[in] msg - Request message
391 * @param[in] payload_length - Length of request message payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600392 * @param[out] type - PLDM Type
393 * @param[out] version - Version for PLDM Type
394 * @return pldm_completion_codes
395 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500396int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length,
vkaverapa6575b82019-04-03 05:33:52 -0500397 uint8_t *type, ver32_t *version);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600398
399/** @brief Create a PLDM response message for GetPLDMCommands
400 *
401 * @param[in] instance_id - Message's instance id
402 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600403 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600404 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
405 * @param[in,out] msg - Message will be written to this
406 * @return pldm_completion_codes
407 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500408 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600409 */
410int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600411 const bitfield8_t *commands, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600412
Sampa Misra432e1872019-02-13 03:49:43 -0600413/* GetPLDMVersion */
414
415/** @brief Create a PLDM response for GetPLDMVersion
416 *
417 * @param[in] instance_id - Message's instance id
418 * @param[in] completion_code - PLDM completion code
419 * @param[in] next_transfer_handle - Handle to identify next portion of
420 * data transfer
421 * @param[in] transfer_flag - Represents the part of transfer
422 * @param[in] version_data - the version data
423 * @param[in] version_size - size of version data
424 * @param[in,out] msg - Message will be written to this
425 * @return pldm_completion_codes
426 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500427 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600428 */
429int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code,
430 uint32_t next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600431 uint8_t transfer_flag, const ver32_t *version_data,
Sampa Misra432e1872019-02-13 03:49:43 -0600432 size_t version_size, struct pldm_msg *msg);
433
434/** @brief Decode a GetPLDMVersion request message
435 *
vkaverapa6575b82019-04-03 05:33:52 -0500436 * @param[in] msg - Request message
437 * @param[in] payload_length - length of request message payload
Sampa Misra432e1872019-02-13 03:49:43 -0600438 * @param[out] transfer_handle - the handle of data
439 * @param[out] transfer_opflag - Transfer Flag
440 * @param[out] type - PLDM type for which version is requested
441 * @return pldm_completion_codes
442 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500443int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra432e1872019-02-13 03:49:43 -0600444 uint32_t *transfer_handle, uint8_t *transfer_opflag,
445 uint8_t *type);
446
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600447/* Requester */
448
John Wang5c4f80d2019-07-29 11:12:18 +0800449/* GetTID */
450
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600451/** @brief Create a PLDM request message for GetTID
452 *
453 * @param[in] instance_id - Message's instance id
454 * @param[in,out] msg - Message will be written to this
455 * @return pldm_completion_codes
456 * @note Caller is responsible for memory alloc and dealloc of param
457 * 'msg.payload'
458 */
459int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg);
460
John Wang5c4f80d2019-07-29 11:12:18 +0800461/** @brief Create a PLDM response message for GetTID
462 *
463 * @param[in] instance_id - Message's instance id
464 * @param[in] completion_code - PLDM completion code
465 * @param[in] tid - Terminus ID
466 * @param[in,out] msg - Message will be written to this
467 * @return pldm_completion_codes
468 * @note Caller is responsible for memory alloc and dealloc of param
469 * 'msg.payload'
470 */
471int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
472 uint8_t tid, struct pldm_msg *msg);
473
John Wang7f02d702019-12-03 13:38:14 +0800474/** @brief Create a PLDM response message containing only cc
475 *
476 * @param[in] instance_id - Message's instance id
477 * @param[in] type - PLDM Type
478 * @param[in] command - PLDM Command
479 * @param[in] cc - PLDM Completion Code
480 * @param[out] msg - Message will be written to this
481 * @return pldm_completion_codes
482 */
483int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
484 uint8_t cc, struct pldm_msg *msg);
485
gokulsanker138ceba2021-04-05 13:25:25 +0530486/** @brief Create a PLDM message only with the header
487 *
488 * @param[in] msg_type - PLDM message type
489 * @param[in] instance_id - Message's instance id
490 * @param[in] pldm_type - PLDM Type
491 * @param[in] command - PLDM Command
492 * @param[out] msg - Message will be written to this
493 *
494 * @return pldm_completion_codes
495 */
496int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id,
497 uint8_t pldm_type, uint8_t command,
498 struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600499#ifdef __cplusplus
500}
501#endif
502
503#endif /* BASE_H */