blob: 8b16e3d9836d398eefac5830d6da754aac8088e0 [file] [log] [blame]
Patrick Venture46470a32018-09-07 19:26:25 -07001#pragma once
Tom Josephbe5eaa12017-07-12 19:54:44 +05302
Patrick Venture0b02be92018-08-31 11:55:55 -07003#include "nlohmann/json.hpp"
4
Tom Josephbe5eaa12017-07-12 19:54:44 +05305#include <map>
Patrick Venture0b02be92018-08-31 11:55:55 -07006#include <sdbusplus/bus.hpp>
Tom Josephbe5eaa12017-07-12 19:54:44 +05307#include <string>
8#include <vector>
9
Tom Josephbe5eaa12017-07-12 19:54:44 +053010namespace dcmi
11{
12
Deepak Kodihalli0b459552018-02-06 06:25:12 -060013using NumInstances = size_t;
14using Json = nlohmann::json;
15
Ratan Gupta11ddbd22017-08-05 11:59:39 +053016enum Commands
17{
18 // Get capability bits
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -060019 GET_CAPABILITIES = 0x01,
Marri Devender Rao66c5fda2018-01-18 10:48:37 -060020 GET_POWER_READING = 0x02,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053021 GET_POWER_LIMIT = 0x03,
22 SET_POWER_LIMIT = 0x04,
23 APPLY_POWER_LIMIT = 0x05,
24 GET_ASSET_TAG = 0x06,
Deepak Kodihalli0b459552018-02-06 06:25:12 -060025 GET_SENSOR_INFO = 0x07,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053026 SET_ASSET_TAG = 0x08,
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030027 GET_MGMNT_CTRL_ID_STR = 0x09,
28 SET_MGMNT_CTRL_ID_STR = 0x0A,
Deepak Kodihalliee717d72018-01-24 04:53:09 -060029 GET_TEMP_READINGS = 0x10,
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060030 SET_CONF_PARAMS = 0x12,
31 GET_CONF_PARAMS = 0x13,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053032};
33
Tom Josephbe5eaa12017-07-12 19:54:44 +053034static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
35static constexpr auto assetTagIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070036 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
Tom Josephbe5eaa12017-07-12 19:54:44 +053037static constexpr auto assetTagProp = "AssetTag";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030038static constexpr auto networkServiceName = "xyz.openbmc_project.Network";
Patrick Venture0b02be92018-08-31 11:55:55 -070039static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030040static constexpr auto networkConfigIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070041 "xyz.openbmc_project.Network.SystemConfiguration";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030042static constexpr auto hostNameProp = "HostName";
Deepak Kodihalliee717d72018-01-24 04:53:09 -060043static constexpr auto temperatureSensorType = 0x01;
Deepak Kodihalli0b459552018-02-06 06:25:12 -060044static constexpr auto maxInstances = 255;
Kirill Pakhomova2573622018-11-02 19:00:18 +030045static constexpr auto gDCMISensorsConfig =
Deepak Kodihalli0b459552018-02-06 06:25:12 -060046 "/usr/share/ipmi-providers/dcmi_sensors.json";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060047static constexpr auto ethernetIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070048 "xyz.openbmc_project.Network.EthernetInterface";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060049static constexpr auto ethernetDefaultChannelNum = 0x1;
50static constexpr auto networkRoot = "/xyz/openbmc_project/network";
51static constexpr auto dhcpObj = "/xyz/openbmc_project/network/config/dhcp";
52static constexpr auto dhcpIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070053 "xyz.openbmc_project.Network.DHCPConfiguration";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060054static constexpr auto systemBusName = "org.freedesktop.systemd1";
55static constexpr auto systemPath = "/org/freedesktop/systemd1";
56static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager";
Kirill Pakhomova2573622018-11-02 19:00:18 +030057static constexpr auto gDCMICapabilitiesConfig =
58 "/usr/share/ipmi-providers/dcmi_cap.json";
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +030059static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement";
60static constexpr auto gDCMIPowerMgmtSupported = 0x1;
Tom Josephbe5eaa12017-07-12 19:54:44 +053061
62namespace assettag
63{
64
Patrick Venture0b02be92018-08-31 11:55:55 -070065using ObjectPath = std::string;
66using Service = std::string;
67using Interfaces = std::vector<std::string>;
68using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053069
Patrick Venture0b02be92018-08-31 11:55:55 -070070} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053071
Deepak Kodihalliee717d72018-01-24 04:53:09 -060072namespace temp_readings
73{
Patrick Venture0b02be92018-08-31 11:55:55 -070074static constexpr auto maxDataSets = 8;
75static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060076
Patrick Venture0b02be92018-08-31 11:55:55 -070077/** @struct Response
78 *
79 * DCMI payload for Get Temperature Readings response
80 */
81struct Response
82{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060083#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070084 uint8_t temperature : 7; //!< Temperature reading in Celsius
85 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060086#endif
87#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070088 uint8_t sign : 1; //!< Sign bit
89 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060090#endif
Patrick Venture0b02be92018-08-31 11:55:55 -070091 uint8_t instance; //!< Entity instance number
92} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060093
Patrick Venture0b02be92018-08-31 11:55:55 -070094using ResponseList = std::vector<Response>;
95using Value = uint8_t;
96using Sign = bool;
97using Temperature = std::tuple<Value, Sign>;
98} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -060099
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600100namespace sensor_info
101{
Patrick Venture0b02be92018-08-31 11:55:55 -0700102static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600103
Patrick Venture0b02be92018-08-31 11:55:55 -0700104/** @struct Response
105 *
106 * DCMI payload for Get Sensor Info response
107 */
108struct Response
109{
110 uint8_t recordIdLsb; //!< SDR record id LS byte
111 uint8_t recordIdMsb; //!< SDR record id MS byte
112} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600113
Patrick Venture0b02be92018-08-31 11:55:55 -0700114using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600115} // namespace sensor_info
116
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530117static constexpr auto groupExtId = 0xDC;
118
119static constexpr auto assetTagMaxOffset = 62;
120static constexpr auto assetTagMaxSize = 63;
121static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300122static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530123
124/** @struct GetAssetTagRequest
125 *
126 * DCMI payload for Get Asset Tag command request.
127 */
128struct GetAssetTagRequest
129{
Patrick Venture0b02be92018-08-31 11:55:55 -0700130 uint8_t groupID; //!< Group extension identification.
131 uint8_t offset; //!< Offset to read.
132 uint8_t bytes; //!< Number of bytes to read.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530133} __attribute__((packed));
134
135/** @struct GetAssetTagResponse
136 *
137 * DCMI payload for Get Asset Tag command response.
138 */
139struct GetAssetTagResponse
140{
Patrick Venture0b02be92018-08-31 11:55:55 -0700141 uint8_t groupID; //!< Group extension identification.
142 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530143} __attribute__((packed));
144
Tom Joseph545dd232017-07-12 20:20:49 +0530145/** @struct SetAssetTagRequest
146 *
147 * DCMI payload for Set Asset Tag command request.
148 */
149struct SetAssetTagRequest
150{
Patrick Venture0b02be92018-08-31 11:55:55 -0700151 uint8_t groupID; //!< Group extension identification.
152 uint8_t offset; //!< Offset to write.
153 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530154} __attribute__((packed));
155
156/** @struct SetAssetTagResponse
157 *
158 * DCMI payload for Set Asset Tag command response.
159 */
160struct SetAssetTagResponse
161{
Patrick Venture0b02be92018-08-31 11:55:55 -0700162 uint8_t groupID; //!< Group extension identification.
163 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530164} __attribute__((packed));
165
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +0300166/** @brief Check whether DCMI power management is supported
167 * in the DCMI Capabilities config file.
168 *
169 * @return True if DCMI power management is supported
170 */
171bool isDCMIPowerMgmtSupported();
172
Tom Josephbe5eaa12017-07-12 19:54:44 +0530173/** @brief Read the object tree to fetch the object path that implemented the
174 * Asset tag interface.
175 *
176 * @param[in,out] objectTree - object tree
177 *
178 * @return On success return the object tree with the object path that
179 * implemented the AssetTag interface.
180 */
181void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
182
183/** @brief Read the asset tag of the server
184 *
185 * @return On success return the asset tag.
186 */
187std::string readAssetTag();
188
Tom Josephbe5b9892017-07-15 00:55:23 +0530189/** @brief Write the asset tag to the asset tag DBUS property
190 *
191 * @param[in] assetTag - Asset Tag to be written to the property.
192 */
193void writeAssetTag(const std::string& assetTag);
194
Tom Josephb9d86f42017-07-26 18:03:47 +0530195/** @brief Read the current power cap value
196 *
197 * @param[in] bus - dbus connection
198 *
199 * @return On success return the power cap value.
200 */
201uint32_t getPcap(sdbusplus::bus::bus& bus);
202
203/** @brief Check if the power capping is enabled
204 *
205 * @param[in] bus - dbus connection
206 *
207 * @return true if the powerCap is enabled and false if the powercap
208 * is disabled.
209 */
210bool getPcapEnabled(sdbusplus::bus::bus& bus);
211
212/** @struct GetPowerLimitRequest
213 *
214 * DCMI payload for Get Power Limit command request.
215 */
216struct GetPowerLimitRequest
217{
Patrick Venture0b02be92018-08-31 11:55:55 -0700218 uint8_t groupID; //!< Group extension identification.
219 uint16_t reserved; //!< Reserved
Tom Josephb9d86f42017-07-26 18:03:47 +0530220} __attribute__((packed));
221
222/** @struct GetPowerLimitResponse
223 *
224 * DCMI payload for Get Power Limit command response.
225 */
226struct GetPowerLimitResponse
227{
Patrick Venture0b02be92018-08-31 11:55:55 -0700228 uint8_t groupID; //!< Group extension identification.
229 uint16_t reserved; //!< Reserved.
230 uint8_t exceptionAction; //!< Exception action.
231 uint16_t powerLimit; //!< Power limit requested in watts.
232 uint32_t correctionTime; //!< Correction time limit in milliseconds.
233 uint16_t reserved1; //!< Reserved.
234 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530235} __attribute__((packed));
236
Tom Joseph46fa37d2017-07-26 18:11:55 +0530237/** @brief Set the power cap value
238 *
239 * @param[in] bus - dbus connection
240 * @param[in] powerCap - power cap value
241 */
242void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
243
244/** @struct SetPowerLimitRequest
245 *
246 * DCMI payload for Set Power Limit command request.
247 */
248struct SetPowerLimitRequest
249{
Patrick Venture0b02be92018-08-31 11:55:55 -0700250 uint8_t groupID; //!< Group extension identification.
251 uint16_t reserved; //!< Reserved
252 uint8_t reserved1; //!< Reserved
253 uint8_t exceptionAction; //!< Exception action.
254 uint16_t powerLimit; //!< Power limit requested in watts.
255 uint32_t correctionTime; //!< Correction time limit in milliseconds.
256 uint16_t reserved2; //!< Reserved.
257 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530258} __attribute__((packed));
259
260/** @struct SetPowerLimitResponse
261 *
262 * DCMI payload for Set Power Limit command response.
263 */
264struct SetPowerLimitResponse
265{
Patrick Venture0b02be92018-08-31 11:55:55 -0700266 uint8_t groupID; //!< Group extension identification.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530267} __attribute__((packed));
268
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530269/** @brief Enable or disable the power capping
270 *
271 * @param[in] bus - dbus connection
272 * @param[in] enabled - enable/disable
273 */
274void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
275
276/** @struct ApplyPowerLimitRequest
277 *
278 * DCMI payload for Activate/Deactivate Power Limit command request.
279 */
280struct ApplyPowerLimitRequest
281{
Patrick Venture0b02be92018-08-31 11:55:55 -0700282 uint8_t groupID; //!< Group extension identification.
283 uint8_t powerLimitAction; //!< Power limit activation
284 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530285} __attribute__((packed));
286
287/** @struct ApplyPowerLimitResponse
288 *
289 * DCMI payload for Acticate/Deactivate Power Limit command response.
290 */
291struct ApplyPowerLimitResponse
292{
Patrick Venture0b02be92018-08-31 11:55:55 -0700293 uint8_t groupID; //!< Group extension identification.
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530294} __attribute__((packed));
295
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300296/** @struct GetMgmntCtrlIdStrRequest
297 *
298 * DCMI payload for Get Management Controller Identifier String cmd request.
299 */
300struct GetMgmntCtrlIdStrRequest
301{
Patrick Venture0b02be92018-08-31 11:55:55 -0700302 uint8_t groupID; //!< Group extension identification.
303 uint8_t offset; //!< Offset to read.
304 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300305} __attribute__((packed));
306
307/** @struct GetMgmntCtrlIdStrResponse
308 *
309 * DCMI payload for Get Management Controller Identifier String cmd response.
310 */
311struct GetMgmntCtrlIdStrResponse
312{
Patrick Venture0b02be92018-08-31 11:55:55 -0700313 uint8_t groupID; //!< Group extension identification.
314 uint8_t strLen; //!< ID string length.
315 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300316} __attribute__((packed));
317
318/** @struct SetMgmntCtrlIdStrRequest
319 *
320 * DCMI payload for Set Management Controller Identifier String cmd request.
321 */
322struct SetMgmntCtrlIdStrRequest
323{
Patrick Venture0b02be92018-08-31 11:55:55 -0700324 uint8_t groupID; //!< Group extension identification.
325 uint8_t offset; //!< Offset to write.
326 uint8_t bytes; //!< Number of bytes to read.
327 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300328} __attribute__((packed));
329
330/** @struct GetMgmntCtrlIdStrResponse
331 *
332 * DCMI payload for Get Management Controller Identifier String cmd response.
333 */
334struct SetMgmntCtrlIdStrResponse
335{
Patrick Venture0b02be92018-08-31 11:55:55 -0700336 uint8_t groupID; //!< Group extension identification.
337 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300338} __attribute__((packed));
339
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600340/** @enum DCMICapParameters
341 *
342 * DCMI Capability parameters
343 */
344enum class DCMICapParameters
345{
346 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
347 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
348 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
349 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
350};
351
352/** @struct GetDCMICapRequest
353 *
354 * DCMI payload for Get capabilities cmd request.
355 */
356struct GetDCMICapRequest
357{
Patrick Venture0b02be92018-08-31 11:55:55 -0700358 uint8_t groupID; //!< Group extension identification.
359 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600360} __attribute__((packed));
361
362/** @struct GetDCMICapRequest
363 *
364 * DCMI payload for Get capabilities cmd response.
365 */
366struct GetDCMICapResponse
367{
Patrick Venture0b02be92018-08-31 11:55:55 -0700368 uint8_t groupID; //!< Group extension identification.
369 uint8_t major; //!< DCMI Specification Conformance - major ver
370 uint8_t minor; //!< DCMI Specification Conformance - minor ver
371 uint8_t paramRevision; //!< Parameter Revision = 02h
372 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600373} __attribute__((packed));
374
375/** @struct DCMICap
376 *
377 * DCMI capabilities protocol info.
378 */
379struct DCMICap
380{
Patrick Venture0b02be92018-08-31 11:55:55 -0700381 std::string name; //!< Name of DCMI capability.
382 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
383 uint8_t position; //!< bit position from the DCMI spec.
384 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600385};
386
387using DCMICapList = std::vector<DCMICap>;
388
389/** @struct DCMICapEntry
390 *
391 * DCMI capabilities list and size for each parameter.
392 */
393struct DCMICapEntry
394{
Patrick Venture0b02be92018-08-31 11:55:55 -0700395 uint8_t size; //!< Size of capability array in bytes.
396 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600397};
398
399using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
400
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600401/** @struct GetTempReadingsRequest
402 *
403 * DCMI payload for Get Temperature Readings request
404 */
405struct GetTempReadingsRequest
406{
Patrick Venture0b02be92018-08-31 11:55:55 -0700407 uint8_t groupID; //!< Group extension identification.
408 uint8_t sensorType; //!< Type of the sensor
409 uint8_t entityId; //!< Entity ID
410 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
411 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600412} __attribute__((packed));
413
414/** @struct GetTempReadingsResponse
415 *
416 * DCMI header for Get Temperature Readings response
417 */
418struct GetTempReadingsResponseHdr
419{
Patrick Venture0b02be92018-08-31 11:55:55 -0700420 uint8_t groupID; //!< Group extension identification.
421 uint8_t numInstances; //!< No. of instances for requested id
422 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600423} __attribute__((packed));
424
Kirill Pakhomova2573622018-11-02 19:00:18 +0300425/** @brief Parse out JSON config file.
426 *
427 * @param[in] configFile - JSON config file name
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600428 *
429 * @return A json object
430 */
Kirill Pakhomova2573622018-11-02 19:00:18 +0300431Json parseJSONConfig(const std::string& configFile);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600432
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600433namespace temp_readings
434{
Patrick Venture0b02be92018-08-31 11:55:55 -0700435/** @brief Read temperature from a d-bus object, scale it as per dcmi
436 * get temperature reading requirements.
437 *
438 * @param[in] dbusService - the D-Bus service
439 * @param[in] dbusPath - the D-Bus path
440 *
441 * @return A temperature reading
442 */
443Temperature readTemp(const std::string& dbusService,
444 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600445
Patrick Venture0b02be92018-08-31 11:55:55 -0700446/** @brief Read temperatures and fill up DCMI response for the Get
447 * Temperature Readings command. This looks at a specific
448 * instance.
449 *
450 * @param[in] type - one of "inlet", "cpu", "baseboard"
451 * @param[in] instance - A non-zero Entity instance number
452 *
453 * @return A tuple, containing a temperature reading and the
454 * number of instances.
455 */
456std::tuple<Response, NumInstances> read(const std::string& type,
457 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600458
Patrick Venture0b02be92018-08-31 11:55:55 -0700459/** @brief Read temperatures and fill up DCMI response for the Get
460 * Temperature Readings command. This looks at a range of
461 * instances.
462 *
463 * @param[in] type - one of "inlet", "cpu", "baseboard"
464 * @param[in] instanceStart - Entity instance start index
465 *
466 * @return A tuple, containing a list of temperature readings and the
467 * number of instances.
468 */
469std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
470 uint8_t instanceStart);
471} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600472
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600473namespace sensor_info
474{
Patrick Venture0b02be92018-08-31 11:55:55 -0700475/** @brief Create response from JSON config.
476 *
477 * @param[in] config - JSON config info about DCMI sensors
478 *
479 * @return Sensor info response
480 */
481Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600482
Patrick Venture0b02be92018-08-31 11:55:55 -0700483/** @brief Read sensor info and fill up DCMI response for the Get
484 * Sensor Info command. This looks at a specific
485 * instance.
486 *
487 * @param[in] type - one of "inlet", "cpu", "baseboard"
488 * @param[in] instance - A non-zero Entity instance number
489 * @param[in] config - JSON config info about DCMI sensors
490 *
491 * @return A tuple, containing a sensor info response and
492 * number of instances.
493 */
494std::tuple<Response, NumInstances> read(const std::string& type,
495 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600496
Patrick Venture0b02be92018-08-31 11:55:55 -0700497/** @brief Read sensor info and fill up DCMI response for the Get
498 * Sensor Info command. This looks at a range of
499 * instances.
500 *
501 * @param[in] type - one of "inlet", "cpu", "baseboard"
502 * @param[in] instanceStart - Entity instance start index
503 * @param[in] config - JSON config info about DCMI sensors
504 *
505 * @return A tuple, containing a list of sensor info responses and the
506 * number of instances.
507 */
508std::tuple<ResponseList, NumInstances>
509 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600510} // namespace sensor_info
511
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600512/** @brief Read power reading from power reading sensor object
513 *
514 * @param[in] bus - dbus connection
515 *
516 * @return total power reading
517 */
518int64_t getPowerReading(sdbusplus::bus::bus& bus);
519
520/** @struct GetPowerReadingRequest
521 *
522 * DCMI Get Power Reading command request.
523 * Refer DCMI specification Version 1.1 Section 6.6.1
524 */
525struct GetPowerReadingRequest
526{
Patrick Venture0b02be92018-08-31 11:55:55 -0700527 uint8_t groupID; //!< Group extension identification.
528 uint8_t mode; //!< Mode
529 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600530} __attribute__((packed));
531
532/** @struct GetPowerReadingResponse
533 *
534 * DCMI Get Power Reading command response.
535 * Refer DCMI specification Version 1.1 Section 6.6.1
536 */
537struct GetPowerReadingResponse
538{
Patrick Venture0b02be92018-08-31 11:55:55 -0700539 uint8_t groupID; //!< Group extension identification.
540 uint16_t currentPower; //!< Current power in watts
541 uint16_t minimumPower; //!< Minimum power over sampling duration
542 //!< in watts
543 uint16_t maximumPower; //!< Maximum power over sampling duration
544 //!< in watts
545 uint16_t averagePower; //!< Average power over sampling duration
546 //!< in watts
547 uint32_t timeStamp; //!< IPMI specification based time stamp
548 uint32_t timeFrame; //!< Statistics reporting time period in milli
549 //!< seconds.
550 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600551} __attribute__((packed));
552
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600553/** @struct GetSensorInfoRequest
554 *
555 * DCMI payload for Get Sensor Info request
556 */
557struct GetSensorInfoRequest
558{
Patrick Venture0b02be92018-08-31 11:55:55 -0700559 uint8_t groupID; //!< Group extension identification.
560 uint8_t sensorType; //!< Type of the sensor
561 uint8_t entityId; //!< Entity ID
562 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
563 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600564} __attribute__((packed));
565
566/** @struct GetSensorInfoResponseHdr
567 *
568 * DCMI header for Get Sensor Info response
569 */
570struct GetSensorInfoResponseHdr
571{
Patrick Venture0b02be92018-08-31 11:55:55 -0700572 uint8_t groupID; //!< Group extension identification.
573 uint8_t numInstances; //!< No. of instances for requested id
574 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600575} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600576/**
577 * @brief Parameters for DCMI Configuration Parameters
578 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700579enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600580{
581 ActivateDHCP = 1,
582 DiscoveryConfig,
583 DHCPTiming1,
584 DHCPTiming2,
585 DHCPTiming3,
586};
587
588/** @struct SetConfParamsRequest
589 *
590 * DCMI Set DCMI Configuration Parameters Command.
591 * Refer DCMI specification Version 1.1 Section 6.1.2
592 */
593struct SetConfParamsRequest
594{
Patrick Venture0b02be92018-08-31 11:55:55 -0700595 uint8_t groupID; //!< Group extension identification.
596 uint8_t paramSelect; //!< Parameter selector.
597 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
598 //!< have one set).
599 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600600} __attribute__((packed));
601
602/** @struct SetConfParamsResponse
603 *
604 * DCMI Set DCMI Configuration Parameters Command response.
605 * Refer DCMI specification Version 1.1 Section 6.1.2
606 */
607struct SetConfParamsResponse
608{
Patrick Venture0b02be92018-08-31 11:55:55 -0700609 uint8_t groupID; //!< Group extension identification.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600610} __attribute__((packed));
611
612/** @struct GetConfParamsRequest
613 *
614 * DCMI Get DCMI Configuration Parameters Command.
615 * Refer DCMI specification Version 1.1 Section 6.1.3
616 */
617struct GetConfParamsRequest
618{
Patrick Venture0b02be92018-08-31 11:55:55 -0700619 uint8_t groupID; //!< Group extension identification.
620 uint8_t paramSelect; //!< Parameter selector.
621 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
622 //!< under a given Parameter selector value. 00h if
623 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600624} __attribute__((packed));
625
626/** @struct GetConfParamsResponse
627 *
628 * DCMI Get DCMI Configuration Parameters Command response.
629 * Refer DCMI specification Version 1.1 Section 6.1.3
630 */
631struct GetConfParamsResponse
632{
Patrick Venture0b02be92018-08-31 11:55:55 -0700633 uint8_t groupID; //!< Group extension identification.
634 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
635 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
636 uint8_t paramRevision; //!< Parameter Revision = 01h.
637 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600638
639} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600640
Tom Josephbe5eaa12017-07-12 19:54:44 +0530641} // namespace dcmi