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 | |
| 4 | #include <map> |
| 5 | #include <string> |
| 6 | #include <vector> |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 8 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 9 | namespace dcmi |
| 10 | { |
| 11 | |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 12 | enum Commands |
| 13 | { |
| 14 | // Get capability bits |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 15 | GET_CAPABILITIES = 0x01, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 16 | GET_POWER_LIMIT = 0x03, |
| 17 | SET_POWER_LIMIT = 0x04, |
| 18 | APPLY_POWER_LIMIT = 0x05, |
| 19 | GET_ASSET_TAG = 0x06, |
| 20 | SET_ASSET_TAG = 0x08, |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 21 | GET_MGMNT_CTRL_ID_STR = 0x09, |
| 22 | SET_MGMNT_CTRL_ID_STR = 0x0A, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 23 | }; |
| 24 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 25 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 26 | static constexpr auto assetTagIntf = |
| 27 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
| 28 | static constexpr auto assetTagProp = "AssetTag"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 29 | static constexpr auto networkServiceName = "xyz.openbmc_project.Network"; |
| 30 | static constexpr auto networkConfigObj = |
| 31 | "/xyz/openbmc_project/network/config"; |
| 32 | static constexpr auto networkConfigIntf = |
| 33 | "xyz.openbmc_project.Network.SystemConfiguration"; |
| 34 | static constexpr auto hostNameProp = "HostName"; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 35 | |
| 36 | namespace assettag |
| 37 | { |
| 38 | |
| 39 | using ObjectPath = std::string; |
| 40 | using Service = std::string; |
| 41 | using Interfaces = std::vector<std::string>; |
| 42 | using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>; |
| 43 | |
| 44 | } //namespace assettag |
| 45 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 46 | static constexpr auto groupExtId = 0xDC; |
| 47 | |
| 48 | static constexpr auto assetTagMaxOffset = 62; |
| 49 | static constexpr auto assetTagMaxSize = 63; |
| 50 | static constexpr auto maxBytes = 16; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 51 | static constexpr size_t maxCtrlIdStrLen = 63; |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 52 | |
| 53 | /** @struct GetAssetTagRequest |
| 54 | * |
| 55 | * DCMI payload for Get Asset Tag command request. |
| 56 | */ |
| 57 | struct GetAssetTagRequest |
| 58 | { |
| 59 | uint8_t groupID; //!< Group extension identification. |
| 60 | uint8_t offset; //!< Offset to read. |
| 61 | uint8_t bytes; //!< Number of bytes to read. |
| 62 | } __attribute__((packed)); |
| 63 | |
| 64 | /** @struct GetAssetTagResponse |
| 65 | * |
| 66 | * DCMI payload for Get Asset Tag command response. |
| 67 | */ |
| 68 | struct GetAssetTagResponse |
| 69 | { |
| 70 | uint8_t groupID; //!< Group extension identification. |
| 71 | uint8_t tagLength; //!< Total asset tag length. |
| 72 | } __attribute__((packed)); |
| 73 | |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 74 | /** @struct SetAssetTagRequest |
| 75 | * |
| 76 | * DCMI payload for Set Asset Tag command request. |
| 77 | */ |
| 78 | struct SetAssetTagRequest |
| 79 | { |
| 80 | uint8_t groupID; //!< Group extension identification. |
| 81 | uint8_t offset; //!< Offset to write. |
| 82 | uint8_t bytes; //!< Number of bytes to write. |
| 83 | } __attribute__((packed)); |
| 84 | |
| 85 | /** @struct SetAssetTagResponse |
| 86 | * |
| 87 | * DCMI payload for Set Asset Tag command response. |
| 88 | */ |
| 89 | struct SetAssetTagResponse |
| 90 | { |
| 91 | uint8_t groupID; //!< Group extension identification. |
| 92 | uint8_t tagLength; //!< Total asset tag length. |
| 93 | } __attribute__((packed)); |
| 94 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 95 | /** @brief Read the object tree to fetch the object path that implemented the |
| 96 | * Asset tag interface. |
| 97 | * |
| 98 | * @param[in,out] objectTree - object tree |
| 99 | * |
| 100 | * @return On success return the object tree with the object path that |
| 101 | * implemented the AssetTag interface. |
| 102 | */ |
| 103 | void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree); |
| 104 | |
| 105 | /** @brief Read the asset tag of the server |
| 106 | * |
| 107 | * @return On success return the asset tag. |
| 108 | */ |
| 109 | std::string readAssetTag(); |
| 110 | |
Tom Joseph | be5b989 | 2017-07-15 00:55:23 +0530 | [diff] [blame] | 111 | /** @brief Write the asset tag to the asset tag DBUS property |
| 112 | * |
| 113 | * @param[in] assetTag - Asset Tag to be written to the property. |
| 114 | */ |
| 115 | void writeAssetTag(const std::string& assetTag); |
| 116 | |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame] | 117 | /** @brief Read the current power cap value |
| 118 | * |
| 119 | * @param[in] bus - dbus connection |
| 120 | * |
| 121 | * @return On success return the power cap value. |
| 122 | */ |
| 123 | uint32_t getPcap(sdbusplus::bus::bus& bus); |
| 124 | |
| 125 | /** @brief Check if the power capping is enabled |
| 126 | * |
| 127 | * @param[in] bus - dbus connection |
| 128 | * |
| 129 | * @return true if the powerCap is enabled and false if the powercap |
| 130 | * is disabled. |
| 131 | */ |
| 132 | bool getPcapEnabled(sdbusplus::bus::bus& bus); |
| 133 | |
| 134 | /** @struct GetPowerLimitRequest |
| 135 | * |
| 136 | * DCMI payload for Get Power Limit command request. |
| 137 | */ |
| 138 | struct GetPowerLimitRequest |
| 139 | { |
| 140 | uint8_t groupID; //!< Group extension identification. |
| 141 | uint16_t reserved; //!< Reserved |
| 142 | } __attribute__((packed)); |
| 143 | |
| 144 | /** @struct GetPowerLimitResponse |
| 145 | * |
| 146 | * DCMI payload for Get Power Limit command response. |
| 147 | */ |
| 148 | struct GetPowerLimitResponse |
| 149 | { |
| 150 | uint8_t groupID; //!< Group extension identification. |
| 151 | uint16_t reserved; //!< Reserved. |
| 152 | uint8_t exceptionAction; //!< Exception action. |
| 153 | uint16_t powerLimit; //!< Power limit requested in watts. |
| 154 | uint32_t correctionTime; //!< Correction time limit in milliseconds. |
| 155 | uint16_t reserved1; //!< Reserved. |
| 156 | uint16_t samplingPeriod; //!< Statistics sampling period in seconds. |
| 157 | } __attribute__((packed)); |
| 158 | |
Tom Joseph | 46fa37d | 2017-07-26 18:11:55 +0530 | [diff] [blame] | 159 | /** @brief Set the power cap value |
| 160 | * |
| 161 | * @param[in] bus - dbus connection |
| 162 | * @param[in] powerCap - power cap value |
| 163 | */ |
| 164 | void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap); |
| 165 | |
| 166 | /** @struct SetPowerLimitRequest |
| 167 | * |
| 168 | * DCMI payload for Set Power Limit command request. |
| 169 | */ |
| 170 | struct SetPowerLimitRequest |
| 171 | { |
| 172 | uint8_t groupID; //!< Group extension identification. |
| 173 | uint16_t reserved; //!< Reserved |
| 174 | uint8_t reserved1; //!< Reserved |
| 175 | uint8_t exceptionAction; //!< Exception action. |
| 176 | uint16_t powerLimit; //!< Power limit requested in watts. |
| 177 | uint32_t correctionTime; //!< Correction time limit in milliseconds. |
| 178 | uint16_t reserved2; //!< Reserved. |
| 179 | uint16_t samplingPeriod; //!< Statistics sampling period in seconds. |
| 180 | } __attribute__((packed)); |
| 181 | |
| 182 | /** @struct SetPowerLimitResponse |
| 183 | * |
| 184 | * DCMI payload for Set Power Limit command response. |
| 185 | */ |
| 186 | struct SetPowerLimitResponse |
| 187 | { |
| 188 | uint8_t groupID; //!< Group extension identification. |
| 189 | } __attribute__((packed)); |
| 190 | |
Tom Joseph | 6c8d51b | 2017-07-26 18:18:06 +0530 | [diff] [blame] | 191 | /** @brief Enable or disable the power capping |
| 192 | * |
| 193 | * @param[in] bus - dbus connection |
| 194 | * @param[in] enabled - enable/disable |
| 195 | */ |
| 196 | void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled); |
| 197 | |
| 198 | /** @struct ApplyPowerLimitRequest |
| 199 | * |
| 200 | * DCMI payload for Activate/Deactivate Power Limit command request. |
| 201 | */ |
| 202 | struct ApplyPowerLimitRequest |
| 203 | { |
| 204 | uint8_t groupID; //!< Group extension identification. |
| 205 | uint8_t powerLimitAction; //!< Power limit activation |
| 206 | uint16_t reserved; //!< Reserved |
| 207 | } __attribute__((packed)); |
| 208 | |
| 209 | /** @struct ApplyPowerLimitResponse |
| 210 | * |
| 211 | * DCMI payload for Acticate/Deactivate Power Limit command response. |
| 212 | */ |
| 213 | struct ApplyPowerLimitResponse |
| 214 | { |
| 215 | uint8_t groupID; //!< Group extension identification. |
| 216 | } __attribute__((packed)); |
| 217 | |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 218 | /** @struct GetMgmntCtrlIdStrRequest |
| 219 | * |
| 220 | * DCMI payload for Get Management Controller Identifier String cmd request. |
| 221 | */ |
| 222 | struct GetMgmntCtrlIdStrRequest |
| 223 | { |
| 224 | uint8_t groupID; //!< Group extension identification. |
| 225 | uint8_t offset; //!< Offset to read. |
| 226 | uint8_t bytes; //!< Number of bytes to read. |
| 227 | } __attribute__((packed)); |
| 228 | |
| 229 | /** @struct GetMgmntCtrlIdStrResponse |
| 230 | * |
| 231 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 232 | */ |
| 233 | struct GetMgmntCtrlIdStrResponse |
| 234 | { |
| 235 | uint8_t groupID; //!< Group extension identification. |
| 236 | uint8_t strLen; //!< ID string length. |
| 237 | char data[]; //!< ID string |
| 238 | } __attribute__((packed)); |
| 239 | |
| 240 | /** @struct SetMgmntCtrlIdStrRequest |
| 241 | * |
| 242 | * DCMI payload for Set Management Controller Identifier String cmd request. |
| 243 | */ |
| 244 | struct SetMgmntCtrlIdStrRequest |
| 245 | { |
| 246 | uint8_t groupID; //!< Group extension identification. |
| 247 | uint8_t offset; //!< Offset to write. |
| 248 | uint8_t bytes; //!< Number of bytes to read. |
| 249 | char data[]; //!< ID string |
| 250 | } __attribute__((packed)); |
| 251 | |
| 252 | /** @struct GetMgmntCtrlIdStrResponse |
| 253 | * |
| 254 | * DCMI payload for Get Management Controller Identifier String cmd response. |
| 255 | */ |
| 256 | struct SetMgmntCtrlIdStrResponse |
| 257 | { |
| 258 | uint8_t groupID; //!< Group extension identification. |
| 259 | uint8_t offset; //!< Last Offset Written. |
| 260 | } __attribute__((packed)); |
| 261 | |
Dhruvaraj Subhashchandran | e29be41 | 2018-01-16 05:11:56 -0600 | [diff] [blame] | 262 | /** @enum DCMICapParameters |
| 263 | * |
| 264 | * DCMI Capability parameters |
| 265 | */ |
| 266 | enum class DCMICapParameters |
| 267 | { |
| 268 | SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities |
| 269 | MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes |
| 270 | OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes |
| 271 | MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes |
| 272 | }; |
| 273 | |
| 274 | /** @struct GetDCMICapRequest |
| 275 | * |
| 276 | * DCMI payload for Get capabilities cmd request. |
| 277 | */ |
| 278 | struct GetDCMICapRequest |
| 279 | { |
| 280 | uint8_t groupID; //!< Group extension identification. |
| 281 | uint8_t param; //!< Capability parameter selector. |
| 282 | } __attribute__((packed)); |
| 283 | |
| 284 | /** @struct GetDCMICapRequest |
| 285 | * |
| 286 | * DCMI payload for Get capabilities cmd response. |
| 287 | */ |
| 288 | struct GetDCMICapResponse |
| 289 | { |
| 290 | uint8_t groupID; //!< Group extension identification. |
| 291 | uint8_t major; //!< DCMI Specification Conformance - major ver |
| 292 | uint8_t minor; //!< DCMI Specification Conformance - minor ver |
| 293 | uint8_t paramRevision; //!< Parameter Revision = 02h |
| 294 | uint8_t data[]; //!< Capability array |
| 295 | } __attribute__((packed)); |
| 296 | |
| 297 | /** @struct DCMICap |
| 298 | * |
| 299 | * DCMI capabilities protocol info. |
| 300 | */ |
| 301 | struct DCMICap |
| 302 | { |
| 303 | std::string name; //!< Name of DCMI capability. |
| 304 | uint8_t bytePosition; //!< Starting byte number from DCMI spec. |
| 305 | uint8_t position; //!< bit position from the DCMI spec. |
| 306 | uint8_t length; //!< Length of the value from DCMI spec. |
| 307 | }; |
| 308 | |
| 309 | using DCMICapList = std::vector<DCMICap>; |
| 310 | |
| 311 | /** @struct DCMICapEntry |
| 312 | * |
| 313 | * DCMI capabilities list and size for each parameter. |
| 314 | */ |
| 315 | struct DCMICapEntry |
| 316 | { |
| 317 | uint8_t size; //!< Size of capability array in bytes. |
| 318 | DCMICapList capList; //!< List of capabilities for a parameter. |
| 319 | }; |
| 320 | |
| 321 | using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>; |
| 322 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 323 | } // namespace dcmi |
| 324 | |
| 325 | #endif |