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