blob: 8ebc6603d362e4e6b15fc32a02f1e4931e6565b1 [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 Joseph6f6dd4d2017-07-12 20:07:11 +053014 IPMI_CMD_DCMI_GET_ASSET_TAG = 0x06,
Tom Joseph545dd232017-07-12 20:20:49 +053015 IPMI_CMD_DCMI_SET_ASSET_TAG = 0x08,
Tom Josephbe5eaa12017-07-12 19:54:44 +053016};
17
18namespace dcmi
19{
20
21static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
22static constexpr auto assetTagIntf =
23 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
24static constexpr auto assetTagProp = "AssetTag";
25
26namespace 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 Joseph6f6dd4d2017-07-12 20:07:11 +053036static constexpr auto groupExtId = 0xDC;
37
38static constexpr auto assetTagMaxOffset = 62;
39static constexpr auto assetTagMaxSize = 63;
40static constexpr auto maxBytes = 16;
41
42/** @struct GetAssetTagRequest
43 *
44 * DCMI payload for Get Asset Tag command request.
45 */
46struct 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 */
57struct GetAssetTagResponse
58{
59 uint8_t groupID; //!< Group extension identification.
60 uint8_t tagLength; //!< Total asset tag length.
61} __attribute__((packed));
62
Tom Joseph545dd232017-07-12 20:20:49 +053063/** @struct SetAssetTagRequest
64 *
65 * DCMI payload for Set Asset Tag command request.
66 */
67struct 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 */
78struct SetAssetTagResponse
79{
80 uint8_t groupID; //!< Group extension identification.
81 uint8_t tagLength; //!< Total asset tag length.
82} __attribute__((packed));
83
Tom Josephbe5eaa12017-07-12 19:54:44 +053084/** @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 */
92void 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 */
98std::string readAssetTag();
99
Tom Josephbe5b9892017-07-15 00:55:23 +0530100/** @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 */
104void writeAssetTag(const std::string& assetTag);
105
Tom Josephb9d86f42017-07-26 18:03:47 +0530106/** @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 */
112uint32_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 */
121bool getPcapEnabled(sdbusplus::bus::bus& bus);
122
123/** @struct GetPowerLimitRequest
124 *
125 * DCMI payload for Get Power Limit command request.
126 */
127struct 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 */
137struct 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 Josephbe5eaa12017-07-12 19:54:44 +0530148} // namespace dcmi
149
150#endif