blob: ed175a97cef8864335328c50a8d177684fcd74da [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
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500244/** @struct pldm_pdr_hdr
245 *
246 * Structure representing PLDM common PDR header
247 */
248struct pldm_pdr_hdr {
249 uint32_t record_handle;
250 uint8_t version;
251 uint8_t type;
252 uint16_t record_change_num;
253 uint16_t length;
254} __attribute__((packed));
255
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500256/** @struct pldm_pdr_entity_association
257 *
258 * Structure representing PLDM Entity Association PDR
259 */
260struct pldm_pdr_entity_association {
261 uint16_t container_id;
262 uint8_t association_type;
263 pldm_entity container;
264 uint8_t num_children;
265 pldm_entity children[1];
266} __attribute__((packed));
267
Deepak Kodihallidb914672020-02-07 02:47:45 -0600268/** @struct pldm_pdr_fru_record_set
269 *
270 * Structure representing PLDM FRU record set PDR
271 */
272struct pldm_pdr_fru_record_set {
273 uint16_t terminus_handle;
274 uint16_t fru_rsi;
275 uint16_t entity_type;
276 uint16_t entity_instance_num;
277 uint16_t container_id;
278} __attribute__((packed));
279
Tom Josephb4268602020-04-17 17:20:45 +0530280/** @struct pldm_state_sensor_pdr
281 *
282 * Structure representing PLDM state sensor PDR
283 */
284struct pldm_state_sensor_pdr {
285 struct pldm_pdr_hdr hdr;
286 uint16_t terminus_handle;
287 uint16_t sensor_id;
288 uint16_t entity_type;
289 uint16_t entity_instance;
290 uint16_t container_id;
291 uint8_t sensor_init;
292 bool8_t sensor_auxiliary_names_pdr;
293 uint8_t composite_sensor_count;
294 uint8_t possible_states[1];
295} __attribute__((packed));
296
297/** @struct state_sensor_possible_states
298 *
299 * Structure representing state enums for state sensor
300 */
301struct state_sensor_possible_states {
302 uint16_t state_set_id;
303 uint8_t possible_states_size;
304 bitfield8_t states[1];
305} __attribute__((packed));
306
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500307/** @struct pldm_state_effecter_pdr
308 *
309 * Structure representing PLDM state effecter PDR
310 */
311struct pldm_state_effecter_pdr {
312 struct pldm_pdr_hdr hdr;
313 uint16_t terminus_handle;
314 uint16_t effecter_id;
315 uint16_t entity_type;
316 uint16_t entity_instance;
317 uint16_t container_id;
318 uint16_t effecter_semantic_id;
319 uint8_t effecter_init;
320 bool8_t has_description_pdr;
321 uint8_t composite_effecter_count;
322 uint8_t possible_states[1];
323} __attribute__((packed));
324
Zach Clarkb728eee2020-06-18 10:01:31 -0500325/** @brief Encode PLDM state sensor PDR
326 *
327 * @param[in/out] sensor Structure to encode. All members of
328 * sensor, except those mentioned in the @note below, should be initialized by
329 * the caller.
330 * @param[in] allocation_size Size of sensor allocation in bytes
331 * @param[in] possible_states Possible sensor states
332 * @param[in] possible_states_size Size of possible sensor states in bytes
333 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
334 * @return int pldm_completion_codes
335 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
336 *
337 * @note The sensor parameter will be encoded in place.
338 * @note Caller is responsible for allocation of the sensor parameter. Caller
339 * must allocate enough space for the base structure and the
340 * sensor->possible_states array, otherwise the function will fail.
341 * @note sensor->hdr.length, .type, and .version will be set appropriately.
342 */
343int encode_state_sensor_pdr(
344 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
345 const struct state_sensor_possible_states *possible_states,
346 size_t possible_states_size, size_t *actual_size);
347
George Liu456c9a22020-01-13 11:36:22 +0800348/** @union union_effecter_data_size
349 *
350 * The bit width and format of reading and threshold values that the effecter
351 * returns.
352 * Refer to: DSP0248_1.2.0: 28.11 Table 87
353 */
354typedef union {
355 uint8_t value_u8;
356 int8_t value_s8;
357 uint16_t value_u16;
358 int16_t value_s16;
359 uint32_t value_u32;
360 int32_t value_s32;
361} union_effecter_data_size;
362
363/** @union union_range_field_format
364 *
365 * Indicates the format used for the nominalValue, normalMax, and normalMin
366 * fields.
367 * Refer to: DSP0248_1.2.0: 28.11 Table 87
368 */
369typedef union {
370 uint8_t value_u8;
371 int8_t value_s8;
372 uint16_t value_u16;
373 int16_t value_s16;
374 uint32_t value_u32;
375 int32_t value_s32;
376 real32_t value_f32;
377} union_range_field_format;
378
379/** @struct pldm_numeric_effecter_value_pdr
380 *
381 * Structure representing PLDM numeric effecter value PDR
382 */
383struct pldm_numeric_effecter_value_pdr {
384 struct pldm_pdr_hdr hdr;
385 uint16_t terminus_handle;
386 uint16_t effecter_id;
387 uint16_t entity_type;
388 uint16_t entity_instance;
389 uint16_t container_id;
390 uint16_t effecter_semantic_id;
391 uint8_t effecter_init;
392 bool8_t effecter_auxiliary_names;
393 uint8_t base_unit;
394 int8_t unit_modifier;
395 uint8_t rate_unit;
396 uint8_t base_oem_unit_handle;
397 uint8_t aux_unit;
398 int8_t aux_unit_modifier;
399 uint8_t aux_rate_unit;
400 uint8_t aux_oem_unit_handle;
401 bool8_t is_linear;
402 uint8_t effecter_data_size;
403 real32_t resolution;
404 real32_t offset;
405 uint16_t accuracy;
406 uint8_t plus_tolerance;
407 uint8_t minus_tolerance;
408 real32_t state_transition_interval;
409 real32_t transition_interval;
410 union_effecter_data_size max_set_table;
411 union_effecter_data_size min_set_table;
412 uint8_t range_field_format;
413 bitfield8_t range_field_support;
414 union_range_field_format nominal_value;
415 union_range_field_format normal_max;
416 union_range_field_format normal_min;
417 union_range_field_format rated_max;
418 union_range_field_format rated_min;
419} __attribute__((packed));
420
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500421/** @struct state_effecter_possible_states
422 *
423 * Structure representing state enums for state effecter
424 */
425struct state_effecter_possible_states {
426 uint16_t state_set_id;
427 uint8_t possible_states_size;
428 bitfield8_t states[1];
429} __attribute__((packed));
430
Zach Clarkb728eee2020-06-18 10:01:31 -0500431/** @brief Encode PLDM state effecter PDR
432 *
433 * @param[in/out] effecter Structure to encode. All members of
434 * effecter, except those mentioned in
435 * the @note below, should be initialized
436 * by the caller.
437 * @param[in] allocation_size Size of effecter allocation in bytes
438 * @param[in] possible_states Possible effecter states
439 * @param[in] possible_states_size Size of possible effecter states in
440 * bytes
441 * @param[out] actual_size Size of effecter PDR. Set to 0 on
442 * error.
443 * @return int pldm_completion_codes
444 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
445 *
446 * @note The effecter parameter will be encoded in place.
447 * @note Caller is responsible for allocation of the effecter parameter. Caller
448 * must allocate enough space for the base structure and the
449 * effecter->possible_states array, otherwise the function will fail.
450 * @note effecter->hdr.length, .type, and .version will be set appropriately.
451 */
452int encode_state_effecter_pdr(
453 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
454 const struct state_effecter_possible_states *possible_states,
455 size_t possible_states_size, size_t *actual_size);
456
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500457/** @struct set_effecter_state_field
458 *
459 * Structure representing a stateField in SetStateEffecterStates command */
460
461typedef struct state_field_for_state_effecter_set {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500462 uint8_t set_request; //!< Whether to change the state
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500463 uint8_t effecter_state; //!< Expected state of the effecter
464} __attribute__((packed)) set_effecter_state_field;
465
Jolie Ku3557bad2020-03-02 16:22:57 +0800466/** @struct get_sensor_readings_field
467 *
468 * Structure representing a stateField in GetStateSensorReadings command */
469
470typedef struct state_field_for_get_state_sensor_readings {
471 uint8_t sensor_op_state; //!< The state of the sensor itself
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500472 uint8_t present_state; //!< Return a state value
Jolie Ku3557bad2020-03-02 16:22:57 +0800473 uint8_t previous_state; //!< The state that the presentState was entered
474 //! from. This must be different from the
475 //! present state
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500476 uint8_t event_state; //!< Return a state value from a PLDM State Set
Jolie Ku3557bad2020-03-02 16:22:57 +0800477 //! that is associated with the sensor
478} __attribute__((packed)) get_sensor_state_field;
479
Priyanga7257fdf2019-06-10 01:59:45 -0500480/** @struct PLDM_SetStateEffecterStates_Request
481 *
482 * Structure representing PLDM set state effecter states request.
483 */
484struct pldm_set_state_effecter_states_req {
485 uint16_t effecter_id;
486 uint8_t comp_effecter_count;
487 set_effecter_state_field field[8];
488} __attribute__((packed));
489
Sampa Misra7fcfb662019-05-08 13:13:53 -0500490/** @struct pldm_get_pdr_resp
491 *
492 * structure representing GetPDR response packet
493 * transfer CRC is not part of the structure and will be
494 * added at the end of last packet in multipart transfer
495 */
496struct pldm_get_pdr_resp {
497 uint8_t completion_code;
498 uint32_t next_record_handle;
499 uint32_t next_data_transfer_handle;
500 uint8_t transfer_flag;
501 uint16_t response_count;
502 uint8_t record_data[1];
503} __attribute__((packed));
504
505/** @struct pldm_get_pdr_req
506 *
507 * structure representing GetPDR request packet
508 */
509struct pldm_get_pdr_req {
510 uint32_t record_handle;
511 uint32_t data_transfer_handle;
512 uint8_t transfer_op_flag;
513 uint16_t request_count;
514 uint16_t record_change_number;
515} __attribute__((packed));
516
George Liu30b859f2020-01-07 15:03:22 +0800517/** @struct pldm_set_numeric_effecter_value_req
518 *
519 * structure representing SetNumericEffecterValue request packet
520 */
521struct pldm_set_numeric_effecter_value_req {
522 uint16_t effecter_id;
523 uint8_t effecter_data_size;
524 uint8_t effecter_value[1];
525} __attribute__((packed));
526
Jolie Ku3557bad2020-03-02 16:22:57 +0800527/** @struct pldm_get_state_sensor_readings_req
528 *
529 * Structure representing PLDM get state sensor readings request.
530 */
531struct pldm_get_state_sensor_readings_req {
532 uint16_t sensor_id;
533 bitfield8_t sensor_rearm;
534 uint8_t reserved;
535} __attribute__((packed));
536
537/** @struct pldm_get_state_sensor_readings_resp
538 *
539 * Structure representing PLDM get state sensor readings response.
540 */
541struct pldm_get_state_sensor_readings_resp {
542 uint8_t completion_code;
543 uint8_t comp_sensor_count;
544 get_sensor_state_field field[1];
545} __attribute__((packed));
546
Zahed Hossaind4abab12020-02-06 03:36:43 -0600547/** @struct pldm_sensor_event
548 *
549 * structure representing sensorEventClass
550 */
551struct pldm_sensor_event_data {
552 uint16_t sensor_id;
553 uint8_t sensor_event_class_type;
554 uint8_t event_class[1];
555} __attribute__((packed));
556
557/** @struct pldm_state_sensor_state
558 *
559 * structure representing sensorEventClass for stateSensorState
560 */
561struct pldm_sensor_event_state_sensor_state {
562 uint8_t sensor_offset;
563 uint8_t event_state;
564 uint8_t previous_event_state;
565} __attribute__((packed));
566
567/** @struct pldm_sensor_event_numeric_sensor_state
568 *
569 * structure representing sensorEventClass for stateSensorState
570 */
571struct pldm_sensor_event_numeric_sensor_state {
572 uint8_t event_state;
573 uint8_t previous_event_state;
574 uint8_t sensor_data_size;
575 uint8_t present_reading[1];
576} __attribute__((packed));
577
578/** @struct pldm_sensor_event_sensor_op_state
579 *
580 * structure representing sensorEventClass for SensorOpState
581 */
582struct pldm_sensor_event_sensor_op_state {
583 uint8_t present_op_state;
584 uint8_t previous_op_state;
585} __attribute__((packed));
586
587/** @struct pldm_platform_event_message_req
588 *
589 * structure representing PlatformEventMessage command request data
590 */
591struct pldm_platform_event_message_req {
592 uint8_t format_version;
593 uint8_t tid;
594 uint8_t event_class;
595 uint8_t event_data[1];
596} __attribute__((packed));
597
598/** @struct pldm_platform_event_message_response
599 *
600 * structure representing PlatformEventMessage command response data
601 */
602struct pldm_platform_event_message_resp {
603 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500604 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600605} __attribute__((packed));
606
607/** @struct pldm_pdr_repository_chg_event_data
608 *
609 * structure representing pldmPDRRepositoryChgEvent class eventData
610 */
611struct pldm_pdr_repository_chg_event_data {
612 uint8_t event_data_format;
613 uint8_t number_of_change_records;
614 uint8_t change_records[1];
615} __attribute__((packed));
616
617/** @struct pldm_pdr_repository_chg_event_change_record_data
618 *
619 * structure representing pldmPDRRepositoryChgEvent class eventData's change
620 * record data
621 */
622struct pldm_pdr_repository_change_record_data {
623 uint8_t event_data_operation;
624 uint8_t number_of_change_entries;
625 uint32_t change_entry[1];
626} __attribute__((packed));
627
Jolie Ku6787f172020-03-19 11:15:53 +0800628/** @struct pldm_get_numeric_effecter_value_req
629 *
630 * structure representing GetNumericEffecterValue request packet
631 */
632struct pldm_get_numeric_effecter_value_req {
633 uint16_t effecter_id;
634} __attribute__((packed));
635
636/** @struct pldm_get_numeric_effecter_value_resp
637 *
638 * structure representing GetNumericEffecterValue response packet
639 */
640struct pldm_get_numeric_effecter_value_resp {
641 uint8_t completion_code;
642 uint8_t effecter_data_size;
643 uint8_t effecter_oper_state;
644 uint8_t pending_and_present_values[1];
645} __attribute__((packed));
646
Jolie Kuf798c8f2020-04-14 11:18:06 +0800647/** @struct pldm_get_sensor_reading_req
648 *
649 * Structure representing PLDM get sensor reading request
650 */
651struct pldm_get_sensor_reading_req {
652 uint16_t sensor_id;
653 bool8_t rearm_event_state;
654} __attribute__((packed));
655
656/** @struct pldm_get_sensor_reading_resp
657 *
658 * Structure representing PLDM get sensor reading response
659 */
660struct pldm_get_sensor_reading_resp {
661 uint8_t completion_code;
662 uint8_t sensor_data_size;
663 uint8_t sensor_operational_state;
664 uint8_t sensor_event_message_enable;
665 uint8_t present_state;
666 uint8_t previous_state;
667 uint8_t event_state;
668 uint8_t present_reading[1];
669} __attribute__((packed));
670
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500671/* Responder */
672
George Liu30b859f2020-01-07 15:03:22 +0800673/* SetNumericEffecterValue */
674
675/** @brief Decode SetNumericEffecterValue request data
676 *
677 * @param[in] msg - Request message
678 * @param[in] payload_length - Length of request message payload
679 * @param[out] effecter_id - used to identify and access the effecter
680 * @param[out] effecter_data_size - The bit width and format of the setting
681 * value for the effecter.
682 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
683 * @param[out] effecter_value - The setting value of numeric effecter being
684 * requested.
685 * @return pldm_completion_codes
686 */
687int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
688 size_t payload_length,
689 uint16_t *effecter_id,
690 uint8_t *effecter_data_size,
691 uint8_t *effecter_value);
692
693/** @brief Create a PLDM response message for SetNumericEffecterValue
694 *
695 * @param[in] instance_id - Message's instance id
696 * @param[in] completion_code - PLDM completion code
697 * @param[out] msg - Message will be written to this
698 * @param[in] payload_length - Length of request message payload
699 * @return pldm_completion_codes
700 * @note Caller is responsible for memory alloc and dealloc of param
701 * 'msg.body.payload'
702 */
703int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
704 uint8_t completion_code,
705 struct pldm_msg *msg,
706 size_t payload_length);
707
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500708/* SetStateEffecterStates */
709
710/** @brief Create a PLDM response message for SetStateEffecterStates
711 *
712 * @param[in] instance_id - Message's instance id
713 * @param[in] completion_code - PLDM completion code
714 * @param[out] msg - Message will be written to this
715 * @return pldm_completion_codes
716 * @note Caller is responsible for memory alloc and dealloc of param
717 * 'msg.body.payload'
718 */
719
720int encode_set_state_effecter_states_resp(uint8_t instance_id,
721 uint8_t completion_code,
722 struct pldm_msg *msg);
723
724/** @brief Decode SetStateEffecterStates request data
725 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500726 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500727 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500728 * @param[out] effecter_id - used to identify and access the effecter
729 * @param[out] comp_effecter_count - number of individual sets of effecter
730 * information. Upto eight sets of state effecter info can be accessed
731 * for a given effecter.
732 * @param[out] field - each unit is an instance of the stateFileld structure
733 * that is used to set the requested state for a particular effecter
734 * within the state effecter. This field holds the starting address of
735 * the stateField values. The user is responsible to allocate the
736 * memory prior to calling this command. Since the state field count is
737 * not known in advance, the user should allocate the maximum size
738 * always, which is 8 in number.
739 * @return pldm_completion_codes
740 */
vkaverapa6575b82019-04-03 05:33:52 -0500741
Zahed Hossain223a73d2019-07-04 12:46:18 -0500742int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500743 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500744 uint16_t *effecter_id,
745 uint8_t *comp_effecter_count,
746 set_effecter_state_field *field);
747
Sampa Misra7fcfb662019-05-08 13:13:53 -0500748/* GetPDR */
749
750/** @brief Create a PLDM response message for GetPDR
751 *
752 * @param[in] instance_id - Message's instance id
753 * @param[in] completion_code - PLDM completion code
754 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
755 * the PDR Repository
756 * @param[in] next_data_transfer_hndl - A handle that identifies the next
757 * portion of the PDR data to be transferred, if any
758 * @param[in] transfer_flag - Indicates the portion of PDR data being
759 * transferred
760 * @param[in] resp_cnt - The number of recordData bytes returned in this
761 * response
762 * @param[in] record_data - PDR data bytes of length resp_cnt
763 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
764 * in the last part of a PDR being transferred
765 * @param[out] msg - Message will be written to this
766 * @return pldm_completion_codes
767 * @note Caller is responsible for memory alloc and dealloc of param
768 * 'msg.payload'
769 */
770int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
771 uint32_t next_record_hndl,
772 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
773 uint16_t resp_cnt, const uint8_t *record_data,
774 uint8_t transfer_crc, struct pldm_msg *msg);
775
776/** @brief Decode GetPDR request data
777 *
778 * @param[in] msg - Request message
779 * @param[in] payload_length - Length of request message payload
780 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
781 * @param[out] data_transfer_hndl - Handle used to identify a particular
782 * multipart PDR data transfer operation
783 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
784 * portion of transfer
785 * @param[out] request_cnt - The maximum number of record bytes requested
786 * @param[out] record_chg_num - Used to determine whether the PDR has changed
787 * while PDR transfer is going on
788 * @return pldm_completion_codes
789 */
790
791int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
792 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
793 uint8_t *transfer_op_flag, uint16_t *request_cnt,
794 uint16_t *record_chg_num);
795
Jolie Ku3557bad2020-03-02 16:22:57 +0800796/* GetStateSensorReadings */
797
798/** @brief Decode GetStateSensorReadings request data
799 *
800 * @param[in] msg - Request message
801 * @param[in] payload_length - Length of request message payload
802 * @param[out] sensor_id - used to identify and access the simple or composite
803 * sensor
804 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
805 * particular sensor within the state sensor, where bit [0] corresponds
806 * to the first state sensor (sensor offset 0) and bit [7] corresponds
807 * to the eighth sensor (sensor offset 7), sequentially.
808 * @param[out] reserved - value: 0x00
809 * @return pldm_completion_codes
810 */
811
812int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
813 size_t payload_length,
814 uint16_t *sensor_id,
815 bitfield8_t *sensor_rearm,
816 uint8_t *reserved);
817
818/** @brief Encode GetStateSensorReadings response data
819 *
820 * @param[in] instance_id - Message's instance id
821 * @param[in] completion_code - PLDM completion code
822 * @param[out] comp_sensor_count - The number of individual sets of sensor
823 * information that this command accesses
824 * @param[out] field - Each stateField is an instance of a stateField structure
825 * that is used to return the present operational state setting and the
826 * present state and event state for a particular set of sensor
827 * information contained within the state sensor
828 * @param[out] msg - Message will be written to this
829 * @return pldm_completion_codes
830 */
831
832int encode_get_state_sensor_readings_resp(uint8_t instance_id,
833 uint8_t completion_code,
834 uint8_t comp_sensor_count,
835 get_sensor_state_field *field,
836 struct pldm_msg *msg);
837
Jolie Ku6787f172020-03-19 11:15:53 +0800838/* GetNumericEffecterValue */
839
840/** @brief Decode GetNumericEffecterValue request data
841 *
842 * @param[in] msg - Request message
843 * @param[in] payload_length - Length of request message payload
844 * @param[out] effecter_id - used to identify and access the effecter
845 * @return pldm_completion_codes
846 */
847int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
848 size_t payload_length,
849 uint16_t *effecter_id);
850
851/** @brief Create a PLDM response message for GetNumericEffecterValue
852 *
853 * @param[in] instance_id - Message's instance id
854 * @param[in] completion_code - PLDM completion code
855 * @param[in] effecter_data_size - The bit width and format of the setting
856 * value for the effecter.
857 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
858 * @param[in] effecter_oper_state - The state of the effecter itself
859 * @param[in] pending_value - The pending numeric value setting of the
860 * effecter. The effecterDataSize field indicates the number of
861 * bits used for this field
862 * @param[in] present_value - The present numeric value setting of the
863 * effecter. The effecterDataSize indicates the number of bits
864 * used for this field
865 * @param[out] msg - Message will be written to this
866 * @param[in] payload_length - Length of request message payload
867 * @return pldm_completion_codes
868 * @note Caller is responsible for memory alloc and dealloc of param
869 * 'msg.payload'
870 */
871int encode_get_numeric_effecter_value_resp(
872 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
873 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
874 struct pldm_msg *msg, size_t payload_length);
875
Jolie Kuf798c8f2020-04-14 11:18:06 +0800876/* GetSensorReading */
877
878/** @brief Decode GetSensorReading request data
879 *
880 * @param[in] msg - Request message
881 * @param[in] payload_length - Length of request message payload
882 * @param[out] sensor_id - A handle that is used to identify and access
883 * the sensor
884 * @param[out] rearm_event_state - true = manually re-arm EventState after
885 * responding to this request, false = no manual re-arm
886 * @return pldm_completion_codes
887 */
888
889int decode_get_sensor_reading_req(const struct pldm_msg *msg,
890 size_t payload_length, uint16_t *sensor_id,
891 bool8_t *rearm_event_state);
892
893/** @brief Encode GetSensorReading response data
894 *
895 * @param[in] instance_id - Message's instance id
896 * @param[in] completion_code - PLDM completion code
897 * @param[out] sensor_data_size - The bit width and format of reading and
898 * threshold values
899 * @param[out] sensor_operational_state - The state of the sensor itself
900 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
901 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
902 * stateEventsOnlyEnabled }
903 * @param[out] present_state - The most recently assessed state value monitored
904 * by the sensor
905 * @param[out] previous_state - The state that the presentState was entered
906 * from
907 * @param[out] event_state - Indicates which threshold crossing assertion
908 * events have been detected
909 * @param[out] present_reading - The present value indicated by the sensor
910 * @param[out] msg - Message will be written to this
911 * @param[in] payload_length - Length of request message payload
912 * @return pldm_completion_codes
913 */
914
915int encode_get_sensor_reading_resp(
916 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
917 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
918 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
919 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
920
Sampa Misra7fcfb662019-05-08 13:13:53 -0500921/* Requester */
922
George Liu820a9a52019-11-26 14:43:59 +0800923/* GetPDR */
924
925/** @brief Create a PLDM request message for GetPDR
926 *
927 * @param[in] instance_id - Message's instance id
928 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
929 * @param[in] data_transfer_hndl - Handle used to identify a particular
930 * multipart PDR data transfer operation
931 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
932 * portion of transfer
933 * @param[in] request_cnt - The maximum number of record bytes requested
934 * @param[in] record_chg_num - Used to determine whether the PDR has changed
935 * while PDR transfer is going on
936 * @param[out] msg - Message will be written to this
937 * @param[in] payload_length - Length of request message payload
938 * @return pldm_completion_codes
939 * @note Caller is responsible for memory alloc and dealloc of param
940 * 'msg.payload'
941 */
942int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
943 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
944 uint16_t request_cnt, uint16_t record_chg_num,
945 struct pldm_msg *msg, size_t payload_length);
946
947/** @brief Decode GetPDR response data
948 *
George Liu684a7162019-12-06 15:10:52 +0800949 * Note:
950 * * If the return value is not PLDM_SUCCESS, it represents a
951 * transport layer error.
952 * * If the completion_code value is not PLDM_SUCCESS, it represents a
953 * protocol layer error and all the out-parameters are invalid.
954 *
George Liu820a9a52019-11-26 14:43:59 +0800955 * @param[in] msg - Request message
956 * @param[in] payload_length - Length of request message payload
957 * @param[out] completion_code - PLDM completion code
958 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
959 * the PDR Repository
960 * @param[out] next_data_transfer_hndl - A handle that identifies the next
961 * portion of the PDR data to be transferred, if any
962 * @param[out] transfer_flag - Indicates the portion of PDR data being
963 * transferred
964 * @param[out] resp_cnt - The number of recordData bytes returned in this
965 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500966 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
967 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800968 * @param[in] record_data_length - Length of record_data
969 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
970 * in the last part of a PDR being transferred
971 * @return pldm_completion_codes
972 */
973int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
974 uint8_t *completion_code, uint32_t *next_record_hndl,
975 uint32_t *next_data_transfer_hndl,
976 uint8_t *transfer_flag, uint16_t *resp_cnt,
977 uint8_t *record_data, size_t record_data_length,
978 uint8_t *transfer_crc);
979
Sampa Misra7fcfb662019-05-08 13:13:53 -0500980/* SetStateEffecterStates */
981
vkaverap98a2c192019-04-03 05:33:52 -0500982/** @brief Create a PLDM request message for SetStateEffecterStates
983 *
984 * @param[in] instance_id - Message's instance id
985 * @param[in] effecter_id - used to identify and access the effecter
986 * @param[in] comp_effecter_count - number of individual sets of effecter
987 * information. Upto eight sets of state effecter info can be accessed
988 * for a given effecter.
989 * @param[in] field - each unit is an instance of the stateField structure
990 * that is used to set the requested state for a particular effecter
991 * within the state effecter. This field holds the starting address of
992 * the stateField values. The user is responsible to allocate the
993 * memory prior to calling this command. The user has to allocate the
994 * field parameter as sizeof(set_effecter_state_field) *
995 * comp_effecter_count
996 * @param[out] msg - Message will be written to this
997 * @return pldm_completion_codes
998 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500999 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -05001000 */
1001
1002int encode_set_state_effecter_states_req(uint8_t instance_id,
1003 uint16_t effecter_id,
1004 uint8_t comp_effecter_count,
1005 set_effecter_state_field *field,
1006 struct pldm_msg *msg);
1007
1008/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +08001009 *
1010 * Note:
1011 * * If the return value is not PLDM_SUCCESS, it represents a
1012 * transport layer error.
1013 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1014 * protocol layer error and all the out-parameters are invalid.
1015 *
Zahed Hossain223a73d2019-07-04 12:46:18 -05001016 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -05001017 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -05001018 * @param[out] completion_code - PLDM completion code
1019 * @return pldm_completion_codes
1020 */
Zahed Hossain223a73d2019-07-04 12:46:18 -05001021int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -05001022 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -05001023 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +08001024
1025/* SetNumericEffecterValue */
1026
1027/** @brief Create a PLDM request message for SetNumericEffecterValue
1028 *
1029 * @param[in] instance_id - Message's instance id
1030 * @param[in] effecter_id - used to identify and access the effecter
1031 * @param[in] effecter_data_size - The bit width and format of the setting
1032 * value for the effecter.
1033 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1034 * @param[in] effecter_value - The setting value of numeric effecter being
1035 * requested.
1036 * @param[in] payload_length - Length of request message payload
1037 * @param[out] msg - Message will be written to this
1038 * @return pldm_completion_codes
1039 * @note Caller is responsible for memory alloc and dealloc of param
1040 * 'msg.payload'
1041 */
1042int encode_set_numeric_effecter_value_req(
1043 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1044 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1045
1046/** @brief Decode SetNumericEffecterValue response data
1047 * @param[in] msg - Request message
1048 * @param[in] payload_length - Length of response message payload
1049 * @param[out] completion_code - PLDM completion code
1050 * @return pldm_completion_codes
1051 */
1052int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1053 size_t payload_length,
1054 uint8_t *completion_code);
1055
Jolie Ku3557bad2020-03-02 16:22:57 +08001056/** @brief Create a PLDM request message for GetStateSensorReadings
1057 *
1058 * @param[in] instance_id - Message's instance id
1059 * @param[in] sensor_id - used to identify and access the simple or composite
1060 * sensor
1061 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1062 * particular sensor within the state sensor, where bit [0] corresponds
1063 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1064 * to the eighth sensor (sensor offset 7), sequentially
1065 * @param[in] reserved - value: 0x00
1066 * @param[out] msg - Message will be written to this
1067 * @return pldm_completion_codes
1068 * @note Caller is responsible for memory alloc and dealloc of param
1069 * 'msg.payload'
1070 */
Jolie Ku3557bad2020-03-02 16:22:57 +08001071int encode_get_state_sensor_readings_req(uint8_t instance_id,
1072 uint16_t sensor_id,
1073 bitfield8_t sensor_rearm,
1074 uint8_t reserved,
1075 struct pldm_msg *msg);
1076
1077/** @brief Decode GetStateSensorReadings response data
1078 *
1079 * @param[in] msg - Request message
1080 * @param[in] payload_length - Length of response message payload
1081 * @param[out] completion_code - PLDM completion code
1082 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1083 * information that this command accesses
1084 * @param[out] field - Each stateField is an instance of a stateField structure
1085 * that is used to return the present operational state setting and the
1086 * present state and event state for a particular set of sensor
1087 * information contained within the state sensor
1088 * @return pldm_completion_codes
1089 */
1090
1091int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1092 size_t payload_length,
1093 uint8_t *completion_code,
1094 uint8_t *comp_sensor_count,
1095 get_sensor_state_field *field);
1096
Zahed Hossaind4abab12020-02-06 03:36:43 -06001097/* PlatformEventMessage */
1098
1099/** @brief Decode PlatformEventMessage request data
1100 * @param[in] msg - Request message
1101 * @param[in] payload_length - Length of response message payload
1102 * @param[out] format_version - Version of the event format
1103 * @param[out] tid - Terminus ID for the terminus that originated the event
1104 * message
1105 * @param[out] event_class - The class of event being sent
1106 * @param[out] event_data_offset - Offset where the event data should be read
1107 * from pldm msg
1108 * @return pldm_completion_codes
1109 */
1110int decode_platform_event_message_req(const struct pldm_msg *msg,
1111 size_t payload_length,
1112 uint8_t *format_version, uint8_t *tid,
1113 uint8_t *event_class,
1114 size_t *event_data_offset);
1115
1116/** @brief Encode PlatformEventMessage response data
1117 * @param[in] instance_id - Message's instance id
1118 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001119 * @param[in] platform_event_status - Response status of the event message
1120 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001121 * @param[out] msg - Message will be written to this
1122 * @return pldm_completion_codes
1123 * @note Caller is responsible for memory alloc and dealloc of param
1124 * 'msg.payload'
1125 */
1126int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001127 uint8_t completion_code,
1128 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001129 struct pldm_msg *msg);
1130
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001131/** @brief Encode PlatformEventMessage request data
1132 * @param[in] instance_id - Message's instance id
1133 * @param[in] format_version - Version of the event format
1134 * @param[in] tid - Terminus ID for the terminus that originated the event
1135 * message
1136 * @param[in] event_class - The class of event being sent
1137 * @param[in] event_data - the event data should be read from pldm msg
1138 * @param[in] event_data_length - Length of the event data
1139 * @param[out] msg - Request message
1140 * @return pldm_completion_codes
1141 * @note Caller is responsible for memory alloc and dealloc of param
1142 * 'msg.payload'
1143 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001144int encode_platform_event_message_req(
1145 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1146 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1147 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001148
1149/** @brief Decode PlatformEventMessage response data
1150 * @param[in] msg - Request message
1151 * @param[in] payload_length - Length of Response message payload
1152 * @param[out] completion_code - PLDM completion code
1153 * @param[out] platform_event_status - Response status of the event message
1154 * command
1155 * @return pldm_completion_codes
1156 */
1157int decode_platform_event_message_resp(const struct pldm_msg *msg,
1158 size_t payload_length,
1159 uint8_t *completion_code,
1160 uint8_t *platform_event_status);
1161
Zahed Hossain1c861712020-03-04 08:55:19 -06001162/** @brief Decode sensorEventData response data
1163 *
1164 * @param[in] event_data - event data from the response message
1165 * @param[in] event_data_length - length of the event data
1166 * @param[out] sensor_id - sensorID value of the sensor
1167 * @param[out] sensor_event_class_type - Type of sensor event class
1168 * @param[out] event_class_data_offset - Offset where the event class data
1169 * should be read from event data
1170 * @return pldm_completion_codes
1171 * @note Caller is responsible for memory alloc and dealloc of param
1172 * 'event_data'
1173 */
1174int decode_sensor_event_data(const uint8_t *event_data,
1175 size_t event_data_length, uint16_t *sensor_id,
1176 uint8_t *sensor_event_class_type,
1177 size_t *event_class_data_offset);
1178
1179/** @brief Decode sensorOpState response data
1180 *
1181 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1182 * @param[in] sensor_data_length - Length of sensor_data
1183 * @param[out] present_op_state - The sensorOperationalState value from the
1184 * state change that triggered the event message
1185 * @param[out] previous_op_state - The sensorOperationalState value for the
1186 * state from which the present state was entered
1187 * @return pldm_completion_codes
1188 * @note Caller is responsible for memory alloc and dealloc of param
1189 * 'sensor_data'
1190 */
1191int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1192 uint8_t *present_op_state,
1193 uint8_t *previous_op_state);
1194
1195/** @brief Decode stateSensorState response data
1196 *
1197 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1198 * @param[in] sensor_data_length - Length of sensor_data
1199 * @param[out] sensor_offset - Identifies which state sensor within a composite
1200 * state sensor the event is being returned for
1201 * @param[out] event_state - The event state value from the state change that
1202 * triggered the event message
1203 * @param[out] previous_event_state - The event state value for the state from
1204 * which the present event state was entered
1205 * @return pldm_completion_codes
1206 * @note Caller is responsible for memory alloc and dealloc of param
1207 * 'sensor_data'
1208 */
1209int decode_state_sensor_data(const uint8_t *sensor_data,
1210 size_t sensor_data_length, uint8_t *sensor_offset,
1211 uint8_t *event_state,
1212 uint8_t *previous_event_state);
1213
1214/** @brief Decode numericSensorState response data
1215 *
1216 * @param[in] sensor_data - sensor_data for sensorEventClass =
1217 * numericSensorState
1218 * @param[in] sensor_data_length - Length of sensor_data
1219 * @param[out] event_state - The eventState value from the state change that
1220 * triggered the event message
1221 * @param[out] previous_event_state - The eventState value for the state from
1222 * which the present state was entered
1223 * @param[out] sensor_data_size - The bit width and format of reading and
1224 * threshold values that the sensor returns
1225 * @param[out] present_reading - The present value indicated by the sensor
1226 * @return pldm_completion_codes
1227 * @note Caller is responsible for memory alloc and dealloc of param
1228 * 'sensor_data'
1229 */
1230int decode_numeric_sensor_data(const uint8_t *sensor_data,
1231 size_t sensor_data_length, uint8_t *event_state,
1232 uint8_t *previous_event_state,
1233 uint8_t *sensor_data_size,
1234 uint32_t *present_reading);
1235
Jolie Ku6787f172020-03-19 11:15:53 +08001236/* GetNumericEffecterValue */
1237
1238/** @brief Create a PLDM request message for GetNumericEffecterValue
1239 *
1240 * @param[in] instance_id - Message's instance id
1241 * @param[in] effecter_id - used to identify and access the effecter
1242 * @param[out] msg - Message will be written to this
1243 * @return pldm_completion_codes
1244 * @note Caller is responsible for memory alloc and dealloc of param
1245 * 'msg.payload'
1246 */
1247int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1248 uint16_t effecter_id,
1249 struct pldm_msg *msg);
1250
1251/** @brief Create a PLDM response message for GetNumericEffecterValue
1252 *
1253 * @param[in] msg - Request message
1254 * @param[in] payload_length - Length of request message payload
1255 * @param[out] completion_code - PLDM completion code
1256 * @param[out] effecter_data_size - The bit width and format of the setting
1257 * value for the effecter.
1258 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1259 * @param[out] effecter_oper_state - The state of the effecter itself
1260 * @param[out] pending_value - The pending numeric value setting of the
1261 * effecter. The effecterDataSize field indicates the number of
1262 * bits used for this field
1263 * @param[out] present_value - The present numeric value setting of the
1264 * effecter. The effecterDataSize indicates the number of bits
1265 * used for this field
1266 * @return pldm_completion_codes
1267 */
1268int decode_get_numeric_effecter_value_resp(
1269 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1270 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1271 uint8_t *pending_value, uint8_t *present_value);
1272
Zahed Hossain9be087c2020-04-02 02:26:41 -05001273/** @brief Decode pldmPDRRepositoryChgEvent response data
1274 *
1275 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1276 * @param[in] event_data_size - Length of event_data
1277 * @param[out] event_data_format - This field indicates if the changedRecords
1278 * are of PDR Types or PDR Record Handles
1279 * @param[out] number_of_change_records - The number of changeRecords following
1280 * this field
1281 * @param[out] change_record_data_offset - Identifies where changeRecord data
1282 * is located within event_data
1283 * @return pldm_completion_codes
1284 * @note Caller is responsible for memory alloc and dealloc of param
1285 * 'event_data'
1286 */
1287int decode_pldm_pdr_repository_chg_event_data(
1288 const uint8_t *event_data, size_t event_data_size,
1289 uint8_t *event_data_format, uint8_t *number_of_change_records,
1290 size_t *change_record_data_offset);
1291
Zach Clark36ad1f52020-04-13 07:04:15 -05001292/** @brief Encode PLDM PDR Repository Change eventData
1293 * @param[in] event_data_format - Format of this event data (e.g.
1294 * FORMAT_IS_PDR_HANDLES)
1295 * @param[in] number_of_change_records - Number of changeRecords in this
1296 * eventData
1297 * @param[in] event_data_operations - Array of eventDataOperations
1298 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1299 * should contain number_of_change_records elements.
1300 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1301 * for each changeRecord in this eventData. This array should contain
1302 * number_of_change_records elements.
1303 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1304 * one array per changeRecord in this eventData. The toplevel array should
1305 * contain number_of_change_records elements. Each subarray [i] should
1306 * contain numbers_of_change_entries[i] elements.
1307 * @param[in] event_data - The eventData will be encoded into this. This entire
1308 * structure must be max_change_records_size long. It must be large enough
1309 * to accomodate the data to be encoded. The caller is responsible for
1310 * allocating and deallocating it, including the variable-size
1311 * 'event_data.change_records' field. If this parameter is NULL,
1312 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1313 * to reflect the required size of the structure.
1314 * @param[out] actual_change_records_size - The actual number of meaningful
1315 * encoded bytes in event_data. The caller can over-allocate memory and use
1316 * this output to determine the real size of the structure.
1317 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1318 * encoded message would be larger than this value, an error is returned.
1319 * @return pldm_completion_codes
1320 * @note Caller is responsible for memory alloc and dealloc of param
1321 * 'event_data.change_records'
1322 */
1323int encode_pldm_pdr_repository_chg_event_data(
1324 uint8_t event_data_format, uint8_t number_of_change_records,
1325 const uint8_t *event_data_operations,
1326 const uint8_t *numbers_of_change_entries,
1327 const uint32_t *const *change_entries,
1328 struct pldm_pdr_repository_chg_event_data *event_data,
1329 size_t *actual_change_records_size, size_t max_change_records_size);
1330
Zach Clarkb728eee2020-06-18 10:01:31 -05001331/** @brief Encode event data for a PLDM Sensor Event
1332 *
1333 * @param[out] event_data The object to store the encoded event in
1334 * @param[in] event_data_size Size of the allocation for event_data
1335 * @param[in] sensor_id Sensor ID
1336 * @param[in] sensor_event_class Sensor event class
1337 * @param[in] sensor_offset Offset
1338 * @param[in] event_state Event state
1339 * @param[in] previous_event_state Previous event state
1340 * @param[out] actual_event_data_size The real size in bytes of the event_data
1341 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1342 * @note If event_data is NULL, then *actual_event_data_size will be set to
1343 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1344 * @note The caller is responsible for allocating and deallocating the
1345 * event_data
1346 */
1347int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1348 size_t event_data_size, uint16_t sensor_id,
1349 enum sensor_event_class_states sensor_event_class,
1350 uint8_t sensor_offset, uint8_t event_state,
1351 uint8_t previous_event_state,
1352 size_t *actual_event_data_size);
1353
Zahed Hossain9be087c2020-04-02 02:26:41 -05001354/** @brief Decode PldmPDRRepositoryChangeRecord response data
1355 *
1356 * @param[in] change_record_data - changeRecordData for
1357 * pldmPDRRepositoryChgEvent
1358 * @param[in] change_record_data_size - Length of change_record_data
1359 * @param[out] event_data_operation - This field indicates the changeEntries
1360 * operation types
1361 * @param[out] number_of_change_entries - The number of changeEntries following
1362 * this field
1363 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1364 * is located within change_record_data
1365 * @return pldm_completion_codes
1366 * @note Caller is responsible for memory alloc and dealloc of param
1367 * 'change_record_data'
1368 */
1369int decode_pldm_pdr_repository_change_record_data(
1370 const uint8_t *change_record_data, size_t change_record_data_size,
1371 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1372 size_t *change_entry_data_offset);
1373
Jolie Kuf798c8f2020-04-14 11:18:06 +08001374/* GetSensorReading */
1375
1376/** @brief Encode GetSensorReading request data
1377 *
1378 * @param[in] instance_id - Message's instance id
1379 * @param[in] sensor_id - A handle that is used to identify and access the
1380 * sensor
1381 * @param[in] rearm_event_state - true = manually re-arm EventState after
1382 * responding to this request, false = no manual re-arm
1383 * @param[out] msg - Message will be written to this
1384 * @return pldm_completion_codes
1385 * @note Caller is responsible for memory alloc and dealloc of param
1386 * 'msg.payload'
1387 */
1388int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1389 bool8_t rearm_event_state,
1390 struct pldm_msg *msg);
1391
1392/** @brief Decode GetSensorReading response data
1393 *
1394 * @param[in] msg - Request message
1395 * @param[in] payload_length - Length of response message payload
1396 * @param[out] completion_code - PLDM completion code
1397 * @param[out] sensor_data_size - The bit width and format of reading and
1398 * threshold values
1399 * @param[out] sensor_operational_state - The state of the sensor itself
1400 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1401 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1402 * stateEventsOnlyEnabled }
1403 * @param[out] present_state - The most recently assessed state value monitored
1404 * by the sensor
1405 * @param[out] previous_state - The state that the presentState was entered
1406 * from
1407 * @param[out] event_state - Indicates which threshold crossing assertion
1408 * events have been detected
1409 * @param[out] present_reading - The present value indicated by the sensor
1410 * @return pldm_completion_codes
1411 */
1412
1413int decode_get_sensor_reading_resp(
1414 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1415 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1416 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1417 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1418
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001419#ifdef __cplusplus
1420}
1421#endif
1422
1423#endif /* PLATFORM_H */