1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 #ifndef PLATFORM_H 3 #define PLATFORM_H 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 #include <assert.h> 10 #include <stdalign.h> 11 #include <stddef.h> 12 #include <stdint.h> 13 #include <uchar.h> 14 15 #include <libpldm/base.h> 16 #include <libpldm/compiler.h> 17 #include <libpldm/pdr.h> 18 #include <libpldm/pldm_types.h> 19 20 /** 21 * @brief PLDM response transfer flag for the Platform and control commands 22 * (GetPDRs, PollForPlatformEventMessage) 23 */ 24 enum pldm_platform_transfer_flag { 25 PLDM_PLATFORM_TRANSFER_START = 0x00, 26 PLDM_PLATFORM_TRANSFER_MIDDLE = 0x01, 27 PLDM_PLATFORM_TRANSFER_END = 0x04, 28 PLDM_PLATFORM_TRANSFER_START_AND_END = 0x05, 29 }; 30 31 /* Maximum size for request */ 32 #define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19 33 #define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4 34 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2 35 #define PLDM_GET_STATE_EFFECTER_STATES_REQ_BYTES 2 36 #define PLDM_GET_SENSOR_READING_REQ_BYTES 3 37 #define PLDM_SET_EVENT_RECEIVER_REQ_BYTES 5 38 39 /* Minimum size for request */ 40 #define PLDM_SET_EVENT_RECEIVER_MIN_REQ_BYTES 3 41 42 /* Response lengths are inclusive of completion code */ 43 #define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1 44 45 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1 46 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4 47 48 #define PLDM_GET_PDR_REQ_BYTES 13 49 50 #define PLDM_SET_EVENT_RECEIVER_RESP_BYTES 1 51 52 /* Platform event supported request */ 53 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_REQ_BYTES 2 54 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES 3 55 56 #define PLDM_EVENT_MESSAGE_SUPPORTED_REQ_BYTES 1 57 #define PLDM_EVENT_MESSAGE_SUPPORTED_MIN_RESP_BYTES 4 58 59 /* PollForPlatformEventMessage PLDM request */ 60 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_REQ_BYTES 8 61 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES 4 62 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_RESP_BYTES 14 63 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_CHECKSUM_BYTES 4 64 65 /* Platform event message request */ 66 #define PLDM_PLATFORM_EVENT_ID_NULL 0x0000 67 #define PLDM_PLATFORM_EVENT_ID_FRAGMENT 0xffff 68 /* Platform event message response */ 69 #define PLDM_PLATFORM_EVENT_ID_NONE 0x0000 70 #define PLDM_PLATFORM_EVENT_ID_ACK 0xffff 71 72 /* Minimum response length */ 73 #define PLDM_GET_PDR_MIN_RESP_BYTES 12 74 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5 75 #define PLDM_GET_STATE_EFFECTER_STATES_MIN_RESP_BYTES 2 76 #define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8 77 #define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES 2 78 #define PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES 41 79 80 /* Minimum length for PLDM PlatformEventMessage request */ 81 #define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3 82 #define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6 83 #define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2 84 #define PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION 1 85 #define PLDM_PLATFORM_EVENT_MESSAGE_EVENT_ID 2 86 #define PLDM_PLATFORM_EVENT_MESSAGE_TRANFER_HANDLE 4 87 88 /* Minimum length of sensor event data */ 89 #define PLDM_MSG_POLL_EVENT_LENGTH 7 90 /* Minimum data length of CPER event type */ 91 #define PLDM_PLATFORM_CPER_EVENT_MIN_LENGTH 4 92 93 /* Minimum length of sensor event data */ 94 #define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5 95 #define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2 96 #define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3 97 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4 98 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7 99 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4 100 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5 101 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7 102 103 /* Minimum length of data for pldmPDRRepositoryChgEvent */ 104 #define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2 105 #define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2 106 107 /* Minimum length of numeric sensor PDR */ 108 #define PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH 57 109 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH 3 110 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH 9 111 #define PLDM_PDR_NUMERIC_SENSOR_PDR_MIN_LENGTH \ 112 (PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH + \ 113 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH + \ 114 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH) 115 116 /* Minimum length of numeric effecter PDR */ 117 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH 56 118 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH 2 119 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH 5 120 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_MIN_LENGTH \ 121 (PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH + \ 122 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH + \ 123 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH) 124 125 /** 126 * Minimum length of entity auxiliary name effecter PDR includes size of hdr, 127 * entityType, entityInstanceNumber, entityContainerID, sharedNameCount and 128 * nameStringCount in `Table 95 - Entity Auxiliary Names PDR format` of DSP0248 129 * v1.2.2 130 */ 131 #define PLDM_PDR_ENTITY_AUXILIARY_NAME_PDR_MIN_LENGTH 8 132 133 #define PLDM_INVALID_EFFECTER_ID 0xffff 134 135 /* DSP0248 Table1 PLDM monitoring and control data types */ 136 #define PLDM_STR_UTF_8_MAX_LEN 256 137 #define PLDM_STR_UTF_16_MAX_LEN 256 138 139 /* Wire-format substructure sizes */ 140 #define PLDM_GET_EFFECTER_STATE_FIELD_SIZE 3 141 142 /* State fields count bounds */ 143 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MIN 1 144 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX 8 145 146 /* Container ID */ 147 /** @brief Table 2 - Parts of the Entity Identification Information format in 148 * PLDM Platform and Control spec, DSP0248 v1.2.2. "If this value is 149 * 0x0000, the containing entity is considered to be the overall system" 150 */ 151 #define PLDM_PLATFORM_ENTITY_SYSTEM_CONTAINER_ID 0 152 153 enum pldm_effecter_data_size { 154 PLDM_EFFECTER_DATA_SIZE_UINT8, 155 PLDM_EFFECTER_DATA_SIZE_SINT8, 156 PLDM_EFFECTER_DATA_SIZE_UINT16, 157 PLDM_EFFECTER_DATA_SIZE_SINT16, 158 PLDM_EFFECTER_DATA_SIZE_UINT32, 159 PLDM_EFFECTER_DATA_SIZE_SINT32 160 }; 161 162 enum pldm_range_field_format { 163 PLDM_RANGE_FIELD_FORMAT_UINT8, 164 PLDM_RANGE_FIELD_FORMAT_SINT8, 165 PLDM_RANGE_FIELD_FORMAT_UINT16, 166 PLDM_RANGE_FIELD_FORMAT_SINT16, 167 PLDM_RANGE_FIELD_FORMAT_UINT32, 168 PLDM_RANGE_FIELD_FORMAT_SINT32, 169 PLDM_RANGE_FIELD_FORMAT_REAL32 170 }; 171 #define PLDM_RANGE_FIELD_FORMAT_MAX PLDM_RANGE_FIELD_FORMAT_REAL32 172 173 enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 }; 174 175 enum effecter_state { PLDM_INVALID_VALUE = 0xff }; 176 177 enum pldm_sensor_present_state { 178 PLDM_SENSOR_UNKNOWN = 0x0, 179 PLDM_SENSOR_NORMAL = 0x01, 180 PLDM_SENSOR_WARNING = 0x02, 181 PLDM_SENSOR_CRITICAL = 0x03, 182 PLDM_SENSOR_FATAL = 0x04, 183 PLDM_SENSOR_LOWERWARNING = 0x05, 184 PLDM_SENSOR_LOWERCRITICAL = 0x06, 185 PLDM_SENSOR_LOWERFATAL = 0x07, 186 PLDM_SENSOR_UPPERWARNING = 0x08, 187 PLDM_SENSOR_UPPERCRITICAL = 0x09, 188 PLDM_SENSOR_UPPERFATAL = 0x0a 189 }; 190 191 enum pldm_sensor_event_message_enable { 192 PLDM_NO_EVENT_GENERATION, 193 PLDM_EVENTS_DISABLED, 194 PLDM_EVENTS_ENABLED, 195 PLDM_OP_EVENTS_ONLY_ENABLED, 196 PLDM_STATE_EVENTS_ONLY_ENABLED 197 }; 198 199 enum pldm_effecter_oper_state { 200 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING, 201 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING, 202 EFFECTER_OPER_STATE_DISABLED, 203 EFFECTER_OPER_STATE_UNAVAILABLE, 204 EFFECTER_OPER_STATE_STATUSUNKNOWN, 205 EFFECTER_OPER_STATE_FAILED, 206 EFFECTER_OPER_STATE_INITIALIZING, 207 EFFECTER_OPER_STATE_SHUTTINGDOWN, 208 EFFECTER_OPER_STATE_INTEST 209 }; 210 211 enum pldm_platform_commands { 212 PLDM_SET_EVENT_RECEIVER = 0x04, 213 PLDM_PLATFORM_EVENT_MESSAGE = 0x0a, 214 PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE = 0x0b, 215 PLDM_EVENT_MESSAGE_SUPPORTED = 0x0c, 216 PLDM_EVENT_MESSAGE_BUFFER_SIZE = 0x0d, 217 PLDM_GET_SENSOR_READING = 0x11, 218 PLDM_GET_STATE_SENSOR_READINGS = 0x21, 219 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31, 220 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32, 221 PLDM_SET_STATE_EFFECTER_STATES = 0x39, 222 PLDM_GET_STATE_EFFECTER_STATES = 0x3a, 223 PLDM_GET_PDR_REPOSITORY_INFO = 0x50, 224 PLDM_GET_PDR = 0x51, 225 }; 226 227 /** @brief PLDM PDR types defined in DSP0248_1.2.0 section 28.2 228 */ 229 enum pldm_pdr_types { 230 PLDM_TERMINUS_LOCATOR_PDR = 1, 231 PLDM_NUMERIC_SENSOR_PDR = 2, 232 PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3, 233 PLDM_STATE_SENSOR_PDR = 4, 234 PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5, 235 PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6, 236 PLDM_OEM_UNIT_PDR = 7, 237 PLDM_OEM_STATE_SET_PDR = 8, 238 PLDM_NUMERIC_EFFECTER_PDR = 9, 239 PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10, 240 PLDM_STATE_EFFECTER_PDR = 11, 241 PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12, 242 PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13, 243 PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14, 244 PLDM_PDR_ENTITY_ASSOCIATION = 15, 245 PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16, 246 PLDM_OEM_ENTITY_ID_PDR = 17, 247 PLDM_INTERRUPT_ASSOCIATION_PDR = 18, 248 PLDM_EVENT_LOG_PDR = 19, 249 PLDM_PDR_FRU_RECORD_SET = 20, 250 PLDM_COMPACT_NUMERIC_SENSOR_PDR = 21, 251 PLDM_REDFISH_RESOURCE_PDR = 22, 252 PLDM_REDFISH_ENTITY_ASSOCIATION_PDR = 23, 253 PLDM_REDFISH_ACTION_PDR = 24, 254 PLDM_OEM_DEVICE_PDR = 126, 255 PLDM_OEM_PDR = 127, 256 }; 257 258 /** @brief PLDM effecter initialization schemes 259 */ 260 enum pldm_effecter_init { 261 PLDM_NO_INIT, 262 PLDM_USE_INIT_PDR, 263 PLDM_ENABLE_EFFECTER, 264 PLDM_DISABLE_EFECTER 265 }; 266 267 /** @brief PLDM Platform M&C completion codes 268 */ 269 enum pldm_platform_completion_codes { 270 PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80, 271 PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81, 272 273 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80, 274 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81, 275 276 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80, 277 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81, 278 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82, 279 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83, 280 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84, 281 282 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82, 283 284 PLDM_PLATFORM_INVALID_PROTOCOL_TYPE = 0x80, 285 PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED = 0x81, 286 PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH = 0x82, 287 }; 288 289 /** @brief PLDM Event types 290 */ 291 enum pldm_event_types { 292 PLDM_SENSOR_EVENT = 0x00, 293 PLDM_EFFECTER_EVENT = 0x01, 294 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02, 295 PLDM_REDFISH_MESSAGE_EVENT = 0x03, 296 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04, 297 PLDM_MESSAGE_POLL_EVENT = 0x05, 298 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06, 299 PLDM_CPER_EVENT = 0x07 300 }; 301 302 /** @brief PLDM sensorEventClass states 303 */ 304 enum sensor_event_class_states { 305 PLDM_SENSOR_OP_STATE, 306 PLDM_STATE_SENSOR_STATE, 307 PLDM_NUMERIC_SENSOR_STATE 308 }; 309 310 /** @brief PLDM sensor supported states 311 */ 312 enum pldm_sensor_operational_state { 313 PLDM_SENSOR_ENABLED, 314 PLDM_SENSOR_DISABLED, 315 PLDM_SENSOR_UNAVAILABLE, 316 PLDM_SENSOR_STATUSUNKOWN, 317 PLDM_SENSOR_FAILED, 318 PLDM_SENSOR_INITIALIZING, 319 PLDM_SENSOR_SHUTTINGDOWN, 320 PLDM_SENSOR_INTEST 321 }; 322 323 /** @brief PLDM pldmPDRRepositoryChgEvent class eventData format 324 */ 325 enum pldm_pdr_repository_chg_event_data_format { 326 REFRESH_ENTIRE_REPOSITORY, 327 FORMAT_IS_PDR_TYPES, 328 FORMAT_IS_PDR_HANDLES 329 }; 330 331 /** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format 332 * eventDataOperation. See CHANGELOG.md for info on the alias members. 333 */ 334 enum pldm_pdr_repository_chg_event_change_record_event_data_operation { 335 PLDM_REFRESH_ALL_RECORDS = 0, 336 PLDM_RECORDS_DELETED = 1, 337 PLDM_RECORDS_ADDED = 2, 338 PLDM_RECORDS_MODIFIED = 3, 339 340 PLDM_PDR_RECORDS_REFRESH_ALL = 0, 341 PLDM_PDR_RECORDS_DELETED = 1, 342 PLDM_PDR_RECORDS_ADDED = 2, 343 PLDM_PDR_RECORDS_MODIFIED = 3 344 }; 345 346 /** @brief PLDM NumericSensorStatePresentReading data type 347 */ 348 enum pldm_sensor_readings_data_type { 349 PLDM_SENSOR_DATA_SIZE_UINT8, 350 PLDM_SENSOR_DATA_SIZE_SINT8, 351 PLDM_SENSOR_DATA_SIZE_UINT16, 352 PLDM_SENSOR_DATA_SIZE_SINT16, 353 PLDM_SENSOR_DATA_SIZE_UINT32, 354 PLDM_SENSOR_DATA_SIZE_SINT32 355 }; 356 #define PLDM_SENSOR_DATA_SIZE_MAX PLDM_SENSOR_DATA_SIZE_SINT32 357 358 /** @brief PLDM PlatformEventMessage response status 359 */ 360 enum pldm_platform_event_status { 361 PLDM_EVENT_NO_LOGGING = 0x00, 362 PLDM_EVENT_LOGGING_DISABLED = 0x01, 363 PLDM_EVENT_LOG_FULL = 0x02, 364 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03, 365 PLDM_EVENT_LOGGED = 0x04, 366 PLDM_EVENT_LOGGING_REJECTED = 0x05 367 }; 368 369 /** @brief PLDM Terminus Locator PDR validity 370 */ 371 enum pldm_terminus_locator_pdr_validity { 372 PLDM_TL_PDR_NOT_VALID, 373 PLDM_TL_PDR_VALID 374 }; 375 376 /** @brief PLDM Terminus Locator type 377 */ 378 enum pldm_terminus_locator_type { 379 PLDM_TERMINUS_LOCATOR_TYPE_UID, 380 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID, 381 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE, 382 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW 383 }; 384 385 /** @brief PLDM event message global enable for 386 * SetEventReceiver command 387 */ 388 enum pldm_event_message_global_enable { 389 PLDM_EVENT_MESSAGE_GLOBAL_DISABLE, 390 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC, 391 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_POLLING, 392 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE 393 }; 394 395 /** @brief PLDM DSP0248 1.2.1 table 74 sensorUnits enumeration 396 */ 397 enum pldm_sensor_units { 398 PLDM_SENSOR_UNIT_NONE = 0x00, 399 PLDM_SENSOR_UNIT_UNSPECIFIED, 400 PLDM_SENSOR_UNIT_DEGRESS_C, 401 PLDM_SENSOR_UNIT_DEGRESS_F, 402 PLDM_SENSOR_UNIT_KELVINS, 403 PLDM_SENSOR_UNIT_VOLTS, 404 PLDM_SENSOR_UNIT_AMPS, 405 PLDM_SENSOR_UNIT_WATTS, 406 PLDM_SENSOR_UNIT_JOULES, 407 PLDM_SENSOR_UNIT_COULOMBS, 408 PLDM_SENSOR_UNIT_VA, 409 PLDM_SENSOR_UNIT_NITS, 410 PLDM_SENSOR_UNIT_LUMENS, 411 PLDM_SENSOR_UNIT_LUX, 412 PLDM_SENSOR_UNIT_CANDELAS, 413 PLDM_SENSOR_UNIT_KPA, 414 PLDM_SENSOR_UNIT_PSI, 415 PLDM_SENSOR_UNIT_NEWTONS, 416 PLDM_SENSOR_UNIT_CFM, 417 PLDM_SENSOR_UNIT_RPM, 418 PLDM_SENSOR_UNIT_HERTZ, 419 PLDM_SENSOR_UNIT_SECONDS, 420 PLDM_SENSOR_UNIT_MINUTES, 421 PLDM_SENSOR_UNIT_HOURS, 422 PLDM_SENSOR_UNIT_DAYS, 423 PLDM_SENSOR_UNIT_WEEKS, 424 PLDM_SENSOR_UNIT_MILS, 425 PLDM_SENSOR_UNIT_INCHES, 426 PLDM_SENSOR_UNIT_FEET, 427 PLDM_SENSOR_UNIT_CUBIC_INCHES, 428 PLDM_SENSOR_UNIT_CUBIC_FEET, 429 PLDM_SENSOR_UNIT_METERS, 430 PLDM_SENSOR_UNIT_CUBIC_CENTERMETERS, 431 PLDM_SENSOR_UNIT_CUBIC_METERS, 432 PLDM_SENSOR_UNIT_LITERS, 433 PLDM_SENSOR_UNIT_FLUID_OUNCES, 434 PLDM_SENSOR_UNIT_RADIANS, 435 PLDM_SENSOR_UNIT_STERADIANS, 436 PLDM_SENSOR_UNIT_REVOLUTIONS, 437 PLDM_SENSOR_UNIT_CYCLES, 438 PLDM_SENSOR_UNIT_GRAVITIES, 439 PLDM_SENSOR_UNIT_OUNCES, 440 PLDM_SENSOR_UNIT_POUNDS, 441 PLDM_SENSOR_UNIT_FOOT_POUNDS, 442 PLDM_SENSOR_UNIT_OUNCE_INCHES, 443 PLDM_SENSOR_UNIT_GUESS, 444 PLDM_SENSOR_UNIT_GILBERTS, 445 PLDM_SENSOR_UNIT_HENRIES, 446 PLDM_SENSOR_UNIT_FARADS, 447 PLDM_SENSOR_UNIT_OHMS, 448 PLDM_SENSOR_UNIT_SIEMENS, 449 PLDM_SENSOR_UNIT_MOLES, 450 PLDM_SENSOR_UNIT_BECQUERELS, 451 PLDM_SENSOR_UNIT_PPM, 452 PLDM_SENSOR_UNIT_DECIBELS, 453 PLDM_SENSOR_UNIT_DBA, 454 PLDM_SENSOR_UNIT_DBC, 455 PLDM_SENSOR_UNIT_GRAYS, 456 PLDM_SENSOR_UNIT_SIEVERTS, 457 PLDM_SENSOR_UNIT_COLOR_TEMPERATURE_DEGRESS_K, 458 PLDM_SENSOR_UNIT_BITS, 459 PLDM_SENSOR_UNIT_BYTES, 460 PLDM_SENSOR_UNIT_WORDS, 461 PLDM_SENSOR_UNIT_DOUBLE_WORDS, 462 PLDM_SENSOR_UNIT_QUAD_WORDS, 463 PLDM_SENSOR_UNIT_PERCENTAGE, 464 PLDM_SENSOR_UNIT_PASCALS, 465 PLDM_SENSOR_UNIT_COUNTS, 466 PLDM_SENSOR_UNIT_GRAMS, 467 PLDM_SENSOR_UNIT_NEWTON_METERS, 468 PLDM_SENSOR_UNIT_HITS, 469 PLDM_SENSOR_UNIT_MISSES, 470 PLDM_SENSOR_UNIT_RETRIES, 471 PLDM_SENSOR_UNIT_OVERRUNS_OVERFLOWS, 472 PLDM_SENSOR_UNIT_UNDERRUNS, 473 PLDM_SENSOR_UNIT_COLLISIONS, 474 PLDM_SENSOR_UNIT_PACKETS, 475 PLDM_SENSOR_UNIT_MESSAGES, 476 PLDM_SENSOR_UNIT_CHARATERS, 477 PLDM_SENSOR_UNIT_ERRORS, 478 PLDM_SENSOR_UNIT_CORRECTED_ERRORS, 479 PLDM_SENSOR_UNIT_UNCORRECTABLE_ERRORS, 480 PLDM_SENSOR_UNIT_SQUARE_MILS, 481 PLDM_SENSOR_UNIT_SQUARE_INCHES, 482 PLDM_SENSOR_UNIT_SQUARE_FEET, 483 PLDM_SENSOR_UNIT_SQUARE_CENTIMETERS, 484 PLDM_SENSOR_UNIT_SQUARE_METERS, 485 PLDM_SENSOR_UNIT_OEMUNIT = 255 486 }; 487 488 enum pldm_occurrence_rate { 489 PLDM_RATE_UNIT_NONE = 0x0, 490 PLDM_RATE_UNIT_PER_MICRO_SECOND, 491 PLDM_RATE_UNIT_PER_MILLI_SECOND, 492 PLDM_RATE_UNIT_PER_SECOND, 493 PLDM_RATE_UNIT_PER_MINUTE, 494 PLDM_RATE_UNIT_PER_HOUR, 495 PLDM_RATE_UNIT_PER_DAY, 496 PLDM_RATE_UNIT_PER_WEEK, 497 PLDM_RATE_UNIT_PER_MONTH, 498 PLDM_RATE_UNIT_PER_YEAR 499 }; 500 501 /** @brief PLDM repository state */ 502 enum pldm_repository_state { 503 PLDM_AVAILABLE, 504 PLDM_UPDATE_IN_PROGRESS, 505 PLDM_FAILED 506 }; 507 508 /** @brief PLDM repository data transfer handler timeout */ 509 enum pldm_repository_data_transfer_handler_timeout { 510 PLDM_NO_TIMEOUT, 511 PLDM_DEFALUT_MINIMUM_TIMEOUT 512 }; 513 514 /** @brief PLDM event message type */ 515 enum pldm_event_message_type { 516 PLDM_MESSAGE_TYPE_NOT_CONFIGURED = 0x00, 517 PLDM_MESSAGE_TYPE_ASYNCHRONOUS = 0x01, 518 PLDM_MESSAGE_TYPE_SYNCHRONOUS = 0x02, 519 PLDM_MESSAGE_TYPE_ASYNCHRONOUS_WITH_HEARTBEAT = 0x03 520 }; 521 522 /** @struct pldm_pdr_hdr 523 * 524 * Structure representing PLDM common PDR header 525 */ 526 struct pldm_pdr_hdr { 527 uint32_t record_handle; 528 uint8_t version; 529 uint8_t type; 530 uint16_t record_change_num; 531 uint16_t length; 532 } __attribute__((packed)); 533 534 /** @struct pldm_terminus_locator_pdr 535 * 536 * Structure representing PLDM terminus locator PDR 537 */ 538 struct pldm_terminus_locator_pdr { 539 struct pldm_pdr_hdr hdr; 540 uint16_t terminus_handle; 541 uint8_t validity; 542 uint8_t tid; 543 uint16_t container_id; 544 uint8_t terminus_locator_type; 545 uint8_t terminus_locator_value_size; 546 uint8_t terminus_locator_value[1]; 547 } __attribute__((packed)); 548 549 /** @struct pldm_sensor_auxiliary_names_pdr 550 * 551 * Structure representing PLDM Sensor Auxiliary Names PDR 552 */ 553 struct pldm_sensor_auxiliary_names_pdr { 554 struct pldm_pdr_hdr hdr; 555 uint16_t terminus_handle; 556 uint16_t sensor_id; 557 uint8_t sensor_count; 558 uint8_t names[1]; 559 } __attribute__((packed)); 560 561 /** @struct pldm_terminus_locator_type_mctp_eid 562 * 563 * Structure representing terminus locator value for 564 * terminus locator type MCTP_EID 565 */ 566 struct pldm_terminus_locator_type_mctp_eid { 567 uint8_t eid; 568 } __attribute__((packed)); 569 570 /** @struct pldm_pdr_entity_association 571 * 572 * Structure representing PLDM Entity Association PDR 573 */ 574 struct pldm_pdr_entity_association { 575 uint16_t container_id; 576 uint8_t association_type; 577 pldm_entity container; 578 uint8_t num_children; 579 pldm_entity children[1]; 580 } __attribute__((packed)); 581 582 /** @struct pldm_pdr_fru_record_set 583 * 584 * Structure representing PLDM FRU record set PDR 585 */ 586 struct pldm_pdr_fru_record_set { 587 uint16_t terminus_handle; 588 uint16_t fru_rsi; 589 uint16_t entity_type; 590 union { 591 uint16_t entity_instance_num; 592 uint16_t entity_instance; 593 }; 594 uint16_t container_id; 595 } __attribute__((packed)); 596 597 /** @struct pldm_state_sensor_pdr 598 * 599 * Structure representing PLDM state sensor PDR 600 */ 601 struct pldm_state_sensor_pdr { 602 struct pldm_pdr_hdr hdr; 603 uint16_t terminus_handle; 604 uint16_t sensor_id; 605 uint16_t entity_type; 606 uint16_t entity_instance; 607 uint16_t container_id; 608 uint8_t sensor_init; 609 bool8_t sensor_auxiliary_names_pdr; 610 uint8_t composite_sensor_count; 611 uint8_t possible_states[1]; 612 } __attribute__((packed)); 613 614 /** @struct state_sensor_possible_states 615 * 616 * Structure representing state enums for state sensor 617 */ 618 struct state_sensor_possible_states { 619 uint16_t state_set_id; 620 uint8_t possible_states_size; 621 bitfield8_t states[1]; 622 } __attribute__((packed)); 623 624 /** @struct pldm_state_effecter_pdr 625 * 626 * Structure representing PLDM state effecter PDR 627 */ 628 struct pldm_state_effecter_pdr { 629 struct pldm_pdr_hdr hdr; 630 uint16_t terminus_handle; 631 uint16_t effecter_id; 632 uint16_t entity_type; 633 uint16_t entity_instance; 634 uint16_t container_id; 635 uint16_t effecter_semantic_id; 636 uint8_t effecter_init; 637 bool8_t has_description_pdr; 638 uint8_t composite_effecter_count; 639 uint8_t possible_states[1]; 640 } __attribute__((packed)); 641 642 /** @struct pldm_compact_numeric_sensor_pdr 643 * 644 * Structure representing PLDM compact numeric sensor PDR 645 */ 646 struct pldm_compact_numeric_sensor_pdr { 647 struct pldm_pdr_hdr hdr; 648 uint16_t terminus_handle; 649 uint16_t sensor_id; 650 uint16_t entity_type; 651 uint16_t entity_instance; 652 uint16_t container_id; 653 uint8_t sensor_name_length; 654 uint8_t base_unit; 655 int8_t unit_modifier; 656 uint8_t occurrence_rate; 657 bitfield8_t range_field_support; 658 int32_t warning_high; 659 int32_t warning_low; 660 int32_t critical_high; 661 int32_t critical_low; 662 int32_t fatal_high; 663 int32_t fatal_low; 664 uint8_t sensor_name[1]; 665 } __attribute__((packed)); 666 667 /** @brief Encode PLDM state sensor PDR 668 * 669 * @param[in/out] sensor Structure to encode. All members of 670 * sensor, except those mentioned in the @note below, should be initialized by 671 * the caller. 672 * @param[in] allocation_size Size of sensor allocation in bytes 673 * @param[in] possible_states Possible sensor states 674 * @param[in] possible_states_size Size of possible sensor states in bytes 675 * @param[out] actual_size Size of sensor PDR. Set to 0 on error. 676 * @return int pldm_completion_codes 677 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH 678 * 679 * @note The sensor parameter will be encoded in place. 680 * @note Caller is responsible for allocation of the sensor parameter. Caller 681 * must allocate enough space for the base structure and the 682 * sensor->possible_states array, otherwise the function will fail. 683 * @note sensor->hdr.length, .type, and .version will be set appropriately. 684 */ 685 int encode_state_sensor_pdr( 686 struct pldm_state_sensor_pdr *sensor, size_t allocation_size, 687 const struct state_sensor_possible_states *possible_states, 688 size_t possible_states_size, size_t *actual_size); 689 690 /** @union union_effecter_data_size 691 * 692 * The bit width and format of reading and threshold values that the effecter 693 * returns. 694 * Refer to: DSP0248_1.2.0: 28.11 Table 87 695 */ 696 typedef union { 697 uint8_t value_u8; 698 int8_t value_s8; 699 uint16_t value_u16; 700 int16_t value_s16; 701 uint32_t value_u32; 702 int32_t value_s32; 703 } union_effecter_data_size; 704 705 /** @union union_range_field_format 706 * 707 * Indicates the format used for the nominalValue, normalMax, and normalMin 708 * fields. 709 * Refer to: DSP0248_1.2.0: 28.11 Table 87 710 */ 711 typedef union { 712 uint8_t value_u8; 713 int8_t value_s8; 714 uint16_t value_u16; 715 int16_t value_s16; 716 uint32_t value_u32; 717 int32_t value_s32; 718 real32_t value_f32; 719 } union_range_field_format; 720 721 /** @struct pldm_numeric_effecter_value_pdr 722 * 723 * Structure representing PLDM numeric effecter value PDR 724 */ 725 struct pldm_numeric_effecter_value_pdr { 726 struct pldm_pdr_hdr hdr; 727 uint16_t terminus_handle; 728 uint16_t effecter_id; 729 uint16_t entity_type; 730 uint16_t entity_instance; 731 uint16_t container_id; 732 uint16_t effecter_semantic_id; 733 uint8_t effecter_init; 734 bool8_t effecter_auxiliary_names; 735 uint8_t base_unit; 736 int8_t unit_modifier; 737 uint8_t rate_unit; 738 uint8_t base_oem_unit_handle; 739 uint8_t aux_unit; 740 int8_t aux_unit_modifier; 741 uint8_t aux_rate_unit; 742 uint8_t aux_oem_unit_handle; 743 bool8_t is_linear; 744 uint8_t effecter_data_size; 745 real32_t resolution; 746 real32_t offset; 747 uint16_t accuracy; 748 uint8_t plus_tolerance; 749 uint8_t minus_tolerance; 750 real32_t state_transition_interval; 751 real32_t transition_interval; 752 union_effecter_data_size max_settable; 753 union_effecter_data_size min_settable; 754 uint8_t range_field_format; 755 bitfield8_t range_field_support; 756 union_range_field_format nominal_value; 757 union_range_field_format normal_max; 758 union_range_field_format normal_min; 759 union_range_field_format rated_max; 760 union_range_field_format rated_min; 761 } __attribute__((packed)); 762 763 /** @union union_sensor_data_size 764 * 765 * The bit width and format of reading and threshold values that the sensor 766 * returns. 767 * Refer to: DSP0248_1.2.0: 28.4 Table 78 768 */ 769 typedef union { 770 uint8_t value_u8; 771 int8_t value_s8; 772 uint16_t value_u16; 773 int16_t value_s16; 774 uint32_t value_u32; 775 int32_t value_s32; 776 } union_sensor_data_size; 777 778 /** @struct pldm_value_pdr_hdr 779 * 780 * Structure representing PLDM PDR header for unpacked value 781 * Refer to: DSP0248_1.2.0: 28.1 Table 75 782 */ 783 struct pldm_value_pdr_hdr { 784 uint32_t record_handle; 785 uint8_t version; 786 uint8_t type; 787 uint16_t record_change_num; 788 uint16_t length; 789 }; 790 791 /** @struct pldm_numeric_sensor_value_pdr 792 * 793 * Structure representing PLDM Numeric Sensor PDR for unpacked value 794 * Refer to: DSP0248_1.2.0: 28.4 Table 78 795 */ 796 struct pldm_numeric_sensor_value_pdr { 797 struct pldm_value_pdr_hdr hdr; 798 uint16_t terminus_handle; 799 uint16_t sensor_id; 800 uint16_t entity_type; 801 union { 802 uint16_t entity_instance_num; 803 uint16_t entity_instance; 804 }; 805 uint16_t container_id; 806 uint8_t sensor_init; 807 bool8_t sensor_auxiliary_names_pdr; 808 uint8_t base_unit; 809 int8_t unit_modifier; 810 uint8_t rate_unit; 811 uint8_t base_oem_unit_handle; 812 uint8_t aux_unit; 813 int8_t aux_unit_modifier; 814 uint8_t aux_rate_unit; 815 uint8_t rel; 816 uint8_t aux_oem_unit_handle; 817 bool8_t is_linear; 818 uint8_t sensor_data_size; 819 real32_t resolution; 820 real32_t offset; 821 uint16_t accuracy; 822 uint8_t plus_tolerance; 823 uint8_t minus_tolerance; 824 union_sensor_data_size hysteresis; 825 bitfield8_t supported_thresholds; 826 bitfield8_t threshold_and_hysteresis_volatility; 827 real32_t state_transition_interval; 828 real32_t update_interval; 829 union_sensor_data_size max_readable; 830 union_sensor_data_size min_readable; 831 uint8_t range_field_format; 832 bitfield8_t range_field_support; 833 union_range_field_format nominal_value; 834 union_range_field_format normal_max; 835 union_range_field_format normal_min; 836 union_range_field_format warning_high; 837 union_range_field_format warning_low; 838 union_range_field_format critical_high; 839 union_range_field_format critical_low; 840 union_range_field_format fatal_high; 841 union_range_field_format fatal_low; 842 }; 843 844 typedef char16_t pldm_utf16be; 845 846 struct pldm_entity_auxiliary_name { 847 /* name_language_tag type is char which terminator is 0x00*/ 848 char *tag; 849 /** 850 * entity_aux_name type is str_utf16be which terminator is 0x00 0x00. 851 * The two bytes of one characters is in BE order. 852 */ 853 pldm_utf16be *name; 854 }; 855 856 struct pldm_entity_auxiliary_names_pdr { 857 struct pldm_value_pdr_hdr hdr; 858 pldm_entity container; 859 uint8_t shared_name_count; 860 uint8_t name_string_count; 861 struct pldm_entity_auxiliary_name *names; 862 size_t auxiliary_name_data_size; 863 #ifndef __cplusplus 864 #if defined __has_attribute 865 /* 866 * auxiliary_name_data is organised in the fashion of struct-of-arrays, by 867 * contrast to the approach of an array-of-structs. By Table 95 the entity 868 * name data is provided in (ASCII, UTF16-BE) pairs, but we rearrange that 869 * to be an array of UTF16-BE strings followed by an array of ASCII strings, 870 * with the pairs associated by index, to maintain alignment. 871 */ 872 static_assert(__has_attribute(aligned), 873 "auxiliary_name_data risks undefined behaviour"); 874 char auxiliary_name_data[] 875 __attribute__((aligned(alignof(pldm_utf16be)))); 876 #else 877 #error("__has_attribute() support is required to uphold runtime safety") 878 #endif 879 #endif 880 }; 881 882 /** @struct state_effecter_possible_states 883 * 884 * Structure representing state enums for state effecter 885 */ 886 struct state_effecter_possible_states { 887 uint16_t state_set_id; 888 uint8_t possible_states_size; 889 bitfield8_t states[1]; 890 } __attribute__((packed)); 891 892 /** @struct pldm_effecter_aux_name_pdr 893 * 894 * Structure representing PLDM aux name numeric effecter value PDR 895 */ 896 struct pldm_effecter_aux_name_pdr { 897 struct pldm_pdr_hdr hdr; 898 uint16_t terminus_handle; 899 uint16_t effecter_id; 900 uint8_t effecter_count; 901 uint8_t effecter_names[1]; 902 } __attribute__((packed)); 903 904 /** @brief Encode PLDM state effecter PDR 905 * 906 * @param[in/out] effecter Structure to encode. All members of 907 * effecter, except those mentioned in 908 * the @note below, should be initialized 909 * by the caller. 910 * @param[in] allocation_size Size of effecter allocation in bytes 911 * @param[in] possible_states Possible effecter states 912 * @param[in] possible_states_size Size of possible effecter states in 913 * bytes 914 * @param[out] actual_size Size of effecter PDR. Set to 0 on 915 * error. 916 * @return int pldm_completion_codes 917 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH 918 * 919 * @note The effecter parameter will be encoded in place. 920 * @note Caller is responsible for allocation of the effecter parameter. Caller 921 * must allocate enough space for the base structure and the 922 * effecter->possible_states array, otherwise the function will fail. 923 * @note effecter->hdr.length, .type, and .version will be set appropriately. 924 */ 925 int encode_state_effecter_pdr( 926 struct pldm_state_effecter_pdr *effecter, size_t allocation_size, 927 const struct state_effecter_possible_states *possible_states, 928 size_t possible_states_size, size_t *actual_size); 929 930 /** @struct set_effecter_state_field 931 * 932 * Structure representing a stateField in SetStateEffecterStates command */ 933 934 typedef struct state_field_for_state_effecter_set { 935 uint8_t set_request; //!< Whether to change the state 936 uint8_t effecter_state; //!< Expected state of the effecter 937 } __attribute__((packed)) set_effecter_state_field; 938 939 /** @struct get_sensor_readings_field 940 * 941 * Structure representing a stateField in GetStateSensorReadings command */ 942 943 typedef struct state_field_for_get_state_sensor_readings { 944 uint8_t sensor_op_state; //!< The state of the sensor itself 945 uint8_t present_state; //!< Return a state value 946 uint8_t previous_state; //!< The state that the presentState was entered 947 //! from. This must be different from the 948 //! present state 949 uint8_t event_state; //!< Return a state value from a PLDM State Set 950 //! that is associated with the sensor 951 } __attribute__((packed)) get_sensor_state_field; 952 953 /** @struct get_effecter_state_field 954 * 955 * Structure representing a stateField in GetStateEffecterStates command 956 */ 957 typedef struct state_field_for_get_state_effecter_states { 958 uint8_t effecter_op_state; //!< The state of the effecter itself 959 uint8_t pending_state; //!< The state that is currently being processed 960 uint8_t present_state; //!< Return a state value 961 } get_effecter_state_field; 962 963 /** @struct PLDM_SetStateEffecterStates_Request 964 * 965 * Structure representing PLDM set state effecter states request. 966 */ 967 struct pldm_set_state_effecter_states_req { 968 uint16_t effecter_id; 969 uint8_t comp_effecter_count; 970 set_effecter_state_field field[8]; 971 } __attribute__((packed)); 972 973 /** @struct pldm_get_pdr_repository_info_resp 974 * 975 * Structure representing GetPDRRepositoryInfo response packet 976 */ 977 struct pldm_pdr_repository_info_resp { 978 uint8_t completion_code; 979 uint8_t repository_state; 980 uint8_t update_time[PLDM_TIMESTAMP104_SIZE]; 981 uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE]; 982 uint32_t record_count; 983 uint32_t repository_size; 984 uint32_t largest_record_size; 985 uint8_t data_transfer_handle_timeout; 986 } __attribute__((packed)); 987 988 /** @struct pldm_get_pdr_resp 989 * 990 * structure representing GetPDR response packet 991 * transfer CRC is not part of the structure and will be 992 * added at the end of last packet in multipart transfer 993 */ 994 struct pldm_get_pdr_resp { 995 uint8_t completion_code; 996 uint32_t next_record_handle; 997 uint32_t next_data_transfer_handle; 998 uint8_t transfer_flag; 999 uint16_t response_count; 1000 uint8_t record_data[1]; 1001 } __attribute__((packed)); 1002 1003 /** @struct pldm_get_pdr_req 1004 * 1005 * structure representing GetPDR request packet 1006 */ 1007 struct pldm_get_pdr_req { 1008 uint32_t record_handle; 1009 uint32_t data_transfer_handle; 1010 uint8_t transfer_op_flag; 1011 uint16_t request_count; 1012 uint16_t record_change_number; 1013 } __attribute__((packed)); 1014 1015 /** @struct pldm_set_event_receiver_req 1016 * 1017 * Structure representing SetEventReceiver command. 1018 * This structure applies only for MCTP as a transport type. 1019 */ 1020 struct pldm_set_event_receiver_req { 1021 uint8_t event_message_global_enable; 1022 uint8_t transport_protocol_type; 1023 uint8_t event_receiver_address_info; 1024 uint16_t heartbeat_timer; 1025 } __attribute__((packed)); 1026 1027 /** @struct pldm_event_message_buffer_size_req 1028 * 1029 * Structure representing EventMessageBufferSizes command request data 1030 */ 1031 struct pldm_event_message_buffer_size_req { 1032 uint16_t event_receiver_max_buffer_size; 1033 } __attribute__((packed)); 1034 1035 /** @struct pldm_event_message_buffer_size_resp 1036 * 1037 * Structure representing EventMessageBufferSizes command response data 1038 */ 1039 struct pldm_event_message_buffer_size_resp { 1040 uint8_t completion_code; 1041 uint16_t terminus_max_buffer_size; 1042 } __attribute__((packed)); 1043 1044 /** @struct pldm_platform_event_message_supported_req 1045 * 1046 * structure representing PlatformEventMessageSupported command request data 1047 */ 1048 struct pldm_event_message_supported_req { 1049 uint8_t format_version; 1050 } __attribute__((packed)); 1051 1052 /** @struct pldm_event_message_supported_response 1053 * 1054 * structure representing EventMessageSupported command response data 1055 */ 1056 struct pldm_event_message_supported_resp { 1057 uint8_t completion_code; 1058 uint8_t synchrony_configuration; 1059 bitfield8_t synchrony_configuration_supported; 1060 uint8_t number_event_class_returned; 1061 uint8_t event_class[1]; 1062 } __attribute__((packed)); 1063 1064 /** @struct pldm_set_numeric_effecter_value_req 1065 * 1066 * structure representing SetNumericEffecterValue request packet 1067 */ 1068 struct pldm_set_numeric_effecter_value_req { 1069 uint16_t effecter_id; 1070 uint8_t effecter_data_size; 1071 uint8_t effecter_value[1]; 1072 } __attribute__((packed)); 1073 1074 /** @struct pldm_get_state_sensor_readings_req 1075 * 1076 * Structure representing PLDM get state sensor readings request. 1077 */ 1078 struct pldm_get_state_sensor_readings_req { 1079 uint16_t sensor_id; 1080 bitfield8_t sensor_rearm; 1081 uint8_t reserved; 1082 } __attribute__((packed)); 1083 1084 /** @struct pldm_get_state_sensor_readings_resp 1085 * 1086 * Structure representing PLDM get state sensor readings response. 1087 */ 1088 struct pldm_get_state_sensor_readings_resp { 1089 uint8_t completion_code; 1090 uint8_t comp_sensor_count; 1091 get_sensor_state_field field[1]; 1092 } __attribute__((packed)); 1093 1094 /** @struct pldm_get_state_effecter_states_req 1095 * 1096 * structure representing GetStateEffecterStates request packet 1097 */ 1098 struct pldm_get_state_effecter_states_req { 1099 uint16_t effecter_id; 1100 }; 1101 1102 /** @struct pldm_get_state_effecter_states_resp 1103 * 1104 * Structure representing PLDM get state effecter states response. 1105 */ 1106 struct pldm_get_state_effecter_states_resp { 1107 uint8_t completion_code; 1108 uint8_t comp_effecter_count; 1109 get_effecter_state_field field[PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX]; 1110 }; 1111 1112 /** @struct pldm_sensor_event 1113 * 1114 * structure representing sensorEventClass 1115 */ 1116 struct pldm_sensor_event_data { 1117 uint16_t sensor_id; 1118 uint8_t sensor_event_class_type; 1119 uint8_t event_class[1]; 1120 } __attribute__((packed)); 1121 1122 /** @struct pldm_state_sensor_state 1123 * 1124 * structure representing sensorEventClass for stateSensorState 1125 */ 1126 struct pldm_sensor_event_state_sensor_state { 1127 uint8_t sensor_offset; 1128 uint8_t event_state; 1129 uint8_t previous_event_state; 1130 } __attribute__((packed)); 1131 1132 /** @struct pldm_sensor_event_numeric_sensor_state 1133 * 1134 * structure representing sensorEventClass for stateSensorState 1135 */ 1136 struct pldm_sensor_event_numeric_sensor_state { 1137 uint8_t event_state; 1138 uint8_t previous_event_state; 1139 uint8_t sensor_data_size; 1140 uint8_t present_reading[1]; 1141 } __attribute__((packed)); 1142 1143 /** @struct pldm_sensor_event_sensor_op_state 1144 * 1145 * structure representing sensorEventClass for SensorOpState 1146 */ 1147 struct pldm_sensor_event_sensor_op_state { 1148 uint8_t present_op_state; 1149 uint8_t previous_op_state; 1150 } __attribute__((packed)); 1151 1152 /** @struct pldm_message_poll_event 1153 * 1154 * structure representing pldmMessagePollEvent 1155 */ 1156 struct pldm_message_poll_event { 1157 uint8_t format_version; 1158 uint16_t event_id; 1159 uint32_t data_transfer_handle; 1160 }; 1161 1162 /** @struct pldm_platform_cper_event 1163 * 1164 * structure representing cperEvent fields 1165 */ 1166 struct pldm_platform_cper_event { 1167 uint8_t format_version; 1168 uint8_t format_type; 1169 uint16_t event_data_length; 1170 #ifndef __cplusplus 1171 uint8_t event_data[] LIBPLDM_CC_COUNTED_BY(event_data_length); 1172 #endif 1173 }; 1174 1175 /** @brief PLDM CPER event format type */ 1176 enum pldm_platform_cper_event_format { 1177 PLDM_PLATFORM_CPER_EVENT_WITH_HEADER = 0x00, 1178 PLDM_PLATFORM_CPER_EVENT_WITHOUT_HEADER = 0x01 1179 }; 1180 1181 /** @struct pldm_platform_event_message_req 1182 * 1183 * structure representing PlatformEventMessage command request data 1184 */ 1185 struct pldm_platform_event_message_req { 1186 uint8_t format_version; 1187 uint8_t tid; 1188 uint8_t event_class; 1189 uint8_t event_data[1]; 1190 } __attribute__((packed)); 1191 1192 /** @struct pldm_poll_for_platform_event_message_req 1193 * 1194 * structure representing PollForPlatformEventMessage command request data 1195 */ 1196 struct pldm_poll_for_platform_event_message_req { 1197 uint8_t format_version; 1198 uint8_t transfer_operation_flag; 1199 uint32_t data_transfer_handle; 1200 uint16_t event_id_to_acknowledge; 1201 }; 1202 1203 /** @struct pldm_poll_for_platform_event_message_min_resp 1204 * 1205 * structure representing PollForPlatformEventMessage command response data 1206 */ 1207 struct pldm_poll_for_platform_event_message_min_resp { 1208 uint8_t completion_code; 1209 uint8_t tid; 1210 uint16_t event_id; 1211 }; 1212 1213 /** @struct pldm_platform_event_message_response 1214 * 1215 * structure representing PlatformEventMessage command response data 1216 */ 1217 struct pldm_platform_event_message_resp { 1218 uint8_t completion_code; 1219 uint8_t platform_event_status; 1220 } __attribute__((packed)); 1221 1222 /** @struct pldm_pdr_repository_chg_event_data 1223 * 1224 * structure representing pldmPDRRepositoryChgEvent class eventData 1225 */ 1226 struct pldm_pdr_repository_chg_event_data { 1227 uint8_t event_data_format; 1228 uint8_t number_of_change_records; 1229 uint8_t change_records[1]; 1230 } __attribute__((packed)); 1231 1232 /** @struct pldm_pdr_repository_chg_event_change_record_data 1233 * 1234 * structure representing pldmPDRRepositoryChgEvent class eventData's change 1235 * record data 1236 */ 1237 struct pldm_pdr_repository_change_record_data { 1238 uint8_t event_data_operation; 1239 uint8_t number_of_change_entries; 1240 uint32_t change_entry[1]; 1241 } __attribute__((packed)); 1242 1243 /** @struct pldm_get_numeric_effecter_value_req 1244 * 1245 * structure representing GetNumericEffecterValue request packet 1246 */ 1247 struct pldm_get_numeric_effecter_value_req { 1248 uint16_t effecter_id; 1249 } __attribute__((packed)); 1250 1251 /** @struct pldm_get_numeric_effecter_value_resp 1252 * 1253 * structure representing GetNumericEffecterValue response packet 1254 */ 1255 struct pldm_get_numeric_effecter_value_resp { 1256 uint8_t completion_code; 1257 uint8_t effecter_data_size; 1258 uint8_t effecter_oper_state; 1259 uint8_t pending_and_present_values[1]; 1260 } __attribute__((packed)); 1261 1262 /** @struct pldm_get_sensor_reading_req 1263 * 1264 * Structure representing PLDM get sensor reading request 1265 */ 1266 struct pldm_get_sensor_reading_req { 1267 uint16_t sensor_id; 1268 bool8_t rearm_event_state; 1269 } __attribute__((packed)); 1270 1271 /** @struct pldm_get_sensor_reading_resp 1272 * 1273 * Structure representing PLDM get sensor reading response 1274 */ 1275 struct pldm_get_sensor_reading_resp { 1276 uint8_t completion_code; 1277 uint8_t sensor_data_size; 1278 uint8_t sensor_operational_state; 1279 uint8_t sensor_event_message_enable; 1280 uint8_t present_state; 1281 uint8_t previous_state; 1282 uint8_t event_state; 1283 uint8_t present_reading[1]; 1284 } __attribute__((packed)); 1285 1286 /* Responder */ 1287 1288 /* SetNumericEffecterValue */ 1289 1290 /** @brief Decode SetNumericEffecterValue request data 1291 * 1292 * @param[in] msg - Request message 1293 * @param[in] payload_length - Length of request message payload 1294 * @param[out] effecter_id - used to identify and access the effecter 1295 * @param[out] effecter_data_size - The bit width and format of the setting 1296 * value for the effecter. 1297 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1298 * @param[out] effecter_value - The setting value of numeric effecter being 1299 * requested. 1300 * @return pldm_completion_codes 1301 */ 1302 int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg, 1303 size_t payload_length, 1304 uint16_t *effecter_id, 1305 uint8_t *effecter_data_size, 1306 uint8_t effecter_value[4]); 1307 1308 /** @brief Create a PLDM response message for SetNumericEffecterValue 1309 * 1310 * @param[in] instance_id - Message's instance id 1311 * @param[in] completion_code - PLDM completion code 1312 * @param[out] msg - Message will be written to this 1313 * @param[in] payload_length - Length of request message payload 1314 * @return pldm_completion_codes 1315 * @note Caller is responsible for memory alloc and dealloc of param 1316 * 'msg.body.payload' 1317 */ 1318 int encode_set_numeric_effecter_value_resp(uint8_t instance_id, 1319 uint8_t completion_code, 1320 struct pldm_msg *msg, 1321 size_t payload_length); 1322 1323 /* SetStateEffecterStates */ 1324 1325 /** @brief Create a PLDM response message for SetStateEffecterStates 1326 * 1327 * @param[in] instance_id - Message's instance id 1328 * @param[in] completion_code - PLDM completion code 1329 * @param[out] msg - Message will be written to this 1330 * @return pldm_completion_codes 1331 * @note Caller is responsible for memory alloc and dealloc of param 1332 * 'msg.body.payload' 1333 */ 1334 1335 int encode_set_state_effecter_states_resp(uint8_t instance_id, 1336 uint8_t completion_code, 1337 struct pldm_msg *msg); 1338 1339 /** @brief Decode SetStateEffecterStates request data 1340 * 1341 * @param[in] msg - Request message 1342 * @param[in] payload_length - Length of request message payload 1343 * @param[out] effecter_id - used to identify and access the effecter 1344 * @param[out] comp_effecter_count - number of individual sets of effecter 1345 * information. Upto eight sets of state effecter info can be accessed 1346 * for a given effecter. 1347 * @param[out] field - each unit is an instance of the stateFileld structure 1348 * that is used to set the requested state for a particular effecter 1349 * within the state effecter. This field holds the starting address of 1350 * the stateField values. The user is responsible to allocate the 1351 * memory prior to calling this command. Since the state field count is 1352 * not known in advance, the user should allocate the maximum size 1353 * always, which is 8 in number. 1354 * @return pldm_completion_codes 1355 */ 1356 1357 int decode_set_state_effecter_states_req(const struct pldm_msg *msg, 1358 size_t payload_length, 1359 uint16_t *effecter_id, 1360 uint8_t *comp_effecter_count, 1361 set_effecter_state_field *field); 1362 1363 /* GetPDR */ 1364 1365 /** @brief Create a PLDM response message for GetPDR 1366 * 1367 * @param[in] instance_id - Message's instance id 1368 * @param[in] completion_code - PLDM completion code 1369 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in 1370 * the PDR Repository 1371 * @param[in] next_data_transfer_hndl - A handle that identifies the next 1372 * portion of the PDR data to be transferred, if any 1373 * @param[in] transfer_flag - Indicates the portion of PDR data being 1374 * transferred 1375 * @param[in] resp_cnt - The number of recordData bytes returned in this 1376 * response 1377 * @param[in] record_data - PDR data bytes of length resp_cnt 1378 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only 1379 * in the last part of a PDR being transferred 1380 * @param[out] msg - Message will be written to this 1381 * @return pldm_completion_codes 1382 * @note Caller is responsible for memory alloc and dealloc of param 1383 * 'msg.payload' 1384 */ 1385 int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code, 1386 uint32_t next_record_hndl, 1387 uint32_t next_data_transfer_hndl, uint8_t transfer_flag, 1388 uint16_t resp_cnt, const uint8_t *record_data, 1389 uint8_t transfer_crc, struct pldm_msg *msg); 1390 1391 /** @brief Decode GetPDR request data 1392 * 1393 * @param[in] msg - Request message 1394 * @param[in] payload_length - Length of request message payload 1395 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved 1396 * @param[out] data_transfer_hndl - Handle used to identify a particular 1397 * multipart PDR data transfer operation 1398 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent 1399 * portion of transfer 1400 * @param[out] request_cnt - The maximum number of record bytes requested 1401 * @param[out] record_chg_num - Used to determine whether the PDR has changed 1402 * while PDR transfer is going on 1403 * @return pldm_completion_codes 1404 */ 1405 1406 int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length, 1407 uint32_t *record_hndl, uint32_t *data_transfer_hndl, 1408 uint8_t *transfer_op_flag, uint16_t *request_cnt, 1409 uint16_t *record_chg_num); 1410 1411 /* GetStateSensorReadings */ 1412 1413 /** @brief Decode GetStateSensorReadings request data 1414 * 1415 * @param[in] msg - Request message 1416 * @param[in] payload_length - Length of request message payload 1417 * @param[out] sensor_id - used to identify and access the simple or composite 1418 * sensor 1419 * @param[out] sensor_rearm - Each bit location in this field corresponds to a 1420 * particular sensor within the state sensor, where bit [0] corresponds 1421 * to the first state sensor (sensor offset 0) and bit [7] corresponds 1422 * to the eighth sensor (sensor offset 7), sequentially. 1423 * @param[out] reserved - value: 0x00 1424 * @return pldm_completion_codes 1425 */ 1426 1427 int decode_get_state_sensor_readings_req(const struct pldm_msg *msg, 1428 size_t payload_length, 1429 uint16_t *sensor_id, 1430 bitfield8_t *sensor_rearm, 1431 uint8_t *reserved); 1432 1433 /** @brief Encode GetStateSensorReadings response data 1434 * 1435 * @param[in] instance_id - Message's instance id 1436 * @param[in] completion_code - PLDM completion code 1437 * @param[out] comp_sensor_count - The number of individual sets of sensor 1438 * information that this command accesses 1439 * @param[out] field - Each stateField is an instance of a stateField structure 1440 * that is used to return the present operational state setting and the 1441 * present state and event state for a particular set of sensor 1442 * information contained within the state sensor 1443 * @param[out] msg - Message will be written to this 1444 * @return pldm_completion_codes 1445 */ 1446 1447 int encode_get_state_sensor_readings_resp(uint8_t instance_id, 1448 uint8_t completion_code, 1449 uint8_t comp_sensor_count, 1450 get_sensor_state_field *field, 1451 struct pldm_msg *msg); 1452 1453 /* GetNumericEffecterValue */ 1454 1455 /** @brief Decode GetNumericEffecterValue request data 1456 * 1457 * @param[in] msg - Request message 1458 * @param[in] payload_length - Length of request message payload 1459 * @param[out] effecter_id - used to identify and access the effecter 1460 * @return pldm_completion_codes 1461 */ 1462 int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg, 1463 size_t payload_length, 1464 uint16_t *effecter_id); 1465 1466 /** @brief Create a PLDM response message for GetNumericEffecterValue 1467 * 1468 * @param[in] instance_id - Message's instance id 1469 * @param[in] completion_code - PLDM completion code 1470 * @param[in] effecter_data_size - The bit width and format of the setting 1471 * value for the effecter. 1472 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1473 * @param[in] effecter_oper_state - The state of the effecter itself 1474 * @param[in] pending_value - The pending numeric value setting of the 1475 * effecter. The effecterDataSize field indicates the number of 1476 * bits used for this field 1477 * @param[in] present_value - The present numeric value setting of the 1478 * effecter. The effecterDataSize indicates the number of bits 1479 * used for this field 1480 * @param[out] msg - Message will be written to this 1481 * @param[in] payload_length - Length of request message payload 1482 * @return pldm_completion_codes 1483 * @note Caller is responsible for memory alloc and dealloc of param 1484 * 'msg.payload' 1485 */ 1486 int encode_get_numeric_effecter_value_resp( 1487 uint8_t instance_id, uint8_t completion_code, 1488 uint8_t effecter_data_size, uint8_t effecter_oper_state, 1489 const uint8_t *pending_value, const uint8_t *present_value, 1490 struct pldm_msg *msg, size_t payload_length); 1491 1492 /* GetSensorReading */ 1493 1494 /** @brief Decode GetSensorReading request data 1495 * 1496 * @param[in] msg - Request message 1497 * @param[in] payload_length - Length of request message payload 1498 * @param[out] sensor_id - A handle that is used to identify and access 1499 * the sensor 1500 * @param[out] rearm_event_state - true = manually re-arm EventState after 1501 * responding to this request, false = no manual re-arm 1502 * @return pldm_completion_codes 1503 */ 1504 1505 int decode_get_sensor_reading_req(const struct pldm_msg *msg, 1506 size_t payload_length, uint16_t *sensor_id, 1507 bool8_t *rearm_event_state); 1508 1509 /** @brief Encode GetSensorReading response data 1510 * 1511 * @param[in] instance_id - Message's instance id 1512 * @param[in] completion_code - PLDM completion code 1513 * @param[out] sensor_data_size - The bit width and format of reading and 1514 * threshold values 1515 * @param[out] sensor_operational_state - The state of the sensor itself 1516 * @param[out] sensor_event_message_enable - value: { noEventGeneration, 1517 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled, 1518 * stateEventsOnlyEnabled } 1519 * @param[out] present_state - The most recently assessed state value monitored 1520 * by the sensor 1521 * @param[out] previous_state - The state that the presentState was entered 1522 * from 1523 * @param[out] event_state - Indicates which threshold crossing assertion 1524 * events have been detected 1525 * @param[out] present_reading - The present value indicated by the sensor 1526 * @param[out] msg - Message will be written to this 1527 * @param[in] payload_length - Length of request message payload 1528 * @return pldm_completion_codes 1529 */ 1530 1531 int encode_get_sensor_reading_resp(uint8_t instance_id, uint8_t completion_code, 1532 uint8_t sensor_data_size, 1533 uint8_t sensor_operational_state, 1534 uint8_t sensor_event_message_enable, 1535 uint8_t present_state, 1536 uint8_t previous_state, uint8_t event_state, 1537 const uint8_t *present_reading, 1538 struct pldm_msg *msg, size_t payload_length); 1539 1540 /* Requester */ 1541 1542 /*GetPDRRepositoryInfo*/ 1543 1544 /** @brief Encode GetPDRRepositoryInfo response data 1545 * 1546 * @param[in] instance_id - Message's instance id 1547 * @param[in] completion_code - PLDM completion code 1548 * @param[in] repository_state - PLDM repository state 1549 * @param[in] update_time - When the standard PDR repository data was 1550 * originally created 1551 * @param[in] oem_update_time - when OEM PDRs in the PDR Repository were 1552 * originally created 1553 * @param[in] record_count - Total number of PDRs in this repository 1554 * @param[in] repository_size - Size of the PDR Repository in bytes 1555 * @param[in] largest_record_size - Size of the largest record in the PDR 1556 * Repository in bytes 1557 * @param[in] data_transfer_handle_timeout - Data transmission timeout 1558 * @param[out] msg - Message will be written to this 1559 * @return pldm_completion_codes 1560 */ 1561 int encode_get_pdr_repository_info_resp( 1562 uint8_t instance_id, uint8_t completion_code, uint8_t repository_state, 1563 const uint8_t *update_time, const uint8_t *oem_update_time, 1564 uint32_t record_count, uint32_t repository_size, 1565 uint32_t largest_record_size, uint8_t data_transfer_handle_timeout, 1566 struct pldm_msg *msg); 1567 1568 /** @brief Decode GetPDRRepositoryInfo response data 1569 * 1570 * @param[in] msg - Response message 1571 * @param[in] payload_length - Length of response message payload 1572 * @param[out] completion_code - PLDM completion code 1573 * @param[out] repository_state - PLDM repository state 1574 * @param[out] update_time - When the standard PDR repository data was 1575 * originally created 1576 * @param[out] oem_update_time - when OEM PDRs in the PDR Repository were 1577 * originally created 1578 * @param[out] record_count - Total number of PDRs in this repository 1579 * @param[out] repository_size - Size of the PDR Repository in bytes 1580 * @param[out] largest_record_size - Size of the largest record in the PDR 1581 * Repository in bytes 1582 * @param[out] data_transfer_handle_timeout - Data transmission timeout 1583 * @return pldm_completion_codes 1584 */ 1585 int decode_get_pdr_repository_info_resp( 1586 const struct pldm_msg *msg, size_t payload_length, 1587 uint8_t *completion_code, uint8_t *repository_state, 1588 uint8_t *update_time, uint8_t *oem_update_time, uint32_t *record_count, 1589 uint32_t *repository_size, uint32_t *largest_record_size, 1590 uint8_t *data_transfer_handle_timeout); 1591 1592 /** @brief Decode GetPDRRepositoryInfo response data 1593 * 1594 * @param[in] msg - Response message 1595 * @param[in] payload_length - Length of response message payload 1596 * @param[out] resp - The response structure to populate with the extracted message data. Output member values are host-endian. 1597 * 1598 * @return 0 on success, a negative errno value on failure. 1599 */ 1600 int decode_get_pdr_repository_info_resp_safe( 1601 const struct pldm_msg *msg, size_t payload_length, 1602 struct pldm_pdr_repository_info_resp *resp); 1603 1604 /* GetPDR */ 1605 1606 /** @brief Create a PLDM request message for GetPDR 1607 * 1608 * @param[in] instance_id - Message's instance id 1609 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved 1610 * @param[in] data_transfer_hndl - Handle used to identify a particular 1611 * multipart PDR data transfer operation 1612 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent 1613 * portion of transfer 1614 * @param[in] request_cnt - The maximum number of record bytes requested 1615 * @param[in] record_chg_num - Used to determine whether the PDR has changed 1616 * while PDR transfer is going on 1617 * @param[out] msg - Message will be written to this 1618 * @param[in] payload_length - Length of request message payload 1619 * @return pldm_completion_codes 1620 * @note Caller is responsible for memory alloc and dealloc of param 1621 * 'msg.payload' 1622 */ 1623 int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl, 1624 uint32_t data_transfer_hndl, uint8_t transfer_op_flag, 1625 uint16_t request_cnt, uint16_t record_chg_num, 1626 struct pldm_msg *msg, size_t payload_length); 1627 1628 /** @brief Decode GetPDR response data 1629 * 1630 * Note: 1631 * * If the return value is not PLDM_SUCCESS, it represents a 1632 * transport layer error. 1633 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1634 * protocol layer error and all the out-parameters are invalid. 1635 * 1636 * @param[in] msg - Request message 1637 * @param[in] payload_length - Length of request message payload 1638 * @param[out] completion_code - PLDM completion code 1639 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in 1640 * the PDR Repository 1641 * @param[out] next_data_transfer_hndl - A handle that identifies the next 1642 * portion of the PDR data to be transferred, if any 1643 * @param[out] transfer_flag - Indicates the portion of PDR data being 1644 * transferred 1645 * @param[out] resp_cnt - The number of recordData bytes returned in this 1646 * response 1647 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to 1648 * skip the copy and place the actual length in resp_cnt. 1649 * @param[in] record_data_length - Length of record_data 1650 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only 1651 * in the last part of a PDR being transferred 1652 * @return pldm_completion_codes 1653 */ 1654 int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length, 1655 uint8_t *completion_code, uint32_t *next_record_hndl, 1656 uint32_t *next_data_transfer_hndl, 1657 uint8_t *transfer_flag, uint16_t *resp_cnt, 1658 uint8_t *record_data, size_t record_data_length, 1659 uint8_t *transfer_crc); 1660 1661 /** @brief Decode GetPDR response data 1662 * 1663 * Note: 1664 * * If the return value is not PLDM_SUCCESS, it represents a 1665 * transport layer error. 1666 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1667 * protocol layer error and all the out-parameters are invalid. 1668 * 1669 * @param[in] msg - Request message 1670 * @param[in] payload_length - Length of request message payload 1671 * @param[out] resp - The response structure into which the message will be unpacked 1672 * @param[in] resp_len - The size of the resp object in memory 1673 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only 1674 * in the last part of a PDR being transferred 1675 * @return 0 on success, otherwise, a negative errno value on failure 1676 */ 1677 int decode_get_pdr_resp_safe(const struct pldm_msg *msg, size_t payload_length, 1678 struct pldm_get_pdr_resp *resp, size_t resp_len, 1679 uint8_t *transfer_crc); 1680 1681 /* SetStateEffecterStates */ 1682 1683 /** @brief Create a PLDM request message for SetStateEffecterStates 1684 * 1685 * @param[in] instance_id - Message's instance id 1686 * @param[in] effecter_id - used to identify and access the effecter 1687 * @param[in] comp_effecter_count - number of individual sets of effecter 1688 * information. Upto eight sets of state effecter info can be accessed 1689 * for a given effecter. 1690 * @param[in] field - each unit is an instance of the stateField structure 1691 * that is used to set the requested state for a particular effecter 1692 * within the state effecter. This field holds the starting address of 1693 * the stateField values. The user is responsible to allocate the 1694 * memory prior to calling this command. The user has to allocate the 1695 * field parameter as sizeof(set_effecter_state_field) * 1696 * comp_effecter_count 1697 * @param[out] msg - Message will be written to this 1698 * @return pldm_completion_codes 1699 * @note Caller is responsible for memory alloc and dealloc of param 1700 * 'msg.payload' 1701 */ 1702 1703 int encode_set_state_effecter_states_req(uint8_t instance_id, 1704 uint16_t effecter_id, 1705 uint8_t comp_effecter_count, 1706 set_effecter_state_field *field, 1707 struct pldm_msg *msg); 1708 1709 /** @brief Decode SetStateEffecterStates response data 1710 * 1711 * Note: 1712 * * If the return value is not PLDM_SUCCESS, it represents a 1713 * transport layer error. 1714 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1715 * protocol layer error and all the out-parameters are invalid. 1716 * 1717 * @param[in] msg - Request message 1718 * @param[in] payload_length - Length of response message payload 1719 * @param[out] completion_code - PLDM completion code 1720 * @return pldm_completion_codes 1721 */ 1722 int decode_set_state_effecter_states_resp(const struct pldm_msg *msg, 1723 size_t payload_length, 1724 uint8_t *completion_code); 1725 1726 /* SetNumericEffecterValue */ 1727 1728 /** @brief Create a PLDM request message for SetNumericEffecterValue 1729 * 1730 * @param[in] instance_id - Message's instance id 1731 * @param[in] effecter_id - used to identify and access the effecter 1732 * @param[in] effecter_data_size - The bit width and format of the setting 1733 * value for the effecter. 1734 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1735 * @param[in] effecter_value - The setting value of numeric effecter being 1736 * requested. 1737 * @param[in] payload_length - Length of request message payload 1738 * @param[out] msg - Message will be written to this 1739 * @return pldm_completion_codes 1740 * @note Caller is responsible for memory alloc and dealloc of param 1741 * 'msg.payload' 1742 */ 1743 int encode_set_numeric_effecter_value_req(uint8_t instance_id, 1744 uint16_t effecter_id, 1745 uint8_t effecter_data_size, 1746 const uint8_t *effecter_value, 1747 struct pldm_msg *msg, 1748 size_t payload_length); 1749 1750 /** @brief Decode SetNumericEffecterValue response data 1751 * @param[in] msg - Request message 1752 * @param[in] payload_length - Length of response message payload 1753 * @param[out] completion_code - PLDM completion code 1754 * @return pldm_completion_codes 1755 */ 1756 int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg, 1757 size_t payload_length, 1758 uint8_t *completion_code); 1759 1760 /** @brief Create a PLDM request message for GetStateSensorReadings 1761 * 1762 * @param[in] instance_id - Message's instance id 1763 * @param[in] sensor_id - used to identify and access the simple or composite 1764 * sensor 1765 * @param[in] sensorRearm - Each bit location in this field corresponds to a 1766 * particular sensor within the state sensor, where bit [0] corresponds 1767 * to the first state sensor (sensor offset 0) and bit [7] corresponds 1768 * to the eighth sensor (sensor offset 7), sequentially 1769 * @param[in] reserved - value: 0x00 1770 * @param[out] msg - Message will be written to this 1771 * @return pldm_completion_codes 1772 * @note Caller is responsible for memory alloc and dealloc of param 1773 * 'msg.payload' 1774 */ 1775 int encode_get_state_sensor_readings_req(uint8_t instance_id, 1776 uint16_t sensor_id, 1777 bitfield8_t sensor_rearm, 1778 uint8_t reserved, 1779 struct pldm_msg *msg); 1780 1781 /** @brief Decode GetStateSensorReadings response data 1782 * 1783 * @param[in] msg - Request message 1784 * @param[in] payload_length - Length of response message payload 1785 * @param[out] completion_code - PLDM completion code 1786 * @param[in,out] comp_sensor_count - The number of individual sets of sensor 1787 * information that this command accesses 1788 * @param[out] field - Each stateField is an instance of a stateField structure 1789 * that is used to return the present operational state setting and the 1790 * present state and event state for a particular set of sensor 1791 * information contained within the state sensor 1792 * @return pldm_completion_codes 1793 */ 1794 1795 int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg, 1796 size_t payload_length, 1797 uint8_t *completion_code, 1798 uint8_t *comp_sensor_count, 1799 get_sensor_state_field *field); 1800 1801 /* GetStateEffecterStates */ 1802 1803 /** @brief Decode GetStateEffecterStates request data 1804 * 1805 * @param[in] msg - Request message 1806 * @param[in] payload_length - Length of request message payload 1807 * @param[out] effecter_id - used to identify and access the effecter 1808 * @return pldm_completion_codes 1809 */ 1810 int decode_get_state_effecter_states_req(const struct pldm_msg *msg, 1811 size_t payload_length, 1812 uint16_t *effecter_id); 1813 1814 /** @brief Create a PLDM request message for GetStateEffecterStates 1815 * 1816 * @param[in] instance_id - Message's instance id 1817 * @param[in] effecter_id - used to identify and access the effecter 1818 * @param[out] msg - Message will be written to this 1819 * @param[in] payload_length - Length of request message payload 1820 * @return pldm_completion_codes 1821 * @note Caller is responsible for memory alloc and dealloc of param 1822 * 'msg.payload' 1823 */ 1824 int encode_get_state_effecter_states_req(uint8_t instance_id, 1825 uint16_t effecter_id, 1826 struct pldm_msg *msg, 1827 size_t payload_length); 1828 1829 /** @brief Decode GetStateEffecterStates response data 1830 * 1831 * @param[in] msg - Request message 1832 * @param[in] payload_length - Length of response message payload 1833 * @param[out] resp - Consists of PLDM completion code, the number 1834 * of individual sets of effecters information that this command 1835 * accesses and an instance of a stateField structure that is 1836 * used to return the present operational state setting and 1837 * the present state and event state for a particular set of effecter 1838 * information contained within the state effecter 1839 * @return pldm_completion_codes 1840 */ 1841 int decode_get_state_effecter_states_resp( 1842 const struct pldm_msg *msg, size_t payload_length, 1843 struct pldm_get_state_effecter_states_resp *resp); 1844 1845 /** @brief Encode GetStateEffecterStates response data 1846 * 1847 * @param[in] instance_id - Message's instance id 1848 * @param[in] resp - Consists of PLDM completion code, the number 1849 * of individual sets of effecters information that this command 1850 * accesses and an instance of a stateField structure that is 1851 * used to return the present operational state setting and 1852 * the present state and event state for a particular set of effecter 1853 * information contained within the state effecter 1854 * @param[out] msg - Message will be written to this 1855 * @param[in] payload_length - Length of response message payload 1856 * @return pldm_completion_codes 1857 */ 1858 int encode_get_state_effecter_states_resp( 1859 uint8_t instance_id, struct pldm_get_state_effecter_states_resp *resp, 1860 struct pldm_msg *msg, size_t payload_length); 1861 1862 /* PlatformEventMessage */ 1863 1864 /** @brief Decode PlatformEventMessage request data 1865 * @param[in] msg - Request message 1866 * @param[in] payload_length - Length of response message payload 1867 * @param[out] format_version - Version of the event format 1868 * @param[out] tid - Terminus ID for the terminus that originated the event 1869 * message 1870 * @param[out] event_class - The class of event being sent 1871 * @param[out] event_data_offset - Offset where the event data should be read 1872 * from pldm msg 1873 * @return pldm_completion_codes 1874 */ 1875 int decode_platform_event_message_req(const struct pldm_msg *msg, 1876 size_t payload_length, 1877 uint8_t *format_version, uint8_t *tid, 1878 uint8_t *event_class, 1879 size_t *event_data_offset); 1880 1881 /** @brief Decode PollForEventMessage request data 1882 * @param[in] msg - Request message 1883 * @param[in] payload_length - Length of response message payload 1884 * @param[out] format_version - Version of the event format 1885 * @param[out] transfer_operation_flag - The transfer operation flag 1886 * @param[out] data_transfer_handle - The data transfer handle 1887 * @param[out] event_id_to_acknowledge - The class of event being sent 1888 * from pldm msg 1889 * @return pldm_completion_codes 1890 */ 1891 int decode_poll_for_platform_event_message_req( 1892 const struct pldm_msg *msg, size_t payload_length, 1893 uint8_t *format_version, uint8_t *transfer_operation_flag, 1894 uint32_t *data_transfer_handle, uint16_t *event_id_to_acknowledge); 1895 1896 /** @brief Encode PlatformEventMessage response data 1897 * @param[in] instance_id - Message's instance id 1898 * @param[in] completion_code - PLDM completion code 1899 * @param[in] platform_event_status - Response status of the event message 1900 * command 1901 * @param[out] msg - Message will be written to this 1902 * @return pldm_completion_codes 1903 * @note Caller is responsible for memory alloc and dealloc of param 1904 * 'msg.payload' 1905 */ 1906 int encode_platform_event_message_resp(uint8_t instance_id, 1907 uint8_t completion_code, 1908 uint8_t platform_event_status, 1909 struct pldm_msg *msg); 1910 1911 /** @brief Encode PollForPlatformEventMessage response data 1912 * @param[in] instance_id - Message's instance id 1913 * @param[in] completion_code - PLDM completion code 1914 * @param[in] tid - Terminus ID 1915 * @param[in] event_id - The event id 1916 * @param[in] next_data_transfer_handle - The next data transfer handle 1917 * @param[in] transfer_flag - The transfer flag 1918 * @param[in] event_class - The event class 1919 * @param[in] event_data_size - The event data size 1920 * @param[in] event_data - The event data 1921 * @param[in] checksum - The checksum 1922 * @param[out] msg - Message will be written to this 1923 * @param[in] payload_length - Length of Response message payload 1924 * @return pldm_completion_codes 1925 * @note Caller is responsible for memory alloc and dealloc of param 1926 * 'msg.payload' 1927 */ 1928 int encode_poll_for_platform_event_message_resp( 1929 uint8_t instance_id, uint8_t completion_code, uint8_t tid, 1930 uint16_t event_id, uint32_t next_data_transfer_handle, 1931 uint8_t transfer_flag, uint8_t event_class, uint32_t event_data_size, 1932 uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg, 1933 size_t payload_length); 1934 1935 /** @brief Encode PlatformEventMessage request data 1936 * @param[in] instance_id - Message's instance id 1937 * @param[in] format_version - Version of the event format 1938 * @param[in] tid - Terminus ID for the terminus that originated the event 1939 * message 1940 * @param[in] event_class - The class of event being sent 1941 * @param[in] event_data - the event data should be read from pldm msg 1942 * @param[in] event_data_length - Length of the event data 1943 * @param[out] msg - Request message 1944 * @return pldm_completion_codes 1945 * @note Caller is responsible for memory alloc and dealloc of param 1946 * 'msg.payload' 1947 */ 1948 int encode_platform_event_message_req( 1949 uint8_t instance_id, uint8_t format_version, uint8_t tid, 1950 uint8_t event_class, const uint8_t *event_data, 1951 size_t event_data_length, struct pldm_msg *msg, size_t payload_length); 1952 1953 /** @brief Encode PollForPlatformEventMessage request data 1954 * @param[in] instance_id - Message's instance id 1955 * @param[in] format_version - Version of the event format 1956 * @param[in] transfer_operation_flag - Transfer operation 1957 * @param[in] data_transfer_handle - The data transfer handle 1958 * @param[in] event_id_to_acknowledge - the event data to acknowleadge 1959 * @param[out] msg - Request message 1960 * @return pldm_completion_codes 1961 * @note Caller is responsible for memory alloc and dealloc of param 1962 * 'msg.payload' 1963 */ 1964 int encode_poll_for_platform_event_message_req(uint8_t instance_id, 1965 uint8_t format_version, 1966 uint8_t transfer_operation_flag, 1967 uint32_t data_transfer_handle, 1968 uint16_t event_id_to_acknowledge, 1969 struct pldm_msg *msg, 1970 size_t payload_length); 1971 1972 /** @brief Decode PollForPlatformEventMessage response data 1973 * @param[in] msg - Request message 1974 * @param[in] payload_length - Length of Response message payload 1975 * @param[out] completion_code - the completion code 1976 * @param[out] tid - the tid 1977 * @param[out] event_id - The event id 1978 * @param[out] next_data_transfer_handle - The next data transfer handle 1979 * @param[out] transfer_flag - The transfer flag 1980 * @param[out] event_class - The event class 1981 * @param[out] event_data_size - The event data size 1982 * @param[out] event_data - The event data. The event_data pointer points into 1983 * msg.payload and therefore has the same lifetime as msg.payload. 1984 * @param[out] event_data_integrity_checksum - The checksum 1985 * command 1986 * @return pldm_completion_codes 1987 * @note Caller is responsible for memory alloc and dealloc of param 1988 * 'msg.payload' 1989 */ 1990 int decode_poll_for_platform_event_message_resp( 1991 const struct pldm_msg *msg, size_t payload_length, 1992 uint8_t *completion_code, uint8_t *tid, uint16_t *event_id, 1993 uint32_t *next_data_transfer_handle, uint8_t *transfer_flag, 1994 uint8_t *event_class, uint32_t *event_data_size, void **event_data, 1995 uint32_t *event_data_integrity_checksum); 1996 1997 /** @brief Decode PlatformEventMessage response data 1998 * @param[in] msg - Request message 1999 * @param[in] payload_length - Length of Response message payload 2000 * @param[out] completion_code - PLDM completion code 2001 * @param[out] platform_event_status - Response status of the event message 2002 * command 2003 * @return pldm_completion_codes 2004 */ 2005 int decode_platform_event_message_resp(const struct pldm_msg *msg, 2006 size_t payload_length, 2007 uint8_t *completion_code, 2008 uint8_t *platform_event_status); 2009 2010 /** @brief Decode EventMessageBufferSize response data 2011 * @param[in] msg - Request message 2012 * @param[in] payload_length - Length of Response message payload 2013 * @param[out] completion_code - PLDM completion code 2014 * @return pldm_completion_codes 2015 */ 2016 int decode_event_message_buffer_size_resp(const struct pldm_msg *msg, 2017 size_t payload_length, 2018 uint8_t *completion_code, 2019 uint16_t *terminus_max_buffer_size); 2020 2021 /** @brief Encode EventMessageBufferSize request data 2022 * @param[in] instance_id - Message's instance id 2023 * @param[in] event_receiver_max_buffer_size - Max buffer size 2024 * @param[out] msg - Request message 2025 * @return pldm_completion_codes 2026 * @note Caller is responsible for memory alloc and dealloc of param 2027 * 'msg.payload' 2028 */ 2029 int encode_event_message_buffer_size_req(uint8_t instance_id, 2030 uint16_t event_receiver_max_buffer_size, 2031 struct pldm_msg *msg); 2032 2033 /** @brief Encode EventMessageSupported request data 2034 * 2035 * @param[in] instance_id - Message's instance id 2036 * @param[in] format_version - Version of the event format 2037 * @param[out] msg - Request message 2038 * 2039 * @return pldm_completion_codes 2040 * @note Caller is responsible for memory alloc and dealloc of param 2041 * 'msg.payload' 2042 */ 2043 int encode_event_message_supported_req(uint8_t instance_id, 2044 uint8_t format_version, 2045 struct pldm_msg *msg); 2046 2047 /** @brief Decode EventMessageSupported response data 2048 * 2049 * @param[in] msg - Request message 2050 * @param[in] payload_length - Length of Response message payload 2051 * @param[out] completion_code - PLDM completion code 2052 * @param[out] synchrony_config - the synchrony configuration 2053 * @param[out] synchrony_config_support - the synchrony configuration support 2054 * @param[out] number_event_class_returned - PLDM completion code 2055 * @param[out] event_class - the event classes 2056 * @param[in] event_class_count - the event class count 2057 * 2058 * @return pldm_completion_codes 2059 */ 2060 int decode_event_message_supported_resp(const struct pldm_msg *msg, 2061 size_t payload_length, 2062 uint8_t *completion_code, 2063 uint8_t *synchrony_config, 2064 bitfield8_t *synchrony_config_support, 2065 uint8_t *number_event_class_returned, 2066 uint8_t *event_class, 2067 uint8_t event_class_count); 2068 2069 /** @brief Decode sensorEventData response data 2070 * 2071 * @param[in] event_data - event data from the response message 2072 * @param[in] event_data_length - length of the event data 2073 * @param[out] sensor_id - sensorID value of the sensor 2074 * @param[out] sensor_event_class_type - Type of sensor event class 2075 * @param[out] event_class_data_offset - Offset where the event class data 2076 * should be read from event data 2077 * @return pldm_completion_codes 2078 * @note Caller is responsible for memory alloc and dealloc of param 2079 * 'event_data' 2080 */ 2081 int decode_sensor_event_data(const uint8_t *event_data, 2082 size_t event_data_length, uint16_t *sensor_id, 2083 uint8_t *sensor_event_class_type, 2084 size_t *event_class_data_offset); 2085 2086 /** @brief Decode sensorOpState response data 2087 * 2088 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState 2089 * @param[in] sensor_data_length - Length of sensor_data 2090 * @param[out] present_op_state - The sensorOperationalState value from the 2091 * state change that triggered the event message 2092 * @param[out] previous_op_state - The sensorOperationalState value for the 2093 * state from which the present state was entered 2094 * @return pldm_completion_codes 2095 * @note Caller is responsible for memory alloc and dealloc of param 2096 * 'sensor_data' 2097 */ 2098 int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length, 2099 uint8_t *present_op_state, 2100 uint8_t *previous_op_state); 2101 2102 /** @brief Decode stateSensorState response data 2103 * 2104 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState 2105 * @param[in] sensor_data_length - Length of sensor_data 2106 * @param[out] sensor_offset - Identifies which state sensor within a composite 2107 * state sensor the event is being returned for 2108 * @param[out] event_state - The event state value from the state change that 2109 * triggered the event message 2110 * @param[out] previous_event_state - The event state value for the state from 2111 * which the present event state was entered 2112 * @return pldm_completion_codes 2113 * @note Caller is responsible for memory alloc and dealloc of param 2114 * 'sensor_data' 2115 */ 2116 int decode_state_sensor_data(const uint8_t *sensor_data, 2117 size_t sensor_data_length, uint8_t *sensor_offset, 2118 uint8_t *event_state, 2119 uint8_t *previous_event_state); 2120 2121 /** @brief Decode numericSensorState response data 2122 * 2123 * @param[in] sensor_data - sensor_data for sensorEventClass = 2124 * numericSensorState 2125 * @param[in] sensor_data_length - Length of sensor_data 2126 * @param[out] event_state - The eventState value from the state change that 2127 * triggered the event message 2128 * @param[out] previous_event_state - The eventState value for the state from 2129 * which the present state was entered 2130 * @param[out] sensor_data_size - The bit width and format of reading and 2131 * threshold values that the sensor returns 2132 * @param[out] present_reading - The present value indicated by the sensor 2133 * @return pldm_completion_codes 2134 * @note Caller is responsible for memory alloc and dealloc of param 2135 * 'sensor_data' 2136 */ 2137 int decode_numeric_sensor_data(const uint8_t *sensor_data, 2138 size_t sensor_data_length, uint8_t *event_state, 2139 uint8_t *previous_event_state, 2140 uint8_t *sensor_data_size, 2141 uint32_t *present_reading); 2142 2143 /** @brief Decode Numeric Sensor Pdr data 2144 * 2145 * @param[in] pdr_data - pdr data for numeric sensor 2146 * @param[in] pdr_data_length - Length of pdr data 2147 * @param[out] pdr_value - unpacked numeric sensor PDR struct 2148 */ 2149 int decode_numeric_sensor_pdr_data( 2150 const void *pdr_data, size_t pdr_data_length, 2151 struct pldm_numeric_sensor_value_pdr *pdr_value); 2152 2153 /* GetNumericEffecterValue */ 2154 2155 /** @brief Create a PLDM request message for GetNumericEffecterValue 2156 * 2157 * @param[in] instance_id - Message's instance id 2158 * @param[in] effecter_id - used to identify and access the effecter 2159 * @param[out] msg - Message will be written to this 2160 * @return pldm_completion_codes 2161 * @note Caller is responsible for memory alloc and dealloc of param 2162 * 'msg.payload' 2163 */ 2164 int encode_get_numeric_effecter_value_req(uint8_t instance_id, 2165 uint16_t effecter_id, 2166 struct pldm_msg *msg); 2167 2168 /** @brief Create a PLDM response message for GetNumericEffecterValue 2169 * 2170 * @param[in] msg - Request message 2171 * @param[in] payload_length - Length of request message payload 2172 * @param[out] completion_code - PLDM completion code 2173 * @param[out] effecter_data_size - The bit width and format of the setting 2174 * value for the effecter. 2175 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 2176 * @param[out] effecter_oper_state - The state of the effecter itself 2177 * @param[out] pending_value - The pending numeric value setting of the 2178 * effecter. The effecterDataSize field indicates the number of 2179 * bits used for this field 2180 * @param[out] present_value - The present numeric value setting of the 2181 * effecter. The effecterDataSize indicates the number of bits 2182 * used for this field 2183 * @return pldm_completion_codes 2184 */ 2185 int decode_get_numeric_effecter_value_resp(const struct pldm_msg *msg, 2186 size_t payload_length, 2187 uint8_t *completion_code, 2188 uint8_t *effecter_data_size, 2189 uint8_t *effecter_oper_state, 2190 uint8_t *pending_value, 2191 uint8_t *present_value); 2192 2193 /** @brief Decode pldmPDRRepositoryChgEvent response data 2194 * 2195 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent 2196 * @param[in] event_data_size - Length of event_data 2197 * @param[out] event_data_format - This field indicates if the changedRecords 2198 * are of PDR Types or PDR Record Handles 2199 * @param[out] number_of_change_records - The number of changeRecords following 2200 * this field 2201 * @param[out] change_record_data_offset - Identifies where changeRecord data 2202 * is located within event_data 2203 * @return pldm_completion_codes 2204 * @note Caller is responsible for memory alloc and dealloc of param 2205 * 'event_data' 2206 */ 2207 int decode_pldm_pdr_repository_chg_event_data( 2208 const uint8_t *event_data, size_t event_data_size, 2209 uint8_t *event_data_format, uint8_t *number_of_change_records, 2210 size_t *change_record_data_offset); 2211 2212 /** @brief Decode pldmMessagePollEvent event data type 2213 * 2214 * @param[in] event_data - event data from the response message 2215 * @param[in] event_data_length - length of the event data 2216 * @param[out] poll_event - the decoded pldm_message_poll_event struct 2217 * @return error code 2218 * @note Caller is responsible for memory alloc and dealloc of param 2219 * 'event_data' 2220 */ 2221 int decode_pldm_message_poll_event_data( 2222 const void *event_data, size_t event_data_length, 2223 struct pldm_message_poll_event *poll_event); 2224 2225 /** @brief Encode pldmMessagePollEvent event data type 2226 * 2227 * @param[in] poll_event - the encoded pldm_message_poll_event struct 2228 * @param[out] event_data - event data to the response message 2229 * @param[in] event_data_length - length of the event data 2230 * @return error code 2231 * @note The caller is responsible for allocating and deallocating the 2232 * event_data 2233 */ 2234 int encode_pldm_message_poll_event_data( 2235 const struct pldm_message_poll_event *poll_event, void *event_data, 2236 size_t event_data_length); 2237 2238 /** @brief Encode PLDM PDR Repository Change eventData 2239 * @param[in] event_data_format - Format of this event data (e.g. 2240 * FORMAT_IS_PDR_HANDLES) 2241 * @param[in] number_of_change_records - Number of changeRecords in this 2242 * eventData 2243 * @param[in] event_data_operations - Array of eventDataOperations 2244 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array 2245 * should contain number_of_change_records elements. 2246 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys 2247 * for each changeRecord in this eventData. This array should contain 2248 * number_of_change_records elements. 2249 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys, 2250 * one array per changeRecord in this eventData. The toplevel array should 2251 * contain number_of_change_records elements. Each subarray [i] should 2252 * contain numbers_of_change_entries[i] elements. 2253 * @param[in] event_data - The eventData will be encoded into this. This entire 2254 * structure must be max_change_records_size long. It must be large enough 2255 * to accommodate the data to be encoded. The caller is responsible for 2256 * allocating and deallocating it, including the variable-size 2257 * 'event_data.change_records' field. If this parameter is NULL, 2258 * PLDM_SUCCESS will be returned and actual_change_records_size will be set 2259 * to reflect the required size of the structure. 2260 * @param[out] actual_change_records_size - The actual number of meaningful 2261 * encoded bytes in event_data. The caller can over-allocate memory and use 2262 * this output to determine the real size of the structure. 2263 * @param[in] max_change_records_size - The size of event_data in bytes. If the 2264 * encoded message would be larger than this value, an error is returned. 2265 * @return pldm_completion_codes 2266 * @note Caller is responsible for memory alloc and dealloc of param 2267 * 'event_data.change_records' 2268 */ 2269 int encode_pldm_pdr_repository_chg_event_data( 2270 uint8_t event_data_format, uint8_t number_of_change_records, 2271 const uint8_t *event_data_operations, 2272 const uint8_t *numbers_of_change_entries, 2273 const uint32_t *const *change_entries, 2274 struct pldm_pdr_repository_chg_event_data *event_data, 2275 size_t *actual_change_records_size, size_t max_change_records_size); 2276 2277 /** @brief Encode event data for a PLDM Sensor Event 2278 * 2279 * @param[out] event_data The object to store the encoded event in 2280 * @param[in] event_data_size Size of the allocation for event_data 2281 * @param[in] sensor_id Sensor ID 2282 * @param[in] sensor_event_class Sensor event class 2283 * @param[in] sensor_offset Offset 2284 * @param[in] event_state Event state 2285 * @param[in] previous_event_state Previous event state 2286 * @param[out] actual_event_data_size The real size in bytes of the event_data 2287 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH 2288 * @note If event_data is NULL, then *actual_event_data_size will be set to 2289 * reflect the size of the event data, and PLDM_SUCCESS will be returned. 2290 * @note The caller is responsible for allocating and deallocating the 2291 * event_data 2292 */ 2293 int encode_sensor_event_data(struct pldm_sensor_event_data *event_data, 2294 size_t event_data_size, uint16_t sensor_id, 2295 enum sensor_event_class_states sensor_event_class, 2296 uint8_t sensor_offset, uint8_t event_state, 2297 uint8_t previous_event_state, 2298 size_t *actual_event_data_size); 2299 2300 /** @brief Decode PldmPDRRepositoryChangeRecord response data 2301 * 2302 * @param[in] change_record_data - changeRecordData for 2303 * pldmPDRRepositoryChgEvent 2304 * @param[in] change_record_data_size - Length of change_record_data 2305 * @param[out] event_data_operation - This field indicates the changeEntries 2306 * operation types 2307 * @param[out] number_of_change_entries - The number of changeEntries following 2308 * this field 2309 * @param[out] change_entry_data_offset - Identifies where changeEntries data 2310 * is located within change_record_data 2311 * @return pldm_completion_codes 2312 * @note Caller is responsible for memory alloc and dealloc of param 2313 * 'change_record_data' 2314 */ 2315 int decode_pldm_pdr_repository_change_record_data( 2316 const uint8_t *change_record_data, size_t change_record_data_size, 2317 uint8_t *event_data_operation, uint8_t *number_of_change_entries, 2318 size_t *change_entry_data_offset); 2319 2320 /* GetSensorReading */ 2321 2322 /** @brief Encode GetSensorReading request data 2323 * 2324 * @param[in] instance_id - Message's instance id 2325 * @param[in] sensor_id - A handle that is used to identify and access the 2326 * sensor 2327 * @param[in] rearm_event_state - true = manually re-arm EventState after 2328 * responding to this request, false = no manual re-arm 2329 * @param[out] msg - Message will be written to this 2330 * @return pldm_completion_codes 2331 * @note Caller is responsible for memory alloc and dealloc of param 2332 * 'msg.payload' 2333 */ 2334 int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id, 2335 bool8_t rearm_event_state, 2336 struct pldm_msg *msg); 2337 2338 /** @brief Decode GetSensorReading response data 2339 * 2340 * @param[in] msg - Request message 2341 * @param[in] payload_length - Length of response message payload 2342 * @param[out] completion_code - PLDM completion code 2343 * @param[out] sensor_data_size - The bit width and format of reading and 2344 * threshold values 2345 * @param[out] sensor_operational_state - The state of the sensor itself 2346 * @param[out] sensor_event_message_enable - value: { noEventGeneration, 2347 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled, 2348 * stateEventsOnlyEnabled } 2349 * @param[out] present_state - The most recently assessed state value monitored 2350 * by the sensor 2351 * @param[out] previous_state - The state that the presentState was entered 2352 * from 2353 * @param[out] event_state - Indicates which threshold crossing assertion 2354 * events have been detected 2355 * @param[out] present_reading - The present value indicated by the sensor 2356 * @return pldm_completion_codes 2357 */ 2358 2359 int decode_get_sensor_reading_resp( 2360 const struct pldm_msg *msg, size_t payload_length, 2361 uint8_t *completion_code, uint8_t *sensor_data_size, 2362 uint8_t *sensor_operational_state, uint8_t *sensor_event_message_enable, 2363 uint8_t *present_state, uint8_t *previous_state, uint8_t *event_state, 2364 uint8_t *present_reading); 2365 2366 /** @brief Encode the SetEventReceiver request message 2367 * 2368 * @param[in] instance_id - Message's instance id 2369 * @param[in] event_message_global_enable - This value is used to enable or 2370 * disable event message generation from the terminus value: { 2371 * disable, enableAsync, enablePolling, enableAsyncKeepAlive } 2372 * @param[in] transport_protocol_type - This value is provided in the request 2373 * to help the responder verify that the content of the 2374 * eventReceiverAddressInfo field used in this request is correct for 2375 * the messaging protocol supported by the terminus. 2376 * @param[in] event_receiver_address_info - this value is a medium and 2377 * protocol-specific address that the responder should use when 2378 * transmitting event messages using the indicated protocol 2379 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing 2380 * of which the terminus shall emit a heartbeat event to the receiver 2381 * @param[out] msg - Argument to capture the Message 2382 * @return pldm_completion_codes 2383 */ 2384 int encode_set_event_receiver_req(uint8_t instance_id, 2385 uint8_t event_message_global_enable, 2386 uint8_t transport_protocol_type, 2387 uint8_t event_receiver_address_info, 2388 uint16_t heartbeat_timer, 2389 struct pldm_msg *msg); 2390 2391 /** @brief Decode the SetEventReceiver response message 2392 * 2393 * @param[in] msg - Request message 2394 * @param[in] payload_length - Length of response message payload 2395 * @param[out] completion_code - PLDM completion code 2396 * @return pldm_completion_codes 2397 */ 2398 int decode_set_event_receiver_resp(const struct pldm_msg *msg, 2399 size_t payload_length, 2400 uint8_t *completion_code); 2401 2402 /** @brief Decode the SetEventReceiver request message 2403 * 2404 * @param[in] msg - Request message 2405 * @param[in] payload_length - Length of request message payload 2406 * @param[out] event_message_global_enable - This value is used to enable or 2407 * disable event message generation from the terminus value: { 2408 * disable, enableAsync, enablePolling, enableAsyncKeepAlive } 2409 * @param[out] transport_protocol_type - This value is provided in the request 2410 * to help the responder verify that the content of the 2411 * eventReceiverAddressInfo field used in this request is correct for 2412 * the messaging protocol supported by the terminus. 2413 * @param[out] event_receiver_address_info - This value is a medium and 2414 * protocol-specific address that the responder should use when 2415 * transmitting event messages using the indicated protocol 2416 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing 2417 * of which the terminus shall emit a heartbeat event to the receiver 2418 * @return pldm_completion_codes 2419 */ 2420 int decode_set_event_receiver_req(const struct pldm_msg *msg, 2421 size_t payload_length, 2422 uint8_t *event_message_global_enable, 2423 uint8_t *transport_protocol_type, 2424 uint8_t *event_receiver_address_info, 2425 uint16_t *heartbeat_timer); 2426 2427 /** @brief Encode the SetEventReceiver response message 2428 * 2429 * @param[in] instance_id - Message's instance id 2430 * @param[in] completion_code - PLDM completion code 2431 * @param[out] msg - Argument to capture the Message 2432 * @return pldm_completion_codes 2433 */ 2434 int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code, 2435 struct pldm_msg *msg); 2436 2437 /** @brief Decode Numeric effecter Pdr data 2438 * 2439 * @param[in] pdr_data - PDR data of the numeric effecter in DSP0248_1.2.2 2440 * table 87. This must be a pointer to the PDR data in the GetPDR 2441 * message body 2442 * @param[in] pdr_data_length - Length of pdr data 2443 * @param[out] pdr_value - the numeric effecter PDR data struct 2444 */ 2445 int decode_numeric_effecter_pdr_data( 2446 const void *pdr_data, size_t pdr_data_length, 2447 struct pldm_numeric_effecter_value_pdr *pdr_value); 2448 2449 /** @brief Decode date fields from Entity Auxiliary name PDR 2450 * 2451 * @note Use case: 2452 * 1. Call `decode_entity_auxiliary_names_pdr()` to decode the Entity 2453 * Auxiliary names PDR raw data to the PDR data fields in 2454 * `struct pldm_entity_auxiliary_names_pdr` equivalent the fields in 2455 * `table 95` of DSP0248_1.2.2. Excepts the entity language tags and 2456 * names. 2457 * 2. Use the decoded `name_string_count` and size of 2458 * `struct pldm_entity_auxiliary_name` to allocate memory for the 2459 * `struct pldm_entity_auxiliary_name *names` field in 2460 * `struct pldm_entity_auxiliary_names_pdr`. 2461 * 3. Call `decode_pldm_entity_auxiliary_names_pdr_index()` to decode 2462 * `auxiliary_name_data[]` in `struct pldm_entity_auxiliary_names_pdr` 2463 * to the entity language tags and names in 2464 * `struct pldm_entity_auxiliary_name`. 2465 * 2466 * @param[in] data - PLDM response message which includes the entity 2467 * auxiliary name PDRs in DSP0248_1.2.2 table 95. 2468 * @param[in] data_length - Length of response message payload 2469 * @param[out] pdr - Entity auxiliary names pdr struct 2470 * @param[out] pdr_length - Entity auxiliary names pdr struct 2471 * 2472 * @return error code 2473 */ 2474 int decode_entity_auxiliary_names_pdr( 2475 const void *data, size_t data_length, 2476 struct pldm_entity_auxiliary_names_pdr *pdr, size_t pdr_length); 2477 2478 /** @brief Decode Entity Auxiliary name data. The API will update the name 2479 * directly to names field in the pdr struct. 2480 * 2481 * @pre The API will decode `auxiliary_name_data[]` array in 2482 * `struct pldm_entity_auxiliary_names_pdr pdr` to 2483 * the entity auxiliary language tags and names in 2484 * `struct pldm_entity_auxiliary_name *names` of the same pdr struct. 2485 * Before call the API, the caller has to allocate memory for the `names` 2486 * struct with the number of name(`name_string_count`) in PDR and size of 2487 * `struct pldm_entity_auxiliary_name`. 2488 * The value of `auxiliary_name_data` and `name_string_count` are decoded 2489 * by `decode_entity_auxiliary_names_pdr()` method so the caller has to 2490 * call that API first. 2491 * 2492 * @param[out] pdr_value - Entity auxiliary names pdr struct 2493 * @param[in] names_size - Size of names data 2494 * @return error code 2495 */ 2496 int decode_pldm_entity_auxiliary_names_pdr_index( 2497 struct pldm_entity_auxiliary_names_pdr *pdr_value); 2498 2499 /** @brief Decode PLDM Platform CPER event data type 2500 * 2501 * @param[in] event_data - event data from the response message 2502 * @param[in] event_data_length - length of the event data 2503 * @param[out] cper_event - the decoded pldm_platform_cper_event struct 2504 * @param[in] cper_event_length - the length of cper event 2505 * @return error code 2506 */ 2507 int decode_pldm_platform_cper_event(const void *event_data, 2508 size_t event_data_length, 2509 struct pldm_platform_cper_event *cper_event, 2510 size_t cper_event_length); 2511 2512 /** @brief Helper function to response CPER event event data 2513 * 2514 * @param[in] cper_event - the decoded pldm_platform_cper_event struct 2515 * @return cper event event data array pointer 2516 */ 2517 uint8_t * 2518 pldm_platform_cper_event_event_data(struct pldm_platform_cper_event *event); 2519 #ifdef __cplusplus 2520 } 2521 #endif 2522 2523 #endif /* PLATFORM_H */ 2524