Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 1 | #pragma once |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include <stdint.h> |
| 4 | |
Vernon Mauery | e08fbff | 2019-04-03 09:19:34 -0700 | [diff] [blame] | 5 | #include <ipmid/api.hpp> |
Vernon Mauery | 3325024 | 2019-03-12 16:49:26 -0700 | [diff] [blame] | 6 | #include <ipmid/types.hpp> |
| 7 | |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 8 | #include <exception> |
| 9 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 10 | /** |
| 11 | * @enum device_type |
| 12 | * IPMI FRU device types |
| 13 | */ |
| 14 | enum device_type |
| 15 | { |
| 16 | IPMI_PHYSICAL_FRU = 0x00, |
| 17 | IPMI_LOGICAL_FRU = 0x80, |
| 18 | }; |
| 19 | |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 20 | // Discrete sensor types. |
| 21 | enum ipmi_sensor_types |
| 22 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 23 | IPMI_SENSOR_TEMP = 0x01, |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 24 | IPMI_SENSOR_VOLTAGE = 0x02, |
| 25 | IPMI_SENSOR_CURRENT = 0x03, |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 26 | IPMI_SENSOR_FAN = 0x04, |
| 27 | IPMI_SENSOR_TPM = 0xCC, |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
Brandon Kim | 9cf8562 | 2019-06-19 12:05:08 -0700 | [diff] [blame] | 30 | /** @brief Custom exception for reading sensors that are not funcitonal. |
| 31 | */ |
| 32 | struct SensorFunctionalError : public std::exception |
| 33 | { |
| 34 | const char* what() const noexcept |
| 35 | { |
| 36 | return "Sensor not functional"; |
| 37 | } |
| 38 | }; |
| 39 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 40 | #define MAX_DBUS_PATH 128 |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 41 | struct dbus_interface_t |
| 42 | { |
| 43 | uint8_t sensornumber; |
| 44 | uint8_t sensortype; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 45 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 46 | char bus[MAX_DBUS_PATH]; |
| 47 | char path[MAX_DBUS_PATH]; |
| 48 | char interface[MAX_DBUS_PATH]; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 49 | }; |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 50 | |
Jia, Chunhui | 3342a8e | 2018-12-29 13:32:26 +0800 | [diff] [blame] | 51 | struct PlatformEventRequest |
| 52 | { |
| 53 | uint8_t eventMessageRevision; |
| 54 | uint8_t sensorType; |
| 55 | uint8_t sensorNumber; |
| 56 | uint8_t eventDirectionType; |
| 57 | uint8_t data[3]; |
| 58 | }; |
| 59 | |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 60 | static constexpr const char* ipmiSELPath = "/xyz/openbmc_project/Logging/IPMI"; |
| 61 | static constexpr const char* ipmiSELAddInterface = |
Jia, Chunhui | 3342a8e | 2018-12-29 13:32:26 +0800 | [diff] [blame] | 62 | "xyz.openbmc_project.Logging.IPMI"; |
Konstantin Aladyshev | b5160f5 | 2023-04-19 14:45:06 +0300 | [diff] [blame] | 63 | static const std::string ipmiSELAddMessage = "IPMI generated SEL Entry"; |
Jia, Chunhui | 3342a8e | 2018-12-29 13:32:26 +0800 | [diff] [blame] | 64 | |
| 65 | static constexpr int selSystemEventSizeWith3Bytes = 8; |
| 66 | static constexpr int selSystemEventSizeWith2Bytes = 7; |
| 67 | static constexpr int selSystemEventSizeWith1Bytes = 6; |
| 68 | static constexpr int selIPMBEventSize = 7; |
| 69 | static constexpr uint8_t directionMask = 0x80; |
| 70 | static constexpr uint8_t byte3EnableMask = 0x30; |
| 71 | static constexpr uint8_t byte2EnableMask = 0xC0; |
| 72 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 73 | int set_sensor_dbus_state_s(uint8_t, const char*, const char*); |
| 74 | int set_sensor_dbus_state_y(uint8_t, const char*, const uint8_t); |
| 75 | int find_openbmc_path(uint8_t, dbus_interface_t*); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 76 | |
George Liu | c7a4da5 | 2025-08-19 16:20:31 +0800 | [diff] [blame^] | 77 | ipmi::RspType<uint16_t, std::vector<uint8_t>> ipmiSensorGetSdr( |
| 78 | uint16_t, uint16_t, uint8_t, uint8_t); |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 79 | |
jayaprakash Mutyala | d957823 | 2019-05-13 20:22:50 +0000 | [diff] [blame] | 80 | ipmi::RspType<uint16_t> ipmiSensorReserveSdr(); |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 81 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 82 | static const uint16_t FRU_RECORD_ID_START = 256; |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 83 | static const uint16_t ENTITY_RECORD_ID_START = 512; |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 84 | static const uint8_t SDR_VERSION = 0x51; |
| 85 | static const uint16_t END_OF_RECORD = 0xFFFF; |
| 86 | static const uint8_t LENGTH_MASK = 0x1F; |
| 87 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 88 | /** |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 89 | * Get SDR |
| 90 | */ |
| 91 | namespace get_sdr |
| 92 | { |
| 93 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 94 | // Record header |
| 95 | struct SensorDataRecordHeader |
| 96 | { |
George Liu | c7a4da5 | 2025-08-19 16:20:31 +0800 | [diff] [blame^] | 97 | uint16_t recordId; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 98 | uint8_t sdr_version; |
| 99 | uint8_t record_type; |
| 100 | uint8_t record_length; // Length not counting the header |
| 101 | } __attribute__((packed)); |
| 102 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 103 | enum SensorDataRecordType |
| 104 | { |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 105 | SENSOR_DATA_FULL_RECORD = 0x1, |
selvaganapathi | 7b2e550 | 2023-02-14 07:10:47 +0530 | [diff] [blame] | 106 | SENSOR_DATA_COMPACT_RECORD = 0x2, |
Hao Jiang | da06d15 | 2021-01-19 15:27:43 -0800 | [diff] [blame] | 107 | SENSOR_DATA_EVENT_RECORD = 0x3, |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 108 | SENSOR_DATA_ENTITY_RECORD = 0x8, |
Harvey Wu | a347627 | 2023-03-22 10:09:38 +0800 | [diff] [blame] | 109 | SENSOR_DATA_FRU_RECORD = 0x11, |
| 110 | SENSOR_DATA_MGMT_CTRL_LOCATOR = 0x12, |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | // Record key |
| 114 | struct SensorDataRecordKey |
| 115 | { |
| 116 | uint8_t owner_id; |
| 117 | uint8_t owner_lun; |
| 118 | uint8_t sensor_number; |
| 119 | } __attribute__((packed)); |
| 120 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 121 | /** @struct SensorDataFruRecordKey |
| 122 | * |
| 123 | * FRU Device Locator Record(key) - SDR Type 11 |
| 124 | */ |
| 125 | struct SensorDataFruRecordKey |
| 126 | { |
| 127 | uint8_t deviceAddress; |
| 128 | uint8_t fruID; |
| 129 | uint8_t accessLun; |
| 130 | uint8_t channelNumber; |
| 131 | } __attribute__((packed)); |
| 132 | |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 133 | /** @struct SensorDataEntityRecordKey |
| 134 | * |
| 135 | * Entity Association Record(key) - SDR Type 8 |
| 136 | */ |
| 137 | struct SensorDataEntityRecordKey |
| 138 | { |
| 139 | uint8_t containerEntityId; |
| 140 | uint8_t containerEntityInstance; |
| 141 | uint8_t flags; |
| 142 | uint8_t entityId1; |
| 143 | uint8_t entityInstance1; |
| 144 | } __attribute__((packed)); |
| 145 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 146 | namespace key |
| 147 | { |
| 148 | |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 149 | static constexpr uint8_t listOrRangeBit = 7; |
| 150 | static constexpr uint8_t linkedBit = 6; |
| 151 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 152 | inline void set_owner_id_ipmb(SensorDataRecordKey* key) |
| 153 | { |
| 154 | key->owner_id &= ~0x01; |
| 155 | }; |
| 156 | |
| 157 | inline void set_owner_id_system_sw(SensorDataRecordKey* key) |
| 158 | { |
| 159 | key->owner_id |= 0x01; |
| 160 | }; |
| 161 | |
Tom Joseph | 9642391 | 2018-01-25 00:14:34 +0530 | [diff] [blame] | 162 | inline void set_owner_id_bmc(SensorDataRecordKey* key) |
| 163 | { |
| 164 | key->owner_id |= 0x20; |
| 165 | }; |
| 166 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 167 | inline void set_owner_id_address(uint8_t addr, SensorDataRecordKey* key) |
| 168 | { |
| 169 | key->owner_id &= 0x01; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 170 | key->owner_id |= addr << 1; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | inline void set_owner_lun(uint8_t lun, SensorDataRecordKey* key) |
| 174 | { |
| 175 | key->owner_lun &= ~0x03; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 176 | key->owner_lun |= (lun & 0x03); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | inline void set_owner_lun_channel(uint8_t channel, SensorDataRecordKey* key) |
| 180 | { |
| 181 | key->owner_lun &= 0x0f; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 182 | key->owner_lun |= ((channel & 0xf) << 4); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 185 | inline void set_flags(bool isList, bool isLinked, |
| 186 | SensorDataEntityRecordKey* key) |
| 187 | { |
| 188 | key->flags = 0x00; |
| 189 | if (!isList) |
| 190 | key->flags |= 1 << listOrRangeBit; |
| 191 | |
| 192 | if (isLinked) |
| 193 | key->flags |= 1 << linkedBit; |
| 194 | }; |
| 195 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 196 | } // namespace key |
| 197 | |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 198 | /** @struct GetSensorThresholdsResponse |
| 199 | * |
| 200 | * Response structure for Get Sensor Thresholds command |
| 201 | */ |
| 202 | struct GetSensorThresholdsResponse |
| 203 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 204 | uint8_t validMask; //!< valid mask |
| 205 | uint8_t lowerNonCritical; //!< lower non-critical threshold |
| 206 | uint8_t lowerCritical; //!< lower critical threshold |
| 207 | uint8_t lowerNonRecoverable; //!< lower non-recoverable threshold |
| 208 | uint8_t upperNonCritical; //!< upper non-critical threshold |
| 209 | uint8_t upperCritical; //!< upper critical threshold |
| 210 | uint8_t upperNonRecoverable; //!< upper non-recoverable threshold |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 211 | } __attribute__((packed)); |
| 212 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 213 | // Body - full record |
| 214 | #define FULL_RECORD_ID_STR_MAX_LENGTH 16 |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 215 | |
| 216 | static const int FRU_RECORD_DEVICE_ID_MAX_LENGTH = 16; |
| 217 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 218 | struct SensorDataFullRecordBody |
| 219 | { |
| 220 | uint8_t entity_id; |
| 221 | uint8_t entity_instance; |
| 222 | uint8_t sensor_initialization; |
| 223 | uint8_t sensor_capabilities; // no macro support |
| 224 | uint8_t sensor_type; |
| 225 | uint8_t event_reading_type; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 226 | uint8_t supported_assertions[2]; // no macro support |
| 227 | uint8_t supported_deassertions[2]; // no macro support |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 228 | uint8_t discrete_reading_setting_mask[2]; // no macro support |
| 229 | uint8_t sensor_units_1; |
| 230 | uint8_t sensor_units_2_base; |
| 231 | uint8_t sensor_units_3_modifier; |
| 232 | uint8_t linearization; |
| 233 | uint8_t m_lsb; |
| 234 | uint8_t m_msb_and_tolerance; |
| 235 | uint8_t b_lsb; |
| 236 | uint8_t b_msb_and_accuracy_lsb; |
| 237 | uint8_t accuracy_and_sensor_direction; |
| 238 | uint8_t r_b_exponents; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 239 | uint8_t analog_characteristic_flags; // no macro support |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 240 | uint8_t nominal_reading; |
| 241 | uint8_t normal_max; |
| 242 | uint8_t normal_min; |
| 243 | uint8_t sensor_max; |
| 244 | uint8_t sensor_min; |
| 245 | uint8_t upper_nonrecoverable_threshold; |
| 246 | uint8_t upper_critical_threshold; |
| 247 | uint8_t upper_noncritical_threshold; |
| 248 | uint8_t lower_nonrecoverable_threshold; |
| 249 | uint8_t lower_critical_threshold; |
| 250 | uint8_t lower_noncritical_threshold; |
| 251 | uint8_t positive_threshold_hysteresis; |
| 252 | uint8_t negative_threshold_hysteresis; |
| 253 | uint16_t reserved; |
| 254 | uint8_t oem_reserved; |
| 255 | uint8_t id_string_info; |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 256 | char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 257 | } __attribute__((packed)); |
| 258 | |
selvaganapathi | 7b2e550 | 2023-02-14 07:10:47 +0530 | [diff] [blame] | 259 | /** @struct SensorDataCompactRecord |
| 260 | * |
| 261 | * Compact Sensor Record(body) - SDR Type 2 |
| 262 | */ |
| 263 | struct SensorDataCompactRecordBody |
| 264 | { |
| 265 | uint8_t entity_id; |
| 266 | uint8_t entity_instance; |
| 267 | uint8_t sensor_initialization; |
| 268 | uint8_t sensor_capabilities; // no macro support |
| 269 | uint8_t sensor_type; |
| 270 | uint8_t event_reading_type; |
| 271 | uint8_t supported_assertions[2]; // no macro support |
| 272 | uint8_t supported_deassertions[2]; // no macro support |
| 273 | uint8_t discrete_reading_setting_mask[2]; // no macro support |
| 274 | uint8_t sensor_units_1; |
| 275 | uint8_t sensor_units_2_base; |
| 276 | uint8_t sensor_units_3_modifier; |
| 277 | uint8_t record_sharing[2]; |
| 278 | uint8_t positive_threshold_hysteresis; |
| 279 | uint8_t negative_threshold_hysteresis; |
| 280 | uint8_t reserved[3]; |
| 281 | uint8_t oem_reserved; |
| 282 | uint8_t id_string_info; |
| 283 | char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; |
| 284 | } __attribute__((packed)); |
| 285 | |
Hao Jiang | da06d15 | 2021-01-19 15:27:43 -0800 | [diff] [blame] | 286 | /** @struct SensorDataEventRecord |
| 287 | * |
| 288 | * Event Only Sensor Record(body) - SDR Type 3 |
| 289 | */ |
| 290 | struct SensorDataEventRecordBody |
| 291 | { |
| 292 | uint8_t entity_id; |
| 293 | uint8_t entity_instance; |
| 294 | uint8_t sensor_type; |
| 295 | uint8_t event_reading_type; |
| 296 | uint8_t sensor_record_sharing_1; |
| 297 | uint8_t sensor_record_sharing_2; |
| 298 | uint8_t reserved; |
| 299 | uint8_t oem_reserved; |
| 300 | uint8_t id_string_info; |
| 301 | char id_string[FULL_RECORD_ID_STR_MAX_LENGTH]; |
| 302 | } __attribute__((packed)); |
| 303 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 304 | /** @struct SensorDataFruRecordBody |
| 305 | * |
| 306 | * FRU Device Locator Record(body) - SDR Type 11 |
| 307 | */ |
| 308 | struct SensorDataFruRecordBody |
| 309 | { |
| 310 | uint8_t reserved; |
| 311 | uint8_t deviceType; |
| 312 | uint8_t deviceTypeModifier; |
| 313 | uint8_t entityID; |
| 314 | uint8_t entityInstance; |
| 315 | uint8_t oem; |
| 316 | uint8_t deviceIDLen; |
| 317 | char deviceID[FRU_RECORD_DEVICE_ID_MAX_LENGTH]; |
| 318 | } __attribute__((packed)); |
| 319 | |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 320 | /** @struct SensorDataEntityRecordBody |
| 321 | * |
| 322 | * Entity Association Record(body) - SDR Type 8 |
| 323 | */ |
| 324 | struct SensorDataEntityRecordBody |
| 325 | { |
| 326 | uint8_t entityId2; |
| 327 | uint8_t entityInstance2; |
| 328 | uint8_t entityId3; |
| 329 | uint8_t entityInstance3; |
| 330 | uint8_t entityId4; |
| 331 | uint8_t entityInstance4; |
| 332 | } __attribute__((packed)); |
| 333 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 334 | namespace body |
| 335 | { |
| 336 | |
| 337 | inline void set_entity_instance_number(uint8_t n, |
| 338 | SensorDataFullRecordBody* body) |
| 339 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 340 | body->entity_instance &= 1 << 7; |
| 341 | body->entity_instance |= (n & ~(1 << 7)); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 342 | }; |
| 343 | inline void set_entity_physical_entity(SensorDataFullRecordBody* body) |
| 344 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 345 | body->entity_instance &= ~(1 << 7); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 346 | }; |
| 347 | inline void set_entity_logical_container(SensorDataFullRecordBody* body) |
| 348 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 349 | body->entity_instance |= 1 << 7; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 350 | }; |
| 351 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 352 | inline void sensor_scanning_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 353 | { |
| 354 | if (enabled) |
| 355 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 356 | body->sensor_initialization |= 1 << 0; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 357 | } |
| 358 | else |
| 359 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 360 | body->sensor_initialization &= ~(1 << 0); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 361 | }; |
| 362 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 363 | inline void event_generation_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 364 | { |
| 365 | if (enabled) |
| 366 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 367 | body->sensor_initialization |= 1 << 1; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 368 | } |
| 369 | else |
| 370 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 371 | body->sensor_initialization &= ~(1 << 1); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 372 | } |
| 373 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 374 | inline void init_types_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 375 | { |
| 376 | if (enabled) |
| 377 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 378 | body->sensor_initialization |= 1 << 2; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 379 | } |
| 380 | else |
| 381 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 382 | body->sensor_initialization &= ~(1 << 2); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 383 | } |
| 384 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 385 | inline void init_hyst_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 386 | { |
| 387 | if (enabled) |
| 388 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 389 | body->sensor_initialization |= 1 << 3; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 390 | } |
| 391 | else |
| 392 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 393 | body->sensor_initialization &= ~(1 << 3); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 394 | } |
| 395 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 396 | inline void init_thresh_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 397 | { |
| 398 | if (enabled) |
| 399 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 400 | body->sensor_initialization |= 1 << 4; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 401 | } |
| 402 | else |
| 403 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 404 | body->sensor_initialization &= ~(1 << 4); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 405 | } |
| 406 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 407 | inline void init_events_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 408 | { |
| 409 | if (enabled) |
| 410 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 411 | body->sensor_initialization |= 1 << 5; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 412 | } |
| 413 | else |
| 414 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 415 | body->sensor_initialization &= ~(1 << 5); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 416 | } |
| 417 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 418 | inline void init_scanning_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 419 | { |
| 420 | if (enabled) |
| 421 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 422 | body->sensor_initialization |= 1 << 6; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 423 | } |
| 424 | else |
| 425 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 426 | body->sensor_initialization &= ~(1 << 6); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 427 | } |
| 428 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 429 | inline void init_settable_state(bool enabled, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 430 | { |
| 431 | if (enabled) |
| 432 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 433 | body->sensor_initialization |= 1 << 7; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 434 | } |
| 435 | else |
| 436 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 437 | body->sensor_initialization &= ~(1 << 7); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 438 | } |
| 439 | }; |
| 440 | |
| 441 | inline void set_percentage(SensorDataFullRecordBody* body) |
| 442 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 443 | body->sensor_units_1 |= 1 << 0; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 444 | }; |
| 445 | inline void unset_percentage(SensorDataFullRecordBody* body) |
| 446 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 447 | body->sensor_units_1 &= ~(1 << 0); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 448 | }; |
| 449 | inline void set_modifier_operation(uint8_t op, SensorDataFullRecordBody* body) |
| 450 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 451 | body->sensor_units_1 &= ~(3 << 1); |
| 452 | body->sensor_units_1 |= (op & 0x3) << 1; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 453 | }; |
| 454 | inline void set_rate_unit(uint8_t unit, SensorDataFullRecordBody* body) |
| 455 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 456 | body->sensor_units_1 &= ~(7 << 3); |
| 457 | body->sensor_units_1 |= (unit & 0x7) << 3; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 458 | }; |
| 459 | inline void set_analog_data_format(uint8_t format, |
| 460 | SensorDataFullRecordBody* body) |
| 461 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 462 | body->sensor_units_1 &= ~(3 << 6); |
| 463 | body->sensor_units_1 |= (format & 0x3) << 6; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 464 | }; |
| 465 | |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 466 | inline void set_m(uint16_t m, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 467 | { |
| 468 | body->m_lsb = m & 0xff; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 469 | body->m_msb_and_tolerance &= ~(3 << 6); |
| 470 | body->m_msb_and_tolerance |= ((m & (3 << 8)) >> 2); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 471 | }; |
| 472 | inline void set_tolerance(uint8_t tol, SensorDataFullRecordBody* body) |
| 473 | { |
| 474 | body->m_msb_and_tolerance &= ~0x3f; |
| 475 | body->m_msb_and_tolerance |= tol & 0x3f; |
| 476 | }; |
| 477 | |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 478 | inline void set_b(uint16_t b, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 479 | { |
| 480 | body->b_lsb = b & 0xff; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 481 | body->b_msb_and_accuracy_lsb &= ~(3 << 6); |
| 482 | body->b_msb_and_accuracy_lsb |= ((b & (3 << 8)) >> 2); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 483 | }; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 484 | inline void set_accuracy(uint16_t acc, SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 485 | { |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 486 | // bottom 6 bits |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 487 | body->b_msb_and_accuracy_lsb &= ~0x3f; |
| 488 | body->b_msb_and_accuracy_lsb |= acc & 0x3f; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 489 | // top 4 bits |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 490 | body->accuracy_and_sensor_direction &= 0x0f; |
Emily Shaffer | 7cad3fc | 2017-08-30 17:50:37 -0700 | [diff] [blame] | 491 | body->accuracy_and_sensor_direction |= ((acc >> 6) & 0xf) << 4; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 492 | }; |
| 493 | inline void set_accuracy_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 494 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 495 | body->accuracy_and_sensor_direction &= ~(3 << 2); |
| 496 | body->accuracy_and_sensor_direction |= (exp & 3) << 2; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 497 | }; |
| 498 | inline void set_sensor_dir(uint8_t dir, SensorDataFullRecordBody* body) |
| 499 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 500 | body->accuracy_and_sensor_direction &= ~(3 << 0); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 501 | body->accuracy_and_sensor_direction |= (dir & 3); |
| 502 | }; |
| 503 | |
| 504 | inline void set_b_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 505 | { |
| 506 | body->r_b_exponents &= 0xf0; |
| 507 | body->r_b_exponents |= exp & 0x0f; |
| 508 | }; |
| 509 | inline void set_r_exp(uint8_t exp, SensorDataFullRecordBody* body) |
| 510 | { |
| 511 | body->r_b_exponents &= 0x0f; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 512 | body->r_b_exponents |= (exp & 0x0f) << 4; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | inline void set_id_strlen(uint8_t len, SensorDataFullRecordBody* body) |
| 516 | { |
| 517 | body->id_string_info &= ~(0x1f); |
| 518 | body->id_string_info |= len & 0x1f; |
| 519 | }; |
Willy Tu | eae8859 | 2022-12-13 14:28:02 -0800 | [diff] [blame] | 520 | inline void set_id_strlen(uint8_t len, SensorDataEventRecordBody* body) |
| 521 | { |
| 522 | body->id_string_info &= ~(0x1f); |
| 523 | body->id_string_info |= len & 0x1f; |
| 524 | }; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 525 | inline uint8_t get_id_strlen(SensorDataFullRecordBody* body) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 526 | { |
| 527 | return body->id_string_info & 0x1f; |
| 528 | }; |
| 529 | inline void set_id_type(uint8_t type, SensorDataFullRecordBody* body) |
| 530 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 531 | body->id_string_info &= ~(3 << 6); |
| 532 | body->id_string_info |= (type & 0x3) << 6; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 533 | }; |
Willy Tu | eae8859 | 2022-12-13 14:28:02 -0800 | [diff] [blame] | 534 | inline void set_id_type(uint8_t type, SensorDataEventRecordBody* body) |
| 535 | { |
| 536 | body->id_string_info &= ~(3 << 6); |
| 537 | body->id_string_info |= (type & 0x3) << 6; |
| 538 | }; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 539 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 540 | inline void set_device_id_strlen(uint8_t len, SensorDataFruRecordBody* body) |
| 541 | { |
| 542 | body->deviceIDLen &= ~(LENGTH_MASK); |
| 543 | body->deviceIDLen |= len & LENGTH_MASK; |
| 544 | }; |
| 545 | |
| 546 | inline uint8_t get_device_id_strlen(SensorDataFruRecordBody* body) |
| 547 | { |
| 548 | return body->deviceIDLen & LENGTH_MASK; |
| 549 | }; |
| 550 | |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 551 | inline void set_readable_mask(uint8_t mask, SensorDataFullRecordBody* body) |
| 552 | { |
| 553 | body->discrete_reading_setting_mask[1] = mask & 0x3F; |
| 554 | } |
| 555 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 556 | } // namespace body |
| 557 | |
| 558 | // More types contained in section 43.17 Sensor Unit Type Codes, |
| 559 | // IPMI spec v2 rev 1.1 |
| 560 | enum SensorUnitTypeCodes |
| 561 | { |
| 562 | SENSOR_UNIT_UNSPECIFIED = 0, |
| 563 | SENSOR_UNIT_DEGREES_C = 1, |
| 564 | SENSOR_UNIT_VOLTS = 4, |
| 565 | SENSOR_UNIT_AMPERES = 5, |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 566 | SENSOR_UNIT_WATTS = 6, |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 567 | SENSOR_UNIT_JOULES = 7, |
Kirill Pakhomov | 812e44c | 2018-10-22 16:25:35 +0300 | [diff] [blame] | 568 | SENSOR_UNIT_RPM = 18, |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 569 | SENSOR_UNIT_METERS = 34, |
| 570 | SENSOR_UNIT_REVOLUTIONS = 41, |
| 571 | }; |
| 572 | |
| 573 | struct SensorDataFullRecord |
| 574 | { |
| 575 | SensorDataRecordHeader header; |
| 576 | SensorDataRecordKey key; |
| 577 | SensorDataFullRecordBody body; |
| 578 | } __attribute__((packed)); |
| 579 | |
selvaganapathi | 7b2e550 | 2023-02-14 07:10:47 +0530 | [diff] [blame] | 580 | /** @struct SensorDataComapactRecord |
| 581 | * |
| 582 | * Compact Sensor Record - SDR Type 2 |
| 583 | */ |
| 584 | struct SensorDataCompactRecord |
| 585 | { |
| 586 | SensorDataRecordHeader header; |
| 587 | SensorDataRecordKey key; |
| 588 | SensorDataCompactRecordBody body; |
| 589 | } __attribute__((packed)); |
| 590 | |
Hao Jiang | da06d15 | 2021-01-19 15:27:43 -0800 | [diff] [blame] | 591 | /** @struct SensorDataEventRecord |
| 592 | * |
| 593 | * Event Only Sensor Record - SDR Type 3 |
| 594 | */ |
| 595 | struct SensorDataEventRecord |
| 596 | { |
| 597 | SensorDataRecordHeader header; |
| 598 | SensorDataRecordKey key; |
| 599 | SensorDataEventRecordBody body; |
| 600 | } __attribute__((packed)); |
| 601 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 602 | /** @struct SensorDataFruRecord |
| 603 | * |
| 604 | * FRU Device Locator Record - SDR Type 11 |
| 605 | */ |
| 606 | struct SensorDataFruRecord |
| 607 | { |
| 608 | SensorDataRecordHeader header; |
| 609 | SensorDataFruRecordKey key; |
| 610 | SensorDataFruRecordBody body; |
| 611 | } __attribute__((packed)); |
| 612 | |
Jaghathiswari Rankappagounder Natarajan | 9c11894 | 2019-02-12 13:22:55 -0800 | [diff] [blame] | 613 | /** @struct SensorDataEntityRecord |
| 614 | * |
| 615 | * Entity Association Record - SDR Type 8 |
| 616 | */ |
| 617 | struct SensorDataEntityRecord |
| 618 | { |
| 619 | SensorDataRecordHeader header; |
| 620 | SensorDataEntityRecordKey key; |
| 621 | SensorDataEntityRecordBody body; |
| 622 | } __attribute__((packed)); |
| 623 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 624 | } // namespace get_sdr |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 625 | |
| 626 | namespace ipmi |
| 627 | { |
| 628 | |
| 629 | namespace sensor |
| 630 | { |
| 631 | |
| 632 | /** |
| 633 | * @brief Map offset to the corresponding bit in the assertion byte. |
| 634 | * |
Gunnar Mills | 8991dd6 | 2017-10-25 17:11:29 -0500 | [diff] [blame] | 635 | * The discrete sensors support up to 14 states. 0-7 offsets are stored in one |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 636 | * byte and offsets 8-14 in the second byte. |
| 637 | * |
| 638 | * @param[in] offset - offset number. |
| 639 | * @param[in/out] resp - get sensor reading response. |
| 640 | */ |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 641 | inline void setOffset(uint8_t offset, ipmi::sensor::GetSensorResponse* resp) |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 642 | { |
| 643 | if (offset > 7) |
| 644 | { |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 645 | resp->discreteReadingSensorStates |= 1 << (offset - 8); |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 646 | } |
| 647 | else |
| 648 | { |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 649 | resp->thresholdLevelsStates |= 1 << offset; |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 650 | } |
| 651 | } |
| 652 | |
Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 653 | /** |
| 654 | * @brief Set the reading field in the response. |
| 655 | * |
| 656 | * @param[in] offset - offset number. |
| 657 | * @param[in/out] resp - get sensor reading response. |
| 658 | */ |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 659 | inline void setReading(uint8_t value, ipmi::sensor::GetSensorResponse* resp) |
Tom Joseph | e4014fc | 2017-09-06 23:57:36 +0530 | [diff] [blame] | 660 | { |
| 661 | resp->reading = value; |
| 662 | } |
| 663 | |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 664 | /** |
| 665 | * @brief Map the value to the assertion bytes. The assertion states are stored |
| 666 | * in 2 bytes. |
| 667 | * |
| 668 | * @param[in] value - value to mapped to the assertion byte. |
| 669 | * @param[in/out] resp - get sensor reading response. |
| 670 | */ |
| 671 | inline void setAssertionBytes(uint16_t value, |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 672 | ipmi::sensor::GetSensorResponse* resp) |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 673 | { |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 674 | resp->thresholdLevelsStates = static_cast<uint8_t>(value & 0x00FF); |
| 675 | resp->discreteReadingSensorStates = static_cast<uint8_t>(value >> 8); |
Tom Joseph | 295f17e | 2017-09-07 00:09:46 +0530 | [diff] [blame] | 676 | } |
| 677 | |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 678 | /** |
| 679 | * @brief Set the scanning enabled bit in the response. |
| 680 | * |
| 681 | * @param[in/out] resp - get sensor reading response. |
| 682 | */ |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 683 | inline void enableScanning(ipmi::sensor::GetSensorResponse* resp) |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 684 | { |
Sui Chen | 4cc4255 | 2019-09-11 10:28:35 -0700 | [diff] [blame] | 685 | resp->readingOrStateUnavailable = false; |
| 686 | resp->scanningEnabled = true; |
| 687 | resp->allEventMessagesEnabled = false; |
Tom Joseph | e05b292 | 2017-09-07 00:43:16 +0530 | [diff] [blame] | 688 | } |
| 689 | |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 690 | } // namespace sensor |
| 691 | |
| 692 | } // namespace ipmi |