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 | |
| 9 | // IPMI commands for net functions. |
| 10 | enum ipmi_netfn_sen_cmds |
| 11 | { |
| 12 | // Get capability bits |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame^] | 13 | IPMI_CMD_DCMI_GET_POWER_LIMIT = 0x03, |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 14 | IPMI_CMD_DCMI_GET_ASSET_TAG = 0x06, |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 15 | IPMI_CMD_DCMI_SET_ASSET_TAG = 0x08, |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | namespace dcmi |
| 19 | { |
| 20 | |
| 21 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 22 | static constexpr auto assetTagIntf = |
| 23 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
| 24 | static constexpr auto assetTagProp = "AssetTag"; |
| 25 | |
| 26 | namespace assettag |
| 27 | { |
| 28 | |
| 29 | using ObjectPath = std::string; |
| 30 | using Service = std::string; |
| 31 | using Interfaces = std::vector<std::string>; |
| 32 | using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>; |
| 33 | |
| 34 | } //namespace assettag |
| 35 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 36 | static constexpr auto groupExtId = 0xDC; |
| 37 | |
| 38 | static constexpr auto assetTagMaxOffset = 62; |
| 39 | static constexpr auto assetTagMaxSize = 63; |
| 40 | static constexpr auto maxBytes = 16; |
| 41 | |
| 42 | /** @struct GetAssetTagRequest |
| 43 | * |
| 44 | * DCMI payload for Get Asset Tag command request. |
| 45 | */ |
| 46 | struct GetAssetTagRequest |
| 47 | { |
| 48 | uint8_t groupID; //!< Group extension identification. |
| 49 | uint8_t offset; //!< Offset to read. |
| 50 | uint8_t bytes; //!< Number of bytes to read. |
| 51 | } __attribute__((packed)); |
| 52 | |
| 53 | /** @struct GetAssetTagResponse |
| 54 | * |
| 55 | * DCMI payload for Get Asset Tag command response. |
| 56 | */ |
| 57 | struct GetAssetTagResponse |
| 58 | { |
| 59 | uint8_t groupID; //!< Group extension identification. |
| 60 | uint8_t tagLength; //!< Total asset tag length. |
| 61 | } __attribute__((packed)); |
| 62 | |
Tom Joseph | 545dd23 | 2017-07-12 20:20:49 +0530 | [diff] [blame] | 63 | /** @struct SetAssetTagRequest |
| 64 | * |
| 65 | * DCMI payload for Set Asset Tag command request. |
| 66 | */ |
| 67 | struct SetAssetTagRequest |
| 68 | { |
| 69 | uint8_t groupID; //!< Group extension identification. |
| 70 | uint8_t offset; //!< Offset to write. |
| 71 | uint8_t bytes; //!< Number of bytes to write. |
| 72 | } __attribute__((packed)); |
| 73 | |
| 74 | /** @struct SetAssetTagResponse |
| 75 | * |
| 76 | * DCMI payload for Set Asset Tag command response. |
| 77 | */ |
| 78 | struct SetAssetTagResponse |
| 79 | { |
| 80 | uint8_t groupID; //!< Group extension identification. |
| 81 | uint8_t tagLength; //!< Total asset tag length. |
| 82 | } __attribute__((packed)); |
| 83 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 84 | /** @brief Read the object tree to fetch the object path that implemented the |
| 85 | * Asset tag interface. |
| 86 | * |
| 87 | * @param[in,out] objectTree - object tree |
| 88 | * |
| 89 | * @return On success return the object tree with the object path that |
| 90 | * implemented the AssetTag interface. |
| 91 | */ |
| 92 | void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree); |
| 93 | |
| 94 | /** @brief Read the asset tag of the server |
| 95 | * |
| 96 | * @return On success return the asset tag. |
| 97 | */ |
| 98 | std::string readAssetTag(); |
| 99 | |
Tom Joseph | be5b989 | 2017-07-15 00:55:23 +0530 | [diff] [blame] | 100 | /** @brief Write the asset tag to the asset tag DBUS property |
| 101 | * |
| 102 | * @param[in] assetTag - Asset Tag to be written to the property. |
| 103 | */ |
| 104 | void writeAssetTag(const std::string& assetTag); |
| 105 | |
Tom Joseph | b9d86f4 | 2017-07-26 18:03:47 +0530 | [diff] [blame^] | 106 | /** @brief Read the current power cap value |
| 107 | * |
| 108 | * @param[in] bus - dbus connection |
| 109 | * |
| 110 | * @return On success return the power cap value. |
| 111 | */ |
| 112 | uint32_t getPcap(sdbusplus::bus::bus& bus); |
| 113 | |
| 114 | /** @brief Check if the power capping is enabled |
| 115 | * |
| 116 | * @param[in] bus - dbus connection |
| 117 | * |
| 118 | * @return true if the powerCap is enabled and false if the powercap |
| 119 | * is disabled. |
| 120 | */ |
| 121 | bool getPcapEnabled(sdbusplus::bus::bus& bus); |
| 122 | |
| 123 | /** @struct GetPowerLimitRequest |
| 124 | * |
| 125 | * DCMI payload for Get Power Limit command request. |
| 126 | */ |
| 127 | struct GetPowerLimitRequest |
| 128 | { |
| 129 | uint8_t groupID; //!< Group extension identification. |
| 130 | uint16_t reserved; //!< Reserved |
| 131 | } __attribute__((packed)); |
| 132 | |
| 133 | /** @struct GetPowerLimitResponse |
| 134 | * |
| 135 | * DCMI payload for Get Power Limit command response. |
| 136 | */ |
| 137 | struct GetPowerLimitResponse |
| 138 | { |
| 139 | uint8_t groupID; //!< Group extension identification. |
| 140 | uint16_t reserved; //!< Reserved. |
| 141 | uint8_t exceptionAction; //!< Exception action. |
| 142 | uint16_t powerLimit; //!< Power limit requested in watts. |
| 143 | uint32_t correctionTime; //!< Correction time limit in milliseconds. |
| 144 | uint16_t reserved1; //!< Reserved. |
| 145 | uint16_t samplingPeriod; //!< Statistics sampling period in seconds. |
| 146 | } __attribute__((packed)); |
| 147 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 148 | } // namespace dcmi |
| 149 | |
| 150 | #endif |