Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 1 | #ifndef __HOST_IPMI_DCMI_HANDLER_H__ |
| 2 | #define __HOST_IPMI_DCMI_HANDLER_H__ |
| 3 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 4 | #include "nlohmann/json.hpp" |
| 5 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 6 | #include <map> |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
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, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 22 | GET_POWER_LIMIT = 0x03, |
| 23 | SET_POWER_LIMIT = 0x04, |
| 24 | APPLY_POWER_LIMIT = 0x05, |
| 25 | GET_ASSET_TAG = 0x06, |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 26 | GET_SENSOR_INFO = 0x07, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 27 | SET_ASSET_TAG = 0x08, |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 28 | GET_MGMNT_CTRL_ID_STR = 0x09, |
| 29 | SET_MGMNT_CTRL_ID_STR = 0x0A, |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 30 | GET_TEMP_READINGS = 0x10, |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 31 | SET_CONF_PARAMS = 0x12, |
| 32 | GET_CONF_PARAMS = 0x13, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 33 | }; |
| 34 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 35 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 36 | static constexpr auto assetTagIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 37 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 38 | static constexpr auto assetTagProp = "AssetTag"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 39 | static constexpr auto networkServiceName = "xyz.openbmc_project.Network"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 40 | static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 41 | static constexpr auto networkConfigIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 42 | "xyz.openbmc_project.Network.SystemConfiguration"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 43 | static constexpr auto hostNameProp = "HostName"; |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 44 | static constexpr auto temperatureSensorType = 0x01; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 45 | static constexpr auto maxInstances = 255; |
| 46 | static constexpr auto configFile = |
| 47 | "/usr/share/ipmi-providers/dcmi_sensors.json"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 48 | static constexpr auto ethernetIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 49 | "xyz.openbmc_project.Network.EthernetInterface"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 50 | static constexpr auto ethernetDefaultChannelNum = 0x1; |
| 51 | static constexpr auto networkRoot = "/xyz/openbmc_project/network"; |
| 52 | static constexpr auto dhcpObj = "/xyz/openbmc_project/network/config/dhcp"; |
| 53 | static constexpr auto dhcpIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 54 | "xyz.openbmc_project.Network.DHCPConfiguration"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 55 | static constexpr auto systemBusName = "org.freedesktop.systemd1"; |
| 56 | static constexpr auto systemPath = "/org/freedesktop/systemd1"; |
| 57 | static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager"; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 58 | |
| 59 | namespace assettag |
| 60 | { |
| 61 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 62 | using ObjectPath = std::string; |
| 63 | using Service = std::string; |
| 64 | using Interfaces = std::vector<std::string>; |
| 65 | using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 66 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 67 | } // namespace assettag |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 68 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 69 | namespace temp_readings |
| 70 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 71 | static constexpr auto maxDataSets = 8; |
| 72 | static constexpr auto maxTemp = 127; // degrees C |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 73 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 74 | /** @struct Response |
| 75 | * |
| 76 | * DCMI payload for Get Temperature Readings response |
| 77 | */ |
| 78 | struct Response |
| 79 | { |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 80 | #if BYTE_ORDER == LITTLE_ENDIAN |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 81 | uint8_t temperature : 7; //!< Temperature reading in Celsius |
| 82 | uint8_t sign : 1; //!< Sign bit |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 83 | #endif |
| 84 | #if BYTE_ORDER == BIG_ENDIAN |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 85 | uint8_t sign : 1; //!< Sign bit |
| 86 | uint8_t temperature : 7; //!< Temperature reading in Celsius |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 87 | #endif |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 88 | uint8_t instance; //!< Entity instance number |
| 89 | } __attribute__((packed)); |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 90 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 91 | using ResponseList = std::vector<Response>; |
| 92 | using Value = uint8_t; |
| 93 | using Sign = bool; |
| 94 | using Temperature = std::tuple<Value, Sign>; |
| 95 | } // namespace temp_readings |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 96 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 97 | namespace sensor_info |
| 98 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 99 | static constexpr auto maxRecords = 8; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 100 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 101 | /** @struct Response |
| 102 | * |
| 103 | * DCMI payload for Get Sensor Info response |
| 104 | */ |
| 105 | struct Response |
| 106 | { |
| 107 | uint8_t recordIdLsb; //!< SDR record id LS byte |
| 108 | uint8_t recordIdMsb; //!< SDR record id MS byte |
| 109 | } __attribute__((packed)); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 110 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 111 | using ResponseList = std::vector<Response>; |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 112 | } // namespace sensor_info |
| 113 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 114 | static constexpr auto groupExtId = 0xDC; |
| 115 | |
| 116 | static constexpr auto assetTagMaxOffset = 62; |
| 117 | static constexpr auto assetTagMaxSize = 63; |
| 118 | static constexpr auto maxBytes = 16; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 119 | static constexpr size_t maxCtrlIdStrLen = 63; |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 120 | |
| 121 | /** @struct GetAssetTagRequest |
| 122 | * |
| 123 | * DCMI payload for Get Asset Tag command request. |
| 124 | */ |
| 125 | struct GetAssetTagRequest |
| 126 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 127 | uint8_t groupID; //!< Group extension identification. |
| 128 | uint8_t offset; //!< Offset to read. |
| 129 | uint8_t bytes; //!< Number of bytes to read. |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 130 | } __attribute__((packed)); |
| 131 | |
| 132 | /** @struct GetAssetTagResponse |
| 133 | * |
| 134 | * DCMI payload for Get Asset Tag command response. |
| 135 | */ |
| 136 | struct GetAssetTagResponse |
| 137 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 138 | uint8_t groupID; //!< Group extension identification. |
| 139 | uint8_t tagLength; //!< Total asset tag length. |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 140 | } __attribute__((packed)); |
| 141 | |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 142 | /** @struct SetAssetTagRequest |
| 143 | * |
| 144 | * DCMI payload for Set Asset Tag command request. |
| 145 | */ |
| 146 | struct SetAssetTagRequest |
| 147 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 148 | uint8_t groupID; //!< Group extension identification. |
| 149 | uint8_t offset; //!< Offset to write. |
| 150 | uint8_t bytes; //!< Number of bytes to write. |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 151 | } __attribute__((packed)); |
| 152 | |
| 153 | /** @struct SetAssetTagResponse |
| 154 | * |
| 155 | * DCMI payload for Set Asset Tag command response. |
| 156 | */ |
| 157 | struct SetAssetTagResponse |
| 158 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 159 | uint8_t groupID; //!< Group extension identification. |
| 160 | uint8_t tagLength; //!< Total asset tag length. |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 161 | } __attribute__((packed)); |
| 162 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 163 | /** @brief Read the object tree to fetch the object path that implemented the |
| 164 | * Asset tag interface. |
| 165 | * |
| 166 | * @param[in,out] objectTree - object tree |
| 167 | * |
| 168 | * @return On success return the object tree with the object path that |
| 169 | * implemented the AssetTag interface. |
| 170 | */ |
| 171 | void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree); |
| 172 | |
| 173 | /** @brief Read the asset tag of the server |
| 174 | * |
| 175 | * @return On success return the asset tag. |
| 176 | */ |
| 177 | std::string readAssetTag(); |
| 178 | |
Tom Joseph | be5b989 | 2017-07-15 00:55:23 +0530 | [diff] [blame] | 179 | /** @brief Write the asset tag to the asset tag DBUS property |
| 180 | * |
| 181 | * @param[in] assetTag - Asset Tag to be written to the property. |
| 182 | */ |
| 183 | void writeAssetTag(const std::string& assetTag); |
| 184 | |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame] | 185 | /** @brief Read the current power cap value |
| 186 | * |
| 187 | * @param[in] bus - dbus connection |
| 188 | * |
| 189 | * @return On success return the power cap value. |
| 190 | */ |
| 191 | uint32_t getPcap(sdbusplus::bus::bus& bus); |
| 192 | |
| 193 | /** @brief Check if the power capping is enabled |
| 194 | * |
| 195 | * @param[in] bus - dbus connection |
| 196 | * |
| 197 | * @return true if the powerCap is enabled and false if the powercap |
| 198 | * is disabled. |
| 199 | */ |
| 200 | bool getPcapEnabled(sdbusplus::bus::bus& bus); |
| 201 | |
| 202 | /** @struct GetPowerLimitRequest |
| 203 | * |
| 204 | * DCMI payload for Get Power Limit command request. |
| 205 | */ |
| 206 | struct GetPowerLimitRequest |
| 207 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 208 | uint8_t groupID; //!< Group extension identification. |
| 209 | uint16_t reserved; //!< Reserved |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame] | 210 | } __attribute__((packed)); |
| 211 | |
| 212 | /** @struct GetPowerLimitResponse |
| 213 | * |
| 214 | * DCMI payload for Get Power Limit command response. |
| 215 | */ |
| 216 | struct GetPowerLimitResponse |
| 217 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 218 | uint8_t groupID; //!< Group extension identification. |
| 219 | uint16_t reserved; //!< Reserved. |
| 220 | uint8_t exceptionAction; //!< Exception action. |
| 221 | uint16_t powerLimit; //!< Power limit requested in watts. |
| 222 | uint32_t correctionTime; //!< Correction time limit in milliseconds. |
| 223 | uint16_t reserved1; //!< Reserved. |
| 224 | uint16_t samplingPeriod; //!< Statistics sampling period in seconds. |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame] | 225 | } __attribute__((packed)); |
| 226 | |
Tom Joseph | 46fa37d | 2017-07-26 18:11:55 +0530 | [diff] [blame] | 227 | /** @brief Set the power cap value |
| 228 | * |
| 229 | * @param[in] bus - dbus connection |
| 230 | * @param[in] powerCap - power cap value |
| 231 | */ |
| 232 | void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap); |
| 233 | |
| 234 | /** @struct SetPowerLimitRequest |
| 235 | * |
| 236 | * DCMI payload for Set Power Limit command request. |
| 237 | */ |
| 238 | struct SetPowerLimitRequest |
| 239 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 240 | uint8_t groupID; //!< Group extension identification. |
| 241 | uint16_t reserved; //!< Reserved |
| 242 | uint8_t reserved1; //!< Reserved |
| 243 | uint8_t exceptionAction; //!< Exception action. |
| 244 | uint16_t powerLimit; //!< Power limit requested in watts. |
| 245 | uint32_t correctionTime; //!< Correction time limit in milliseconds. |
| 246 | uint16_t reserved2; //!< Reserved. |
| 247 | uint16_t samplingPeriod; //!< Statistics sampling period in seconds. |
Tom Joseph | 46fa37d | 2017-07-26 18:11:55 +0530 | [diff] [blame] | 248 | } __attribute__((packed)); |
| 249 | |
| 250 | /** @struct SetPowerLimitResponse |
| 251 | * |
| 252 | * DCMI payload for Set Power Limit command response. |
| 253 | */ |
| 254 | struct SetPowerLimitResponse |
| 255 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 256 | uint8_t groupID; //!< Group extension identification. |
Tom Joseph | 46fa37d | 2017-07-26 18:11:55 +0530 | [diff] [blame] | 257 | } __attribute__((packed)); |
| 258 | |
Tom Joseph | 6c8d51b | 2017-07-26 18:18:06 +0530 | [diff] [blame] | 259 | /** @brief Enable or disable the power capping |
| 260 | * |
| 261 | * @param[in] bus - dbus connection |
| 262 | * @param[in] enabled - enable/disable |
| 263 | */ |
| 264 | void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled); |
| 265 | |
| 266 | /** @struct ApplyPowerLimitRequest |
| 267 | * |
| 268 | * DCMI payload for Activate/Deactivate Power Limit command request. |
| 269 | */ |
| 270 | struct ApplyPowerLimitRequest |
| 271 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 272 | uint8_t groupID; //!< Group extension identification. |
| 273 | uint8_t powerLimitAction; //!< Power limit activation |
| 274 | uint16_t reserved; //!< Reserved |
Tom Joseph | 6c8d51b | 2017-07-26 18:18:06 +0530 | [diff] [blame] | 275 | } __attribute__((packed)); |
| 276 | |
| 277 | /** @struct ApplyPowerLimitResponse |
| 278 | * |
| 279 | * DCMI payload for Acticate/Deactivate Power Limit command response. |
| 280 | */ |
| 281 | struct ApplyPowerLimitResponse |
| 282 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 283 | uint8_t groupID; //!< Group extension identification. |
Tom Joseph | 6c8d51b | 2017-07-26 18:18:06 +0530 | [diff] [blame] | 284 | } __attribute__((packed)); |
| 285 | |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 286 | /** @struct GetMgmntCtrlIdStrRequest |
| 287 | * |
| 288 | * DCMI payload for Get Management Controller Identifier String cmd request. |
| 289 | */ |
| 290 | struct GetMgmntCtrlIdStrRequest |
| 291 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 292 | uint8_t groupID; //!< Group extension identification. |
| 293 | uint8_t offset; //!< Offset to read. |
| 294 | uint8_t bytes; //!< Number of bytes to read. |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 295 | } __attribute__((packed)); |
| 296 | |
| 297 | /** @struct GetMgmntCtrlIdStrResponse |
| 298 | * |
| 299 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 300 | */ |
| 301 | struct GetMgmntCtrlIdStrResponse |
| 302 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 303 | uint8_t groupID; //!< Group extension identification. |
| 304 | uint8_t strLen; //!< ID string length. |
| 305 | char data[]; //!< ID string |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 306 | } __attribute__((packed)); |
| 307 | |
| 308 | /** @struct SetMgmntCtrlIdStrRequest |
| 309 | * |
| 310 | * DCMI payload for Set Management Controller Identifier String cmd request. |
| 311 | */ |
| 312 | struct SetMgmntCtrlIdStrRequest |
| 313 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 314 | uint8_t groupID; //!< Group extension identification. |
| 315 | uint8_t offset; //!< Offset to write. |
| 316 | uint8_t bytes; //!< Number of bytes to read. |
| 317 | char data[]; //!< ID string |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 318 | } __attribute__((packed)); |
| 319 | |
| 320 | /** @struct GetMgmntCtrlIdStrResponse |
| 321 | * |
| 322 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 323 | */ |
| 324 | struct SetMgmntCtrlIdStrResponse |
| 325 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 326 | uint8_t groupID; //!< Group extension identification. |
| 327 | uint8_t offset; //!< Last Offset Written. |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 328 | } __attribute__((packed)); |
| 329 | |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 330 | /** @enum DCMICapParameters |
| 331 | * |
| 332 | * DCMI Capability parameters |
| 333 | */ |
| 334 | enum class DCMICapParameters |
| 335 | { |
| 336 | SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities |
| 337 | MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes |
| 338 | OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes |
| 339 | MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes |
| 340 | }; |
| 341 | |
| 342 | /** @struct GetDCMICapRequest |
| 343 | * |
| 344 | * DCMI payload for Get capabilities cmd request. |
| 345 | */ |
| 346 | struct GetDCMICapRequest |
| 347 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 348 | uint8_t groupID; //!< Group extension identification. |
| 349 | uint8_t param; //!< Capability parameter selector. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 350 | } __attribute__((packed)); |
| 351 | |
| 352 | /** @struct GetDCMICapRequest |
| 353 | * |
| 354 | * DCMI payload for Get capabilities cmd response. |
| 355 | */ |
| 356 | struct GetDCMICapResponse |
| 357 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 358 | uint8_t groupID; //!< Group extension identification. |
| 359 | uint8_t major; //!< DCMI Specification Conformance - major ver |
| 360 | uint8_t minor; //!< DCMI Specification Conformance - minor ver |
| 361 | uint8_t paramRevision; //!< Parameter Revision = 02h |
| 362 | uint8_t data[]; //!< Capability array |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 363 | } __attribute__((packed)); |
| 364 | |
| 365 | /** @struct DCMICap |
| 366 | * |
| 367 | * DCMI capabilities protocol info. |
| 368 | */ |
| 369 | struct DCMICap |
| 370 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 371 | std::string name; //!< Name of DCMI capability. |
| 372 | uint8_t bytePosition; //!< Starting byte number from DCMI spec. |
| 373 | uint8_t position; //!< bit position from the DCMI spec. |
| 374 | uint8_t length; //!< Length of the value from DCMI spec. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | using DCMICapList = std::vector<DCMICap>; |
| 378 | |
| 379 | /** @struct DCMICapEntry |
| 380 | * |
| 381 | * DCMI capabilities list and size for each parameter. |
| 382 | */ |
| 383 | struct DCMICapEntry |
| 384 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 385 | uint8_t size; //!< Size of capability array in bytes. |
| 386 | DCMICapList capList; //!< List of capabilities for a parameter. |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 387 | }; |
| 388 | |
| 389 | using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>; |
| 390 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 391 | /** @struct GetTempReadingsRequest |
| 392 | * |
| 393 | * DCMI payload for Get Temperature Readings request |
| 394 | */ |
| 395 | struct GetTempReadingsRequest |
| 396 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 397 | uint8_t groupID; //!< Group extension identification. |
| 398 | uint8_t sensorType; //!< Type of the sensor |
| 399 | uint8_t entityId; //!< Entity ID |
| 400 | uint8_t entityInstance; //!< Entity Instance (0 means all instances) |
| 401 | uint8_t instanceStart; //!< Instance start (used if instance is 0) |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 402 | } __attribute__((packed)); |
| 403 | |
| 404 | /** @struct GetTempReadingsResponse |
| 405 | * |
| 406 | * DCMI header for Get Temperature Readings response |
| 407 | */ |
| 408 | struct GetTempReadingsResponseHdr |
| 409 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 410 | uint8_t groupID; //!< Group extension identification. |
| 411 | uint8_t numInstances; //!< No. of instances for requested id |
| 412 | uint8_t numDataSets; //!< No. of sets of temperature data |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 413 | } __attribute__((packed)); |
| 414 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 415 | /** @brief Parse out JSON config file containing information |
| 416 | * related to sensors. |
| 417 | * |
| 418 | * @return A json object |
| 419 | */ |
| 420 | Json parseSensorConfig(); |
| 421 | |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 422 | namespace temp_readings |
| 423 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 424 | /** @brief Read temperature from a d-bus object, scale it as per dcmi |
| 425 | * get temperature reading requirements. |
| 426 | * |
| 427 | * @param[in] dbusService - the D-Bus service |
| 428 | * @param[in] dbusPath - the D-Bus path |
| 429 | * |
| 430 | * @return A temperature reading |
| 431 | */ |
| 432 | Temperature readTemp(const std::string& dbusService, |
| 433 | const std::string& dbusPath); |
Deepak Kodihalli | b1e8fba | 2018-01-24 04:57:10 -0600 | [diff] [blame] | 434 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 435 | /** @brief Read temperatures and fill up DCMI response for the Get |
| 436 | * Temperature Readings command. This looks at a specific |
| 437 | * instance. |
| 438 | * |
| 439 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 440 | * @param[in] instance - A non-zero Entity instance number |
| 441 | * |
| 442 | * @return A tuple, containing a temperature reading and the |
| 443 | * number of instances. |
| 444 | */ |
| 445 | std::tuple<Response, NumInstances> read(const std::string& type, |
| 446 | uint8_t instance); |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 447 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 448 | /** @brief Read temperatures and fill up DCMI response for the Get |
| 449 | * Temperature Readings command. This looks at a range of |
| 450 | * instances. |
| 451 | * |
| 452 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 453 | * @param[in] instanceStart - Entity instance start index |
| 454 | * |
| 455 | * @return A tuple, containing a list of temperature readings and the |
| 456 | * number of instances. |
| 457 | */ |
| 458 | std::tuple<ResponseList, NumInstances> readAll(const std::string& type, |
| 459 | uint8_t instanceStart); |
| 460 | } // namespace temp_readings |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 461 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 462 | namespace sensor_info |
| 463 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 464 | /** @brief Create response from JSON config. |
| 465 | * |
| 466 | * @param[in] config - JSON config info about DCMI sensors |
| 467 | * |
| 468 | * @return Sensor info response |
| 469 | */ |
| 470 | Response createFromJson(const Json& config); |
Deepak Kodihalli | dd4cff1 | 2018-02-06 06:48:29 -0600 | [diff] [blame] | 471 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 472 | /** @brief Read sensor info and fill up DCMI response for the Get |
| 473 | * Sensor Info command. This looks at a specific |
| 474 | * instance. |
| 475 | * |
| 476 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 477 | * @param[in] instance - A non-zero Entity instance number |
| 478 | * @param[in] config - JSON config info about DCMI sensors |
| 479 | * |
| 480 | * @return A tuple, containing a sensor info response and |
| 481 | * number of instances. |
| 482 | */ |
| 483 | std::tuple<Response, NumInstances> read(const std::string& type, |
| 484 | uint8_t instance, const Json& config); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 485 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 486 | /** @brief Read sensor info and fill up DCMI response for the Get |
| 487 | * Sensor Info command. This looks at a range of |
| 488 | * instances. |
| 489 | * |
| 490 | * @param[in] type - one of "inlet", "cpu", "baseboard" |
| 491 | * @param[in] instanceStart - Entity instance start index |
| 492 | * @param[in] config - JSON config info about DCMI sensors |
| 493 | * |
| 494 | * @return A tuple, containing a list of sensor info responses and the |
| 495 | * number of instances. |
| 496 | */ |
| 497 | std::tuple<ResponseList, NumInstances> |
| 498 | readAll(const std::string& type, uint8_t instanceStart, const Json& config); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 499 | } // namespace sensor_info |
| 500 | |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 501 | /** @brief Read power reading from power reading sensor object |
| 502 | * |
| 503 | * @param[in] bus - dbus connection |
| 504 | * |
| 505 | * @return total power reading |
| 506 | */ |
| 507 | int64_t getPowerReading(sdbusplus::bus::bus& bus); |
| 508 | |
| 509 | /** @struct GetPowerReadingRequest |
| 510 | * |
| 511 | * DCMI Get Power Reading command request. |
| 512 | * Refer DCMI specification Version 1.1 Section 6.6.1 |
| 513 | */ |
| 514 | struct GetPowerReadingRequest |
| 515 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 516 | uint8_t groupID; //!< Group extension identification. |
| 517 | uint8_t mode; //!< Mode |
| 518 | uint8_t modeAttribute; //!< Mode Attributes |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 519 | } __attribute__((packed)); |
| 520 | |
| 521 | /** @struct GetPowerReadingResponse |
| 522 | * |
| 523 | * DCMI Get Power Reading command response. |
| 524 | * Refer DCMI specification Version 1.1 Section 6.6.1 |
| 525 | */ |
| 526 | struct GetPowerReadingResponse |
| 527 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 528 | uint8_t groupID; //!< Group extension identification. |
| 529 | uint16_t currentPower; //!< Current power in watts |
| 530 | uint16_t minimumPower; //!< Minimum power over sampling duration |
| 531 | //!< in watts |
| 532 | uint16_t maximumPower; //!< Maximum power over sampling duration |
| 533 | //!< in watts |
| 534 | uint16_t averagePower; //!< Average power over sampling duration |
| 535 | //!< in watts |
| 536 | uint32_t timeStamp; //!< IPMI specification based time stamp |
| 537 | uint32_t timeFrame; //!< Statistics reporting time period in milli |
| 538 | //!< seconds. |
| 539 | uint8_t powerReadingState; //!< Power Reading State |
Marri Devender Rao | 66c5fda | 2018-01-18 10:48:37 -0600 | [diff] [blame] | 540 | } __attribute__((packed)); |
| 541 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 542 | /** @struct GetSensorInfoRequest |
| 543 | * |
| 544 | * DCMI payload for Get Sensor Info request |
| 545 | */ |
| 546 | struct GetSensorInfoRequest |
| 547 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 548 | uint8_t groupID; //!< Group extension identification. |
| 549 | uint8_t sensorType; //!< Type of the sensor |
| 550 | uint8_t entityId; //!< Entity ID |
| 551 | uint8_t entityInstance; //!< Entity Instance (0 means all instances) |
| 552 | uint8_t instanceStart; //!< Instance start (used if instance is 0) |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 553 | } __attribute__((packed)); |
| 554 | |
| 555 | /** @struct GetSensorInfoResponseHdr |
| 556 | * |
| 557 | * DCMI header for Get Sensor Info response |
| 558 | */ |
| 559 | struct GetSensorInfoResponseHdr |
| 560 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 561 | uint8_t groupID; //!< Group extension identification. |
| 562 | uint8_t numInstances; //!< No. of instances for requested id |
| 563 | uint8_t numRecords; //!< No. of record ids in the response |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 564 | } __attribute__((packed)); |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 565 | /** |
| 566 | * @brief Parameters for DCMI Configuration Parameters |
| 567 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 568 | enum class DCMIConfigParameters : uint8_t |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 569 | { |
| 570 | ActivateDHCP = 1, |
| 571 | DiscoveryConfig, |
| 572 | DHCPTiming1, |
| 573 | DHCPTiming2, |
| 574 | DHCPTiming3, |
| 575 | }; |
| 576 | |
| 577 | /** @struct SetConfParamsRequest |
| 578 | * |
| 579 | * DCMI Set DCMI Configuration Parameters Command. |
| 580 | * Refer DCMI specification Version 1.1 Section 6.1.2 |
| 581 | */ |
| 582 | struct SetConfParamsRequest |
| 583 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 584 | uint8_t groupID; //!< Group extension identification. |
| 585 | uint8_t paramSelect; //!< Parameter selector. |
| 586 | uint8_t setSelect; //!< Set Selector (use 00h for parameters that only |
| 587 | //!< have one set). |
| 588 | uint8_t data[]; //!< Configuration parameter data. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 589 | } __attribute__((packed)); |
| 590 | |
| 591 | /** @struct SetConfParamsResponse |
| 592 | * |
| 593 | * DCMI Set DCMI Configuration Parameters Command response. |
| 594 | * Refer DCMI specification Version 1.1 Section 6.1.2 |
| 595 | */ |
| 596 | struct SetConfParamsResponse |
| 597 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 598 | uint8_t groupID; //!< Group extension identification. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 599 | } __attribute__((packed)); |
| 600 | |
| 601 | /** @struct GetConfParamsRequest |
| 602 | * |
| 603 | * DCMI Get DCMI Configuration Parameters Command. |
| 604 | * Refer DCMI specification Version 1.1 Section 6.1.3 |
| 605 | */ |
| 606 | struct GetConfParamsRequest |
| 607 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 608 | uint8_t groupID; //!< Group extension identification. |
| 609 | uint8_t paramSelect; //!< Parameter selector. |
| 610 | uint8_t setSelect; //!< Set Selector. Selects a given set of parameters |
| 611 | //!< under a given Parameter selector value. 00h if |
| 612 | //!< parameter doesn't use a Set Selector. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 613 | } __attribute__((packed)); |
| 614 | |
| 615 | /** @struct GetConfParamsResponse |
| 616 | * |
| 617 | * DCMI Get DCMI Configuration Parameters Command response. |
| 618 | * Refer DCMI specification Version 1.1 Section 6.1.3 |
| 619 | */ |
| 620 | struct GetConfParamsResponse |
| 621 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 622 | uint8_t groupID; //!< Group extension identification. |
| 623 | uint8_t major; //!< DCMI Spec Conformance - major ver = 01h. |
| 624 | uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h. |
| 625 | uint8_t paramRevision; //!< Parameter Revision = 01h. |
| 626 | uint8_t data[]; //!< Parameter data. |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 627 | |
| 628 | } __attribute__((packed)); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 629 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 630 | } // namespace dcmi |
| 631 | |
| 632 | #endif |