blob: bd4d5576831a4077ee86b0e8ed135454dea6665f [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 {
George Liu362c18d2020-05-14 09:46:36 +0800160 PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80,
161 PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81,
162
Sampa Misraa2fa0702019-05-31 01:28:55 -0500163 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
164 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500165
166 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
167 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530168 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500169 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
170 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
171
Sampa Misraa2fa0702019-05-31 01:28:55 -0500172 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530173};
174
Zahed Hossaind4abab12020-02-06 03:36:43 -0600175/** @brief PLDM Event types
176 */
177enum pldm_event_types {
178 PLDM_SENSOR_EVENT = 0x00,
179 PLDM_EFFECTER_EVENT = 0x01,
180 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
181 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
182 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
183 PLDM_MESSAGE_POLL_EVENT = 0x05,
184 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
185};
186
187/** @brief PLDM sensorEventClass states
188 */
189enum sensor_event_class_states {
190 PLDM_SENSOR_OP_STATE,
191 PLDM_STATE_SENSOR_STATE,
192 PLDM_NUMERIC_SENSOR_STATE
193};
194
195/** @brief PLDM sensor supported states
196 */
197enum pldm_sensor_operational_state {
198 PLDM_SENSOR_ENABLED,
199 PLDM_SENSOR_DISABLED,
200 PLDM_SENSOR_UNAVAILABLE,
201 PLDM_SENSOR_STATUSUNKOWN,
202 PLDM_SENSOR_FAILED,
203 PLDM_SENSOR_INITIALIZING,
204 PLDM_SENSOR_SHUTTINGDOWN,
205 PLDM_SENSOR_INTEST
206};
207
208/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
209 */
210enum pldm_pdr_repository_chg_event_data_format {
211 REFRESH_ENTIRE_REPOSITORY,
212 FORMAT_IS_PDR_TYPES,
213 FORMAT_IS_PDR_HANDLES
214};
215
Zahed Hossain9be087c2020-04-02 02:26:41 -0500216/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
217 * eventDataOperation
218 */
219enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
220 PLDM_REFRESH_ALL_RECORDS,
221 PLDM_RECORDS_DELETED,
222 PLDM_RECORDS_ADDED,
223 PLDM_RECORDS_MODIFIED
224};
225
Zahed Hossain1c861712020-03-04 08:55:19 -0600226/** @brief PLDM NumericSensorStatePresentReading data type
227 */
228enum pldm_sensor_readings_data_type {
229 PLDM_SENSOR_DATA_SIZE_UINT8,
230 PLDM_SENSOR_DATA_SIZE_SINT8,
231 PLDM_SENSOR_DATA_SIZE_UINT16,
232 PLDM_SENSOR_DATA_SIZE_SINT16,
233 PLDM_SENSOR_DATA_SIZE_UINT32,
234 PLDM_SENSOR_DATA_SIZE_SINT32
235};
236
Tom Joseph56e45c52020-03-16 10:01:45 +0530237/** @brief PLDM PlatformEventMessage response status
238 */
239enum pldm_platform_event_status {
240 PLDM_EVENT_NO_LOGGING = 0x00,
241 PLDM_EVENT_LOGGING_DISABLED = 0x01,
242 PLDM_EVENT_LOG_FULL = 0x02,
243 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
244 PLDM_EVENT_LOGGED = 0x04,
245 PLDM_EVENT_LOGGING_REJECTED = 0x05
246};
247
Sampa Misra12afe112020-05-25 11:40:44 -0500248/** @brief PLDM Terminus Locator PDR validity
249 */
250enum pldm_terminus_locator_pdr_validity {
251 PLDM_TL_PDR_NOT_VALID,
252 PLDM_TL_PDR_VALID
253};
254
255/** @brief PLDM Terminus Locator type
256 */
257enum pldm_terminus_locator_type {
258 PLDM_TERMINUS_LOCATOR_TYPE_UID,
259 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID,
260 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE,
261 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW
262};
263
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500264/** @struct pldm_pdr_hdr
265 *
266 * Structure representing PLDM common PDR header
267 */
268struct pldm_pdr_hdr {
269 uint32_t record_handle;
270 uint8_t version;
271 uint8_t type;
272 uint16_t record_change_num;
273 uint16_t length;
274} __attribute__((packed));
275
Sampa Misra12afe112020-05-25 11:40:44 -0500276/** @struct pldm_terminus_locator_pdr
277 *
278 * Structure representing PLDM terminus locator PDR
279 */
280struct pldm_terminus_locator_pdr {
281 struct pldm_pdr_hdr hdr;
282 uint16_t terminus_handle;
283 uint8_t validity;
284 uint8_t tid;
285 uint16_t container_id;
286 uint8_t terminus_locator_type;
287 uint8_t terminus_locator_value_size;
288 uint8_t terminus_locator_value[1];
289} __attribute__((packed));
290
291/** @struct pldm_terminus_locator_type_mctp_eid
292 *
293 * Structure representing terminus locator value for
294 * terminus locator type MCTP_EID
295 */
296struct pldm_terminus_locator_type_mctp_eid {
297 uint8_t eid;
298} __attribute__((packed));
299
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500300/** @struct pldm_pdr_entity_association
301 *
302 * Structure representing PLDM Entity Association PDR
303 */
304struct pldm_pdr_entity_association {
305 uint16_t container_id;
306 uint8_t association_type;
307 pldm_entity container;
308 uint8_t num_children;
309 pldm_entity children[1];
310} __attribute__((packed));
311
Deepak Kodihallidb914672020-02-07 02:47:45 -0600312/** @struct pldm_pdr_fru_record_set
313 *
314 * Structure representing PLDM FRU record set PDR
315 */
316struct pldm_pdr_fru_record_set {
317 uint16_t terminus_handle;
318 uint16_t fru_rsi;
319 uint16_t entity_type;
320 uint16_t entity_instance_num;
321 uint16_t container_id;
322} __attribute__((packed));
323
Tom Josephb4268602020-04-17 17:20:45 +0530324/** @struct pldm_state_sensor_pdr
325 *
326 * Structure representing PLDM state sensor PDR
327 */
328struct pldm_state_sensor_pdr {
329 struct pldm_pdr_hdr hdr;
330 uint16_t terminus_handle;
331 uint16_t sensor_id;
332 uint16_t entity_type;
333 uint16_t entity_instance;
334 uint16_t container_id;
335 uint8_t sensor_init;
336 bool8_t sensor_auxiliary_names_pdr;
337 uint8_t composite_sensor_count;
338 uint8_t possible_states[1];
339} __attribute__((packed));
340
341/** @struct state_sensor_possible_states
342 *
343 * Structure representing state enums for state sensor
344 */
345struct state_sensor_possible_states {
346 uint16_t state_set_id;
347 uint8_t possible_states_size;
348 bitfield8_t states[1];
349} __attribute__((packed));
350
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500351/** @struct pldm_state_effecter_pdr
352 *
353 * Structure representing PLDM state effecter PDR
354 */
355struct pldm_state_effecter_pdr {
356 struct pldm_pdr_hdr hdr;
357 uint16_t terminus_handle;
358 uint16_t effecter_id;
359 uint16_t entity_type;
360 uint16_t entity_instance;
361 uint16_t container_id;
362 uint16_t effecter_semantic_id;
363 uint8_t effecter_init;
364 bool8_t has_description_pdr;
365 uint8_t composite_effecter_count;
366 uint8_t possible_states[1];
367} __attribute__((packed));
368
Zach Clarkb728eee2020-06-18 10:01:31 -0500369/** @brief Encode PLDM state sensor PDR
370 *
371 * @param[in/out] sensor Structure to encode. All members of
372 * sensor, except those mentioned in the @note below, should be initialized by
373 * the caller.
374 * @param[in] allocation_size Size of sensor allocation in bytes
375 * @param[in] possible_states Possible sensor states
376 * @param[in] possible_states_size Size of possible sensor states in bytes
377 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
378 * @return int pldm_completion_codes
379 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
380 *
381 * @note The sensor parameter will be encoded in place.
382 * @note Caller is responsible for allocation of the sensor parameter. Caller
383 * must allocate enough space for the base structure and the
384 * sensor->possible_states array, otherwise the function will fail.
385 * @note sensor->hdr.length, .type, and .version will be set appropriately.
386 */
387int encode_state_sensor_pdr(
388 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
389 const struct state_sensor_possible_states *possible_states,
390 size_t possible_states_size, size_t *actual_size);
391
George Liu456c9a22020-01-13 11:36:22 +0800392/** @union union_effecter_data_size
393 *
394 * The bit width and format of reading and threshold values that the effecter
395 * returns.
396 * Refer to: DSP0248_1.2.0: 28.11 Table 87
397 */
398typedef union {
399 uint8_t value_u8;
400 int8_t value_s8;
401 uint16_t value_u16;
402 int16_t value_s16;
403 uint32_t value_u32;
404 int32_t value_s32;
405} union_effecter_data_size;
406
407/** @union union_range_field_format
408 *
409 * Indicates the format used for the nominalValue, normalMax, and normalMin
410 * fields.
411 * Refer to: DSP0248_1.2.0: 28.11 Table 87
412 */
413typedef union {
414 uint8_t value_u8;
415 int8_t value_s8;
416 uint16_t value_u16;
417 int16_t value_s16;
418 uint32_t value_u32;
419 int32_t value_s32;
420 real32_t value_f32;
421} union_range_field_format;
422
423/** @struct pldm_numeric_effecter_value_pdr
424 *
425 * Structure representing PLDM numeric effecter value PDR
426 */
427struct pldm_numeric_effecter_value_pdr {
428 struct pldm_pdr_hdr hdr;
429 uint16_t terminus_handle;
430 uint16_t effecter_id;
431 uint16_t entity_type;
432 uint16_t entity_instance;
433 uint16_t container_id;
434 uint16_t effecter_semantic_id;
435 uint8_t effecter_init;
436 bool8_t effecter_auxiliary_names;
437 uint8_t base_unit;
438 int8_t unit_modifier;
439 uint8_t rate_unit;
440 uint8_t base_oem_unit_handle;
441 uint8_t aux_unit;
442 int8_t aux_unit_modifier;
443 uint8_t aux_rate_unit;
444 uint8_t aux_oem_unit_handle;
445 bool8_t is_linear;
446 uint8_t effecter_data_size;
447 real32_t resolution;
448 real32_t offset;
449 uint16_t accuracy;
450 uint8_t plus_tolerance;
451 uint8_t minus_tolerance;
452 real32_t state_transition_interval;
453 real32_t transition_interval;
454 union_effecter_data_size max_set_table;
455 union_effecter_data_size min_set_table;
456 uint8_t range_field_format;
457 bitfield8_t range_field_support;
458 union_range_field_format nominal_value;
459 union_range_field_format normal_max;
460 union_range_field_format normal_min;
461 union_range_field_format rated_max;
462 union_range_field_format rated_min;
463} __attribute__((packed));
464
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500465/** @struct state_effecter_possible_states
466 *
467 * Structure representing state enums for state effecter
468 */
469struct state_effecter_possible_states {
470 uint16_t state_set_id;
471 uint8_t possible_states_size;
472 bitfield8_t states[1];
473} __attribute__((packed));
474
Zach Clarkb728eee2020-06-18 10:01:31 -0500475/** @brief Encode PLDM state effecter PDR
476 *
477 * @param[in/out] effecter Structure to encode. All members of
478 * effecter, except those mentioned in
479 * the @note below, should be initialized
480 * by the caller.
481 * @param[in] allocation_size Size of effecter allocation in bytes
482 * @param[in] possible_states Possible effecter states
483 * @param[in] possible_states_size Size of possible effecter states in
484 * bytes
485 * @param[out] actual_size Size of effecter PDR. Set to 0 on
486 * error.
487 * @return int pldm_completion_codes
488 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
489 *
490 * @note The effecter parameter will be encoded in place.
491 * @note Caller is responsible for allocation of the effecter parameter. Caller
492 * must allocate enough space for the base structure and the
493 * effecter->possible_states array, otherwise the function will fail.
494 * @note effecter->hdr.length, .type, and .version will be set appropriately.
495 */
496int encode_state_effecter_pdr(
497 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
498 const struct state_effecter_possible_states *possible_states,
499 size_t possible_states_size, size_t *actual_size);
500
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500501/** @struct set_effecter_state_field
502 *
503 * Structure representing a stateField in SetStateEffecterStates command */
504
505typedef struct state_field_for_state_effecter_set {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500506 uint8_t set_request; //!< Whether to change the state
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500507 uint8_t effecter_state; //!< Expected state of the effecter
508} __attribute__((packed)) set_effecter_state_field;
509
Jolie Ku3557bad2020-03-02 16:22:57 +0800510/** @struct get_sensor_readings_field
511 *
512 * Structure representing a stateField in GetStateSensorReadings command */
513
514typedef struct state_field_for_get_state_sensor_readings {
515 uint8_t sensor_op_state; //!< The state of the sensor itself
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500516 uint8_t present_state; //!< Return a state value
Jolie Ku3557bad2020-03-02 16:22:57 +0800517 uint8_t previous_state; //!< The state that the presentState was entered
518 //! from. This must be different from the
519 //! present state
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500520 uint8_t event_state; //!< Return a state value from a PLDM State Set
Jolie Ku3557bad2020-03-02 16:22:57 +0800521 //! that is associated with the sensor
522} __attribute__((packed)) get_sensor_state_field;
523
Priyanga7257fdf2019-06-10 01:59:45 -0500524/** @struct PLDM_SetStateEffecterStates_Request
525 *
526 * Structure representing PLDM set state effecter states request.
527 */
528struct pldm_set_state_effecter_states_req {
529 uint16_t effecter_id;
530 uint8_t comp_effecter_count;
531 set_effecter_state_field field[8];
532} __attribute__((packed));
533
Sampa Misra7fcfb662019-05-08 13:13:53 -0500534/** @struct pldm_get_pdr_resp
535 *
536 * structure representing GetPDR response packet
537 * transfer CRC is not part of the structure and will be
538 * added at the end of last packet in multipart transfer
539 */
540struct pldm_get_pdr_resp {
541 uint8_t completion_code;
542 uint32_t next_record_handle;
543 uint32_t next_data_transfer_handle;
544 uint8_t transfer_flag;
545 uint16_t response_count;
546 uint8_t record_data[1];
547} __attribute__((packed));
548
549/** @struct pldm_get_pdr_req
550 *
551 * structure representing GetPDR request packet
552 */
553struct pldm_get_pdr_req {
554 uint32_t record_handle;
555 uint32_t data_transfer_handle;
556 uint8_t transfer_op_flag;
557 uint16_t request_count;
558 uint16_t record_change_number;
559} __attribute__((packed));
560
George Liu30b859f2020-01-07 15:03:22 +0800561/** @struct pldm_set_numeric_effecter_value_req
562 *
563 * structure representing SetNumericEffecterValue request packet
564 */
565struct pldm_set_numeric_effecter_value_req {
566 uint16_t effecter_id;
567 uint8_t effecter_data_size;
568 uint8_t effecter_value[1];
569} __attribute__((packed));
570
Jolie Ku3557bad2020-03-02 16:22:57 +0800571/** @struct pldm_get_state_sensor_readings_req
572 *
573 * Structure representing PLDM get state sensor readings request.
574 */
575struct pldm_get_state_sensor_readings_req {
576 uint16_t sensor_id;
577 bitfield8_t sensor_rearm;
578 uint8_t reserved;
579} __attribute__((packed));
580
581/** @struct pldm_get_state_sensor_readings_resp
582 *
583 * Structure representing PLDM get state sensor readings response.
584 */
585struct pldm_get_state_sensor_readings_resp {
586 uint8_t completion_code;
587 uint8_t comp_sensor_count;
588 get_sensor_state_field field[1];
589} __attribute__((packed));
590
Zahed Hossaind4abab12020-02-06 03:36:43 -0600591/** @struct pldm_sensor_event
592 *
593 * structure representing sensorEventClass
594 */
595struct pldm_sensor_event_data {
596 uint16_t sensor_id;
597 uint8_t sensor_event_class_type;
598 uint8_t event_class[1];
599} __attribute__((packed));
600
601/** @struct pldm_state_sensor_state
602 *
603 * structure representing sensorEventClass for stateSensorState
604 */
605struct pldm_sensor_event_state_sensor_state {
606 uint8_t sensor_offset;
607 uint8_t event_state;
608 uint8_t previous_event_state;
609} __attribute__((packed));
610
611/** @struct pldm_sensor_event_numeric_sensor_state
612 *
613 * structure representing sensorEventClass for stateSensorState
614 */
615struct pldm_sensor_event_numeric_sensor_state {
616 uint8_t event_state;
617 uint8_t previous_event_state;
618 uint8_t sensor_data_size;
619 uint8_t present_reading[1];
620} __attribute__((packed));
621
622/** @struct pldm_sensor_event_sensor_op_state
623 *
624 * structure representing sensorEventClass for SensorOpState
625 */
626struct pldm_sensor_event_sensor_op_state {
627 uint8_t present_op_state;
628 uint8_t previous_op_state;
629} __attribute__((packed));
630
631/** @struct pldm_platform_event_message_req
632 *
633 * structure representing PlatformEventMessage command request data
634 */
635struct pldm_platform_event_message_req {
636 uint8_t format_version;
637 uint8_t tid;
638 uint8_t event_class;
639 uint8_t event_data[1];
640} __attribute__((packed));
641
642/** @struct pldm_platform_event_message_response
643 *
644 * structure representing PlatformEventMessage command response data
645 */
646struct pldm_platform_event_message_resp {
647 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500648 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600649} __attribute__((packed));
650
651/** @struct pldm_pdr_repository_chg_event_data
652 *
653 * structure representing pldmPDRRepositoryChgEvent class eventData
654 */
655struct pldm_pdr_repository_chg_event_data {
656 uint8_t event_data_format;
657 uint8_t number_of_change_records;
658 uint8_t change_records[1];
659} __attribute__((packed));
660
661/** @struct pldm_pdr_repository_chg_event_change_record_data
662 *
663 * structure representing pldmPDRRepositoryChgEvent class eventData's change
664 * record data
665 */
666struct pldm_pdr_repository_change_record_data {
667 uint8_t event_data_operation;
668 uint8_t number_of_change_entries;
669 uint32_t change_entry[1];
670} __attribute__((packed));
671
Jolie Ku6787f172020-03-19 11:15:53 +0800672/** @struct pldm_get_numeric_effecter_value_req
673 *
674 * structure representing GetNumericEffecterValue request packet
675 */
676struct pldm_get_numeric_effecter_value_req {
677 uint16_t effecter_id;
678} __attribute__((packed));
679
680/** @struct pldm_get_numeric_effecter_value_resp
681 *
682 * structure representing GetNumericEffecterValue response packet
683 */
684struct pldm_get_numeric_effecter_value_resp {
685 uint8_t completion_code;
686 uint8_t effecter_data_size;
687 uint8_t effecter_oper_state;
688 uint8_t pending_and_present_values[1];
689} __attribute__((packed));
690
Jolie Kuf798c8f2020-04-14 11:18:06 +0800691/** @struct pldm_get_sensor_reading_req
692 *
693 * Structure representing PLDM get sensor reading request
694 */
695struct pldm_get_sensor_reading_req {
696 uint16_t sensor_id;
697 bool8_t rearm_event_state;
698} __attribute__((packed));
699
700/** @struct pldm_get_sensor_reading_resp
701 *
702 * Structure representing PLDM get sensor reading response
703 */
704struct pldm_get_sensor_reading_resp {
705 uint8_t completion_code;
706 uint8_t sensor_data_size;
707 uint8_t sensor_operational_state;
708 uint8_t sensor_event_message_enable;
709 uint8_t present_state;
710 uint8_t previous_state;
711 uint8_t event_state;
712 uint8_t present_reading[1];
713} __attribute__((packed));
714
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500715/* Responder */
716
George Liu30b859f2020-01-07 15:03:22 +0800717/* SetNumericEffecterValue */
718
719/** @brief Decode SetNumericEffecterValue request data
720 *
721 * @param[in] msg - Request message
722 * @param[in] payload_length - Length of request message payload
723 * @param[out] effecter_id - used to identify and access the effecter
724 * @param[out] effecter_data_size - The bit width and format of the setting
725 * value for the effecter.
726 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
727 * @param[out] effecter_value - The setting value of numeric effecter being
728 * requested.
729 * @return pldm_completion_codes
730 */
731int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
732 size_t payload_length,
733 uint16_t *effecter_id,
734 uint8_t *effecter_data_size,
735 uint8_t *effecter_value);
736
737/** @brief Create a PLDM response message for SetNumericEffecterValue
738 *
739 * @param[in] instance_id - Message's instance id
740 * @param[in] completion_code - PLDM completion code
741 * @param[out] msg - Message will be written to this
742 * @param[in] payload_length - Length of request message payload
743 * @return pldm_completion_codes
744 * @note Caller is responsible for memory alloc and dealloc of param
745 * 'msg.body.payload'
746 */
747int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
748 uint8_t completion_code,
749 struct pldm_msg *msg,
750 size_t payload_length);
751
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500752/* SetStateEffecterStates */
753
754/** @brief Create a PLDM response message for SetStateEffecterStates
755 *
756 * @param[in] instance_id - Message's instance id
757 * @param[in] completion_code - PLDM completion code
758 * @param[out] msg - Message will be written to this
759 * @return pldm_completion_codes
760 * @note Caller is responsible for memory alloc and dealloc of param
761 * 'msg.body.payload'
762 */
763
764int encode_set_state_effecter_states_resp(uint8_t instance_id,
765 uint8_t completion_code,
766 struct pldm_msg *msg);
767
768/** @brief Decode SetStateEffecterStates request data
769 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500770 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500771 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500772 * @param[out] effecter_id - used to identify and access the effecter
773 * @param[out] comp_effecter_count - number of individual sets of effecter
774 * information. Upto eight sets of state effecter info can be accessed
775 * for a given effecter.
776 * @param[out] field - each unit is an instance of the stateFileld structure
777 * that is used to set the requested state for a particular effecter
778 * within the state effecter. This field holds the starting address of
779 * the stateField values. The user is responsible to allocate the
780 * memory prior to calling this command. Since the state field count is
781 * not known in advance, the user should allocate the maximum size
782 * always, which is 8 in number.
783 * @return pldm_completion_codes
784 */
vkaverapa6575b82019-04-03 05:33:52 -0500785
Zahed Hossain223a73d2019-07-04 12:46:18 -0500786int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500787 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500788 uint16_t *effecter_id,
789 uint8_t *comp_effecter_count,
790 set_effecter_state_field *field);
791
Sampa Misra7fcfb662019-05-08 13:13:53 -0500792/* GetPDR */
793
794/** @brief Create a PLDM response message for GetPDR
795 *
796 * @param[in] instance_id - Message's instance id
797 * @param[in] completion_code - PLDM completion code
798 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
799 * the PDR Repository
800 * @param[in] next_data_transfer_hndl - A handle that identifies the next
801 * portion of the PDR data to be transferred, if any
802 * @param[in] transfer_flag - Indicates the portion of PDR data being
803 * transferred
804 * @param[in] resp_cnt - The number of recordData bytes returned in this
805 * response
806 * @param[in] record_data - PDR data bytes of length resp_cnt
807 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
808 * in the last part of a PDR being transferred
809 * @param[out] msg - Message will be written to this
810 * @return pldm_completion_codes
811 * @note Caller is responsible for memory alloc and dealloc of param
812 * 'msg.payload'
813 */
814int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
815 uint32_t next_record_hndl,
816 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
817 uint16_t resp_cnt, const uint8_t *record_data,
818 uint8_t transfer_crc, struct pldm_msg *msg);
819
820/** @brief Decode GetPDR request data
821 *
822 * @param[in] msg - Request message
823 * @param[in] payload_length - Length of request message payload
824 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
825 * @param[out] data_transfer_hndl - Handle used to identify a particular
826 * multipart PDR data transfer operation
827 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
828 * portion of transfer
829 * @param[out] request_cnt - The maximum number of record bytes requested
830 * @param[out] record_chg_num - Used to determine whether the PDR has changed
831 * while PDR transfer is going on
832 * @return pldm_completion_codes
833 */
834
835int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
836 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
837 uint8_t *transfer_op_flag, uint16_t *request_cnt,
838 uint16_t *record_chg_num);
839
Jolie Ku3557bad2020-03-02 16:22:57 +0800840/* GetStateSensorReadings */
841
842/** @brief Decode GetStateSensorReadings request data
843 *
844 * @param[in] msg - Request message
845 * @param[in] payload_length - Length of request message payload
846 * @param[out] sensor_id - used to identify and access the simple or composite
847 * sensor
848 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
849 * particular sensor within the state sensor, where bit [0] corresponds
850 * to the first state sensor (sensor offset 0) and bit [7] corresponds
851 * to the eighth sensor (sensor offset 7), sequentially.
852 * @param[out] reserved - value: 0x00
853 * @return pldm_completion_codes
854 */
855
856int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
857 size_t payload_length,
858 uint16_t *sensor_id,
859 bitfield8_t *sensor_rearm,
860 uint8_t *reserved);
861
862/** @brief Encode GetStateSensorReadings response data
863 *
864 * @param[in] instance_id - Message's instance id
865 * @param[in] completion_code - PLDM completion code
866 * @param[out] comp_sensor_count - The number of individual sets of sensor
867 * information that this command accesses
868 * @param[out] field - Each stateField is an instance of a stateField structure
869 * that is used to return the present operational state setting and the
870 * present state and event state for a particular set of sensor
871 * information contained within the state sensor
872 * @param[out] msg - Message will be written to this
873 * @return pldm_completion_codes
874 */
875
876int encode_get_state_sensor_readings_resp(uint8_t instance_id,
877 uint8_t completion_code,
878 uint8_t comp_sensor_count,
879 get_sensor_state_field *field,
880 struct pldm_msg *msg);
881
Jolie Ku6787f172020-03-19 11:15:53 +0800882/* GetNumericEffecterValue */
883
884/** @brief Decode GetNumericEffecterValue request data
885 *
886 * @param[in] msg - Request message
887 * @param[in] payload_length - Length of request message payload
888 * @param[out] effecter_id - used to identify and access the effecter
889 * @return pldm_completion_codes
890 */
891int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
892 size_t payload_length,
893 uint16_t *effecter_id);
894
895/** @brief Create a PLDM response message for GetNumericEffecterValue
896 *
897 * @param[in] instance_id - Message's instance id
898 * @param[in] completion_code - PLDM completion code
899 * @param[in] effecter_data_size - The bit width and format of the setting
900 * value for the effecter.
901 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
902 * @param[in] effecter_oper_state - The state of the effecter itself
903 * @param[in] pending_value - The pending numeric value setting of the
904 * effecter. The effecterDataSize field indicates the number of
905 * bits used for this field
906 * @param[in] present_value - The present numeric value setting of the
907 * effecter. The effecterDataSize indicates the number of bits
908 * used for this field
909 * @param[out] msg - Message will be written to this
910 * @param[in] payload_length - Length of request message payload
911 * @return pldm_completion_codes
912 * @note Caller is responsible for memory alloc and dealloc of param
913 * 'msg.payload'
914 */
915int encode_get_numeric_effecter_value_resp(
916 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
917 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
918 struct pldm_msg *msg, size_t payload_length);
919
Jolie Kuf798c8f2020-04-14 11:18:06 +0800920/* GetSensorReading */
921
922/** @brief Decode GetSensorReading request data
923 *
924 * @param[in] msg - Request message
925 * @param[in] payload_length - Length of request message payload
926 * @param[out] sensor_id - A handle that is used to identify and access
927 * the sensor
928 * @param[out] rearm_event_state - true = manually re-arm EventState after
929 * responding to this request, false = no manual re-arm
930 * @return pldm_completion_codes
931 */
932
933int decode_get_sensor_reading_req(const struct pldm_msg *msg,
934 size_t payload_length, uint16_t *sensor_id,
935 bool8_t *rearm_event_state);
936
937/** @brief Encode GetSensorReading response data
938 *
939 * @param[in] instance_id - Message's instance id
940 * @param[in] completion_code - PLDM completion code
941 * @param[out] sensor_data_size - The bit width and format of reading and
942 * threshold values
943 * @param[out] sensor_operational_state - The state of the sensor itself
944 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
945 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
946 * stateEventsOnlyEnabled }
947 * @param[out] present_state - The most recently assessed state value monitored
948 * by the sensor
949 * @param[out] previous_state - The state that the presentState was entered
950 * from
951 * @param[out] event_state - Indicates which threshold crossing assertion
952 * events have been detected
953 * @param[out] present_reading - The present value indicated by the sensor
954 * @param[out] msg - Message will be written to this
955 * @param[in] payload_length - Length of request message payload
956 * @return pldm_completion_codes
957 */
958
959int encode_get_sensor_reading_resp(
960 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
961 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
962 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
963 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
964
Sampa Misra7fcfb662019-05-08 13:13:53 -0500965/* Requester */
966
George Liu820a9a52019-11-26 14:43:59 +0800967/* GetPDR */
968
969/** @brief Create a PLDM request message for GetPDR
970 *
971 * @param[in] instance_id - Message's instance id
972 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
973 * @param[in] data_transfer_hndl - Handle used to identify a particular
974 * multipart PDR data transfer operation
975 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
976 * portion of transfer
977 * @param[in] request_cnt - The maximum number of record bytes requested
978 * @param[in] record_chg_num - Used to determine whether the PDR has changed
979 * while PDR transfer is going on
980 * @param[out] msg - Message will be written to this
981 * @param[in] payload_length - Length of request message payload
982 * @return pldm_completion_codes
983 * @note Caller is responsible for memory alloc and dealloc of param
984 * 'msg.payload'
985 */
986int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
987 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
988 uint16_t request_cnt, uint16_t record_chg_num,
989 struct pldm_msg *msg, size_t payload_length);
990
991/** @brief Decode GetPDR response data
992 *
George Liu684a7162019-12-06 15:10:52 +0800993 * Note:
994 * * If the return value is not PLDM_SUCCESS, it represents a
995 * transport layer error.
996 * * If the completion_code value is not PLDM_SUCCESS, it represents a
997 * protocol layer error and all the out-parameters are invalid.
998 *
George Liu820a9a52019-11-26 14:43:59 +0800999 * @param[in] msg - Request message
1000 * @param[in] payload_length - Length of request message payload
1001 * @param[out] completion_code - PLDM completion code
1002 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1003 * the PDR Repository
1004 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1005 * portion of the PDR data to be transferred, if any
1006 * @param[out] transfer_flag - Indicates the portion of PDR data being
1007 * transferred
1008 * @param[out] resp_cnt - The number of recordData bytes returned in this
1009 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -05001010 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1011 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +08001012 * @param[in] record_data_length - Length of record_data
1013 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1014 * in the last part of a PDR being transferred
1015 * @return pldm_completion_codes
1016 */
1017int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1018 uint8_t *completion_code, uint32_t *next_record_hndl,
1019 uint32_t *next_data_transfer_hndl,
1020 uint8_t *transfer_flag, uint16_t *resp_cnt,
1021 uint8_t *record_data, size_t record_data_length,
1022 uint8_t *transfer_crc);
1023
Sampa Misra7fcfb662019-05-08 13:13:53 -05001024/* SetStateEffecterStates */
1025
vkaverap98a2c192019-04-03 05:33:52 -05001026/** @brief Create a PLDM request message for SetStateEffecterStates
1027 *
1028 * @param[in] instance_id - Message's instance id
1029 * @param[in] effecter_id - used to identify and access the effecter
1030 * @param[in] comp_effecter_count - number of individual sets of effecter
1031 * information. Upto eight sets of state effecter info can be accessed
1032 * for a given effecter.
1033 * @param[in] field - each unit is an instance of the stateField structure
1034 * that is used to set the requested state for a particular effecter
1035 * within the state effecter. This field holds the starting address of
1036 * the stateField values. The user is responsible to allocate the
1037 * memory prior to calling this command. The user has to allocate the
1038 * field parameter as sizeof(set_effecter_state_field) *
1039 * comp_effecter_count
1040 * @param[out] msg - Message will be written to this
1041 * @return pldm_completion_codes
1042 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -05001043 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -05001044 */
1045
1046int encode_set_state_effecter_states_req(uint8_t instance_id,
1047 uint16_t effecter_id,
1048 uint8_t comp_effecter_count,
1049 set_effecter_state_field *field,
1050 struct pldm_msg *msg);
1051
1052/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +08001053 *
1054 * Note:
1055 * * If the return value is not PLDM_SUCCESS, it represents a
1056 * transport layer error.
1057 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1058 * protocol layer error and all the out-parameters are invalid.
1059 *
Zahed Hossain223a73d2019-07-04 12:46:18 -05001060 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -05001061 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -05001062 * @param[out] completion_code - PLDM completion code
1063 * @return pldm_completion_codes
1064 */
Zahed Hossain223a73d2019-07-04 12:46:18 -05001065int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -05001066 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -05001067 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +08001068
1069/* SetNumericEffecterValue */
1070
1071/** @brief Create a PLDM request message for SetNumericEffecterValue
1072 *
1073 * @param[in] instance_id - Message's instance id
1074 * @param[in] effecter_id - used to identify and access the effecter
1075 * @param[in] effecter_data_size - The bit width and format of the setting
1076 * value for the effecter.
1077 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1078 * @param[in] effecter_value - The setting value of numeric effecter being
1079 * requested.
1080 * @param[in] payload_length - Length of request message payload
1081 * @param[out] msg - Message will be written to this
1082 * @return pldm_completion_codes
1083 * @note Caller is responsible for memory alloc and dealloc of param
1084 * 'msg.payload'
1085 */
1086int encode_set_numeric_effecter_value_req(
1087 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1088 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1089
1090/** @brief Decode SetNumericEffecterValue response data
1091 * @param[in] msg - Request message
1092 * @param[in] payload_length - Length of response message payload
1093 * @param[out] completion_code - PLDM completion code
1094 * @return pldm_completion_codes
1095 */
1096int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1097 size_t payload_length,
1098 uint8_t *completion_code);
1099
Jolie Ku3557bad2020-03-02 16:22:57 +08001100/** @brief Create a PLDM request message for GetStateSensorReadings
1101 *
1102 * @param[in] instance_id - Message's instance id
1103 * @param[in] sensor_id - used to identify and access the simple or composite
1104 * sensor
1105 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1106 * particular sensor within the state sensor, where bit [0] corresponds
1107 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1108 * to the eighth sensor (sensor offset 7), sequentially
1109 * @param[in] reserved - value: 0x00
1110 * @param[out] msg - Message will be written to this
1111 * @return pldm_completion_codes
1112 * @note Caller is responsible for memory alloc and dealloc of param
1113 * 'msg.payload'
1114 */
Jolie Ku3557bad2020-03-02 16:22:57 +08001115int encode_get_state_sensor_readings_req(uint8_t instance_id,
1116 uint16_t sensor_id,
1117 bitfield8_t sensor_rearm,
1118 uint8_t reserved,
1119 struct pldm_msg *msg);
1120
1121/** @brief Decode GetStateSensorReadings response data
1122 *
1123 * @param[in] msg - Request message
1124 * @param[in] payload_length - Length of response message payload
1125 * @param[out] completion_code - PLDM completion code
1126 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1127 * information that this command accesses
1128 * @param[out] field - Each stateField is an instance of a stateField structure
1129 * that is used to return the present operational state setting and the
1130 * present state and event state for a particular set of sensor
1131 * information contained within the state sensor
1132 * @return pldm_completion_codes
1133 */
1134
1135int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1136 size_t payload_length,
1137 uint8_t *completion_code,
1138 uint8_t *comp_sensor_count,
1139 get_sensor_state_field *field);
1140
Zahed Hossaind4abab12020-02-06 03:36:43 -06001141/* PlatformEventMessage */
1142
1143/** @brief Decode PlatformEventMessage request data
1144 * @param[in] msg - Request message
1145 * @param[in] payload_length - Length of response message payload
1146 * @param[out] format_version - Version of the event format
1147 * @param[out] tid - Terminus ID for the terminus that originated the event
1148 * message
1149 * @param[out] event_class - The class of event being sent
1150 * @param[out] event_data_offset - Offset where the event data should be read
1151 * from pldm msg
1152 * @return pldm_completion_codes
1153 */
1154int decode_platform_event_message_req(const struct pldm_msg *msg,
1155 size_t payload_length,
1156 uint8_t *format_version, uint8_t *tid,
1157 uint8_t *event_class,
1158 size_t *event_data_offset);
1159
1160/** @brief Encode PlatformEventMessage response data
1161 * @param[in] instance_id - Message's instance id
1162 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001163 * @param[in] platform_event_status - Response status of the event message
1164 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001165 * @param[out] msg - Message will be written to this
1166 * @return pldm_completion_codes
1167 * @note Caller is responsible for memory alloc and dealloc of param
1168 * 'msg.payload'
1169 */
1170int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001171 uint8_t completion_code,
1172 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001173 struct pldm_msg *msg);
1174
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001175/** @brief Encode PlatformEventMessage request data
1176 * @param[in] instance_id - Message's instance id
1177 * @param[in] format_version - Version of the event format
1178 * @param[in] tid - Terminus ID for the terminus that originated the event
1179 * message
1180 * @param[in] event_class - The class of event being sent
1181 * @param[in] event_data - the event data should be read from pldm msg
1182 * @param[in] event_data_length - Length of the event data
1183 * @param[out] msg - Request message
1184 * @return pldm_completion_codes
1185 * @note Caller is responsible for memory alloc and dealloc of param
1186 * 'msg.payload'
1187 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001188int encode_platform_event_message_req(
1189 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1190 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1191 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001192
1193/** @brief Decode PlatformEventMessage response data
1194 * @param[in] msg - Request message
1195 * @param[in] payload_length - Length of Response message payload
1196 * @param[out] completion_code - PLDM completion code
1197 * @param[out] platform_event_status - Response status of the event message
1198 * command
1199 * @return pldm_completion_codes
1200 */
1201int decode_platform_event_message_resp(const struct pldm_msg *msg,
1202 size_t payload_length,
1203 uint8_t *completion_code,
1204 uint8_t *platform_event_status);
1205
Zahed Hossain1c861712020-03-04 08:55:19 -06001206/** @brief Decode sensorEventData response data
1207 *
1208 * @param[in] event_data - event data from the response message
1209 * @param[in] event_data_length - length of the event data
1210 * @param[out] sensor_id - sensorID value of the sensor
1211 * @param[out] sensor_event_class_type - Type of sensor event class
1212 * @param[out] event_class_data_offset - Offset where the event class data
1213 * should be read from event data
1214 * @return pldm_completion_codes
1215 * @note Caller is responsible for memory alloc and dealloc of param
1216 * 'event_data'
1217 */
1218int decode_sensor_event_data(const uint8_t *event_data,
1219 size_t event_data_length, uint16_t *sensor_id,
1220 uint8_t *sensor_event_class_type,
1221 size_t *event_class_data_offset);
1222
1223/** @brief Decode sensorOpState response data
1224 *
1225 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1226 * @param[in] sensor_data_length - Length of sensor_data
1227 * @param[out] present_op_state - The sensorOperationalState value from the
1228 * state change that triggered the event message
1229 * @param[out] previous_op_state - The sensorOperationalState value for the
1230 * state from which the present state was entered
1231 * @return pldm_completion_codes
1232 * @note Caller is responsible for memory alloc and dealloc of param
1233 * 'sensor_data'
1234 */
1235int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1236 uint8_t *present_op_state,
1237 uint8_t *previous_op_state);
1238
1239/** @brief Decode stateSensorState response data
1240 *
1241 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1242 * @param[in] sensor_data_length - Length of sensor_data
1243 * @param[out] sensor_offset - Identifies which state sensor within a composite
1244 * state sensor the event is being returned for
1245 * @param[out] event_state - The event state value from the state change that
1246 * triggered the event message
1247 * @param[out] previous_event_state - The event state value for the state from
1248 * which the present event state was entered
1249 * @return pldm_completion_codes
1250 * @note Caller is responsible for memory alloc and dealloc of param
1251 * 'sensor_data'
1252 */
1253int decode_state_sensor_data(const uint8_t *sensor_data,
1254 size_t sensor_data_length, uint8_t *sensor_offset,
1255 uint8_t *event_state,
1256 uint8_t *previous_event_state);
1257
1258/** @brief Decode numericSensorState response data
1259 *
1260 * @param[in] sensor_data - sensor_data for sensorEventClass =
1261 * numericSensorState
1262 * @param[in] sensor_data_length - Length of sensor_data
1263 * @param[out] event_state - The eventState value from the state change that
1264 * triggered the event message
1265 * @param[out] previous_event_state - The eventState value for the state from
1266 * which the present state was entered
1267 * @param[out] sensor_data_size - The bit width and format of reading and
1268 * threshold values that the sensor returns
1269 * @param[out] present_reading - The present value indicated by the sensor
1270 * @return pldm_completion_codes
1271 * @note Caller is responsible for memory alloc and dealloc of param
1272 * 'sensor_data'
1273 */
1274int decode_numeric_sensor_data(const uint8_t *sensor_data,
1275 size_t sensor_data_length, uint8_t *event_state,
1276 uint8_t *previous_event_state,
1277 uint8_t *sensor_data_size,
1278 uint32_t *present_reading);
1279
Jolie Ku6787f172020-03-19 11:15:53 +08001280/* GetNumericEffecterValue */
1281
1282/** @brief Create a PLDM request message for GetNumericEffecterValue
1283 *
1284 * @param[in] instance_id - Message's instance id
1285 * @param[in] effecter_id - used to identify and access the effecter
1286 * @param[out] msg - Message will be written to this
1287 * @return pldm_completion_codes
1288 * @note Caller is responsible for memory alloc and dealloc of param
1289 * 'msg.payload'
1290 */
1291int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1292 uint16_t effecter_id,
1293 struct pldm_msg *msg);
1294
1295/** @brief Create a PLDM response message for GetNumericEffecterValue
1296 *
1297 * @param[in] msg - Request message
1298 * @param[in] payload_length - Length of request message payload
1299 * @param[out] completion_code - PLDM completion code
1300 * @param[out] effecter_data_size - The bit width and format of the setting
1301 * value for the effecter.
1302 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1303 * @param[out] effecter_oper_state - The state of the effecter itself
1304 * @param[out] pending_value - The pending numeric value setting of the
1305 * effecter. The effecterDataSize field indicates the number of
1306 * bits used for this field
1307 * @param[out] present_value - The present numeric value setting of the
1308 * effecter. The effecterDataSize indicates the number of bits
1309 * used for this field
1310 * @return pldm_completion_codes
1311 */
1312int decode_get_numeric_effecter_value_resp(
1313 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1314 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1315 uint8_t *pending_value, uint8_t *present_value);
1316
Zahed Hossain9be087c2020-04-02 02:26:41 -05001317/** @brief Decode pldmPDRRepositoryChgEvent response data
1318 *
1319 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1320 * @param[in] event_data_size - Length of event_data
1321 * @param[out] event_data_format - This field indicates if the changedRecords
1322 * are of PDR Types or PDR Record Handles
1323 * @param[out] number_of_change_records - The number of changeRecords following
1324 * this field
1325 * @param[out] change_record_data_offset - Identifies where changeRecord data
1326 * is located within event_data
1327 * @return pldm_completion_codes
1328 * @note Caller is responsible for memory alloc and dealloc of param
1329 * 'event_data'
1330 */
1331int decode_pldm_pdr_repository_chg_event_data(
1332 const uint8_t *event_data, size_t event_data_size,
1333 uint8_t *event_data_format, uint8_t *number_of_change_records,
1334 size_t *change_record_data_offset);
1335
Zach Clark36ad1f52020-04-13 07:04:15 -05001336/** @brief Encode PLDM PDR Repository Change eventData
1337 * @param[in] event_data_format - Format of this event data (e.g.
1338 * FORMAT_IS_PDR_HANDLES)
1339 * @param[in] number_of_change_records - Number of changeRecords in this
1340 * eventData
1341 * @param[in] event_data_operations - Array of eventDataOperations
1342 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1343 * should contain number_of_change_records elements.
1344 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1345 * for each changeRecord in this eventData. This array should contain
1346 * number_of_change_records elements.
1347 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1348 * one array per changeRecord in this eventData. The toplevel array should
1349 * contain number_of_change_records elements. Each subarray [i] should
1350 * contain numbers_of_change_entries[i] elements.
1351 * @param[in] event_data - The eventData will be encoded into this. This entire
1352 * structure must be max_change_records_size long. It must be large enough
1353 * to accomodate the data to be encoded. The caller is responsible for
1354 * allocating and deallocating it, including the variable-size
1355 * 'event_data.change_records' field. If this parameter is NULL,
1356 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1357 * to reflect the required size of the structure.
1358 * @param[out] actual_change_records_size - The actual number of meaningful
1359 * encoded bytes in event_data. The caller can over-allocate memory and use
1360 * this output to determine the real size of the structure.
1361 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1362 * encoded message would be larger than this value, an error is returned.
1363 * @return pldm_completion_codes
1364 * @note Caller is responsible for memory alloc and dealloc of param
1365 * 'event_data.change_records'
1366 */
1367int encode_pldm_pdr_repository_chg_event_data(
1368 uint8_t event_data_format, uint8_t number_of_change_records,
1369 const uint8_t *event_data_operations,
1370 const uint8_t *numbers_of_change_entries,
1371 const uint32_t *const *change_entries,
1372 struct pldm_pdr_repository_chg_event_data *event_data,
1373 size_t *actual_change_records_size, size_t max_change_records_size);
1374
Zach Clarkb728eee2020-06-18 10:01:31 -05001375/** @brief Encode event data for a PLDM Sensor Event
1376 *
1377 * @param[out] event_data The object to store the encoded event in
1378 * @param[in] event_data_size Size of the allocation for event_data
1379 * @param[in] sensor_id Sensor ID
1380 * @param[in] sensor_event_class Sensor event class
1381 * @param[in] sensor_offset Offset
1382 * @param[in] event_state Event state
1383 * @param[in] previous_event_state Previous event state
1384 * @param[out] actual_event_data_size The real size in bytes of the event_data
1385 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1386 * @note If event_data is NULL, then *actual_event_data_size will be set to
1387 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1388 * @note The caller is responsible for allocating and deallocating the
1389 * event_data
1390 */
1391int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1392 size_t event_data_size, uint16_t sensor_id,
1393 enum sensor_event_class_states sensor_event_class,
1394 uint8_t sensor_offset, uint8_t event_state,
1395 uint8_t previous_event_state,
1396 size_t *actual_event_data_size);
1397
Zahed Hossain9be087c2020-04-02 02:26:41 -05001398/** @brief Decode PldmPDRRepositoryChangeRecord response data
1399 *
1400 * @param[in] change_record_data - changeRecordData for
1401 * pldmPDRRepositoryChgEvent
1402 * @param[in] change_record_data_size - Length of change_record_data
1403 * @param[out] event_data_operation - This field indicates the changeEntries
1404 * operation types
1405 * @param[out] number_of_change_entries - The number of changeEntries following
1406 * this field
1407 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1408 * is located within change_record_data
1409 * @return pldm_completion_codes
1410 * @note Caller is responsible for memory alloc and dealloc of param
1411 * 'change_record_data'
1412 */
1413int decode_pldm_pdr_repository_change_record_data(
1414 const uint8_t *change_record_data, size_t change_record_data_size,
1415 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1416 size_t *change_entry_data_offset);
1417
Jolie Kuf798c8f2020-04-14 11:18:06 +08001418/* GetSensorReading */
1419
1420/** @brief Encode GetSensorReading request data
1421 *
1422 * @param[in] instance_id - Message's instance id
1423 * @param[in] sensor_id - A handle that is used to identify and access the
1424 * sensor
1425 * @param[in] rearm_event_state - true = manually re-arm EventState after
1426 * responding to this request, false = no manual re-arm
1427 * @param[out] msg - Message will be written to this
1428 * @return pldm_completion_codes
1429 * @note Caller is responsible for memory alloc and dealloc of param
1430 * 'msg.payload'
1431 */
1432int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1433 bool8_t rearm_event_state,
1434 struct pldm_msg *msg);
1435
1436/** @brief Decode GetSensorReading response data
1437 *
1438 * @param[in] msg - Request message
1439 * @param[in] payload_length - Length of response message payload
1440 * @param[out] completion_code - PLDM completion code
1441 * @param[out] sensor_data_size - The bit width and format of reading and
1442 * threshold values
1443 * @param[out] sensor_operational_state - The state of the sensor itself
1444 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1445 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1446 * stateEventsOnlyEnabled }
1447 * @param[out] present_state - The most recently assessed state value monitored
1448 * by the sensor
1449 * @param[out] previous_state - The state that the presentState was entered
1450 * from
1451 * @param[out] event_state - Indicates which threshold crossing assertion
1452 * events have been detected
1453 * @param[out] present_reading - The present value indicated by the sensor
1454 * @return pldm_completion_codes
1455 */
1456
1457int decode_get_sensor_reading_resp(
1458 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1459 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1460 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1461 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1462
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001463#ifdef __cplusplus
1464}
1465#endif
1466
1467#endif /* PLATFORM_H */