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