blob: 7834f591a9bcef82acd15933a8a3f4861441a056 [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
21
George Liu30b859f2020-01-07 15:03:22 +080022#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
23#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
24
Sampa Misra7fcfb662019-05-08 13:13:53 -050025#define PLDM_GET_PDR_REQ_BYTES 13
26/* Minimum response length */
27#define PLDM_GET_PDR_MIN_RESP_BYTES 12
Jolie Ku6787f172020-03-19 11:15:53 +080028#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
Jolie Kuf798c8f2020-04-14 11:18:06 +080029#define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8
George Liu80237ef2020-07-10 15:16:39 +080030#define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES 2
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
Sampa Misra868c8792020-05-26 03:12:13 -050052#define PLDM_TID_RESERVED 0xFF
Tom Joseph250c4752020-04-15 10:32:45 +053053
George Liu30b859f2020-01-07 15:03:22 +080054enum pldm_effecter_data_size {
55 PLDM_EFFECTER_DATA_SIZE_UINT8,
56 PLDM_EFFECTER_DATA_SIZE_SINT8,
57 PLDM_EFFECTER_DATA_SIZE_UINT16,
58 PLDM_EFFECTER_DATA_SIZE_SINT16,
59 PLDM_EFFECTER_DATA_SIZE_UINT32,
60 PLDM_EFFECTER_DATA_SIZE_SINT32
61};
62
George Liu456c9a22020-01-13 11:36:22 +080063enum pldm_range_field_format {
64 PLDM_RANGE_FIELD_FORMAT_UINT8,
65 PLDM_RANGE_FIELD_FORMAT_SINT8,
66 PLDM_RANGE_FIELD_FORMAT_UINT16,
67 PLDM_RANGE_FIELD_FORMAT_SINT16,
68 PLDM_RANGE_FIELD_FORMAT_UINT32,
69 PLDM_RANGE_FIELD_FORMAT_SINT32,
70 PLDM_RANGE_FIELD_FORMAT_REAL32
71};
72
Sampa Misra0db1dfa2019-03-19 00:15:31 -050073enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
74
75enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
76
George Liu9d155022020-07-10 15:06:35 +080077enum pldm_sensor_present_state {
78 PLDM_SENSOR_UNKNOWN = 0x0,
79 PLDM_SENSOR_NORMAL = 0x01,
80 PLDM_SENSOR_WARNING = 0x02,
81 PLDM_SENSOR_CRITICAL = 0x03,
82 PLDM_SENSOR_FATAL = 0x04,
83 PLDM_SENSOR_LOWERWARNING = 0x05,
84 PLDM_SENSOR_LOWERCRITICAL = 0x06,
85 PLDM_SENSOR_LOWERFATAL = 0x07,
86 PLDM_SENSOR_UPPERWARNING = 0x08,
87 PLDM_SENSOR_UPPERCRITICAL = 0x09,
88 PLDM_SENSOR_UPPERFATAL = 0x0a
Jolie Ku3557bad2020-03-02 16:22:57 +080089};
90
Jolie Kuf798c8f2020-04-14 11:18:06 +080091enum pldm_sensor_event_message_enable {
92 PLDM_NO_EVENT_GENERATION,
93 PLDM_EVENTS_DISABLED,
94 PLDM_EVENTS_ENABLED,
95 PLDM_OP_EVENTS_ONLY_ENABLED,
96 PLDM_STATE_EVENTS_ONLY_ENABLED
97};
98
Jolie Ku6787f172020-03-19 11:15:53 +080099enum pldm_effecter_oper_state {
100 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
101 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
102 EFFECTER_OPER_STATE_DISABLED,
103 EFFECTER_OPER_STATE_UNAVAILABLE,
104 EFFECTER_OPER_STATE_STATUSUNKNOWN,
105 EFFECTER_OPER_STATE_FAILED,
106 EFFECTER_OPER_STATE_INITIALIZING,
107 EFFECTER_OPER_STATE_SHUTTINGDOWN,
108 EFFECTER_OPER_STATE_INTEST
109};
110
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500111enum pldm_platform_commands {
Jolie Kuf798c8f2020-04-14 11:18:06 +0800112 PLDM_GET_SENSOR_READING = 0x11,
Jolie Ku3557bad2020-03-02 16:22:57 +0800113 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +0800114 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +0800115 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500116 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -0500117 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600118 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500119};
120
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500121/** @brief PLDM PDR types
122 */
123enum pldm_pdr_types {
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500124 PLDM_TERMINUS_LOCATOR_PDR = 1,
125 PLDM_NUMERIC_SENSOR_PDR = 2,
126 PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3,
Tom Josephb4268602020-04-17 17:20:45 +0530127 PLDM_STATE_SENSOR_PDR = 4,
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500128 PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5,
129 PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6,
130 PLDM_OEM_UNIT_PDR = 7,
131 PLDM_OEM_STATE_SET_PDR = 8,
George Liu456c9a22020-01-13 11:36:22 +0800132 PLDM_NUMERIC_EFFECTER_PDR = 9,
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500133 PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500134 PLDM_STATE_EFFECTER_PDR = 11,
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500135 PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12,
136 PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13,
137 PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500138 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500139 PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16,
140 PLDM_OEM_ENTITY_ID_PDR = 17,
141 PLDM_INTERRUPT_ASSOCIATION_PDR = 18,
142 PLDM_EVENT_LOG_PDR = 19,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600143 PLDM_PDR_FRU_RECORD_SET = 20,
Sridevi Ramesha1bfb782020-07-14 02:51:23 -0500144 PLDM_OEM_DEVICE_PDR = 126,
145 PLDM_OEM_PDR = 127,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500146};
147
148/** @brief PLDM effecter initialization schemes
149 */
150enum pldm_effecter_init {
151 PLDM_NO_INIT,
152 PLDM_USE_INIT_PDR,
153 PLDM_ENABLE_EFFECTER,
154 PLDM_DISABLE_EFECTER
155};
156
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530157/** @brief PLDM Platform M&C completion codes
158 */
159enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500160 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
161 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500162
163 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
164 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530165 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500166 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
167 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
168
Sampa Misraa2fa0702019-05-31 01:28:55 -0500169 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530170};
171
Zahed Hossaind4abab12020-02-06 03:36:43 -0600172/** @brief PLDM Event types
173 */
174enum pldm_event_types {
175 PLDM_SENSOR_EVENT = 0x00,
176 PLDM_EFFECTER_EVENT = 0x01,
177 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
178 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
179 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
180 PLDM_MESSAGE_POLL_EVENT = 0x05,
181 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
182};
183
184/** @brief PLDM sensorEventClass states
185 */
186enum sensor_event_class_states {
187 PLDM_SENSOR_OP_STATE,
188 PLDM_STATE_SENSOR_STATE,
189 PLDM_NUMERIC_SENSOR_STATE
190};
191
192/** @brief PLDM sensor supported states
193 */
194enum pldm_sensor_operational_state {
195 PLDM_SENSOR_ENABLED,
196 PLDM_SENSOR_DISABLED,
197 PLDM_SENSOR_UNAVAILABLE,
198 PLDM_SENSOR_STATUSUNKOWN,
199 PLDM_SENSOR_FAILED,
200 PLDM_SENSOR_INITIALIZING,
201 PLDM_SENSOR_SHUTTINGDOWN,
202 PLDM_SENSOR_INTEST
203};
204
205/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
206 */
207enum pldm_pdr_repository_chg_event_data_format {
208 REFRESH_ENTIRE_REPOSITORY,
209 FORMAT_IS_PDR_TYPES,
210 FORMAT_IS_PDR_HANDLES
211};
212
Zahed Hossain9be087c2020-04-02 02:26:41 -0500213/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
214 * eventDataOperation
215 */
216enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
217 PLDM_REFRESH_ALL_RECORDS,
218 PLDM_RECORDS_DELETED,
219 PLDM_RECORDS_ADDED,
220 PLDM_RECORDS_MODIFIED
221};
222
Zahed Hossain1c861712020-03-04 08:55:19 -0600223/** @brief PLDM NumericSensorStatePresentReading data type
224 */
225enum pldm_sensor_readings_data_type {
226 PLDM_SENSOR_DATA_SIZE_UINT8,
227 PLDM_SENSOR_DATA_SIZE_SINT8,
228 PLDM_SENSOR_DATA_SIZE_UINT16,
229 PLDM_SENSOR_DATA_SIZE_SINT16,
230 PLDM_SENSOR_DATA_SIZE_UINT32,
231 PLDM_SENSOR_DATA_SIZE_SINT32
232};
233
Tom Joseph56e45c52020-03-16 10:01:45 +0530234/** @brief PLDM PlatformEventMessage response status
235 */
236enum pldm_platform_event_status {
237 PLDM_EVENT_NO_LOGGING = 0x00,
238 PLDM_EVENT_LOGGING_DISABLED = 0x01,
239 PLDM_EVENT_LOG_FULL = 0x02,
240 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
241 PLDM_EVENT_LOGGED = 0x04,
242 PLDM_EVENT_LOGGING_REJECTED = 0x05
243};
244
Sampa Misra12afe112020-05-25 11:40:44 -0500245/** @brief PLDM Terminus Locator PDR validity
246 */
247enum pldm_terminus_locator_pdr_validity {
248 PLDM_TL_PDR_NOT_VALID,
249 PLDM_TL_PDR_VALID
250};
251
252/** @brief PLDM Terminus Locator type
253 */
254enum pldm_terminus_locator_type {
255 PLDM_TERMINUS_LOCATOR_TYPE_UID,
256 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID,
257 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE,
258 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW
259};
260
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500261/** @struct pldm_pdr_hdr
262 *
263 * Structure representing PLDM common PDR header
264 */
265struct pldm_pdr_hdr {
266 uint32_t record_handle;
267 uint8_t version;
268 uint8_t type;
269 uint16_t record_change_num;
270 uint16_t length;
271} __attribute__((packed));
272
Sampa Misra12afe112020-05-25 11:40:44 -0500273/** @struct pldm_terminus_locator_pdr
274 *
275 * Structure representing PLDM terminus locator PDR
276 */
277struct pldm_terminus_locator_pdr {
278 struct pldm_pdr_hdr hdr;
279 uint16_t terminus_handle;
280 uint8_t validity;
281 uint8_t tid;
282 uint16_t container_id;
283 uint8_t terminus_locator_type;
284 uint8_t terminus_locator_value_size;
285 uint8_t terminus_locator_value[1];
286} __attribute__((packed));
287
288/** @struct pldm_terminus_locator_type_mctp_eid
289 *
290 * Structure representing terminus locator value for
291 * terminus locator type MCTP_EID
292 */
293struct pldm_terminus_locator_type_mctp_eid {
294 uint8_t eid;
295} __attribute__((packed));
296
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500297/** @struct pldm_pdr_entity_association
298 *
299 * Structure representing PLDM Entity Association PDR
300 */
301struct pldm_pdr_entity_association {
302 uint16_t container_id;
303 uint8_t association_type;
304 pldm_entity container;
305 uint8_t num_children;
306 pldm_entity children[1];
307} __attribute__((packed));
308
Deepak Kodihallidb914672020-02-07 02:47:45 -0600309/** @struct pldm_pdr_fru_record_set
310 *
311 * Structure representing PLDM FRU record set PDR
312 */
313struct pldm_pdr_fru_record_set {
314 uint16_t terminus_handle;
315 uint16_t fru_rsi;
316 uint16_t entity_type;
317 uint16_t entity_instance_num;
318 uint16_t container_id;
319} __attribute__((packed));
320
Tom Josephb4268602020-04-17 17:20:45 +0530321/** @struct pldm_state_sensor_pdr
322 *
323 * Structure representing PLDM state sensor PDR
324 */
325struct pldm_state_sensor_pdr {
326 struct pldm_pdr_hdr hdr;
327 uint16_t terminus_handle;
328 uint16_t sensor_id;
329 uint16_t entity_type;
330 uint16_t entity_instance;
331 uint16_t container_id;
332 uint8_t sensor_init;
333 bool8_t sensor_auxiliary_names_pdr;
334 uint8_t composite_sensor_count;
335 uint8_t possible_states[1];
336} __attribute__((packed));
337
338/** @struct state_sensor_possible_states
339 *
340 * Structure representing state enums for state sensor
341 */
342struct state_sensor_possible_states {
343 uint16_t state_set_id;
344 uint8_t possible_states_size;
345 bitfield8_t states[1];
346} __attribute__((packed));
347
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500348/** @struct pldm_state_effecter_pdr
349 *
350 * Structure representing PLDM state effecter PDR
351 */
352struct pldm_state_effecter_pdr {
353 struct pldm_pdr_hdr hdr;
354 uint16_t terminus_handle;
355 uint16_t effecter_id;
356 uint16_t entity_type;
357 uint16_t entity_instance;
358 uint16_t container_id;
359 uint16_t effecter_semantic_id;
360 uint8_t effecter_init;
361 bool8_t has_description_pdr;
362 uint8_t composite_effecter_count;
363 uint8_t possible_states[1];
364} __attribute__((packed));
365
Zach Clarkb728eee2020-06-18 10:01:31 -0500366/** @brief Encode PLDM state sensor PDR
367 *
368 * @param[in/out] sensor Structure to encode. All members of
369 * sensor, except those mentioned in the @note below, should be initialized by
370 * the caller.
371 * @param[in] allocation_size Size of sensor allocation in bytes
372 * @param[in] possible_states Possible sensor states
373 * @param[in] possible_states_size Size of possible sensor states in bytes
374 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
375 * @return int pldm_completion_codes
376 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
377 *
378 * @note The sensor parameter will be encoded in place.
379 * @note Caller is responsible for allocation of the sensor parameter. Caller
380 * must allocate enough space for the base structure and the
381 * sensor->possible_states array, otherwise the function will fail.
382 * @note sensor->hdr.length, .type, and .version will be set appropriately.
383 */
384int encode_state_sensor_pdr(
385 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
386 const struct state_sensor_possible_states *possible_states,
387 size_t possible_states_size, size_t *actual_size);
388
George Liu456c9a22020-01-13 11:36:22 +0800389/** @union union_effecter_data_size
390 *
391 * The bit width and format of reading and threshold values that the effecter
392 * returns.
393 * Refer to: DSP0248_1.2.0: 28.11 Table 87
394 */
395typedef union {
396 uint8_t value_u8;
397 int8_t value_s8;
398 uint16_t value_u16;
399 int16_t value_s16;
400 uint32_t value_u32;
401 int32_t value_s32;
402} union_effecter_data_size;
403
404/** @union union_range_field_format
405 *
406 * Indicates the format used for the nominalValue, normalMax, and normalMin
407 * fields.
408 * Refer to: DSP0248_1.2.0: 28.11 Table 87
409 */
410typedef union {
411 uint8_t value_u8;
412 int8_t value_s8;
413 uint16_t value_u16;
414 int16_t value_s16;
415 uint32_t value_u32;
416 int32_t value_s32;
417 real32_t value_f32;
418} union_range_field_format;
419
420/** @struct pldm_numeric_effecter_value_pdr
421 *
422 * Structure representing PLDM numeric effecter value PDR
423 */
424struct pldm_numeric_effecter_value_pdr {
425 struct pldm_pdr_hdr hdr;
426 uint16_t terminus_handle;
427 uint16_t effecter_id;
428 uint16_t entity_type;
429 uint16_t entity_instance;
430 uint16_t container_id;
431 uint16_t effecter_semantic_id;
432 uint8_t effecter_init;
433 bool8_t effecter_auxiliary_names;
434 uint8_t base_unit;
435 int8_t unit_modifier;
436 uint8_t rate_unit;
437 uint8_t base_oem_unit_handle;
438 uint8_t aux_unit;
439 int8_t aux_unit_modifier;
440 uint8_t aux_rate_unit;
441 uint8_t aux_oem_unit_handle;
442 bool8_t is_linear;
443 uint8_t effecter_data_size;
444 real32_t resolution;
445 real32_t offset;
446 uint16_t accuracy;
447 uint8_t plus_tolerance;
448 uint8_t minus_tolerance;
449 real32_t state_transition_interval;
450 real32_t transition_interval;
451 union_effecter_data_size max_set_table;
452 union_effecter_data_size min_set_table;
453 uint8_t range_field_format;
454 bitfield8_t range_field_support;
455 union_range_field_format nominal_value;
456 union_range_field_format normal_max;
457 union_range_field_format normal_min;
458 union_range_field_format rated_max;
459 union_range_field_format rated_min;
460} __attribute__((packed));
461
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500462/** @struct state_effecter_possible_states
463 *
464 * Structure representing state enums for state effecter
465 */
466struct state_effecter_possible_states {
467 uint16_t state_set_id;
468 uint8_t possible_states_size;
469 bitfield8_t states[1];
470} __attribute__((packed));
471
Zach Clarkb728eee2020-06-18 10:01:31 -0500472/** @brief Encode PLDM state effecter PDR
473 *
474 * @param[in/out] effecter Structure to encode. All members of
475 * effecter, except those mentioned in
476 * the @note below, should be initialized
477 * by the caller.
478 * @param[in] allocation_size Size of effecter allocation in bytes
479 * @param[in] possible_states Possible effecter states
480 * @param[in] possible_states_size Size of possible effecter states in
481 * bytes
482 * @param[out] actual_size Size of effecter PDR. Set to 0 on
483 * error.
484 * @return int pldm_completion_codes
485 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
486 *
487 * @note The effecter parameter will be encoded in place.
488 * @note Caller is responsible for allocation of the effecter parameter. Caller
489 * must allocate enough space for the base structure and the
490 * effecter->possible_states array, otherwise the function will fail.
491 * @note effecter->hdr.length, .type, and .version will be set appropriately.
492 */
493int encode_state_effecter_pdr(
494 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
495 const struct state_effecter_possible_states *possible_states,
496 size_t possible_states_size, size_t *actual_size);
497
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500498/** @struct set_effecter_state_field
499 *
500 * Structure representing a stateField in SetStateEffecterStates command */
501
502typedef struct state_field_for_state_effecter_set {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500503 uint8_t set_request; //!< Whether to change the state
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500504 uint8_t effecter_state; //!< Expected state of the effecter
505} __attribute__((packed)) set_effecter_state_field;
506
Jolie Ku3557bad2020-03-02 16:22:57 +0800507/** @struct get_sensor_readings_field
508 *
509 * Structure representing a stateField in GetStateSensorReadings command */
510
511typedef struct state_field_for_get_state_sensor_readings {
512 uint8_t sensor_op_state; //!< The state of the sensor itself
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500513 uint8_t present_state; //!< Return a state value
Jolie Ku3557bad2020-03-02 16:22:57 +0800514 uint8_t previous_state; //!< The state that the presentState was entered
515 //! from. This must be different from the
516 //! present state
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500517 uint8_t event_state; //!< Return a state value from a PLDM State Set
Jolie Ku3557bad2020-03-02 16:22:57 +0800518 //! that is associated with the sensor
519} __attribute__((packed)) get_sensor_state_field;
520
Priyanga7257fdf2019-06-10 01:59:45 -0500521/** @struct PLDM_SetStateEffecterStates_Request
522 *
523 * Structure representing PLDM set state effecter states request.
524 */
525struct pldm_set_state_effecter_states_req {
526 uint16_t effecter_id;
527 uint8_t comp_effecter_count;
528 set_effecter_state_field field[8];
529} __attribute__((packed));
530
Sampa Misra7fcfb662019-05-08 13:13:53 -0500531/** @struct pldm_get_pdr_resp
532 *
533 * structure representing GetPDR response packet
534 * transfer CRC is not part of the structure and will be
535 * added at the end of last packet in multipart transfer
536 */
537struct pldm_get_pdr_resp {
538 uint8_t completion_code;
539 uint32_t next_record_handle;
540 uint32_t next_data_transfer_handle;
541 uint8_t transfer_flag;
542 uint16_t response_count;
543 uint8_t record_data[1];
544} __attribute__((packed));
545
546/** @struct pldm_get_pdr_req
547 *
548 * structure representing GetPDR request packet
549 */
550struct pldm_get_pdr_req {
551 uint32_t record_handle;
552 uint32_t data_transfer_handle;
553 uint8_t transfer_op_flag;
554 uint16_t request_count;
555 uint16_t record_change_number;
556} __attribute__((packed));
557
George Liu30b859f2020-01-07 15:03:22 +0800558/** @struct pldm_set_numeric_effecter_value_req
559 *
560 * structure representing SetNumericEffecterValue request packet
561 */
562struct pldm_set_numeric_effecter_value_req {
563 uint16_t effecter_id;
564 uint8_t effecter_data_size;
565 uint8_t effecter_value[1];
566} __attribute__((packed));
567
Jolie Ku3557bad2020-03-02 16:22:57 +0800568/** @struct pldm_get_state_sensor_readings_req
569 *
570 * Structure representing PLDM get state sensor readings request.
571 */
572struct pldm_get_state_sensor_readings_req {
573 uint16_t sensor_id;
574 bitfield8_t sensor_rearm;
575 uint8_t reserved;
576} __attribute__((packed));
577
578/** @struct pldm_get_state_sensor_readings_resp
579 *
580 * Structure representing PLDM get state sensor readings response.
581 */
582struct pldm_get_state_sensor_readings_resp {
583 uint8_t completion_code;
584 uint8_t comp_sensor_count;
585 get_sensor_state_field field[1];
586} __attribute__((packed));
587
Zahed Hossaind4abab12020-02-06 03:36:43 -0600588/** @struct pldm_sensor_event
589 *
590 * structure representing sensorEventClass
591 */
592struct pldm_sensor_event_data {
593 uint16_t sensor_id;
594 uint8_t sensor_event_class_type;
595 uint8_t event_class[1];
596} __attribute__((packed));
597
598/** @struct pldm_state_sensor_state
599 *
600 * structure representing sensorEventClass for stateSensorState
601 */
602struct pldm_sensor_event_state_sensor_state {
603 uint8_t sensor_offset;
604 uint8_t event_state;
605 uint8_t previous_event_state;
606} __attribute__((packed));
607
608/** @struct pldm_sensor_event_numeric_sensor_state
609 *
610 * structure representing sensorEventClass for stateSensorState
611 */
612struct pldm_sensor_event_numeric_sensor_state {
613 uint8_t event_state;
614 uint8_t previous_event_state;
615 uint8_t sensor_data_size;
616 uint8_t present_reading[1];
617} __attribute__((packed));
618
619/** @struct pldm_sensor_event_sensor_op_state
620 *
621 * structure representing sensorEventClass for SensorOpState
622 */
623struct pldm_sensor_event_sensor_op_state {
624 uint8_t present_op_state;
625 uint8_t previous_op_state;
626} __attribute__((packed));
627
628/** @struct pldm_platform_event_message_req
629 *
630 * structure representing PlatformEventMessage command request data
631 */
632struct pldm_platform_event_message_req {
633 uint8_t format_version;
634 uint8_t tid;
635 uint8_t event_class;
636 uint8_t event_data[1];
637} __attribute__((packed));
638
639/** @struct pldm_platform_event_message_response
640 *
641 * structure representing PlatformEventMessage command response data
642 */
643struct pldm_platform_event_message_resp {
644 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500645 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600646} __attribute__((packed));
647
648/** @struct pldm_pdr_repository_chg_event_data
649 *
650 * structure representing pldmPDRRepositoryChgEvent class eventData
651 */
652struct pldm_pdr_repository_chg_event_data {
653 uint8_t event_data_format;
654 uint8_t number_of_change_records;
655 uint8_t change_records[1];
656} __attribute__((packed));
657
658/** @struct pldm_pdr_repository_chg_event_change_record_data
659 *
660 * structure representing pldmPDRRepositoryChgEvent class eventData's change
661 * record data
662 */
663struct pldm_pdr_repository_change_record_data {
664 uint8_t event_data_operation;
665 uint8_t number_of_change_entries;
666 uint32_t change_entry[1];
667} __attribute__((packed));
668
Jolie Ku6787f172020-03-19 11:15:53 +0800669/** @struct pldm_get_numeric_effecter_value_req
670 *
671 * structure representing GetNumericEffecterValue request packet
672 */
673struct pldm_get_numeric_effecter_value_req {
674 uint16_t effecter_id;
675} __attribute__((packed));
676
677/** @struct pldm_get_numeric_effecter_value_resp
678 *
679 * structure representing GetNumericEffecterValue response packet
680 */
681struct pldm_get_numeric_effecter_value_resp {
682 uint8_t completion_code;
683 uint8_t effecter_data_size;
684 uint8_t effecter_oper_state;
685 uint8_t pending_and_present_values[1];
686} __attribute__((packed));
687
Jolie Kuf798c8f2020-04-14 11:18:06 +0800688/** @struct pldm_get_sensor_reading_req
689 *
690 * Structure representing PLDM get sensor reading request
691 */
692struct pldm_get_sensor_reading_req {
693 uint16_t sensor_id;
694 bool8_t rearm_event_state;
695} __attribute__((packed));
696
697/** @struct pldm_get_sensor_reading_resp
698 *
699 * Structure representing PLDM get sensor reading response
700 */
701struct pldm_get_sensor_reading_resp {
702 uint8_t completion_code;
703 uint8_t sensor_data_size;
704 uint8_t sensor_operational_state;
705 uint8_t sensor_event_message_enable;
706 uint8_t present_state;
707 uint8_t previous_state;
708 uint8_t event_state;
709 uint8_t present_reading[1];
710} __attribute__((packed));
711
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500712/* Responder */
713
George Liu30b859f2020-01-07 15:03:22 +0800714/* SetNumericEffecterValue */
715
716/** @brief Decode SetNumericEffecterValue request data
717 *
718 * @param[in] msg - Request message
719 * @param[in] payload_length - Length of request message payload
720 * @param[out] effecter_id - used to identify and access the effecter
721 * @param[out] effecter_data_size - The bit width and format of the setting
722 * value for the effecter.
723 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
724 * @param[out] effecter_value - The setting value of numeric effecter being
725 * requested.
726 * @return pldm_completion_codes
727 */
728int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
729 size_t payload_length,
730 uint16_t *effecter_id,
731 uint8_t *effecter_data_size,
732 uint8_t *effecter_value);
733
734/** @brief Create a PLDM response message for SetNumericEffecterValue
735 *
736 * @param[in] instance_id - Message's instance id
737 * @param[in] completion_code - PLDM completion code
738 * @param[out] msg - Message will be written to this
739 * @param[in] payload_length - Length of request message payload
740 * @return pldm_completion_codes
741 * @note Caller is responsible for memory alloc and dealloc of param
742 * 'msg.body.payload'
743 */
744int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
745 uint8_t completion_code,
746 struct pldm_msg *msg,
747 size_t payload_length);
748
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500749/* SetStateEffecterStates */
750
751/** @brief Create a PLDM response message for SetStateEffecterStates
752 *
753 * @param[in] instance_id - Message's instance id
754 * @param[in] completion_code - PLDM completion code
755 * @param[out] msg - Message will be written to this
756 * @return pldm_completion_codes
757 * @note Caller is responsible for memory alloc and dealloc of param
758 * 'msg.body.payload'
759 */
760
761int encode_set_state_effecter_states_resp(uint8_t instance_id,
762 uint8_t completion_code,
763 struct pldm_msg *msg);
764
765/** @brief Decode SetStateEffecterStates request data
766 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500767 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500768 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500769 * @param[out] effecter_id - used to identify and access the effecter
770 * @param[out] comp_effecter_count - number of individual sets of effecter
771 * information. Upto eight sets of state effecter info can be accessed
772 * for a given effecter.
773 * @param[out] field - each unit is an instance of the stateFileld structure
774 * that is used to set the requested state for a particular effecter
775 * within the state effecter. This field holds the starting address of
776 * the stateField values. The user is responsible to allocate the
777 * memory prior to calling this command. Since the state field count is
778 * not known in advance, the user should allocate the maximum size
779 * always, which is 8 in number.
780 * @return pldm_completion_codes
781 */
vkaverapa6575b82019-04-03 05:33:52 -0500782
Zahed Hossain223a73d2019-07-04 12:46:18 -0500783int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500784 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500785 uint16_t *effecter_id,
786 uint8_t *comp_effecter_count,
787 set_effecter_state_field *field);
788
Sampa Misra7fcfb662019-05-08 13:13:53 -0500789/* GetPDR */
790
791/** @brief Create a PLDM response message for GetPDR
792 *
793 * @param[in] instance_id - Message's instance id
794 * @param[in] completion_code - PLDM completion code
795 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
796 * the PDR Repository
797 * @param[in] next_data_transfer_hndl - A handle that identifies the next
798 * portion of the PDR data to be transferred, if any
799 * @param[in] transfer_flag - Indicates the portion of PDR data being
800 * transferred
801 * @param[in] resp_cnt - The number of recordData bytes returned in this
802 * response
803 * @param[in] record_data - PDR data bytes of length resp_cnt
804 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
805 * in the last part of a PDR being transferred
806 * @param[out] msg - Message will be written to this
807 * @return pldm_completion_codes
808 * @note Caller is responsible for memory alloc and dealloc of param
809 * 'msg.payload'
810 */
811int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
812 uint32_t next_record_hndl,
813 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
814 uint16_t resp_cnt, const uint8_t *record_data,
815 uint8_t transfer_crc, struct pldm_msg *msg);
816
817/** @brief Decode GetPDR request data
818 *
819 * @param[in] msg - Request message
820 * @param[in] payload_length - Length of request message payload
821 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
822 * @param[out] data_transfer_hndl - Handle used to identify a particular
823 * multipart PDR data transfer operation
824 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
825 * portion of transfer
826 * @param[out] request_cnt - The maximum number of record bytes requested
827 * @param[out] record_chg_num - Used to determine whether the PDR has changed
828 * while PDR transfer is going on
829 * @return pldm_completion_codes
830 */
831
832int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
833 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
834 uint8_t *transfer_op_flag, uint16_t *request_cnt,
835 uint16_t *record_chg_num);
836
Jolie Ku3557bad2020-03-02 16:22:57 +0800837/* GetStateSensorReadings */
838
839/** @brief Decode GetStateSensorReadings request data
840 *
841 * @param[in] msg - Request message
842 * @param[in] payload_length - Length of request message payload
843 * @param[out] sensor_id - used to identify and access the simple or composite
844 * sensor
845 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
846 * particular sensor within the state sensor, where bit [0] corresponds
847 * to the first state sensor (sensor offset 0) and bit [7] corresponds
848 * to the eighth sensor (sensor offset 7), sequentially.
849 * @param[out] reserved - value: 0x00
850 * @return pldm_completion_codes
851 */
852
853int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
854 size_t payload_length,
855 uint16_t *sensor_id,
856 bitfield8_t *sensor_rearm,
857 uint8_t *reserved);
858
859/** @brief Encode GetStateSensorReadings response data
860 *
861 * @param[in] instance_id - Message's instance id
862 * @param[in] completion_code - PLDM completion code
863 * @param[out] comp_sensor_count - The number of individual sets of sensor
864 * information that this command accesses
865 * @param[out] field - Each stateField is an instance of a stateField structure
866 * that is used to return the present operational state setting and the
867 * present state and event state for a particular set of sensor
868 * information contained within the state sensor
869 * @param[out] msg - Message will be written to this
870 * @return pldm_completion_codes
871 */
872
873int encode_get_state_sensor_readings_resp(uint8_t instance_id,
874 uint8_t completion_code,
875 uint8_t comp_sensor_count,
876 get_sensor_state_field *field,
877 struct pldm_msg *msg);
878
Jolie Ku6787f172020-03-19 11:15:53 +0800879/* GetNumericEffecterValue */
880
881/** @brief Decode GetNumericEffecterValue request data
882 *
883 * @param[in] msg - Request message
884 * @param[in] payload_length - Length of request message payload
885 * @param[out] effecter_id - used to identify and access the effecter
886 * @return pldm_completion_codes
887 */
888int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
889 size_t payload_length,
890 uint16_t *effecter_id);
891
892/** @brief Create a PLDM response message for GetNumericEffecterValue
893 *
894 * @param[in] instance_id - Message's instance id
895 * @param[in] completion_code - PLDM completion code
896 * @param[in] effecter_data_size - The bit width and format of the setting
897 * value for the effecter.
898 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
899 * @param[in] effecter_oper_state - The state of the effecter itself
900 * @param[in] pending_value - The pending numeric value setting of the
901 * effecter. The effecterDataSize field indicates the number of
902 * bits used for this field
903 * @param[in] present_value - The present numeric value setting of the
904 * effecter. The effecterDataSize indicates the number of bits
905 * used for this field
906 * @param[out] msg - Message will be written to this
907 * @param[in] payload_length - Length of request message payload
908 * @return pldm_completion_codes
909 * @note Caller is responsible for memory alloc and dealloc of param
910 * 'msg.payload'
911 */
912int encode_get_numeric_effecter_value_resp(
913 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
914 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
915 struct pldm_msg *msg, size_t payload_length);
916
Jolie Kuf798c8f2020-04-14 11:18:06 +0800917/* GetSensorReading */
918
919/** @brief Decode GetSensorReading request data
920 *
921 * @param[in] msg - Request message
922 * @param[in] payload_length - Length of request message payload
923 * @param[out] sensor_id - A handle that is used to identify and access
924 * the sensor
925 * @param[out] rearm_event_state - true = manually re-arm EventState after
926 * responding to this request, false = no manual re-arm
927 * @return pldm_completion_codes
928 */
929
930int decode_get_sensor_reading_req(const struct pldm_msg *msg,
931 size_t payload_length, uint16_t *sensor_id,
932 bool8_t *rearm_event_state);
933
934/** @brief Encode GetSensorReading response data
935 *
936 * @param[in] instance_id - Message's instance id
937 * @param[in] completion_code - PLDM completion code
938 * @param[out] sensor_data_size - The bit width and format of reading and
939 * threshold values
940 * @param[out] sensor_operational_state - The state of the sensor itself
941 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
942 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
943 * stateEventsOnlyEnabled }
944 * @param[out] present_state - The most recently assessed state value monitored
945 * by the sensor
946 * @param[out] previous_state - The state that the presentState was entered
947 * from
948 * @param[out] event_state - Indicates which threshold crossing assertion
949 * events have been detected
950 * @param[out] present_reading - The present value indicated by the sensor
951 * @param[out] msg - Message will be written to this
952 * @param[in] payload_length - Length of request message payload
953 * @return pldm_completion_codes
954 */
955
956int encode_get_sensor_reading_resp(
957 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
958 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
959 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
960 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
961
Sampa Misra7fcfb662019-05-08 13:13:53 -0500962/* Requester */
963
George Liu820a9a52019-11-26 14:43:59 +0800964/* GetPDR */
965
966/** @brief Create a PLDM request message for GetPDR
967 *
968 * @param[in] instance_id - Message's instance id
969 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
970 * @param[in] data_transfer_hndl - Handle used to identify a particular
971 * multipart PDR data transfer operation
972 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
973 * portion of transfer
974 * @param[in] request_cnt - The maximum number of record bytes requested
975 * @param[in] record_chg_num - Used to determine whether the PDR has changed
976 * while PDR transfer is going on
977 * @param[out] msg - Message will be written to this
978 * @param[in] payload_length - Length of request message payload
979 * @return pldm_completion_codes
980 * @note Caller is responsible for memory alloc and dealloc of param
981 * 'msg.payload'
982 */
983int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
984 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
985 uint16_t request_cnt, uint16_t record_chg_num,
986 struct pldm_msg *msg, size_t payload_length);
987
988/** @brief Decode GetPDR response data
989 *
George Liu684a7162019-12-06 15:10:52 +0800990 * Note:
991 * * If the return value is not PLDM_SUCCESS, it represents a
992 * transport layer error.
993 * * If the completion_code value is not PLDM_SUCCESS, it represents a
994 * protocol layer error and all the out-parameters are invalid.
995 *
George Liu820a9a52019-11-26 14:43:59 +0800996 * @param[in] msg - Request message
997 * @param[in] payload_length - Length of request message payload
998 * @param[out] completion_code - PLDM completion code
999 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1000 * the PDR Repository
1001 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1002 * portion of the PDR data to be transferred, if any
1003 * @param[out] transfer_flag - Indicates the portion of PDR data being
1004 * transferred
1005 * @param[out] resp_cnt - The number of recordData bytes returned in this
1006 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -05001007 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1008 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +08001009 * @param[in] record_data_length - Length of record_data
1010 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1011 * in the last part of a PDR being transferred
1012 * @return pldm_completion_codes
1013 */
1014int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1015 uint8_t *completion_code, uint32_t *next_record_hndl,
1016 uint32_t *next_data_transfer_hndl,
1017 uint8_t *transfer_flag, uint16_t *resp_cnt,
1018 uint8_t *record_data, size_t record_data_length,
1019 uint8_t *transfer_crc);
1020
Sampa Misra7fcfb662019-05-08 13:13:53 -05001021/* SetStateEffecterStates */
1022
vkaverap98a2c192019-04-03 05:33:52 -05001023/** @brief Create a PLDM request message for SetStateEffecterStates
1024 *
1025 * @param[in] instance_id - Message's instance id
1026 * @param[in] effecter_id - used to identify and access the effecter
1027 * @param[in] comp_effecter_count - number of individual sets of effecter
1028 * information. Upto eight sets of state effecter info can be accessed
1029 * for a given effecter.
1030 * @param[in] field - each unit is an instance of the stateField structure
1031 * that is used to set the requested state for a particular effecter
1032 * within the state effecter. This field holds the starting address of
1033 * the stateField values. The user is responsible to allocate the
1034 * memory prior to calling this command. The user has to allocate the
1035 * field parameter as sizeof(set_effecter_state_field) *
1036 * comp_effecter_count
1037 * @param[out] msg - Message will be written to this
1038 * @return pldm_completion_codes
1039 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -05001040 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -05001041 */
1042
1043int encode_set_state_effecter_states_req(uint8_t instance_id,
1044 uint16_t effecter_id,
1045 uint8_t comp_effecter_count,
1046 set_effecter_state_field *field,
1047 struct pldm_msg *msg);
1048
1049/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +08001050 *
1051 * Note:
1052 * * If the return value is not PLDM_SUCCESS, it represents a
1053 * transport layer error.
1054 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1055 * protocol layer error and all the out-parameters are invalid.
1056 *
Zahed Hossain223a73d2019-07-04 12:46:18 -05001057 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -05001058 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -05001059 * @param[out] completion_code - PLDM completion code
1060 * @return pldm_completion_codes
1061 */
Zahed Hossain223a73d2019-07-04 12:46:18 -05001062int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -05001063 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -05001064 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +08001065
1066/* SetNumericEffecterValue */
1067
1068/** @brief Create a PLDM request message for SetNumericEffecterValue
1069 *
1070 * @param[in] instance_id - Message's instance id
1071 * @param[in] effecter_id - used to identify and access the effecter
1072 * @param[in] effecter_data_size - The bit width and format of the setting
1073 * value for the effecter.
1074 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1075 * @param[in] effecter_value - The setting value of numeric effecter being
1076 * requested.
1077 * @param[in] payload_length - Length of request message payload
1078 * @param[out] msg - Message will be written to this
1079 * @return pldm_completion_codes
1080 * @note Caller is responsible for memory alloc and dealloc of param
1081 * 'msg.payload'
1082 */
1083int encode_set_numeric_effecter_value_req(
1084 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1085 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1086
1087/** @brief Decode SetNumericEffecterValue response data
1088 * @param[in] msg - Request message
1089 * @param[in] payload_length - Length of response message payload
1090 * @param[out] completion_code - PLDM completion code
1091 * @return pldm_completion_codes
1092 */
1093int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1094 size_t payload_length,
1095 uint8_t *completion_code);
1096
Jolie Ku3557bad2020-03-02 16:22:57 +08001097/** @brief Create a PLDM request message for GetStateSensorReadings
1098 *
1099 * @param[in] instance_id - Message's instance id
1100 * @param[in] sensor_id - used to identify and access the simple or composite
1101 * sensor
1102 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1103 * particular sensor within the state sensor, where bit [0] corresponds
1104 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1105 * to the eighth sensor (sensor offset 7), sequentially
1106 * @param[in] reserved - value: 0x00
1107 * @param[out] msg - Message will be written to this
1108 * @return pldm_completion_codes
1109 * @note Caller is responsible for memory alloc and dealloc of param
1110 * 'msg.payload'
1111 */
Jolie Ku3557bad2020-03-02 16:22:57 +08001112int encode_get_state_sensor_readings_req(uint8_t instance_id,
1113 uint16_t sensor_id,
1114 bitfield8_t sensor_rearm,
1115 uint8_t reserved,
1116 struct pldm_msg *msg);
1117
1118/** @brief Decode GetStateSensorReadings response data
1119 *
1120 * @param[in] msg - Request message
1121 * @param[in] payload_length - Length of response message payload
1122 * @param[out] completion_code - PLDM completion code
1123 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1124 * information that this command accesses
1125 * @param[out] field - Each stateField is an instance of a stateField structure
1126 * that is used to return the present operational state setting and the
1127 * present state and event state for a particular set of sensor
1128 * information contained within the state sensor
1129 * @return pldm_completion_codes
1130 */
1131
1132int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1133 size_t payload_length,
1134 uint8_t *completion_code,
1135 uint8_t *comp_sensor_count,
1136 get_sensor_state_field *field);
1137
Zahed Hossaind4abab12020-02-06 03:36:43 -06001138/* PlatformEventMessage */
1139
1140/** @brief Decode PlatformEventMessage request data
1141 * @param[in] msg - Request message
1142 * @param[in] payload_length - Length of response message payload
1143 * @param[out] format_version - Version of the event format
1144 * @param[out] tid - Terminus ID for the terminus that originated the event
1145 * message
1146 * @param[out] event_class - The class of event being sent
1147 * @param[out] event_data_offset - Offset where the event data should be read
1148 * from pldm msg
1149 * @return pldm_completion_codes
1150 */
1151int decode_platform_event_message_req(const struct pldm_msg *msg,
1152 size_t payload_length,
1153 uint8_t *format_version, uint8_t *tid,
1154 uint8_t *event_class,
1155 size_t *event_data_offset);
1156
1157/** @brief Encode PlatformEventMessage response data
1158 * @param[in] instance_id - Message's instance id
1159 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001160 * @param[in] platform_event_status - Response status of the event message
1161 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001162 * @param[out] msg - Message will be written to this
1163 * @return pldm_completion_codes
1164 * @note Caller is responsible for memory alloc and dealloc of param
1165 * 'msg.payload'
1166 */
1167int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001168 uint8_t completion_code,
1169 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001170 struct pldm_msg *msg);
1171
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001172/** @brief Encode PlatformEventMessage request data
1173 * @param[in] instance_id - Message's instance id
1174 * @param[in] format_version - Version of the event format
1175 * @param[in] tid - Terminus ID for the terminus that originated the event
1176 * message
1177 * @param[in] event_class - The class of event being sent
1178 * @param[in] event_data - the event data should be read from pldm msg
1179 * @param[in] event_data_length - Length of the event data
1180 * @param[out] msg - Request message
1181 * @return pldm_completion_codes
1182 * @note Caller is responsible for memory alloc and dealloc of param
1183 * 'msg.payload'
1184 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001185int encode_platform_event_message_req(
1186 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1187 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1188 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001189
1190/** @brief Decode PlatformEventMessage response data
1191 * @param[in] msg - Request message
1192 * @param[in] payload_length - Length of Response message payload
1193 * @param[out] completion_code - PLDM completion code
1194 * @param[out] platform_event_status - Response status of the event message
1195 * command
1196 * @return pldm_completion_codes
1197 */
1198int decode_platform_event_message_resp(const struct pldm_msg *msg,
1199 size_t payload_length,
1200 uint8_t *completion_code,
1201 uint8_t *platform_event_status);
1202
Zahed Hossain1c861712020-03-04 08:55:19 -06001203/** @brief Decode sensorEventData response data
1204 *
1205 * @param[in] event_data - event data from the response message
1206 * @param[in] event_data_length - length of the event data
1207 * @param[out] sensor_id - sensorID value of the sensor
1208 * @param[out] sensor_event_class_type - Type of sensor event class
1209 * @param[out] event_class_data_offset - Offset where the event class data
1210 * should be read from event data
1211 * @return pldm_completion_codes
1212 * @note Caller is responsible for memory alloc and dealloc of param
1213 * 'event_data'
1214 */
1215int decode_sensor_event_data(const uint8_t *event_data,
1216 size_t event_data_length, uint16_t *sensor_id,
1217 uint8_t *sensor_event_class_type,
1218 size_t *event_class_data_offset);
1219
1220/** @brief Decode sensorOpState response data
1221 *
1222 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1223 * @param[in] sensor_data_length - Length of sensor_data
1224 * @param[out] present_op_state - The sensorOperationalState value from the
1225 * state change that triggered the event message
1226 * @param[out] previous_op_state - The sensorOperationalState value for the
1227 * state from which the present state was entered
1228 * @return pldm_completion_codes
1229 * @note Caller is responsible for memory alloc and dealloc of param
1230 * 'sensor_data'
1231 */
1232int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1233 uint8_t *present_op_state,
1234 uint8_t *previous_op_state);
1235
1236/** @brief Decode stateSensorState response data
1237 *
1238 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1239 * @param[in] sensor_data_length - Length of sensor_data
1240 * @param[out] sensor_offset - Identifies which state sensor within a composite
1241 * state sensor the event is being returned for
1242 * @param[out] event_state - The event state value from the state change that
1243 * triggered the event message
1244 * @param[out] previous_event_state - The event state value for the state from
1245 * which the present event state was entered
1246 * @return pldm_completion_codes
1247 * @note Caller is responsible for memory alloc and dealloc of param
1248 * 'sensor_data'
1249 */
1250int decode_state_sensor_data(const uint8_t *sensor_data,
1251 size_t sensor_data_length, uint8_t *sensor_offset,
1252 uint8_t *event_state,
1253 uint8_t *previous_event_state);
1254
1255/** @brief Decode numericSensorState response data
1256 *
1257 * @param[in] sensor_data - sensor_data for sensorEventClass =
1258 * numericSensorState
1259 * @param[in] sensor_data_length - Length of sensor_data
1260 * @param[out] event_state - The eventState value from the state change that
1261 * triggered the event message
1262 * @param[out] previous_event_state - The eventState value for the state from
1263 * which the present state was entered
1264 * @param[out] sensor_data_size - The bit width and format of reading and
1265 * threshold values that the sensor returns
1266 * @param[out] present_reading - The present value indicated by the sensor
1267 * @return pldm_completion_codes
1268 * @note Caller is responsible for memory alloc and dealloc of param
1269 * 'sensor_data'
1270 */
1271int decode_numeric_sensor_data(const uint8_t *sensor_data,
1272 size_t sensor_data_length, uint8_t *event_state,
1273 uint8_t *previous_event_state,
1274 uint8_t *sensor_data_size,
1275 uint32_t *present_reading);
1276
Jolie Ku6787f172020-03-19 11:15:53 +08001277/* GetNumericEffecterValue */
1278
1279/** @brief Create a PLDM request message for GetNumericEffecterValue
1280 *
1281 * @param[in] instance_id - Message's instance id
1282 * @param[in] effecter_id - used to identify and access the effecter
1283 * @param[out] msg - Message will be written to this
1284 * @return pldm_completion_codes
1285 * @note Caller is responsible for memory alloc and dealloc of param
1286 * 'msg.payload'
1287 */
1288int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1289 uint16_t effecter_id,
1290 struct pldm_msg *msg);
1291
1292/** @brief Create a PLDM response message for GetNumericEffecterValue
1293 *
1294 * @param[in] msg - Request message
1295 * @param[in] payload_length - Length of request message payload
1296 * @param[out] completion_code - PLDM completion code
1297 * @param[out] effecter_data_size - The bit width and format of the setting
1298 * value for the effecter.
1299 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1300 * @param[out] effecter_oper_state - The state of the effecter itself
1301 * @param[out] pending_value - The pending numeric value setting of the
1302 * effecter. The effecterDataSize field indicates the number of
1303 * bits used for this field
1304 * @param[out] present_value - The present numeric value setting of the
1305 * effecter. The effecterDataSize indicates the number of bits
1306 * used for this field
1307 * @return pldm_completion_codes
1308 */
1309int decode_get_numeric_effecter_value_resp(
1310 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1311 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1312 uint8_t *pending_value, uint8_t *present_value);
1313
Zahed Hossain9be087c2020-04-02 02:26:41 -05001314/** @brief Decode pldmPDRRepositoryChgEvent response data
1315 *
1316 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1317 * @param[in] event_data_size - Length of event_data
1318 * @param[out] event_data_format - This field indicates if the changedRecords
1319 * are of PDR Types or PDR Record Handles
1320 * @param[out] number_of_change_records - The number of changeRecords following
1321 * this field
1322 * @param[out] change_record_data_offset - Identifies where changeRecord data
1323 * is located within event_data
1324 * @return pldm_completion_codes
1325 * @note Caller is responsible for memory alloc and dealloc of param
1326 * 'event_data'
1327 */
1328int decode_pldm_pdr_repository_chg_event_data(
1329 const uint8_t *event_data, size_t event_data_size,
1330 uint8_t *event_data_format, uint8_t *number_of_change_records,
1331 size_t *change_record_data_offset);
1332
Zach Clark36ad1f52020-04-13 07:04:15 -05001333/** @brief Encode PLDM PDR Repository Change eventData
1334 * @param[in] event_data_format - Format of this event data (e.g.
1335 * FORMAT_IS_PDR_HANDLES)
1336 * @param[in] number_of_change_records - Number of changeRecords in this
1337 * eventData
1338 * @param[in] event_data_operations - Array of eventDataOperations
1339 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1340 * should contain number_of_change_records elements.
1341 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1342 * for each changeRecord in this eventData. This array should contain
1343 * number_of_change_records elements.
1344 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1345 * one array per changeRecord in this eventData. The toplevel array should
1346 * contain number_of_change_records elements. Each subarray [i] should
1347 * contain numbers_of_change_entries[i] elements.
1348 * @param[in] event_data - The eventData will be encoded into this. This entire
1349 * structure must be max_change_records_size long. It must be large enough
1350 * to accomodate the data to be encoded. The caller is responsible for
1351 * allocating and deallocating it, including the variable-size
1352 * 'event_data.change_records' field. If this parameter is NULL,
1353 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1354 * to reflect the required size of the structure.
1355 * @param[out] actual_change_records_size - The actual number of meaningful
1356 * encoded bytes in event_data. The caller can over-allocate memory and use
1357 * this output to determine the real size of the structure.
1358 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1359 * encoded message would be larger than this value, an error is returned.
1360 * @return pldm_completion_codes
1361 * @note Caller is responsible for memory alloc and dealloc of param
1362 * 'event_data.change_records'
1363 */
1364int encode_pldm_pdr_repository_chg_event_data(
1365 uint8_t event_data_format, uint8_t number_of_change_records,
1366 const uint8_t *event_data_operations,
1367 const uint8_t *numbers_of_change_entries,
1368 const uint32_t *const *change_entries,
1369 struct pldm_pdr_repository_chg_event_data *event_data,
1370 size_t *actual_change_records_size, size_t max_change_records_size);
1371
Zach Clarkb728eee2020-06-18 10:01:31 -05001372/** @brief Encode event data for a PLDM Sensor Event
1373 *
1374 * @param[out] event_data The object to store the encoded event in
1375 * @param[in] event_data_size Size of the allocation for event_data
1376 * @param[in] sensor_id Sensor ID
1377 * @param[in] sensor_event_class Sensor event class
1378 * @param[in] sensor_offset Offset
1379 * @param[in] event_state Event state
1380 * @param[in] previous_event_state Previous event state
1381 * @param[out] actual_event_data_size The real size in bytes of the event_data
1382 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1383 * @note If event_data is NULL, then *actual_event_data_size will be set to
1384 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1385 * @note The caller is responsible for allocating and deallocating the
1386 * event_data
1387 */
1388int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1389 size_t event_data_size, uint16_t sensor_id,
1390 enum sensor_event_class_states sensor_event_class,
1391 uint8_t sensor_offset, uint8_t event_state,
1392 uint8_t previous_event_state,
1393 size_t *actual_event_data_size);
1394
Zahed Hossain9be087c2020-04-02 02:26:41 -05001395/** @brief Decode PldmPDRRepositoryChangeRecord response data
1396 *
1397 * @param[in] change_record_data - changeRecordData for
1398 * pldmPDRRepositoryChgEvent
1399 * @param[in] change_record_data_size - Length of change_record_data
1400 * @param[out] event_data_operation - This field indicates the changeEntries
1401 * operation types
1402 * @param[out] number_of_change_entries - The number of changeEntries following
1403 * this field
1404 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1405 * is located within change_record_data
1406 * @return pldm_completion_codes
1407 * @note Caller is responsible for memory alloc and dealloc of param
1408 * 'change_record_data'
1409 */
1410int decode_pldm_pdr_repository_change_record_data(
1411 const uint8_t *change_record_data, size_t change_record_data_size,
1412 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1413 size_t *change_entry_data_offset);
1414
Jolie Kuf798c8f2020-04-14 11:18:06 +08001415/* GetSensorReading */
1416
1417/** @brief Encode GetSensorReading request data
1418 *
1419 * @param[in] instance_id - Message's instance id
1420 * @param[in] sensor_id - A handle that is used to identify and access the
1421 * sensor
1422 * @param[in] rearm_event_state - true = manually re-arm EventState after
1423 * responding to this request, false = no manual re-arm
1424 * @param[out] msg - Message will be written to this
1425 * @return pldm_completion_codes
1426 * @note Caller is responsible for memory alloc and dealloc of param
1427 * 'msg.payload'
1428 */
1429int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1430 bool8_t rearm_event_state,
1431 struct pldm_msg *msg);
1432
1433/** @brief Decode GetSensorReading response data
1434 *
1435 * @param[in] msg - Request message
1436 * @param[in] payload_length - Length of response message payload
1437 * @param[out] completion_code - PLDM completion code
1438 * @param[out] sensor_data_size - The bit width and format of reading and
1439 * threshold values
1440 * @param[out] sensor_operational_state - The state of the sensor itself
1441 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1442 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1443 * stateEventsOnlyEnabled }
1444 * @param[out] present_state - The most recently assessed state value monitored
1445 * by the sensor
1446 * @param[out] previous_state - The state that the presentState was entered
1447 * from
1448 * @param[out] event_state - Indicates which threshold crossing assertion
1449 * events have been detected
1450 * @param[out] present_reading - The present value indicated by the sensor
1451 * @return pldm_completion_codes
1452 */
1453
1454int decode_get_sensor_reading_resp(
1455 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1456 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1457 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1458 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1459
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001460#ifdef __cplusplus
1461}
1462#endif
1463
1464#endif /* PLATFORM_H */