blob: 6e64faf65d67ef570bb7a6b216dbc9fa33431b0c [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
Patrick Venture0b02be92018-08-31 11:55:55 -07004#include "nlohmann/json.hpp"
5
Tom Josephbe5eaa12017-07-12 19:54:44 +05306#include <map>
Patrick Venture0b02be92018-08-31 11:55:55 -07007#include <sdbusplus/bus.hpp>
Tom Josephbe5eaa12017-07-12 19:54:44 +05308#include <string>
9#include <vector>
10
Tom Josephbe5eaa12017-07-12 19:54:44 +053011namespace dcmi
12{
13
Deepak Kodihalli0b459552018-02-06 06:25:12 -060014using NumInstances = size_t;
15using Json = nlohmann::json;
16
Ratan Gupta11ddbd22017-08-05 11:59:39 +053017enum Commands
18{
19 // Get capability bits
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -060020 GET_CAPABILITIES = 0x01,
Marri Devender Rao66c5fda2018-01-18 10:48:37 -060021 GET_POWER_READING = 0x02,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053022 GET_POWER_LIMIT = 0x03,
23 SET_POWER_LIMIT = 0x04,
24 APPLY_POWER_LIMIT = 0x05,
25 GET_ASSET_TAG = 0x06,
Deepak Kodihalli0b459552018-02-06 06:25:12 -060026 GET_SENSOR_INFO = 0x07,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053027 SET_ASSET_TAG = 0x08,
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030028 GET_MGMNT_CTRL_ID_STR = 0x09,
29 SET_MGMNT_CTRL_ID_STR = 0x0A,
Deepak Kodihalliee717d72018-01-24 04:53:09 -060030 GET_TEMP_READINGS = 0x10,
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060031 SET_CONF_PARAMS = 0x12,
32 GET_CONF_PARAMS = 0x13,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053033};
34
Tom Josephbe5eaa12017-07-12 19:54:44 +053035static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
36static constexpr auto assetTagIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070037 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
Tom Josephbe5eaa12017-07-12 19:54:44 +053038static constexpr auto assetTagProp = "AssetTag";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030039static constexpr auto networkServiceName = "xyz.openbmc_project.Network";
Patrick Venture0b02be92018-08-31 11:55:55 -070040static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030041static constexpr auto networkConfigIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070042 "xyz.openbmc_project.Network.SystemConfiguration";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030043static constexpr auto hostNameProp = "HostName";
Deepak Kodihalliee717d72018-01-24 04:53:09 -060044static constexpr auto temperatureSensorType = 0x01;
Deepak Kodihalli0b459552018-02-06 06:25:12 -060045static constexpr auto maxInstances = 255;
46static constexpr auto configFile =
47 "/usr/share/ipmi-providers/dcmi_sensors.json";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060048static constexpr auto ethernetIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070049 "xyz.openbmc_project.Network.EthernetInterface";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060050static constexpr auto ethernetDefaultChannelNum = 0x1;
51static constexpr auto networkRoot = "/xyz/openbmc_project/network";
52static constexpr auto dhcpObj = "/xyz/openbmc_project/network/config/dhcp";
53static constexpr auto dhcpIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070054 "xyz.openbmc_project.Network.DHCPConfiguration";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060055static constexpr auto systemBusName = "org.freedesktop.systemd1";
56static constexpr auto systemPath = "/org/freedesktop/systemd1";
57static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager";
Tom Josephbe5eaa12017-07-12 19:54:44 +053058
59namespace assettag
60{
61
Patrick Venture0b02be92018-08-31 11:55:55 -070062using ObjectPath = std::string;
63using Service = std::string;
64using Interfaces = std::vector<std::string>;
65using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053066
Patrick Venture0b02be92018-08-31 11:55:55 -070067} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053068
Deepak Kodihalliee717d72018-01-24 04:53:09 -060069namespace temp_readings
70{
Patrick Venture0b02be92018-08-31 11:55:55 -070071static constexpr auto maxDataSets = 8;
72static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060073
Patrick Venture0b02be92018-08-31 11:55:55 -070074/** @struct Response
75 *
76 * DCMI payload for Get Temperature Readings response
77 */
78struct Response
79{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060080#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070081 uint8_t temperature : 7; //!< Temperature reading in Celsius
82 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060083#endif
84#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070085 uint8_t sign : 1; //!< Sign bit
86 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060087#endif
Patrick Venture0b02be92018-08-31 11:55:55 -070088 uint8_t instance; //!< Entity instance number
89} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060090
Patrick Venture0b02be92018-08-31 11:55:55 -070091using ResponseList = std::vector<Response>;
92using Value = uint8_t;
93using Sign = bool;
94using Temperature = std::tuple<Value, Sign>;
95} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -060096
Deepak Kodihalli0b459552018-02-06 06:25:12 -060097namespace sensor_info
98{
Patrick Venture0b02be92018-08-31 11:55:55 -070099static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600100
Patrick Venture0b02be92018-08-31 11:55:55 -0700101/** @struct Response
102 *
103 * DCMI payload for Get Sensor Info response
104 */
105struct Response
106{
107 uint8_t recordIdLsb; //!< SDR record id LS byte
108 uint8_t recordIdMsb; //!< SDR record id MS byte
109} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600110
Patrick Venture0b02be92018-08-31 11:55:55 -0700111using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600112} // namespace sensor_info
113
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530114static constexpr auto groupExtId = 0xDC;
115
116static constexpr auto assetTagMaxOffset = 62;
117static constexpr auto assetTagMaxSize = 63;
118static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300119static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530120
121/** @struct GetAssetTagRequest
122 *
123 * DCMI payload for Get Asset Tag command request.
124 */
125struct GetAssetTagRequest
126{
Patrick Venture0b02be92018-08-31 11:55:55 -0700127 uint8_t groupID; //!< Group extension identification.
128 uint8_t offset; //!< Offset to read.
129 uint8_t bytes; //!< Number of bytes to read.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530130} __attribute__((packed));
131
132/** @struct GetAssetTagResponse
133 *
134 * DCMI payload for Get Asset Tag command response.
135 */
136struct GetAssetTagResponse
137{
Patrick Venture0b02be92018-08-31 11:55:55 -0700138 uint8_t groupID; //!< Group extension identification.
139 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530140} __attribute__((packed));
141
Tom Joseph545dd232017-07-12 20:20:49 +0530142/** @struct SetAssetTagRequest
143 *
144 * DCMI payload for Set Asset Tag command request.
145 */
146struct SetAssetTagRequest
147{
Patrick Venture0b02be92018-08-31 11:55:55 -0700148 uint8_t groupID; //!< Group extension identification.
149 uint8_t offset; //!< Offset to write.
150 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530151} __attribute__((packed));
152
153/** @struct SetAssetTagResponse
154 *
155 * DCMI payload for Set Asset Tag command response.
156 */
157struct SetAssetTagResponse
158{
Patrick Venture0b02be92018-08-31 11:55:55 -0700159 uint8_t groupID; //!< Group extension identification.
160 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530161} __attribute__((packed));
162
Tom Josephbe5eaa12017-07-12 19:54:44 +0530163/** @brief Read the object tree to fetch the object path that implemented the
164 * Asset tag interface.
165 *
166 * @param[in,out] objectTree - object tree
167 *
168 * @return On success return the object tree with the object path that
169 * implemented the AssetTag interface.
170 */
171void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
172
173/** @brief Read the asset tag of the server
174 *
175 * @return On success return the asset tag.
176 */
177std::string readAssetTag();
178
Tom Josephbe5b9892017-07-15 00:55:23 +0530179/** @brief Write the asset tag to the asset tag DBUS property
180 *
181 * @param[in] assetTag - Asset Tag to be written to the property.
182 */
183void writeAssetTag(const std::string& assetTag);
184
Tom Josephb9d86f42017-07-26 18:03:47 +0530185/** @brief Read the current power cap value
186 *
187 * @param[in] bus - dbus connection
188 *
189 * @return On success return the power cap value.
190 */
191uint32_t getPcap(sdbusplus::bus::bus& bus);
192
193/** @brief Check if the power capping is enabled
194 *
195 * @param[in] bus - dbus connection
196 *
197 * @return true if the powerCap is enabled and false if the powercap
198 * is disabled.
199 */
200bool getPcapEnabled(sdbusplus::bus::bus& bus);
201
202/** @struct GetPowerLimitRequest
203 *
204 * DCMI payload for Get Power Limit command request.
205 */
206struct GetPowerLimitRequest
207{
Patrick Venture0b02be92018-08-31 11:55:55 -0700208 uint8_t groupID; //!< Group extension identification.
209 uint16_t reserved; //!< Reserved
Tom Josephb9d86f42017-07-26 18:03:47 +0530210} __attribute__((packed));
211
212/** @struct GetPowerLimitResponse
213 *
214 * DCMI payload for Get Power Limit command response.
215 */
216struct GetPowerLimitResponse
217{
Patrick Venture0b02be92018-08-31 11:55:55 -0700218 uint8_t groupID; //!< Group extension identification.
219 uint16_t reserved; //!< Reserved.
220 uint8_t exceptionAction; //!< Exception action.
221 uint16_t powerLimit; //!< Power limit requested in watts.
222 uint32_t correctionTime; //!< Correction time limit in milliseconds.
223 uint16_t reserved1; //!< Reserved.
224 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530225} __attribute__((packed));
226
Tom Joseph46fa37d2017-07-26 18:11:55 +0530227/** @brief Set the power cap value
228 *
229 * @param[in] bus - dbus connection
230 * @param[in] powerCap - power cap value
231 */
232void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
233
234/** @struct SetPowerLimitRequest
235 *
236 * DCMI payload for Set Power Limit command request.
237 */
238struct SetPowerLimitRequest
239{
Patrick Venture0b02be92018-08-31 11:55:55 -0700240 uint8_t groupID; //!< Group extension identification.
241 uint16_t reserved; //!< Reserved
242 uint8_t reserved1; //!< Reserved
243 uint8_t exceptionAction; //!< Exception action.
244 uint16_t powerLimit; //!< Power limit requested in watts.
245 uint32_t correctionTime; //!< Correction time limit in milliseconds.
246 uint16_t reserved2; //!< Reserved.
247 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530248} __attribute__((packed));
249
250/** @struct SetPowerLimitResponse
251 *
252 * DCMI payload for Set Power Limit command response.
253 */
254struct SetPowerLimitResponse
255{
Patrick Venture0b02be92018-08-31 11:55:55 -0700256 uint8_t groupID; //!< Group extension identification.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530257} __attribute__((packed));
258
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530259/** @brief Enable or disable the power capping
260 *
261 * @param[in] bus - dbus connection
262 * @param[in] enabled - enable/disable
263 */
264void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
265
266/** @struct ApplyPowerLimitRequest
267 *
268 * DCMI payload for Activate/Deactivate Power Limit command request.
269 */
270struct ApplyPowerLimitRequest
271{
Patrick Venture0b02be92018-08-31 11:55:55 -0700272 uint8_t groupID; //!< Group extension identification.
273 uint8_t powerLimitAction; //!< Power limit activation
274 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530275} __attribute__((packed));
276
277/** @struct ApplyPowerLimitResponse
278 *
279 * DCMI payload for Acticate/Deactivate Power Limit command response.
280 */
281struct ApplyPowerLimitResponse
282{
Patrick Venture0b02be92018-08-31 11:55:55 -0700283 uint8_t groupID; //!< Group extension identification.
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530284} __attribute__((packed));
285
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300286/** @struct GetMgmntCtrlIdStrRequest
287 *
288 * DCMI payload for Get Management Controller Identifier String cmd request.
289 */
290struct GetMgmntCtrlIdStrRequest
291{
Patrick Venture0b02be92018-08-31 11:55:55 -0700292 uint8_t groupID; //!< Group extension identification.
293 uint8_t offset; //!< Offset to read.
294 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300295} __attribute__((packed));
296
297/** @struct GetMgmntCtrlIdStrResponse
298 *
299 * DCMI payload for Get Management Controller Identifier String cmd response.
300 */
301struct GetMgmntCtrlIdStrResponse
302{
Patrick Venture0b02be92018-08-31 11:55:55 -0700303 uint8_t groupID; //!< Group extension identification.
304 uint8_t strLen; //!< ID string length.
305 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300306} __attribute__((packed));
307
308/** @struct SetMgmntCtrlIdStrRequest
309 *
310 * DCMI payload for Set Management Controller Identifier String cmd request.
311 */
312struct SetMgmntCtrlIdStrRequest
313{
Patrick Venture0b02be92018-08-31 11:55:55 -0700314 uint8_t groupID; //!< Group extension identification.
315 uint8_t offset; //!< Offset to write.
316 uint8_t bytes; //!< Number of bytes to read.
317 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300318} __attribute__((packed));
319
320/** @struct GetMgmntCtrlIdStrResponse
321 *
322 * DCMI payload for Get Management Controller Identifier String cmd response.
323 */
324struct SetMgmntCtrlIdStrResponse
325{
Patrick Venture0b02be92018-08-31 11:55:55 -0700326 uint8_t groupID; //!< Group extension identification.
327 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300328} __attribute__((packed));
329
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600330/** @enum DCMICapParameters
331 *
332 * DCMI Capability parameters
333 */
334enum class DCMICapParameters
335{
336 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
337 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
338 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
339 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
340};
341
342/** @struct GetDCMICapRequest
343 *
344 * DCMI payload for Get capabilities cmd request.
345 */
346struct GetDCMICapRequest
347{
Patrick Venture0b02be92018-08-31 11:55:55 -0700348 uint8_t groupID; //!< Group extension identification.
349 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600350} __attribute__((packed));
351
352/** @struct GetDCMICapRequest
353 *
354 * DCMI payload for Get capabilities cmd response.
355 */
356struct GetDCMICapResponse
357{
Patrick Venture0b02be92018-08-31 11:55:55 -0700358 uint8_t groupID; //!< Group extension identification.
359 uint8_t major; //!< DCMI Specification Conformance - major ver
360 uint8_t minor; //!< DCMI Specification Conformance - minor ver
361 uint8_t paramRevision; //!< Parameter Revision = 02h
362 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600363} __attribute__((packed));
364
365/** @struct DCMICap
366 *
367 * DCMI capabilities protocol info.
368 */
369struct DCMICap
370{
Patrick Venture0b02be92018-08-31 11:55:55 -0700371 std::string name; //!< Name of DCMI capability.
372 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
373 uint8_t position; //!< bit position from the DCMI spec.
374 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600375};
376
377using DCMICapList = std::vector<DCMICap>;
378
379/** @struct DCMICapEntry
380 *
381 * DCMI capabilities list and size for each parameter.
382 */
383struct DCMICapEntry
384{
Patrick Venture0b02be92018-08-31 11:55:55 -0700385 uint8_t size; //!< Size of capability array in bytes.
386 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600387};
388
389using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
390
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600391/** @struct GetTempReadingsRequest
392 *
393 * DCMI payload for Get Temperature Readings request
394 */
395struct GetTempReadingsRequest
396{
Patrick Venture0b02be92018-08-31 11:55:55 -0700397 uint8_t groupID; //!< Group extension identification.
398 uint8_t sensorType; //!< Type of the sensor
399 uint8_t entityId; //!< Entity ID
400 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
401 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600402} __attribute__((packed));
403
404/** @struct GetTempReadingsResponse
405 *
406 * DCMI header for Get Temperature Readings response
407 */
408struct GetTempReadingsResponseHdr
409{
Patrick Venture0b02be92018-08-31 11:55:55 -0700410 uint8_t groupID; //!< Group extension identification.
411 uint8_t numInstances; //!< No. of instances for requested id
412 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600413} __attribute__((packed));
414
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600415/** @brief Parse out JSON config file containing information
416 * related to sensors.
417 *
418 * @return A json object
419 */
420Json parseSensorConfig();
421
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600422namespace temp_readings
423{
Patrick Venture0b02be92018-08-31 11:55:55 -0700424/** @brief Read temperature from a d-bus object, scale it as per dcmi
425 * get temperature reading requirements.
426 *
427 * @param[in] dbusService - the D-Bus service
428 * @param[in] dbusPath - the D-Bus path
429 *
430 * @return A temperature reading
431 */
432Temperature readTemp(const std::string& dbusService,
433 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600434
Patrick Venture0b02be92018-08-31 11:55:55 -0700435/** @brief Read temperatures and fill up DCMI response for the Get
436 * Temperature Readings command. This looks at a specific
437 * instance.
438 *
439 * @param[in] type - one of "inlet", "cpu", "baseboard"
440 * @param[in] instance - A non-zero Entity instance number
441 *
442 * @return A tuple, containing a temperature reading and the
443 * number of instances.
444 */
445std::tuple<Response, NumInstances> read(const std::string& type,
446 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -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 range of
450 * instances.
451 *
452 * @param[in] type - one of "inlet", "cpu", "baseboard"
453 * @param[in] instanceStart - Entity instance start index
454 *
455 * @return A tuple, containing a list of temperature readings and the
456 * number of instances.
457 */
458std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
459 uint8_t instanceStart);
460} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600461
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600462namespace sensor_info
463{
Patrick Venture0b02be92018-08-31 11:55:55 -0700464/** @brief Create response from JSON config.
465 *
466 * @param[in] config - JSON config info about DCMI sensors
467 *
468 * @return Sensor info response
469 */
470Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600471
Patrick Venture0b02be92018-08-31 11:55:55 -0700472/** @brief Read sensor info and fill up DCMI response for the Get
473 * Sensor Info command. This looks at a specific
474 * instance.
475 *
476 * @param[in] type - one of "inlet", "cpu", "baseboard"
477 * @param[in] instance - A non-zero Entity instance number
478 * @param[in] config - JSON config info about DCMI sensors
479 *
480 * @return A tuple, containing a sensor info response and
481 * number of instances.
482 */
483std::tuple<Response, NumInstances> read(const std::string& type,
484 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600485
Patrick Venture0b02be92018-08-31 11:55:55 -0700486/** @brief Read sensor info and fill up DCMI response for the Get
487 * Sensor Info command. This looks at a range of
488 * instances.
489 *
490 * @param[in] type - one of "inlet", "cpu", "baseboard"
491 * @param[in] instanceStart - Entity instance start index
492 * @param[in] config - JSON config info about DCMI sensors
493 *
494 * @return A tuple, containing a list of sensor info responses and the
495 * number of instances.
496 */
497std::tuple<ResponseList, NumInstances>
498 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600499} // namespace sensor_info
500
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600501/** @brief Read power reading from power reading sensor object
502 *
503 * @param[in] bus - dbus connection
504 *
505 * @return total power reading
506 */
507int64_t getPowerReading(sdbusplus::bus::bus& bus);
508
509/** @struct GetPowerReadingRequest
510 *
511 * DCMI Get Power Reading command request.
512 * Refer DCMI specification Version 1.1 Section 6.6.1
513 */
514struct GetPowerReadingRequest
515{
Patrick Venture0b02be92018-08-31 11:55:55 -0700516 uint8_t groupID; //!< Group extension identification.
517 uint8_t mode; //!< Mode
518 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600519} __attribute__((packed));
520
521/** @struct GetPowerReadingResponse
522 *
523 * DCMI Get Power Reading command response.
524 * Refer DCMI specification Version 1.1 Section 6.6.1
525 */
526struct GetPowerReadingResponse
527{
Patrick Venture0b02be92018-08-31 11:55:55 -0700528 uint8_t groupID; //!< Group extension identification.
529 uint16_t currentPower; //!< Current power in watts
530 uint16_t minimumPower; //!< Minimum power over sampling duration
531 //!< in watts
532 uint16_t maximumPower; //!< Maximum power over sampling duration
533 //!< in watts
534 uint16_t averagePower; //!< Average power over sampling duration
535 //!< in watts
536 uint32_t timeStamp; //!< IPMI specification based time stamp
537 uint32_t timeFrame; //!< Statistics reporting time period in milli
538 //!< seconds.
539 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600540} __attribute__((packed));
541
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600542/** @struct GetSensorInfoRequest
543 *
544 * DCMI payload for Get Sensor Info request
545 */
546struct GetSensorInfoRequest
547{
Patrick Venture0b02be92018-08-31 11:55:55 -0700548 uint8_t groupID; //!< Group extension identification.
549 uint8_t sensorType; //!< Type of the sensor
550 uint8_t entityId; //!< Entity ID
551 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
552 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600553} __attribute__((packed));
554
555/** @struct GetSensorInfoResponseHdr
556 *
557 * DCMI header for Get Sensor Info response
558 */
559struct GetSensorInfoResponseHdr
560{
Patrick Venture0b02be92018-08-31 11:55:55 -0700561 uint8_t groupID; //!< Group extension identification.
562 uint8_t numInstances; //!< No. of instances for requested id
563 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600564} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600565/**
566 * @brief Parameters for DCMI Configuration Parameters
567 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700568enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600569{
570 ActivateDHCP = 1,
571 DiscoveryConfig,
572 DHCPTiming1,
573 DHCPTiming2,
574 DHCPTiming3,
575};
576
577/** @struct SetConfParamsRequest
578 *
579 * DCMI Set DCMI Configuration Parameters Command.
580 * Refer DCMI specification Version 1.1 Section 6.1.2
581 */
582struct SetConfParamsRequest
583{
Patrick Venture0b02be92018-08-31 11:55:55 -0700584 uint8_t groupID; //!< Group extension identification.
585 uint8_t paramSelect; //!< Parameter selector.
586 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
587 //!< have one set).
588 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600589} __attribute__((packed));
590
591/** @struct SetConfParamsResponse
592 *
593 * DCMI Set DCMI Configuration Parameters Command response.
594 * Refer DCMI specification Version 1.1 Section 6.1.2
595 */
596struct SetConfParamsResponse
597{
Patrick Venture0b02be92018-08-31 11:55:55 -0700598 uint8_t groupID; //!< Group extension identification.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600599} __attribute__((packed));
600
601/** @struct GetConfParamsRequest
602 *
603 * DCMI Get DCMI Configuration Parameters Command.
604 * Refer DCMI specification Version 1.1 Section 6.1.3
605 */
606struct GetConfParamsRequest
607{
Patrick Venture0b02be92018-08-31 11:55:55 -0700608 uint8_t groupID; //!< Group extension identification.
609 uint8_t paramSelect; //!< Parameter selector.
610 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
611 //!< under a given Parameter selector value. 00h if
612 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600613} __attribute__((packed));
614
615/** @struct GetConfParamsResponse
616 *
617 * DCMI Get DCMI Configuration Parameters Command response.
618 * Refer DCMI specification Version 1.1 Section 6.1.3
619 */
620struct GetConfParamsResponse
621{
Patrick Venture0b02be92018-08-31 11:55:55 -0700622 uint8_t groupID; //!< Group extension identification.
623 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
624 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
625 uint8_t paramRevision; //!< Parameter Revision = 01h.
626 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600627
628} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600629
Tom Josephbe5eaa12017-07-12 19:54:44 +0530630} // namespace dcmi
631
632#endif