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