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