blob: cafd47c52d30c0c68e0fac19c1512b39fc064252 [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"
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -050012#include "pdr.h"
Sampa Misra0db1dfa2019-03-19 00:15:31 -050013
14/* Maximum size for request */
15#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
Jolie Ku3557bad2020-03-02 16:22:57 +080016#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
Jolie Ku6787f172020-03-19 11:15:53 +080017#define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
Jolie Kuf798c8f2020-04-14 11:18:06 +080018#define PLDM_GET_SENSOR_READING_REQ_BYTES 4
Sampa Misra0db1dfa2019-03-19 00:15:31 -050019/* Response lengths are inclusive of completion code */
20#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080021#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050022
George Liu30b859f2020-01-07 15:03:22 +080023#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
24#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
25
Sampa Misra7fcfb662019-05-08 13:13:53 -050026#define PLDM_GET_PDR_REQ_BYTES 13
27/* Minimum response length */
28#define PLDM_GET_PDR_MIN_RESP_BYTES 12
Jolie Ku6787f172020-03-19 11:15:53 +080029#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
Jolie Kuf798c8f2020-04-14 11:18:06 +080030#define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8
Sampa Misra7fcfb662019-05-08 13:13:53 -050031
Zahed Hossaind4abab12020-02-06 03:36:43 -060032/* Minimum length for PLDM PlatformEventMessage request */
33#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
34#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
Tom Joseph56e45c52020-03-16 10:01:45 +053035#define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2
Zahed Hossaind4abab12020-02-06 03:36:43 -060036
Zahed Hossain1c861712020-03-04 08:55:19 -060037/* Minumum length of senson event data */
38#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
39#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
40#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
41#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
42#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
43#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
44#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
45#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
46
Zahed Hossain9be087c2020-04-02 02:26:41 -050047/* Minimum length of data for pldmPDRRepositoryChgEvent */
48#define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2
49#define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2
50
George Liu30b859f2020-01-07 15:03:22 +080051enum pldm_effecter_data_size {
52 PLDM_EFFECTER_DATA_SIZE_UINT8,
53 PLDM_EFFECTER_DATA_SIZE_SINT8,
54 PLDM_EFFECTER_DATA_SIZE_UINT16,
55 PLDM_EFFECTER_DATA_SIZE_SINT16,
56 PLDM_EFFECTER_DATA_SIZE_UINT32,
57 PLDM_EFFECTER_DATA_SIZE_SINT32
58};
59
George Liu456c9a22020-01-13 11:36:22 +080060enum pldm_range_field_format {
61 PLDM_RANGE_FIELD_FORMAT_UINT8,
62 PLDM_RANGE_FIELD_FORMAT_SINT8,
63 PLDM_RANGE_FIELD_FORMAT_UINT16,
64 PLDM_RANGE_FIELD_FORMAT_SINT16,
65 PLDM_RANGE_FIELD_FORMAT_UINT32,
66 PLDM_RANGE_FIELD_FORMAT_SINT32,
67 PLDM_RANGE_FIELD_FORMAT_REAL32
68};
69
Sampa Misra0db1dfa2019-03-19 00:15:31 -050070enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
71
72enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
73
Jolie Ku3557bad2020-03-02 16:22:57 +080074enum sensor_operational_state {
75 ENABLED = 0x00,
76 DISABLED = 0x01,
77 UNAVAILABLE = 0x02,
78 STATUSUNKNOWN = 0x03,
79 FAILED = 0x04,
80 INITIALIZING = 0x05,
81 SHUTTINGDOWN = 0x06,
82 INTEST = 0x07
83};
84
85enum present_state {
86 UNKNOWN = 0x0,
87 NORMAL = 0x01,
88 WARNING = 0x02,
89 CRITICAL = 0x03,
90 FATAL = 0x04,
91 LOWERWARNING = 0x05,
92 LOWERCRITICAL = 0x06,
93 LOWERFATAL = 0x07,
94 UPPERWARNING = 0x08,
95 UPPERCRITICAL = 0x09,
96 UPPERFATAL = 0x0a
97};
98
Jolie Kuf798c8f2020-04-14 11:18:06 +080099enum pldm_sensor_event_message_enable {
100 PLDM_NO_EVENT_GENERATION,
101 PLDM_EVENTS_DISABLED,
102 PLDM_EVENTS_ENABLED,
103 PLDM_OP_EVENTS_ONLY_ENABLED,
104 PLDM_STATE_EVENTS_ONLY_ENABLED
105};
106
Jolie Ku6787f172020-03-19 11:15:53 +0800107enum pldm_effecter_oper_state {
108 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
109 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
110 EFFECTER_OPER_STATE_DISABLED,
111 EFFECTER_OPER_STATE_UNAVAILABLE,
112 EFFECTER_OPER_STATE_STATUSUNKNOWN,
113 EFFECTER_OPER_STATE_FAILED,
114 EFFECTER_OPER_STATE_INITIALIZING,
115 EFFECTER_OPER_STATE_SHUTTINGDOWN,
116 EFFECTER_OPER_STATE_INTEST
117};
118
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500119enum pldm_platform_commands {
Jolie Kuf798c8f2020-04-14 11:18:06 +0800120 PLDM_GET_SENSOR_READING = 0x11,
Jolie Ku3557bad2020-03-02 16:22:57 +0800121 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +0800122 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +0800123 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500124 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -0500125 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600126 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500127};
128
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500129/** @brief PLDM PDR types
130 */
131enum pldm_pdr_types {
George Liu456c9a22020-01-13 11:36:22 +0800132 PLDM_NUMERIC_EFFECTER_PDR = 9,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500133 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500134 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600135 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500136};
137
138/** @brief PLDM effecter initialization schemes
139 */
140enum pldm_effecter_init {
141 PLDM_NO_INIT,
142 PLDM_USE_INIT_PDR,
143 PLDM_ENABLE_EFFECTER,
144 PLDM_DISABLE_EFECTER
145};
146
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530147/** @brief PLDM Platform M&C completion codes
148 */
149enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500150 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
151 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500152
153 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
154 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530155 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500156 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
157 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
158
Sampa Misraa2fa0702019-05-31 01:28:55 -0500159 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530160};
161
Zahed Hossaind4abab12020-02-06 03:36:43 -0600162/** @brief PLDM Event types
163 */
164enum pldm_event_types {
165 PLDM_SENSOR_EVENT = 0x00,
166 PLDM_EFFECTER_EVENT = 0x01,
167 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
168 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
169 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
170 PLDM_MESSAGE_POLL_EVENT = 0x05,
171 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
172};
173
174/** @brief PLDM sensorEventClass states
175 */
176enum sensor_event_class_states {
177 PLDM_SENSOR_OP_STATE,
178 PLDM_STATE_SENSOR_STATE,
179 PLDM_NUMERIC_SENSOR_STATE
180};
181
182/** @brief PLDM sensor supported states
183 */
184enum pldm_sensor_operational_state {
185 PLDM_SENSOR_ENABLED,
186 PLDM_SENSOR_DISABLED,
187 PLDM_SENSOR_UNAVAILABLE,
188 PLDM_SENSOR_STATUSUNKOWN,
189 PLDM_SENSOR_FAILED,
190 PLDM_SENSOR_INITIALIZING,
191 PLDM_SENSOR_SHUTTINGDOWN,
192 PLDM_SENSOR_INTEST
193};
194
195/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
196 */
197enum pldm_pdr_repository_chg_event_data_format {
198 REFRESH_ENTIRE_REPOSITORY,
199 FORMAT_IS_PDR_TYPES,
200 FORMAT_IS_PDR_HANDLES
201};
202
Zahed Hossain9be087c2020-04-02 02:26:41 -0500203/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
204 * eventDataOperation
205 */
206enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
207 PLDM_REFRESH_ALL_RECORDS,
208 PLDM_RECORDS_DELETED,
209 PLDM_RECORDS_ADDED,
210 PLDM_RECORDS_MODIFIED
211};
212
Zahed Hossain1c861712020-03-04 08:55:19 -0600213/** @brief PLDM NumericSensorStatePresentReading data type
214 */
215enum pldm_sensor_readings_data_type {
216 PLDM_SENSOR_DATA_SIZE_UINT8,
217 PLDM_SENSOR_DATA_SIZE_SINT8,
218 PLDM_SENSOR_DATA_SIZE_UINT16,
219 PLDM_SENSOR_DATA_SIZE_SINT16,
220 PLDM_SENSOR_DATA_SIZE_UINT32,
221 PLDM_SENSOR_DATA_SIZE_SINT32
222};
223
Tom Joseph56e45c52020-03-16 10:01:45 +0530224/** @brief PLDM PlatformEventMessage response status
225 */
226enum pldm_platform_event_status {
227 PLDM_EVENT_NO_LOGGING = 0x00,
228 PLDM_EVENT_LOGGING_DISABLED = 0x01,
229 PLDM_EVENT_LOG_FULL = 0x02,
230 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
231 PLDM_EVENT_LOGGED = 0x04,
232 PLDM_EVENT_LOGGING_REJECTED = 0x05
233};
234
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500235/** @struct pldm_pdr_hdr
236 *
237 * Structure representing PLDM common PDR header
238 */
239struct pldm_pdr_hdr {
240 uint32_t record_handle;
241 uint8_t version;
242 uint8_t type;
243 uint16_t record_change_num;
244 uint16_t length;
245} __attribute__((packed));
246
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500247/** @struct pldm_pdr_entity_association
248 *
249 * Structure representing PLDM Entity Association PDR
250 */
251struct pldm_pdr_entity_association {
252 uint16_t container_id;
253 uint8_t association_type;
254 pldm_entity container;
255 uint8_t num_children;
256 pldm_entity children[1];
257} __attribute__((packed));
258
Deepak Kodihallidb914672020-02-07 02:47:45 -0600259/** @struct pldm_pdr_fru_record_set
260 *
261 * Structure representing PLDM FRU record set PDR
262 */
263struct pldm_pdr_fru_record_set {
264 uint16_t terminus_handle;
265 uint16_t fru_rsi;
266 uint16_t entity_type;
267 uint16_t entity_instance_num;
268 uint16_t container_id;
269} __attribute__((packed));
270
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500271/** @struct pldm_state_effecter_pdr
272 *
273 * Structure representing PLDM state effecter PDR
274 */
275struct pldm_state_effecter_pdr {
276 struct pldm_pdr_hdr hdr;
277 uint16_t terminus_handle;
278 uint16_t effecter_id;
279 uint16_t entity_type;
280 uint16_t entity_instance;
281 uint16_t container_id;
282 uint16_t effecter_semantic_id;
283 uint8_t effecter_init;
284 bool8_t has_description_pdr;
285 uint8_t composite_effecter_count;
286 uint8_t possible_states[1];
287} __attribute__((packed));
288
George Liu456c9a22020-01-13 11:36:22 +0800289/** @union union_effecter_data_size
290 *
291 * The bit width and format of reading and threshold values that the effecter
292 * returns.
293 * Refer to: DSP0248_1.2.0: 28.11 Table 87
294 */
295typedef union {
296 uint8_t value_u8;
297 int8_t value_s8;
298 uint16_t value_u16;
299 int16_t value_s16;
300 uint32_t value_u32;
301 int32_t value_s32;
302} union_effecter_data_size;
303
304/** @union union_range_field_format
305 *
306 * Indicates the format used for the nominalValue, normalMax, and normalMin
307 * fields.
308 * Refer to: DSP0248_1.2.0: 28.11 Table 87
309 */
310typedef union {
311 uint8_t value_u8;
312 int8_t value_s8;
313 uint16_t value_u16;
314 int16_t value_s16;
315 uint32_t value_u32;
316 int32_t value_s32;
317 real32_t value_f32;
318} union_range_field_format;
319
320/** @struct pldm_numeric_effecter_value_pdr
321 *
322 * Structure representing PLDM numeric effecter value PDR
323 */
324struct pldm_numeric_effecter_value_pdr {
325 struct pldm_pdr_hdr hdr;
326 uint16_t terminus_handle;
327 uint16_t effecter_id;
328 uint16_t entity_type;
329 uint16_t entity_instance;
330 uint16_t container_id;
331 uint16_t effecter_semantic_id;
332 uint8_t effecter_init;
333 bool8_t effecter_auxiliary_names;
334 uint8_t base_unit;
335 int8_t unit_modifier;
336 uint8_t rate_unit;
337 uint8_t base_oem_unit_handle;
338 uint8_t aux_unit;
339 int8_t aux_unit_modifier;
340 uint8_t aux_rate_unit;
341 uint8_t aux_oem_unit_handle;
342 bool8_t is_linear;
343 uint8_t effecter_data_size;
344 real32_t resolution;
345 real32_t offset;
346 uint16_t accuracy;
347 uint8_t plus_tolerance;
348 uint8_t minus_tolerance;
349 real32_t state_transition_interval;
350 real32_t transition_interval;
351 union_effecter_data_size max_set_table;
352 union_effecter_data_size min_set_table;
353 uint8_t range_field_format;
354 bitfield8_t range_field_support;
355 union_range_field_format nominal_value;
356 union_range_field_format normal_max;
357 union_range_field_format normal_min;
358 union_range_field_format rated_max;
359 union_range_field_format rated_min;
360} __attribute__((packed));
361
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500362/** @struct state_effecter_possible_states
363 *
364 * Structure representing state enums for state effecter
365 */
366struct state_effecter_possible_states {
367 uint16_t state_set_id;
368 uint8_t possible_states_size;
369 bitfield8_t states[1];
370} __attribute__((packed));
371
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500372/** @struct set_effecter_state_field
373 *
374 * Structure representing a stateField in SetStateEffecterStates command */
375
376typedef struct state_field_for_state_effecter_set {
377 uint8_t set_request; //!< Whether to change the state
378 uint8_t effecter_state; //!< Expected state of the effecter
379} __attribute__((packed)) set_effecter_state_field;
380
Jolie Ku3557bad2020-03-02 16:22:57 +0800381/** @struct get_sensor_readings_field
382 *
383 * Structure representing a stateField in GetStateSensorReadings command */
384
385typedef struct state_field_for_get_state_sensor_readings {
386 uint8_t sensor_op_state; //!< The state of the sensor itself
387 uint8_t present_state; //!< Return a state value
388 uint8_t previous_state; //!< The state that the presentState was entered
389 //! from. This must be different from the
390 //! present state
391 uint8_t event_state; //!< Return a state value from a PLDM State Set
392 //! that is associated with the sensor
393} __attribute__((packed)) get_sensor_state_field;
394
Priyanga7257fdf2019-06-10 01:59:45 -0500395/** @struct PLDM_SetStateEffecterStates_Request
396 *
397 * Structure representing PLDM set state effecter states request.
398 */
399struct pldm_set_state_effecter_states_req {
400 uint16_t effecter_id;
401 uint8_t comp_effecter_count;
402 set_effecter_state_field field[8];
403} __attribute__((packed));
404
Sampa Misra7fcfb662019-05-08 13:13:53 -0500405/** @struct pldm_get_pdr_resp
406 *
407 * structure representing GetPDR response packet
408 * transfer CRC is not part of the structure and will be
409 * added at the end of last packet in multipart transfer
410 */
411struct pldm_get_pdr_resp {
412 uint8_t completion_code;
413 uint32_t next_record_handle;
414 uint32_t next_data_transfer_handle;
415 uint8_t transfer_flag;
416 uint16_t response_count;
417 uint8_t record_data[1];
418} __attribute__((packed));
419
420/** @struct pldm_get_pdr_req
421 *
422 * structure representing GetPDR request packet
423 */
424struct pldm_get_pdr_req {
425 uint32_t record_handle;
426 uint32_t data_transfer_handle;
427 uint8_t transfer_op_flag;
428 uint16_t request_count;
429 uint16_t record_change_number;
430} __attribute__((packed));
431
George Liu30b859f2020-01-07 15:03:22 +0800432/** @struct pldm_set_numeric_effecter_value_req
433 *
434 * structure representing SetNumericEffecterValue request packet
435 */
436struct pldm_set_numeric_effecter_value_req {
437 uint16_t effecter_id;
438 uint8_t effecter_data_size;
439 uint8_t effecter_value[1];
440} __attribute__((packed));
441
Jolie Ku3557bad2020-03-02 16:22:57 +0800442/** @struct pldm_get_state_sensor_readings_req
443 *
444 * Structure representing PLDM get state sensor readings request.
445 */
446struct pldm_get_state_sensor_readings_req {
447 uint16_t sensor_id;
448 bitfield8_t sensor_rearm;
449 uint8_t reserved;
450} __attribute__((packed));
451
452/** @struct pldm_get_state_sensor_readings_resp
453 *
454 * Structure representing PLDM get state sensor readings response.
455 */
456struct pldm_get_state_sensor_readings_resp {
457 uint8_t completion_code;
458 uint8_t comp_sensor_count;
459 get_sensor_state_field field[1];
460} __attribute__((packed));
461
Zahed Hossaind4abab12020-02-06 03:36:43 -0600462/** @struct pldm_sensor_event
463 *
464 * structure representing sensorEventClass
465 */
466struct pldm_sensor_event_data {
467 uint16_t sensor_id;
468 uint8_t sensor_event_class_type;
469 uint8_t event_class[1];
470} __attribute__((packed));
471
472/** @struct pldm_state_sensor_state
473 *
474 * structure representing sensorEventClass for stateSensorState
475 */
476struct pldm_sensor_event_state_sensor_state {
477 uint8_t sensor_offset;
478 uint8_t event_state;
479 uint8_t previous_event_state;
480} __attribute__((packed));
481
482/** @struct pldm_sensor_event_numeric_sensor_state
483 *
484 * structure representing sensorEventClass for stateSensorState
485 */
486struct pldm_sensor_event_numeric_sensor_state {
487 uint8_t event_state;
488 uint8_t previous_event_state;
489 uint8_t sensor_data_size;
490 uint8_t present_reading[1];
491} __attribute__((packed));
492
493/** @struct pldm_sensor_event_sensor_op_state
494 *
495 * structure representing sensorEventClass for SensorOpState
496 */
497struct pldm_sensor_event_sensor_op_state {
498 uint8_t present_op_state;
499 uint8_t previous_op_state;
500} __attribute__((packed));
501
502/** @struct pldm_platform_event_message_req
503 *
504 * structure representing PlatformEventMessage command request data
505 */
506struct pldm_platform_event_message_req {
507 uint8_t format_version;
508 uint8_t tid;
509 uint8_t event_class;
510 uint8_t event_data[1];
511} __attribute__((packed));
512
513/** @struct pldm_platform_event_message_response
514 *
515 * structure representing PlatformEventMessage command response data
516 */
517struct pldm_platform_event_message_resp {
518 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500519 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600520} __attribute__((packed));
521
522/** @struct pldm_pdr_repository_chg_event_data
523 *
524 * structure representing pldmPDRRepositoryChgEvent class eventData
525 */
526struct pldm_pdr_repository_chg_event_data {
527 uint8_t event_data_format;
528 uint8_t number_of_change_records;
529 uint8_t change_records[1];
530} __attribute__((packed));
531
532/** @struct pldm_pdr_repository_chg_event_change_record_data
533 *
534 * structure representing pldmPDRRepositoryChgEvent class eventData's change
535 * record data
536 */
537struct pldm_pdr_repository_change_record_data {
538 uint8_t event_data_operation;
539 uint8_t number_of_change_entries;
540 uint32_t change_entry[1];
541} __attribute__((packed));
542
Jolie Ku6787f172020-03-19 11:15:53 +0800543/** @struct pldm_get_numeric_effecter_value_req
544 *
545 * structure representing GetNumericEffecterValue request packet
546 */
547struct pldm_get_numeric_effecter_value_req {
548 uint16_t effecter_id;
549} __attribute__((packed));
550
551/** @struct pldm_get_numeric_effecter_value_resp
552 *
553 * structure representing GetNumericEffecterValue response packet
554 */
555struct pldm_get_numeric_effecter_value_resp {
556 uint8_t completion_code;
557 uint8_t effecter_data_size;
558 uint8_t effecter_oper_state;
559 uint8_t pending_and_present_values[1];
560} __attribute__((packed));
561
Jolie Kuf798c8f2020-04-14 11:18:06 +0800562/** @struct pldm_get_sensor_reading_req
563 *
564 * Structure representing PLDM get sensor reading request
565 */
566struct pldm_get_sensor_reading_req {
567 uint16_t sensor_id;
568 bool8_t rearm_event_state;
569} __attribute__((packed));
570
571/** @struct pldm_get_sensor_reading_resp
572 *
573 * Structure representing PLDM get sensor reading response
574 */
575struct pldm_get_sensor_reading_resp {
576 uint8_t completion_code;
577 uint8_t sensor_data_size;
578 uint8_t sensor_operational_state;
579 uint8_t sensor_event_message_enable;
580 uint8_t present_state;
581 uint8_t previous_state;
582 uint8_t event_state;
583 uint8_t present_reading[1];
584} __attribute__((packed));
585
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500586/* Responder */
587
George Liu30b859f2020-01-07 15:03:22 +0800588/* SetNumericEffecterValue */
589
590/** @brief Decode SetNumericEffecterValue request data
591 *
592 * @param[in] msg - Request message
593 * @param[in] payload_length - Length of request message payload
594 * @param[out] effecter_id - used to identify and access the effecter
595 * @param[out] effecter_data_size - The bit width and format of the setting
596 * value for the effecter.
597 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
598 * @param[out] effecter_value - The setting value of numeric effecter being
599 * requested.
600 * @return pldm_completion_codes
601 */
602int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
603 size_t payload_length,
604 uint16_t *effecter_id,
605 uint8_t *effecter_data_size,
606 uint8_t *effecter_value);
607
608/** @brief Create a PLDM response message for SetNumericEffecterValue
609 *
610 * @param[in] instance_id - Message's instance id
611 * @param[in] completion_code - PLDM completion code
612 * @param[out] msg - Message will be written to this
613 * @param[in] payload_length - Length of request message payload
614 * @return pldm_completion_codes
615 * @note Caller is responsible for memory alloc and dealloc of param
616 * 'msg.body.payload'
617 */
618int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
619 uint8_t completion_code,
620 struct pldm_msg *msg,
621 size_t payload_length);
622
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500623/* SetStateEffecterStates */
624
625/** @brief Create a PLDM response message for SetStateEffecterStates
626 *
627 * @param[in] instance_id - Message's instance id
628 * @param[in] completion_code - PLDM completion code
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
632 * 'msg.body.payload'
633 */
634
635int encode_set_state_effecter_states_resp(uint8_t instance_id,
636 uint8_t completion_code,
637 struct pldm_msg *msg);
638
639/** @brief Decode SetStateEffecterStates request data
640 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500641 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500642 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500643 * @param[out] effecter_id - used to identify and access the effecter
644 * @param[out] comp_effecter_count - number of individual sets of effecter
645 * information. Upto eight sets of state effecter info can be accessed
646 * for a given effecter.
647 * @param[out] field - each unit is an instance of the stateFileld structure
648 * that is used to set the requested state for a particular effecter
649 * within the state effecter. This field holds the starting address of
650 * the stateField values. The user is responsible to allocate the
651 * memory prior to calling this command. Since the state field count is
652 * not known in advance, the user should allocate the maximum size
653 * always, which is 8 in number.
654 * @return pldm_completion_codes
655 */
vkaverapa6575b82019-04-03 05:33:52 -0500656
Zahed Hossain223a73d2019-07-04 12:46:18 -0500657int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500658 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500659 uint16_t *effecter_id,
660 uint8_t *comp_effecter_count,
661 set_effecter_state_field *field);
662
Sampa Misra7fcfb662019-05-08 13:13:53 -0500663/* GetPDR */
664
665/** @brief Create a PLDM response message for GetPDR
666 *
667 * @param[in] instance_id - Message's instance id
668 * @param[in] completion_code - PLDM completion code
669 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
670 * the PDR Repository
671 * @param[in] next_data_transfer_hndl - A handle that identifies the next
672 * portion of the PDR data to be transferred, if any
673 * @param[in] transfer_flag - Indicates the portion of PDR data being
674 * transferred
675 * @param[in] resp_cnt - The number of recordData bytes returned in this
676 * response
677 * @param[in] record_data - PDR data bytes of length resp_cnt
678 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
679 * in the last part of a PDR being transferred
680 * @param[out] msg - Message will be written to this
681 * @return pldm_completion_codes
682 * @note Caller is responsible for memory alloc and dealloc of param
683 * 'msg.payload'
684 */
685int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
686 uint32_t next_record_hndl,
687 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
688 uint16_t resp_cnt, const uint8_t *record_data,
689 uint8_t transfer_crc, struct pldm_msg *msg);
690
691/** @brief Decode GetPDR request data
692 *
693 * @param[in] msg - Request message
694 * @param[in] payload_length - Length of request message payload
695 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
696 * @param[out] data_transfer_hndl - Handle used to identify a particular
697 * multipart PDR data transfer operation
698 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
699 * portion of transfer
700 * @param[out] request_cnt - The maximum number of record bytes requested
701 * @param[out] record_chg_num - Used to determine whether the PDR has changed
702 * while PDR transfer is going on
703 * @return pldm_completion_codes
704 */
705
706int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
707 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
708 uint8_t *transfer_op_flag, uint16_t *request_cnt,
709 uint16_t *record_chg_num);
710
Jolie Ku3557bad2020-03-02 16:22:57 +0800711/* GetStateSensorReadings */
712
713/** @brief Decode GetStateSensorReadings request data
714 *
715 * @param[in] msg - Request message
716 * @param[in] payload_length - Length of request message payload
717 * @param[out] sensor_id - used to identify and access the simple or composite
718 * sensor
719 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
720 * particular sensor within the state sensor, where bit [0] corresponds
721 * to the first state sensor (sensor offset 0) and bit [7] corresponds
722 * to the eighth sensor (sensor offset 7), sequentially.
723 * @param[out] reserved - value: 0x00
724 * @return pldm_completion_codes
725 */
726
727int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
728 size_t payload_length,
729 uint16_t *sensor_id,
730 bitfield8_t *sensor_rearm,
731 uint8_t *reserved);
732
733/** @brief Encode GetStateSensorReadings response data
734 *
735 * @param[in] instance_id - Message's instance id
736 * @param[in] completion_code - PLDM completion code
737 * @param[out] comp_sensor_count - The number of individual sets of sensor
738 * information that this command accesses
739 * @param[out] field - Each stateField is an instance of a stateField structure
740 * that is used to return the present operational state setting and the
741 * present state and event state for a particular set of sensor
742 * information contained within the state sensor
743 * @param[out] msg - Message will be written to this
744 * @return pldm_completion_codes
745 */
746
747int encode_get_state_sensor_readings_resp(uint8_t instance_id,
748 uint8_t completion_code,
749 uint8_t comp_sensor_count,
750 get_sensor_state_field *field,
751 struct pldm_msg *msg);
752
Jolie Ku6787f172020-03-19 11:15:53 +0800753/* GetNumericEffecterValue */
754
755/** @brief Decode GetNumericEffecterValue request data
756 *
757 * @param[in] msg - Request message
758 * @param[in] payload_length - Length of request message payload
759 * @param[out] effecter_id - used to identify and access the effecter
760 * @return pldm_completion_codes
761 */
762int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
763 size_t payload_length,
764 uint16_t *effecter_id);
765
766/** @brief Create a PLDM response message for GetNumericEffecterValue
767 *
768 * @param[in] instance_id - Message's instance id
769 * @param[in] completion_code - PLDM completion code
770 * @param[in] effecter_data_size - The bit width and format of the setting
771 * value for the effecter.
772 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
773 * @param[in] effecter_oper_state - The state of the effecter itself
774 * @param[in] pending_value - The pending numeric value setting of the
775 * effecter. The effecterDataSize field indicates the number of
776 * bits used for this field
777 * @param[in] present_value - The present numeric value setting of the
778 * effecter. The effecterDataSize indicates the number of bits
779 * used for this field
780 * @param[out] msg - Message will be written to this
781 * @param[in] payload_length - Length of request message payload
782 * @return pldm_completion_codes
783 * @note Caller is responsible for memory alloc and dealloc of param
784 * 'msg.payload'
785 */
786int encode_get_numeric_effecter_value_resp(
787 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
788 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
789 struct pldm_msg *msg, size_t payload_length);
790
Jolie Kuf798c8f2020-04-14 11:18:06 +0800791/* GetSensorReading */
792
793/** @brief Decode GetSensorReading request data
794 *
795 * @param[in] msg - Request message
796 * @param[in] payload_length - Length of request message payload
797 * @param[out] sensor_id - A handle that is used to identify and access
798 * the sensor
799 * @param[out] rearm_event_state - true = manually re-arm EventState after
800 * responding to this request, false = no manual re-arm
801 * @return pldm_completion_codes
802 */
803
804int decode_get_sensor_reading_req(const struct pldm_msg *msg,
805 size_t payload_length, uint16_t *sensor_id,
806 bool8_t *rearm_event_state);
807
808/** @brief Encode GetSensorReading response data
809 *
810 * @param[in] instance_id - Message's instance id
811 * @param[in] completion_code - PLDM completion code
812 * @param[out] sensor_data_size - The bit width and format of reading and
813 * threshold values
814 * @param[out] sensor_operational_state - The state of the sensor itself
815 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
816 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
817 * stateEventsOnlyEnabled }
818 * @param[out] present_state - The most recently assessed state value monitored
819 * by the sensor
820 * @param[out] previous_state - The state that the presentState was entered
821 * from
822 * @param[out] event_state - Indicates which threshold crossing assertion
823 * events have been detected
824 * @param[out] present_reading - The present value indicated by the sensor
825 * @param[out] msg - Message will be written to this
826 * @param[in] payload_length - Length of request message payload
827 * @return pldm_completion_codes
828 */
829
830int encode_get_sensor_reading_resp(
831 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
832 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
833 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
834 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
835
Sampa Misra7fcfb662019-05-08 13:13:53 -0500836/* Requester */
837
George Liu820a9a52019-11-26 14:43:59 +0800838/* GetPDR */
839
840/** @brief Create a PLDM request message for GetPDR
841 *
842 * @param[in] instance_id - Message's instance id
843 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
844 * @param[in] data_transfer_hndl - Handle used to identify a particular
845 * multipart PDR data transfer operation
846 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
847 * portion of transfer
848 * @param[in] request_cnt - The maximum number of record bytes requested
849 * @param[in] record_chg_num - Used to determine whether the PDR has changed
850 * while PDR transfer is going on
851 * @param[out] msg - Message will be written to this
852 * @param[in] payload_length - Length of request message payload
853 * @return pldm_completion_codes
854 * @note Caller is responsible for memory alloc and dealloc of param
855 * 'msg.payload'
856 */
857int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
858 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
859 uint16_t request_cnt, uint16_t record_chg_num,
860 struct pldm_msg *msg, size_t payload_length);
861
862/** @brief Decode GetPDR response data
863 *
George Liu684a7162019-12-06 15:10:52 +0800864 * Note:
865 * * If the return value is not PLDM_SUCCESS, it represents a
866 * transport layer error.
867 * * If the completion_code value is not PLDM_SUCCESS, it represents a
868 * protocol layer error and all the out-parameters are invalid.
869 *
George Liu820a9a52019-11-26 14:43:59 +0800870 * @param[in] msg - Request message
871 * @param[in] payload_length - Length of request message payload
872 * @param[out] completion_code - PLDM completion code
873 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
874 * the PDR Repository
875 * @param[out] next_data_transfer_hndl - A handle that identifies the next
876 * portion of the PDR data to be transferred, if any
877 * @param[out] transfer_flag - Indicates the portion of PDR data being
878 * transferred
879 * @param[out] resp_cnt - The number of recordData bytes returned in this
880 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500881 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
882 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800883 * @param[in] record_data_length - Length of record_data
884 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
885 * in the last part of a PDR being transferred
886 * @return pldm_completion_codes
887 */
888int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
889 uint8_t *completion_code, uint32_t *next_record_hndl,
890 uint32_t *next_data_transfer_hndl,
891 uint8_t *transfer_flag, uint16_t *resp_cnt,
892 uint8_t *record_data, size_t record_data_length,
893 uint8_t *transfer_crc);
894
Sampa Misra7fcfb662019-05-08 13:13:53 -0500895/* SetStateEffecterStates */
896
vkaverap98a2c192019-04-03 05:33:52 -0500897/** @brief Create a PLDM request message for SetStateEffecterStates
898 *
899 * @param[in] instance_id - Message's instance id
900 * @param[in] effecter_id - used to identify and access the effecter
901 * @param[in] comp_effecter_count - number of individual sets of effecter
902 * information. Upto eight sets of state effecter info can be accessed
903 * for a given effecter.
904 * @param[in] field - each unit is an instance of the stateField structure
905 * that is used to set the requested state for a particular effecter
906 * within the state effecter. This field holds the starting address of
907 * the stateField values. The user is responsible to allocate the
908 * memory prior to calling this command. The user has to allocate the
909 * field parameter as sizeof(set_effecter_state_field) *
910 * comp_effecter_count
911 * @param[out] msg - Message will be written to this
912 * @return pldm_completion_codes
913 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500914 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500915 */
916
917int encode_set_state_effecter_states_req(uint8_t instance_id,
918 uint16_t effecter_id,
919 uint8_t comp_effecter_count,
920 set_effecter_state_field *field,
921 struct pldm_msg *msg);
922
923/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800924 *
925 * Note:
926 * * If the return value is not PLDM_SUCCESS, it represents a
927 * transport layer error.
928 * * If the completion_code value is not PLDM_SUCCESS, it represents a
929 * protocol layer error and all the out-parameters are invalid.
930 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500931 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500932 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500933 * @param[out] completion_code - PLDM completion code
934 * @return pldm_completion_codes
935 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500936int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500937 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500938 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800939
940/* SetNumericEffecterValue */
941
942/** @brief Create a PLDM request message for SetNumericEffecterValue
943 *
944 * @param[in] instance_id - Message's instance id
945 * @param[in] effecter_id - used to identify and access the effecter
946 * @param[in] effecter_data_size - The bit width and format of the setting
947 * value for the effecter.
948 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
949 * @param[in] effecter_value - The setting value of numeric effecter being
950 * requested.
951 * @param[in] payload_length - Length of request message payload
952 * @param[out] msg - Message will be written to this
953 * @return pldm_completion_codes
954 * @note Caller is responsible for memory alloc and dealloc of param
955 * 'msg.payload'
956 */
957int encode_set_numeric_effecter_value_req(
958 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
959 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
960
961/** @brief Decode SetNumericEffecterValue response data
962 * @param[in] msg - Request message
963 * @param[in] payload_length - Length of response message payload
964 * @param[out] completion_code - PLDM completion code
965 * @return pldm_completion_codes
966 */
967int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
968 size_t payload_length,
969 uint8_t *completion_code);
970
Jolie Ku3557bad2020-03-02 16:22:57 +0800971/** @brief Create a PLDM request message for GetStateSensorReadings
972 *
973 * @param[in] instance_id - Message's instance id
974 * @param[in] sensor_id - used to identify and access the simple or composite
975 * sensor
976 * @param[in] sensorRearm - Each bit location in this field corresponds to a
977 * particular sensor within the state sensor, where bit [0] corresponds
978 * to the first state sensor (sensor offset 0) and bit [7] corresponds
979 * to the eighth sensor (sensor offset 7), sequentially
980 * @param[in] reserved - value: 0x00
981 * @param[out] msg - Message will be written to this
982 * @return pldm_completion_codes
983 * @note Caller is responsible for memory alloc and dealloc of param
984 * 'msg.payload'
985 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800986int encode_get_state_sensor_readings_req(uint8_t instance_id,
987 uint16_t sensor_id,
988 bitfield8_t sensor_rearm,
989 uint8_t reserved,
990 struct pldm_msg *msg);
991
992/** @brief Decode GetStateSensorReadings response data
993 *
994 * @param[in] msg - Request message
995 * @param[in] payload_length - Length of response message payload
996 * @param[out] completion_code - PLDM completion code
997 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
998 * information that this command accesses
999 * @param[out] field - Each stateField is an instance of a stateField structure
1000 * that is used to return the present operational state setting and the
1001 * present state and event state for a particular set of sensor
1002 * information contained within the state sensor
1003 * @return pldm_completion_codes
1004 */
1005
1006int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1007 size_t payload_length,
1008 uint8_t *completion_code,
1009 uint8_t *comp_sensor_count,
1010 get_sensor_state_field *field);
1011
Zahed Hossaind4abab12020-02-06 03:36:43 -06001012/* PlatformEventMessage */
1013
1014/** @brief Decode PlatformEventMessage request data
1015 * @param[in] msg - Request message
1016 * @param[in] payload_length - Length of response message payload
1017 * @param[out] format_version - Version of the event format
1018 * @param[out] tid - Terminus ID for the terminus that originated the event
1019 * message
1020 * @param[out] event_class - The class of event being sent
1021 * @param[out] event_data_offset - Offset where the event data should be read
1022 * from pldm msg
1023 * @return pldm_completion_codes
1024 */
1025int decode_platform_event_message_req(const struct pldm_msg *msg,
1026 size_t payload_length,
1027 uint8_t *format_version, uint8_t *tid,
1028 uint8_t *event_class,
1029 size_t *event_data_offset);
1030
1031/** @brief Encode PlatformEventMessage response data
1032 * @param[in] instance_id - Message's instance id
1033 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001034 * @param[in] platform_event_status - Response status of the event message
1035 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001036 * @param[out] msg - Message will be written to this
1037 * @return pldm_completion_codes
1038 * @note Caller is responsible for memory alloc and dealloc of param
1039 * 'msg.payload'
1040 */
1041int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001042 uint8_t completion_code,
1043 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001044 struct pldm_msg *msg);
1045
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001046/** @brief Encode PlatformEventMessage request data
1047 * @param[in] instance_id - Message's instance id
1048 * @param[in] format_version - Version of the event format
1049 * @param[in] tid - Terminus ID for the terminus that originated the event
1050 * message
1051 * @param[in] event_class - The class of event being sent
1052 * @param[in] event_data - the event data should be read from pldm msg
1053 * @param[in] event_data_length - Length of the event data
1054 * @param[out] msg - Request message
1055 * @return pldm_completion_codes
1056 * @note Caller is responsible for memory alloc and dealloc of param
1057 * 'msg.payload'
1058 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001059int encode_platform_event_message_req(
1060 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1061 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1062 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001063
1064/** @brief Decode PlatformEventMessage response data
1065 * @param[in] msg - Request message
1066 * @param[in] payload_length - Length of Response message payload
1067 * @param[out] completion_code - PLDM completion code
1068 * @param[out] platform_event_status - Response status of the event message
1069 * command
1070 * @return pldm_completion_codes
1071 */
1072int decode_platform_event_message_resp(const struct pldm_msg *msg,
1073 size_t payload_length,
1074 uint8_t *completion_code,
1075 uint8_t *platform_event_status);
1076
Zahed Hossain1c861712020-03-04 08:55:19 -06001077/** @brief Decode sensorEventData response data
1078 *
1079 * @param[in] event_data - event data from the response message
1080 * @param[in] event_data_length - length of the event data
1081 * @param[out] sensor_id - sensorID value of the sensor
1082 * @param[out] sensor_event_class_type - Type of sensor event class
1083 * @param[out] event_class_data_offset - Offset where the event class data
1084 * should be read from event data
1085 * @return pldm_completion_codes
1086 * @note Caller is responsible for memory alloc and dealloc of param
1087 * 'event_data'
1088 */
1089int decode_sensor_event_data(const uint8_t *event_data,
1090 size_t event_data_length, uint16_t *sensor_id,
1091 uint8_t *sensor_event_class_type,
1092 size_t *event_class_data_offset);
1093
1094/** @brief Decode sensorOpState response data
1095 *
1096 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1097 * @param[in] sensor_data_length - Length of sensor_data
1098 * @param[out] present_op_state - The sensorOperationalState value from the
1099 * state change that triggered the event message
1100 * @param[out] previous_op_state - The sensorOperationalState value for the
1101 * state from which the present state was entered
1102 * @return pldm_completion_codes
1103 * @note Caller is responsible for memory alloc and dealloc of param
1104 * 'sensor_data'
1105 */
1106int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1107 uint8_t *present_op_state,
1108 uint8_t *previous_op_state);
1109
1110/** @brief Decode stateSensorState response data
1111 *
1112 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1113 * @param[in] sensor_data_length - Length of sensor_data
1114 * @param[out] sensor_offset - Identifies which state sensor within a composite
1115 * state sensor the event is being returned for
1116 * @param[out] event_state - The event state value from the state change that
1117 * triggered the event message
1118 * @param[out] previous_event_state - The event state value for the state from
1119 * which the present event state was entered
1120 * @return pldm_completion_codes
1121 * @note Caller is responsible for memory alloc and dealloc of param
1122 * 'sensor_data'
1123 */
1124int decode_state_sensor_data(const uint8_t *sensor_data,
1125 size_t sensor_data_length, uint8_t *sensor_offset,
1126 uint8_t *event_state,
1127 uint8_t *previous_event_state);
1128
1129/** @brief Decode numericSensorState response data
1130 *
1131 * @param[in] sensor_data - sensor_data for sensorEventClass =
1132 * numericSensorState
1133 * @param[in] sensor_data_length - Length of sensor_data
1134 * @param[out] event_state - The eventState value from the state change that
1135 * triggered the event message
1136 * @param[out] previous_event_state - The eventState value for the state from
1137 * which the present state was entered
1138 * @param[out] sensor_data_size - The bit width and format of reading and
1139 * threshold values that the sensor returns
1140 * @param[out] present_reading - The present value indicated by the sensor
1141 * @return pldm_completion_codes
1142 * @note Caller is responsible for memory alloc and dealloc of param
1143 * 'sensor_data'
1144 */
1145int decode_numeric_sensor_data(const uint8_t *sensor_data,
1146 size_t sensor_data_length, uint8_t *event_state,
1147 uint8_t *previous_event_state,
1148 uint8_t *sensor_data_size,
1149 uint32_t *present_reading);
1150
Jolie Ku6787f172020-03-19 11:15:53 +08001151/* GetNumericEffecterValue */
1152
1153/** @brief Create a PLDM request message for GetNumericEffecterValue
1154 *
1155 * @param[in] instance_id - Message's instance id
1156 * @param[in] effecter_id - used to identify and access the effecter
1157 * @param[out] msg - Message will be written to this
1158 * @return pldm_completion_codes
1159 * @note Caller is responsible for memory alloc and dealloc of param
1160 * 'msg.payload'
1161 */
1162int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1163 uint16_t effecter_id,
1164 struct pldm_msg *msg);
1165
1166/** @brief Create a PLDM response message for GetNumericEffecterValue
1167 *
1168 * @param[in] msg - Request message
1169 * @param[in] payload_length - Length of request message payload
1170 * @param[out] completion_code - PLDM completion code
1171 * @param[out] effecter_data_size - The bit width and format of the setting
1172 * value for the effecter.
1173 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1174 * @param[out] effecter_oper_state - The state of the effecter itself
1175 * @param[out] pending_value - The pending numeric value setting of the
1176 * effecter. The effecterDataSize field indicates the number of
1177 * bits used for this field
1178 * @param[out] present_value - The present numeric value setting of the
1179 * effecter. The effecterDataSize indicates the number of bits
1180 * used for this field
1181 * @return pldm_completion_codes
1182 */
1183int decode_get_numeric_effecter_value_resp(
1184 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1185 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1186 uint8_t *pending_value, uint8_t *present_value);
1187
Zahed Hossain9be087c2020-04-02 02:26:41 -05001188/** @brief Decode pldmPDRRepositoryChgEvent response data
1189 *
1190 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1191 * @param[in] event_data_size - Length of event_data
1192 * @param[out] event_data_format - This field indicates if the changedRecords
1193 * are of PDR Types or PDR Record Handles
1194 * @param[out] number_of_change_records - The number of changeRecords following
1195 * this field
1196 * @param[out] change_record_data_offset - Identifies where changeRecord data
1197 * is located within event_data
1198 * @return pldm_completion_codes
1199 * @note Caller is responsible for memory alloc and dealloc of param
1200 * 'event_data'
1201 */
1202int decode_pldm_pdr_repository_chg_event_data(
1203 const uint8_t *event_data, size_t event_data_size,
1204 uint8_t *event_data_format, uint8_t *number_of_change_records,
1205 size_t *change_record_data_offset);
1206
Zach Clark36ad1f52020-04-13 07:04:15 -05001207/** @brief Encode PLDM PDR Repository Change eventData
1208 * @param[in] event_data_format - Format of this event data (e.g.
1209 * FORMAT_IS_PDR_HANDLES)
1210 * @param[in] number_of_change_records - Number of changeRecords in this
1211 * eventData
1212 * @param[in] event_data_operations - Array of eventDataOperations
1213 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1214 * should contain number_of_change_records elements.
1215 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1216 * for each changeRecord in this eventData. This array should contain
1217 * number_of_change_records elements.
1218 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1219 * one array per changeRecord in this eventData. The toplevel array should
1220 * contain number_of_change_records elements. Each subarray [i] should
1221 * contain numbers_of_change_entries[i] elements.
1222 * @param[in] event_data - The eventData will be encoded into this. This entire
1223 * structure must be max_change_records_size long. It must be large enough
1224 * to accomodate the data to be encoded. The caller is responsible for
1225 * allocating and deallocating it, including the variable-size
1226 * 'event_data.change_records' field. If this parameter is NULL,
1227 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1228 * to reflect the required size of the structure.
1229 * @param[out] actual_change_records_size - The actual number of meaningful
1230 * encoded bytes in event_data. The caller can over-allocate memory and use
1231 * this output to determine the real size of the structure.
1232 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1233 * encoded message would be larger than this value, an error is returned.
1234 * @return pldm_completion_codes
1235 * @note Caller is responsible for memory alloc and dealloc of param
1236 * 'event_data.change_records'
1237 */
1238int encode_pldm_pdr_repository_chg_event_data(
1239 uint8_t event_data_format, uint8_t number_of_change_records,
1240 const uint8_t *event_data_operations,
1241 const uint8_t *numbers_of_change_entries,
1242 const uint32_t *const *change_entries,
1243 struct pldm_pdr_repository_chg_event_data *event_data,
1244 size_t *actual_change_records_size, size_t max_change_records_size);
1245
Zahed Hossain9be087c2020-04-02 02:26:41 -05001246/** @brief Decode PldmPDRRepositoryChangeRecord response data
1247 *
1248 * @param[in] change_record_data - changeRecordData for
1249 * pldmPDRRepositoryChgEvent
1250 * @param[in] change_record_data_size - Length of change_record_data
1251 * @param[out] event_data_operation - This field indicates the changeEntries
1252 * operation types
1253 * @param[out] number_of_change_entries - The number of changeEntries following
1254 * this field
1255 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1256 * is located within change_record_data
1257 * @return pldm_completion_codes
1258 * @note Caller is responsible for memory alloc and dealloc of param
1259 * 'change_record_data'
1260 */
1261int decode_pldm_pdr_repository_change_record_data(
1262 const uint8_t *change_record_data, size_t change_record_data_size,
1263 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1264 size_t *change_entry_data_offset);
1265
Jolie Kuf798c8f2020-04-14 11:18:06 +08001266/* GetSensorReading */
1267
1268/** @brief Encode GetSensorReading request data
1269 *
1270 * @param[in] instance_id - Message's instance id
1271 * @param[in] sensor_id - A handle that is used to identify and access the
1272 * sensor
1273 * @param[in] rearm_event_state - true = manually re-arm EventState after
1274 * responding to this request, false = no manual re-arm
1275 * @param[out] msg - Message will be written to this
1276 * @return pldm_completion_codes
1277 * @note Caller is responsible for memory alloc and dealloc of param
1278 * 'msg.payload'
1279 */
1280int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1281 bool8_t rearm_event_state,
1282 struct pldm_msg *msg);
1283
1284/** @brief Decode GetSensorReading response data
1285 *
1286 * @param[in] msg - Request message
1287 * @param[in] payload_length - Length of response message payload
1288 * @param[out] completion_code - PLDM completion code
1289 * @param[out] sensor_data_size - The bit width and format of reading and
1290 * threshold values
1291 * @param[out] sensor_operational_state - The state of the sensor itself
1292 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1293 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1294 * stateEventsOnlyEnabled }
1295 * @param[out] present_state - The most recently assessed state value monitored
1296 * by the sensor
1297 * @param[out] previous_state - The state that the presentState was entered
1298 * from
1299 * @param[out] event_state - Indicates which threshold crossing assertion
1300 * events have been detected
1301 * @param[out] present_reading - The present value indicated by the sensor
1302 * @return pldm_completion_codes
1303 */
1304
1305int decode_get_sensor_reading_resp(
1306 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1307 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1308 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1309 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1310
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001311#ifdef __cplusplus
1312}
1313#endif
1314
1315#endif /* PLATFORM_H */