blob: c4b62f5fc758d45aded2db706274bee1a5b86889 [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,
Thu Nguyen0970e332023-01-12 13:28:58 +0700396 PLDM_RATE_UNIT_PER_HOUR,
397 PLDM_RATE_UNIT_PER_DAY,
398 PLDM_RATE_UNIT_PER_WEEK,
399 PLDM_RATE_UNIT_PER_MONTH,
400 PLDM_RATE_UNIT_PER_YEAR
Thu Nguyen02476112022-11-02 09:52:54 +0700401};
402
Andrew Jeffery9c766792022-08-10 23:12:49 +0930403/** @brief PLDM respository state */
404enum pldm_repository_state {
405 PLDM_AVAILABLE,
406 PLDM_UPDATE_IN_PROGRESS,
407 PLDM_FAILED
408};
409
410/** @brief PLDM respository data transfer handler timeout */
411enum pldm_repository_data_transfer_handler_timeout {
412 PLDM_NO_TIMEOUT,
413 PLDM_DEFALUT_MINIMUM_TIMEOUT
414};
415
Dung Cao1bf8c872022-11-29 05:32:58 +0700416/** @brief PLDM event message type */
417enum pldm_event_message_type {
418 PLDM_MESSAGE_TYPE_NOT_CONFIGURED = 0x00,
419 PLDM_MESSAGE_TYPE_ASYNCHRONOUS = 0x01,
420 PLDM_MESSAGE_TYPE_SYNCHRONOUS = 0x02,
421 PLDM_MESSAGE_TYPE_ASYNCHRONOUS_WITH_HEARTBEAT = 0x03
422};
423
Andrew Jeffery9c766792022-08-10 23:12:49 +0930424/** @struct pldm_pdr_hdr
425 *
426 * Structure representing PLDM common PDR header
427 */
428struct pldm_pdr_hdr {
429 uint32_t record_handle;
430 uint8_t version;
431 uint8_t type;
432 uint16_t record_change_num;
433 uint16_t length;
434} __attribute__((packed));
435
436/** @struct pldm_terminus_locator_pdr
437 *
438 * Structure representing PLDM terminus locator PDR
439 */
440struct pldm_terminus_locator_pdr {
441 struct pldm_pdr_hdr hdr;
442 uint16_t terminus_handle;
443 uint8_t validity;
444 uint8_t tid;
445 uint16_t container_id;
446 uint8_t terminus_locator_type;
447 uint8_t terminus_locator_value_size;
448 uint8_t terminus_locator_value[1];
449} __attribute__((packed));
450
451/** @struct pldm_terminus_locator_type_mctp_eid
452 *
453 * Structure representing terminus locator value for
454 * terminus locator type MCTP_EID
455 */
456struct pldm_terminus_locator_type_mctp_eid {
457 uint8_t eid;
458} __attribute__((packed));
459
460/** @struct pldm_pdr_entity_association
461 *
462 * Structure representing PLDM Entity Association PDR
463 */
464struct pldm_pdr_entity_association {
465 uint16_t container_id;
466 uint8_t association_type;
467 pldm_entity container;
468 uint8_t num_children;
469 pldm_entity children[1];
470} __attribute__((packed));
471
472/** @struct pldm_pdr_fru_record_set
473 *
474 * Structure representing PLDM FRU record set PDR
475 */
476struct pldm_pdr_fru_record_set {
477 uint16_t terminus_handle;
478 uint16_t fru_rsi;
479 uint16_t entity_type;
480 uint16_t entity_instance_num;
481 uint16_t container_id;
482} __attribute__((packed));
483
484/** @struct pldm_state_sensor_pdr
485 *
486 * Structure representing PLDM state sensor PDR
487 */
488struct pldm_state_sensor_pdr {
489 struct pldm_pdr_hdr hdr;
490 uint16_t terminus_handle;
491 uint16_t sensor_id;
492 uint16_t entity_type;
493 uint16_t entity_instance;
494 uint16_t container_id;
495 uint8_t sensor_init;
496 bool8_t sensor_auxiliary_names_pdr;
497 uint8_t composite_sensor_count;
498 uint8_t possible_states[1];
499} __attribute__((packed));
500
501/** @struct state_sensor_possible_states
502 *
503 * Structure representing state enums for state sensor
504 */
505struct state_sensor_possible_states {
506 uint16_t state_set_id;
507 uint8_t possible_states_size;
508 bitfield8_t states[1];
509} __attribute__((packed));
510
511/** @struct pldm_state_effecter_pdr
512 *
513 * Structure representing PLDM state effecter PDR
514 */
515struct pldm_state_effecter_pdr {
516 struct pldm_pdr_hdr hdr;
517 uint16_t terminus_handle;
518 uint16_t effecter_id;
519 uint16_t entity_type;
520 uint16_t entity_instance;
521 uint16_t container_id;
522 uint16_t effecter_semantic_id;
523 uint8_t effecter_init;
524 bool8_t has_description_pdr;
525 uint8_t composite_effecter_count;
526 uint8_t possible_states[1];
527} __attribute__((packed));
528
Thu Nguyend2972ef2023-01-12 13:33:47 +0700529/** @struct pldm_compact_numeric_sensor_pdr
Thu Nguyen02476112022-11-02 09:52:54 +0700530 *
Thu Nguyend2972ef2023-01-12 13:33:47 +0700531 * Structure representing PLDM compact numeric sensor PDR
Thu Nguyen02476112022-11-02 09:52:54 +0700532 */
Thu Nguyend2972ef2023-01-12 13:33:47 +0700533struct pldm_compact_numeric_sensor_pdr {
Thu Nguyen02476112022-11-02 09:52:54 +0700534 struct pldm_pdr_hdr hdr;
535 uint16_t terminus_handle;
536 uint16_t sensor_id;
537 uint16_t entity_type;
538 uint16_t entity_instance;
539 uint16_t container_id;
540 uint8_t sensor_name_length;
541 uint8_t base_unit;
542 int8_t unit_modifier;
543 uint8_t occurrence_rate;
544 bitfield8_t range_field_support;
545 int32_t warning_high;
546 int32_t warning_low;
547 int32_t critical_high;
548 int32_t critical_low;
549 int32_t fatal_high;
550 int32_t fatal_low;
551 uint8_t sensor_name[1];
552} __attribute__((packed));
553
Andrew Jeffery9c766792022-08-10 23:12:49 +0930554/** @brief Encode PLDM state sensor PDR
555 *
556 * @param[in/out] sensor Structure to encode. All members of
557 * sensor, except those mentioned in the @note below, should be initialized by
558 * the caller.
559 * @param[in] allocation_size Size of sensor allocation in bytes
560 * @param[in] possible_states Possible sensor states
561 * @param[in] possible_states_size Size of possible sensor states in bytes
562 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
563 * @return int pldm_completion_codes
564 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
565 *
566 * @note The sensor parameter will be encoded in place.
567 * @note Caller is responsible for allocation of the sensor parameter. Caller
568 * must allocate enough space for the base structure and the
569 * sensor->possible_states array, otherwise the function will fail.
570 * @note sensor->hdr.length, .type, and .version will be set appropriately.
571 */
572int encode_state_sensor_pdr(
573 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
574 const struct state_sensor_possible_states *possible_states,
575 size_t possible_states_size, size_t *actual_size);
576
577/** @union union_effecter_data_size
578 *
579 * The bit width and format of reading and threshold values that the effecter
580 * returns.
581 * Refer to: DSP0248_1.2.0: 28.11 Table 87
582 */
583typedef union {
584 uint8_t value_u8;
585 int8_t value_s8;
586 uint16_t value_u16;
587 int16_t value_s16;
588 uint32_t value_u32;
589 int32_t value_s32;
590} union_effecter_data_size;
591
592/** @union union_range_field_format
593 *
594 * Indicates the format used for the nominalValue, normalMax, and normalMin
595 * fields.
596 * Refer to: DSP0248_1.2.0: 28.11 Table 87
597 */
598typedef union {
599 uint8_t value_u8;
600 int8_t value_s8;
601 uint16_t value_u16;
602 int16_t value_s16;
603 uint32_t value_u32;
604 int32_t value_s32;
605 real32_t value_f32;
606} union_range_field_format;
607
608/** @struct pldm_numeric_effecter_value_pdr
609 *
610 * Structure representing PLDM numeric effecter value PDR
611 */
612struct pldm_numeric_effecter_value_pdr {
613 struct pldm_pdr_hdr hdr;
614 uint16_t terminus_handle;
615 uint16_t effecter_id;
616 uint16_t entity_type;
617 uint16_t entity_instance;
618 uint16_t container_id;
619 uint16_t effecter_semantic_id;
620 uint8_t effecter_init;
621 bool8_t effecter_auxiliary_names;
622 uint8_t base_unit;
623 int8_t unit_modifier;
624 uint8_t rate_unit;
625 uint8_t base_oem_unit_handle;
626 uint8_t aux_unit;
627 int8_t aux_unit_modifier;
628 uint8_t aux_rate_unit;
629 uint8_t aux_oem_unit_handle;
630 bool8_t is_linear;
631 uint8_t effecter_data_size;
632 real32_t resolution;
633 real32_t offset;
634 uint16_t accuracy;
635 uint8_t plus_tolerance;
636 uint8_t minus_tolerance;
637 real32_t state_transition_interval;
638 real32_t transition_interval;
639 union_effecter_data_size max_settable;
640 union_effecter_data_size min_settable;
641 uint8_t range_field_format;
642 bitfield8_t range_field_support;
643 union_range_field_format nominal_value;
644 union_range_field_format normal_max;
645 union_range_field_format normal_min;
646 union_range_field_format rated_max;
647 union_range_field_format rated_min;
648} __attribute__((packed));
649
650/** @struct state_effecter_possible_states
651 *
652 * Structure representing state enums for state effecter
653 */
654struct state_effecter_possible_states {
655 uint16_t state_set_id;
656 uint8_t possible_states_size;
657 bitfield8_t states[1];
658} __attribute__((packed));
659
Thu Nguyen0585de92022-11-02 09:57:25 +0700660/** @struct pldm_effecter_aux_name_pdr
661 *
662 * Structure representing PLDM aux name numeric effecter value PDR
663 */
664struct pldm_effecter_aux_name_pdr {
665 struct pldm_pdr_hdr hdr;
666 uint16_t terminus_handle;
667 uint16_t effecter_id;
668 uint8_t effecter_count;
669 uint8_t effecter_names[1];
670} __attribute__((packed));
671
Andrew Jeffery9c766792022-08-10 23:12:49 +0930672/** @brief Encode PLDM state effecter PDR
673 *
674 * @param[in/out] effecter Structure to encode. All members of
675 * effecter, except those mentioned in
676 * the @note below, should be initialized
677 * by the caller.
678 * @param[in] allocation_size Size of effecter allocation in bytes
679 * @param[in] possible_states Possible effecter states
680 * @param[in] possible_states_size Size of possible effecter states in
681 * bytes
682 * @param[out] actual_size Size of effecter PDR. Set to 0 on
683 * error.
684 * @return int pldm_completion_codes
685 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
686 *
687 * @note The effecter parameter will be encoded in place.
688 * @note Caller is responsible for allocation of the effecter parameter. Caller
689 * must allocate enough space for the base structure and the
690 * effecter->possible_states array, otherwise the function will fail.
691 * @note effecter->hdr.length, .type, and .version will be set appropriately.
692 */
693int encode_state_effecter_pdr(
694 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
695 const struct state_effecter_possible_states *possible_states,
696 size_t possible_states_size, size_t *actual_size);
697
698/** @struct set_effecter_state_field
699 *
700 * Structure representing a stateField in SetStateEffecterStates command */
701
702typedef struct state_field_for_state_effecter_set {
703 uint8_t set_request; //!< Whether to change the state
704 uint8_t effecter_state; //!< Expected state of the effecter
705} __attribute__((packed)) set_effecter_state_field;
706
707/** @struct get_sensor_readings_field
708 *
709 * Structure representing a stateField in GetStateSensorReadings command */
710
711typedef struct state_field_for_get_state_sensor_readings {
712 uint8_t sensor_op_state; //!< The state of the sensor itself
713 uint8_t present_state; //!< Return a state value
714 uint8_t previous_state; //!< The state that the presentState was entered
715 //! from. This must be different from the
716 //! present state
717 uint8_t event_state; //!< Return a state value from a PLDM State Set
718 //! that is associated with the sensor
719} __attribute__((packed)) get_sensor_state_field;
720
721/** @struct PLDM_SetStateEffecterStates_Request
722 *
723 * Structure representing PLDM set state effecter states request.
724 */
725struct pldm_set_state_effecter_states_req {
726 uint16_t effecter_id;
727 uint8_t comp_effecter_count;
728 set_effecter_state_field field[8];
729} __attribute__((packed));
730
731/** @struct pldm_get_pdr_repository_info_resp
732 *
733 * Structure representing GetPDRRepositoryInfo response packet
734 */
735struct pldm_pdr_repository_info_resp {
736 uint8_t completion_code;
737 uint8_t repository_state;
738 uint8_t update_time[PLDM_TIMESTAMP104_SIZE];
739 uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE];
740 uint32_t record_count;
741 uint32_t repository_size;
742 uint32_t largest_record_size;
743 uint8_t data_transfer_handle_timeout;
744} __attribute__((packed));
745
746/** @struct pldm_get_pdr_resp
747 *
748 * structure representing GetPDR response packet
749 * transfer CRC is not part of the structure and will be
750 * added at the end of last packet in multipart transfer
751 */
752struct pldm_get_pdr_resp {
753 uint8_t completion_code;
754 uint32_t next_record_handle;
755 uint32_t next_data_transfer_handle;
756 uint8_t transfer_flag;
757 uint16_t response_count;
758 uint8_t record_data[1];
759} __attribute__((packed));
760
761/** @struct pldm_get_pdr_req
762 *
763 * structure representing GetPDR request packet
764 */
765struct pldm_get_pdr_req {
766 uint32_t record_handle;
767 uint32_t data_transfer_handle;
768 uint8_t transfer_op_flag;
769 uint16_t request_count;
770 uint16_t record_change_number;
771} __attribute__((packed));
772
773/** @struct pldm_set_event_receiver_req
774 *
775 * Structure representing SetEventReceiver command.
776 * This structure applies only for MCTP as a transport type.
777 */
778struct pldm_set_event_receiver_req {
779 uint8_t event_message_global_enable;
780 uint8_t transport_protocol_type;
781 uint8_t event_receiver_address_info;
782 uint16_t heartbeat_timer;
783} __attribute__((packed));
784
Dung Caod6ae8982022-11-02 10:00:10 +0700785/** @struct pldm_event_message_buffer_size_req
786 *
787 * Structure representing EventMessageBufferSizes command request data
788 */
789struct pldm_event_message_buffer_size_req {
790 uint16_t event_receiver_max_buffer_size;
791} __attribute__((packed));
792
793/** @struct pldm_event_message_buffer_size_resp
794 *
795 * Structure representing EventMessageBufferSizes command response data
796 */
797struct pldm_event_message_buffer_size_resp {
798 uint8_t completion_code;
799 uint16_t terminus_max_buffer_size;
800} __attribute__((packed));
801
Dung Cao1bf8c872022-11-29 05:32:58 +0700802/** @struct pldm_platform_event_message_supported_req
803 *
804 * structure representing PlatformEventMessageSupported command request data
805 */
806struct pldm_event_message_supported_req {
807 uint8_t format_version;
808} __attribute__((packed));
809
810/** @struct pldm_event_message_supported_response
811 *
812 * structure representing EventMessageSupported command response data
813 */
814struct pldm_event_message_supported_resp {
815 uint8_t completion_code;
816 uint8_t synchrony_configuration;
817 bitfield8_t synchrony_configuration_supported;
818 uint8_t number_event_class_returned;
819 uint8_t event_class[1];
820} __attribute__((packed));
821
Andrew Jeffery9c766792022-08-10 23:12:49 +0930822/** @struct pldm_set_numeric_effecter_value_req
823 *
824 * structure representing SetNumericEffecterValue request packet
825 */
826struct pldm_set_numeric_effecter_value_req {
827 uint16_t effecter_id;
828 uint8_t effecter_data_size;
829 uint8_t effecter_value[1];
830} __attribute__((packed));
831
832/** @struct pldm_get_state_sensor_readings_req
833 *
834 * Structure representing PLDM get state sensor readings request.
835 */
836struct pldm_get_state_sensor_readings_req {
837 uint16_t sensor_id;
838 bitfield8_t sensor_rearm;
839 uint8_t reserved;
840} __attribute__((packed));
841
842/** @struct pldm_get_state_sensor_readings_resp
843 *
844 * Structure representing PLDM get state sensor readings response.
845 */
846struct pldm_get_state_sensor_readings_resp {
847 uint8_t completion_code;
848 uint8_t comp_sensor_count;
849 get_sensor_state_field field[1];
850} __attribute__((packed));
851
852/** @struct pldm_sensor_event
853 *
854 * structure representing sensorEventClass
855 */
856struct pldm_sensor_event_data {
857 uint16_t sensor_id;
858 uint8_t sensor_event_class_type;
859 uint8_t event_class[1];
860} __attribute__((packed));
861
862/** @struct pldm_state_sensor_state
863 *
864 * structure representing sensorEventClass for stateSensorState
865 */
866struct pldm_sensor_event_state_sensor_state {
867 uint8_t sensor_offset;
868 uint8_t event_state;
869 uint8_t previous_event_state;
870} __attribute__((packed));
871
872/** @struct pldm_sensor_event_numeric_sensor_state
873 *
874 * structure representing sensorEventClass for stateSensorState
875 */
876struct pldm_sensor_event_numeric_sensor_state {
877 uint8_t event_state;
878 uint8_t previous_event_state;
879 uint8_t sensor_data_size;
880 uint8_t present_reading[1];
881} __attribute__((packed));
882
883/** @struct pldm_sensor_event_sensor_op_state
884 *
885 * structure representing sensorEventClass for SensorOpState
886 */
887struct pldm_sensor_event_sensor_op_state {
888 uint8_t present_op_state;
889 uint8_t previous_op_state;
890} __attribute__((packed));
891
892/** @struct pldm_platform_event_message_req
893 *
894 * structure representing PlatformEventMessage command request data
895 */
896struct pldm_platform_event_message_req {
897 uint8_t format_version;
898 uint8_t tid;
899 uint8_t event_class;
900 uint8_t event_data[1];
901} __attribute__((packed));
902
903/** @struct pldm_platform_event_message_response
904 *
905 * structure representing PlatformEventMessage command response data
906 */
907struct pldm_platform_event_message_resp {
908 uint8_t completion_code;
909 uint8_t platform_event_status;
910} __attribute__((packed));
911
912/** @struct pldm_pdr_repository_chg_event_data
913 *
914 * structure representing pldmPDRRepositoryChgEvent class eventData
915 */
916struct pldm_pdr_repository_chg_event_data {
917 uint8_t event_data_format;
918 uint8_t number_of_change_records;
919 uint8_t change_records[1];
920} __attribute__((packed));
921
922/** @struct pldm_pdr_repository_chg_event_change_record_data
923 *
924 * structure representing pldmPDRRepositoryChgEvent class eventData's change
925 * record data
926 */
927struct pldm_pdr_repository_change_record_data {
928 uint8_t event_data_operation;
929 uint8_t number_of_change_entries;
930 uint32_t change_entry[1];
931} __attribute__((packed));
932
933/** @struct pldm_get_numeric_effecter_value_req
934 *
935 * structure representing GetNumericEffecterValue request packet
936 */
937struct pldm_get_numeric_effecter_value_req {
938 uint16_t effecter_id;
939} __attribute__((packed));
940
941/** @struct pldm_get_numeric_effecter_value_resp
942 *
943 * structure representing GetNumericEffecterValue response packet
944 */
945struct pldm_get_numeric_effecter_value_resp {
946 uint8_t completion_code;
947 uint8_t effecter_data_size;
948 uint8_t effecter_oper_state;
949 uint8_t pending_and_present_values[1];
950} __attribute__((packed));
951
952/** @struct pldm_get_sensor_reading_req
953 *
954 * Structure representing PLDM get sensor reading request
955 */
956struct pldm_get_sensor_reading_req {
957 uint16_t sensor_id;
958 bool8_t rearm_event_state;
959} __attribute__((packed));
960
961/** @struct pldm_get_sensor_reading_resp
962 *
963 * Structure representing PLDM get sensor reading response
964 */
965struct pldm_get_sensor_reading_resp {
966 uint8_t completion_code;
967 uint8_t sensor_data_size;
968 uint8_t sensor_operational_state;
969 uint8_t sensor_event_message_enable;
970 uint8_t present_state;
971 uint8_t previous_state;
972 uint8_t event_state;
973 uint8_t present_reading[1];
974} __attribute__((packed));
975
976/* Responder */
977
978/* SetNumericEffecterValue */
979
980/** @brief Decode SetNumericEffecterValue request data
981 *
982 * @param[in] msg - Request message
983 * @param[in] payload_length - Length of request message payload
984 * @param[out] effecter_id - used to identify and access the effecter
985 * @param[out] effecter_data_size - The bit width and format of the setting
986 * value for the effecter.
987 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
988 * @param[out] effecter_value - The setting value of numeric effecter being
989 * requested.
990 * @return pldm_completion_codes
991 */
992int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
993 size_t payload_length,
994 uint16_t *effecter_id,
995 uint8_t *effecter_data_size,
996 uint8_t *effecter_value);
997
998/** @brief Create a PLDM response message for SetNumericEffecterValue
999 *
1000 * @param[in] instance_id - Message's instance id
1001 * @param[in] completion_code - PLDM completion code
1002 * @param[out] msg - Message will be written to this
1003 * @param[in] payload_length - Length of request message payload
1004 * @return pldm_completion_codes
1005 * @note Caller is responsible for memory alloc and dealloc of param
1006 * 'msg.body.payload'
1007 */
1008int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
1009 uint8_t completion_code,
1010 struct pldm_msg *msg,
1011 size_t payload_length);
1012
1013/* SetStateEffecterStates */
1014
1015/** @brief Create a PLDM response message for SetStateEffecterStates
1016 *
1017 * @param[in] instance_id - Message's instance id
1018 * @param[in] completion_code - PLDM completion code
1019 * @param[out] msg - Message will be written to this
1020 * @return pldm_completion_codes
1021 * @note Caller is responsible for memory alloc and dealloc of param
1022 * 'msg.body.payload'
1023 */
1024
1025int encode_set_state_effecter_states_resp(uint8_t instance_id,
1026 uint8_t completion_code,
1027 struct pldm_msg *msg);
1028
1029/** @brief Decode SetStateEffecterStates request data
1030 *
1031 * @param[in] msg - Request message
1032 * @param[in] payload_length - Length of request message payload
1033 * @param[out] effecter_id - used to identify and access the effecter
1034 * @param[out] comp_effecter_count - number of individual sets of effecter
1035 * information. Upto eight sets of state effecter info can be accessed
1036 * for a given effecter.
1037 * @param[out] field - each unit is an instance of the stateFileld structure
1038 * that is used to set the requested state for a particular effecter
1039 * within the state effecter. This field holds the starting address of
1040 * the stateField values. The user is responsible to allocate the
1041 * memory prior to calling this command. Since the state field count is
1042 * not known in advance, the user should allocate the maximum size
1043 * always, which is 8 in number.
1044 * @return pldm_completion_codes
1045 */
1046
1047int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
1048 size_t payload_length,
1049 uint16_t *effecter_id,
1050 uint8_t *comp_effecter_count,
1051 set_effecter_state_field *field);
1052
1053/* GetPDR */
1054
1055/** @brief Create a PLDM response message for GetPDR
1056 *
1057 * @param[in] instance_id - Message's instance id
1058 * @param[in] completion_code - PLDM completion code
1059 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
1060 * the PDR Repository
1061 * @param[in] next_data_transfer_hndl - A handle that identifies the next
1062 * portion of the PDR data to be transferred, if any
1063 * @param[in] transfer_flag - Indicates the portion of PDR data being
1064 * transferred
1065 * @param[in] resp_cnt - The number of recordData bytes returned in this
1066 * response
1067 * @param[in] record_data - PDR data bytes of length resp_cnt
1068 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
1069 * in the last part of a PDR being transferred
1070 * @param[out] msg - Message will be written to this
1071 * @return pldm_completion_codes
1072 * @note Caller is responsible for memory alloc and dealloc of param
1073 * 'msg.payload'
1074 */
1075int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
1076 uint32_t next_record_hndl,
1077 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
1078 uint16_t resp_cnt, const uint8_t *record_data,
1079 uint8_t transfer_crc, struct pldm_msg *msg);
1080
1081/** @brief Decode GetPDR request data
1082 *
1083 * @param[in] msg - Request message
1084 * @param[in] payload_length - Length of request message payload
1085 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
1086 * @param[out] data_transfer_hndl - Handle used to identify a particular
1087 * multipart PDR data transfer operation
1088 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
1089 * portion of transfer
1090 * @param[out] request_cnt - The maximum number of record bytes requested
1091 * @param[out] record_chg_num - Used to determine whether the PDR has changed
1092 * while PDR transfer is going on
1093 * @return pldm_completion_codes
1094 */
1095
1096int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
1097 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
1098 uint8_t *transfer_op_flag, uint16_t *request_cnt,
1099 uint16_t *record_chg_num);
1100
1101/* GetStateSensorReadings */
1102
1103/** @brief Decode GetStateSensorReadings request data
1104 *
1105 * @param[in] msg - Request message
1106 * @param[in] payload_length - Length of request message payload
1107 * @param[out] sensor_id - used to identify and access the simple or composite
1108 * sensor
1109 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
1110 * particular sensor within the state sensor, where bit [0] corresponds
1111 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1112 * to the eighth sensor (sensor offset 7), sequentially.
1113 * @param[out] reserved - value: 0x00
1114 * @return pldm_completion_codes
1115 */
1116
1117int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
1118 size_t payload_length,
1119 uint16_t *sensor_id,
1120 bitfield8_t *sensor_rearm,
1121 uint8_t *reserved);
1122
1123/** @brief Encode GetStateSensorReadings response data
1124 *
1125 * @param[in] instance_id - Message's instance id
1126 * @param[in] completion_code - PLDM completion code
1127 * @param[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 * @param[out] msg - Message will be written to this
1134 * @return pldm_completion_codes
1135 */
1136
1137int encode_get_state_sensor_readings_resp(uint8_t instance_id,
1138 uint8_t completion_code,
1139 uint8_t comp_sensor_count,
1140 get_sensor_state_field *field,
1141 struct pldm_msg *msg);
1142
1143/* GetNumericEffecterValue */
1144
1145/** @brief Decode GetNumericEffecterValue request data
1146 *
1147 * @param[in] msg - Request message
1148 * @param[in] payload_length - Length of request message payload
1149 * @param[out] effecter_id - used to identify and access the effecter
1150 * @return pldm_completion_codes
1151 */
1152int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
1153 size_t payload_length,
1154 uint16_t *effecter_id);
1155
1156/** @brief Create a PLDM response message for GetNumericEffecterValue
1157 *
1158 * @param[in] instance_id - Message's instance id
1159 * @param[in] completion_code - PLDM completion code
1160 * @param[in] effecter_data_size - The bit width and format of the setting
1161 * value for the effecter.
1162 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1163 * @param[in] effecter_oper_state - The state of the effecter itself
1164 * @param[in] pending_value - The pending numeric value setting of the
1165 * effecter. The effecterDataSize field indicates the number of
1166 * bits used for this field
1167 * @param[in] present_value - The present numeric value setting of the
1168 * effecter. The effecterDataSize indicates the number of bits
1169 * used for this field
1170 * @param[out] msg - Message will be written to this
1171 * @param[in] payload_length - Length of request message payload
1172 * @return pldm_completion_codes
1173 * @note Caller is responsible for memory alloc and dealloc of param
1174 * 'msg.payload'
1175 */
1176int encode_get_numeric_effecter_value_resp(
1177 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
1178 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
1179 struct pldm_msg *msg, size_t payload_length);
1180
1181/* GetSensorReading */
1182
1183/** @brief Decode GetSensorReading request data
1184 *
1185 * @param[in] msg - Request message
1186 * @param[in] payload_length - Length of request message payload
1187 * @param[out] sensor_id - A handle that is used to identify and access
1188 * the sensor
1189 * @param[out] rearm_event_state - true = manually re-arm EventState after
1190 * responding to this request, false = no manual re-arm
1191 * @return pldm_completion_codes
1192 */
1193
1194int decode_get_sensor_reading_req(const struct pldm_msg *msg,
1195 size_t payload_length, uint16_t *sensor_id,
1196 bool8_t *rearm_event_state);
1197
1198/** @brief Encode GetSensorReading response data
1199 *
1200 * @param[in] instance_id - Message's instance id
1201 * @param[in] completion_code - PLDM completion code
1202 * @param[out] sensor_data_size - The bit width and format of reading and
1203 * threshold values
1204 * @param[out] sensor_operational_state - The state of the sensor itself
1205 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1206 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1207 * stateEventsOnlyEnabled }
1208 * @param[out] present_state - The most recently assessed state value monitored
1209 * by the sensor
1210 * @param[out] previous_state - The state that the presentState was entered
1211 * from
1212 * @param[out] event_state - Indicates which threshold crossing assertion
1213 * events have been detected
1214 * @param[out] present_reading - The present value indicated by the sensor
1215 * @param[out] msg - Message will be written to this
1216 * @param[in] payload_length - Length of request message payload
1217 * @return pldm_completion_codes
1218 */
1219
1220int encode_get_sensor_reading_resp(
1221 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
1222 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
1223 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
1224 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
1225
1226/* Requester */
1227
1228/*GetPDRRepositoryInfo*/
1229
1230/** @brief Encode GetPDRRepositoryInfo response data
1231 *
1232 * @param[in] instance_id - Message's instance id
1233 * @param[in] completion_code - PLDM completion code
1234 * @param[in] repository_state - PLDM repository state
1235 * @param[in] update_time - When the standard PDR repository data was
1236 * originally created
1237 * @param[in] oem_update_time - when OEM PDRs in the PDR Repository were
1238 * originally created
1239 * @param[in] record_count - Total number of PDRs in this repository
1240 * @param[in] repository_size - Size of the PDR Repository in bytes
1241 * @param[in] largest_record_size - Size of the largest record in the PDR
1242 * Repository in bytes
1243 * @param[in] data_transfer_handle_timeout - Data transmission timeout
1244 * @param[out] msg - Message will be written to this
1245 * @return pldm_completion_codes
1246 */
1247int encode_get_pdr_repository_info_resp(
1248 uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
1249 const uint8_t *update_time, const uint8_t *oem_update_time,
1250 uint32_t record_count, uint32_t repository_size,
1251 uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
1252 struct pldm_msg *msg);
1253
Gilbert Chenb7c73e52022-11-10 11:29:52 +08001254/** @brief Decode GetPDRRepositoryInfo response data
1255 *
1256 * @param[in] msg - Response message
1257 * @param[in] payload_length - Length of response message payload
1258 * @param[out] completion_code - PLDM completion code
1259 * @param[out] repository_state - PLDM repository state
1260 * @param[out] update_time - When the standard PDR repository data was
1261 * originally created
1262 * @param[out] oem_update_time - when OEM PDRs in the PDR Repository were
1263 * originally created
1264 * @param[out] record_count - Total number of PDRs in this repository
1265 * @param[out] repository_size - Size of the PDR Repository in bytes
1266 * @param[out] largest_record_size - Size of the largest record in the PDR
1267 * Repository in bytes
1268 * @param[out] data_transfer_handle_timeout - Data transmission timeout
1269 * @return pldm_completion_codes
1270 */
1271int decode_get_pdr_repository_info_resp(
1272 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1273 uint8_t *repository_state, uint8_t *update_time, uint8_t *oem_update_time,
1274 uint32_t *record_count, uint32_t *repository_size,
1275 uint32_t *largest_record_size, uint8_t *data_transfer_handle_timeout);
1276
Andrew Jeffery9c766792022-08-10 23:12:49 +09301277/* GetPDR */
1278
1279/** @brief Create a PLDM request message for GetPDR
1280 *
1281 * @param[in] instance_id - Message's instance id
1282 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
1283 * @param[in] data_transfer_hndl - Handle used to identify a particular
1284 * multipart PDR data transfer operation
1285 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
1286 * portion of transfer
1287 * @param[in] request_cnt - The maximum number of record bytes requested
1288 * @param[in] record_chg_num - Used to determine whether the PDR has changed
1289 * while PDR transfer is going on
1290 * @param[out] msg - Message will be written to this
1291 * @param[in] payload_length - Length of request message payload
1292 * @return pldm_completion_codes
1293 * @note Caller is responsible for memory alloc and dealloc of param
1294 * 'msg.payload'
1295 */
1296int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
1297 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
1298 uint16_t request_cnt, uint16_t record_chg_num,
1299 struct pldm_msg *msg, size_t payload_length);
1300
1301/** @brief Decode GetPDR response data
1302 *
1303 * Note:
1304 * * If the return value is not PLDM_SUCCESS, it represents a
1305 * transport layer error.
1306 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1307 * protocol layer error and all the out-parameters are invalid.
1308 *
1309 * @param[in] msg - Request message
1310 * @param[in] payload_length - Length of request message payload
1311 * @param[out] completion_code - PLDM completion code
1312 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1313 * the PDR Repository
1314 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1315 * portion of the PDR data to be transferred, if any
1316 * @param[out] transfer_flag - Indicates the portion of PDR data being
1317 * transferred
1318 * @param[out] resp_cnt - The number of recordData bytes returned in this
1319 * response
1320 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1321 * skip the copy and place the actual length in resp_cnt.
1322 * @param[in] record_data_length - Length of record_data
1323 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1324 * in the last part of a PDR being transferred
1325 * @return pldm_completion_codes
1326 */
1327int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1328 uint8_t *completion_code, uint32_t *next_record_hndl,
1329 uint32_t *next_data_transfer_hndl,
1330 uint8_t *transfer_flag, uint16_t *resp_cnt,
1331 uint8_t *record_data, size_t record_data_length,
1332 uint8_t *transfer_crc);
1333
1334/* SetStateEffecterStates */
1335
1336/** @brief Create a PLDM request message for SetStateEffecterStates
1337 *
1338 * @param[in] instance_id - Message's instance id
1339 * @param[in] effecter_id - used to identify and access the effecter
1340 * @param[in] comp_effecter_count - number of individual sets of effecter
1341 * information. Upto eight sets of state effecter info can be accessed
1342 * for a given effecter.
1343 * @param[in] field - each unit is an instance of the stateField structure
1344 * that is used to set the requested state for a particular effecter
1345 * within the state effecter. This field holds the starting address of
1346 * the stateField values. The user is responsible to allocate the
1347 * memory prior to calling this command. The user has to allocate the
1348 * field parameter as sizeof(set_effecter_state_field) *
1349 * comp_effecter_count
1350 * @param[out] msg - Message will be written to this
1351 * @return pldm_completion_codes
1352 * @note Caller is responsible for memory alloc and dealloc of param
1353 * 'msg.payload'
1354 */
1355
1356int encode_set_state_effecter_states_req(uint8_t instance_id,
1357 uint16_t effecter_id,
1358 uint8_t comp_effecter_count,
1359 set_effecter_state_field *field,
1360 struct pldm_msg *msg);
1361
1362/** @brief Decode SetStateEffecterStates response data
1363 *
1364 * Note:
1365 * * If the return value is not PLDM_SUCCESS, it represents a
1366 * transport layer error.
1367 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1368 * protocol layer error and all the out-parameters are invalid.
1369 *
1370 * @param[in] msg - Request message
1371 * @param[in] payload_length - Length of response message payload
1372 * @param[out] completion_code - PLDM completion code
1373 * @return pldm_completion_codes
1374 */
1375int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
1376 size_t payload_length,
1377 uint8_t *completion_code);
1378
1379/* SetNumericEffecterValue */
1380
1381/** @brief Create a PLDM request message for SetNumericEffecterValue
1382 *
1383 * @param[in] instance_id - Message's instance id
1384 * @param[in] effecter_id - used to identify and access the effecter
1385 * @param[in] effecter_data_size - The bit width and format of the setting
1386 * value for the effecter.
1387 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1388 * @param[in] effecter_value - The setting value of numeric effecter being
1389 * requested.
1390 * @param[in] payload_length - Length of request message payload
1391 * @param[out] msg - Message will be written to this
1392 * @return pldm_completion_codes
1393 * @note Caller is responsible for memory alloc and dealloc of param
1394 * 'msg.payload'
1395 */
1396int encode_set_numeric_effecter_value_req(
1397 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1398 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1399
1400/** @brief Decode SetNumericEffecterValue response data
1401 * @param[in] msg - Request message
1402 * @param[in] payload_length - Length of response message payload
1403 * @param[out] completion_code - PLDM completion code
1404 * @return pldm_completion_codes
1405 */
1406int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1407 size_t payload_length,
1408 uint8_t *completion_code);
1409
1410/** @brief Create a PLDM request message for GetStateSensorReadings
1411 *
1412 * @param[in] instance_id - Message's instance id
1413 * @param[in] sensor_id - used to identify and access the simple or composite
1414 * sensor
1415 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1416 * particular sensor within the state sensor, where bit [0] corresponds
1417 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1418 * to the eighth sensor (sensor offset 7), sequentially
1419 * @param[in] reserved - value: 0x00
1420 * @param[out] msg - Message will be written to this
1421 * @return pldm_completion_codes
1422 * @note Caller is responsible for memory alloc and dealloc of param
1423 * 'msg.payload'
1424 */
1425int encode_get_state_sensor_readings_req(uint8_t instance_id,
1426 uint16_t sensor_id,
1427 bitfield8_t sensor_rearm,
1428 uint8_t reserved,
1429 struct pldm_msg *msg);
1430
1431/** @brief Decode GetStateSensorReadings response data
1432 *
1433 * @param[in] msg - Request message
1434 * @param[in] payload_length - Length of response message payload
1435 * @param[out] completion_code - PLDM completion code
1436 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1437 * information that this command accesses
1438 * @param[out] field - Each stateField is an instance of a stateField structure
1439 * that is used to return the present operational state setting and the
1440 * present state and event state for a particular set of sensor
1441 * information contained within the state sensor
1442 * @return pldm_completion_codes
1443 */
1444
1445int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1446 size_t payload_length,
1447 uint8_t *completion_code,
1448 uint8_t *comp_sensor_count,
1449 get_sensor_state_field *field);
1450
1451/* PlatformEventMessage */
1452
1453/** @brief Decode PlatformEventMessage request data
1454 * @param[in] msg - Request message
1455 * @param[in] payload_length - Length of response message payload
1456 * @param[out] format_version - Version of the event format
1457 * @param[out] tid - Terminus ID for the terminus that originated the event
1458 * message
1459 * @param[out] event_class - The class of event being sent
1460 * @param[out] event_data_offset - Offset where the event data should be read
1461 * from pldm msg
1462 * @return pldm_completion_codes
1463 */
1464int decode_platform_event_message_req(const struct pldm_msg *msg,
1465 size_t payload_length,
1466 uint8_t *format_version, uint8_t *tid,
1467 uint8_t *event_class,
1468 size_t *event_data_offset);
1469
1470/** @brief Encode PlatformEventMessage response data
1471 * @param[in] instance_id - Message's instance id
1472 * @param[in] completion_code - PLDM completion code
1473 * @param[in] platform_event_status - Response status of the event message
1474 * command
1475 * @param[out] msg - Message will be written to this
1476 * @return pldm_completion_codes
1477 * @note Caller is responsible for memory alloc and dealloc of param
1478 * 'msg.payload'
1479 */
1480int encode_platform_event_message_resp(uint8_t instance_id,
1481 uint8_t completion_code,
1482 uint8_t platform_event_status,
1483 struct pldm_msg *msg);
1484
1485/** @brief Encode PlatformEventMessage request data
1486 * @param[in] instance_id - Message's instance id
1487 * @param[in] format_version - Version of the event format
1488 * @param[in] tid - Terminus ID for the terminus that originated the event
1489 * message
1490 * @param[in] event_class - The class of event being sent
1491 * @param[in] event_data - the event data should be read from pldm msg
1492 * @param[in] event_data_length - Length of the event data
1493 * @param[out] msg - Request message
1494 * @return pldm_completion_codes
1495 * @note Caller is responsible for memory alloc and dealloc of param
1496 * 'msg.payload'
1497 */
1498int encode_platform_event_message_req(
1499 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1500 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1501 struct pldm_msg *msg, size_t payload_length);
1502
1503/** @brief Decode PlatformEventMessage response data
1504 * @param[in] msg - Request message
1505 * @param[in] payload_length - Length of Response message payload
1506 * @param[out] completion_code - PLDM completion code
1507 * @param[out] platform_event_status - Response status of the event message
1508 * command
1509 * @return pldm_completion_codes
1510 */
1511int decode_platform_event_message_resp(const struct pldm_msg *msg,
1512 size_t payload_length,
1513 uint8_t *completion_code,
1514 uint8_t *platform_event_status);
1515
Dung Caod6ae8982022-11-02 10:00:10 +07001516/** @brief Decode EventMessageBufferSize response data
1517 * @param[in] msg - Request message
1518 * @param[in] payload_length - Length of Response message payload
1519 * @param[out] completion_code - PLDM completion code
1520 * @return pldm_completion_codes
1521 */
1522int decode_event_message_buffer_size_resp(const struct pldm_msg *msg,
1523 size_t payload_length,
1524 uint8_t *completion_code,
1525 uint16_t *terminus_max_buffer_size);
1526
1527/** @brief Encode EventMessageBufferSize request data
1528 * @param[in] instance_id - Message's instance id
1529 * @param[in] event_receiver_max_buffer_size - Max buffer size
1530 * @param[out] msg - Request message
1531 * @return pldm_completion_codes
1532 * @note Caller is responsible for memory alloc and dealloc of param
1533 * 'msg.payload'
1534 */
1535int encode_event_message_buffer_size_req(
1536 uint8_t instance_id, uint16_t event_receiver_max_buffer_size,
1537 struct pldm_msg *msg);
1538
Dung Cao1bf8c872022-11-29 05:32:58 +07001539/** @brief Encode EventMessageSupported request data
1540 *
1541 * @param[in] instance_id - Message's instance id
1542 * @param[in] format_version - Version of the event format
1543 * @param[out] msg - Request message
1544 *
1545 * @return pldm_completion_codes
1546 * @note Caller is responsible for memory alloc and dealloc of param
1547 * 'msg.payload'
1548 */
1549int encode_event_message_supported_req(uint8_t instance_id,
1550 uint8_t format_version,
1551 struct pldm_msg *msg);
1552
1553/** @brief Decode EventMessageSupported response data
1554 *
1555 * @param[in] msg - Request message
1556 * @param[in] payload_length - Length of Response message payload
1557 * @param[out] completion_code - PLDM completion code
1558 * @param[out] synchrony_config - the synchrony configuration
1559 * @param[out] synchrony_config_support - the synchrony configuration support
1560 * @param[out] number_event_class_returned - PLDM completion code
1561 * @param[out] event_class - the event classes
1562 * @param[in] event_class_count - the event class count
1563 *
1564 * @return pldm_completion_codes
1565 */
1566int decode_event_message_supported_resp(
1567 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1568 uint8_t *synchrony_config, bitfield8_t *synchrony_config_support,
1569 uint8_t *number_event_class_returned, uint8_t *event_class,
1570 uint8_t event_class_count);
1571
Andrew Jeffery9c766792022-08-10 23:12:49 +09301572/** @brief Decode sensorEventData response data
1573 *
1574 * @param[in] event_data - event data from the response message
1575 * @param[in] event_data_length - length of the event data
1576 * @param[out] sensor_id - sensorID value of the sensor
1577 * @param[out] sensor_event_class_type - Type of sensor event class
1578 * @param[out] event_class_data_offset - Offset where the event class data
1579 * should be read from event data
1580 * @return pldm_completion_codes
1581 * @note Caller is responsible for memory alloc and dealloc of param
1582 * 'event_data'
1583 */
1584int decode_sensor_event_data(const uint8_t *event_data,
1585 size_t event_data_length, uint16_t *sensor_id,
1586 uint8_t *sensor_event_class_type,
1587 size_t *event_class_data_offset);
1588
1589/** @brief Decode sensorOpState response data
1590 *
1591 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1592 * @param[in] sensor_data_length - Length of sensor_data
1593 * @param[out] present_op_state - The sensorOperationalState value from the
1594 * state change that triggered the event message
1595 * @param[out] previous_op_state - The sensorOperationalState value for the
1596 * state from which the present state was entered
1597 * @return pldm_completion_codes
1598 * @note Caller is responsible for memory alloc and dealloc of param
1599 * 'sensor_data'
1600 */
1601int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1602 uint8_t *present_op_state,
1603 uint8_t *previous_op_state);
1604
1605/** @brief Decode stateSensorState response data
1606 *
1607 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1608 * @param[in] sensor_data_length - Length of sensor_data
1609 * @param[out] sensor_offset - Identifies which state sensor within a composite
1610 * state sensor the event is being returned for
1611 * @param[out] event_state - The event state value from the state change that
1612 * triggered the event message
1613 * @param[out] previous_event_state - The event state value for the state from
1614 * which the present event state was entered
1615 * @return pldm_completion_codes
1616 * @note Caller is responsible for memory alloc and dealloc of param
1617 * 'sensor_data'
1618 */
1619int decode_state_sensor_data(const uint8_t *sensor_data,
1620 size_t sensor_data_length, uint8_t *sensor_offset,
1621 uint8_t *event_state,
1622 uint8_t *previous_event_state);
1623
1624/** @brief Decode numericSensorState response data
1625 *
1626 * @param[in] sensor_data - sensor_data for sensorEventClass =
1627 * numericSensorState
1628 * @param[in] sensor_data_length - Length of sensor_data
1629 * @param[out] event_state - The eventState value from the state change that
1630 * triggered the event message
1631 * @param[out] previous_event_state - The eventState value for the state from
1632 * which the present state was entered
1633 * @param[out] sensor_data_size - The bit width and format of reading and
1634 * threshold values that the sensor returns
1635 * @param[out] present_reading - The present value indicated by the sensor
1636 * @return pldm_completion_codes
1637 * @note Caller is responsible for memory alloc and dealloc of param
1638 * 'sensor_data'
1639 */
1640int decode_numeric_sensor_data(const uint8_t *sensor_data,
1641 size_t sensor_data_length, uint8_t *event_state,
1642 uint8_t *previous_event_state,
1643 uint8_t *sensor_data_size,
1644 uint32_t *present_reading);
1645
1646/* GetNumericEffecterValue */
1647
1648/** @brief Create a PLDM request message for GetNumericEffecterValue
1649 *
1650 * @param[in] instance_id - Message's instance id
1651 * @param[in] effecter_id - used to identify and access the effecter
1652 * @param[out] msg - Message will be written to this
1653 * @return pldm_completion_codes
1654 * @note Caller is responsible for memory alloc and dealloc of param
1655 * 'msg.payload'
1656 */
1657int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1658 uint16_t effecter_id,
1659 struct pldm_msg *msg);
1660
1661/** @brief Create a PLDM response message for GetNumericEffecterValue
1662 *
1663 * @param[in] msg - Request message
1664 * @param[in] payload_length - Length of request message payload
1665 * @param[out] completion_code - PLDM completion code
1666 * @param[out] effecter_data_size - The bit width and format of the setting
1667 * value for the effecter.
1668 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1669 * @param[out] effecter_oper_state - The state of the effecter itself
1670 * @param[out] pending_value - The pending numeric value setting of the
1671 * effecter. The effecterDataSize field indicates the number of
1672 * bits used for this field
1673 * @param[out] present_value - The present numeric value setting of the
1674 * effecter. The effecterDataSize indicates the number of bits
1675 * used for this field
1676 * @return pldm_completion_codes
1677 */
1678int decode_get_numeric_effecter_value_resp(
1679 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1680 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1681 uint8_t *pending_value, uint8_t *present_value);
1682
1683/** @brief Decode pldmPDRRepositoryChgEvent response data
1684 *
1685 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1686 * @param[in] event_data_size - Length of event_data
1687 * @param[out] event_data_format - This field indicates if the changedRecords
1688 * are of PDR Types or PDR Record Handles
1689 * @param[out] number_of_change_records - The number of changeRecords following
1690 * this field
1691 * @param[out] change_record_data_offset - Identifies where changeRecord data
1692 * is located within event_data
1693 * @return pldm_completion_codes
1694 * @note Caller is responsible for memory alloc and dealloc of param
1695 * 'event_data'
1696 */
1697int decode_pldm_pdr_repository_chg_event_data(
1698 const uint8_t *event_data, size_t event_data_size,
1699 uint8_t *event_data_format, uint8_t *number_of_change_records,
1700 size_t *change_record_data_offset);
1701
1702/** @brief Encode PLDM PDR Repository Change eventData
1703 * @param[in] event_data_format - Format of this event data (e.g.
1704 * FORMAT_IS_PDR_HANDLES)
1705 * @param[in] number_of_change_records - Number of changeRecords in this
1706 * eventData
1707 * @param[in] event_data_operations - Array of eventDataOperations
1708 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1709 * should contain number_of_change_records elements.
1710 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1711 * for each changeRecord in this eventData. This array should contain
1712 * number_of_change_records elements.
1713 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1714 * one array per changeRecord in this eventData. The toplevel array should
1715 * contain number_of_change_records elements. Each subarray [i] should
1716 * contain numbers_of_change_entries[i] elements.
1717 * @param[in] event_data - The eventData will be encoded into this. This entire
1718 * structure must be max_change_records_size long. It must be large enough
1719 * to accomodate the data to be encoded. The caller is responsible for
1720 * allocating and deallocating it, including the variable-size
1721 * 'event_data.change_records' field. If this parameter is NULL,
1722 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1723 * to reflect the required size of the structure.
1724 * @param[out] actual_change_records_size - The actual number of meaningful
1725 * encoded bytes in event_data. The caller can over-allocate memory and use
1726 * this output to determine the real size of the structure.
1727 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1728 * encoded message would be larger than this value, an error is returned.
1729 * @return pldm_completion_codes
1730 * @note Caller is responsible for memory alloc and dealloc of param
1731 * 'event_data.change_records'
1732 */
1733int encode_pldm_pdr_repository_chg_event_data(
1734 uint8_t event_data_format, uint8_t number_of_change_records,
1735 const uint8_t *event_data_operations,
1736 const uint8_t *numbers_of_change_entries,
1737 const uint32_t *const *change_entries,
1738 struct pldm_pdr_repository_chg_event_data *event_data,
1739 size_t *actual_change_records_size, size_t max_change_records_size);
1740
1741/** @brief Encode event data for a PLDM Sensor Event
1742 *
1743 * @param[out] event_data The object to store the encoded event in
1744 * @param[in] event_data_size Size of the allocation for event_data
1745 * @param[in] sensor_id Sensor ID
1746 * @param[in] sensor_event_class Sensor event class
1747 * @param[in] sensor_offset Offset
1748 * @param[in] event_state Event state
1749 * @param[in] previous_event_state Previous event state
1750 * @param[out] actual_event_data_size The real size in bytes of the event_data
1751 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1752 * @note If event_data is NULL, then *actual_event_data_size will be set to
1753 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1754 * @note The caller is responsible for allocating and deallocating the
1755 * event_data
1756 */
1757int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1758 size_t event_data_size, uint16_t sensor_id,
1759 enum sensor_event_class_states sensor_event_class,
1760 uint8_t sensor_offset, uint8_t event_state,
1761 uint8_t previous_event_state,
1762 size_t *actual_event_data_size);
1763
1764/** @brief Decode PldmPDRRepositoryChangeRecord response data
1765 *
1766 * @param[in] change_record_data - changeRecordData for
1767 * pldmPDRRepositoryChgEvent
1768 * @param[in] change_record_data_size - Length of change_record_data
1769 * @param[out] event_data_operation - This field indicates the changeEntries
1770 * operation types
1771 * @param[out] number_of_change_entries - The number of changeEntries following
1772 * this field
1773 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1774 * is located within change_record_data
1775 * @return pldm_completion_codes
1776 * @note Caller is responsible for memory alloc and dealloc of param
1777 * 'change_record_data'
1778 */
1779int decode_pldm_pdr_repository_change_record_data(
1780 const uint8_t *change_record_data, size_t change_record_data_size,
1781 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1782 size_t *change_entry_data_offset);
1783
1784/* GetSensorReading */
1785
1786/** @brief Encode GetSensorReading request data
1787 *
1788 * @param[in] instance_id - Message's instance id
1789 * @param[in] sensor_id - A handle that is used to identify and access the
1790 * sensor
1791 * @param[in] rearm_event_state - true = manually re-arm EventState after
1792 * responding to this request, false = no manual re-arm
1793 * @param[out] msg - Message will be written to this
1794 * @return pldm_completion_codes
1795 * @note Caller is responsible for memory alloc and dealloc of param
1796 * 'msg.payload'
1797 */
1798int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1799 bool8_t rearm_event_state,
1800 struct pldm_msg *msg);
1801
1802/** @brief Decode GetSensorReading response data
1803 *
1804 * @param[in] msg - Request message
1805 * @param[in] payload_length - Length of response message payload
1806 * @param[out] completion_code - PLDM completion code
1807 * @param[out] sensor_data_size - The bit width and format of reading and
1808 * threshold values
1809 * @param[out] sensor_operational_state - The state of the sensor itself
1810 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1811 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1812 * stateEventsOnlyEnabled }
1813 * @param[out] present_state - The most recently assessed state value monitored
1814 * by the sensor
1815 * @param[out] previous_state - The state that the presentState was entered
1816 * from
1817 * @param[out] event_state - Indicates which threshold crossing assertion
1818 * events have been detected
1819 * @param[out] present_reading - The present value indicated by the sensor
1820 * @return pldm_completion_codes
1821 */
1822
1823int decode_get_sensor_reading_resp(
1824 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1825 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1826 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1827 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1828
1829/** @brief Encode the SetEventReceiver request message
1830 *
1831 * @param[in] instance_id - Message's instance id
1832 * @param[in] event_message_global_enable - This value is used to enable or
1833 * disable event message generation from the terminus value: {
1834 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1835 * @param[in] transport_protocol_type - This value is provided in the request
1836 * to help the responder verify that the content of the
1837 * eventReceiverAddressInfo field used in this request is correct for
1838 * the messaging protocol supported by the terminus.
1839 * @param[in] event_receiver_address_info - this value is a medium and
1840 * protocol-specific address that the responder should use when
1841 * transmitting event messages using the indicated protocol
1842 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing
1843 * of which the terminus shall emit a heartbeat event to the receiver
1844 * @param[out] msg - Argument to capture the Message
1845 * @return pldm_completion_codes
1846 */
1847int encode_set_event_receiver_req(uint8_t instance_id,
1848 uint8_t event_message_global_enable,
1849 uint8_t transport_protocol_type,
1850 uint8_t event_receiver_address_info,
1851 uint16_t heartbeat_timer,
1852 struct pldm_msg *msg);
1853
1854/** @brief Decode the SetEventReceiver response message
1855 *
1856 * @param[in] msg - Request message
1857 * @param[in] payload_length - Length of response message payload
1858 * @param[out] completion_code - PLDM completion code
1859 * @return pldm_completion_codes
1860 */
1861int decode_set_event_receiver_resp(const struct pldm_msg *msg,
1862 size_t payload_length,
1863 uint8_t *completion_code);
1864
1865/** @brief Decode the SetEventReceiver request message
1866 *
1867 * @param[in] msg - Request message
1868 * @param[in] payload_length - Length of request message payload
1869 * @param[out] event_message_global_enable - This value is used to enable or
1870 * disable event message generation from the terminus value: {
1871 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1872 * @param[out] transport_protocol_type - This value is provided in the request
1873 * to help the responder verify that the content of the
1874 * eventReceiverAddressInfo field used in this request is correct for
1875 * the messaging protocol supported by the terminus.
1876 * @param[out] event_receiver_address_info - This value is a medium and
1877 * protocol-specific address that the responder should use when
1878 * transmitting event messages using the indicated protocol
1879 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing
1880 * of which the terminus shall emit a heartbeat event to the receiver
1881 * @return pldm_completion_codes
1882 */
1883int decode_set_event_receiver_req(const struct pldm_msg *msg,
1884 size_t payload_length,
1885 uint8_t *event_message_global_enable,
1886 uint8_t *transport_protocol_type,
1887 uint8_t *event_receiver_address_info,
1888 uint16_t *heartbeat_timer);
1889
1890/** @brief Encode the SetEventReceiver response message
1891 *
1892 * @param[in] instance_id - Message's instance id
1893 * @param[in] completion_code - PLDM completion code
1894 * @param[out] msg - Argument to capture the Message
1895 * @return pldm_completion_codes
1896 */
1897int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code,
1898 struct pldm_msg *msg);
1899
1900#ifdef __cplusplus
1901}
1902#endif
1903
1904#endif /* PLATFORM_H */