blob: 91707f3b967f1f5b4c97345e1736e96b3871af9a [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,
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030020 GET_MGMNT_CTRL_ID_STR = 0x09,
21 SET_MGMNT_CTRL_ID_STR = 0x0A,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053022};
23
Tom Josephbe5eaa12017-07-12 19:54:44 +053024static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
25static constexpr auto assetTagIntf =
26 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
27static constexpr auto assetTagProp = "AssetTag";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030028static constexpr auto networkServiceName = "xyz.openbmc_project.Network";
29static constexpr auto networkConfigObj =
30 "/xyz/openbmc_project/network/config";
31static constexpr auto networkConfigIntf =
32 "xyz.openbmc_project.Network.SystemConfiguration";
33static constexpr auto hostNameProp = "HostName";
Tom Josephbe5eaa12017-07-12 19:54:44 +053034
35namespace assettag
36{
37
38 using ObjectPath = std::string;
39 using Service = std::string;
40 using Interfaces = std::vector<std::string>;
41 using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
42
43} //namespace assettag
44
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053045static constexpr auto groupExtId = 0xDC;
46
47static constexpr auto assetTagMaxOffset = 62;
48static constexpr auto assetTagMaxSize = 63;
49static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030050static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053051
52/** @struct GetAssetTagRequest
53 *
54 * DCMI payload for Get Asset Tag command request.
55 */
56struct GetAssetTagRequest
57{
58 uint8_t groupID; //!< Group extension identification.
59 uint8_t offset; //!< Offset to read.
60 uint8_t bytes; //!< Number of bytes to read.
61} __attribute__((packed));
62
63/** @struct GetAssetTagResponse
64 *
65 * DCMI payload for Get Asset Tag command response.
66 */
67struct GetAssetTagResponse
68{
69 uint8_t groupID; //!< Group extension identification.
70 uint8_t tagLength; //!< Total asset tag length.
71} __attribute__((packed));
72
Tom Joseph545dd232017-07-12 20:20:49 +053073/** @struct SetAssetTagRequest
74 *
75 * DCMI payload for Set Asset Tag command request.
76 */
77struct SetAssetTagRequest
78{
79 uint8_t groupID; //!< Group extension identification.
80 uint8_t offset; //!< Offset to write.
81 uint8_t bytes; //!< Number of bytes to write.
82} __attribute__((packed));
83
84/** @struct SetAssetTagResponse
85 *
86 * DCMI payload for Set Asset Tag command response.
87 */
88struct SetAssetTagResponse
89{
90 uint8_t groupID; //!< Group extension identification.
91 uint8_t tagLength; //!< Total asset tag length.
92} __attribute__((packed));
93
Tom Josephbe5eaa12017-07-12 19:54:44 +053094/** @brief Read the object tree to fetch the object path that implemented the
95 * Asset tag interface.
96 *
97 * @param[in,out] objectTree - object tree
98 *
99 * @return On success return the object tree with the object path that
100 * implemented the AssetTag interface.
101 */
102void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
103
104/** @brief Read the asset tag of the server
105 *
106 * @return On success return the asset tag.
107 */
108std::string readAssetTag();
109
Tom Josephbe5b9892017-07-15 00:55:23 +0530110/** @brief Write the asset tag to the asset tag DBUS property
111 *
112 * @param[in] assetTag - Asset Tag to be written to the property.
113 */
114void writeAssetTag(const std::string& assetTag);
115
Tom Josephb9d86f42017-07-26 18:03:47 +0530116/** @brief Read the current power cap value
117 *
118 * @param[in] bus - dbus connection
119 *
120 * @return On success return the power cap value.
121 */
122uint32_t getPcap(sdbusplus::bus::bus& bus);
123
124/** @brief Check if the power capping is enabled
125 *
126 * @param[in] bus - dbus connection
127 *
128 * @return true if the powerCap is enabled and false if the powercap
129 * is disabled.
130 */
131bool getPcapEnabled(sdbusplus::bus::bus& bus);
132
133/** @struct GetPowerLimitRequest
134 *
135 * DCMI payload for Get Power Limit command request.
136 */
137struct GetPowerLimitRequest
138{
139 uint8_t groupID; //!< Group extension identification.
140 uint16_t reserved; //!< Reserved
141} __attribute__((packed));
142
143/** @struct GetPowerLimitResponse
144 *
145 * DCMI payload for Get Power Limit command response.
146 */
147struct GetPowerLimitResponse
148{
149 uint8_t groupID; //!< Group extension identification.
150 uint16_t reserved; //!< Reserved.
151 uint8_t exceptionAction; //!< Exception action.
152 uint16_t powerLimit; //!< Power limit requested in watts.
153 uint32_t correctionTime; //!< Correction time limit in milliseconds.
154 uint16_t reserved1; //!< Reserved.
155 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
156} __attribute__((packed));
157
Tom Joseph46fa37d2017-07-26 18:11:55 +0530158/** @brief Set the power cap value
159 *
160 * @param[in] bus - dbus connection
161 * @param[in] powerCap - power cap value
162 */
163void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
164
165/** @struct SetPowerLimitRequest
166 *
167 * DCMI payload for Set Power Limit command request.
168 */
169struct SetPowerLimitRequest
170{
171 uint8_t groupID; //!< Group extension identification.
172 uint16_t reserved; //!< Reserved
173 uint8_t reserved1; //!< Reserved
174 uint8_t exceptionAction; //!< Exception action.
175 uint16_t powerLimit; //!< Power limit requested in watts.
176 uint32_t correctionTime; //!< Correction time limit in milliseconds.
177 uint16_t reserved2; //!< Reserved.
178 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
179} __attribute__((packed));
180
181/** @struct SetPowerLimitResponse
182 *
183 * DCMI payload for Set Power Limit command response.
184 */
185struct SetPowerLimitResponse
186{
187 uint8_t groupID; //!< Group extension identification.
188} __attribute__((packed));
189
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530190/** @brief Enable or disable the power capping
191 *
192 * @param[in] bus - dbus connection
193 * @param[in] enabled - enable/disable
194 */
195void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
196
197/** @struct ApplyPowerLimitRequest
198 *
199 * DCMI payload for Activate/Deactivate Power Limit command request.
200 */
201struct ApplyPowerLimitRequest
202{
203 uint8_t groupID; //!< Group extension identification.
204 uint8_t powerLimitAction; //!< Power limit activation
205 uint16_t reserved; //!< Reserved
206} __attribute__((packed));
207
208/** @struct ApplyPowerLimitResponse
209 *
210 * DCMI payload for Acticate/Deactivate Power Limit command response.
211 */
212struct ApplyPowerLimitResponse
213{
214 uint8_t groupID; //!< Group extension identification.
215} __attribute__((packed));
216
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300217/** @struct GetMgmntCtrlIdStrRequest
218 *
219 * DCMI payload for Get Management Controller Identifier String cmd request.
220 */
221struct GetMgmntCtrlIdStrRequest
222{
223 uint8_t groupID; //!< Group extension identification.
224 uint8_t offset; //!< Offset to read.
225 uint8_t bytes; //!< Number of bytes to read.
226} __attribute__((packed));
227
228/** @struct GetMgmntCtrlIdStrResponse
229 *
230 * DCMI payload for Get Management Controller Identifier String cmd response.
231 */
232struct GetMgmntCtrlIdStrResponse
233{
234 uint8_t groupID; //!< Group extension identification.
235 uint8_t strLen; //!< ID string length.
236 char data[]; //!< ID string
237} __attribute__((packed));
238
239/** @struct SetMgmntCtrlIdStrRequest
240 *
241 * DCMI payload for Set Management Controller Identifier String cmd request.
242 */
243struct SetMgmntCtrlIdStrRequest
244{
245 uint8_t groupID; //!< Group extension identification.
246 uint8_t offset; //!< Offset to write.
247 uint8_t bytes; //!< Number of bytes to read.
248 char data[]; //!< ID string
249} __attribute__((packed));
250
251/** @struct GetMgmntCtrlIdStrResponse
252 *
253 * DCMI payload for Get Management Controller Identifier String cmd response.
254 */
255struct SetMgmntCtrlIdStrResponse
256{
257 uint8_t groupID; //!< Group extension identification.
258 uint8_t offset; //!< Last Offset Written.
259} __attribute__((packed));
260
Tom Josephbe5eaa12017-07-12 19:54:44 +0530261} // namespace dcmi
262
263#endif