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