blob: e1b5b23c09a6e0893507884cbf09844daec9b0ce [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 {
Tom Josephb4268602020-04-17 17:20:45 +0530123 PLDM_STATE_SENSOR_PDR = 4,
George Liu456c9a22020-01-13 11:36:22 +0800124 PLDM_NUMERIC_EFFECTER_PDR = 9,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500125 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500126 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600127 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500128};
129
130/** @brief PLDM effecter initialization schemes
131 */
132enum pldm_effecter_init {
133 PLDM_NO_INIT,
134 PLDM_USE_INIT_PDR,
135 PLDM_ENABLE_EFFECTER,
136 PLDM_DISABLE_EFECTER
137};
138
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530139/** @brief PLDM Platform M&C completion codes
140 */
141enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500142 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
143 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500144
145 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
146 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530147 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500148 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
149 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
150
Sampa Misraa2fa0702019-05-31 01:28:55 -0500151 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530152};
153
Zahed Hossaind4abab12020-02-06 03:36:43 -0600154/** @brief PLDM Event types
155 */
156enum pldm_event_types {
157 PLDM_SENSOR_EVENT = 0x00,
158 PLDM_EFFECTER_EVENT = 0x01,
159 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
160 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
161 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
162 PLDM_MESSAGE_POLL_EVENT = 0x05,
163 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
164};
165
166/** @brief PLDM sensorEventClass states
167 */
168enum sensor_event_class_states {
169 PLDM_SENSOR_OP_STATE,
170 PLDM_STATE_SENSOR_STATE,
171 PLDM_NUMERIC_SENSOR_STATE
172};
173
174/** @brief PLDM sensor supported states
175 */
176enum pldm_sensor_operational_state {
177 PLDM_SENSOR_ENABLED,
178 PLDM_SENSOR_DISABLED,
179 PLDM_SENSOR_UNAVAILABLE,
180 PLDM_SENSOR_STATUSUNKOWN,
181 PLDM_SENSOR_FAILED,
182 PLDM_SENSOR_INITIALIZING,
183 PLDM_SENSOR_SHUTTINGDOWN,
184 PLDM_SENSOR_INTEST
185};
186
187/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
188 */
189enum pldm_pdr_repository_chg_event_data_format {
190 REFRESH_ENTIRE_REPOSITORY,
191 FORMAT_IS_PDR_TYPES,
192 FORMAT_IS_PDR_HANDLES
193};
194
Zahed Hossain9be087c2020-04-02 02:26:41 -0500195/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
196 * eventDataOperation
197 */
198enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
199 PLDM_REFRESH_ALL_RECORDS,
200 PLDM_RECORDS_DELETED,
201 PLDM_RECORDS_ADDED,
202 PLDM_RECORDS_MODIFIED
203};
204
Zahed Hossain1c861712020-03-04 08:55:19 -0600205/** @brief PLDM NumericSensorStatePresentReading data type
206 */
207enum pldm_sensor_readings_data_type {
208 PLDM_SENSOR_DATA_SIZE_UINT8,
209 PLDM_SENSOR_DATA_SIZE_SINT8,
210 PLDM_SENSOR_DATA_SIZE_UINT16,
211 PLDM_SENSOR_DATA_SIZE_SINT16,
212 PLDM_SENSOR_DATA_SIZE_UINT32,
213 PLDM_SENSOR_DATA_SIZE_SINT32
214};
215
Tom Joseph56e45c52020-03-16 10:01:45 +0530216/** @brief PLDM PlatformEventMessage response status
217 */
218enum pldm_platform_event_status {
219 PLDM_EVENT_NO_LOGGING = 0x00,
220 PLDM_EVENT_LOGGING_DISABLED = 0x01,
221 PLDM_EVENT_LOG_FULL = 0x02,
222 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
223 PLDM_EVENT_LOGGED = 0x04,
224 PLDM_EVENT_LOGGING_REJECTED = 0x05
225};
226
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500227/** @struct pldm_pdr_hdr
228 *
229 * Structure representing PLDM common PDR header
230 */
231struct pldm_pdr_hdr {
232 uint32_t record_handle;
233 uint8_t version;
234 uint8_t type;
235 uint16_t record_change_num;
236 uint16_t length;
237} __attribute__((packed));
238
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500239/** @struct pldm_pdr_entity_association
240 *
241 * Structure representing PLDM Entity Association PDR
242 */
243struct pldm_pdr_entity_association {
244 uint16_t container_id;
245 uint8_t association_type;
246 pldm_entity container;
247 uint8_t num_children;
248 pldm_entity children[1];
249} __attribute__((packed));
250
Deepak Kodihallidb914672020-02-07 02:47:45 -0600251/** @struct pldm_pdr_fru_record_set
252 *
253 * Structure representing PLDM FRU record set PDR
254 */
255struct pldm_pdr_fru_record_set {
256 uint16_t terminus_handle;
257 uint16_t fru_rsi;
258 uint16_t entity_type;
259 uint16_t entity_instance_num;
260 uint16_t container_id;
261} __attribute__((packed));
262
Tom Josephb4268602020-04-17 17:20:45 +0530263/** @struct pldm_state_sensor_pdr
264 *
265 * Structure representing PLDM state sensor PDR
266 */
267struct pldm_state_sensor_pdr {
268 struct pldm_pdr_hdr hdr;
269 uint16_t terminus_handle;
270 uint16_t sensor_id;
271 uint16_t entity_type;
272 uint16_t entity_instance;
273 uint16_t container_id;
274 uint8_t sensor_init;
275 bool8_t sensor_auxiliary_names_pdr;
276 uint8_t composite_sensor_count;
277 uint8_t possible_states[1];
278} __attribute__((packed));
279
280/** @struct state_sensor_possible_states
281 *
282 * Structure representing state enums for state sensor
283 */
284struct state_sensor_possible_states {
285 uint16_t state_set_id;
286 uint8_t possible_states_size;
287 bitfield8_t states[1];
288} __attribute__((packed));
289
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500290/** @struct pldm_state_effecter_pdr
291 *
292 * Structure representing PLDM state effecter PDR
293 */
294struct pldm_state_effecter_pdr {
295 struct pldm_pdr_hdr hdr;
296 uint16_t terminus_handle;
297 uint16_t effecter_id;
298 uint16_t entity_type;
299 uint16_t entity_instance;
300 uint16_t container_id;
301 uint16_t effecter_semantic_id;
302 uint8_t effecter_init;
303 bool8_t has_description_pdr;
304 uint8_t composite_effecter_count;
305 uint8_t possible_states[1];
306} __attribute__((packed));
307
Zach Clarkb728eee2020-06-18 10:01:31 -0500308/** @brief Encode PLDM state sensor PDR
309 *
310 * @param[in/out] sensor Structure to encode. All members of
311 * sensor, except those mentioned in the @note below, should be initialized by
312 * the caller.
313 * @param[in] allocation_size Size of sensor allocation in bytes
314 * @param[in] possible_states Possible sensor states
315 * @param[in] possible_states_size Size of possible sensor states in bytes
316 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
317 * @return int pldm_completion_codes
318 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
319 *
320 * @note The sensor parameter will be encoded in place.
321 * @note Caller is responsible for allocation of the sensor parameter. Caller
322 * must allocate enough space for the base structure and the
323 * sensor->possible_states array, otherwise the function will fail.
324 * @note sensor->hdr.length, .type, and .version will be set appropriately.
325 */
326int encode_state_sensor_pdr(
327 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
328 const struct state_sensor_possible_states *possible_states,
329 size_t possible_states_size, size_t *actual_size);
330
George Liu456c9a22020-01-13 11:36:22 +0800331/** @union union_effecter_data_size
332 *
333 * The bit width and format of reading and threshold values that the effecter
334 * returns.
335 * Refer to: DSP0248_1.2.0: 28.11 Table 87
336 */
337typedef union {
338 uint8_t value_u8;
339 int8_t value_s8;
340 uint16_t value_u16;
341 int16_t value_s16;
342 uint32_t value_u32;
343 int32_t value_s32;
344} union_effecter_data_size;
345
346/** @union union_range_field_format
347 *
348 * Indicates the format used for the nominalValue, normalMax, and normalMin
349 * fields.
350 * Refer to: DSP0248_1.2.0: 28.11 Table 87
351 */
352typedef union {
353 uint8_t value_u8;
354 int8_t value_s8;
355 uint16_t value_u16;
356 int16_t value_s16;
357 uint32_t value_u32;
358 int32_t value_s32;
359 real32_t value_f32;
360} union_range_field_format;
361
362/** @struct pldm_numeric_effecter_value_pdr
363 *
364 * Structure representing PLDM numeric effecter value PDR
365 */
366struct pldm_numeric_effecter_value_pdr {
367 struct pldm_pdr_hdr hdr;
368 uint16_t terminus_handle;
369 uint16_t effecter_id;
370 uint16_t entity_type;
371 uint16_t entity_instance;
372 uint16_t container_id;
373 uint16_t effecter_semantic_id;
374 uint8_t effecter_init;
375 bool8_t effecter_auxiliary_names;
376 uint8_t base_unit;
377 int8_t unit_modifier;
378 uint8_t rate_unit;
379 uint8_t base_oem_unit_handle;
380 uint8_t aux_unit;
381 int8_t aux_unit_modifier;
382 uint8_t aux_rate_unit;
383 uint8_t aux_oem_unit_handle;
384 bool8_t is_linear;
385 uint8_t effecter_data_size;
386 real32_t resolution;
387 real32_t offset;
388 uint16_t accuracy;
389 uint8_t plus_tolerance;
390 uint8_t minus_tolerance;
391 real32_t state_transition_interval;
392 real32_t transition_interval;
393 union_effecter_data_size max_set_table;
394 union_effecter_data_size min_set_table;
395 uint8_t range_field_format;
396 bitfield8_t range_field_support;
397 union_range_field_format nominal_value;
398 union_range_field_format normal_max;
399 union_range_field_format normal_min;
400 union_range_field_format rated_max;
401 union_range_field_format rated_min;
402} __attribute__((packed));
403
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500404/** @struct state_effecter_possible_states
405 *
406 * Structure representing state enums for state effecter
407 */
408struct state_effecter_possible_states {
409 uint16_t state_set_id;
410 uint8_t possible_states_size;
411 bitfield8_t states[1];
412} __attribute__((packed));
413
Zach Clarkb728eee2020-06-18 10:01:31 -0500414/** @brief Encode PLDM state effecter PDR
415 *
416 * @param[in/out] effecter Structure to encode. All members of
417 * effecter, except those mentioned in
418 * the @note below, should be initialized
419 * by the caller.
420 * @param[in] allocation_size Size of effecter allocation in bytes
421 * @param[in] possible_states Possible effecter states
422 * @param[in] possible_states_size Size of possible effecter states in
423 * bytes
424 * @param[out] actual_size Size of effecter PDR. Set to 0 on
425 * error.
426 * @return int pldm_completion_codes
427 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
428 *
429 * @note The effecter parameter will be encoded in place.
430 * @note Caller is responsible for allocation of the effecter parameter. Caller
431 * must allocate enough space for the base structure and the
432 * effecter->possible_states array, otherwise the function will fail.
433 * @note effecter->hdr.length, .type, and .version will be set appropriately.
434 */
435int encode_state_effecter_pdr(
436 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
437 const struct state_effecter_possible_states *possible_states,
438 size_t possible_states_size, size_t *actual_size);
439
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500440/** @struct set_effecter_state_field
441 *
442 * Structure representing a stateField in SetStateEffecterStates command */
443
444typedef struct state_field_for_state_effecter_set {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500445 uint8_t set_request; //!< Whether to change the state
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500446 uint8_t effecter_state; //!< Expected state of the effecter
447} __attribute__((packed)) set_effecter_state_field;
448
Jolie Ku3557bad2020-03-02 16:22:57 +0800449/** @struct get_sensor_readings_field
450 *
451 * Structure representing a stateField in GetStateSensorReadings command */
452
453typedef struct state_field_for_get_state_sensor_readings {
454 uint8_t sensor_op_state; //!< The state of the sensor itself
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500455 uint8_t present_state; //!< Return a state value
Jolie Ku3557bad2020-03-02 16:22:57 +0800456 uint8_t previous_state; //!< The state that the presentState was entered
457 //! from. This must be different from the
458 //! present state
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500459 uint8_t event_state; //!< Return a state value from a PLDM State Set
Jolie Ku3557bad2020-03-02 16:22:57 +0800460 //! that is associated with the sensor
461} __attribute__((packed)) get_sensor_state_field;
462
Priyanga7257fdf2019-06-10 01:59:45 -0500463/** @struct PLDM_SetStateEffecterStates_Request
464 *
465 * Structure representing PLDM set state effecter states request.
466 */
467struct pldm_set_state_effecter_states_req {
468 uint16_t effecter_id;
469 uint8_t comp_effecter_count;
470 set_effecter_state_field field[8];
471} __attribute__((packed));
472
Sampa Misra7fcfb662019-05-08 13:13:53 -0500473/** @struct pldm_get_pdr_resp
474 *
475 * structure representing GetPDR response packet
476 * transfer CRC is not part of the structure and will be
477 * added at the end of last packet in multipart transfer
478 */
479struct pldm_get_pdr_resp {
480 uint8_t completion_code;
481 uint32_t next_record_handle;
482 uint32_t next_data_transfer_handle;
483 uint8_t transfer_flag;
484 uint16_t response_count;
485 uint8_t record_data[1];
486} __attribute__((packed));
487
488/** @struct pldm_get_pdr_req
489 *
490 * structure representing GetPDR request packet
491 */
492struct pldm_get_pdr_req {
493 uint32_t record_handle;
494 uint32_t data_transfer_handle;
495 uint8_t transfer_op_flag;
496 uint16_t request_count;
497 uint16_t record_change_number;
498} __attribute__((packed));
499
George Liu30b859f2020-01-07 15:03:22 +0800500/** @struct pldm_set_numeric_effecter_value_req
501 *
502 * structure representing SetNumericEffecterValue request packet
503 */
504struct pldm_set_numeric_effecter_value_req {
505 uint16_t effecter_id;
506 uint8_t effecter_data_size;
507 uint8_t effecter_value[1];
508} __attribute__((packed));
509
Jolie Ku3557bad2020-03-02 16:22:57 +0800510/** @struct pldm_get_state_sensor_readings_req
511 *
512 * Structure representing PLDM get state sensor readings request.
513 */
514struct pldm_get_state_sensor_readings_req {
515 uint16_t sensor_id;
516 bitfield8_t sensor_rearm;
517 uint8_t reserved;
518} __attribute__((packed));
519
520/** @struct pldm_get_state_sensor_readings_resp
521 *
522 * Structure representing PLDM get state sensor readings response.
523 */
524struct pldm_get_state_sensor_readings_resp {
525 uint8_t completion_code;
526 uint8_t comp_sensor_count;
527 get_sensor_state_field field[1];
528} __attribute__((packed));
529
Zahed Hossaind4abab12020-02-06 03:36:43 -0600530/** @struct pldm_sensor_event
531 *
532 * structure representing sensorEventClass
533 */
534struct pldm_sensor_event_data {
535 uint16_t sensor_id;
536 uint8_t sensor_event_class_type;
537 uint8_t event_class[1];
538} __attribute__((packed));
539
540/** @struct pldm_state_sensor_state
541 *
542 * structure representing sensorEventClass for stateSensorState
543 */
544struct pldm_sensor_event_state_sensor_state {
545 uint8_t sensor_offset;
546 uint8_t event_state;
547 uint8_t previous_event_state;
548} __attribute__((packed));
549
550/** @struct pldm_sensor_event_numeric_sensor_state
551 *
552 * structure representing sensorEventClass for stateSensorState
553 */
554struct pldm_sensor_event_numeric_sensor_state {
555 uint8_t event_state;
556 uint8_t previous_event_state;
557 uint8_t sensor_data_size;
558 uint8_t present_reading[1];
559} __attribute__((packed));
560
561/** @struct pldm_sensor_event_sensor_op_state
562 *
563 * structure representing sensorEventClass for SensorOpState
564 */
565struct pldm_sensor_event_sensor_op_state {
566 uint8_t present_op_state;
567 uint8_t previous_op_state;
568} __attribute__((packed));
569
570/** @struct pldm_platform_event_message_req
571 *
572 * structure representing PlatformEventMessage command request data
573 */
574struct pldm_platform_event_message_req {
575 uint8_t format_version;
576 uint8_t tid;
577 uint8_t event_class;
578 uint8_t event_data[1];
579} __attribute__((packed));
580
581/** @struct pldm_platform_event_message_response
582 *
583 * structure representing PlatformEventMessage command response data
584 */
585struct pldm_platform_event_message_resp {
586 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500587 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600588} __attribute__((packed));
589
590/** @struct pldm_pdr_repository_chg_event_data
591 *
592 * structure representing pldmPDRRepositoryChgEvent class eventData
593 */
594struct pldm_pdr_repository_chg_event_data {
595 uint8_t event_data_format;
596 uint8_t number_of_change_records;
597 uint8_t change_records[1];
598} __attribute__((packed));
599
600/** @struct pldm_pdr_repository_chg_event_change_record_data
601 *
602 * structure representing pldmPDRRepositoryChgEvent class eventData's change
603 * record data
604 */
605struct pldm_pdr_repository_change_record_data {
606 uint8_t event_data_operation;
607 uint8_t number_of_change_entries;
608 uint32_t change_entry[1];
609} __attribute__((packed));
610
Jolie Ku6787f172020-03-19 11:15:53 +0800611/** @struct pldm_get_numeric_effecter_value_req
612 *
613 * structure representing GetNumericEffecterValue request packet
614 */
615struct pldm_get_numeric_effecter_value_req {
616 uint16_t effecter_id;
617} __attribute__((packed));
618
619/** @struct pldm_get_numeric_effecter_value_resp
620 *
621 * structure representing GetNumericEffecterValue response packet
622 */
623struct pldm_get_numeric_effecter_value_resp {
624 uint8_t completion_code;
625 uint8_t effecter_data_size;
626 uint8_t effecter_oper_state;
627 uint8_t pending_and_present_values[1];
628} __attribute__((packed));
629
Jolie Kuf798c8f2020-04-14 11:18:06 +0800630/** @struct pldm_get_sensor_reading_req
631 *
632 * Structure representing PLDM get sensor reading request
633 */
634struct pldm_get_sensor_reading_req {
635 uint16_t sensor_id;
636 bool8_t rearm_event_state;
637} __attribute__((packed));
638
639/** @struct pldm_get_sensor_reading_resp
640 *
641 * Structure representing PLDM get sensor reading response
642 */
643struct pldm_get_sensor_reading_resp {
644 uint8_t completion_code;
645 uint8_t sensor_data_size;
646 uint8_t sensor_operational_state;
647 uint8_t sensor_event_message_enable;
648 uint8_t present_state;
649 uint8_t previous_state;
650 uint8_t event_state;
651 uint8_t present_reading[1];
652} __attribute__((packed));
653
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500654/* Responder */
655
George Liu30b859f2020-01-07 15:03:22 +0800656/* SetNumericEffecterValue */
657
658/** @brief Decode SetNumericEffecterValue request data
659 *
660 * @param[in] msg - Request message
661 * @param[in] payload_length - Length of request message payload
662 * @param[out] effecter_id - used to identify and access the effecter
663 * @param[out] effecter_data_size - The bit width and format of the setting
664 * value for the effecter.
665 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
666 * @param[out] effecter_value - The setting value of numeric effecter being
667 * requested.
668 * @return pldm_completion_codes
669 */
670int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
671 size_t payload_length,
672 uint16_t *effecter_id,
673 uint8_t *effecter_data_size,
674 uint8_t *effecter_value);
675
676/** @brief Create a PLDM response message for SetNumericEffecterValue
677 *
678 * @param[in] instance_id - Message's instance id
679 * @param[in] completion_code - PLDM completion code
680 * @param[out] msg - Message will be written to this
681 * @param[in] payload_length - Length of request message payload
682 * @return pldm_completion_codes
683 * @note Caller is responsible for memory alloc and dealloc of param
684 * 'msg.body.payload'
685 */
686int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
687 uint8_t completion_code,
688 struct pldm_msg *msg,
689 size_t payload_length);
690
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500691/* SetStateEffecterStates */
692
693/** @brief Create a PLDM response message for SetStateEffecterStates
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 * @return pldm_completion_codes
699 * @note Caller is responsible for memory alloc and dealloc of param
700 * 'msg.body.payload'
701 */
702
703int encode_set_state_effecter_states_resp(uint8_t instance_id,
704 uint8_t completion_code,
705 struct pldm_msg *msg);
706
707/** @brief Decode SetStateEffecterStates request data
708 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500709 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500710 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500711 * @param[out] effecter_id - used to identify and access the effecter
712 * @param[out] comp_effecter_count - number of individual sets of effecter
713 * information. Upto eight sets of state effecter info can be accessed
714 * for a given effecter.
715 * @param[out] field - each unit is an instance of the stateFileld structure
716 * that is used to set the requested state for a particular effecter
717 * within the state effecter. This field holds the starting address of
718 * the stateField values. The user is responsible to allocate the
719 * memory prior to calling this command. Since the state field count is
720 * not known in advance, the user should allocate the maximum size
721 * always, which is 8 in number.
722 * @return pldm_completion_codes
723 */
vkaverapa6575b82019-04-03 05:33:52 -0500724
Zahed Hossain223a73d2019-07-04 12:46:18 -0500725int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500726 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500727 uint16_t *effecter_id,
728 uint8_t *comp_effecter_count,
729 set_effecter_state_field *field);
730
Sampa Misra7fcfb662019-05-08 13:13:53 -0500731/* GetPDR */
732
733/** @brief Create a PLDM response message for GetPDR
734 *
735 * @param[in] instance_id - Message's instance id
736 * @param[in] completion_code - PLDM completion code
737 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
738 * the PDR Repository
739 * @param[in] next_data_transfer_hndl - A handle that identifies the next
740 * portion of the PDR data to be transferred, if any
741 * @param[in] transfer_flag - Indicates the portion of PDR data being
742 * transferred
743 * @param[in] resp_cnt - The number of recordData bytes returned in this
744 * response
745 * @param[in] record_data - PDR data bytes of length resp_cnt
746 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
747 * in the last part of a PDR being transferred
748 * @param[out] msg - Message will be written to this
749 * @return pldm_completion_codes
750 * @note Caller is responsible for memory alloc and dealloc of param
751 * 'msg.payload'
752 */
753int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
754 uint32_t next_record_hndl,
755 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
756 uint16_t resp_cnt, const uint8_t *record_data,
757 uint8_t transfer_crc, struct pldm_msg *msg);
758
759/** @brief Decode GetPDR request data
760 *
761 * @param[in] msg - Request message
762 * @param[in] payload_length - Length of request message payload
763 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
764 * @param[out] data_transfer_hndl - Handle used to identify a particular
765 * multipart PDR data transfer operation
766 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
767 * portion of transfer
768 * @param[out] request_cnt - The maximum number of record bytes requested
769 * @param[out] record_chg_num - Used to determine whether the PDR has changed
770 * while PDR transfer is going on
771 * @return pldm_completion_codes
772 */
773
774int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
775 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
776 uint8_t *transfer_op_flag, uint16_t *request_cnt,
777 uint16_t *record_chg_num);
778
Jolie Ku3557bad2020-03-02 16:22:57 +0800779/* GetStateSensorReadings */
780
781/** @brief Decode GetStateSensorReadings request data
782 *
783 * @param[in] msg - Request message
784 * @param[in] payload_length - Length of request message payload
785 * @param[out] sensor_id - used to identify and access the simple or composite
786 * sensor
787 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
788 * particular sensor within the state sensor, where bit [0] corresponds
789 * to the first state sensor (sensor offset 0) and bit [7] corresponds
790 * to the eighth sensor (sensor offset 7), sequentially.
791 * @param[out] reserved - value: 0x00
792 * @return pldm_completion_codes
793 */
794
795int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
796 size_t payload_length,
797 uint16_t *sensor_id,
798 bitfield8_t *sensor_rearm,
799 uint8_t *reserved);
800
801/** @brief Encode GetStateSensorReadings response data
802 *
803 * @param[in] instance_id - Message's instance id
804 * @param[in] completion_code - PLDM completion code
805 * @param[out] comp_sensor_count - The number of individual sets of sensor
806 * information that this command accesses
807 * @param[out] field - Each stateField is an instance of a stateField structure
808 * that is used to return the present operational state setting and the
809 * present state and event state for a particular set of sensor
810 * information contained within the state sensor
811 * @param[out] msg - Message will be written to this
812 * @return pldm_completion_codes
813 */
814
815int encode_get_state_sensor_readings_resp(uint8_t instance_id,
816 uint8_t completion_code,
817 uint8_t comp_sensor_count,
818 get_sensor_state_field *field,
819 struct pldm_msg *msg);
820
Jolie Ku6787f172020-03-19 11:15:53 +0800821/* GetNumericEffecterValue */
822
823/** @brief Decode GetNumericEffecterValue request data
824 *
825 * @param[in] msg - Request message
826 * @param[in] payload_length - Length of request message payload
827 * @param[out] effecter_id - used to identify and access the effecter
828 * @return pldm_completion_codes
829 */
830int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
831 size_t payload_length,
832 uint16_t *effecter_id);
833
834/** @brief Create a PLDM response message for GetNumericEffecterValue
835 *
836 * @param[in] instance_id - Message's instance id
837 * @param[in] completion_code - PLDM completion code
838 * @param[in] effecter_data_size - The bit width and format of the setting
839 * value for the effecter.
840 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
841 * @param[in] effecter_oper_state - The state of the effecter itself
842 * @param[in] pending_value - The pending numeric value setting of the
843 * effecter. The effecterDataSize field indicates the number of
844 * bits used for this field
845 * @param[in] present_value - The present numeric value setting of the
846 * effecter. The effecterDataSize indicates the number of bits
847 * used for this field
848 * @param[out] msg - Message will be written to this
849 * @param[in] payload_length - Length of request message payload
850 * @return pldm_completion_codes
851 * @note Caller is responsible for memory alloc and dealloc of param
852 * 'msg.payload'
853 */
854int encode_get_numeric_effecter_value_resp(
855 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
856 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
857 struct pldm_msg *msg, size_t payload_length);
858
Jolie Kuf798c8f2020-04-14 11:18:06 +0800859/* GetSensorReading */
860
861/** @brief Decode GetSensorReading request data
862 *
863 * @param[in] msg - Request message
864 * @param[in] payload_length - Length of request message payload
865 * @param[out] sensor_id - A handle that is used to identify and access
866 * the sensor
867 * @param[out] rearm_event_state - true = manually re-arm EventState after
868 * responding to this request, false = no manual re-arm
869 * @return pldm_completion_codes
870 */
871
872int decode_get_sensor_reading_req(const struct pldm_msg *msg,
873 size_t payload_length, uint16_t *sensor_id,
874 bool8_t *rearm_event_state);
875
876/** @brief Encode GetSensorReading response data
877 *
878 * @param[in] instance_id - Message's instance id
879 * @param[in] completion_code - PLDM completion code
880 * @param[out] sensor_data_size - The bit width and format of reading and
881 * threshold values
882 * @param[out] sensor_operational_state - The state of the sensor itself
883 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
884 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
885 * stateEventsOnlyEnabled }
886 * @param[out] present_state - The most recently assessed state value monitored
887 * by the sensor
888 * @param[out] previous_state - The state that the presentState was entered
889 * from
890 * @param[out] event_state - Indicates which threshold crossing assertion
891 * events have been detected
892 * @param[out] present_reading - The present value indicated by the sensor
893 * @param[out] msg - Message will be written to this
894 * @param[in] payload_length - Length of request message payload
895 * @return pldm_completion_codes
896 */
897
898int encode_get_sensor_reading_resp(
899 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
900 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
901 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
902 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
903
Sampa Misra7fcfb662019-05-08 13:13:53 -0500904/* Requester */
905
George Liu820a9a52019-11-26 14:43:59 +0800906/* GetPDR */
907
908/** @brief Create a PLDM request message for GetPDR
909 *
910 * @param[in] instance_id - Message's instance id
911 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
912 * @param[in] data_transfer_hndl - Handle used to identify a particular
913 * multipart PDR data transfer operation
914 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
915 * portion of transfer
916 * @param[in] request_cnt - The maximum number of record bytes requested
917 * @param[in] record_chg_num - Used to determine whether the PDR has changed
918 * while PDR transfer is going on
919 * @param[out] msg - Message will be written to this
920 * @param[in] payload_length - Length of request message payload
921 * @return pldm_completion_codes
922 * @note Caller is responsible for memory alloc and dealloc of param
923 * 'msg.payload'
924 */
925int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
926 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
927 uint16_t request_cnt, uint16_t record_chg_num,
928 struct pldm_msg *msg, size_t payload_length);
929
930/** @brief Decode GetPDR response data
931 *
George Liu684a7162019-12-06 15:10:52 +0800932 * Note:
933 * * If the return value is not PLDM_SUCCESS, it represents a
934 * transport layer error.
935 * * If the completion_code value is not PLDM_SUCCESS, it represents a
936 * protocol layer error and all the out-parameters are invalid.
937 *
George Liu820a9a52019-11-26 14:43:59 +0800938 * @param[in] msg - Request message
939 * @param[in] payload_length - Length of request message payload
940 * @param[out] completion_code - PLDM completion code
941 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
942 * the PDR Repository
943 * @param[out] next_data_transfer_hndl - A handle that identifies the next
944 * portion of the PDR data to be transferred, if any
945 * @param[out] transfer_flag - Indicates the portion of PDR data being
946 * transferred
947 * @param[out] resp_cnt - The number of recordData bytes returned in this
948 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500949 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
950 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800951 * @param[in] record_data_length - Length of record_data
952 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
953 * in the last part of a PDR being transferred
954 * @return pldm_completion_codes
955 */
956int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
957 uint8_t *completion_code, uint32_t *next_record_hndl,
958 uint32_t *next_data_transfer_hndl,
959 uint8_t *transfer_flag, uint16_t *resp_cnt,
960 uint8_t *record_data, size_t record_data_length,
961 uint8_t *transfer_crc);
962
Sampa Misra7fcfb662019-05-08 13:13:53 -0500963/* SetStateEffecterStates */
964
vkaverap98a2c192019-04-03 05:33:52 -0500965/** @brief Create a PLDM request message for SetStateEffecterStates
966 *
967 * @param[in] instance_id - Message's instance id
968 * @param[in] effecter_id - used to identify and access the effecter
969 * @param[in] comp_effecter_count - number of individual sets of effecter
970 * information. Upto eight sets of state effecter info can be accessed
971 * for a given effecter.
972 * @param[in] field - each unit is an instance of the stateField structure
973 * that is used to set the requested state for a particular effecter
974 * within the state effecter. This field holds the starting address of
975 * the stateField values. The user is responsible to allocate the
976 * memory prior to calling this command. The user has to allocate the
977 * field parameter as sizeof(set_effecter_state_field) *
978 * comp_effecter_count
979 * @param[out] msg - Message will be written to this
980 * @return pldm_completion_codes
981 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500982 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500983 */
984
985int encode_set_state_effecter_states_req(uint8_t instance_id,
986 uint16_t effecter_id,
987 uint8_t comp_effecter_count,
988 set_effecter_state_field *field,
989 struct pldm_msg *msg);
990
991/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800992 *
993 * Note:
994 * * If the return value is not PLDM_SUCCESS, it represents a
995 * transport layer error.
996 * * If the completion_code value is not PLDM_SUCCESS, it represents a
997 * protocol layer error and all the out-parameters are invalid.
998 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500999 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -05001000 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -05001001 * @param[out] completion_code - PLDM completion code
1002 * @return pldm_completion_codes
1003 */
Zahed Hossain223a73d2019-07-04 12:46:18 -05001004int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -05001005 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -05001006 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +08001007
1008/* SetNumericEffecterValue */
1009
1010/** @brief Create a PLDM request message for SetNumericEffecterValue
1011 *
1012 * @param[in] instance_id - Message's instance id
1013 * @param[in] effecter_id - used to identify and access the effecter
1014 * @param[in] effecter_data_size - The bit width and format of the setting
1015 * value for the effecter.
1016 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1017 * @param[in] effecter_value - The setting value of numeric effecter being
1018 * requested.
1019 * @param[in] payload_length - Length of request message payload
1020 * @param[out] msg - Message will be written to this
1021 * @return pldm_completion_codes
1022 * @note Caller is responsible for memory alloc and dealloc of param
1023 * 'msg.payload'
1024 */
1025int encode_set_numeric_effecter_value_req(
1026 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1027 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1028
1029/** @brief Decode SetNumericEffecterValue response data
1030 * @param[in] msg - Request message
1031 * @param[in] payload_length - Length of response message payload
1032 * @param[out] completion_code - PLDM completion code
1033 * @return pldm_completion_codes
1034 */
1035int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1036 size_t payload_length,
1037 uint8_t *completion_code);
1038
Jolie Ku3557bad2020-03-02 16:22:57 +08001039/** @brief Create a PLDM request message for GetStateSensorReadings
1040 *
1041 * @param[in] instance_id - Message's instance id
1042 * @param[in] sensor_id - used to identify and access the simple or composite
1043 * sensor
1044 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1045 * particular sensor within the state sensor, where bit [0] corresponds
1046 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1047 * to the eighth sensor (sensor offset 7), sequentially
1048 * @param[in] reserved - value: 0x00
1049 * @param[out] msg - Message will be written to this
1050 * @return pldm_completion_codes
1051 * @note Caller is responsible for memory alloc and dealloc of param
1052 * 'msg.payload'
1053 */
Jolie Ku3557bad2020-03-02 16:22:57 +08001054int encode_get_state_sensor_readings_req(uint8_t instance_id,
1055 uint16_t sensor_id,
1056 bitfield8_t sensor_rearm,
1057 uint8_t reserved,
1058 struct pldm_msg *msg);
1059
1060/** @brief Decode GetStateSensorReadings response data
1061 *
1062 * @param[in] msg - Request message
1063 * @param[in] payload_length - Length of response message payload
1064 * @param[out] completion_code - PLDM completion code
1065 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1066 * information that this command accesses
1067 * @param[out] field - Each stateField is an instance of a stateField structure
1068 * that is used to return the present operational state setting and the
1069 * present state and event state for a particular set of sensor
1070 * information contained within the state sensor
1071 * @return pldm_completion_codes
1072 */
1073
1074int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1075 size_t payload_length,
1076 uint8_t *completion_code,
1077 uint8_t *comp_sensor_count,
1078 get_sensor_state_field *field);
1079
Zahed Hossaind4abab12020-02-06 03:36:43 -06001080/* PlatformEventMessage */
1081
1082/** @brief Decode PlatformEventMessage request data
1083 * @param[in] msg - Request message
1084 * @param[in] payload_length - Length of response message payload
1085 * @param[out] format_version - Version of the event format
1086 * @param[out] tid - Terminus ID for the terminus that originated the event
1087 * message
1088 * @param[out] event_class - The class of event being sent
1089 * @param[out] event_data_offset - Offset where the event data should be read
1090 * from pldm msg
1091 * @return pldm_completion_codes
1092 */
1093int decode_platform_event_message_req(const struct pldm_msg *msg,
1094 size_t payload_length,
1095 uint8_t *format_version, uint8_t *tid,
1096 uint8_t *event_class,
1097 size_t *event_data_offset);
1098
1099/** @brief Encode PlatformEventMessage response data
1100 * @param[in] instance_id - Message's instance id
1101 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001102 * @param[in] platform_event_status - Response status of the event message
1103 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001104 * @param[out] msg - Message will be written to this
1105 * @return pldm_completion_codes
1106 * @note Caller is responsible for memory alloc and dealloc of param
1107 * 'msg.payload'
1108 */
1109int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001110 uint8_t completion_code,
1111 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001112 struct pldm_msg *msg);
1113
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001114/** @brief Encode PlatformEventMessage request data
1115 * @param[in] instance_id - Message's instance id
1116 * @param[in] format_version - Version of the event format
1117 * @param[in] tid - Terminus ID for the terminus that originated the event
1118 * message
1119 * @param[in] event_class - The class of event being sent
1120 * @param[in] event_data - the event data should be read from pldm msg
1121 * @param[in] event_data_length - Length of the event data
1122 * @param[out] msg - Request message
1123 * @return pldm_completion_codes
1124 * @note Caller is responsible for memory alloc and dealloc of param
1125 * 'msg.payload'
1126 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001127int encode_platform_event_message_req(
1128 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1129 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1130 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001131
1132/** @brief Decode PlatformEventMessage response data
1133 * @param[in] msg - Request message
1134 * @param[in] payload_length - Length of Response message payload
1135 * @param[out] completion_code - PLDM completion code
1136 * @param[out] platform_event_status - Response status of the event message
1137 * command
1138 * @return pldm_completion_codes
1139 */
1140int decode_platform_event_message_resp(const struct pldm_msg *msg,
1141 size_t payload_length,
1142 uint8_t *completion_code,
1143 uint8_t *platform_event_status);
1144
Zahed Hossain1c861712020-03-04 08:55:19 -06001145/** @brief Decode sensorEventData response data
1146 *
1147 * @param[in] event_data - event data from the response message
1148 * @param[in] event_data_length - length of the event data
1149 * @param[out] sensor_id - sensorID value of the sensor
1150 * @param[out] sensor_event_class_type - Type of sensor event class
1151 * @param[out] event_class_data_offset - Offset where the event class data
1152 * should be read from event data
1153 * @return pldm_completion_codes
1154 * @note Caller is responsible for memory alloc and dealloc of param
1155 * 'event_data'
1156 */
1157int decode_sensor_event_data(const uint8_t *event_data,
1158 size_t event_data_length, uint16_t *sensor_id,
1159 uint8_t *sensor_event_class_type,
1160 size_t *event_class_data_offset);
1161
1162/** @brief Decode sensorOpState response data
1163 *
1164 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1165 * @param[in] sensor_data_length - Length of sensor_data
1166 * @param[out] present_op_state - The sensorOperationalState value from the
1167 * state change that triggered the event message
1168 * @param[out] previous_op_state - The sensorOperationalState value for the
1169 * state from which the present state was entered
1170 * @return pldm_completion_codes
1171 * @note Caller is responsible for memory alloc and dealloc of param
1172 * 'sensor_data'
1173 */
1174int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1175 uint8_t *present_op_state,
1176 uint8_t *previous_op_state);
1177
1178/** @brief Decode stateSensorState response data
1179 *
1180 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1181 * @param[in] sensor_data_length - Length of sensor_data
1182 * @param[out] sensor_offset - Identifies which state sensor within a composite
1183 * state sensor the event is being returned for
1184 * @param[out] event_state - The event state value from the state change that
1185 * triggered the event message
1186 * @param[out] previous_event_state - The event state value for the state from
1187 * which the present event state was entered
1188 * @return pldm_completion_codes
1189 * @note Caller is responsible for memory alloc and dealloc of param
1190 * 'sensor_data'
1191 */
1192int decode_state_sensor_data(const uint8_t *sensor_data,
1193 size_t sensor_data_length, uint8_t *sensor_offset,
1194 uint8_t *event_state,
1195 uint8_t *previous_event_state);
1196
1197/** @brief Decode numericSensorState response data
1198 *
1199 * @param[in] sensor_data - sensor_data for sensorEventClass =
1200 * numericSensorState
1201 * @param[in] sensor_data_length - Length of sensor_data
1202 * @param[out] event_state - The eventState value from the state change that
1203 * triggered the event message
1204 * @param[out] previous_event_state - The eventState value for the state from
1205 * which the present state was entered
1206 * @param[out] sensor_data_size - The bit width and format of reading and
1207 * threshold values that the sensor returns
1208 * @param[out] present_reading - The present value indicated by the sensor
1209 * @return pldm_completion_codes
1210 * @note Caller is responsible for memory alloc and dealloc of param
1211 * 'sensor_data'
1212 */
1213int decode_numeric_sensor_data(const uint8_t *sensor_data,
1214 size_t sensor_data_length, uint8_t *event_state,
1215 uint8_t *previous_event_state,
1216 uint8_t *sensor_data_size,
1217 uint32_t *present_reading);
1218
Jolie Ku6787f172020-03-19 11:15:53 +08001219/* GetNumericEffecterValue */
1220
1221/** @brief Create a PLDM request message for GetNumericEffecterValue
1222 *
1223 * @param[in] instance_id - Message's instance id
1224 * @param[in] effecter_id - used to identify and access the effecter
1225 * @param[out] msg - Message will be written to this
1226 * @return pldm_completion_codes
1227 * @note Caller is responsible for memory alloc and dealloc of param
1228 * 'msg.payload'
1229 */
1230int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1231 uint16_t effecter_id,
1232 struct pldm_msg *msg);
1233
1234/** @brief Create a PLDM response message for GetNumericEffecterValue
1235 *
1236 * @param[in] msg - Request message
1237 * @param[in] payload_length - Length of request message payload
1238 * @param[out] completion_code - PLDM completion code
1239 * @param[out] effecter_data_size - The bit width and format of the setting
1240 * value for the effecter.
1241 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1242 * @param[out] effecter_oper_state - The state of the effecter itself
1243 * @param[out] pending_value - The pending numeric value setting of the
1244 * effecter. The effecterDataSize field indicates the number of
1245 * bits used for this field
1246 * @param[out] present_value - The present numeric value setting of the
1247 * effecter. The effecterDataSize indicates the number of bits
1248 * used for this field
1249 * @return pldm_completion_codes
1250 */
1251int decode_get_numeric_effecter_value_resp(
1252 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1253 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1254 uint8_t *pending_value, uint8_t *present_value);
1255
Zahed Hossain9be087c2020-04-02 02:26:41 -05001256/** @brief Decode pldmPDRRepositoryChgEvent response data
1257 *
1258 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1259 * @param[in] event_data_size - Length of event_data
1260 * @param[out] event_data_format - This field indicates if the changedRecords
1261 * are of PDR Types or PDR Record Handles
1262 * @param[out] number_of_change_records - The number of changeRecords following
1263 * this field
1264 * @param[out] change_record_data_offset - Identifies where changeRecord data
1265 * is located within event_data
1266 * @return pldm_completion_codes
1267 * @note Caller is responsible for memory alloc and dealloc of param
1268 * 'event_data'
1269 */
1270int decode_pldm_pdr_repository_chg_event_data(
1271 const uint8_t *event_data, size_t event_data_size,
1272 uint8_t *event_data_format, uint8_t *number_of_change_records,
1273 size_t *change_record_data_offset);
1274
Zach Clark36ad1f52020-04-13 07:04:15 -05001275/** @brief Encode PLDM PDR Repository Change eventData
1276 * @param[in] event_data_format - Format of this event data (e.g.
1277 * FORMAT_IS_PDR_HANDLES)
1278 * @param[in] number_of_change_records - Number of changeRecords in this
1279 * eventData
1280 * @param[in] event_data_operations - Array of eventDataOperations
1281 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1282 * should contain number_of_change_records elements.
1283 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1284 * for each changeRecord in this eventData. This array should contain
1285 * number_of_change_records elements.
1286 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1287 * one array per changeRecord in this eventData. The toplevel array should
1288 * contain number_of_change_records elements. Each subarray [i] should
1289 * contain numbers_of_change_entries[i] elements.
1290 * @param[in] event_data - The eventData will be encoded into this. This entire
1291 * structure must be max_change_records_size long. It must be large enough
1292 * to accomodate the data to be encoded. The caller is responsible for
1293 * allocating and deallocating it, including the variable-size
1294 * 'event_data.change_records' field. If this parameter is NULL,
1295 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1296 * to reflect the required size of the structure.
1297 * @param[out] actual_change_records_size - The actual number of meaningful
1298 * encoded bytes in event_data. The caller can over-allocate memory and use
1299 * this output to determine the real size of the structure.
1300 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1301 * encoded message would be larger than this value, an error is returned.
1302 * @return pldm_completion_codes
1303 * @note Caller is responsible for memory alloc and dealloc of param
1304 * 'event_data.change_records'
1305 */
1306int encode_pldm_pdr_repository_chg_event_data(
1307 uint8_t event_data_format, uint8_t number_of_change_records,
1308 const uint8_t *event_data_operations,
1309 const uint8_t *numbers_of_change_entries,
1310 const uint32_t *const *change_entries,
1311 struct pldm_pdr_repository_chg_event_data *event_data,
1312 size_t *actual_change_records_size, size_t max_change_records_size);
1313
Zach Clarkb728eee2020-06-18 10:01:31 -05001314/** @brief Encode event data for a PLDM Sensor Event
1315 *
1316 * @param[out] event_data The object to store the encoded event in
1317 * @param[in] event_data_size Size of the allocation for event_data
1318 * @param[in] sensor_id Sensor ID
1319 * @param[in] sensor_event_class Sensor event class
1320 * @param[in] sensor_offset Offset
1321 * @param[in] event_state Event state
1322 * @param[in] previous_event_state Previous event state
1323 * @param[out] actual_event_data_size The real size in bytes of the event_data
1324 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1325 * @note If event_data is NULL, then *actual_event_data_size will be set to
1326 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1327 * @note The caller is responsible for allocating and deallocating the
1328 * event_data
1329 */
1330int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1331 size_t event_data_size, uint16_t sensor_id,
1332 enum sensor_event_class_states sensor_event_class,
1333 uint8_t sensor_offset, uint8_t event_state,
1334 uint8_t previous_event_state,
1335 size_t *actual_event_data_size);
1336
Zahed Hossain9be087c2020-04-02 02:26:41 -05001337/** @brief Decode PldmPDRRepositoryChangeRecord response data
1338 *
1339 * @param[in] change_record_data - changeRecordData for
1340 * pldmPDRRepositoryChgEvent
1341 * @param[in] change_record_data_size - Length of change_record_data
1342 * @param[out] event_data_operation - This field indicates the changeEntries
1343 * operation types
1344 * @param[out] number_of_change_entries - The number of changeEntries following
1345 * this field
1346 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1347 * is located within change_record_data
1348 * @return pldm_completion_codes
1349 * @note Caller is responsible for memory alloc and dealloc of param
1350 * 'change_record_data'
1351 */
1352int decode_pldm_pdr_repository_change_record_data(
1353 const uint8_t *change_record_data, size_t change_record_data_size,
1354 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1355 size_t *change_entry_data_offset);
1356
Jolie Kuf798c8f2020-04-14 11:18:06 +08001357/* GetSensorReading */
1358
1359/** @brief Encode GetSensorReading request data
1360 *
1361 * @param[in] instance_id - Message's instance id
1362 * @param[in] sensor_id - A handle that is used to identify and access the
1363 * sensor
1364 * @param[in] rearm_event_state - true = manually re-arm EventState after
1365 * responding to this request, false = no manual re-arm
1366 * @param[out] msg - Message will be written to this
1367 * @return pldm_completion_codes
1368 * @note Caller is responsible for memory alloc and dealloc of param
1369 * 'msg.payload'
1370 */
1371int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1372 bool8_t rearm_event_state,
1373 struct pldm_msg *msg);
1374
1375/** @brief Decode GetSensorReading response data
1376 *
1377 * @param[in] msg - Request message
1378 * @param[in] payload_length - Length of response message payload
1379 * @param[out] completion_code - PLDM completion code
1380 * @param[out] sensor_data_size - The bit width and format of reading and
1381 * threshold values
1382 * @param[out] sensor_operational_state - The state of the sensor itself
1383 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1384 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1385 * stateEventsOnlyEnabled }
1386 * @param[out] present_state - The most recently assessed state value monitored
1387 * by the sensor
1388 * @param[out] previous_state - The state that the presentState was entered
1389 * from
1390 * @param[out] event_state - Indicates which threshold crossing assertion
1391 * events have been detected
1392 * @param[out] present_reading - The present value indicated by the sensor
1393 * @return pldm_completion_codes
1394 */
1395
1396int decode_get_sensor_reading_resp(
1397 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1398 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1399 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1400 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1401
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001402#ifdef __cplusplus
1403}
1404#endif
1405
1406#endif /* PLATFORM_H */