blob: 212e9ac390ca696ab92575426904cf1cc1afaa06 [file] [log] [blame]
Tom Josephbe5eaa12017-07-12 19:54:44 +05301#ifndef __HOST_IPMI_DCMI_HANDLER_H__
2#define __HOST_IPMI_DCMI_HANDLER_H__
3
4#include <map>
5#include <string>
6#include <vector>
Tom Josephb9d86f42017-07-26 18:03:47 +05307#include <sdbusplus/bus.hpp>
Tom Josephbe5eaa12017-07-12 19:54:44 +05308
Tom Josephbe5eaa12017-07-12 19:54:44 +05309namespace dcmi
10{
11
Ratan Gupta11ddbd22017-08-05 11:59:39 +053012enum Commands
13{
14 // Get capability bits
15 GET_POWER_LIMIT = 0x03,
16 SET_POWER_LIMIT = 0x04,
17 APPLY_POWER_LIMIT = 0x05,
18 GET_ASSET_TAG = 0x06,
19 SET_ASSET_TAG = 0x08,
20};
21
22
Tom Josephbe5eaa12017-07-12 19:54:44 +053023static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
24static constexpr auto assetTagIntf =
25 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
26static constexpr auto assetTagProp = "AssetTag";
27
28namespace assettag
29{
30
31 using ObjectPath = std::string;
32 using Service = std::string;
33 using Interfaces = std::vector<std::string>;
34 using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
35
36} //namespace assettag
37
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053038static constexpr auto groupExtId = 0xDC;
39
40static constexpr auto assetTagMaxOffset = 62;
41static constexpr auto assetTagMaxSize = 63;
42static constexpr auto maxBytes = 16;
43
44/** @struct GetAssetTagRequest
45 *
46 * DCMI payload for Get Asset Tag command request.
47 */
48struct GetAssetTagRequest
49{
50 uint8_t groupID; //!< Group extension identification.
51 uint8_t offset; //!< Offset to read.
52 uint8_t bytes; //!< Number of bytes to read.
53} __attribute__((packed));
54
55/** @struct GetAssetTagResponse
56 *
57 * DCMI payload for Get Asset Tag command response.
58 */
59struct GetAssetTagResponse
60{
61 uint8_t groupID; //!< Group extension identification.
62 uint8_t tagLength; //!< Total asset tag length.
63} __attribute__((packed));
64
Tom Joseph545dd232017-07-12 20:20:49 +053065/** @struct SetAssetTagRequest
66 *
67 * DCMI payload for Set Asset Tag command request.
68 */
69struct SetAssetTagRequest
70{
71 uint8_t groupID; //!< Group extension identification.
72 uint8_t offset; //!< Offset to write.
73 uint8_t bytes; //!< Number of bytes to write.
74} __attribute__((packed));
75
76/** @struct SetAssetTagResponse
77 *
78 * DCMI payload for Set Asset Tag command response.
79 */
80struct SetAssetTagResponse
81{
82 uint8_t groupID; //!< Group extension identification.
83 uint8_t tagLength; //!< Total asset tag length.
84} __attribute__((packed));
85
Tom Josephbe5eaa12017-07-12 19:54:44 +053086/** @brief Read the object tree to fetch the object path that implemented the
87 * Asset tag interface.
88 *
89 * @param[in,out] objectTree - object tree
90 *
91 * @return On success return the object tree with the object path that
92 * implemented the AssetTag interface.
93 */
94void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
95
96/** @brief Read the asset tag of the server
97 *
98 * @return On success return the asset tag.
99 */
100std::string readAssetTag();
101
Tom Josephbe5b9892017-07-15 00:55:23 +0530102/** @brief Write the asset tag to the asset tag DBUS property
103 *
104 * @param[in] assetTag - Asset Tag to be written to the property.
105 */
106void writeAssetTag(const std::string& assetTag);
107
Tom Josephb9d86f42017-07-26 18:03:47 +0530108/** @brief Read the current power cap value
109 *
110 * @param[in] bus - dbus connection
111 *
112 * @return On success return the power cap value.
113 */
114uint32_t getPcap(sdbusplus::bus::bus& bus);
115
116/** @brief Check if the power capping is enabled
117 *
118 * @param[in] bus - dbus connection
119 *
120 * @return true if the powerCap is enabled and false if the powercap
121 * is disabled.
122 */
123bool getPcapEnabled(sdbusplus::bus::bus& bus);
124
125/** @struct GetPowerLimitRequest
126 *
127 * DCMI payload for Get Power Limit command request.
128 */
129struct GetPowerLimitRequest
130{
131 uint8_t groupID; //!< Group extension identification.
132 uint16_t reserved; //!< Reserved
133} __attribute__((packed));
134
135/** @struct GetPowerLimitResponse
136 *
137 * DCMI payload for Get Power Limit command response.
138 */
139struct GetPowerLimitResponse
140{
141 uint8_t groupID; //!< Group extension identification.
142 uint16_t reserved; //!< Reserved.
143 uint8_t exceptionAction; //!< Exception action.
144 uint16_t powerLimit; //!< Power limit requested in watts.
145 uint32_t correctionTime; //!< Correction time limit in milliseconds.
146 uint16_t reserved1; //!< Reserved.
147 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
148} __attribute__((packed));
149
Tom Joseph46fa37d2017-07-26 18:11:55 +0530150/** @brief Set the power cap value
151 *
152 * @param[in] bus - dbus connection
153 * @param[in] powerCap - power cap value
154 */
155void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
156
157/** @struct SetPowerLimitRequest
158 *
159 * DCMI payload for Set Power Limit command request.
160 */
161struct SetPowerLimitRequest
162{
163 uint8_t groupID; //!< Group extension identification.
164 uint16_t reserved; //!< Reserved
165 uint8_t reserved1; //!< Reserved
166 uint8_t exceptionAction; //!< Exception action.
167 uint16_t powerLimit; //!< Power limit requested in watts.
168 uint32_t correctionTime; //!< Correction time limit in milliseconds.
169 uint16_t reserved2; //!< Reserved.
170 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
171} __attribute__((packed));
172
173/** @struct SetPowerLimitResponse
174 *
175 * DCMI payload for Set Power Limit command response.
176 */
177struct SetPowerLimitResponse
178{
179 uint8_t groupID; //!< Group extension identification.
180} __attribute__((packed));
181
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530182/** @brief Enable or disable the power capping
183 *
184 * @param[in] bus - dbus connection
185 * @param[in] enabled - enable/disable
186 */
187void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
188
189/** @struct ApplyPowerLimitRequest
190 *
191 * DCMI payload for Activate/Deactivate Power Limit command request.
192 */
193struct ApplyPowerLimitRequest
194{
195 uint8_t groupID; //!< Group extension identification.
196 uint8_t powerLimitAction; //!< Power limit activation
197 uint16_t reserved; //!< Reserved
198} __attribute__((packed));
199
200/** @struct ApplyPowerLimitResponse
201 *
202 * DCMI payload for Acticate/Deactivate Power Limit command response.
203 */
204struct ApplyPowerLimitResponse
205{
206 uint8_t groupID; //!< Group extension identification.
207} __attribute__((packed));
208
Tom Josephbe5eaa12017-07-12 19:54:44 +0530209} // namespace dcmi
210
211#endif