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