blob: 181fd3eeba262d77760246d7f08235fa7ae53f00 [file] [log] [blame]
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12
13/* Maximum size for request */
14#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
Jolie Ku3557bad2020-03-02 16:22:57 +080015#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
Sampa Misra0db1dfa2019-03-19 00:15:31 -050016/* Response lengths are inclusive of completion code */
17#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080018#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050019
George Liu30b859f2020-01-07 15:03:22 +080020#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
21#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
22
Sampa Misra7fcfb662019-05-08 13:13:53 -050023#define PLDM_GET_PDR_REQ_BYTES 13
24/* Minimum response length */
25#define PLDM_GET_PDR_MIN_RESP_BYTES 12
26
Zahed Hossaind4abab12020-02-06 03:36:43 -060027/* Minimum length for PLDM PlatformEventMessage request */
28#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
29#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
30
George Liu30b859f2020-01-07 15:03:22 +080031enum pldm_effecter_data_size {
32 PLDM_EFFECTER_DATA_SIZE_UINT8,
33 PLDM_EFFECTER_DATA_SIZE_SINT8,
34 PLDM_EFFECTER_DATA_SIZE_UINT16,
35 PLDM_EFFECTER_DATA_SIZE_SINT16,
36 PLDM_EFFECTER_DATA_SIZE_UINT32,
37 PLDM_EFFECTER_DATA_SIZE_SINT32
38};
39
Sampa Misra0db1dfa2019-03-19 00:15:31 -050040enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
41
42enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
43
Jolie Ku3557bad2020-03-02 16:22:57 +080044enum sensor_operational_state {
45 ENABLED = 0x00,
46 DISABLED = 0x01,
47 UNAVAILABLE = 0x02,
48 STATUSUNKNOWN = 0x03,
49 FAILED = 0x04,
50 INITIALIZING = 0x05,
51 SHUTTINGDOWN = 0x06,
52 INTEST = 0x07
53};
54
55enum present_state {
56 UNKNOWN = 0x0,
57 NORMAL = 0x01,
58 WARNING = 0x02,
59 CRITICAL = 0x03,
60 FATAL = 0x04,
61 LOWERWARNING = 0x05,
62 LOWERCRITICAL = 0x06,
63 LOWERFATAL = 0x07,
64 UPPERWARNING = 0x08,
65 UPPERCRITICAL = 0x09,
66 UPPERFATAL = 0x0a
67};
68
Sampa Misra0db1dfa2019-03-19 00:15:31 -050069enum pldm_platform_commands {
Jolie Ku3557bad2020-03-02 16:22:57 +080070 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +080071 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050072 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -050073 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -060074 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -050075};
76
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050077/** @brief PLDM PDR types
78 */
79enum pldm_pdr_types {
80 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -050081 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -060082 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050083};
84
85/** @brief PLDM effecter initialization schemes
86 */
87enum pldm_effecter_init {
88 PLDM_NO_INIT,
89 PLDM_USE_INIT_PDR,
90 PLDM_ENABLE_EFFECTER,
91 PLDM_DISABLE_EFECTER
92};
93
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053094/** @brief PLDM Platform M&C completion codes
95 */
96enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -050097 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
98 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053099 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Sampa Misraa2fa0702019-05-31 01:28:55 -0500100 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530101};
102
Zahed Hossaind4abab12020-02-06 03:36:43 -0600103/** @brief PLDM Event types
104 */
105enum pldm_event_types {
106 PLDM_SENSOR_EVENT = 0x00,
107 PLDM_EFFECTER_EVENT = 0x01,
108 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
109 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
110 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
111 PLDM_MESSAGE_POLL_EVENT = 0x05,
112 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
113};
114
115/** @brief PLDM sensorEventClass states
116 */
117enum sensor_event_class_states {
118 PLDM_SENSOR_OP_STATE,
119 PLDM_STATE_SENSOR_STATE,
120 PLDM_NUMERIC_SENSOR_STATE
121};
122
123/** @brief PLDM sensor supported states
124 */
125enum pldm_sensor_operational_state {
126 PLDM_SENSOR_ENABLED,
127 PLDM_SENSOR_DISABLED,
128 PLDM_SENSOR_UNAVAILABLE,
129 PLDM_SENSOR_STATUSUNKOWN,
130 PLDM_SENSOR_FAILED,
131 PLDM_SENSOR_INITIALIZING,
132 PLDM_SENSOR_SHUTTINGDOWN,
133 PLDM_SENSOR_INTEST
134};
135
136/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
137 */
138enum pldm_pdr_repository_chg_event_data_format {
139 REFRESH_ENTIRE_REPOSITORY,
140 FORMAT_IS_PDR_TYPES,
141 FORMAT_IS_PDR_HANDLES
142};
143
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500144/** @struct pldm_pdr_hdr
145 *
146 * Structure representing PLDM common PDR header
147 */
148struct pldm_pdr_hdr {
149 uint32_t record_handle;
150 uint8_t version;
151 uint8_t type;
152 uint16_t record_change_num;
153 uint16_t length;
154} __attribute__((packed));
155
Deepak Kodihallidb914672020-02-07 02:47:45 -0600156/** @struct pldm_pdr_fru_record_set
157 *
158 * Structure representing PLDM FRU record set PDR
159 */
160struct pldm_pdr_fru_record_set {
161 uint16_t terminus_handle;
162 uint16_t fru_rsi;
163 uint16_t entity_type;
164 uint16_t entity_instance_num;
165 uint16_t container_id;
166} __attribute__((packed));
167
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500168/** @struct pldm_state_effecter_pdr
169 *
170 * Structure representing PLDM state effecter PDR
171 */
172struct pldm_state_effecter_pdr {
173 struct pldm_pdr_hdr hdr;
174 uint16_t terminus_handle;
175 uint16_t effecter_id;
176 uint16_t entity_type;
177 uint16_t entity_instance;
178 uint16_t container_id;
179 uint16_t effecter_semantic_id;
180 uint8_t effecter_init;
181 bool8_t has_description_pdr;
182 uint8_t composite_effecter_count;
183 uint8_t possible_states[1];
184} __attribute__((packed));
185
186/** @struct state_effecter_possible_states
187 *
188 * Structure representing state enums for state effecter
189 */
190struct state_effecter_possible_states {
191 uint16_t state_set_id;
192 uint8_t possible_states_size;
193 bitfield8_t states[1];
194} __attribute__((packed));
195
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500196/** @struct set_effecter_state_field
197 *
198 * Structure representing a stateField in SetStateEffecterStates command */
199
200typedef struct state_field_for_state_effecter_set {
201 uint8_t set_request; //!< Whether to change the state
202 uint8_t effecter_state; //!< Expected state of the effecter
203} __attribute__((packed)) set_effecter_state_field;
204
Jolie Ku3557bad2020-03-02 16:22:57 +0800205/** @struct get_sensor_readings_field
206 *
207 * Structure representing a stateField in GetStateSensorReadings command */
208
209typedef struct state_field_for_get_state_sensor_readings {
210 uint8_t sensor_op_state; //!< The state of the sensor itself
211 uint8_t present_state; //!< Return a state value
212 uint8_t previous_state; //!< The state that the presentState was entered
213 //! from. This must be different from the
214 //! present state
215 uint8_t event_state; //!< Return a state value from a PLDM State Set
216 //! that is associated with the sensor
217} __attribute__((packed)) get_sensor_state_field;
218
Priyanga7257fdf2019-06-10 01:59:45 -0500219/** @struct PLDM_SetStateEffecterStates_Request
220 *
221 * Structure representing PLDM set state effecter states request.
222 */
223struct pldm_set_state_effecter_states_req {
224 uint16_t effecter_id;
225 uint8_t comp_effecter_count;
226 set_effecter_state_field field[8];
227} __attribute__((packed));
228
Sampa Misra7fcfb662019-05-08 13:13:53 -0500229/** @struct pldm_get_pdr_resp
230 *
231 * structure representing GetPDR response packet
232 * transfer CRC is not part of the structure and will be
233 * added at the end of last packet in multipart transfer
234 */
235struct pldm_get_pdr_resp {
236 uint8_t completion_code;
237 uint32_t next_record_handle;
238 uint32_t next_data_transfer_handle;
239 uint8_t transfer_flag;
240 uint16_t response_count;
241 uint8_t record_data[1];
242} __attribute__((packed));
243
244/** @struct pldm_get_pdr_req
245 *
246 * structure representing GetPDR request packet
247 */
248struct pldm_get_pdr_req {
249 uint32_t record_handle;
250 uint32_t data_transfer_handle;
251 uint8_t transfer_op_flag;
252 uint16_t request_count;
253 uint16_t record_change_number;
254} __attribute__((packed));
255
George Liu30b859f2020-01-07 15:03:22 +0800256/** @struct pldm_set_numeric_effecter_value_req
257 *
258 * structure representing SetNumericEffecterValue request packet
259 */
260struct pldm_set_numeric_effecter_value_req {
261 uint16_t effecter_id;
262 uint8_t effecter_data_size;
263 uint8_t effecter_value[1];
264} __attribute__((packed));
265
Jolie Ku3557bad2020-03-02 16:22:57 +0800266/** @struct pldm_get_state_sensor_readings_req
267 *
268 * Structure representing PLDM get state sensor readings request.
269 */
270struct pldm_get_state_sensor_readings_req {
271 uint16_t sensor_id;
272 bitfield8_t sensor_rearm;
273 uint8_t reserved;
274} __attribute__((packed));
275
276/** @struct pldm_get_state_sensor_readings_resp
277 *
278 * Structure representing PLDM get state sensor readings response.
279 */
280struct pldm_get_state_sensor_readings_resp {
281 uint8_t completion_code;
282 uint8_t comp_sensor_count;
283 get_sensor_state_field field[1];
284} __attribute__((packed));
285
Zahed Hossaind4abab12020-02-06 03:36:43 -0600286/** @struct pldm_sensor_event
287 *
288 * structure representing sensorEventClass
289 */
290struct pldm_sensor_event_data {
291 uint16_t sensor_id;
292 uint8_t sensor_event_class_type;
293 uint8_t event_class[1];
294} __attribute__((packed));
295
296/** @struct pldm_state_sensor_state
297 *
298 * structure representing sensorEventClass for stateSensorState
299 */
300struct pldm_sensor_event_state_sensor_state {
301 uint8_t sensor_offset;
302 uint8_t event_state;
303 uint8_t previous_event_state;
304} __attribute__((packed));
305
306/** @struct pldm_sensor_event_numeric_sensor_state
307 *
308 * structure representing sensorEventClass for stateSensorState
309 */
310struct pldm_sensor_event_numeric_sensor_state {
311 uint8_t event_state;
312 uint8_t previous_event_state;
313 uint8_t sensor_data_size;
314 uint8_t present_reading[1];
315} __attribute__((packed));
316
317/** @struct pldm_sensor_event_sensor_op_state
318 *
319 * structure representing sensorEventClass for SensorOpState
320 */
321struct pldm_sensor_event_sensor_op_state {
322 uint8_t present_op_state;
323 uint8_t previous_op_state;
324} __attribute__((packed));
325
326/** @struct pldm_platform_event_message_req
327 *
328 * structure representing PlatformEventMessage command request data
329 */
330struct pldm_platform_event_message_req {
331 uint8_t format_version;
332 uint8_t tid;
333 uint8_t event_class;
334 uint8_t event_data[1];
335} __attribute__((packed));
336
337/** @struct pldm_platform_event_message_response
338 *
339 * structure representing PlatformEventMessage command response data
340 */
341struct pldm_platform_event_message_resp {
342 uint8_t completion_code;
343 uint8_t status;
344} __attribute__((packed));
345
346/** @struct pldm_pdr_repository_chg_event_data
347 *
348 * structure representing pldmPDRRepositoryChgEvent class eventData
349 */
350struct pldm_pdr_repository_chg_event_data {
351 uint8_t event_data_format;
352 uint8_t number_of_change_records;
353 uint8_t change_records[1];
354} __attribute__((packed));
355
356/** @struct pldm_pdr_repository_chg_event_change_record_data
357 *
358 * structure representing pldmPDRRepositoryChgEvent class eventData's change
359 * record data
360 */
361struct pldm_pdr_repository_change_record_data {
362 uint8_t event_data_operation;
363 uint8_t number_of_change_entries;
364 uint32_t change_entry[1];
365} __attribute__((packed));
366
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500367/* Responder */
368
George Liu30b859f2020-01-07 15:03:22 +0800369/* SetNumericEffecterValue */
370
371/** @brief Decode SetNumericEffecterValue request data
372 *
373 * @param[in] msg - Request message
374 * @param[in] payload_length - Length of request message payload
375 * @param[out] effecter_id - used to identify and access the effecter
376 * @param[out] effecter_data_size - The bit width and format of the setting
377 * value for the effecter.
378 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
379 * @param[out] effecter_value - The setting value of numeric effecter being
380 * requested.
381 * @return pldm_completion_codes
382 */
383int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
384 size_t payload_length,
385 uint16_t *effecter_id,
386 uint8_t *effecter_data_size,
387 uint8_t *effecter_value);
388
389/** @brief Create a PLDM response message for SetNumericEffecterValue
390 *
391 * @param[in] instance_id - Message's instance id
392 * @param[in] completion_code - PLDM completion code
393 * @param[out] msg - Message will be written to this
394 * @param[in] payload_length - Length of request message payload
395 * @return pldm_completion_codes
396 * @note Caller is responsible for memory alloc and dealloc of param
397 * 'msg.body.payload'
398 */
399int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
400 uint8_t completion_code,
401 struct pldm_msg *msg,
402 size_t payload_length);
403
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500404/* SetStateEffecterStates */
405
406/** @brief Create a PLDM response message for SetStateEffecterStates
407 *
408 * @param[in] instance_id - Message's instance id
409 * @param[in] completion_code - PLDM completion code
410 * @param[out] msg - Message will be written to this
411 * @return pldm_completion_codes
412 * @note Caller is responsible for memory alloc and dealloc of param
413 * 'msg.body.payload'
414 */
415
416int encode_set_state_effecter_states_resp(uint8_t instance_id,
417 uint8_t completion_code,
418 struct pldm_msg *msg);
419
420/** @brief Decode SetStateEffecterStates request data
421 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500422 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500423 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500424 * @param[out] effecter_id - used to identify and access the effecter
425 * @param[out] comp_effecter_count - number of individual sets of effecter
426 * information. Upto eight sets of state effecter info can be accessed
427 * for a given effecter.
428 * @param[out] field - each unit is an instance of the stateFileld structure
429 * that is used to set the requested state for a particular effecter
430 * within the state effecter. This field holds the starting address of
431 * the stateField values. The user is responsible to allocate the
432 * memory prior to calling this command. Since the state field count is
433 * not known in advance, the user should allocate the maximum size
434 * always, which is 8 in number.
435 * @return pldm_completion_codes
436 */
vkaverapa6575b82019-04-03 05:33:52 -0500437
Zahed Hossain223a73d2019-07-04 12:46:18 -0500438int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500439 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500440 uint16_t *effecter_id,
441 uint8_t *comp_effecter_count,
442 set_effecter_state_field *field);
443
Sampa Misra7fcfb662019-05-08 13:13:53 -0500444/* GetPDR */
445
446/** @brief Create a PLDM response message for GetPDR
447 *
448 * @param[in] instance_id - Message's instance id
449 * @param[in] completion_code - PLDM completion code
450 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
451 * the PDR Repository
452 * @param[in] next_data_transfer_hndl - A handle that identifies the next
453 * portion of the PDR data to be transferred, if any
454 * @param[in] transfer_flag - Indicates the portion of PDR data being
455 * transferred
456 * @param[in] resp_cnt - The number of recordData bytes returned in this
457 * response
458 * @param[in] record_data - PDR data bytes of length resp_cnt
459 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
460 * in the last part of a PDR being transferred
461 * @param[out] msg - Message will be written to this
462 * @return pldm_completion_codes
463 * @note Caller is responsible for memory alloc and dealloc of param
464 * 'msg.payload'
465 */
466int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
467 uint32_t next_record_hndl,
468 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
469 uint16_t resp_cnt, const uint8_t *record_data,
470 uint8_t transfer_crc, struct pldm_msg *msg);
471
472/** @brief Decode GetPDR request data
473 *
474 * @param[in] msg - Request message
475 * @param[in] payload_length - Length of request message payload
476 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
477 * @param[out] data_transfer_hndl - Handle used to identify a particular
478 * multipart PDR data transfer operation
479 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
480 * portion of transfer
481 * @param[out] request_cnt - The maximum number of record bytes requested
482 * @param[out] record_chg_num - Used to determine whether the PDR has changed
483 * while PDR transfer is going on
484 * @return pldm_completion_codes
485 */
486
487int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
488 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
489 uint8_t *transfer_op_flag, uint16_t *request_cnt,
490 uint16_t *record_chg_num);
491
Jolie Ku3557bad2020-03-02 16:22:57 +0800492/* GetStateSensorReadings */
493
494/** @brief Decode GetStateSensorReadings request data
495 *
496 * @param[in] msg - Request message
497 * @param[in] payload_length - Length of request message payload
498 * @param[out] sensor_id - used to identify and access the simple or composite
499 * sensor
500 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
501 * particular sensor within the state sensor, where bit [0] corresponds
502 * to the first state sensor (sensor offset 0) and bit [7] corresponds
503 * to the eighth sensor (sensor offset 7), sequentially.
504 * @param[out] reserved - value: 0x00
505 * @return pldm_completion_codes
506 */
507
508int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
509 size_t payload_length,
510 uint16_t *sensor_id,
511 bitfield8_t *sensor_rearm,
512 uint8_t *reserved);
513
514/** @brief Encode GetStateSensorReadings response data
515 *
516 * @param[in] instance_id - Message's instance id
517 * @param[in] completion_code - PLDM completion code
518 * @param[out] comp_sensor_count - The number of individual sets of sensor
519 * information that this command accesses
520 * @param[out] field - Each stateField is an instance of a stateField structure
521 * that is used to return the present operational state setting and the
522 * present state and event state for a particular set of sensor
523 * information contained within the state sensor
524 * @param[out] msg - Message will be written to this
525 * @return pldm_completion_codes
526 */
527
528int encode_get_state_sensor_readings_resp(uint8_t instance_id,
529 uint8_t completion_code,
530 uint8_t comp_sensor_count,
531 get_sensor_state_field *field,
532 struct pldm_msg *msg);
533
Sampa Misra7fcfb662019-05-08 13:13:53 -0500534/* Requester */
535
George Liu820a9a52019-11-26 14:43:59 +0800536/* GetPDR */
537
538/** @brief Create a PLDM request message for GetPDR
539 *
540 * @param[in] instance_id - Message's instance id
541 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
542 * @param[in] data_transfer_hndl - Handle used to identify a particular
543 * multipart PDR data transfer operation
544 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
545 * portion of transfer
546 * @param[in] request_cnt - The maximum number of record bytes requested
547 * @param[in] record_chg_num - Used to determine whether the PDR has changed
548 * while PDR transfer is going on
549 * @param[out] msg - Message will be written to this
550 * @param[in] payload_length - Length of request message payload
551 * @return pldm_completion_codes
552 * @note Caller is responsible for memory alloc and dealloc of param
553 * 'msg.payload'
554 */
555int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
556 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
557 uint16_t request_cnt, uint16_t record_chg_num,
558 struct pldm_msg *msg, size_t payload_length);
559
560/** @brief Decode GetPDR response data
561 *
George Liu684a7162019-12-06 15:10:52 +0800562 * Note:
563 * * If the return value is not PLDM_SUCCESS, it represents a
564 * transport layer error.
565 * * If the completion_code value is not PLDM_SUCCESS, it represents a
566 * protocol layer error and all the out-parameters are invalid.
567 *
George Liu820a9a52019-11-26 14:43:59 +0800568 * @param[in] msg - Request message
569 * @param[in] payload_length - Length of request message payload
570 * @param[out] completion_code - PLDM completion code
571 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
572 * the PDR Repository
573 * @param[out] next_data_transfer_hndl - A handle that identifies the next
574 * portion of the PDR data to be transferred, if any
575 * @param[out] transfer_flag - Indicates the portion of PDR data being
576 * transferred
577 * @param[out] resp_cnt - The number of recordData bytes returned in this
578 * response
579 * @param[out] record_data - PDR data bytes of length resp_cnt
580 * @param[in] record_data_length - Length of record_data
581 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
582 * in the last part of a PDR being transferred
583 * @return pldm_completion_codes
584 */
585int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
586 uint8_t *completion_code, uint32_t *next_record_hndl,
587 uint32_t *next_data_transfer_hndl,
588 uint8_t *transfer_flag, uint16_t *resp_cnt,
589 uint8_t *record_data, size_t record_data_length,
590 uint8_t *transfer_crc);
591
Sampa Misra7fcfb662019-05-08 13:13:53 -0500592/* SetStateEffecterStates */
593
vkaverap98a2c192019-04-03 05:33:52 -0500594/** @brief Create a PLDM request message for SetStateEffecterStates
595 *
596 * @param[in] instance_id - Message's instance id
597 * @param[in] effecter_id - used to identify and access the effecter
598 * @param[in] comp_effecter_count - number of individual sets of effecter
599 * information. Upto eight sets of state effecter info can be accessed
600 * for a given effecter.
601 * @param[in] field - each unit is an instance of the stateField structure
602 * that is used to set the requested state for a particular effecter
603 * within the state effecter. This field holds the starting address of
604 * the stateField values. The user is responsible to allocate the
605 * memory prior to calling this command. The user has to allocate the
606 * field parameter as sizeof(set_effecter_state_field) *
607 * comp_effecter_count
608 * @param[out] msg - Message will be written to this
609 * @return pldm_completion_codes
610 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500611 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500612 */
613
614int encode_set_state_effecter_states_req(uint8_t instance_id,
615 uint16_t effecter_id,
616 uint8_t comp_effecter_count,
617 set_effecter_state_field *field,
618 struct pldm_msg *msg);
619
620/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800621 *
622 * Note:
623 * * If the return value is not PLDM_SUCCESS, it represents a
624 * transport layer error.
625 * * If the completion_code value is not PLDM_SUCCESS, it represents a
626 * protocol layer error and all the out-parameters are invalid.
627 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500628 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500629 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500630 * @param[out] completion_code - PLDM completion code
631 * @return pldm_completion_codes
632 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500633int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500634 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500635 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800636
637/* SetNumericEffecterValue */
638
639/** @brief Create a PLDM request message for SetNumericEffecterValue
640 *
641 * @param[in] instance_id - Message's instance id
642 * @param[in] effecter_id - used to identify and access the effecter
643 * @param[in] effecter_data_size - The bit width and format of the setting
644 * value for the effecter.
645 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
646 * @param[in] effecter_value - The setting value of numeric effecter being
647 * requested.
648 * @param[in] payload_length - Length of request message payload
649 * @param[out] msg - Message will be written to this
650 * @return pldm_completion_codes
651 * @note Caller is responsible for memory alloc and dealloc of param
652 * 'msg.payload'
653 */
654int encode_set_numeric_effecter_value_req(
655 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
656 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
657
658/** @brief Decode SetNumericEffecterValue response data
659 * @param[in] msg - Request message
660 * @param[in] payload_length - Length of response message payload
661 * @param[out] completion_code - PLDM completion code
662 * @return pldm_completion_codes
663 */
664int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
665 size_t payload_length,
666 uint8_t *completion_code);
667
Jolie Ku3557bad2020-03-02 16:22:57 +0800668/** @brief Create a PLDM request message for GetStateSensorReadings
669 *
670 * @param[in] instance_id - Message's instance id
671 * @param[in] sensor_id - used to identify and access the simple or composite
672 * sensor
673 * @param[in] sensorRearm - Each bit location in this field corresponds to a
674 * particular sensor within the state sensor, where bit [0] corresponds
675 * to the first state sensor (sensor offset 0) and bit [7] corresponds
676 * to the eighth sensor (sensor offset 7), sequentially
677 * @param[in] reserved - value: 0x00
678 * @param[out] msg - Message will be written to this
679 * @return pldm_completion_codes
680 * @note Caller is responsible for memory alloc and dealloc of param
681 * 'msg.payload'
682 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800683int encode_get_state_sensor_readings_req(uint8_t instance_id,
684 uint16_t sensor_id,
685 bitfield8_t sensor_rearm,
686 uint8_t reserved,
687 struct pldm_msg *msg);
688
689/** @brief Decode GetStateSensorReadings response data
690 *
691 * @param[in] msg - Request message
692 * @param[in] payload_length - Length of response message payload
693 * @param[out] completion_code - PLDM completion code
694 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
695 * information that this command accesses
696 * @param[out] field - Each stateField is an instance of a stateField structure
697 * that is used to return the present operational state setting and the
698 * present state and event state for a particular set of sensor
699 * information contained within the state sensor
700 * @return pldm_completion_codes
701 */
702
703int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
704 size_t payload_length,
705 uint8_t *completion_code,
706 uint8_t *comp_sensor_count,
707 get_sensor_state_field *field);
708
Zahed Hossaind4abab12020-02-06 03:36:43 -0600709/* PlatformEventMessage */
710
711/** @brief Decode PlatformEventMessage request data
712 * @param[in] msg - Request message
713 * @param[in] payload_length - Length of response message payload
714 * @param[out] format_version - Version of the event format
715 * @param[out] tid - Terminus ID for the terminus that originated the event
716 * message
717 * @param[out] event_class - The class of event being sent
718 * @param[out] event_data_offset - Offset where the event data should be read
719 * from pldm msg
720 * @return pldm_completion_codes
721 */
722int decode_platform_event_message_req(const struct pldm_msg *msg,
723 size_t payload_length,
724 uint8_t *format_version, uint8_t *tid,
725 uint8_t *event_class,
726 size_t *event_data_offset);
727
728/** @brief Encode PlatformEventMessage response data
729 * @param[in] instance_id - Message's instance id
730 * @param[in] completion_code - PLDM completion code
731 * @param[in] status - Response status of the event message command
732 * @param[out] msg - Message will be written to this
733 * @return pldm_completion_codes
734 * @note Caller is responsible for memory alloc and dealloc of param
735 * 'msg.payload'
736 */
737int encode_platform_event_message_resp(uint8_t instance_id,
738 uint8_t completion_code, uint8_t status,
739 struct pldm_msg *msg);
740
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500741#ifdef __cplusplus
742}
743#endif
744
745#endif /* PLATFORM_H */