blob: a188c253fb2512a0a49c8c6eb9e176713c5dcc27 [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;
Kirill Pakhomovdb5d9b02018-11-06 19:17:51 +030061static constexpr auto gMaxSELEntriesMask = 0xFFF;
62static constexpr auto gByteBitSize = 8;
Tom Josephbe5eaa12017-07-12 19:54:44 +053063
64namespace assettag
65{
66
Patrick Venture0b02be92018-08-31 11:55:55 -070067using ObjectPath = std::string;
68using Service = std::string;
69using Interfaces = std::vector<std::string>;
70using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053071
Patrick Venture0b02be92018-08-31 11:55:55 -070072} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053073
Deepak Kodihalliee717d72018-01-24 04:53:09 -060074namespace temp_readings
75{
Patrick Venture0b02be92018-08-31 11:55:55 -070076static constexpr auto maxDataSets = 8;
77static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060078
Patrick Venture0b02be92018-08-31 11:55:55 -070079/** @struct Response
80 *
81 * DCMI payload for Get Temperature Readings response
82 */
83struct Response
84{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060085#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070086 uint8_t temperature : 7; //!< Temperature reading in Celsius
87 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060088#endif
89#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070090 uint8_t sign : 1; //!< Sign bit
91 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060092#endif
Patrick Venture0b02be92018-08-31 11:55:55 -070093 uint8_t instance; //!< Entity instance number
94} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060095
Patrick Venture0b02be92018-08-31 11:55:55 -070096using ResponseList = std::vector<Response>;
97using Value = uint8_t;
98using Sign = bool;
99using Temperature = std::tuple<Value, Sign>;
100} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600101
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600102namespace sensor_info
103{
Patrick Venture0b02be92018-08-31 11:55:55 -0700104static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600105
Patrick Venture0b02be92018-08-31 11:55:55 -0700106/** @struct Response
107 *
108 * DCMI payload for Get Sensor Info response
109 */
110struct Response
111{
112 uint8_t recordIdLsb; //!< SDR record id LS byte
113 uint8_t recordIdMsb; //!< SDR record id MS byte
114} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600115
Patrick Venture0b02be92018-08-31 11:55:55 -0700116using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600117} // namespace sensor_info
118
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530119static constexpr auto groupExtId = 0xDC;
120
121static constexpr auto assetTagMaxOffset = 62;
122static constexpr auto assetTagMaxSize = 63;
123static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300124static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530125
126/** @struct GetAssetTagRequest
127 *
128 * DCMI payload for Get Asset Tag command request.
129 */
130struct GetAssetTagRequest
131{
Patrick Venture0b02be92018-08-31 11:55:55 -0700132 uint8_t groupID; //!< Group extension identification.
133 uint8_t offset; //!< Offset to read.
134 uint8_t bytes; //!< Number of bytes to read.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530135} __attribute__((packed));
136
137/** @struct GetAssetTagResponse
138 *
139 * DCMI payload for Get Asset Tag command response.
140 */
141struct GetAssetTagResponse
142{
Patrick Venture0b02be92018-08-31 11:55:55 -0700143 uint8_t groupID; //!< Group extension identification.
144 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530145} __attribute__((packed));
146
Tom Joseph545dd232017-07-12 20:20:49 +0530147/** @struct SetAssetTagRequest
148 *
149 * DCMI payload for Set Asset Tag command request.
150 */
151struct SetAssetTagRequest
152{
Patrick Venture0b02be92018-08-31 11:55:55 -0700153 uint8_t groupID; //!< Group extension identification.
154 uint8_t offset; //!< Offset to write.
155 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530156} __attribute__((packed));
157
158/** @struct SetAssetTagResponse
159 *
160 * DCMI payload for Set Asset Tag command response.
161 */
162struct SetAssetTagResponse
163{
Patrick Venture0b02be92018-08-31 11:55:55 -0700164 uint8_t groupID; //!< Group extension identification.
165 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530166} __attribute__((packed));
167
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +0300168/** @brief Check whether DCMI power management is supported
169 * in the DCMI Capabilities config file.
170 *
171 * @return True if DCMI power management is supported
172 */
173bool isDCMIPowerMgmtSupported();
174
Tom Josephbe5eaa12017-07-12 19:54:44 +0530175/** @brief Read the object tree to fetch the object path that implemented the
176 * Asset tag interface.
177 *
178 * @param[in,out] objectTree - object tree
179 *
180 * @return On success return the object tree with the object path that
181 * implemented the AssetTag interface.
182 */
183void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
184
185/** @brief Read the asset tag of the server
186 *
187 * @return On success return the asset tag.
188 */
189std::string readAssetTag();
190
Tom Josephbe5b9892017-07-15 00:55:23 +0530191/** @brief Write the asset tag to the asset tag DBUS property
192 *
193 * @param[in] assetTag - Asset Tag to be written to the property.
194 */
195void writeAssetTag(const std::string& assetTag);
196
Tom Josephb9d86f42017-07-26 18:03:47 +0530197/** @brief Read the current power cap value
198 *
199 * @param[in] bus - dbus connection
200 *
201 * @return On success return the power cap value.
202 */
203uint32_t getPcap(sdbusplus::bus::bus& bus);
204
205/** @brief Check if the power capping is enabled
206 *
207 * @param[in] bus - dbus connection
208 *
209 * @return true if the powerCap is enabled and false if the powercap
210 * is disabled.
211 */
212bool getPcapEnabled(sdbusplus::bus::bus& bus);
213
214/** @struct GetPowerLimitRequest
215 *
216 * DCMI payload for Get Power Limit command request.
217 */
218struct GetPowerLimitRequest
219{
Patrick Venture0b02be92018-08-31 11:55:55 -0700220 uint8_t groupID; //!< Group extension identification.
221 uint16_t reserved; //!< Reserved
Tom Josephb9d86f42017-07-26 18:03:47 +0530222} __attribute__((packed));
223
224/** @struct GetPowerLimitResponse
225 *
226 * DCMI payload for Get Power Limit command response.
227 */
228struct GetPowerLimitResponse
229{
Patrick Venture0b02be92018-08-31 11:55:55 -0700230 uint8_t groupID; //!< Group extension identification.
231 uint16_t reserved; //!< Reserved.
232 uint8_t exceptionAction; //!< Exception action.
233 uint16_t powerLimit; //!< Power limit requested in watts.
234 uint32_t correctionTime; //!< Correction time limit in milliseconds.
235 uint16_t reserved1; //!< Reserved.
236 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530237} __attribute__((packed));
238
Tom Joseph46fa37d2017-07-26 18:11:55 +0530239/** @brief Set the power cap value
240 *
241 * @param[in] bus - dbus connection
242 * @param[in] powerCap - power cap value
243 */
244void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
245
246/** @struct SetPowerLimitRequest
247 *
248 * DCMI payload for Set Power Limit command request.
249 */
250struct SetPowerLimitRequest
251{
Patrick Venture0b02be92018-08-31 11:55:55 -0700252 uint8_t groupID; //!< Group extension identification.
253 uint16_t reserved; //!< Reserved
254 uint8_t reserved1; //!< Reserved
255 uint8_t exceptionAction; //!< Exception action.
256 uint16_t powerLimit; //!< Power limit requested in watts.
257 uint32_t correctionTime; //!< Correction time limit in milliseconds.
258 uint16_t reserved2; //!< Reserved.
259 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530260} __attribute__((packed));
261
262/** @struct SetPowerLimitResponse
263 *
264 * DCMI payload for Set Power Limit command response.
265 */
266struct SetPowerLimitResponse
267{
Patrick Venture0b02be92018-08-31 11:55:55 -0700268 uint8_t groupID; //!< Group extension identification.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530269} __attribute__((packed));
270
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530271/** @brief Enable or disable the power capping
272 *
273 * @param[in] bus - dbus connection
274 * @param[in] enabled - enable/disable
275 */
276void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
277
278/** @struct ApplyPowerLimitRequest
279 *
280 * DCMI payload for Activate/Deactivate Power Limit command request.
281 */
282struct ApplyPowerLimitRequest
283{
Patrick Venture0b02be92018-08-31 11:55:55 -0700284 uint8_t groupID; //!< Group extension identification.
285 uint8_t powerLimitAction; //!< Power limit activation
286 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530287} __attribute__((packed));
288
289/** @struct ApplyPowerLimitResponse
290 *
291 * DCMI payload for Acticate/Deactivate Power Limit command response.
292 */
293struct ApplyPowerLimitResponse
294{
Patrick Venture0b02be92018-08-31 11:55:55 -0700295 uint8_t groupID; //!< Group extension identification.
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530296} __attribute__((packed));
297
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300298/** @struct GetMgmntCtrlIdStrRequest
299 *
300 * DCMI payload for Get Management Controller Identifier String cmd request.
301 */
302struct GetMgmntCtrlIdStrRequest
303{
Patrick Venture0b02be92018-08-31 11:55:55 -0700304 uint8_t groupID; //!< Group extension identification.
305 uint8_t offset; //!< Offset to read.
306 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300307} __attribute__((packed));
308
309/** @struct GetMgmntCtrlIdStrResponse
310 *
311 * DCMI payload for Get Management Controller Identifier String cmd response.
312 */
313struct GetMgmntCtrlIdStrResponse
314{
Patrick Venture0b02be92018-08-31 11:55:55 -0700315 uint8_t groupID; //!< Group extension identification.
316 uint8_t strLen; //!< ID string length.
317 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300318} __attribute__((packed));
319
320/** @struct SetMgmntCtrlIdStrRequest
321 *
322 * DCMI payload for Set Management Controller Identifier String cmd request.
323 */
324struct SetMgmntCtrlIdStrRequest
325{
Patrick Venture0b02be92018-08-31 11:55:55 -0700326 uint8_t groupID; //!< Group extension identification.
327 uint8_t offset; //!< Offset to write.
328 uint8_t bytes; //!< Number of bytes to read.
329 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300330} __attribute__((packed));
331
332/** @struct GetMgmntCtrlIdStrResponse
333 *
334 * DCMI payload for Get Management Controller Identifier String cmd response.
335 */
336struct SetMgmntCtrlIdStrResponse
337{
Patrick Venture0b02be92018-08-31 11:55:55 -0700338 uint8_t groupID; //!< Group extension identification.
339 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300340} __attribute__((packed));
341
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600342/** @enum DCMICapParameters
343 *
344 * DCMI Capability parameters
345 */
346enum class DCMICapParameters
347{
348 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
349 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
350 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
351 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
352};
353
354/** @struct GetDCMICapRequest
355 *
356 * DCMI payload for Get capabilities cmd request.
357 */
358struct GetDCMICapRequest
359{
Patrick Venture0b02be92018-08-31 11:55:55 -0700360 uint8_t groupID; //!< Group extension identification.
361 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600362} __attribute__((packed));
363
364/** @struct GetDCMICapRequest
365 *
366 * DCMI payload for Get capabilities cmd response.
367 */
368struct GetDCMICapResponse
369{
Patrick Venture0b02be92018-08-31 11:55:55 -0700370 uint8_t groupID; //!< Group extension identification.
371 uint8_t major; //!< DCMI Specification Conformance - major ver
372 uint8_t minor; //!< DCMI Specification Conformance - minor ver
373 uint8_t paramRevision; //!< Parameter Revision = 02h
374 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600375} __attribute__((packed));
376
377/** @struct DCMICap
378 *
379 * DCMI capabilities protocol info.
380 */
381struct DCMICap
382{
Patrick Venture0b02be92018-08-31 11:55:55 -0700383 std::string name; //!< Name of DCMI capability.
384 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
385 uint8_t position; //!< bit position from the DCMI spec.
386 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600387};
388
389using DCMICapList = std::vector<DCMICap>;
390
391/** @struct DCMICapEntry
392 *
393 * DCMI capabilities list and size for each parameter.
394 */
395struct DCMICapEntry
396{
Patrick Venture0b02be92018-08-31 11:55:55 -0700397 uint8_t size; //!< Size of capability array in bytes.
398 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600399};
400
401using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
402
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600403/** @struct GetTempReadingsRequest
404 *
405 * DCMI payload for Get Temperature Readings request
406 */
407struct GetTempReadingsRequest
408{
Patrick Venture0b02be92018-08-31 11:55:55 -0700409 uint8_t groupID; //!< Group extension identification.
410 uint8_t sensorType; //!< Type of the sensor
411 uint8_t entityId; //!< Entity ID
412 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
413 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600414} __attribute__((packed));
415
416/** @struct GetTempReadingsResponse
417 *
418 * DCMI header for Get Temperature Readings response
419 */
420struct GetTempReadingsResponseHdr
421{
Patrick Venture0b02be92018-08-31 11:55:55 -0700422 uint8_t groupID; //!< Group extension identification.
423 uint8_t numInstances; //!< No. of instances for requested id
424 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600425} __attribute__((packed));
426
Kirill Pakhomova2573622018-11-02 19:00:18 +0300427/** @brief Parse out JSON config file.
428 *
429 * @param[in] configFile - JSON config file name
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600430 *
431 * @return A json object
432 */
Kirill Pakhomova2573622018-11-02 19:00:18 +0300433Json parseJSONConfig(const std::string& configFile);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600434
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600435namespace temp_readings
436{
Patrick Venture0b02be92018-08-31 11:55:55 -0700437/** @brief Read temperature from a d-bus object, scale it as per dcmi
438 * get temperature reading requirements.
439 *
440 * @param[in] dbusService - the D-Bus service
441 * @param[in] dbusPath - the D-Bus path
442 *
443 * @return A temperature reading
444 */
445Temperature readTemp(const std::string& dbusService,
446 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600447
Patrick Venture0b02be92018-08-31 11:55:55 -0700448/** @brief Read temperatures and fill up DCMI response for the Get
449 * Temperature Readings command. This looks at a specific
450 * instance.
451 *
452 * @param[in] type - one of "inlet", "cpu", "baseboard"
453 * @param[in] instance - A non-zero Entity instance number
454 *
455 * @return A tuple, containing a temperature reading and the
456 * number of instances.
457 */
458std::tuple<Response, NumInstances> read(const std::string& type,
459 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600460
Patrick Venture0b02be92018-08-31 11:55:55 -0700461/** @brief Read temperatures and fill up DCMI response for the Get
462 * Temperature Readings command. This looks at a range of
463 * instances.
464 *
465 * @param[in] type - one of "inlet", "cpu", "baseboard"
466 * @param[in] instanceStart - Entity instance start index
467 *
468 * @return A tuple, containing a list of temperature readings and the
469 * number of instances.
470 */
471std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
472 uint8_t instanceStart);
473} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600474
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600475namespace sensor_info
476{
Patrick Venture0b02be92018-08-31 11:55:55 -0700477/** @brief Create response from JSON config.
478 *
479 * @param[in] config - JSON config info about DCMI sensors
480 *
481 * @return Sensor info response
482 */
483Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600484
Patrick Venture0b02be92018-08-31 11:55:55 -0700485/** @brief Read sensor info and fill up DCMI response for the Get
486 * Sensor Info command. This looks at a specific
487 * instance.
488 *
489 * @param[in] type - one of "inlet", "cpu", "baseboard"
490 * @param[in] instance - A non-zero Entity instance number
491 * @param[in] config - JSON config info about DCMI sensors
492 *
493 * @return A tuple, containing a sensor info response and
494 * number of instances.
495 */
496std::tuple<Response, NumInstances> read(const std::string& type,
497 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600498
Patrick Venture0b02be92018-08-31 11:55:55 -0700499/** @brief Read sensor info and fill up DCMI response for the Get
500 * Sensor Info command. This looks at a range of
501 * instances.
502 *
503 * @param[in] type - one of "inlet", "cpu", "baseboard"
504 * @param[in] instanceStart - Entity instance start index
505 * @param[in] config - JSON config info about DCMI sensors
506 *
507 * @return A tuple, containing a list of sensor info responses and the
508 * number of instances.
509 */
510std::tuple<ResponseList, NumInstances>
511 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600512} // namespace sensor_info
513
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600514/** @brief Read power reading from power reading sensor object
515 *
516 * @param[in] bus - dbus connection
517 *
518 * @return total power reading
519 */
520int64_t getPowerReading(sdbusplus::bus::bus& bus);
521
522/** @struct GetPowerReadingRequest
523 *
524 * DCMI Get Power Reading command request.
525 * Refer DCMI specification Version 1.1 Section 6.6.1
526 */
527struct GetPowerReadingRequest
528{
Patrick Venture0b02be92018-08-31 11:55:55 -0700529 uint8_t groupID; //!< Group extension identification.
530 uint8_t mode; //!< Mode
531 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600532} __attribute__((packed));
533
534/** @struct GetPowerReadingResponse
535 *
536 * DCMI Get Power Reading command response.
537 * Refer DCMI specification Version 1.1 Section 6.6.1
538 */
539struct GetPowerReadingResponse
540{
Patrick Venture0b02be92018-08-31 11:55:55 -0700541 uint8_t groupID; //!< Group extension identification.
542 uint16_t currentPower; //!< Current power in watts
543 uint16_t minimumPower; //!< Minimum power over sampling duration
544 //!< in watts
545 uint16_t maximumPower; //!< Maximum power over sampling duration
546 //!< in watts
547 uint16_t averagePower; //!< Average power over sampling duration
548 //!< in watts
549 uint32_t timeStamp; //!< IPMI specification based time stamp
550 uint32_t timeFrame; //!< Statistics reporting time period in milli
551 //!< seconds.
552 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600553} __attribute__((packed));
554
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600555/** @struct GetSensorInfoRequest
556 *
557 * DCMI payload for Get Sensor Info request
558 */
559struct GetSensorInfoRequest
560{
Patrick Venture0b02be92018-08-31 11:55:55 -0700561 uint8_t groupID; //!< Group extension identification.
562 uint8_t sensorType; //!< Type of the sensor
563 uint8_t entityId; //!< Entity ID
564 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
565 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600566} __attribute__((packed));
567
568/** @struct GetSensorInfoResponseHdr
569 *
570 * DCMI header for Get Sensor Info response
571 */
572struct GetSensorInfoResponseHdr
573{
Patrick Venture0b02be92018-08-31 11:55:55 -0700574 uint8_t groupID; //!< Group extension identification.
575 uint8_t numInstances; //!< No. of instances for requested id
576 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600577} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600578/**
579 * @brief Parameters for DCMI Configuration Parameters
580 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700581enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600582{
583 ActivateDHCP = 1,
584 DiscoveryConfig,
585 DHCPTiming1,
586 DHCPTiming2,
587 DHCPTiming3,
588};
589
590/** @struct SetConfParamsRequest
591 *
592 * DCMI Set DCMI Configuration Parameters Command.
593 * Refer DCMI specification Version 1.1 Section 6.1.2
594 */
595struct SetConfParamsRequest
596{
Patrick Venture0b02be92018-08-31 11:55:55 -0700597 uint8_t groupID; //!< Group extension identification.
598 uint8_t paramSelect; //!< Parameter selector.
599 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
600 //!< have one set).
601 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600602} __attribute__((packed));
603
604/** @struct SetConfParamsResponse
605 *
606 * DCMI Set DCMI Configuration Parameters Command response.
607 * Refer DCMI specification Version 1.1 Section 6.1.2
608 */
609struct SetConfParamsResponse
610{
Patrick Venture0b02be92018-08-31 11:55:55 -0700611 uint8_t groupID; //!< Group extension identification.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600612} __attribute__((packed));
613
614/** @struct GetConfParamsRequest
615 *
616 * DCMI Get DCMI Configuration Parameters Command.
617 * Refer DCMI specification Version 1.1 Section 6.1.3
618 */
619struct GetConfParamsRequest
620{
Patrick Venture0b02be92018-08-31 11:55:55 -0700621 uint8_t groupID; //!< Group extension identification.
622 uint8_t paramSelect; //!< Parameter selector.
623 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
624 //!< under a given Parameter selector value. 00h if
625 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600626} __attribute__((packed));
627
628/** @struct GetConfParamsResponse
629 *
630 * DCMI Get DCMI Configuration Parameters Command response.
631 * Refer DCMI specification Version 1.1 Section 6.1.3
632 */
633struct GetConfParamsResponse
634{
Patrick Venture0b02be92018-08-31 11:55:55 -0700635 uint8_t groupID; //!< Group extension identification.
636 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
637 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
638 uint8_t paramRevision; //!< Parameter Revision = 01h.
639 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600640
641} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600642
Tom Josephbe5eaa12017-07-12 19:54:44 +0530643} // namespace dcmi