blob: 5e1a3dcec9a513fc094b2050b4c7be838c79a258 [file] [log] [blame]
Andrew Jeffery9c766792022-08-10 23:12:49 +09301#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"
12#include "pdr.h"
Manojkiran Eda9a8e4972022-11-28 16:38:21 +053013#include "pldm_types.h"
Andrew Jeffery9c766792022-08-10 23:12:49 +093014
15/* Maximum size for request */
16#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
17#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
18#define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
19#define PLDM_GET_SENSOR_READING_REQ_BYTES 3
20#define PLDM_SET_EVENT_RECEIVER_REQ_BYTES 5
21/* Response lengths are inclusive of completion code */
22#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
23
24#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
25#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
26
27#define PLDM_GET_PDR_REQ_BYTES 13
28
29#define PLDM_SET_EVENT_RECEIVER_RESP_BYTES 1
Dung Caod6ae8982022-11-02 10:00:10 +070030
31/* Platform event supported request */
32#define PLDM_EVENT_MESSAGE_BUFFER_SIZE_REQ_BYTES 2
33#define PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES 3
34
Dung Cao1bf8c872022-11-29 05:32:58 +070035#define PLDM_EVENT_MESSAGE_SUPPORTED_REQ_BYTES 1
36#define PLDM_EVENT_MESSAGE_SUPPORTED_MIN_RESP_BYTES 4
37
Andrew Jeffery9c766792022-08-10 23:12:49 +093038/* Minimum response length */
39#define PLDM_GET_PDR_MIN_RESP_BYTES 12
40#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
41#define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8
42#define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES 2
43#define PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES 41
44
45/* Minimum length for PLDM PlatformEventMessage request */
46#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
47#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
48#define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2
49#define PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION 1
50
51/* Minumum length of senson event data */
52#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
53#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
54#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
55#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
56#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
57#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
58#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
59#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
60
61/* Minimum length of data for pldmPDRRepositoryChgEvent */
62#define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2
63#define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2
64
65#define PLDM_INVALID_EFFECTER_ID 0xFFFF
66#define PLDM_TID_RESERVED 0xFF
67
68enum pldm_effecter_data_size {
69 PLDM_EFFECTER_DATA_SIZE_UINT8,
70 PLDM_EFFECTER_DATA_SIZE_SINT8,
71 PLDM_EFFECTER_DATA_SIZE_UINT16,
72 PLDM_EFFECTER_DATA_SIZE_SINT16,
73 PLDM_EFFECTER_DATA_SIZE_UINT32,
74 PLDM_EFFECTER_DATA_SIZE_SINT32
75};
76
77enum pldm_range_field_format {
78 PLDM_RANGE_FIELD_FORMAT_UINT8,
79 PLDM_RANGE_FIELD_FORMAT_SINT8,
80 PLDM_RANGE_FIELD_FORMAT_UINT16,
81 PLDM_RANGE_FIELD_FORMAT_SINT16,
82 PLDM_RANGE_FIELD_FORMAT_UINT32,
83 PLDM_RANGE_FIELD_FORMAT_SINT32,
84 PLDM_RANGE_FIELD_FORMAT_REAL32
85};
86
87enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
88
89enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
90
91enum pldm_sensor_present_state {
92 PLDM_SENSOR_UNKNOWN = 0x0,
93 PLDM_SENSOR_NORMAL = 0x01,
94 PLDM_SENSOR_WARNING = 0x02,
95 PLDM_SENSOR_CRITICAL = 0x03,
96 PLDM_SENSOR_FATAL = 0x04,
97 PLDM_SENSOR_LOWERWARNING = 0x05,
98 PLDM_SENSOR_LOWERCRITICAL = 0x06,
99 PLDM_SENSOR_LOWERFATAL = 0x07,
100 PLDM_SENSOR_UPPERWARNING = 0x08,
101 PLDM_SENSOR_UPPERCRITICAL = 0x09,
102 PLDM_SENSOR_UPPERFATAL = 0x0a
103};
104
105enum pldm_sensor_event_message_enable {
106 PLDM_NO_EVENT_GENERATION,
107 PLDM_EVENTS_DISABLED,
108 PLDM_EVENTS_ENABLED,
109 PLDM_OP_EVENTS_ONLY_ENABLED,
110 PLDM_STATE_EVENTS_ONLY_ENABLED
111};
112
113enum pldm_effecter_oper_state {
114 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
115 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
116 EFFECTER_OPER_STATE_DISABLED,
117 EFFECTER_OPER_STATE_UNAVAILABLE,
118 EFFECTER_OPER_STATE_STATUSUNKNOWN,
119 EFFECTER_OPER_STATE_FAILED,
120 EFFECTER_OPER_STATE_INITIALIZING,
121 EFFECTER_OPER_STATE_SHUTTINGDOWN,
122 EFFECTER_OPER_STATE_INTEST
123};
124
125enum pldm_platform_commands {
126 PLDM_SET_EVENT_RECEIVER = 0x04,
Dung Caod6ae8982022-11-02 10:00:10 +0700127 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A,
Dung Cao1bf8c872022-11-29 05:32:58 +0700128 PLDM_EVENT_MESSAGE_SUPPORTED = 0x0C,
129 PLDM_EVENT_MESSAGE_BUFFER_SIZE = 0x0D,
Andrew Jeffery9c766792022-08-10 23:12:49 +0930130 PLDM_GET_SENSOR_READING = 0x11,
131 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
132 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
133 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
134 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
135 PLDM_GET_PDR_REPOSITORY_INFO = 0x50,
136 PLDM_GET_PDR = 0x51,
Andrew Jeffery9c766792022-08-10 23:12:49 +0930137};
138
139/** @brief PLDM PDR types
140 */
141enum pldm_pdr_types {
142 PLDM_TERMINUS_LOCATOR_PDR = 1,
143 PLDM_NUMERIC_SENSOR_PDR = 2,
144 PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3,
145 PLDM_STATE_SENSOR_PDR = 4,
146 PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5,
147 PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6,
148 PLDM_OEM_UNIT_PDR = 7,
149 PLDM_OEM_STATE_SET_PDR = 8,
150 PLDM_NUMERIC_EFFECTER_PDR = 9,
151 PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10,
152 PLDM_STATE_EFFECTER_PDR = 11,
153 PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12,
154 PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13,
155 PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14,
156 PLDM_PDR_ENTITY_ASSOCIATION = 15,
157 PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16,
158 PLDM_OEM_ENTITY_ID_PDR = 17,
159 PLDM_INTERRUPT_ASSOCIATION_PDR = 18,
160 PLDM_EVENT_LOG_PDR = 19,
161 PLDM_PDR_FRU_RECORD_SET = 20,
Thu Nguyen02476112022-11-02 09:52:54 +0700162 PLDM_COMPACT_NUMERIC_SENSOR_PDR = 21,
Andrew Jeffery9c766792022-08-10 23:12:49 +0930163 PLDM_OEM_DEVICE_PDR = 126,
164 PLDM_OEM_PDR = 127,
165};
166
167/** @brief PLDM effecter initialization schemes
168 */
169enum pldm_effecter_init {
170 PLDM_NO_INIT,
171 PLDM_USE_INIT_PDR,
172 PLDM_ENABLE_EFFECTER,
173 PLDM_DISABLE_EFECTER
174};
175
176/** @brief PLDM Platform M&C completion codes
177 */
178enum pldm_platform_completion_codes {
179 PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80,
180 PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81,
181
182 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
183 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
184
185 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
186 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
187 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
188 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
189 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
190
191 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
192
193 PLDM_PLATFORM_INVALID_PROTOCOL_TYPE = 0x80,
194 PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED = 0x81,
195 PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH = 0x82,
196};
197
198/** @brief PLDM Event types
199 */
200enum pldm_event_types {
201 PLDM_SENSOR_EVENT = 0x00,
202 PLDM_EFFECTER_EVENT = 0x01,
203 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
204 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
205 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
206 PLDM_MESSAGE_POLL_EVENT = 0x05,
207 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
208};
209
210/** @brief PLDM sensorEventClass states
211 */
212enum sensor_event_class_states {
213 PLDM_SENSOR_OP_STATE,
214 PLDM_STATE_SENSOR_STATE,
215 PLDM_NUMERIC_SENSOR_STATE
216};
217
218/** @brief PLDM sensor supported states
219 */
220enum pldm_sensor_operational_state {
221 PLDM_SENSOR_ENABLED,
222 PLDM_SENSOR_DISABLED,
223 PLDM_SENSOR_UNAVAILABLE,
224 PLDM_SENSOR_STATUSUNKOWN,
225 PLDM_SENSOR_FAILED,
226 PLDM_SENSOR_INITIALIZING,
227 PLDM_SENSOR_SHUTTINGDOWN,
228 PLDM_SENSOR_INTEST
229};
230
231/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
232 */
233enum pldm_pdr_repository_chg_event_data_format {
234 REFRESH_ENTIRE_REPOSITORY,
235 FORMAT_IS_PDR_TYPES,
236 FORMAT_IS_PDR_HANDLES
237};
238
239/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
240 * eventDataOperation
241 */
242enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
243 PLDM_REFRESH_ALL_RECORDS,
244 PLDM_RECORDS_DELETED,
245 PLDM_RECORDS_ADDED,
246 PLDM_RECORDS_MODIFIED
247};
248
249/** @brief PLDM NumericSensorStatePresentReading data type
250 */
251enum pldm_sensor_readings_data_type {
252 PLDM_SENSOR_DATA_SIZE_UINT8,
253 PLDM_SENSOR_DATA_SIZE_SINT8,
254 PLDM_SENSOR_DATA_SIZE_UINT16,
255 PLDM_SENSOR_DATA_SIZE_SINT16,
256 PLDM_SENSOR_DATA_SIZE_UINT32,
257 PLDM_SENSOR_DATA_SIZE_SINT32
258};
259
260/** @brief PLDM PlatformEventMessage response status
261 */
262enum pldm_platform_event_status {
263 PLDM_EVENT_NO_LOGGING = 0x00,
264 PLDM_EVENT_LOGGING_DISABLED = 0x01,
265 PLDM_EVENT_LOG_FULL = 0x02,
266 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
267 PLDM_EVENT_LOGGED = 0x04,
268 PLDM_EVENT_LOGGING_REJECTED = 0x05
269};
270
271/** @brief PLDM Terminus Locator PDR validity
272 */
273enum pldm_terminus_locator_pdr_validity {
274 PLDM_TL_PDR_NOT_VALID,
275 PLDM_TL_PDR_VALID
276};
277
278/** @brief PLDM Terminus Locator type
279 */
280enum pldm_terminus_locator_type {
281 PLDM_TERMINUS_LOCATOR_TYPE_UID,
282 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID,
283 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE,
284 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW
285};
286
287/** @brief PLDM event message global enable for
288 * SetEventReceiver command
289 */
290enum pldm_event_message_global_enable {
291 PLDM_EVENT_MESSAGE_GLOBAL_DISABLE,
292 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC,
293 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_POLLING,
294 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE
295};
296
Thu Nguyen02476112022-11-02 09:52:54 +0700297/** @brief PLDM DSP0248 1.2.1 table 74 sensorUnits enumeration
298 */
299enum pldm_sensor_units {
300 PLDM_SENSOR_UNIT_NONE = 0x00,
301 PLDM_SENSOR_UNIT_UNSPECIFIED,
302 PLDM_SENSOR_UNIT_DEGRESS_C,
303 PLDM_SENSOR_UNIT_DEGRESS_F,
304 PLDM_SENSOR_UNIT_KELVINS,
305 PLDM_SENSOR_UNIT_VOLTS,
306 PLDM_SENSOR_UNIT_AMPS,
307 PLDM_SENSOR_UNIT_WATTS,
308 PLDM_SENSOR_UNIT_JOULES,
309 PLDM_SENSOR_UNIT_COULOMBS,
310 PLDM_SENSOR_UNIT_VA,
311 PLDM_SENSOR_UNIT_NITS,
312 PLDM_SENSOR_UNIT_LUMENS,
313 PLDM_SENSOR_UNIT_LUX,
314 PLDM_SENSOR_UNIT_CANDELAS,
315 PLDM_SENSOR_UNIT_KPA,
316 PLDM_SENSOR_UNIT_PSI,
317 PLDM_SENSOR_UNIT_NEWTONS,
318 PLDM_SENSOR_UNIT_CFM,
319 PLDM_SENSOR_UNIT_RPM,
320 PLDM_SENSOR_UNIT_HERTZ,
321 PLDM_SENSOR_UNIT_SECONDS,
322 PLDM_SENSOR_UNIT_MINUTES,
323 PLDM_SENSOR_UNIT_HOURS,
324 PLDM_SENSOR_UNIT_DAYS,
325 PLDM_SENSOR_UNIT_WEEKS,
326 PLDM_SENSOR_UNIT_MILS,
327 PLDM_SENSOR_UNIT_INCHES,
328 PLDM_SENSOR_UNIT_FEET,
329 PLDM_SENSOR_UNIT_CUBIC_INCHES,
330 PLDM_SENSOR_UNIT_CUBIC_FEET,
331 PLDM_SENSOR_UNIT_METERS,
332 PLDM_SENSOR_UNIT_CUBIC_CENTERMETERS,
333 PLDM_SENSOR_UNIT_CUBIC_METERS,
334 PLDM_SENSOR_UNIT_LITERS,
335 PLDM_SENSOR_UNIT_FLUID_OUNCES,
336 PLDM_SENSOR_UNIT_RADIANS,
337 PLDM_SENSOR_UNIT_STERADIANS,
338 PLDM_SENSOR_UNIT_REVOLUTIONS,
339 PLDM_SENSOR_UNIT_CYCLES,
340 PLDM_SENSOR_UNIT_GRAVITIES,
341 PLDM_SENSOR_UNIT_OUNCES,
342 PLDM_SENSOR_UNIT_POUNDS,
343 PLDM_SENSOR_UNIT_FOOT_POUNDS,
344 PLDM_SENSOR_UNIT_OUNCE_INCHES,
345 PLDM_SENSOR_UNIT_GUESS,
346 PLDM_SENSOR_UNIT_GILBERTS,
347 PLDM_SENSOR_UNIT_HENRIES,
348 PLDM_SENSOR_UNIT_FARADS,
349 PLDM_SENSOR_UNIT_OHMS,
350 PLDM_SENSOR_UNIT_SIEMENS,
351 PLDM_SENSOR_UNIT_MOLES,
352 PLDM_SENSOR_UNIT_BECQUERELS,
353 PLDM_SENSOR_UNIT_PPM,
354 PLDM_SENSOR_UNIT_DECIBELS,
355 PLDM_SENSOR_UNIT_DBA,
356 PLDM_SENSOR_UNIT_DBC,
357 PLDM_SENSOR_UNIT_GRAYS,
358 PLDM_SENSOR_UNIT_SIEVERTS,
359 PLDM_SENSOR_UNIT_COLOR_TEMPERATURE_DEGRESS_K,
360 PLDM_SENSOR_UNIT_BITS,
361 PLDM_SENSOR_UNIT_BYTES,
362 PLDM_SENSOR_UNIT_WORDS,
363 PLDM_SENSOR_UNIT_DOUBLE_WORDS,
364 PLDM_SENSOR_UNIT_QUAD_WORDS,
365 PLDM_SENSOR_UNIT_PERCENTAGE,
366 PLDM_SENSOR_UNIT_PASCALS,
367 PLDM_SENSOR_UNIT_COUNTS,
368 PLDM_SENSOR_UNIT_GRAMS,
369 PLDM_SENSOR_UNIT_NEWTON_METERS,
370 PLDM_SENSOR_UNIT_HITS,
371 PLDM_SENSOR_UNIT_MISSES,
372 PLDM_SENSOR_UNIT_RETRIES,
373 PLDM_SENSOR_UNIT_OVERRUNS_OVERFLOWS,
374 PLDM_SENSOR_UNIT_UNDERRUNS,
375 PLDM_SENSOR_UNIT_COLLISIONS,
376 PLDM_SENSOR_UNIT_PACKETS,
377 PLDM_SENSOR_UNIT_MESSAGES,
378 PLDM_SENSOR_UNIT_CHARATERS,
379 PLDM_SENSOR_UNIT_ERRORS,
380 PLDM_SENSOR_UNIT_CORRECTED_ERRORS,
381 PLDM_SENSOR_UNIT_UNCORRECTABLE_ERRORS,
382 PLDM_SENSOR_UNIT_SQUARE_MILS,
383 PLDM_SENSOR_UNIT_SQUARE_INCHES,
384 PLDM_SENSOR_UNIT_SQUARE_FEET,
385 PLDM_SENSOR_UNIT_SQUARE_CENTIMETERS,
386 PLDM_SENSOR_UNIT_SQUARE_METERS,
387 PLDM_SENSOR_UNIT_OEMUNIT = 255
388};
389
390enum pldm_occurrence_rate {
391 PLDM_RATE_UNIT_NONE = 0x0,
392 PLDM_RATE_UNIT_PER_MICRO_SECOND,
393 PLDM_RATE_UNIT_PER_MILLI_SECOND,
394 PLDM_RATE_UNIT_PER_SECOND,
395 PLDM_RATE_UNIT_PER_MINUTE,
396 PLDM_RATE_UNIT_PER_HOUR
397};
398
Andrew Jeffery9c766792022-08-10 23:12:49 +0930399/** @brief PLDM respository state */
400enum pldm_repository_state {
401 PLDM_AVAILABLE,
402 PLDM_UPDATE_IN_PROGRESS,
403 PLDM_FAILED
404};
405
406/** @brief PLDM respository data transfer handler timeout */
407enum pldm_repository_data_transfer_handler_timeout {
408 PLDM_NO_TIMEOUT,
409 PLDM_DEFALUT_MINIMUM_TIMEOUT
410};
411
Dung Cao1bf8c872022-11-29 05:32:58 +0700412/** @brief PLDM event message type */
413enum pldm_event_message_type {
414 PLDM_MESSAGE_TYPE_NOT_CONFIGURED = 0x00,
415 PLDM_MESSAGE_TYPE_ASYNCHRONOUS = 0x01,
416 PLDM_MESSAGE_TYPE_SYNCHRONOUS = 0x02,
417 PLDM_MESSAGE_TYPE_ASYNCHRONOUS_WITH_HEARTBEAT = 0x03
418};
419
Andrew Jeffery9c766792022-08-10 23:12:49 +0930420/** @struct pldm_pdr_hdr
421 *
422 * Structure representing PLDM common PDR header
423 */
424struct pldm_pdr_hdr {
425 uint32_t record_handle;
426 uint8_t version;
427 uint8_t type;
428 uint16_t record_change_num;
429 uint16_t length;
430} __attribute__((packed));
431
432/** @struct pldm_terminus_locator_pdr
433 *
434 * Structure representing PLDM terminus locator PDR
435 */
436struct pldm_terminus_locator_pdr {
437 struct pldm_pdr_hdr hdr;
438 uint16_t terminus_handle;
439 uint8_t validity;
440 uint8_t tid;
441 uint16_t container_id;
442 uint8_t terminus_locator_type;
443 uint8_t terminus_locator_value_size;
444 uint8_t terminus_locator_value[1];
445} __attribute__((packed));
446
447/** @struct pldm_terminus_locator_type_mctp_eid
448 *
449 * Structure representing terminus locator value for
450 * terminus locator type MCTP_EID
451 */
452struct pldm_terminus_locator_type_mctp_eid {
453 uint8_t eid;
454} __attribute__((packed));
455
456/** @struct pldm_pdr_entity_association
457 *
458 * Structure representing PLDM Entity Association PDR
459 */
460struct pldm_pdr_entity_association {
461 uint16_t container_id;
462 uint8_t association_type;
463 pldm_entity container;
464 uint8_t num_children;
465 pldm_entity children[1];
466} __attribute__((packed));
467
468/** @struct pldm_pdr_fru_record_set
469 *
470 * Structure representing PLDM FRU record set PDR
471 */
472struct pldm_pdr_fru_record_set {
473 uint16_t terminus_handle;
474 uint16_t fru_rsi;
475 uint16_t entity_type;
476 uint16_t entity_instance_num;
477 uint16_t container_id;
478} __attribute__((packed));
479
480/** @struct pldm_state_sensor_pdr
481 *
482 * Structure representing PLDM state sensor PDR
483 */
484struct pldm_state_sensor_pdr {
485 struct pldm_pdr_hdr hdr;
486 uint16_t terminus_handle;
487 uint16_t sensor_id;
488 uint16_t entity_type;
489 uint16_t entity_instance;
490 uint16_t container_id;
491 uint8_t sensor_init;
492 bool8_t sensor_auxiliary_names_pdr;
493 uint8_t composite_sensor_count;
494 uint8_t possible_states[1];
495} __attribute__((packed));
496
497/** @struct state_sensor_possible_states
498 *
499 * Structure representing state enums for state sensor
500 */
501struct state_sensor_possible_states {
502 uint16_t state_set_id;
503 uint8_t possible_states_size;
504 bitfield8_t states[1];
505} __attribute__((packed));
506
507/** @struct pldm_state_effecter_pdr
508 *
509 * Structure representing PLDM state effecter PDR
510 */
511struct pldm_state_effecter_pdr {
512 struct pldm_pdr_hdr hdr;
513 uint16_t terminus_handle;
514 uint16_t effecter_id;
515 uint16_t entity_type;
516 uint16_t entity_instance;
517 uint16_t container_id;
518 uint16_t effecter_semantic_id;
519 uint8_t effecter_init;
520 bool8_t has_description_pdr;
521 uint8_t composite_effecter_count;
522 uint8_t possible_states[1];
523} __attribute__((packed));
524
Thu Nguyen02476112022-11-02 09:52:54 +0700525/** @struct pldm_compact_nummeric_sensor_pdr
526 *
527 * Structure representing PLDM compact nummeric sensor PDR
528 */
529struct pldm_compact_nummeric_sensor_pdr {
530 struct pldm_pdr_hdr hdr;
531 uint16_t terminus_handle;
532 uint16_t sensor_id;
533 uint16_t entity_type;
534 uint16_t entity_instance;
535 uint16_t container_id;
536 uint8_t sensor_name_length;
537 uint8_t base_unit;
538 int8_t unit_modifier;
539 uint8_t occurrence_rate;
540 bitfield8_t range_field_support;
541 int32_t warning_high;
542 int32_t warning_low;
543 int32_t critical_high;
544 int32_t critical_low;
545 int32_t fatal_high;
546 int32_t fatal_low;
547 uint8_t sensor_name[1];
548} __attribute__((packed));
549
Andrew Jeffery9c766792022-08-10 23:12:49 +0930550/** @brief Encode PLDM state sensor PDR
551 *
552 * @param[in/out] sensor Structure to encode. All members of
553 * sensor, except those mentioned in the @note below, should be initialized by
554 * the caller.
555 * @param[in] allocation_size Size of sensor allocation in bytes
556 * @param[in] possible_states Possible sensor states
557 * @param[in] possible_states_size Size of possible sensor states in bytes
558 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
559 * @return int pldm_completion_codes
560 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
561 *
562 * @note The sensor parameter will be encoded in place.
563 * @note Caller is responsible for allocation of the sensor parameter. Caller
564 * must allocate enough space for the base structure and the
565 * sensor->possible_states array, otherwise the function will fail.
566 * @note sensor->hdr.length, .type, and .version will be set appropriately.
567 */
568int encode_state_sensor_pdr(
569 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
570 const struct state_sensor_possible_states *possible_states,
571 size_t possible_states_size, size_t *actual_size);
572
573/** @union union_effecter_data_size
574 *
575 * The bit width and format of reading and threshold values that the effecter
576 * returns.
577 * Refer to: DSP0248_1.2.0: 28.11 Table 87
578 */
579typedef union {
580 uint8_t value_u8;
581 int8_t value_s8;
582 uint16_t value_u16;
583 int16_t value_s16;
584 uint32_t value_u32;
585 int32_t value_s32;
586} union_effecter_data_size;
587
588/** @union union_range_field_format
589 *
590 * Indicates the format used for the nominalValue, normalMax, and normalMin
591 * fields.
592 * Refer to: DSP0248_1.2.0: 28.11 Table 87
593 */
594typedef union {
595 uint8_t value_u8;
596 int8_t value_s8;
597 uint16_t value_u16;
598 int16_t value_s16;
599 uint32_t value_u32;
600 int32_t value_s32;
601 real32_t value_f32;
602} union_range_field_format;
603
604/** @struct pldm_numeric_effecter_value_pdr
605 *
606 * Structure representing PLDM numeric effecter value PDR
607 */
608struct pldm_numeric_effecter_value_pdr {
609 struct pldm_pdr_hdr hdr;
610 uint16_t terminus_handle;
611 uint16_t effecter_id;
612 uint16_t entity_type;
613 uint16_t entity_instance;
614 uint16_t container_id;
615 uint16_t effecter_semantic_id;
616 uint8_t effecter_init;
617 bool8_t effecter_auxiliary_names;
618 uint8_t base_unit;
619 int8_t unit_modifier;
620 uint8_t rate_unit;
621 uint8_t base_oem_unit_handle;
622 uint8_t aux_unit;
623 int8_t aux_unit_modifier;
624 uint8_t aux_rate_unit;
625 uint8_t aux_oem_unit_handle;
626 bool8_t is_linear;
627 uint8_t effecter_data_size;
628 real32_t resolution;
629 real32_t offset;
630 uint16_t accuracy;
631 uint8_t plus_tolerance;
632 uint8_t minus_tolerance;
633 real32_t state_transition_interval;
634 real32_t transition_interval;
635 union_effecter_data_size max_settable;
636 union_effecter_data_size min_settable;
637 uint8_t range_field_format;
638 bitfield8_t range_field_support;
639 union_range_field_format nominal_value;
640 union_range_field_format normal_max;
641 union_range_field_format normal_min;
642 union_range_field_format rated_max;
643 union_range_field_format rated_min;
644} __attribute__((packed));
645
646/** @struct state_effecter_possible_states
647 *
648 * Structure representing state enums for state effecter
649 */
650struct state_effecter_possible_states {
651 uint16_t state_set_id;
652 uint8_t possible_states_size;
653 bitfield8_t states[1];
654} __attribute__((packed));
655
Thu Nguyen0585de92022-11-02 09:57:25 +0700656/** @struct pldm_effecter_aux_name_pdr
657 *
658 * Structure representing PLDM aux name numeric effecter value PDR
659 */
660struct pldm_effecter_aux_name_pdr {
661 struct pldm_pdr_hdr hdr;
662 uint16_t terminus_handle;
663 uint16_t effecter_id;
664 uint8_t effecter_count;
665 uint8_t effecter_names[1];
666} __attribute__((packed));
667
Andrew Jeffery9c766792022-08-10 23:12:49 +0930668/** @brief Encode PLDM state effecter PDR
669 *
670 * @param[in/out] effecter Structure to encode. All members of
671 * effecter, except those mentioned in
672 * the @note below, should be initialized
673 * by the caller.
674 * @param[in] allocation_size Size of effecter allocation in bytes
675 * @param[in] possible_states Possible effecter states
676 * @param[in] possible_states_size Size of possible effecter states in
677 * bytes
678 * @param[out] actual_size Size of effecter PDR. Set to 0 on
679 * error.
680 * @return int pldm_completion_codes
681 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
682 *
683 * @note The effecter parameter will be encoded in place.
684 * @note Caller is responsible for allocation of the effecter parameter. Caller
685 * must allocate enough space for the base structure and the
686 * effecter->possible_states array, otherwise the function will fail.
687 * @note effecter->hdr.length, .type, and .version will be set appropriately.
688 */
689int encode_state_effecter_pdr(
690 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
691 const struct state_effecter_possible_states *possible_states,
692 size_t possible_states_size, size_t *actual_size);
693
694/** @struct set_effecter_state_field
695 *
696 * Structure representing a stateField in SetStateEffecterStates command */
697
698typedef struct state_field_for_state_effecter_set {
699 uint8_t set_request; //!< Whether to change the state
700 uint8_t effecter_state; //!< Expected state of the effecter
701} __attribute__((packed)) set_effecter_state_field;
702
703/** @struct get_sensor_readings_field
704 *
705 * Structure representing a stateField in GetStateSensorReadings command */
706
707typedef struct state_field_for_get_state_sensor_readings {
708 uint8_t sensor_op_state; //!< The state of the sensor itself
709 uint8_t present_state; //!< Return a state value
710 uint8_t previous_state; //!< The state that the presentState was entered
711 //! from. This must be different from the
712 //! present state
713 uint8_t event_state; //!< Return a state value from a PLDM State Set
714 //! that is associated with the sensor
715} __attribute__((packed)) get_sensor_state_field;
716
717/** @struct PLDM_SetStateEffecterStates_Request
718 *
719 * Structure representing PLDM set state effecter states request.
720 */
721struct pldm_set_state_effecter_states_req {
722 uint16_t effecter_id;
723 uint8_t comp_effecter_count;
724 set_effecter_state_field field[8];
725} __attribute__((packed));
726
727/** @struct pldm_get_pdr_repository_info_resp
728 *
729 * Structure representing GetPDRRepositoryInfo response packet
730 */
731struct pldm_pdr_repository_info_resp {
732 uint8_t completion_code;
733 uint8_t repository_state;
734 uint8_t update_time[PLDM_TIMESTAMP104_SIZE];
735 uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE];
736 uint32_t record_count;
737 uint32_t repository_size;
738 uint32_t largest_record_size;
739 uint8_t data_transfer_handle_timeout;
740} __attribute__((packed));
741
742/** @struct pldm_get_pdr_resp
743 *
744 * structure representing GetPDR response packet
745 * transfer CRC is not part of the structure and will be
746 * added at the end of last packet in multipart transfer
747 */
748struct pldm_get_pdr_resp {
749 uint8_t completion_code;
750 uint32_t next_record_handle;
751 uint32_t next_data_transfer_handle;
752 uint8_t transfer_flag;
753 uint16_t response_count;
754 uint8_t record_data[1];
755} __attribute__((packed));
756
757/** @struct pldm_get_pdr_req
758 *
759 * structure representing GetPDR request packet
760 */
761struct pldm_get_pdr_req {
762 uint32_t record_handle;
763 uint32_t data_transfer_handle;
764 uint8_t transfer_op_flag;
765 uint16_t request_count;
766 uint16_t record_change_number;
767} __attribute__((packed));
768
769/** @struct pldm_set_event_receiver_req
770 *
771 * Structure representing SetEventReceiver command.
772 * This structure applies only for MCTP as a transport type.
773 */
774struct pldm_set_event_receiver_req {
775 uint8_t event_message_global_enable;
776 uint8_t transport_protocol_type;
777 uint8_t event_receiver_address_info;
778 uint16_t heartbeat_timer;
779} __attribute__((packed));
780
Dung Caod6ae8982022-11-02 10:00:10 +0700781/** @struct pldm_event_message_buffer_size_req
782 *
783 * Structure representing EventMessageBufferSizes command request data
784 */
785struct pldm_event_message_buffer_size_req {
786 uint16_t event_receiver_max_buffer_size;
787} __attribute__((packed));
788
789/** @struct pldm_event_message_buffer_size_resp
790 *
791 * Structure representing EventMessageBufferSizes command response data
792 */
793struct pldm_event_message_buffer_size_resp {
794 uint8_t completion_code;
795 uint16_t terminus_max_buffer_size;
796} __attribute__((packed));
797
Dung Cao1bf8c872022-11-29 05:32:58 +0700798/** @struct pldm_platform_event_message_supported_req
799 *
800 * structure representing PlatformEventMessageSupported command request data
801 */
802struct pldm_event_message_supported_req {
803 uint8_t format_version;
804} __attribute__((packed));
805
806/** @struct pldm_event_message_supported_response
807 *
808 * structure representing EventMessageSupported command response data
809 */
810struct pldm_event_message_supported_resp {
811 uint8_t completion_code;
812 uint8_t synchrony_configuration;
813 bitfield8_t synchrony_configuration_supported;
814 uint8_t number_event_class_returned;
815 uint8_t event_class[1];
816} __attribute__((packed));
817
Andrew Jeffery9c766792022-08-10 23:12:49 +0930818/** @struct pldm_set_numeric_effecter_value_req
819 *
820 * structure representing SetNumericEffecterValue request packet
821 */
822struct pldm_set_numeric_effecter_value_req {
823 uint16_t effecter_id;
824 uint8_t effecter_data_size;
825 uint8_t effecter_value[1];
826} __attribute__((packed));
827
828/** @struct pldm_get_state_sensor_readings_req
829 *
830 * Structure representing PLDM get state sensor readings request.
831 */
832struct pldm_get_state_sensor_readings_req {
833 uint16_t sensor_id;
834 bitfield8_t sensor_rearm;
835 uint8_t reserved;
836} __attribute__((packed));
837
838/** @struct pldm_get_state_sensor_readings_resp
839 *
840 * Structure representing PLDM get state sensor readings response.
841 */
842struct pldm_get_state_sensor_readings_resp {
843 uint8_t completion_code;
844 uint8_t comp_sensor_count;
845 get_sensor_state_field field[1];
846} __attribute__((packed));
847
848/** @struct pldm_sensor_event
849 *
850 * structure representing sensorEventClass
851 */
852struct pldm_sensor_event_data {
853 uint16_t sensor_id;
854 uint8_t sensor_event_class_type;
855 uint8_t event_class[1];
856} __attribute__((packed));
857
858/** @struct pldm_state_sensor_state
859 *
860 * structure representing sensorEventClass for stateSensorState
861 */
862struct pldm_sensor_event_state_sensor_state {
863 uint8_t sensor_offset;
864 uint8_t event_state;
865 uint8_t previous_event_state;
866} __attribute__((packed));
867
868/** @struct pldm_sensor_event_numeric_sensor_state
869 *
870 * structure representing sensorEventClass for stateSensorState
871 */
872struct pldm_sensor_event_numeric_sensor_state {
873 uint8_t event_state;
874 uint8_t previous_event_state;
875 uint8_t sensor_data_size;
876 uint8_t present_reading[1];
877} __attribute__((packed));
878
879/** @struct pldm_sensor_event_sensor_op_state
880 *
881 * structure representing sensorEventClass for SensorOpState
882 */
883struct pldm_sensor_event_sensor_op_state {
884 uint8_t present_op_state;
885 uint8_t previous_op_state;
886} __attribute__((packed));
887
888/** @struct pldm_platform_event_message_req
889 *
890 * structure representing PlatformEventMessage command request data
891 */
892struct pldm_platform_event_message_req {
893 uint8_t format_version;
894 uint8_t tid;
895 uint8_t event_class;
896 uint8_t event_data[1];
897} __attribute__((packed));
898
899/** @struct pldm_platform_event_message_response
900 *
901 * structure representing PlatformEventMessage command response data
902 */
903struct pldm_platform_event_message_resp {
904 uint8_t completion_code;
905 uint8_t platform_event_status;
906} __attribute__((packed));
907
908/** @struct pldm_pdr_repository_chg_event_data
909 *
910 * structure representing pldmPDRRepositoryChgEvent class eventData
911 */
912struct pldm_pdr_repository_chg_event_data {
913 uint8_t event_data_format;
914 uint8_t number_of_change_records;
915 uint8_t change_records[1];
916} __attribute__((packed));
917
918/** @struct pldm_pdr_repository_chg_event_change_record_data
919 *
920 * structure representing pldmPDRRepositoryChgEvent class eventData's change
921 * record data
922 */
923struct pldm_pdr_repository_change_record_data {
924 uint8_t event_data_operation;
925 uint8_t number_of_change_entries;
926 uint32_t change_entry[1];
927} __attribute__((packed));
928
929/** @struct pldm_get_numeric_effecter_value_req
930 *
931 * structure representing GetNumericEffecterValue request packet
932 */
933struct pldm_get_numeric_effecter_value_req {
934 uint16_t effecter_id;
935} __attribute__((packed));
936
937/** @struct pldm_get_numeric_effecter_value_resp
938 *
939 * structure representing GetNumericEffecterValue response packet
940 */
941struct pldm_get_numeric_effecter_value_resp {
942 uint8_t completion_code;
943 uint8_t effecter_data_size;
944 uint8_t effecter_oper_state;
945 uint8_t pending_and_present_values[1];
946} __attribute__((packed));
947
948/** @struct pldm_get_sensor_reading_req
949 *
950 * Structure representing PLDM get sensor reading request
951 */
952struct pldm_get_sensor_reading_req {
953 uint16_t sensor_id;
954 bool8_t rearm_event_state;
955} __attribute__((packed));
956
957/** @struct pldm_get_sensor_reading_resp
958 *
959 * Structure representing PLDM get sensor reading response
960 */
961struct pldm_get_sensor_reading_resp {
962 uint8_t completion_code;
963 uint8_t sensor_data_size;
964 uint8_t sensor_operational_state;
965 uint8_t sensor_event_message_enable;
966 uint8_t present_state;
967 uint8_t previous_state;
968 uint8_t event_state;
969 uint8_t present_reading[1];
970} __attribute__((packed));
971
972/* Responder */
973
974/* SetNumericEffecterValue */
975
976/** @brief Decode SetNumericEffecterValue request data
977 *
978 * @param[in] msg - Request message
979 * @param[in] payload_length - Length of request message payload
980 * @param[out] effecter_id - used to identify and access the effecter
981 * @param[out] effecter_data_size - The bit width and format of the setting
982 * value for the effecter.
983 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
984 * @param[out] effecter_value - The setting value of numeric effecter being
985 * requested.
986 * @return pldm_completion_codes
987 */
988int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
989 size_t payload_length,
990 uint16_t *effecter_id,
991 uint8_t *effecter_data_size,
992 uint8_t *effecter_value);
993
994/** @brief Create a PLDM response message for SetNumericEffecterValue
995 *
996 * @param[in] instance_id - Message's instance id
997 * @param[in] completion_code - PLDM completion code
998 * @param[out] msg - Message will be written to this
999 * @param[in] payload_length - Length of request message payload
1000 * @return pldm_completion_codes
1001 * @note Caller is responsible for memory alloc and dealloc of param
1002 * 'msg.body.payload'
1003 */
1004int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
1005 uint8_t completion_code,
1006 struct pldm_msg *msg,
1007 size_t payload_length);
1008
1009/* SetStateEffecterStates */
1010
1011/** @brief Create a PLDM response message for SetStateEffecterStates
1012 *
1013 * @param[in] instance_id - Message's instance id
1014 * @param[in] completion_code - PLDM completion code
1015 * @param[out] msg - Message will be written to this
1016 * @return pldm_completion_codes
1017 * @note Caller is responsible for memory alloc and dealloc of param
1018 * 'msg.body.payload'
1019 */
1020
1021int encode_set_state_effecter_states_resp(uint8_t instance_id,
1022 uint8_t completion_code,
1023 struct pldm_msg *msg);
1024
1025/** @brief Decode SetStateEffecterStates request data
1026 *
1027 * @param[in] msg - Request message
1028 * @param[in] payload_length - Length of request message payload
1029 * @param[out] effecter_id - used to identify and access the effecter
1030 * @param[out] comp_effecter_count - number of individual sets of effecter
1031 * information. Upto eight sets of state effecter info can be accessed
1032 * for a given effecter.
1033 * @param[out] field - each unit is an instance of the stateFileld structure
1034 * that is used to set the requested state for a particular effecter
1035 * within the state effecter. This field holds the starting address of
1036 * the stateField values. The user is responsible to allocate the
1037 * memory prior to calling this command. Since the state field count is
1038 * not known in advance, the user should allocate the maximum size
1039 * always, which is 8 in number.
1040 * @return pldm_completion_codes
1041 */
1042
1043int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
1044 size_t payload_length,
1045 uint16_t *effecter_id,
1046 uint8_t *comp_effecter_count,
1047 set_effecter_state_field *field);
1048
1049/* GetPDR */
1050
1051/** @brief Create a PLDM response message for GetPDR
1052 *
1053 * @param[in] instance_id - Message's instance id
1054 * @param[in] completion_code - PLDM completion code
1055 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
1056 * the PDR Repository
1057 * @param[in] next_data_transfer_hndl - A handle that identifies the next
1058 * portion of the PDR data to be transferred, if any
1059 * @param[in] transfer_flag - Indicates the portion of PDR data being
1060 * transferred
1061 * @param[in] resp_cnt - The number of recordData bytes returned in this
1062 * response
1063 * @param[in] record_data - PDR data bytes of length resp_cnt
1064 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
1065 * in the last part of a PDR being transferred
1066 * @param[out] msg - Message will be written to this
1067 * @return pldm_completion_codes
1068 * @note Caller is responsible for memory alloc and dealloc of param
1069 * 'msg.payload'
1070 */
1071int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
1072 uint32_t next_record_hndl,
1073 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
1074 uint16_t resp_cnt, const uint8_t *record_data,
1075 uint8_t transfer_crc, struct pldm_msg *msg);
1076
1077/** @brief Decode GetPDR request data
1078 *
1079 * @param[in] msg - Request message
1080 * @param[in] payload_length - Length of request message payload
1081 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
1082 * @param[out] data_transfer_hndl - Handle used to identify a particular
1083 * multipart PDR data transfer operation
1084 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
1085 * portion of transfer
1086 * @param[out] request_cnt - The maximum number of record bytes requested
1087 * @param[out] record_chg_num - Used to determine whether the PDR has changed
1088 * while PDR transfer is going on
1089 * @return pldm_completion_codes
1090 */
1091
1092int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
1093 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
1094 uint8_t *transfer_op_flag, uint16_t *request_cnt,
1095 uint16_t *record_chg_num);
1096
1097/* GetStateSensorReadings */
1098
1099/** @brief Decode GetStateSensorReadings request data
1100 *
1101 * @param[in] msg - Request message
1102 * @param[in] payload_length - Length of request message payload
1103 * @param[out] sensor_id - used to identify and access the simple or composite
1104 * sensor
1105 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
1106 * particular sensor within the state sensor, where bit [0] corresponds
1107 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1108 * to the eighth sensor (sensor offset 7), sequentially.
1109 * @param[out] reserved - value: 0x00
1110 * @return pldm_completion_codes
1111 */
1112
1113int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
1114 size_t payload_length,
1115 uint16_t *sensor_id,
1116 bitfield8_t *sensor_rearm,
1117 uint8_t *reserved);
1118
1119/** @brief Encode GetStateSensorReadings response data
1120 *
1121 * @param[in] instance_id - Message's instance id
1122 * @param[in] completion_code - PLDM completion code
1123 * @param[out] comp_sensor_count - The number of individual sets of sensor
1124 * information that this command accesses
1125 * @param[out] field - Each stateField is an instance of a stateField structure
1126 * that is used to return the present operational state setting and the
1127 * present state and event state for a particular set of sensor
1128 * information contained within the state sensor
1129 * @param[out] msg - Message will be written to this
1130 * @return pldm_completion_codes
1131 */
1132
1133int encode_get_state_sensor_readings_resp(uint8_t instance_id,
1134 uint8_t completion_code,
1135 uint8_t comp_sensor_count,
1136 get_sensor_state_field *field,
1137 struct pldm_msg *msg);
1138
1139/* GetNumericEffecterValue */
1140
1141/** @brief Decode GetNumericEffecterValue request data
1142 *
1143 * @param[in] msg - Request message
1144 * @param[in] payload_length - Length of request message payload
1145 * @param[out] effecter_id - used to identify and access the effecter
1146 * @return pldm_completion_codes
1147 */
1148int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
1149 size_t payload_length,
1150 uint16_t *effecter_id);
1151
1152/** @brief Create a PLDM response message for GetNumericEffecterValue
1153 *
1154 * @param[in] instance_id - Message's instance id
1155 * @param[in] completion_code - PLDM completion code
1156 * @param[in] effecter_data_size - The bit width and format of the setting
1157 * value for the effecter.
1158 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1159 * @param[in] effecter_oper_state - The state of the effecter itself
1160 * @param[in] pending_value - The pending numeric value setting of the
1161 * effecter. The effecterDataSize field indicates the number of
1162 * bits used for this field
1163 * @param[in] present_value - The present numeric value setting of the
1164 * effecter. The effecterDataSize indicates the number of bits
1165 * used for this field
1166 * @param[out] msg - Message will be written to this
1167 * @param[in] payload_length - Length of request message payload
1168 * @return pldm_completion_codes
1169 * @note Caller is responsible for memory alloc and dealloc of param
1170 * 'msg.payload'
1171 */
1172int encode_get_numeric_effecter_value_resp(
1173 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
1174 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
1175 struct pldm_msg *msg, size_t payload_length);
1176
1177/* GetSensorReading */
1178
1179/** @brief Decode GetSensorReading request data
1180 *
1181 * @param[in] msg - Request message
1182 * @param[in] payload_length - Length of request message payload
1183 * @param[out] sensor_id - A handle that is used to identify and access
1184 * the sensor
1185 * @param[out] rearm_event_state - true = manually re-arm EventState after
1186 * responding to this request, false = no manual re-arm
1187 * @return pldm_completion_codes
1188 */
1189
1190int decode_get_sensor_reading_req(const struct pldm_msg *msg,
1191 size_t payload_length, uint16_t *sensor_id,
1192 bool8_t *rearm_event_state);
1193
1194/** @brief Encode GetSensorReading response data
1195 *
1196 * @param[in] instance_id - Message's instance id
1197 * @param[in] completion_code - PLDM completion code
1198 * @param[out] sensor_data_size - The bit width and format of reading and
1199 * threshold values
1200 * @param[out] sensor_operational_state - The state of the sensor itself
1201 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1202 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1203 * stateEventsOnlyEnabled }
1204 * @param[out] present_state - The most recently assessed state value monitored
1205 * by the sensor
1206 * @param[out] previous_state - The state that the presentState was entered
1207 * from
1208 * @param[out] event_state - Indicates which threshold crossing assertion
1209 * events have been detected
1210 * @param[out] present_reading - The present value indicated by the sensor
1211 * @param[out] msg - Message will be written to this
1212 * @param[in] payload_length - Length of request message payload
1213 * @return pldm_completion_codes
1214 */
1215
1216int encode_get_sensor_reading_resp(
1217 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
1218 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
1219 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
1220 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
1221
1222/* Requester */
1223
1224/*GetPDRRepositoryInfo*/
1225
1226/** @brief Encode GetPDRRepositoryInfo response data
1227 *
1228 * @param[in] instance_id - Message's instance id
1229 * @param[in] completion_code - PLDM completion code
1230 * @param[in] repository_state - PLDM repository state
1231 * @param[in] update_time - When the standard PDR repository data was
1232 * originally created
1233 * @param[in] oem_update_time - when OEM PDRs in the PDR Repository were
1234 * originally created
1235 * @param[in] record_count - Total number of PDRs in this repository
1236 * @param[in] repository_size - Size of the PDR Repository in bytes
1237 * @param[in] largest_record_size - Size of the largest record in the PDR
1238 * Repository in bytes
1239 * @param[in] data_transfer_handle_timeout - Data transmission timeout
1240 * @param[out] msg - Message will be written to this
1241 * @return pldm_completion_codes
1242 */
1243int encode_get_pdr_repository_info_resp(
1244 uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
1245 const uint8_t *update_time, const uint8_t *oem_update_time,
1246 uint32_t record_count, uint32_t repository_size,
1247 uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
1248 struct pldm_msg *msg);
1249
Gilbert Chenb7c73e52022-11-10 11:29:52 +08001250/** @brief Decode GetPDRRepositoryInfo response data
1251 *
1252 * @param[in] msg - Response message
1253 * @param[in] payload_length - Length of response message payload
1254 * @param[out] completion_code - PLDM completion code
1255 * @param[out] repository_state - PLDM repository state
1256 * @param[out] update_time - When the standard PDR repository data was
1257 * originally created
1258 * @param[out] oem_update_time - when OEM PDRs in the PDR Repository were
1259 * originally created
1260 * @param[out] record_count - Total number of PDRs in this repository
1261 * @param[out] repository_size - Size of the PDR Repository in bytes
1262 * @param[out] largest_record_size - Size of the largest record in the PDR
1263 * Repository in bytes
1264 * @param[out] data_transfer_handle_timeout - Data transmission timeout
1265 * @return pldm_completion_codes
1266 */
1267int decode_get_pdr_repository_info_resp(
1268 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1269 uint8_t *repository_state, uint8_t *update_time, uint8_t *oem_update_time,
1270 uint32_t *record_count, uint32_t *repository_size,
1271 uint32_t *largest_record_size, uint8_t *data_transfer_handle_timeout);
1272
Andrew Jeffery9c766792022-08-10 23:12:49 +09301273/* GetPDR */
1274
1275/** @brief Create a PLDM request message for GetPDR
1276 *
1277 * @param[in] instance_id - Message's instance id
1278 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
1279 * @param[in] data_transfer_hndl - Handle used to identify a particular
1280 * multipart PDR data transfer operation
1281 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
1282 * portion of transfer
1283 * @param[in] request_cnt - The maximum number of record bytes requested
1284 * @param[in] record_chg_num - Used to determine whether the PDR has changed
1285 * while PDR transfer is going on
1286 * @param[out] msg - Message will be written to this
1287 * @param[in] payload_length - Length of request message payload
1288 * @return pldm_completion_codes
1289 * @note Caller is responsible for memory alloc and dealloc of param
1290 * 'msg.payload'
1291 */
1292int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
1293 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
1294 uint16_t request_cnt, uint16_t record_chg_num,
1295 struct pldm_msg *msg, size_t payload_length);
1296
1297/** @brief Decode GetPDR response data
1298 *
1299 * Note:
1300 * * If the return value is not PLDM_SUCCESS, it represents a
1301 * transport layer error.
1302 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1303 * protocol layer error and all the out-parameters are invalid.
1304 *
1305 * @param[in] msg - Request message
1306 * @param[in] payload_length - Length of request message payload
1307 * @param[out] completion_code - PLDM completion code
1308 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1309 * the PDR Repository
1310 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1311 * portion of the PDR data to be transferred, if any
1312 * @param[out] transfer_flag - Indicates the portion of PDR data being
1313 * transferred
1314 * @param[out] resp_cnt - The number of recordData bytes returned in this
1315 * response
1316 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1317 * skip the copy and place the actual length in resp_cnt.
1318 * @param[in] record_data_length - Length of record_data
1319 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1320 * in the last part of a PDR being transferred
1321 * @return pldm_completion_codes
1322 */
1323int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1324 uint8_t *completion_code, uint32_t *next_record_hndl,
1325 uint32_t *next_data_transfer_hndl,
1326 uint8_t *transfer_flag, uint16_t *resp_cnt,
1327 uint8_t *record_data, size_t record_data_length,
1328 uint8_t *transfer_crc);
1329
1330/* SetStateEffecterStates */
1331
1332/** @brief Create a PLDM request message for SetStateEffecterStates
1333 *
1334 * @param[in] instance_id - Message's instance id
1335 * @param[in] effecter_id - used to identify and access the effecter
1336 * @param[in] comp_effecter_count - number of individual sets of effecter
1337 * information. Upto eight sets of state effecter info can be accessed
1338 * for a given effecter.
1339 * @param[in] field - each unit is an instance of the stateField structure
1340 * that is used to set the requested state for a particular effecter
1341 * within the state effecter. This field holds the starting address of
1342 * the stateField values. The user is responsible to allocate the
1343 * memory prior to calling this command. The user has to allocate the
1344 * field parameter as sizeof(set_effecter_state_field) *
1345 * comp_effecter_count
1346 * @param[out] msg - Message will be written to this
1347 * @return pldm_completion_codes
1348 * @note Caller is responsible for memory alloc and dealloc of param
1349 * 'msg.payload'
1350 */
1351
1352int encode_set_state_effecter_states_req(uint8_t instance_id,
1353 uint16_t effecter_id,
1354 uint8_t comp_effecter_count,
1355 set_effecter_state_field *field,
1356 struct pldm_msg *msg);
1357
1358/** @brief Decode SetStateEffecterStates response data
1359 *
1360 * Note:
1361 * * If the return value is not PLDM_SUCCESS, it represents a
1362 * transport layer error.
1363 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1364 * protocol layer error and all the out-parameters are invalid.
1365 *
1366 * @param[in] msg - Request message
1367 * @param[in] payload_length - Length of response message payload
1368 * @param[out] completion_code - PLDM completion code
1369 * @return pldm_completion_codes
1370 */
1371int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
1372 size_t payload_length,
1373 uint8_t *completion_code);
1374
1375/* SetNumericEffecterValue */
1376
1377/** @brief Create a PLDM request message for SetNumericEffecterValue
1378 *
1379 * @param[in] instance_id - Message's instance id
1380 * @param[in] effecter_id - used to identify and access the effecter
1381 * @param[in] effecter_data_size - The bit width and format of the setting
1382 * value for the effecter.
1383 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1384 * @param[in] effecter_value - The setting value of numeric effecter being
1385 * requested.
1386 * @param[in] payload_length - Length of request message payload
1387 * @param[out] msg - Message will be written to this
1388 * @return pldm_completion_codes
1389 * @note Caller is responsible for memory alloc and dealloc of param
1390 * 'msg.payload'
1391 */
1392int encode_set_numeric_effecter_value_req(
1393 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1394 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1395
1396/** @brief Decode SetNumericEffecterValue response data
1397 * @param[in] msg - Request message
1398 * @param[in] payload_length - Length of response message payload
1399 * @param[out] completion_code - PLDM completion code
1400 * @return pldm_completion_codes
1401 */
1402int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1403 size_t payload_length,
1404 uint8_t *completion_code);
1405
1406/** @brief Create a PLDM request message for GetStateSensorReadings
1407 *
1408 * @param[in] instance_id - Message's instance id
1409 * @param[in] sensor_id - used to identify and access the simple or composite
1410 * sensor
1411 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1412 * particular sensor within the state sensor, where bit [0] corresponds
1413 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1414 * to the eighth sensor (sensor offset 7), sequentially
1415 * @param[in] reserved - value: 0x00
1416 * @param[out] msg - Message will be written to this
1417 * @return pldm_completion_codes
1418 * @note Caller is responsible for memory alloc and dealloc of param
1419 * 'msg.payload'
1420 */
1421int encode_get_state_sensor_readings_req(uint8_t instance_id,
1422 uint16_t sensor_id,
1423 bitfield8_t sensor_rearm,
1424 uint8_t reserved,
1425 struct pldm_msg *msg);
1426
1427/** @brief Decode GetStateSensorReadings response data
1428 *
1429 * @param[in] msg - Request message
1430 * @param[in] payload_length - Length of response message payload
1431 * @param[out] completion_code - PLDM completion code
1432 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1433 * information that this command accesses
1434 * @param[out] field - Each stateField is an instance of a stateField structure
1435 * that is used to return the present operational state setting and the
1436 * present state and event state for a particular set of sensor
1437 * information contained within the state sensor
1438 * @return pldm_completion_codes
1439 */
1440
1441int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1442 size_t payload_length,
1443 uint8_t *completion_code,
1444 uint8_t *comp_sensor_count,
1445 get_sensor_state_field *field);
1446
1447/* PlatformEventMessage */
1448
1449/** @brief Decode PlatformEventMessage request data
1450 * @param[in] msg - Request message
1451 * @param[in] payload_length - Length of response message payload
1452 * @param[out] format_version - Version of the event format
1453 * @param[out] tid - Terminus ID for the terminus that originated the event
1454 * message
1455 * @param[out] event_class - The class of event being sent
1456 * @param[out] event_data_offset - Offset where the event data should be read
1457 * from pldm msg
1458 * @return pldm_completion_codes
1459 */
1460int decode_platform_event_message_req(const struct pldm_msg *msg,
1461 size_t payload_length,
1462 uint8_t *format_version, uint8_t *tid,
1463 uint8_t *event_class,
1464 size_t *event_data_offset);
1465
1466/** @brief Encode PlatformEventMessage response data
1467 * @param[in] instance_id - Message's instance id
1468 * @param[in] completion_code - PLDM completion code
1469 * @param[in] platform_event_status - Response status of the event message
1470 * command
1471 * @param[out] msg - Message will be written to this
1472 * @return pldm_completion_codes
1473 * @note Caller is responsible for memory alloc and dealloc of param
1474 * 'msg.payload'
1475 */
1476int encode_platform_event_message_resp(uint8_t instance_id,
1477 uint8_t completion_code,
1478 uint8_t platform_event_status,
1479 struct pldm_msg *msg);
1480
1481/** @brief Encode PlatformEventMessage request data
1482 * @param[in] instance_id - Message's instance id
1483 * @param[in] format_version - Version of the event format
1484 * @param[in] tid - Terminus ID for the terminus that originated the event
1485 * message
1486 * @param[in] event_class - The class of event being sent
1487 * @param[in] event_data - the event data should be read from pldm msg
1488 * @param[in] event_data_length - Length of the event data
1489 * @param[out] msg - Request message
1490 * @return pldm_completion_codes
1491 * @note Caller is responsible for memory alloc and dealloc of param
1492 * 'msg.payload'
1493 */
1494int encode_platform_event_message_req(
1495 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1496 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1497 struct pldm_msg *msg, size_t payload_length);
1498
1499/** @brief Decode PlatformEventMessage response data
1500 * @param[in] msg - Request message
1501 * @param[in] payload_length - Length of Response message payload
1502 * @param[out] completion_code - PLDM completion code
1503 * @param[out] platform_event_status - Response status of the event message
1504 * command
1505 * @return pldm_completion_codes
1506 */
1507int decode_platform_event_message_resp(const struct pldm_msg *msg,
1508 size_t payload_length,
1509 uint8_t *completion_code,
1510 uint8_t *platform_event_status);
1511
Dung Caod6ae8982022-11-02 10:00:10 +07001512/** @brief Decode EventMessageBufferSize response data
1513 * @param[in] msg - Request message
1514 * @param[in] payload_length - Length of Response message payload
1515 * @param[out] completion_code - PLDM completion code
1516 * @return pldm_completion_codes
1517 */
1518int decode_event_message_buffer_size_resp(const struct pldm_msg *msg,
1519 size_t payload_length,
1520 uint8_t *completion_code,
1521 uint16_t *terminus_max_buffer_size);
1522
1523/** @brief Encode EventMessageBufferSize request data
1524 * @param[in] instance_id - Message's instance id
1525 * @param[in] event_receiver_max_buffer_size - Max buffer size
1526 * @param[out] msg - Request message
1527 * @return pldm_completion_codes
1528 * @note Caller is responsible for memory alloc and dealloc of param
1529 * 'msg.payload'
1530 */
1531int encode_event_message_buffer_size_req(
1532 uint8_t instance_id, uint16_t event_receiver_max_buffer_size,
1533 struct pldm_msg *msg);
1534
Dung Cao1bf8c872022-11-29 05:32:58 +07001535/** @brief Encode EventMessageSupported request data
1536 *
1537 * @param[in] instance_id - Message's instance id
1538 * @param[in] format_version - Version of the event format
1539 * @param[out] msg - Request message
1540 *
1541 * @return pldm_completion_codes
1542 * @note Caller is responsible for memory alloc and dealloc of param
1543 * 'msg.payload'
1544 */
1545int encode_event_message_supported_req(uint8_t instance_id,
1546 uint8_t format_version,
1547 struct pldm_msg *msg);
1548
1549/** @brief Decode EventMessageSupported response data
1550 *
1551 * @param[in] msg - Request message
1552 * @param[in] payload_length - Length of Response message payload
1553 * @param[out] completion_code - PLDM completion code
1554 * @param[out] synchrony_config - the synchrony configuration
1555 * @param[out] synchrony_config_support - the synchrony configuration support
1556 * @param[out] number_event_class_returned - PLDM completion code
1557 * @param[out] event_class - the event classes
1558 * @param[in] event_class_count - the event class count
1559 *
1560 * @return pldm_completion_codes
1561 */
1562int decode_event_message_supported_resp(
1563 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1564 uint8_t *synchrony_config, bitfield8_t *synchrony_config_support,
1565 uint8_t *number_event_class_returned, uint8_t *event_class,
1566 uint8_t event_class_count);
1567
Andrew Jeffery9c766792022-08-10 23:12:49 +09301568/** @brief Decode sensorEventData response data
1569 *
1570 * @param[in] event_data - event data from the response message
1571 * @param[in] event_data_length - length of the event data
1572 * @param[out] sensor_id - sensorID value of the sensor
1573 * @param[out] sensor_event_class_type - Type of sensor event class
1574 * @param[out] event_class_data_offset - Offset where the event class data
1575 * should be read from event data
1576 * @return pldm_completion_codes
1577 * @note Caller is responsible for memory alloc and dealloc of param
1578 * 'event_data'
1579 */
1580int decode_sensor_event_data(const uint8_t *event_data,
1581 size_t event_data_length, uint16_t *sensor_id,
1582 uint8_t *sensor_event_class_type,
1583 size_t *event_class_data_offset);
1584
1585/** @brief Decode sensorOpState response data
1586 *
1587 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1588 * @param[in] sensor_data_length - Length of sensor_data
1589 * @param[out] present_op_state - The sensorOperationalState value from the
1590 * state change that triggered the event message
1591 * @param[out] previous_op_state - The sensorOperationalState value for the
1592 * state from which the present state was entered
1593 * @return pldm_completion_codes
1594 * @note Caller is responsible for memory alloc and dealloc of param
1595 * 'sensor_data'
1596 */
1597int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1598 uint8_t *present_op_state,
1599 uint8_t *previous_op_state);
1600
1601/** @brief Decode stateSensorState response data
1602 *
1603 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1604 * @param[in] sensor_data_length - Length of sensor_data
1605 * @param[out] sensor_offset - Identifies which state sensor within a composite
1606 * state sensor the event is being returned for
1607 * @param[out] event_state - The event state value from the state change that
1608 * triggered the event message
1609 * @param[out] previous_event_state - The event state value for the state from
1610 * which the present event state was entered
1611 * @return pldm_completion_codes
1612 * @note Caller is responsible for memory alloc and dealloc of param
1613 * 'sensor_data'
1614 */
1615int decode_state_sensor_data(const uint8_t *sensor_data,
1616 size_t sensor_data_length, uint8_t *sensor_offset,
1617 uint8_t *event_state,
1618 uint8_t *previous_event_state);
1619
1620/** @brief Decode numericSensorState response data
1621 *
1622 * @param[in] sensor_data - sensor_data for sensorEventClass =
1623 * numericSensorState
1624 * @param[in] sensor_data_length - Length of sensor_data
1625 * @param[out] event_state - The eventState value from the state change that
1626 * triggered the event message
1627 * @param[out] previous_event_state - The eventState value for the state from
1628 * which the present state was entered
1629 * @param[out] sensor_data_size - The bit width and format of reading and
1630 * threshold values that the sensor returns
1631 * @param[out] present_reading - The present value indicated by the sensor
1632 * @return pldm_completion_codes
1633 * @note Caller is responsible for memory alloc and dealloc of param
1634 * 'sensor_data'
1635 */
1636int decode_numeric_sensor_data(const uint8_t *sensor_data,
1637 size_t sensor_data_length, uint8_t *event_state,
1638 uint8_t *previous_event_state,
1639 uint8_t *sensor_data_size,
1640 uint32_t *present_reading);
1641
1642/* GetNumericEffecterValue */
1643
1644/** @brief Create a PLDM request message for GetNumericEffecterValue
1645 *
1646 * @param[in] instance_id - Message's instance id
1647 * @param[in] effecter_id - used to identify and access the effecter
1648 * @param[out] msg - Message will be written to this
1649 * @return pldm_completion_codes
1650 * @note Caller is responsible for memory alloc and dealloc of param
1651 * 'msg.payload'
1652 */
1653int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1654 uint16_t effecter_id,
1655 struct pldm_msg *msg);
1656
1657/** @brief Create a PLDM response message for GetNumericEffecterValue
1658 *
1659 * @param[in] msg - Request message
1660 * @param[in] payload_length - Length of request message payload
1661 * @param[out] completion_code - PLDM completion code
1662 * @param[out] effecter_data_size - The bit width and format of the setting
1663 * value for the effecter.
1664 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1665 * @param[out] effecter_oper_state - The state of the effecter itself
1666 * @param[out] pending_value - The pending numeric value setting of the
1667 * effecter. The effecterDataSize field indicates the number of
1668 * bits used for this field
1669 * @param[out] present_value - The present numeric value setting of the
1670 * effecter. The effecterDataSize indicates the number of bits
1671 * used for this field
1672 * @return pldm_completion_codes
1673 */
1674int decode_get_numeric_effecter_value_resp(
1675 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1676 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1677 uint8_t *pending_value, uint8_t *present_value);
1678
1679/** @brief Decode pldmPDRRepositoryChgEvent response data
1680 *
1681 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1682 * @param[in] event_data_size - Length of event_data
1683 * @param[out] event_data_format - This field indicates if the changedRecords
1684 * are of PDR Types or PDR Record Handles
1685 * @param[out] number_of_change_records - The number of changeRecords following
1686 * this field
1687 * @param[out] change_record_data_offset - Identifies where changeRecord data
1688 * is located within event_data
1689 * @return pldm_completion_codes
1690 * @note Caller is responsible for memory alloc and dealloc of param
1691 * 'event_data'
1692 */
1693int decode_pldm_pdr_repository_chg_event_data(
1694 const uint8_t *event_data, size_t event_data_size,
1695 uint8_t *event_data_format, uint8_t *number_of_change_records,
1696 size_t *change_record_data_offset);
1697
1698/** @brief Encode PLDM PDR Repository Change eventData
1699 * @param[in] event_data_format - Format of this event data (e.g.
1700 * FORMAT_IS_PDR_HANDLES)
1701 * @param[in] number_of_change_records - Number of changeRecords in this
1702 * eventData
1703 * @param[in] event_data_operations - Array of eventDataOperations
1704 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1705 * should contain number_of_change_records elements.
1706 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1707 * for each changeRecord in this eventData. This array should contain
1708 * number_of_change_records elements.
1709 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1710 * one array per changeRecord in this eventData. The toplevel array should
1711 * contain number_of_change_records elements. Each subarray [i] should
1712 * contain numbers_of_change_entries[i] elements.
1713 * @param[in] event_data - The eventData will be encoded into this. This entire
1714 * structure must be max_change_records_size long. It must be large enough
1715 * to accomodate the data to be encoded. The caller is responsible for
1716 * allocating and deallocating it, including the variable-size
1717 * 'event_data.change_records' field. If this parameter is NULL,
1718 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1719 * to reflect the required size of the structure.
1720 * @param[out] actual_change_records_size - The actual number of meaningful
1721 * encoded bytes in event_data. The caller can over-allocate memory and use
1722 * this output to determine the real size of the structure.
1723 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1724 * encoded message would be larger than this value, an error is returned.
1725 * @return pldm_completion_codes
1726 * @note Caller is responsible for memory alloc and dealloc of param
1727 * 'event_data.change_records'
1728 */
1729int encode_pldm_pdr_repository_chg_event_data(
1730 uint8_t event_data_format, uint8_t number_of_change_records,
1731 const uint8_t *event_data_operations,
1732 const uint8_t *numbers_of_change_entries,
1733 const uint32_t *const *change_entries,
1734 struct pldm_pdr_repository_chg_event_data *event_data,
1735 size_t *actual_change_records_size, size_t max_change_records_size);
1736
1737/** @brief Encode event data for a PLDM Sensor Event
1738 *
1739 * @param[out] event_data The object to store the encoded event in
1740 * @param[in] event_data_size Size of the allocation for event_data
1741 * @param[in] sensor_id Sensor ID
1742 * @param[in] sensor_event_class Sensor event class
1743 * @param[in] sensor_offset Offset
1744 * @param[in] event_state Event state
1745 * @param[in] previous_event_state Previous event state
1746 * @param[out] actual_event_data_size The real size in bytes of the event_data
1747 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1748 * @note If event_data is NULL, then *actual_event_data_size will be set to
1749 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1750 * @note The caller is responsible for allocating and deallocating the
1751 * event_data
1752 */
1753int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1754 size_t event_data_size, uint16_t sensor_id,
1755 enum sensor_event_class_states sensor_event_class,
1756 uint8_t sensor_offset, uint8_t event_state,
1757 uint8_t previous_event_state,
1758 size_t *actual_event_data_size);
1759
1760/** @brief Decode PldmPDRRepositoryChangeRecord response data
1761 *
1762 * @param[in] change_record_data - changeRecordData for
1763 * pldmPDRRepositoryChgEvent
1764 * @param[in] change_record_data_size - Length of change_record_data
1765 * @param[out] event_data_operation - This field indicates the changeEntries
1766 * operation types
1767 * @param[out] number_of_change_entries - The number of changeEntries following
1768 * this field
1769 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1770 * is located within change_record_data
1771 * @return pldm_completion_codes
1772 * @note Caller is responsible for memory alloc and dealloc of param
1773 * 'change_record_data'
1774 */
1775int decode_pldm_pdr_repository_change_record_data(
1776 const uint8_t *change_record_data, size_t change_record_data_size,
1777 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1778 size_t *change_entry_data_offset);
1779
1780/* GetSensorReading */
1781
1782/** @brief Encode GetSensorReading request data
1783 *
1784 * @param[in] instance_id - Message's instance id
1785 * @param[in] sensor_id - A handle that is used to identify and access the
1786 * sensor
1787 * @param[in] rearm_event_state - true = manually re-arm EventState after
1788 * responding to this request, false = no manual re-arm
1789 * @param[out] msg - Message will be written to this
1790 * @return pldm_completion_codes
1791 * @note Caller is responsible for memory alloc and dealloc of param
1792 * 'msg.payload'
1793 */
1794int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1795 bool8_t rearm_event_state,
1796 struct pldm_msg *msg);
1797
1798/** @brief Decode GetSensorReading response data
1799 *
1800 * @param[in] msg - Request message
1801 * @param[in] payload_length - Length of response message payload
1802 * @param[out] completion_code - PLDM completion code
1803 * @param[out] sensor_data_size - The bit width and format of reading and
1804 * threshold values
1805 * @param[out] sensor_operational_state - The state of the sensor itself
1806 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1807 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1808 * stateEventsOnlyEnabled }
1809 * @param[out] present_state - The most recently assessed state value monitored
1810 * by the sensor
1811 * @param[out] previous_state - The state that the presentState was entered
1812 * from
1813 * @param[out] event_state - Indicates which threshold crossing assertion
1814 * events have been detected
1815 * @param[out] present_reading - The present value indicated by the sensor
1816 * @return pldm_completion_codes
1817 */
1818
1819int decode_get_sensor_reading_resp(
1820 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1821 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1822 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1823 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1824
1825/** @brief Encode the SetEventReceiver request message
1826 *
1827 * @param[in] instance_id - Message's instance id
1828 * @param[in] event_message_global_enable - This value is used to enable or
1829 * disable event message generation from the terminus value: {
1830 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1831 * @param[in] transport_protocol_type - This value is provided in the request
1832 * to help the responder verify that the content of the
1833 * eventReceiverAddressInfo field used in this request is correct for
1834 * the messaging protocol supported by the terminus.
1835 * @param[in] event_receiver_address_info - this value is a medium and
1836 * protocol-specific address that the responder should use when
1837 * transmitting event messages using the indicated protocol
1838 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing
1839 * of which the terminus shall emit a heartbeat event to the receiver
1840 * @param[out] msg - Argument to capture the Message
1841 * @return pldm_completion_codes
1842 */
1843int encode_set_event_receiver_req(uint8_t instance_id,
1844 uint8_t event_message_global_enable,
1845 uint8_t transport_protocol_type,
1846 uint8_t event_receiver_address_info,
1847 uint16_t heartbeat_timer,
1848 struct pldm_msg *msg);
1849
1850/** @brief Decode the SetEventReceiver response message
1851 *
1852 * @param[in] msg - Request message
1853 * @param[in] payload_length - Length of response message payload
1854 * @param[out] completion_code - PLDM completion code
1855 * @return pldm_completion_codes
1856 */
1857int decode_set_event_receiver_resp(const struct pldm_msg *msg,
1858 size_t payload_length,
1859 uint8_t *completion_code);
1860
1861/** @brief Decode the SetEventReceiver request message
1862 *
1863 * @param[in] msg - Request message
1864 * @param[in] payload_length - Length of request message payload
1865 * @param[out] event_message_global_enable - This value is used to enable or
1866 * disable event message generation from the terminus value: {
1867 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1868 * @param[out] transport_protocol_type - This value is provided in the request
1869 * to help the responder verify that the content of the
1870 * eventReceiverAddressInfo field used in this request is correct for
1871 * the messaging protocol supported by the terminus.
1872 * @param[out] event_receiver_address_info - This value is a medium and
1873 * protocol-specific address that the responder should use when
1874 * transmitting event messages using the indicated protocol
1875 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing
1876 * of which the terminus shall emit a heartbeat event to the receiver
1877 * @return pldm_completion_codes
1878 */
1879int decode_set_event_receiver_req(const struct pldm_msg *msg,
1880 size_t payload_length,
1881 uint8_t *event_message_global_enable,
1882 uint8_t *transport_protocol_type,
1883 uint8_t *event_receiver_address_info,
1884 uint16_t *heartbeat_timer);
1885
1886/** @brief Encode the SetEventReceiver response message
1887 *
1888 * @param[in] instance_id - Message's instance id
1889 * @param[in] completion_code - PLDM completion code
1890 * @param[out] msg - Argument to capture the Message
1891 * @return pldm_completion_codes
1892 */
1893int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code,
1894 struct pldm_msg *msg);
1895
1896#ifdef __cplusplus
1897}
1898#endif
1899
1900#endif /* PLATFORM_H */