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