blob: 5109c3450a7266c5f7cea7a8f59dccd3f7f2829a [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
Tom Joseph41251042019-02-07 16:17:07 +053057/** @enum MessageType
58 *
59 * The different message types supported by the PLDM specification.
60 */
61typedef 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 Kodihalli1b24f972019-02-01 04:09:13 -060069#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 Misra432e1872019-02-13 03:49:43 -060074#define PLDM_GET_VERSION_REQ_BYTES 6
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060075
76/* Response lengths are inclusive of completion code */
77#define PLDM_GET_TYPES_RESP_BYTES 9
John Wang5c4f80d2019-07-29 11:12:18 +080078#define PLDM_GET_TID_RESP_BYTES 2
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060079#define PLDM_GET_COMMANDS_RESP_BYTES 33
Sampa Misra432e1872019-02-13 03:49:43 -060080/* Response data has only one version and does not contain the checksum */
81#define PLDM_GET_VERSION_RESP_BYTES 10
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060082
Christian Geddes6c146f12020-05-01 14:48:23 -050083#define PLDM_VERSION_0 0
84#define PLDM_CURRENT_VERSION PLDM_VERSION_0
85
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060086/** @struct pldm_msg_hdr
87 *
88 * Structure representing PLDM message header fields
89 */
90struct pldm_msg_hdr {
91#if defined(__LITTLE_ENDIAN_BITFIELD)
92 uint8_t instance_id : 5; //!< Instance ID
Deepak Kodihalli826c9d42020-05-26 01:58:06 -050093 uint8_t reserved : 1; //!< Reserved
94 uint8_t datagram : 1; //!< Datagram bit
95 uint8_t request : 1; //!< Request bit
Deepak Kodihalli1b24f972019-02-01 04:09:13 -060096#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -050097 uint8_t request : 1; //!< Request bit
98 uint8_t datagram : 1; //!< Datagram bit
99 uint8_t reserved : 1; //!< Reserved
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600100 uint8_t instance_id : 5; //!< Instance ID
101#endif
102
103#if defined(__LITTLE_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500104 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600105 uint8_t header_ver : 2; //!< Header version
106#elif defined(__BIG_ENDIAN_BITFIELD)
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500107 uint8_t header_ver : 2; //!< Header version
108 uint8_t type : 6; //!< PLDM type
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600109#endif
110 uint8_t command; //!< PLDM command code
111} __attribute__((packed));
112
Zach Clarkb728eee2020-06-18 10:01:31 -0500113// Macros for byte-swapping variables in-place
114#define HTOLE32(X) (X = htole32(X))
115#define HTOLE16(X) (X = htole16(X))
116
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600117/** @struct pldm_msg
118 *
119 * Structure representing PLDM message
120 */
121struct pldm_msg {
vkaverapa6575b82019-04-03 05:33:52 -0500122 struct pldm_msg_hdr hdr; //!< PLDM message header
123 uint8_t payload[1]; //!< &payload[0] is the beginning of the payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600124} __attribute__((packed));
125
Tom Joseph41251042019-02-07 16:17:07 +0530126/** @struct pldm_header_info
127 *
128 * The information needed to prepare PLDM header and this is passed to the
129 * pack_pldm_header and unpack_pldm_header API.
130 */
131struct pldm_header_info {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500132 MessageType msg_type; //!< PLDM message type
133 uint8_t instance; //!< PLDM instance id
134 uint8_t pldm_type; //!< PLDM type
Tom Joseph41251042019-02-07 16:17:07 +0530135 uint8_t command; //!< PLDM command code
136 uint8_t completion_code; //!< PLDM completion code, applies for response
137};
138
Priyanga4b790ce2019-06-10 01:30:09 -0500139/** @struct pldm_get_types_resp
140 *
141 * Structure representing PLDM get types response.
142 */
143struct pldm_get_types_resp {
144 uint8_t completion_code; //!< completion code
145 bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type
146 //!< is supported
147} __attribute__((packed));
148
149/** @struct pldm_get_commands_req
150 *
151 * Structure representing PLDM get commands request.
152 */
153struct pldm_get_commands_req {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500154 uint8_t type; //!< PLDM Type for which command support information is
Priyanga4b790ce2019-06-10 01:30:09 -0500155 //!< being requested
156 ver32_t version; //!< version for the specified PLDM Type
157} __attribute__((packed));
158
159/** @struct pldm_get_commands_resp
160 *
161 * Structure representing PLDM get commands response.
162 */
163struct pldm_get_commands_resp {
164 uint8_t completion_code; //!< completion code
165 bitfield8_t commands[32]; //!< each bit represents whether a given PLDM
166 //!< command is supported
167} __attribute__((packed));
168
169/** @struct pldm_get_version_req
170 *
171 * Structure representing PLDM get version request.
172 */
173struct pldm_get_version_req {
174 uint32_t
175 transfer_handle; //!< handle to identify PLDM version data transfer
176 uint8_t transfer_opflag; //!< PLDM GetVersion operation flag
177 uint8_t type; //!< PLDM Type for which version information is being
178 //!< requested
179} __attribute__((packed));
180
181/** @struct pldm_get_version_resp
182 *
183 * Structure representing PLDM get version response.
184 */
185
186struct pldm_get_version_resp {
187 uint8_t completion_code; //!< completion code
188 uint32_t next_transfer_handle; //!< next portion of PLDM version data
189 //!< transfer
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500190 uint8_t transfer_flag; //!< PLDM GetVersion transfer flag
Priyanga4b790ce2019-06-10 01:30:09 -0500191 uint8_t version_data[1]; //!< PLDM GetVersion version field
192} __attribute__((packed));
193
John Wang5c4f80d2019-07-29 11:12:18 +0800194/** @struct pldm_get_tid_resp
195 *
196 * Structure representing PLDM get tid response.
197 */
198
199struct pldm_get_tid_resp {
200 uint8_t completion_code; //!< completion code
201 uint8_t tid; //!< PLDM GetTID TID field
202} __attribute__((packed));
203
Tom Joseph41251042019-02-07 16:17:07 +0530204/**
205 * @brief Populate the PLDM message with the PLDM header.The caller of this API
206 * allocates buffer for the PLDM header when forming the PLDM message.
207 * The buffer is passed to this API to pack the PLDM header.
208 *
209 * @param[in] hdr - Pointer to the PLDM header information
210 * @param[out] msg - Pointer to PLDM message header
211 *
212 * @return 0 on success, otherwise PLDM error codes.
Christian Geddes6c146f12020-05-01 14:48:23 -0500213 * @note Caller is responsible for alloc and dealloc of msg
214 * and hdr params
Tom Joseph41251042019-02-07 16:17:07 +0530215 */
216int pack_pldm_header(const struct pldm_header_info *hdr,
217 struct pldm_msg_hdr *msg);
218
219/**
220 * @brief Unpack the PLDM header from the PLDM message.
221 *
222 * @param[in] msg - Pointer to the PLDM message header
223 * @param[out] hdr - Pointer to the PLDM header information
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 */
229int unpack_pldm_header(const struct pldm_msg_hdr *msg,
230 struct pldm_header_info *hdr);
231
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600232/* Requester */
233
234/* GetPLDMTypes */
235
236/** @brief Create a PLDM request message for GetPLDMTypes
237 *
238 * @param[in] instance_id - Message's instance id
239 * @param[in,out] msg - Message will be written to this
240 * @return pldm_completion_codes
241 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500242 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600243 */
244int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg);
245
246/** @brief Decode a GetPLDMTypes response message
247 *
George Liu684a7162019-12-06 15:10:52 +0800248 * Note:
249 * * If the return value is not PLDM_SUCCESS, it represents a
250 * transport layer error.
251 * * If the completion_code value is not PLDM_SUCCESS, it represents a
252 * protocol layer error and all the out-parameters are invalid.
253 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500254 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500255 * @param[in] payload_length - Length of response message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600256 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600257 * @param[out] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600258 * types (MAX_TYPES/8) = 8), as per DSP0240
259 * @return pldm_completion_codes
260 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500261int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600262 uint8_t *completion_code, bitfield8_t *types);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600263
264/* GetPLDMCommands */
265
266/** @brief Create a PLDM request message for GetPLDMCommands
267 *
268 * @param[in] instance_id - Message's instance id
269 * @param[in] type - PLDM Type
270 * @param[in] version - Version for PLDM Type
271 * @param[in,out] msg - Message will be written to this
272 * @return pldm_completion_codes
273 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500274 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600275 */
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600276int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version,
277 struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600278
279/** @brief Decode a GetPLDMCommands response message
280 *
George Liu684a7162019-12-06 15:10:52 +0800281 * Note:
282 * * If the return value is not PLDM_SUCCESS, it represents a
283 * transport layer error.
284 * * If the completion_code value is not PLDM_SUCCESS, it represents a
285 * protocol layer error and all the out-parameters are invalid.
286 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500287 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500288 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600289 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600290 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600291 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
292 * @return pldm_completion_codes
293 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500294int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600295 uint8_t *completion_code, bitfield8_t *commands);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600296
Sampa Misra432e1872019-02-13 03:49:43 -0600297/* GetPLDMVersion */
298
299/** @brief Create a PLDM request for GetPLDMVersion
300 *
301 * @param[in] instance_id - Message's instance id
302 * @param[in] transfer_handle - Handle to identify PLDM version data transfer.
303 * This handle is ignored by the responder when the
304 * transferop_flag is set to getFirstPart.
305 * @param[in] transfer_opflag - flag to indicate whether it is start of
306 * transfer
307 * @param[in] type - PLDM Type for which version is requested
308 * @param[in,out] msg - Message will be written to this
309 * @return pldm_completion_codes
310 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500311 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600312 */
313int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle,
314 uint8_t transfer_opflag, uint8_t type,
315 struct pldm_msg *msg);
316
317/** @brief Decode a GetPLDMVersion response message
318 *
George Liu684a7162019-12-06 15:10:52 +0800319 * Note:
320 * * If the return value is not PLDM_SUCCESS, it represents a
321 * transport layer error.
322 * * If the completion_code value is not PLDM_SUCCESS, it represents a
323 * protocol layer error and all the out-parameters are invalid.
324 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500325 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500326 * @param[in] payload_length - Length of reponse message payload
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600327 * @param[out] completion_code - Pointer to response msg's PLDM completion code
Sampa Misra432e1872019-02-13 03:49:43 -0600328 * @param[out] next_transfer_handle - the next handle for the next part of data
329 * @param[out] transfer_flag - flag to indicate the part of data
330 * @return pldm_completion_codes
331 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500332int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length,
Deepak Kodihalli8c643462019-02-21 10:43:36 -0600333 uint8_t *completion_code,
Sampa Misra432e1872019-02-13 03:49:43 -0600334 uint32_t *next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600335 uint8_t *transfer_flag, ver32_t *version);
Sampa Misra432e1872019-02-13 03:49:43 -0600336
John Wang5c4f80d2019-07-29 11:12:18 +0800337/* GetTID */
338
339/** @brief Decode a GetTID response message
340 *
George Liu684a7162019-12-06 15:10:52 +0800341 * Note:
342 * * If the return value is not PLDM_SUCCESS, it represents a
343 * transport layer error.
344 * * If the completion_code value is not PLDM_SUCCESS, it represents a
345 * protocol layer error and all the out-parameters are invalid.
346 *
John Wang5c4f80d2019-07-29 11:12:18 +0800347 * @param[in] msg - Response message
348 * @param[in] payload_length - Length of response message payload
349 * @param[out] completion_code - Pointer to response msg's PLDM completion code
350 * @param[out] tid - Pointer to the terminus id
351 * @return pldm_completion_codes
352 */
353int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
354 uint8_t *completion_code, uint8_t *tid);
355
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600356/* Responder */
357
358/* GetPLDMTypes */
359
360/** @brief Create a PLDM response message for GetPLDMTypes
361 *
362 * @param[in] instance_id - Message's instance id
363 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600364 * @param[in] types - pointer to array bitfield8_t[8] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600365 * types (MAX_TYPES/8) = 8), as per DSP0240
366 * @param[in,out] msg - Message will be written to this
367 * @return pldm_completion_codes
368 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500369 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600370 */
371int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600372 const bitfield8_t *types, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600373
374/* GetPLDMCommands */
375
376/** @brief Decode GetPLDMCommands' request data
377 *
vkaverapa6575b82019-04-03 05:33:52 -0500378 * @param[in] msg - Request message
379 * @param[in] payload_length - Length of request message payload
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600380 * @param[out] type - PLDM Type
381 * @param[out] version - Version for PLDM Type
382 * @return pldm_completion_codes
383 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500384int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length,
vkaverapa6575b82019-04-03 05:33:52 -0500385 uint8_t *type, ver32_t *version);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600386
387/** @brief Create a PLDM response message for GetPLDMCommands
388 *
389 * @param[in] instance_id - Message's instance id
390 * @param[in] completion_code - PLDM completion code
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600391 * @param[in] commands - pointer to array bitfield8_t[32] containing supported
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600392 * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240
393 * @param[in,out] msg - Message will be written to this
394 * @return pldm_completion_codes
395 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500396 * 'msg.payload'
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600397 */
398int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600399 const bitfield8_t *commands, struct pldm_msg *msg);
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600400
Sampa Misra432e1872019-02-13 03:49:43 -0600401/* GetPLDMVersion */
402
403/** @brief Create a PLDM response for GetPLDMVersion
404 *
405 * @param[in] instance_id - Message's instance id
406 * @param[in] completion_code - PLDM completion code
407 * @param[in] next_transfer_handle - Handle to identify next portion of
408 * data transfer
409 * @param[in] transfer_flag - Represents the part of transfer
410 * @param[in] version_data - the version data
411 * @param[in] version_size - size of version data
412 * @param[in,out] msg - Message will be written to this
413 * @return pldm_completion_codes
414 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500415 * 'msg.payload'
Sampa Misra432e1872019-02-13 03:49:43 -0600416 */
417int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code,
418 uint32_t next_transfer_handle,
Deepak Kodihalli97e0bd52019-02-21 03:54:22 -0600419 uint8_t transfer_flag, const ver32_t *version_data,
Sampa Misra432e1872019-02-13 03:49:43 -0600420 size_t version_size, struct pldm_msg *msg);
421
422/** @brief Decode a GetPLDMVersion request message
423 *
vkaverapa6575b82019-04-03 05:33:52 -0500424 * @param[in] msg - Request message
425 * @param[in] payload_length - length of request message payload
Sampa Misra432e1872019-02-13 03:49:43 -0600426 * @param[out] transfer_handle - the handle of data
427 * @param[out] transfer_opflag - Transfer Flag
428 * @param[out] type - PLDM type for which version is requested
429 * @return pldm_completion_codes
430 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500431int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra432e1872019-02-13 03:49:43 -0600432 uint32_t *transfer_handle, uint8_t *transfer_opflag,
433 uint8_t *type);
434
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600435/* Requester */
436
John Wang5c4f80d2019-07-29 11:12:18 +0800437/* GetTID */
438
Sridevi Rameshbc6ff262019-12-12 04:58:35 -0600439/** @brief Create a PLDM request message for GetTID
440 *
441 * @param[in] instance_id - Message's instance id
442 * @param[in,out] msg - Message will be written to this
443 * @return pldm_completion_codes
444 * @note Caller is responsible for memory alloc and dealloc of param
445 * 'msg.payload'
446 */
447int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg);
448
John Wang5c4f80d2019-07-29 11:12:18 +0800449/** @brief Create a PLDM response message for GetTID
450 *
451 * @param[in] instance_id - Message's instance id
452 * @param[in] completion_code - PLDM completion code
453 * @param[in] tid - Terminus 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_resp(uint8_t instance_id, uint8_t completion_code,
460 uint8_t tid, struct pldm_msg *msg);
461
John Wang7f02d702019-12-03 13:38:14 +0800462/** @brief Create a PLDM response message containing only cc
463 *
464 * @param[in] instance_id - Message's instance id
465 * @param[in] type - PLDM Type
466 * @param[in] command - PLDM Command
467 * @param[in] cc - PLDM Completion Code
468 * @param[out] msg - Message will be written to this
469 * @return pldm_completion_codes
470 */
471int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
472 uint8_t cc, struct pldm_msg *msg);
473
Deepak Kodihalli1b24f972019-02-01 04:09:13 -0600474#ifdef __cplusplus
475}
476#endif
477
478#endif /* BASE_H */