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