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