blob: 29757fff1e33996d8b8583ed50313749df215f0a [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;
45static constexpr auto configFile =
46 "/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";
Tom Josephbe5eaa12017-07-12 19:54:44 +053057
58namespace assettag
59{
60
Patrick Venture0b02be92018-08-31 11:55:55 -070061using ObjectPath = std::string;
62using Service = std::string;
63using Interfaces = std::vector<std::string>;
64using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053065
Patrick Venture0b02be92018-08-31 11:55:55 -070066} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053067
Deepak Kodihalliee717d72018-01-24 04:53:09 -060068namespace temp_readings
69{
Patrick Venture0b02be92018-08-31 11:55:55 -070070static constexpr auto maxDataSets = 8;
71static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060072
Patrick Venture0b02be92018-08-31 11:55:55 -070073/** @struct Response
74 *
75 * DCMI payload for Get Temperature Readings response
76 */
77struct Response
78{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060079#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070080 uint8_t temperature : 7; //!< Temperature reading in Celsius
81 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060082#endif
83#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070084 uint8_t sign : 1; //!< Sign bit
85 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060086#endif
Patrick Venture0b02be92018-08-31 11:55:55 -070087 uint8_t instance; //!< Entity instance number
88} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060089
Patrick Venture0b02be92018-08-31 11:55:55 -070090using ResponseList = std::vector<Response>;
91using Value = uint8_t;
92using Sign = bool;
93using Temperature = std::tuple<Value, Sign>;
94} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -060095
Deepak Kodihalli0b459552018-02-06 06:25:12 -060096namespace sensor_info
97{
Patrick Venture0b02be92018-08-31 11:55:55 -070098static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -060099
Patrick Venture0b02be92018-08-31 11:55:55 -0700100/** @struct Response
101 *
102 * DCMI payload for Get Sensor Info response
103 */
104struct Response
105{
106 uint8_t recordIdLsb; //!< SDR record id LS byte
107 uint8_t recordIdMsb; //!< SDR record id MS byte
108} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600109
Patrick Venture0b02be92018-08-31 11:55:55 -0700110using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600111} // namespace sensor_info
112
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530113static constexpr auto groupExtId = 0xDC;
114
115static constexpr auto assetTagMaxOffset = 62;
116static constexpr auto assetTagMaxSize = 63;
117static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300118static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530119
120/** @struct GetAssetTagRequest
121 *
122 * DCMI payload for Get Asset Tag command request.
123 */
124struct GetAssetTagRequest
125{
Patrick Venture0b02be92018-08-31 11:55:55 -0700126 uint8_t groupID; //!< Group extension identification.
127 uint8_t offset; //!< Offset to read.
128 uint8_t bytes; //!< Number of bytes to read.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530129} __attribute__((packed));
130
131/** @struct GetAssetTagResponse
132 *
133 * DCMI payload for Get Asset Tag command response.
134 */
135struct GetAssetTagResponse
136{
Patrick Venture0b02be92018-08-31 11:55:55 -0700137 uint8_t groupID; //!< Group extension identification.
138 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530139} __attribute__((packed));
140
Tom Joseph545dd232017-07-12 20:20:49 +0530141/** @struct SetAssetTagRequest
142 *
143 * DCMI payload for Set Asset Tag command request.
144 */
145struct SetAssetTagRequest
146{
Patrick Venture0b02be92018-08-31 11:55:55 -0700147 uint8_t groupID; //!< Group extension identification.
148 uint8_t offset; //!< Offset to write.
149 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530150} __attribute__((packed));
151
152/** @struct SetAssetTagResponse
153 *
154 * DCMI payload for Set Asset Tag command response.
155 */
156struct SetAssetTagResponse
157{
Patrick Venture0b02be92018-08-31 11:55:55 -0700158 uint8_t groupID; //!< Group extension identification.
159 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530160} __attribute__((packed));
161
Tom Josephbe5eaa12017-07-12 19:54:44 +0530162/** @brief Read the object tree to fetch the object path that implemented the
163 * Asset tag interface.
164 *
165 * @param[in,out] objectTree - object tree
166 *
167 * @return On success return the object tree with the object path that
168 * implemented the AssetTag interface.
169 */
170void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
171
172/** @brief Read the asset tag of the server
173 *
174 * @return On success return the asset tag.
175 */
176std::string readAssetTag();
177
Tom Josephbe5b9892017-07-15 00:55:23 +0530178/** @brief Write the asset tag to the asset tag DBUS property
179 *
180 * @param[in] assetTag - Asset Tag to be written to the property.
181 */
182void writeAssetTag(const std::string& assetTag);
183
Tom Josephb9d86f42017-07-26 18:03:47 +0530184/** @brief Read the current power cap value
185 *
186 * @param[in] bus - dbus connection
187 *
188 * @return On success return the power cap value.
189 */
190uint32_t getPcap(sdbusplus::bus::bus& bus);
191
192/** @brief Check if the power capping is enabled
193 *
194 * @param[in] bus - dbus connection
195 *
196 * @return true if the powerCap is enabled and false if the powercap
197 * is disabled.
198 */
199bool getPcapEnabled(sdbusplus::bus::bus& bus);
200
201/** @struct GetPowerLimitRequest
202 *
203 * DCMI payload for Get Power Limit command request.
204 */
205struct GetPowerLimitRequest
206{
Patrick Venture0b02be92018-08-31 11:55:55 -0700207 uint8_t groupID; //!< Group extension identification.
208 uint16_t reserved; //!< Reserved
Tom Josephb9d86f42017-07-26 18:03:47 +0530209} __attribute__((packed));
210
211/** @struct GetPowerLimitResponse
212 *
213 * DCMI payload for Get Power Limit command response.
214 */
215struct GetPowerLimitResponse
216{
Patrick Venture0b02be92018-08-31 11:55:55 -0700217 uint8_t groupID; //!< Group extension identification.
218 uint16_t reserved; //!< Reserved.
219 uint8_t exceptionAction; //!< Exception action.
220 uint16_t powerLimit; //!< Power limit requested in watts.
221 uint32_t correctionTime; //!< Correction time limit in milliseconds.
222 uint16_t reserved1; //!< Reserved.
223 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530224} __attribute__((packed));
225
Tom Joseph46fa37d2017-07-26 18:11:55 +0530226/** @brief Set the power cap value
227 *
228 * @param[in] bus - dbus connection
229 * @param[in] powerCap - power cap value
230 */
231void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
232
233/** @struct SetPowerLimitRequest
234 *
235 * DCMI payload for Set Power Limit command request.
236 */
237struct SetPowerLimitRequest
238{
Patrick Venture0b02be92018-08-31 11:55:55 -0700239 uint8_t groupID; //!< Group extension identification.
240 uint16_t reserved; //!< Reserved
241 uint8_t reserved1; //!< Reserved
242 uint8_t exceptionAction; //!< Exception action.
243 uint16_t powerLimit; //!< Power limit requested in watts.
244 uint32_t correctionTime; //!< Correction time limit in milliseconds.
245 uint16_t reserved2; //!< Reserved.
246 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530247} __attribute__((packed));
248
249/** @struct SetPowerLimitResponse
250 *
251 * DCMI payload for Set Power Limit command response.
252 */
253struct SetPowerLimitResponse
254{
Patrick Venture0b02be92018-08-31 11:55:55 -0700255 uint8_t groupID; //!< Group extension identification.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530256} __attribute__((packed));
257
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530258/** @brief Enable or disable the power capping
259 *
260 * @param[in] bus - dbus connection
261 * @param[in] enabled - enable/disable
262 */
263void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
264
265/** @struct ApplyPowerLimitRequest
266 *
267 * DCMI payload for Activate/Deactivate Power Limit command request.
268 */
269struct ApplyPowerLimitRequest
270{
Patrick Venture0b02be92018-08-31 11:55:55 -0700271 uint8_t groupID; //!< Group extension identification.
272 uint8_t powerLimitAction; //!< Power limit activation
273 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530274} __attribute__((packed));
275
276/** @struct ApplyPowerLimitResponse
277 *
278 * DCMI payload for Acticate/Deactivate Power Limit command response.
279 */
280struct ApplyPowerLimitResponse
281{
Patrick Venture0b02be92018-08-31 11:55:55 -0700282 uint8_t groupID; //!< Group extension identification.
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530283} __attribute__((packed));
284
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300285/** @struct GetMgmntCtrlIdStrRequest
286 *
287 * DCMI payload for Get Management Controller Identifier String cmd request.
288 */
289struct GetMgmntCtrlIdStrRequest
290{
Patrick Venture0b02be92018-08-31 11:55:55 -0700291 uint8_t groupID; //!< Group extension identification.
292 uint8_t offset; //!< Offset to read.
293 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300294} __attribute__((packed));
295
296/** @struct GetMgmntCtrlIdStrResponse
297 *
298 * DCMI payload for Get Management Controller Identifier String cmd response.
299 */
300struct GetMgmntCtrlIdStrResponse
301{
Patrick Venture0b02be92018-08-31 11:55:55 -0700302 uint8_t groupID; //!< Group extension identification.
303 uint8_t strLen; //!< ID string length.
304 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300305} __attribute__((packed));
306
307/** @struct SetMgmntCtrlIdStrRequest
308 *
309 * DCMI payload for Set Management Controller Identifier String cmd request.
310 */
311struct SetMgmntCtrlIdStrRequest
312{
Patrick Venture0b02be92018-08-31 11:55:55 -0700313 uint8_t groupID; //!< Group extension identification.
314 uint8_t offset; //!< Offset to write.
315 uint8_t bytes; //!< Number of bytes to read.
316 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300317} __attribute__((packed));
318
319/** @struct GetMgmntCtrlIdStrResponse
320 *
321 * DCMI payload for Get Management Controller Identifier String cmd response.
322 */
323struct SetMgmntCtrlIdStrResponse
324{
Patrick Venture0b02be92018-08-31 11:55:55 -0700325 uint8_t groupID; //!< Group extension identification.
326 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300327} __attribute__((packed));
328
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600329/** @enum DCMICapParameters
330 *
331 * DCMI Capability parameters
332 */
333enum class DCMICapParameters
334{
335 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
336 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
337 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
338 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
339};
340
341/** @struct GetDCMICapRequest
342 *
343 * DCMI payload for Get capabilities cmd request.
344 */
345struct GetDCMICapRequest
346{
Patrick Venture0b02be92018-08-31 11:55:55 -0700347 uint8_t groupID; //!< Group extension identification.
348 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600349} __attribute__((packed));
350
351/** @struct GetDCMICapRequest
352 *
353 * DCMI payload for Get capabilities cmd response.
354 */
355struct GetDCMICapResponse
356{
Patrick Venture0b02be92018-08-31 11:55:55 -0700357 uint8_t groupID; //!< Group extension identification.
358 uint8_t major; //!< DCMI Specification Conformance - major ver
359 uint8_t minor; //!< DCMI Specification Conformance - minor ver
360 uint8_t paramRevision; //!< Parameter Revision = 02h
361 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600362} __attribute__((packed));
363
364/** @struct DCMICap
365 *
366 * DCMI capabilities protocol info.
367 */
368struct DCMICap
369{
Patrick Venture0b02be92018-08-31 11:55:55 -0700370 std::string name; //!< Name of DCMI capability.
371 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
372 uint8_t position; //!< bit position from the DCMI spec.
373 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600374};
375
376using DCMICapList = std::vector<DCMICap>;
377
378/** @struct DCMICapEntry
379 *
380 * DCMI capabilities list and size for each parameter.
381 */
382struct DCMICapEntry
383{
Patrick Venture0b02be92018-08-31 11:55:55 -0700384 uint8_t size; //!< Size of capability array in bytes.
385 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600386};
387
388using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
389
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600390/** @struct GetTempReadingsRequest
391 *
392 * DCMI payload for Get Temperature Readings request
393 */
394struct GetTempReadingsRequest
395{
Patrick Venture0b02be92018-08-31 11:55:55 -0700396 uint8_t groupID; //!< Group extension identification.
397 uint8_t sensorType; //!< Type of the sensor
398 uint8_t entityId; //!< Entity ID
399 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
400 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600401} __attribute__((packed));
402
403/** @struct GetTempReadingsResponse
404 *
405 * DCMI header for Get Temperature Readings response
406 */
407struct GetTempReadingsResponseHdr
408{
Patrick Venture0b02be92018-08-31 11:55:55 -0700409 uint8_t groupID; //!< Group extension identification.
410 uint8_t numInstances; //!< No. of instances for requested id
411 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600412} __attribute__((packed));
413
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600414/** @brief Parse out JSON config file containing information
415 * related to sensors.
416 *
417 * @return A json object
418 */
419Json parseSensorConfig();
420
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600421namespace temp_readings
422{
Patrick Venture0b02be92018-08-31 11:55:55 -0700423/** @brief Read temperature from a d-bus object, scale it as per dcmi
424 * get temperature reading requirements.
425 *
426 * @param[in] dbusService - the D-Bus service
427 * @param[in] dbusPath - the D-Bus path
428 *
429 * @return A temperature reading
430 */
431Temperature readTemp(const std::string& dbusService,
432 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600433
Patrick Venture0b02be92018-08-31 11:55:55 -0700434/** @brief Read temperatures and fill up DCMI response for the Get
435 * Temperature Readings command. This looks at a specific
436 * instance.
437 *
438 * @param[in] type - one of "inlet", "cpu", "baseboard"
439 * @param[in] instance - A non-zero Entity instance number
440 *
441 * @return A tuple, containing a temperature reading and the
442 * number of instances.
443 */
444std::tuple<Response, NumInstances> read(const std::string& type,
445 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600446
Patrick Venture0b02be92018-08-31 11:55:55 -0700447/** @brief Read temperatures and fill up DCMI response for the Get
448 * Temperature Readings command. This looks at a range of
449 * instances.
450 *
451 * @param[in] type - one of "inlet", "cpu", "baseboard"
452 * @param[in] instanceStart - Entity instance start index
453 *
454 * @return A tuple, containing a list of temperature readings and the
455 * number of instances.
456 */
457std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
458 uint8_t instanceStart);
459} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600460
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600461namespace sensor_info
462{
Patrick Venture0b02be92018-08-31 11:55:55 -0700463/** @brief Create response from JSON config.
464 *
465 * @param[in] config - JSON config info about DCMI sensors
466 *
467 * @return Sensor info response
468 */
469Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600470
Patrick Venture0b02be92018-08-31 11:55:55 -0700471/** @brief Read sensor info and fill up DCMI response for the Get
472 * Sensor Info command. This looks at a specific
473 * instance.
474 *
475 * @param[in] type - one of "inlet", "cpu", "baseboard"
476 * @param[in] instance - A non-zero Entity instance number
477 * @param[in] config - JSON config info about DCMI sensors
478 *
479 * @return A tuple, containing a sensor info response and
480 * number of instances.
481 */
482std::tuple<Response, NumInstances> read(const std::string& type,
483 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -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 range of
487 * instances.
488 *
489 * @param[in] type - one of "inlet", "cpu", "baseboard"
490 * @param[in] instanceStart - Entity instance start index
491 * @param[in] config - JSON config info about DCMI sensors
492 *
493 * @return A tuple, containing a list of sensor info responses and the
494 * number of instances.
495 */
496std::tuple<ResponseList, NumInstances>
497 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600498} // namespace sensor_info
499
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600500/** @brief Read power reading from power reading sensor object
501 *
502 * @param[in] bus - dbus connection
503 *
504 * @return total power reading
505 */
506int64_t getPowerReading(sdbusplus::bus::bus& bus);
507
508/** @struct GetPowerReadingRequest
509 *
510 * DCMI Get Power Reading command request.
511 * Refer DCMI specification Version 1.1 Section 6.6.1
512 */
513struct GetPowerReadingRequest
514{
Patrick Venture0b02be92018-08-31 11:55:55 -0700515 uint8_t groupID; //!< Group extension identification.
516 uint8_t mode; //!< Mode
517 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600518} __attribute__((packed));
519
520/** @struct GetPowerReadingResponse
521 *
522 * DCMI Get Power Reading command response.
523 * Refer DCMI specification Version 1.1 Section 6.6.1
524 */
525struct GetPowerReadingResponse
526{
Patrick Venture0b02be92018-08-31 11:55:55 -0700527 uint8_t groupID; //!< Group extension identification.
528 uint16_t currentPower; //!< Current power in watts
529 uint16_t minimumPower; //!< Minimum power over sampling duration
530 //!< in watts
531 uint16_t maximumPower; //!< Maximum power over sampling duration
532 //!< in watts
533 uint16_t averagePower; //!< Average power over sampling duration
534 //!< in watts
535 uint32_t timeStamp; //!< IPMI specification based time stamp
536 uint32_t timeFrame; //!< Statistics reporting time period in milli
537 //!< seconds.
538 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600539} __attribute__((packed));
540
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600541/** @struct GetSensorInfoRequest
542 *
543 * DCMI payload for Get Sensor Info request
544 */
545struct GetSensorInfoRequest
546{
Patrick Venture0b02be92018-08-31 11:55:55 -0700547 uint8_t groupID; //!< Group extension identification.
548 uint8_t sensorType; //!< Type of the sensor
549 uint8_t entityId; //!< Entity ID
550 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
551 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600552} __attribute__((packed));
553
554/** @struct GetSensorInfoResponseHdr
555 *
556 * DCMI header for Get Sensor Info response
557 */
558struct GetSensorInfoResponseHdr
559{
Patrick Venture0b02be92018-08-31 11:55:55 -0700560 uint8_t groupID; //!< Group extension identification.
561 uint8_t numInstances; //!< No. of instances for requested id
562 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600563} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600564/**
565 * @brief Parameters for DCMI Configuration Parameters
566 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700567enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600568{
569 ActivateDHCP = 1,
570 DiscoveryConfig,
571 DHCPTiming1,
572 DHCPTiming2,
573 DHCPTiming3,
574};
575
576/** @struct SetConfParamsRequest
577 *
578 * DCMI Set DCMI Configuration Parameters Command.
579 * Refer DCMI specification Version 1.1 Section 6.1.2
580 */
581struct SetConfParamsRequest
582{
Patrick Venture0b02be92018-08-31 11:55:55 -0700583 uint8_t groupID; //!< Group extension identification.
584 uint8_t paramSelect; //!< Parameter selector.
585 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
586 //!< have one set).
587 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600588} __attribute__((packed));
589
590/** @struct SetConfParamsResponse
591 *
592 * DCMI Set DCMI Configuration Parameters Command response.
593 * Refer DCMI specification Version 1.1 Section 6.1.2
594 */
595struct SetConfParamsResponse
596{
Patrick Venture0b02be92018-08-31 11:55:55 -0700597 uint8_t groupID; //!< Group extension identification.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600598} __attribute__((packed));
599
600/** @struct GetConfParamsRequest
601 *
602 * DCMI Get DCMI Configuration Parameters Command.
603 * Refer DCMI specification Version 1.1 Section 6.1.3
604 */
605struct GetConfParamsRequest
606{
Patrick Venture0b02be92018-08-31 11:55:55 -0700607 uint8_t groupID; //!< Group extension identification.
608 uint8_t paramSelect; //!< Parameter selector.
609 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
610 //!< under a given Parameter selector value. 00h if
611 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600612} __attribute__((packed));
613
614/** @struct GetConfParamsResponse
615 *
616 * DCMI Get DCMI Configuration Parameters Command response.
617 * Refer DCMI specification Version 1.1 Section 6.1.3
618 */
619struct GetConfParamsResponse
620{
Patrick Venture0b02be92018-08-31 11:55:55 -0700621 uint8_t groupID; //!< Group extension identification.
622 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
623 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
624 uint8_t paramRevision; //!< Parameter Revision = 01h.
625 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600626
627} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600628
Tom Josephbe5eaa12017-07-12 19:54:44 +0530629} // namespace dcmi