Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 1 | #pragma once |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include "nlohmann/json.hpp" |
| 4 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 6 | |
| 7 | #include <map> |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 11 | namespace dcmi |
| 12 | { |
| 13 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 14 | using NumInstances = size_t; |
| 15 | using Json = nlohmann::json; |
| 16 | |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 17 | enum Commands |
| 18 | { |
| 19 | // Get capability bits |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 20 | GET_CAPABILITIES = 0x01, |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 21 | GET_POWER_READING = 0x02, |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 22 | GET_SENSOR_INFO = 0x07, |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 23 | GET_MGMNT_CTRL_ID_STR = 0x09, |
| 24 | SET_MGMNT_CTRL_ID_STR = 0x0A, |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 25 | GET_TEMP_READINGS = 0x10, |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 26 | SET_CONF_PARAMS = 0x12, |
| 27 | GET_CONF_PARAMS = 0x13, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 28 | }; |
| 29 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 30 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 31 | static constexpr auto assetTagIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 32 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 33 | static constexpr auto assetTagProp = "AssetTag"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 34 | static constexpr auto networkServiceName = "xyz.openbmc_project.Network"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 35 | static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 36 | static constexpr auto networkConfigIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 37 | "xyz.openbmc_project.Network.SystemConfiguration"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 38 | static constexpr auto hostNameProp = "HostName"; |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 39 | static constexpr auto temperatureSensorType = 0x01; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 40 | static constexpr auto maxInstances = 255; |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 41 | static constexpr auto gDCMISensorsConfig = |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 42 | "/usr/share/ipmi-providers/dcmi_sensors.json"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 43 | static constexpr auto ethernetIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 44 | "xyz.openbmc_project.Network.EthernetInterface"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 45 | static constexpr auto ethernetDefaultChannelNum = 0x1; |
| 46 | static constexpr auto networkRoot = "/xyz/openbmc_project/network"; |
Jian Zhang | 958806d | 2022-12-13 13:37:09 +0800 | [diff] [blame] | 47 | static constexpr auto dhcpObj = "/xyz/openbmc_project/network/dhcp"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 48 | static constexpr auto dhcpIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 49 | "xyz.openbmc_project.Network.DHCPConfiguration"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 50 | static constexpr auto systemBusName = "org.freedesktop.systemd1"; |
| 51 | static constexpr auto systemPath = "/org/freedesktop/systemd1"; |
| 52 | static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager"; |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 53 | static constexpr auto gDCMICapabilitiesConfig = |
| 54 | "/usr/share/ipmi-providers/dcmi_cap.json"; |
Kirill Pakhomov | 2c2af2c | 2018-11-06 16:06:10 +0300 | [diff] [blame] | 55 | static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement"; |
| 56 | static constexpr auto gDCMIPowerMgmtSupported = 0x1; |
Kirill Pakhomov | db5d9b0 | 2018-11-06 19:17:51 +0300 | [diff] [blame] | 57 | static constexpr auto gMaxSELEntriesMask = 0xFFF; |
| 58 | static constexpr auto gByteBitSize = 8; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 59 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 60 | namespace temp_readings |
| 61 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 62 | static constexpr auto maxDataSets = 8; |
| 63 | static constexpr auto maxTemp = 127; // degrees C |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 64 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 65 | /** @struct Response |
| 66 | * |
| 67 | * DCMI payload for Get Temperature Readings response |
| 68 | */ |
| 69 | struct Response |
| 70 | { |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 71 | #if BYTE_ORDER == LITTLE_ENDIAN |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 72 | uint8_t temperature : 7; //!< Temperature reading in Celsius |
| 73 | uint8_t sign : 1; //!< Sign bit |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 74 | #endif |
| 75 | #if BYTE_ORDER == BIG_ENDIAN |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 76 | uint8_t sign : 1; //!< Sign bit |
| 77 | uint8_t temperature : 7; //!< Temperature reading in Celsius |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 78 | #endif |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 79 | uint8_t instance; //!< Entity instance number |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 80 | } __attribute__((packed)); |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 81 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 82 | using ResponseList = std::vector<Response>; |
| 83 | using Value = uint8_t; |
| 84 | using Sign = bool; |
| 85 | using Temperature = std::tuple<Value, Sign>; |
| 86 | } // namespace temp_readings |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 87 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 88 | namespace sensor_info |
| 89 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 90 | static constexpr auto maxRecords = 8; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 91 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 92 | /** @struct Response |
| 93 | * |
| 94 | * DCMI payload for Get Sensor Info response |
| 95 | */ |
| 96 | struct Response |
| 97 | { |
| 98 | uint8_t recordIdLsb; //!< SDR record id LS byte |
| 99 | uint8_t recordIdMsb; //!< SDR record id MS byte |
| 100 | } __attribute__((packed)); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 101 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 102 | using ResponseList = std::vector<Response>; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 103 | } // namespace sensor_info |
| 104 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 105 | static constexpr auto groupExtId = 0xDC; |
| 106 | |
Kirill Pakhomov | 2c2af2c | 2018-11-06 16:06:10 +0300 | [diff] [blame] | 107 | /** @brief Check whether DCMI power management is supported |
| 108 | * in the DCMI Capabilities config file. |
| 109 | * |
| 110 | * @return True if DCMI power management is supported |
| 111 | */ |
| 112 | bool isDCMIPowerMgmtSupported(); |
| 113 | |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 114 | /** @struct GetMgmntCtrlIdStrRequest |
| 115 | * |
| 116 | * DCMI payload for Get Management Controller Identifier String cmd request. |
| 117 | */ |
| 118 | struct GetMgmntCtrlIdStrRequest |
| 119 | { |
William A. Kennington III | 5d06cc6 | 2019-04-25 02:10:55 -0700 | [diff] [blame] | 120 | uint8_t offset; //!< Offset to read. |
| 121 | uint8_t bytes; //!< Number of bytes to read. |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 122 | } __attribute__((packed)); |
| 123 | |
| 124 | /** @struct GetMgmntCtrlIdStrResponse |
| 125 | * |
| 126 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 127 | */ |
| 128 | struct GetMgmntCtrlIdStrResponse |
| 129 | { |
William A. Kennington III | 5d06cc6 | 2019-04-25 02:10:55 -0700 | [diff] [blame] | 130 | uint8_t strLen; //!< ID string length. |
| 131 | char data[]; //!< ID string |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 132 | } __attribute__((packed)); |
| 133 | |
| 134 | /** @struct SetMgmntCtrlIdStrRequest |
| 135 | * |
| 136 | * DCMI payload for Set Management Controller Identifier String cmd request. |
| 137 | */ |
| 138 | struct SetMgmntCtrlIdStrRequest |
| 139 | { |
William A. Kennington III | 5d06cc6 | 2019-04-25 02:10:55 -0700 | [diff] [blame] | 140 | uint8_t offset; //!< Offset to write. |
| 141 | uint8_t bytes; //!< Number of bytes to read. |
| 142 | char data[]; //!< ID string |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 143 | } __attribute__((packed)); |
| 144 | |
| 145 | /** @struct GetMgmntCtrlIdStrResponse |
| 146 | * |
| 147 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 148 | */ |
| 149 | struct SetMgmntCtrlIdStrResponse |
| 150 | { |
William A. Kennington III | 5d06cc6 | 2019-04-25 02:10:55 -0700 | [diff] [blame] | 151 | uint8_t offset; //!< Last Offset Written. |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 152 | } __attribute__((packed)); |
| 153 | |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 154 | /** @enum DCMICapParameters |
| 155 | * |
| 156 | * DCMI Capability parameters |
| 157 | */ |
| 158 | enum class DCMICapParameters |
| 159 | { |
| 160 | SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities |
| 161 | MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes |
| 162 | OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes |
| 163 | MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes |
| 164 | }; |
| 165 | |
| 166 | /** @struct GetDCMICapRequest |
| 167 | * |
| 168 | * DCMI payload for Get capabilities cmd request. |
| 169 | */ |
| 170 | struct GetDCMICapRequest |
| 171 | { |
William A. Kennington III | 5d06cc6 | 2019-04-25 02:10:55 -0700 | [diff] [blame] | 172 | uint8_t param; //!< Capability parameter selector. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 173 | } __attribute__((packed)); |
| 174 | |
| 175 | /** @struct GetDCMICapRequest |
| 176 | * |
| 177 | * DCMI payload for Get capabilities cmd response. |
| 178 | */ |
| 179 | struct GetDCMICapResponse |
| 180 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 181 | uint8_t major; //!< DCMI Specification Conformance - major ver |
| 182 | uint8_t minor; //!< DCMI Specification Conformance - minor ver |
| 183 | uint8_t paramRevision; //!< Parameter Revision = 02h |
| 184 | uint8_t data[]; //!< Capability array |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 185 | } __attribute__((packed)); |
| 186 | |
| 187 | /** @struct DCMICap |
| 188 | * |
| 189 | * DCMI capabilities protocol info. |
| 190 | */ |
| 191 | struct DCMICap |
| 192 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 193 | std::string name; //!< Name of DCMI capability. |
| 194 | uint8_t bytePosition; //!< Starting byte number from DCMI spec. |
| 195 | uint8_t position; //!< bit position from the DCMI spec. |
| 196 | uint8_t length; //!< Length of the value from DCMI spec. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | using DCMICapList = std::vector<DCMICap>; |
| 200 | |
| 201 | /** @struct DCMICapEntry |
| 202 | * |
| 203 | * DCMI capabilities list and size for each parameter. |
| 204 | */ |
| 205 | struct DCMICapEntry |
| 206 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 207 | uint8_t size; //!< Size of capability array in bytes. |
| 208 | DCMICapList capList; //!< List of capabilities for a parameter. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 209 | }; |
| 210 | |
| 211 | using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>; |
| 212 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 213 | /** @struct GetTempReadingsRequest |
| 214 | * |
| 215 | * DCMI payload for Get Temperature Readings request |
| 216 | */ |
| 217 | struct GetTempReadingsRequest |
| 218 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 219 | uint8_t sensorType; //!< Type of the sensor |
| 220 | uint8_t entityId; //!< Entity ID |
| 221 | uint8_t entityInstance; //!< Entity Instance (0 means all instances) |
| 222 | uint8_t instanceStart; //!< Instance start (used if instance is 0) |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 223 | } __attribute__((packed)); |
| 224 | |
| 225 | /** @struct GetTempReadingsResponse |
| 226 | * |
| 227 | * DCMI header for Get Temperature Readings response |
| 228 | */ |
| 229 | struct GetTempReadingsResponseHdr |
| 230 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 231 | uint8_t numInstances; //!< No. of instances for requested id |
| 232 | uint8_t numDataSets; //!< No. of sets of temperature data |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 233 | } __attribute__((packed)); |
| 234 | |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 235 | /** @brief Parse out JSON config file. |
| 236 | * |
| 237 | * @param[in] configFile - JSON config file name |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 238 | * |
| 239 | * @return A json object |
| 240 | */ |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 241 | Json parseJSONConfig(const std::string& configFile); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 242 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 243 | namespace temp_readings |
| 244 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 245 | /** @brief Read temperature from a d-bus object, scale it as per dcmi |
| 246 | * get temperature reading requirements. |
| 247 | * |
| 248 | * @param[in] dbusService - the D-Bus service |
| 249 | * @param[in] dbusPath - the D-Bus path |
| 250 | * |
| 251 | * @return A temperature reading |
| 252 | */ |
| 253 | Temperature readTemp(const std::string& dbusService, |
| 254 | const std::string& dbusPath); |
Deepak Kodihalli | b1e8fba | 2018-01-24 04:57:10 -0600 | [diff] [blame] | 255 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 256 | /** @brief Read temperatures and fill up DCMI response for the Get |
| 257 | * Temperature Readings command. This looks at a specific |
| 258 | * instance. |
| 259 | * |
| 260 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 261 | * @param[in] instance - A non-zero Entity instance number |
| 262 | * |
| 263 | * @return A tuple, containing a temperature reading and the |
| 264 | * number of instances. |
| 265 | */ |
| 266 | std::tuple<Response, NumInstances> read(const std::string& type, |
| 267 | uint8_t instance); |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 268 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 269 | /** @brief Read temperatures and fill up DCMI response for the Get |
| 270 | * Temperature Readings command. This looks at a range of |
| 271 | * instances. |
| 272 | * |
| 273 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 274 | * @param[in] instanceStart - Entity instance start index |
| 275 | * |
| 276 | * @return A tuple, containing a list of temperature readings and the |
| 277 | * number of instances. |
| 278 | */ |
| 279 | std::tuple<ResponseList, NumInstances> readAll(const std::string& type, |
| 280 | uint8_t instanceStart); |
| 281 | } // namespace temp_readings |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 282 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 283 | namespace sensor_info |
| 284 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 285 | /** @brief Create response from JSON config. |
| 286 | * |
| 287 | * @param[in] config - JSON config info about DCMI sensors |
| 288 | * |
| 289 | * @return Sensor info response |
| 290 | */ |
| 291 | Response createFromJson(const Json& config); |
Deepak Kodihalli | dd4cff1 | 2018-02-06 06:48:29 -0600 | [diff] [blame] | 292 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 293 | /** @brief Read sensor info and fill up DCMI response for the Get |
| 294 | * Sensor Info command. This looks at a specific |
| 295 | * instance. |
| 296 | * |
| 297 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 298 | * @param[in] instance - A non-zero Entity instance number |
| 299 | * @param[in] config - JSON config info about DCMI sensors |
| 300 | * |
| 301 | * @return A tuple, containing a sensor info response and |
| 302 | * number of instances. |
| 303 | */ |
| 304 | std::tuple<Response, NumInstances> read(const std::string& type, |
| 305 | uint8_t instance, const Json& config); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 306 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 307 | /** @brief Read sensor info and fill up DCMI response for the Get |
| 308 | * Sensor Info command. This looks at a range of |
| 309 | * instances. |
| 310 | * |
| 311 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 312 | * @param[in] instanceStart - Entity instance start index |
| 313 | * @param[in] config - JSON config info about DCMI sensors |
| 314 | * |
| 315 | * @return A tuple, containing a list of sensor info responses and the |
| 316 | * number of instances. |
| 317 | */ |
| 318 | std::tuple<ResponseList, NumInstances> |
| 319 | readAll(const std::string& type, uint8_t instanceStart, const Json& config); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 320 | } // namespace sensor_info |
| 321 | |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 322 | /** @brief Read power reading from power reading sensor object |
| 323 | * |
| 324 | * @param[in] bus - dbus connection |
| 325 | * |
| 326 | * @return total power reading |
| 327 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 328 | int64_t getPowerReading(sdbusplus::bus_t& bus); |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 329 | |
| 330 | /** @struct GetPowerReadingRequest |
| 331 | * |
| 332 | * DCMI Get Power Reading command request. |
| 333 | * Refer DCMI specification Version 1.1 Section 6.6.1 |
| 334 | */ |
| 335 | struct GetPowerReadingRequest |
| 336 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 337 | uint8_t mode; //!< Mode |
| 338 | uint8_t modeAttribute; //!< Mode Attributes |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 339 | } __attribute__((packed)); |
| 340 | |
| 341 | /** @struct GetPowerReadingResponse |
| 342 | * |
| 343 | * DCMI Get Power Reading command response. |
| 344 | * Refer DCMI specification Version 1.1 Section 6.6.1 |
| 345 | */ |
| 346 | struct GetPowerReadingResponse |
| 347 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 348 | uint16_t currentPower; //!< Current power in watts |
| 349 | uint16_t minimumPower; //!< Minimum power over sampling duration |
| 350 | //!< in watts |
| 351 | uint16_t maximumPower; //!< Maximum power over sampling duration |
| 352 | //!< in watts |
| 353 | uint16_t averagePower; //!< Average power over sampling duration |
| 354 | //!< in watts |
| 355 | uint32_t timeStamp; //!< IPMI specification based time stamp |
| 356 | uint32_t timeFrame; //!< Statistics reporting time period in milli |
| 357 | //!< seconds. |
| 358 | uint8_t powerReadingState; //!< Power Reading State |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 359 | } __attribute__((packed)); |
| 360 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 361 | /** @struct GetSensorInfoRequest |
| 362 | * |
| 363 | * DCMI payload for Get Sensor Info request |
| 364 | */ |
| 365 | struct GetSensorInfoRequest |
| 366 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 367 | uint8_t sensorType; //!< Type of the sensor |
| 368 | uint8_t entityId; //!< Entity ID |
| 369 | uint8_t entityInstance; //!< Entity Instance (0 means all instances) |
| 370 | uint8_t instanceStart; //!< Instance start (used if instance is 0) |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 371 | } __attribute__((packed)); |
| 372 | |
| 373 | /** @struct GetSensorInfoResponseHdr |
| 374 | * |
| 375 | * DCMI header for Get Sensor Info response |
| 376 | */ |
| 377 | struct GetSensorInfoResponseHdr |
| 378 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 379 | uint8_t numInstances; //!< No. of instances for requested id |
| 380 | uint8_t numRecords; //!< No. of record ids in the response |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 381 | } __attribute__((packed)); |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 382 | /** |
| 383 | * @brief Parameters for DCMI Configuration Parameters |
| 384 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 385 | enum class DCMIConfigParameters : uint8_t |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 386 | { |
| 387 | ActivateDHCP = 1, |
| 388 | DiscoveryConfig, |
| 389 | DHCPTiming1, |
| 390 | DHCPTiming2, |
| 391 | DHCPTiming3, |
| 392 | }; |
| 393 | |
| 394 | /** @struct SetConfParamsRequest |
| 395 | * |
| 396 | * DCMI Set DCMI Configuration Parameters Command. |
| 397 | * Refer DCMI specification Version 1.1 Section 6.1.2 |
| 398 | */ |
| 399 | struct SetConfParamsRequest |
| 400 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 401 | uint8_t paramSelect; //!< Parameter selector. |
| 402 | uint8_t setSelect; //!< Set Selector (use 00h for parameters that only |
| 403 | //!< have one set). |
| 404 | uint8_t data[]; //!< Configuration parameter data. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 405 | } __attribute__((packed)); |
| 406 | |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 407 | /** @struct GetConfParamsRequest |
| 408 | * |
| 409 | * DCMI Get DCMI Configuration Parameters Command. |
| 410 | * Refer DCMI specification Version 1.1 Section 6.1.3 |
| 411 | */ |
| 412 | struct GetConfParamsRequest |
| 413 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 414 | uint8_t paramSelect; //!< Parameter selector. |
| 415 | uint8_t setSelect; //!< Set Selector. Selects a given set of parameters |
| 416 | //!< under a given Parameter selector value. 00h if |
| 417 | //!< parameter doesn't use a Set Selector. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 418 | } __attribute__((packed)); |
| 419 | |
| 420 | /** @struct GetConfParamsResponse |
| 421 | * |
| 422 | * DCMI Get DCMI Configuration Parameters Command response. |
| 423 | * Refer DCMI specification Version 1.1 Section 6.1.3 |
| 424 | */ |
| 425 | struct GetConfParamsResponse |
| 426 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 427 | uint8_t major; //!< DCMI Spec Conformance - major ver = 01h. |
| 428 | uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h. |
| 429 | uint8_t paramRevision; //!< Parameter Revision = 01h. |
| 430 | uint8_t data[]; //!< Parameter data. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 431 | } __attribute__((packed)); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 432 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 433 | } // namespace dcmi |