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