blob: 4813ee6c7fd22c355be909bcfa635068be586860 [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,
Jinu Joy Thomasf666db12019-05-29 05:22:31 -050021 PLDM_OEM = 0x3F,
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060022};
23
24/** @brief PLDM Commands
25 */
26enum pldm_supported_commands {
John Wang5c4f80d2019-07-29 11:12:18 +080027 PLDM_GET_TID = 0x2,
Sampa Misra432e1872019-02-13 03:49:43 -060028 PLDM_GET_PLDM_VERSION = 0x3,
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060029 PLDM_GET_PLDM_TYPES = 0x4,
30 PLDM_GET_PLDM_COMMANDS = 0x5
31};
32
33/** @brief PLDM base codes
34 */
35enum 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 Misra432e1872019-02-13 03:49:43 -060045enum transfer_op_flag {
46 PLDM_GET_NEXTPART = 0,
47 PLDM_GET_FIRSTPART = 1,
48};
49
50enum transfer_resp_flag {
51 PLDM_START = 0x01,
52 PLDM_MIDDLE = 0x02,
53 PLDM_END = 0x04,
54 PLDM_START_AND_END = 0x05,
55};
56
Sagar Srinivas535bccd2021-03-24 12:18:26 -050057/** @brief PLDM transport protocol type
58 */
59enum pldm_transport_protocol_type {
60 PLDM_TRANSPORT_PROTOCOL_TYPE_MCTP = 0x00,
61 PLDM_TRANSPORT_PROTOCOL_TYPE_OEM = 0xFF,
62};
63
Tom Joseph41251042019-02-07 16:17:07 +053064/** @enum MessageType
65 *
66 * The different message types supported by the PLDM specification.
67 */
68typedef enum {
69 PLDM_RESPONSE, //!< PLDM response
70 PLDM_REQUEST, //!< PLDM request
71 PLDM_RESERVED, //!< Reserved
72 PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages
73} MessageType;
74
75#define PLDM_INSTANCE_MAX 31
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060076#define PLDM_MAX_TYPES 64
77#define PLDM_MAX_CMDS_PER_TYPE 256
78
79/* Message payload lengths */
80#define PLDM_GET_COMMANDS_REQ_BYTES 5
Sampa Misra432e1872019-02-13 03:49:43 -060081#define PLDM_GET_VERSION_REQ_BYTES 6
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060082
83/* Response lengths are inclusive of completion code */
84#define PLDM_GET_TYPES_RESP_BYTES 9
John Wang5c4f80d2019-07-29 11:12:18 +080085#define PLDM_GET_TID_RESP_BYTES 2
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060086#define PLDM_GET_COMMANDS_RESP_BYTES 33
Sampa Misra432e1872019-02-13 03:49:43 -060087/* Response data has only one version and does not contain the checksum */
88#define PLDM_GET_VERSION_RESP_BYTES 10
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060089
Christian Geddes6c146f12020-05-01 14:48:23 -050090#define PLDM_VERSION_0 0
91#define PLDM_CURRENT_VERSION PLDM_VERSION_0
92
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060093/** @struct pldm_msg_hdr
94 *
95 * Structure representing PLDM message header fields
96 */
97struct pldm_msg_hdr {
98#if defined(__LITTLE_ENDIAN_BITFIELD)
99 uint8_t instance_id : 5; //!< Instance ID
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500100 uint8_t reserved : 1; //!< Reserved
101 uint8_t datagram : 1; //!< Datagram bit
102 uint8_t request : 1; //!< Request bit
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600103#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500104 uint8_t request : 1; //!< Request bit
105 uint8_t datagram : 1; //!< Datagram bit
106 uint8_t reserved : 1; //!< Reserved
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600107 uint8_t instance_id : 5; //!< Instance ID
108#endif
109
110#if defined(__LITTLE_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500111 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600112 uint8_t header_ver : 2; //!< Header version
113#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500114 uint8_t header_ver : 2; //!< Header version
115 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600116#endif
117 uint8_t command; //!< PLDM command code
118} __attribute__((packed));
119
Zach Clarkb728eee2020-06-18 10:01:31 -0500120// Macros for byte-swapping variables in-place
121#define HTOLE32(X) (X = htole32(X))
122#define HTOLE16(X) (X = htole16(X))
George Liucae18662020-05-15 09:32:57 +0800123#define LE32TOH(X) (X = le32toh(X))
124#define LE16TOH(X) (X = le16toh(X))
Zach Clarkb728eee2020-06-18 10:01:31 -0500125
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600126/** @struct pldm_msg
127 *
128 * Structure representing PLDM message
129 */
130struct pldm_msg {
vkaverapa6575b82019-04-03 05:33:52 -0500131 struct pldm_msg_hdr hdr; //!< PLDM message header
132 uint8_t payload[1]; //!< &payload[0] is the beginning of the payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600133} __attribute__((packed));
134
Tom Joseph41251042019-02-07 16:17:07 +0530135/** @struct pldm_header_info
136 *
137 * The information needed to prepare PLDM header and this is passed to the
138 * pack_pldm_header and unpack_pldm_header API.
139 */
140struct pldm_header_info {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500141 MessageType msg_type; //!< PLDM message type
142 uint8_t instance; //!< PLDM instance id
143 uint8_t pldm_type; //!< PLDM type
Tom Joseph41251042019-02-07 16:17:07 +0530144 uint8_t command; //!< PLDM command code
145 uint8_t completion_code; //!< PLDM completion code, applies for response
146};
147
Priyanga4b790ce2019-06-10 01:30:09 -0500148/** @struct pldm_get_types_resp
149 *
150 * Structure representing PLDM get types response.
151 */
152struct pldm_get_types_resp {
153 uint8_t completion_code; //!< completion code
154 bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type
155 //!< is supported
156} __attribute__((packed));
157
158/** @struct pldm_get_commands_req
159 *
160 * Structure representing PLDM get commands request.
161 */
162struct pldm_get_commands_req {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500163 uint8_t type; //!< PLDM Type for which command support information is
Priyanga4b790ce2019-06-10 01:30:09 -0500164 //!< being requested
165 ver32_t version; //!< version for the specified PLDM Type
166} __attribute__((packed));
167
168/** @struct pldm_get_commands_resp
169 *
170 * Structure representing PLDM get commands response.
171 */
172struct pldm_get_commands_resp {
173 uint8_t completion_code; //!< completion code
174 bitfield8_t commands[32]; //!< each bit represents whether a given PLDM
175 //!< command is supported
176} __attribute__((packed));
177
178/** @struct pldm_get_version_req
179 *
180 * Structure representing PLDM get version request.
181 */
182struct pldm_get_version_req {
183 uint32_t
184 transfer_handle; //!< handle to identify PLDM version data transfer
185 uint8_t transfer_opflag; //!< PLDM GetVersion operation flag
186 uint8_t type; //!< PLDM Type for which version information is being
187 //!< requested
188} __attribute__((packed));
189
190/** @struct pldm_get_version_resp
191 *
192 * Structure representing PLDM get version response.
193 */
194
195struct pldm_get_version_resp {
196 uint8_t completion_code; //!< completion code
197 uint32_t next_transfer_handle; //!< next portion of PLDM version data
198 //!< transfer
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500199 uint8_t transfer_flag; //!< PLDM GetVersion transfer flag
Priyanga4b790ce2019-06-10 01:30:09 -0500200 uint8_t version_data[1]; //!< PLDM GetVersion version field
201} __attribute__((packed));
202
John Wang5c4f80d2019-07-29 11:12:18 +0800203/** @struct pldm_get_tid_resp
204 *
205 * Structure representing PLDM get tid response.
206 */
207
208struct pldm_get_tid_resp {
209 uint8_t completion_code; //!< completion code
210 uint8_t tid; //!< PLDM GetTID TID field
211} __attribute__((packed));
212
Tom Joseph41251042019-02-07 16:17:07 +0530213/**
214 * @brief Populate the PLDM message with the PLDM header.The caller of this API
215 * allocates buffer for the PLDM header when forming the PLDM message.
216 * The buffer is passed to this API to pack the PLDM header.
217 *
218 * @param[in] hdr - Pointer to the PLDM header information
219 * @param[out] msg - Pointer to PLDM message header
220 *
221 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500222 * @note Caller is responsible for alloc and dealloc of msg
223 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530224 */
225int pack_pldm_header(const struct pldm_header_info *hdr,
226 struct pldm_msg_hdr *msg);
227
228/**
229 * @brief Unpack the PLDM header from the PLDM message.
230 *
231 * @param[in] msg - Pointer to the PLDM message header
232 * @param[out] hdr - Pointer to the PLDM header information
233 *
234 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500235 * @note Caller is responsible for alloc and dealloc of msg
236 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530237 */
238int unpack_pldm_header(const struct pldm_msg_hdr *msg,
239 struct pldm_header_info *hdr);
240
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600241/* Requester */
242
243/* GetPLDMTypes */
244
245/** @brief Create a PLDM request message for GetPLDMTypes
246 *
247 * @param[in] instance_id - Message's instance id
248 * @param[in,out] msg - Message will be written to this
249 * @return pldm_completion_codes
250 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500251 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600252 */
253int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg);
254
255/** @brief Decode a GetPLDMTypes response message
256 *
George Liu684a7162019-12-06 15:10:52 +0800257 * Note:
258 * * If the return value is not PLDM_SUCCESS, it represents a
259 * transport layer error.
260 * * If the completion_code value is not PLDM_SUCCESS, it represents a
261 * protocol layer error and all the out-parameters are invalid.
262 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500263 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500264 * @param[in] payload_length - Length of response message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600265 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600266 * @param[out] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600267 * types (MAX_TYPES/8) = 8), as per DSP0240
268 * @return pldm_completion_codes
269 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500270int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600271 uint8_t *completion_code, bitfield8_t *types);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600272
273/* GetPLDMCommands */
274
275/** @brief Create a PLDM request message for GetPLDMCommands
276 *
277 * @param[in] instance_id - Message's instance id
278 * @param[in] type - PLDM Type
279 * @param[in] version - Version for PLDM Type
280 * @param[in,out] msg - Message will be written to this
281 * @return pldm_completion_codes
282 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500283 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600284 */
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600285int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version,
286 struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600287
288/** @brief Decode a GetPLDMCommands response message
289 *
George Liu684a7162019-12-06 15:10:52 +0800290 * Note:
291 * * If the return value is not PLDM_SUCCESS, it represents a
292 * transport layer error.
293 * * If the completion_code value is not PLDM_SUCCESS, it represents a
294 * protocol layer error and all the out-parameters are invalid.
295 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500296 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500297 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600298 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600299 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600300 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
301 * @return pldm_completion_codes
302 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500303int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600304 uint8_t *completion_code, bitfield8_t *commands);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600305
Sampa Misra432e1872019-02-13 03:49:43 -0600306/* GetPLDMVersion */
307
308/** @brief Create a PLDM request for GetPLDMVersion
309 *
310 * @param[in] instance_id - Message's instance id
311 * @param[in] transfer_handle - Handle to identify PLDM version data transfer.
312 * This handle is ignored by the responder when the
313 * transferop_flag is set to getFirstPart.
314 * @param[in] transfer_opflag - flag to indicate whether it is start of
315 * transfer
316 * @param[in] type - PLDM Type for which version is requested
317 * @param[in,out] msg - Message will be written to this
318 * @return pldm_completion_codes
319 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500320 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600321 */
322int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle,
323 uint8_t transfer_opflag, uint8_t type,
324 struct pldm_msg *msg);
325
326/** @brief Decode a GetPLDMVersion response message
327 *
George Liu684a7162019-12-06 15:10:52 +0800328 * Note:
329 * * If the return value is not PLDM_SUCCESS, it represents a
330 * transport layer error.
331 * * If the completion_code value is not PLDM_SUCCESS, it represents a
332 * protocol layer error and all the out-parameters are invalid.
333 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500334 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500335 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600336 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Sampa Misra432e1872019-02-13 03:49:43 -0600337 * @param[out] next_transfer_handle - the next handle for the next part of data
338 * @param[out] transfer_flag - flag to indicate the part of data
339 * @return pldm_completion_codes
340 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500341int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600342 uint8_t *completion_code,
Sampa Misra432e1872019-02-13 03:49:43 -0600343 uint32_t *next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600344 uint8_t *transfer_flag, ver32_t *version);
Sampa Misra432e1872019-02-13 03:49:43 -0600345
John Wang5c4f80d2019-07-29 11:12:18 +0800346/* GetTID */
347
348/** @brief Decode a GetTID response message
349 *
George Liu684a7162019-12-06 15:10:52 +0800350 * Note:
351 * * If the return value is not PLDM_SUCCESS, it represents a
352 * transport layer error.
353 * * If the completion_code value is not PLDM_SUCCESS, it represents a
354 * protocol layer error and all the out-parameters are invalid.
355 *
John Wang5c4f80d2019-07-29 11:12:18 +0800356 * @param[in] msg - Response message
357 * @param[in] payload_length - Length of response message payload
358 * @param[out] completion_code - Pointer to response msg's PLDM completion code
359 * @param[out] tid - Pointer to the terminus id
360 * @return pldm_completion_codes
361 */
362int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
363 uint8_t *completion_code, uint8_t *tid);
364
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600365/* Responder */
366
367/* GetPLDMTypes */
368
369/** @brief Create a PLDM response message for GetPLDMTypes
370 *
371 * @param[in] instance_id - Message's instance id
372 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600373 * @param[in] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600374 * types (MAX_TYPES/8) = 8), as per DSP0240
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
vkaverapa6575b82019-04-03 05:33:52 -0500378 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600379 */
380int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600381 const bitfield8_t *types, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600382
383/* GetPLDMCommands */
384
385/** @brief Decode GetPLDMCommands' request data
386 *
vkaverapa6575b82019-04-03 05:33:52 -0500387 * @param[in] msg - Request message
388 * @param[in] payload_length - Length of request message payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600389 * @param[out] type - PLDM Type
390 * @param[out] version - Version for PLDM Type
391 * @return pldm_completion_codes
392 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500393int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length,
vkaverapa6575b82019-04-03 05:33:52 -0500394 uint8_t *type, ver32_t *version);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600395
396/** @brief Create a PLDM response message for GetPLDMCommands
397 *
398 * @param[in] instance_id - Message's instance id
399 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600400 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600401 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
402 * @param[in,out] msg - Message will be written to this
403 * @return pldm_completion_codes
404 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500405 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600406 */
407int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600408 const bitfield8_t *commands, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600409
Sampa Misra432e1872019-02-13 03:49:43 -0600410/* GetPLDMVersion */
411
412/** @brief Create a PLDM response for GetPLDMVersion
413 *
414 * @param[in] instance_id - Message's instance id
415 * @param[in] completion_code - PLDM completion code
416 * @param[in] next_transfer_handle - Handle to identify next portion of
417 * data transfer
418 * @param[in] transfer_flag - Represents the part of transfer
419 * @param[in] version_data - the version data
420 * @param[in] version_size - size of version data
421 * @param[in,out] msg - Message will be written to this
422 * @return pldm_completion_codes
423 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500424 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600425 */
426int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code,
427 uint32_t next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600428 uint8_t transfer_flag, const ver32_t *version_data,
Sampa Misra432e1872019-02-13 03:49:43 -0600429 size_t version_size, struct pldm_msg *msg);
430
431/** @brief Decode a GetPLDMVersion request message
432 *
vkaverapa6575b82019-04-03 05:33:52 -0500433 * @param[in] msg - Request message
434 * @param[in] payload_length - length of request message payload
Sampa Misra432e1872019-02-13 03:49:43 -0600435 * @param[out] transfer_handle - the handle of data
436 * @param[out] transfer_opflag - Transfer Flag
437 * @param[out] type - PLDM type for which version is requested
438 * @return pldm_completion_codes
439 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500440int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra432e1872019-02-13 03:49:43 -0600441 uint32_t *transfer_handle, uint8_t *transfer_opflag,
442 uint8_t *type);
443
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600444/* Requester */
445
John Wang5c4f80d2019-07-29 11:12:18 +0800446/* GetTID */
447
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600448/** @brief Create a PLDM request message for GetTID
449 *
450 * @param[in] instance_id - Message's instance id
451 * @param[in,out] msg - Message will be written to this
452 * @return pldm_completion_codes
453 * @note Caller is responsible for memory alloc and dealloc of param
454 * 'msg.payload'
455 */
456int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg);
457
John Wang5c4f80d2019-07-29 11:12:18 +0800458/** @brief Create a PLDM response message for GetTID
459 *
460 * @param[in] instance_id - Message's instance id
461 * @param[in] completion_code - PLDM completion code
462 * @param[in] tid - Terminus ID
463 * @param[in,out] msg - Message will be written to this
464 * @return pldm_completion_codes
465 * @note Caller is responsible for memory alloc and dealloc of param
466 * 'msg.payload'
467 */
468int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
469 uint8_t tid, struct pldm_msg *msg);
470
John Wang7f02d702019-12-03 13:38:14 +0800471/** @brief Create a PLDM response message containing only cc
472 *
473 * @param[in] instance_id - Message's instance id
474 * @param[in] type - PLDM Type
475 * @param[in] command - PLDM Command
476 * @param[in] cc - PLDM Completion Code
477 * @param[out] msg - Message will be written to this
478 * @return pldm_completion_codes
479 */
480int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
481 uint8_t cc, struct pldm_msg *msg);
482
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600483#ifdef __cplusplus
484}
485#endif
486
487#endif /* BASE_H */