blob: ba0854c1a67a637e54824fa91676c935965e6b69 [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
Zahed Hossain1c861712020-03-04 08:55:19 -060031/* Minumum length of senson event data */
32#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
33#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
34#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
35#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
36#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
37#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
38#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
39#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
40
George Liu30b859f2020-01-07 15:03:22 +080041enum pldm_effecter_data_size {
42 PLDM_EFFECTER_DATA_SIZE_UINT8,
43 PLDM_EFFECTER_DATA_SIZE_SINT8,
44 PLDM_EFFECTER_DATA_SIZE_UINT16,
45 PLDM_EFFECTER_DATA_SIZE_SINT16,
46 PLDM_EFFECTER_DATA_SIZE_UINT32,
47 PLDM_EFFECTER_DATA_SIZE_SINT32
48};
49
Sampa Misra0db1dfa2019-03-19 00:15:31 -050050enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
51
52enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
53
Jolie Ku3557bad2020-03-02 16:22:57 +080054enum sensor_operational_state {
55 ENABLED = 0x00,
56 DISABLED = 0x01,
57 UNAVAILABLE = 0x02,
58 STATUSUNKNOWN = 0x03,
59 FAILED = 0x04,
60 INITIALIZING = 0x05,
61 SHUTTINGDOWN = 0x06,
62 INTEST = 0x07
63};
64
65enum present_state {
66 UNKNOWN = 0x0,
67 NORMAL = 0x01,
68 WARNING = 0x02,
69 CRITICAL = 0x03,
70 FATAL = 0x04,
71 LOWERWARNING = 0x05,
72 LOWERCRITICAL = 0x06,
73 LOWERFATAL = 0x07,
74 UPPERWARNING = 0x08,
75 UPPERCRITICAL = 0x09,
76 UPPERFATAL = 0x0a
77};
78
Sampa Misra0db1dfa2019-03-19 00:15:31 -050079enum pldm_platform_commands {
Jolie Ku3557bad2020-03-02 16:22:57 +080080 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +080081 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050082 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -050083 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -060084 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -050085};
86
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050087/** @brief PLDM PDR types
88 */
89enum pldm_pdr_types {
90 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -050091 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -060092 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050093};
94
95/** @brief PLDM effecter initialization schemes
96 */
97enum pldm_effecter_init {
98 PLDM_NO_INIT,
99 PLDM_USE_INIT_PDR,
100 PLDM_ENABLE_EFFECTER,
101 PLDM_DISABLE_EFECTER
102};
103
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530104/** @brief PLDM Platform M&C completion codes
105 */
106enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500107 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
108 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530109 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Sampa Misraa2fa0702019-05-31 01:28:55 -0500110 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530111};
112
Zahed Hossaind4abab12020-02-06 03:36:43 -0600113/** @brief PLDM Event types
114 */
115enum pldm_event_types {
116 PLDM_SENSOR_EVENT = 0x00,
117 PLDM_EFFECTER_EVENT = 0x01,
118 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
119 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
120 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
121 PLDM_MESSAGE_POLL_EVENT = 0x05,
122 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
123};
124
125/** @brief PLDM sensorEventClass states
126 */
127enum sensor_event_class_states {
128 PLDM_SENSOR_OP_STATE,
129 PLDM_STATE_SENSOR_STATE,
130 PLDM_NUMERIC_SENSOR_STATE
131};
132
133/** @brief PLDM sensor supported states
134 */
135enum pldm_sensor_operational_state {
136 PLDM_SENSOR_ENABLED,
137 PLDM_SENSOR_DISABLED,
138 PLDM_SENSOR_UNAVAILABLE,
139 PLDM_SENSOR_STATUSUNKOWN,
140 PLDM_SENSOR_FAILED,
141 PLDM_SENSOR_INITIALIZING,
142 PLDM_SENSOR_SHUTTINGDOWN,
143 PLDM_SENSOR_INTEST
144};
145
146/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
147 */
148enum pldm_pdr_repository_chg_event_data_format {
149 REFRESH_ENTIRE_REPOSITORY,
150 FORMAT_IS_PDR_TYPES,
151 FORMAT_IS_PDR_HANDLES
152};
153
Zahed Hossain1c861712020-03-04 08:55:19 -0600154/** @brief PLDM NumericSensorStatePresentReading data type
155 */
156enum pldm_sensor_readings_data_type {
157 PLDM_SENSOR_DATA_SIZE_UINT8,
158 PLDM_SENSOR_DATA_SIZE_SINT8,
159 PLDM_SENSOR_DATA_SIZE_UINT16,
160 PLDM_SENSOR_DATA_SIZE_SINT16,
161 PLDM_SENSOR_DATA_SIZE_UINT32,
162 PLDM_SENSOR_DATA_SIZE_SINT32
163};
164
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500165/** @struct pldm_pdr_hdr
166 *
167 * Structure representing PLDM common PDR header
168 */
169struct pldm_pdr_hdr {
170 uint32_t record_handle;
171 uint8_t version;
172 uint8_t type;
173 uint16_t record_change_num;
174 uint16_t length;
175} __attribute__((packed));
176
Deepak Kodihallidb914672020-02-07 02:47:45 -0600177/** @struct pldm_pdr_fru_record_set
178 *
179 * Structure representing PLDM FRU record set PDR
180 */
181struct pldm_pdr_fru_record_set {
182 uint16_t terminus_handle;
183 uint16_t fru_rsi;
184 uint16_t entity_type;
185 uint16_t entity_instance_num;
186 uint16_t container_id;
187} __attribute__((packed));
188
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500189/** @struct pldm_state_effecter_pdr
190 *
191 * Structure representing PLDM state effecter PDR
192 */
193struct pldm_state_effecter_pdr {
194 struct pldm_pdr_hdr hdr;
195 uint16_t terminus_handle;
196 uint16_t effecter_id;
197 uint16_t entity_type;
198 uint16_t entity_instance;
199 uint16_t container_id;
200 uint16_t effecter_semantic_id;
201 uint8_t effecter_init;
202 bool8_t has_description_pdr;
203 uint8_t composite_effecter_count;
204 uint8_t possible_states[1];
205} __attribute__((packed));
206
207/** @struct state_effecter_possible_states
208 *
209 * Structure representing state enums for state effecter
210 */
211struct state_effecter_possible_states {
212 uint16_t state_set_id;
213 uint8_t possible_states_size;
214 bitfield8_t states[1];
215} __attribute__((packed));
216
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500217/** @struct set_effecter_state_field
218 *
219 * Structure representing a stateField in SetStateEffecterStates command */
220
221typedef struct state_field_for_state_effecter_set {
222 uint8_t set_request; //!< Whether to change the state
223 uint8_t effecter_state; //!< Expected state of the effecter
224} __attribute__((packed)) set_effecter_state_field;
225
Jolie Ku3557bad2020-03-02 16:22:57 +0800226/** @struct get_sensor_readings_field
227 *
228 * Structure representing a stateField in GetStateSensorReadings command */
229
230typedef struct state_field_for_get_state_sensor_readings {
231 uint8_t sensor_op_state; //!< The state of the sensor itself
232 uint8_t present_state; //!< Return a state value
233 uint8_t previous_state; //!< The state that the presentState was entered
234 //! from. This must be different from the
235 //! present state
236 uint8_t event_state; //!< Return a state value from a PLDM State Set
237 //! that is associated with the sensor
238} __attribute__((packed)) get_sensor_state_field;
239
Priyanga7257fdf2019-06-10 01:59:45 -0500240/** @struct PLDM_SetStateEffecterStates_Request
241 *
242 * Structure representing PLDM set state effecter states request.
243 */
244struct pldm_set_state_effecter_states_req {
245 uint16_t effecter_id;
246 uint8_t comp_effecter_count;
247 set_effecter_state_field field[8];
248} __attribute__((packed));
249
Sampa Misra7fcfb662019-05-08 13:13:53 -0500250/** @struct pldm_get_pdr_resp
251 *
252 * structure representing GetPDR response packet
253 * transfer CRC is not part of the structure and will be
254 * added at the end of last packet in multipart transfer
255 */
256struct pldm_get_pdr_resp {
257 uint8_t completion_code;
258 uint32_t next_record_handle;
259 uint32_t next_data_transfer_handle;
260 uint8_t transfer_flag;
261 uint16_t response_count;
262 uint8_t record_data[1];
263} __attribute__((packed));
264
265/** @struct pldm_get_pdr_req
266 *
267 * structure representing GetPDR request packet
268 */
269struct pldm_get_pdr_req {
270 uint32_t record_handle;
271 uint32_t data_transfer_handle;
272 uint8_t transfer_op_flag;
273 uint16_t request_count;
274 uint16_t record_change_number;
275} __attribute__((packed));
276
George Liu30b859f2020-01-07 15:03:22 +0800277/** @struct pldm_set_numeric_effecter_value_req
278 *
279 * structure representing SetNumericEffecterValue request packet
280 */
281struct pldm_set_numeric_effecter_value_req {
282 uint16_t effecter_id;
283 uint8_t effecter_data_size;
284 uint8_t effecter_value[1];
285} __attribute__((packed));
286
Jolie Ku3557bad2020-03-02 16:22:57 +0800287/** @struct pldm_get_state_sensor_readings_req
288 *
289 * Structure representing PLDM get state sensor readings request.
290 */
291struct pldm_get_state_sensor_readings_req {
292 uint16_t sensor_id;
293 bitfield8_t sensor_rearm;
294 uint8_t reserved;
295} __attribute__((packed));
296
297/** @struct pldm_get_state_sensor_readings_resp
298 *
299 * Structure representing PLDM get state sensor readings response.
300 */
301struct pldm_get_state_sensor_readings_resp {
302 uint8_t completion_code;
303 uint8_t comp_sensor_count;
304 get_sensor_state_field field[1];
305} __attribute__((packed));
306
Zahed Hossaind4abab12020-02-06 03:36:43 -0600307/** @struct pldm_sensor_event
308 *
309 * structure representing sensorEventClass
310 */
311struct pldm_sensor_event_data {
312 uint16_t sensor_id;
313 uint8_t sensor_event_class_type;
314 uint8_t event_class[1];
315} __attribute__((packed));
316
317/** @struct pldm_state_sensor_state
318 *
319 * structure representing sensorEventClass for stateSensorState
320 */
321struct pldm_sensor_event_state_sensor_state {
322 uint8_t sensor_offset;
323 uint8_t event_state;
324 uint8_t previous_event_state;
325} __attribute__((packed));
326
327/** @struct pldm_sensor_event_numeric_sensor_state
328 *
329 * structure representing sensorEventClass for stateSensorState
330 */
331struct pldm_sensor_event_numeric_sensor_state {
332 uint8_t event_state;
333 uint8_t previous_event_state;
334 uint8_t sensor_data_size;
335 uint8_t present_reading[1];
336} __attribute__((packed));
337
338/** @struct pldm_sensor_event_sensor_op_state
339 *
340 * structure representing sensorEventClass for SensorOpState
341 */
342struct pldm_sensor_event_sensor_op_state {
343 uint8_t present_op_state;
344 uint8_t previous_op_state;
345} __attribute__((packed));
346
347/** @struct pldm_platform_event_message_req
348 *
349 * structure representing PlatformEventMessage command request data
350 */
351struct pldm_platform_event_message_req {
352 uint8_t format_version;
353 uint8_t tid;
354 uint8_t event_class;
355 uint8_t event_data[1];
356} __attribute__((packed));
357
358/** @struct pldm_platform_event_message_response
359 *
360 * structure representing PlatformEventMessage command response data
361 */
362struct pldm_platform_event_message_resp {
363 uint8_t completion_code;
364 uint8_t status;
365} __attribute__((packed));
366
367/** @struct pldm_pdr_repository_chg_event_data
368 *
369 * structure representing pldmPDRRepositoryChgEvent class eventData
370 */
371struct pldm_pdr_repository_chg_event_data {
372 uint8_t event_data_format;
373 uint8_t number_of_change_records;
374 uint8_t change_records[1];
375} __attribute__((packed));
376
377/** @struct pldm_pdr_repository_chg_event_change_record_data
378 *
379 * structure representing pldmPDRRepositoryChgEvent class eventData's change
380 * record data
381 */
382struct pldm_pdr_repository_change_record_data {
383 uint8_t event_data_operation;
384 uint8_t number_of_change_entries;
385 uint32_t change_entry[1];
386} __attribute__((packed));
387
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500388/* Responder */
389
George Liu30b859f2020-01-07 15:03:22 +0800390/* SetNumericEffecterValue */
391
392/** @brief Decode SetNumericEffecterValue request data
393 *
394 * @param[in] msg - Request message
395 * @param[in] payload_length - Length of request message payload
396 * @param[out] effecter_id - used to identify and access the effecter
397 * @param[out] effecter_data_size - The bit width and format of the setting
398 * value for the effecter.
399 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
400 * @param[out] effecter_value - The setting value of numeric effecter being
401 * requested.
402 * @return pldm_completion_codes
403 */
404int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
405 size_t payload_length,
406 uint16_t *effecter_id,
407 uint8_t *effecter_data_size,
408 uint8_t *effecter_value);
409
410/** @brief Create a PLDM response message for SetNumericEffecterValue
411 *
412 * @param[in] instance_id - Message's instance id
413 * @param[in] completion_code - PLDM completion code
414 * @param[out] msg - Message will be written to this
415 * @param[in] payload_length - Length of request message payload
416 * @return pldm_completion_codes
417 * @note Caller is responsible for memory alloc and dealloc of param
418 * 'msg.body.payload'
419 */
420int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
421 uint8_t completion_code,
422 struct pldm_msg *msg,
423 size_t payload_length);
424
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500425/* SetStateEffecterStates */
426
427/** @brief Create a PLDM response message for SetStateEffecterStates
428 *
429 * @param[in] instance_id - Message's instance id
430 * @param[in] completion_code - PLDM completion code
431 * @param[out] msg - Message will be written to this
432 * @return pldm_completion_codes
433 * @note Caller is responsible for memory alloc and dealloc of param
434 * 'msg.body.payload'
435 */
436
437int encode_set_state_effecter_states_resp(uint8_t instance_id,
438 uint8_t completion_code,
439 struct pldm_msg *msg);
440
441/** @brief Decode SetStateEffecterStates request data
442 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500443 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500444 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500445 * @param[out] effecter_id - used to identify and access the effecter
446 * @param[out] comp_effecter_count - number of individual sets of effecter
447 * information. Upto eight sets of state effecter info can be accessed
448 * for a given effecter.
449 * @param[out] field - each unit is an instance of the stateFileld structure
450 * that is used to set the requested state for a particular effecter
451 * within the state effecter. This field holds the starting address of
452 * the stateField values. The user is responsible to allocate the
453 * memory prior to calling this command. Since the state field count is
454 * not known in advance, the user should allocate the maximum size
455 * always, which is 8 in number.
456 * @return pldm_completion_codes
457 */
vkaverapa6575b82019-04-03 05:33:52 -0500458
Zahed Hossain223a73d2019-07-04 12:46:18 -0500459int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500460 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500461 uint16_t *effecter_id,
462 uint8_t *comp_effecter_count,
463 set_effecter_state_field *field);
464
Sampa Misra7fcfb662019-05-08 13:13:53 -0500465/* GetPDR */
466
467/** @brief Create a PLDM response message for GetPDR
468 *
469 * @param[in] instance_id - Message's instance id
470 * @param[in] completion_code - PLDM completion code
471 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
472 * the PDR Repository
473 * @param[in] next_data_transfer_hndl - A handle that identifies the next
474 * portion of the PDR data to be transferred, if any
475 * @param[in] transfer_flag - Indicates the portion of PDR data being
476 * transferred
477 * @param[in] resp_cnt - The number of recordData bytes returned in this
478 * response
479 * @param[in] record_data - PDR data bytes of length resp_cnt
480 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
481 * in the last part of a PDR being transferred
482 * @param[out] msg - Message will be written to this
483 * @return pldm_completion_codes
484 * @note Caller is responsible for memory alloc and dealloc of param
485 * 'msg.payload'
486 */
487int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
488 uint32_t next_record_hndl,
489 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
490 uint16_t resp_cnt, const uint8_t *record_data,
491 uint8_t transfer_crc, struct pldm_msg *msg);
492
493/** @brief Decode GetPDR request data
494 *
495 * @param[in] msg - Request message
496 * @param[in] payload_length - Length of request message payload
497 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
498 * @param[out] data_transfer_hndl - Handle used to identify a particular
499 * multipart PDR data transfer operation
500 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
501 * portion of transfer
502 * @param[out] request_cnt - The maximum number of record bytes requested
503 * @param[out] record_chg_num - Used to determine whether the PDR has changed
504 * while PDR transfer is going on
505 * @return pldm_completion_codes
506 */
507
508int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
509 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
510 uint8_t *transfer_op_flag, uint16_t *request_cnt,
511 uint16_t *record_chg_num);
512
Jolie Ku3557bad2020-03-02 16:22:57 +0800513/* GetStateSensorReadings */
514
515/** @brief Decode GetStateSensorReadings request data
516 *
517 * @param[in] msg - Request message
518 * @param[in] payload_length - Length of request message payload
519 * @param[out] sensor_id - used to identify and access the simple or composite
520 * sensor
521 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
522 * particular sensor within the state sensor, where bit [0] corresponds
523 * to the first state sensor (sensor offset 0) and bit [7] corresponds
524 * to the eighth sensor (sensor offset 7), sequentially.
525 * @param[out] reserved - value: 0x00
526 * @return pldm_completion_codes
527 */
528
529int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
530 size_t payload_length,
531 uint16_t *sensor_id,
532 bitfield8_t *sensor_rearm,
533 uint8_t *reserved);
534
535/** @brief Encode GetStateSensorReadings response data
536 *
537 * @param[in] instance_id - Message's instance id
538 * @param[in] completion_code - PLDM completion code
539 * @param[out] comp_sensor_count - The number of individual sets of sensor
540 * information that this command accesses
541 * @param[out] field - Each stateField is an instance of a stateField structure
542 * that is used to return the present operational state setting and the
543 * present state and event state for a particular set of sensor
544 * information contained within the state sensor
545 * @param[out] msg - Message will be written to this
546 * @return pldm_completion_codes
547 */
548
549int encode_get_state_sensor_readings_resp(uint8_t instance_id,
550 uint8_t completion_code,
551 uint8_t comp_sensor_count,
552 get_sensor_state_field *field,
553 struct pldm_msg *msg);
554
Sampa Misra7fcfb662019-05-08 13:13:53 -0500555/* Requester */
556
George Liu820a9a52019-11-26 14:43:59 +0800557/* GetPDR */
558
559/** @brief Create a PLDM request message for GetPDR
560 *
561 * @param[in] instance_id - Message's instance id
562 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
563 * @param[in] data_transfer_hndl - Handle used to identify a particular
564 * multipart PDR data transfer operation
565 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
566 * portion of transfer
567 * @param[in] request_cnt - The maximum number of record bytes requested
568 * @param[in] record_chg_num - Used to determine whether the PDR has changed
569 * while PDR transfer is going on
570 * @param[out] msg - Message will be written to this
571 * @param[in] payload_length - Length of request message payload
572 * @return pldm_completion_codes
573 * @note Caller is responsible for memory alloc and dealloc of param
574 * 'msg.payload'
575 */
576int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
577 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
578 uint16_t request_cnt, uint16_t record_chg_num,
579 struct pldm_msg *msg, size_t payload_length);
580
581/** @brief Decode GetPDR response data
582 *
George Liu684a7162019-12-06 15:10:52 +0800583 * Note:
584 * * If the return value is not PLDM_SUCCESS, it represents a
585 * transport layer error.
586 * * If the completion_code value is not PLDM_SUCCESS, it represents a
587 * protocol layer error and all the out-parameters are invalid.
588 *
George Liu820a9a52019-11-26 14:43:59 +0800589 * @param[in] msg - Request message
590 * @param[in] payload_length - Length of request message payload
591 * @param[out] completion_code - PLDM completion code
592 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
593 * the PDR Repository
594 * @param[out] next_data_transfer_hndl - A handle that identifies the next
595 * portion of the PDR data to be transferred, if any
596 * @param[out] transfer_flag - Indicates the portion of PDR data being
597 * transferred
598 * @param[out] resp_cnt - The number of recordData bytes returned in this
599 * response
600 * @param[out] record_data - PDR data bytes of length resp_cnt
601 * @param[in] record_data_length - Length of record_data
602 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
603 * in the last part of a PDR being transferred
604 * @return pldm_completion_codes
605 */
606int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
607 uint8_t *completion_code, uint32_t *next_record_hndl,
608 uint32_t *next_data_transfer_hndl,
609 uint8_t *transfer_flag, uint16_t *resp_cnt,
610 uint8_t *record_data, size_t record_data_length,
611 uint8_t *transfer_crc);
612
Sampa Misra7fcfb662019-05-08 13:13:53 -0500613/* SetStateEffecterStates */
614
vkaverap98a2c192019-04-03 05:33:52 -0500615/** @brief Create a PLDM request message for SetStateEffecterStates
616 *
617 * @param[in] instance_id - Message's instance id
618 * @param[in] effecter_id - used to identify and access the effecter
619 * @param[in] comp_effecter_count - number of individual sets of effecter
620 * information. Upto eight sets of state effecter info can be accessed
621 * for a given effecter.
622 * @param[in] field - each unit is an instance of the stateField structure
623 * that is used to set the requested state for a particular effecter
624 * within the state effecter. This field holds the starting address of
625 * the stateField values. The user is responsible to allocate the
626 * memory prior to calling this command. The user has to allocate the
627 * field parameter as sizeof(set_effecter_state_field) *
628 * comp_effecter_count
629 * @param[out] msg - Message will be written to this
630 * @return pldm_completion_codes
631 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500632 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500633 */
634
635int encode_set_state_effecter_states_req(uint8_t instance_id,
636 uint16_t effecter_id,
637 uint8_t comp_effecter_count,
638 set_effecter_state_field *field,
639 struct pldm_msg *msg);
640
641/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800642 *
643 * Note:
644 * * If the return value is not PLDM_SUCCESS, it represents a
645 * transport layer error.
646 * * If the completion_code value is not PLDM_SUCCESS, it represents a
647 * protocol layer error and all the out-parameters are invalid.
648 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500649 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500650 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500651 * @param[out] completion_code - PLDM completion code
652 * @return pldm_completion_codes
653 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500654int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500655 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500656 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800657
658/* SetNumericEffecterValue */
659
660/** @brief Create a PLDM request message for SetNumericEffecterValue
661 *
662 * @param[in] instance_id - Message's instance id
663 * @param[in] effecter_id - used to identify and access the effecter
664 * @param[in] effecter_data_size - The bit width and format of the setting
665 * value for the effecter.
666 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
667 * @param[in] effecter_value - The setting value of numeric effecter being
668 * requested.
669 * @param[in] payload_length - Length of request message payload
670 * @param[out] msg - Message will be written to this
671 * @return pldm_completion_codes
672 * @note Caller is responsible for memory alloc and dealloc of param
673 * 'msg.payload'
674 */
675int encode_set_numeric_effecter_value_req(
676 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
677 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
678
679/** @brief Decode SetNumericEffecterValue response data
680 * @param[in] msg - Request message
681 * @param[in] payload_length - Length of response message payload
682 * @param[out] completion_code - PLDM completion code
683 * @return pldm_completion_codes
684 */
685int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
686 size_t payload_length,
687 uint8_t *completion_code);
688
Jolie Ku3557bad2020-03-02 16:22:57 +0800689/** @brief Create a PLDM request message for GetStateSensorReadings
690 *
691 * @param[in] instance_id - Message's instance id
692 * @param[in] sensor_id - used to identify and access the simple or composite
693 * sensor
694 * @param[in] sensorRearm - Each bit location in this field corresponds to a
695 * particular sensor within the state sensor, where bit [0] corresponds
696 * to the first state sensor (sensor offset 0) and bit [7] corresponds
697 * to the eighth sensor (sensor offset 7), sequentially
698 * @param[in] reserved - value: 0x00
699 * @param[out] msg - Message will be written to this
700 * @return pldm_completion_codes
701 * @note Caller is responsible for memory alloc and dealloc of param
702 * 'msg.payload'
703 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800704int encode_get_state_sensor_readings_req(uint8_t instance_id,
705 uint16_t sensor_id,
706 bitfield8_t sensor_rearm,
707 uint8_t reserved,
708 struct pldm_msg *msg);
709
710/** @brief Decode GetStateSensorReadings response data
711 *
712 * @param[in] msg - Request message
713 * @param[in] payload_length - Length of response message payload
714 * @param[out] completion_code - PLDM completion code
715 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
716 * information that this command accesses
717 * @param[out] field - Each stateField is an instance of a stateField structure
718 * that is used to return the present operational state setting and the
719 * present state and event state for a particular set of sensor
720 * information contained within the state sensor
721 * @return pldm_completion_codes
722 */
723
724int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
725 size_t payload_length,
726 uint8_t *completion_code,
727 uint8_t *comp_sensor_count,
728 get_sensor_state_field *field);
729
Zahed Hossaind4abab12020-02-06 03:36:43 -0600730/* PlatformEventMessage */
731
732/** @brief Decode PlatformEventMessage request data
733 * @param[in] msg - Request message
734 * @param[in] payload_length - Length of response message payload
735 * @param[out] format_version - Version of the event format
736 * @param[out] tid - Terminus ID for the terminus that originated the event
737 * message
738 * @param[out] event_class - The class of event being sent
739 * @param[out] event_data_offset - Offset where the event data should be read
740 * from pldm msg
741 * @return pldm_completion_codes
742 */
743int decode_platform_event_message_req(const struct pldm_msg *msg,
744 size_t payload_length,
745 uint8_t *format_version, uint8_t *tid,
746 uint8_t *event_class,
747 size_t *event_data_offset);
748
749/** @brief Encode PlatformEventMessage response data
750 * @param[in] instance_id - Message's instance id
751 * @param[in] completion_code - PLDM completion code
752 * @param[in] status - Response status of the event message command
753 * @param[out] msg - Message will be written to this
754 * @return pldm_completion_codes
755 * @note Caller is responsible for memory alloc and dealloc of param
756 * 'msg.payload'
757 */
758int encode_platform_event_message_resp(uint8_t instance_id,
759 uint8_t completion_code, uint8_t status,
760 struct pldm_msg *msg);
761
Zahed Hossain1c861712020-03-04 08:55:19 -0600762/** @brief Decode sensorEventData response data
763 *
764 * @param[in] event_data - event data from the response message
765 * @param[in] event_data_length - length of the event data
766 * @param[out] sensor_id - sensorID value of the sensor
767 * @param[out] sensor_event_class_type - Type of sensor event class
768 * @param[out] event_class_data_offset - Offset where the event class data
769 * should be read from event data
770 * @return pldm_completion_codes
771 * @note Caller is responsible for memory alloc and dealloc of param
772 * 'event_data'
773 */
774int decode_sensor_event_data(const uint8_t *event_data,
775 size_t event_data_length, uint16_t *sensor_id,
776 uint8_t *sensor_event_class_type,
777 size_t *event_class_data_offset);
778
779/** @brief Decode sensorOpState response data
780 *
781 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
782 * @param[in] sensor_data_length - Length of sensor_data
783 * @param[out] present_op_state - The sensorOperationalState value from the
784 * state change that triggered the event message
785 * @param[out] previous_op_state - The sensorOperationalState value for the
786 * state from which the present state was entered
787 * @return pldm_completion_codes
788 * @note Caller is responsible for memory alloc and dealloc of param
789 * 'sensor_data'
790 */
791int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
792 uint8_t *present_op_state,
793 uint8_t *previous_op_state);
794
795/** @brief Decode stateSensorState response data
796 *
797 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
798 * @param[in] sensor_data_length - Length of sensor_data
799 * @param[out] sensor_offset - Identifies which state sensor within a composite
800 * state sensor the event is being returned for
801 * @param[out] event_state - The event state value from the state change that
802 * triggered the event message
803 * @param[out] previous_event_state - The event state value for the state from
804 * which the present event state was entered
805 * @return pldm_completion_codes
806 * @note Caller is responsible for memory alloc and dealloc of param
807 * 'sensor_data'
808 */
809int decode_state_sensor_data(const uint8_t *sensor_data,
810 size_t sensor_data_length, uint8_t *sensor_offset,
811 uint8_t *event_state,
812 uint8_t *previous_event_state);
813
814/** @brief Decode numericSensorState response data
815 *
816 * @param[in] sensor_data - sensor_data for sensorEventClass =
817 * numericSensorState
818 * @param[in] sensor_data_length - Length of sensor_data
819 * @param[out] event_state - The eventState value from the state change that
820 * triggered the event message
821 * @param[out] previous_event_state - The eventState value for the state from
822 * which the present state was entered
823 * @param[out] sensor_data_size - The bit width and format of reading and
824 * threshold values that the sensor returns
825 * @param[out] present_reading - The present value indicated by the sensor
826 * @return pldm_completion_codes
827 * @note Caller is responsible for memory alloc and dealloc of param
828 * 'sensor_data'
829 */
830int decode_numeric_sensor_data(const uint8_t *sensor_data,
831 size_t sensor_data_length, uint8_t *event_state,
832 uint8_t *previous_event_state,
833 uint8_t *sensor_data_size,
834 uint32_t *present_reading);
835
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500836#ifdef __cplusplus
837}
838#endif
839
840#endif /* PLATFORM_H */