blob: 288e4d78f3143aca6cf31029f89519084f09b6df [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
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -060015 GET_CAPABILITIES = 0x01,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053016 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 Vovchenko8f7a6f62017-08-17 00:31:14 +030021 GET_MGMNT_CTRL_ID_STR = 0x09,
22 SET_MGMNT_CTRL_ID_STR = 0x0A,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053023};
24
Tom Josephbe5eaa12017-07-12 19:54:44 +053025static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
26static constexpr auto assetTagIntf =
27 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
28static constexpr auto assetTagProp = "AssetTag";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030029static constexpr auto networkServiceName = "xyz.openbmc_project.Network";
30static constexpr auto networkConfigObj =
31 "/xyz/openbmc_project/network/config";
32static constexpr auto networkConfigIntf =
33 "xyz.openbmc_project.Network.SystemConfiguration";
34static constexpr auto hostNameProp = "HostName";
Tom Josephbe5eaa12017-07-12 19:54:44 +053035
36namespace 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 Joseph6f6dd4d2017-07-12 20:07:11 +053046static constexpr auto groupExtId = 0xDC;
47
48static constexpr auto assetTagMaxOffset = 62;
49static constexpr auto assetTagMaxSize = 63;
50static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030051static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053052
53/** @struct GetAssetTagRequest
54 *
55 * DCMI payload for Get Asset Tag command request.
56 */
57struct 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 */
68struct GetAssetTagResponse
69{
70 uint8_t groupID; //!< Group extension identification.
71 uint8_t tagLength; //!< Total asset tag length.
72} __attribute__((packed));
73
Tom Joseph545dd232017-07-12 20:20:49 +053074/** @struct SetAssetTagRequest
75 *
76 * DCMI payload for Set Asset Tag command request.
77 */
78struct 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 */
89struct SetAssetTagResponse
90{
91 uint8_t groupID; //!< Group extension identification.
92 uint8_t tagLength; //!< Total asset tag length.
93} __attribute__((packed));
94
Tom Josephbe5eaa12017-07-12 19:54:44 +053095/** @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 */
103void 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 */
109std::string readAssetTag();
110
Tom Josephbe5b9892017-07-15 00:55:23 +0530111/** @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 */
115void writeAssetTag(const std::string& assetTag);
116
Tom Josephb9d86f42017-07-26 18:03:47 +0530117/** @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 */
123uint32_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 */
132bool getPcapEnabled(sdbusplus::bus::bus& bus);
133
134/** @struct GetPowerLimitRequest
135 *
136 * DCMI payload for Get Power Limit command request.
137 */
138struct 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 */
148struct 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 Joseph46fa37d2017-07-26 18:11:55 +0530159/** @brief Set the power cap value
160 *
161 * @param[in] bus - dbus connection
162 * @param[in] powerCap - power cap value
163 */
164void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
165
166/** @struct SetPowerLimitRequest
167 *
168 * DCMI payload for Set Power Limit command request.
169 */
170struct 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 */
186struct SetPowerLimitResponse
187{
188 uint8_t groupID; //!< Group extension identification.
189} __attribute__((packed));
190
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530191/** @brief Enable or disable the power capping
192 *
193 * @param[in] bus - dbus connection
194 * @param[in] enabled - enable/disable
195 */
196void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
197
198/** @struct ApplyPowerLimitRequest
199 *
200 * DCMI payload for Activate/Deactivate Power Limit command request.
201 */
202struct 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 */
213struct ApplyPowerLimitResponse
214{
215 uint8_t groupID; //!< Group extension identification.
216} __attribute__((packed));
217
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300218/** @struct GetMgmntCtrlIdStrRequest
219 *
220 * DCMI payload for Get Management Controller Identifier String cmd request.
221 */
222struct 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 */
233struct 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 */
244struct 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 */
256struct SetMgmntCtrlIdStrResponse
257{
258 uint8_t groupID; //!< Group extension identification.
259 uint8_t offset; //!< Last Offset Written.
260} __attribute__((packed));
261
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600262/** @enum DCMICapParameters
263 *
264 * DCMI Capability parameters
265 */
266enum 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 */
278struct 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 */
288struct 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 */
301struct 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
309using DCMICapList = std::vector<DCMICap>;
310
311/** @struct DCMICapEntry
312 *
313 * DCMI capabilities list and size for each parameter.
314 */
315struct DCMICapEntry
316{
317 uint8_t size; //!< Size of capability array in bytes.
318 DCMICapList capList; //!< List of capabilities for a parameter.
319};
320
321using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
322
Tom Josephbe5eaa12017-07-12 19:54:44 +0530323} // namespace dcmi
324
325#endif