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