blob: e3fa9de8264f5c56e1c5b09cc64442d89debb233 [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";
Tom Josephbe5eaa12017-07-12 19:54:44 +053059
60namespace assettag
61{
62
Patrick Venture0b02be92018-08-31 11:55:55 -070063using ObjectPath = std::string;
64using Service = std::string;
65using Interfaces = std::vector<std::string>;
66using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053067
Patrick Venture0b02be92018-08-31 11:55:55 -070068} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053069
Deepak Kodihalliee717d72018-01-24 04:53:09 -060070namespace temp_readings
71{
Patrick Venture0b02be92018-08-31 11:55:55 -070072static constexpr auto maxDataSets = 8;
73static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060074
Patrick Venture0b02be92018-08-31 11:55:55 -070075/** @struct Response
76 *
77 * DCMI payload for Get Temperature Readings response
78 */
79struct Response
80{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060081#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070082 uint8_t temperature : 7; //!< Temperature reading in Celsius
83 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060084#endif
85#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070086 uint8_t sign : 1; //!< Sign bit
87 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060088#endif
Patrick Venture0b02be92018-08-31 11:55:55 -070089 uint8_t instance; //!< Entity instance number
90} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060091
Patrick Venture0b02be92018-08-31 11:55:55 -070092using ResponseList = std::vector<Response>;
93using Value = uint8_t;
94using Sign = bool;
95using Temperature = std::tuple<Value, Sign>;
96} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -060097
Deepak Kodihalli0b459552018-02-06 06:25:12 -060098namespace sensor_info
99{
Patrick Venture0b02be92018-08-31 11:55:55 -0700100static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600101
Patrick Venture0b02be92018-08-31 11:55:55 -0700102/** @struct Response
103 *
104 * DCMI payload for Get Sensor Info response
105 */
106struct Response
107{
108 uint8_t recordIdLsb; //!< SDR record id LS byte
109 uint8_t recordIdMsb; //!< SDR record id MS byte
110} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600111
Patrick Venture0b02be92018-08-31 11:55:55 -0700112using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600113} // namespace sensor_info
114
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530115static constexpr auto groupExtId = 0xDC;
116
117static constexpr auto assetTagMaxOffset = 62;
118static constexpr auto assetTagMaxSize = 63;
119static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300120static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530121
122/** @struct GetAssetTagRequest
123 *
124 * DCMI payload for Get Asset Tag command request.
125 */
126struct GetAssetTagRequest
127{
Patrick Venture0b02be92018-08-31 11:55:55 -0700128 uint8_t groupID; //!< Group extension identification.
129 uint8_t offset; //!< Offset to read.
130 uint8_t bytes; //!< Number of bytes to read.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530131} __attribute__((packed));
132
133/** @struct GetAssetTagResponse
134 *
135 * DCMI payload for Get Asset Tag command response.
136 */
137struct GetAssetTagResponse
138{
Patrick Venture0b02be92018-08-31 11:55:55 -0700139 uint8_t groupID; //!< Group extension identification.
140 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530141} __attribute__((packed));
142
Tom Joseph545dd232017-07-12 20:20:49 +0530143/** @struct SetAssetTagRequest
144 *
145 * DCMI payload for Set Asset Tag command request.
146 */
147struct SetAssetTagRequest
148{
Patrick Venture0b02be92018-08-31 11:55:55 -0700149 uint8_t groupID; //!< Group extension identification.
150 uint8_t offset; //!< Offset to write.
151 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530152} __attribute__((packed));
153
154/** @struct SetAssetTagResponse
155 *
156 * DCMI payload for Set Asset Tag command response.
157 */
158struct SetAssetTagResponse
159{
Patrick Venture0b02be92018-08-31 11:55:55 -0700160 uint8_t groupID; //!< Group extension identification.
161 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530162} __attribute__((packed));
163
Tom Josephbe5eaa12017-07-12 19:54:44 +0530164/** @brief Read the object tree to fetch the object path that implemented the
165 * Asset tag interface.
166 *
167 * @param[in,out] objectTree - object tree
168 *
169 * @return On success return the object tree with the object path that
170 * implemented the AssetTag interface.
171 */
172void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
173
174/** @brief Read the asset tag of the server
175 *
176 * @return On success return the asset tag.
177 */
178std::string readAssetTag();
179
Tom Josephbe5b9892017-07-15 00:55:23 +0530180/** @brief Write the asset tag to the asset tag DBUS property
181 *
182 * @param[in] assetTag - Asset Tag to be written to the property.
183 */
184void writeAssetTag(const std::string& assetTag);
185
Tom Josephb9d86f42017-07-26 18:03:47 +0530186/** @brief Read the current power cap value
187 *
188 * @param[in] bus - dbus connection
189 *
190 * @return On success return the power cap value.
191 */
192uint32_t getPcap(sdbusplus::bus::bus& bus);
193
194/** @brief Check if the power capping is enabled
195 *
196 * @param[in] bus - dbus connection
197 *
198 * @return true if the powerCap is enabled and false if the powercap
199 * is disabled.
200 */
201bool getPcapEnabled(sdbusplus::bus::bus& bus);
202
203/** @struct GetPowerLimitRequest
204 *
205 * DCMI payload for Get Power Limit command request.
206 */
207struct GetPowerLimitRequest
208{
Patrick Venture0b02be92018-08-31 11:55:55 -0700209 uint8_t groupID; //!< Group extension identification.
210 uint16_t reserved; //!< Reserved
Tom Josephb9d86f42017-07-26 18:03:47 +0530211} __attribute__((packed));
212
213/** @struct GetPowerLimitResponse
214 *
215 * DCMI payload for Get Power Limit command response.
216 */
217struct GetPowerLimitResponse
218{
Patrick Venture0b02be92018-08-31 11:55:55 -0700219 uint8_t groupID; //!< Group extension identification.
220 uint16_t reserved; //!< Reserved.
221 uint8_t exceptionAction; //!< Exception action.
222 uint16_t powerLimit; //!< Power limit requested in watts.
223 uint32_t correctionTime; //!< Correction time limit in milliseconds.
224 uint16_t reserved1; //!< Reserved.
225 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530226} __attribute__((packed));
227
Tom Joseph46fa37d2017-07-26 18:11:55 +0530228/** @brief Set the power cap value
229 *
230 * @param[in] bus - dbus connection
231 * @param[in] powerCap - power cap value
232 */
233void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap);
234
235/** @struct SetPowerLimitRequest
236 *
237 * DCMI payload for Set Power Limit command request.
238 */
239struct SetPowerLimitRequest
240{
Patrick Venture0b02be92018-08-31 11:55:55 -0700241 uint8_t groupID; //!< Group extension identification.
242 uint16_t reserved; //!< Reserved
243 uint8_t reserved1; //!< Reserved
244 uint8_t exceptionAction; //!< Exception action.
245 uint16_t powerLimit; //!< Power limit requested in watts.
246 uint32_t correctionTime; //!< Correction time limit in milliseconds.
247 uint16_t reserved2; //!< Reserved.
248 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530249} __attribute__((packed));
250
251/** @struct SetPowerLimitResponse
252 *
253 * DCMI payload for Set Power Limit command response.
254 */
255struct SetPowerLimitResponse
256{
Patrick Venture0b02be92018-08-31 11:55:55 -0700257 uint8_t groupID; //!< Group extension identification.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530258} __attribute__((packed));
259
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530260/** @brief Enable or disable the power capping
261 *
262 * @param[in] bus - dbus connection
263 * @param[in] enabled - enable/disable
264 */
265void setPcapEnable(sdbusplus::bus::bus& bus, bool enabled);
266
267/** @struct ApplyPowerLimitRequest
268 *
269 * DCMI payload for Activate/Deactivate Power Limit command request.
270 */
271struct ApplyPowerLimitRequest
272{
Patrick Venture0b02be92018-08-31 11:55:55 -0700273 uint8_t groupID; //!< Group extension identification.
274 uint8_t powerLimitAction; //!< Power limit activation
275 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530276} __attribute__((packed));
277
278/** @struct ApplyPowerLimitResponse
279 *
280 * DCMI payload for Acticate/Deactivate Power Limit command response.
281 */
282struct ApplyPowerLimitResponse
283{
Patrick Venture0b02be92018-08-31 11:55:55 -0700284 uint8_t groupID; //!< Group extension identification.
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530285} __attribute__((packed));
286
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300287/** @struct GetMgmntCtrlIdStrRequest
288 *
289 * DCMI payload for Get Management Controller Identifier String cmd request.
290 */
291struct GetMgmntCtrlIdStrRequest
292{
Patrick Venture0b02be92018-08-31 11:55:55 -0700293 uint8_t groupID; //!< Group extension identification.
294 uint8_t offset; //!< Offset to read.
295 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300296} __attribute__((packed));
297
298/** @struct GetMgmntCtrlIdStrResponse
299 *
300 * DCMI payload for Get Management Controller Identifier String cmd response.
301 */
302struct GetMgmntCtrlIdStrResponse
303{
Patrick Venture0b02be92018-08-31 11:55:55 -0700304 uint8_t groupID; //!< Group extension identification.
305 uint8_t strLen; //!< ID string length.
306 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300307} __attribute__((packed));
308
309/** @struct SetMgmntCtrlIdStrRequest
310 *
311 * DCMI payload for Set Management Controller Identifier String cmd request.
312 */
313struct SetMgmntCtrlIdStrRequest
314{
Patrick Venture0b02be92018-08-31 11:55:55 -0700315 uint8_t groupID; //!< Group extension identification.
316 uint8_t offset; //!< Offset to write.
317 uint8_t bytes; //!< Number of bytes to read.
318 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300319} __attribute__((packed));
320
321/** @struct GetMgmntCtrlIdStrResponse
322 *
323 * DCMI payload for Get Management Controller Identifier String cmd response.
324 */
325struct SetMgmntCtrlIdStrResponse
326{
Patrick Venture0b02be92018-08-31 11:55:55 -0700327 uint8_t groupID; //!< Group extension identification.
328 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300329} __attribute__((packed));
330
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600331/** @enum DCMICapParameters
332 *
333 * DCMI Capability parameters
334 */
335enum class DCMICapParameters
336{
337 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
338 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
339 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
340 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
341};
342
343/** @struct GetDCMICapRequest
344 *
345 * DCMI payload for Get capabilities cmd request.
346 */
347struct GetDCMICapRequest
348{
Patrick Venture0b02be92018-08-31 11:55:55 -0700349 uint8_t groupID; //!< Group extension identification.
350 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600351} __attribute__((packed));
352
353/** @struct GetDCMICapRequest
354 *
355 * DCMI payload for Get capabilities cmd response.
356 */
357struct GetDCMICapResponse
358{
Patrick Venture0b02be92018-08-31 11:55:55 -0700359 uint8_t groupID; //!< Group extension identification.
360 uint8_t major; //!< DCMI Specification Conformance - major ver
361 uint8_t minor; //!< DCMI Specification Conformance - minor ver
362 uint8_t paramRevision; //!< Parameter Revision = 02h
363 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600364} __attribute__((packed));
365
366/** @struct DCMICap
367 *
368 * DCMI capabilities protocol info.
369 */
370struct DCMICap
371{
Patrick Venture0b02be92018-08-31 11:55:55 -0700372 std::string name; //!< Name of DCMI capability.
373 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
374 uint8_t position; //!< bit position from the DCMI spec.
375 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600376};
377
378using DCMICapList = std::vector<DCMICap>;
379
380/** @struct DCMICapEntry
381 *
382 * DCMI capabilities list and size for each parameter.
383 */
384struct DCMICapEntry
385{
Patrick Venture0b02be92018-08-31 11:55:55 -0700386 uint8_t size; //!< Size of capability array in bytes.
387 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600388};
389
390using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
391
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600392/** @struct GetTempReadingsRequest
393 *
394 * DCMI payload for Get Temperature Readings request
395 */
396struct GetTempReadingsRequest
397{
Patrick Venture0b02be92018-08-31 11:55:55 -0700398 uint8_t groupID; //!< Group extension identification.
399 uint8_t sensorType; //!< Type of the sensor
400 uint8_t entityId; //!< Entity ID
401 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
402 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600403} __attribute__((packed));
404
405/** @struct GetTempReadingsResponse
406 *
407 * DCMI header for Get Temperature Readings response
408 */
409struct GetTempReadingsResponseHdr
410{
Patrick Venture0b02be92018-08-31 11:55:55 -0700411 uint8_t groupID; //!< Group extension identification.
412 uint8_t numInstances; //!< No. of instances for requested id
413 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600414} __attribute__((packed));
415
Kirill Pakhomova2573622018-11-02 19:00:18 +0300416/** @brief Parse out JSON config file.
417 *
418 * @param[in] configFile - JSON config file name
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600419 *
420 * @return A json object
421 */
Kirill Pakhomova2573622018-11-02 19:00:18 +0300422Json parseJSONConfig(const std::string& configFile);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600423
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600424namespace temp_readings
425{
Patrick Venture0b02be92018-08-31 11:55:55 -0700426/** @brief Read temperature from a d-bus object, scale it as per dcmi
427 * get temperature reading requirements.
428 *
429 * @param[in] dbusService - the D-Bus service
430 * @param[in] dbusPath - the D-Bus path
431 *
432 * @return A temperature reading
433 */
434Temperature readTemp(const std::string& dbusService,
435 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600436
Patrick Venture0b02be92018-08-31 11:55:55 -0700437/** @brief Read temperatures and fill up DCMI response for the Get
438 * Temperature Readings command. This looks at a specific
439 * instance.
440 *
441 * @param[in] type - one of "inlet", "cpu", "baseboard"
442 * @param[in] instance - A non-zero Entity instance number
443 *
444 * @return A tuple, containing a temperature reading and the
445 * number of instances.
446 */
447std::tuple<Response, NumInstances> read(const std::string& type,
448 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600449
Patrick Venture0b02be92018-08-31 11:55:55 -0700450/** @brief Read temperatures and fill up DCMI response for the Get
451 * Temperature Readings command. This looks at a range of
452 * instances.
453 *
454 * @param[in] type - one of "inlet", "cpu", "baseboard"
455 * @param[in] instanceStart - Entity instance start index
456 *
457 * @return A tuple, containing a list of temperature readings and the
458 * number of instances.
459 */
460std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
461 uint8_t instanceStart);
462} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600463
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600464namespace sensor_info
465{
Patrick Venture0b02be92018-08-31 11:55:55 -0700466/** @brief Create response from JSON config.
467 *
468 * @param[in] config - JSON config info about DCMI sensors
469 *
470 * @return Sensor info response
471 */
472Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600473
Patrick Venture0b02be92018-08-31 11:55:55 -0700474/** @brief Read sensor info and fill up DCMI response for the Get
475 * Sensor Info command. This looks at a specific
476 * instance.
477 *
478 * @param[in] type - one of "inlet", "cpu", "baseboard"
479 * @param[in] instance - A non-zero Entity instance number
480 * @param[in] config - JSON config info about DCMI sensors
481 *
482 * @return A tuple, containing a sensor info response and
483 * number of instances.
484 */
485std::tuple<Response, NumInstances> read(const std::string& type,
486 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600487
Patrick Venture0b02be92018-08-31 11:55:55 -0700488/** @brief Read sensor info and fill up DCMI response for the Get
489 * Sensor Info command. This looks at a range of
490 * instances.
491 *
492 * @param[in] type - one of "inlet", "cpu", "baseboard"
493 * @param[in] instanceStart - Entity instance start index
494 * @param[in] config - JSON config info about DCMI sensors
495 *
496 * @return A tuple, containing a list of sensor info responses and the
497 * number of instances.
498 */
499std::tuple<ResponseList, NumInstances>
500 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600501} // namespace sensor_info
502
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600503/** @brief Read power reading from power reading sensor object
504 *
505 * @param[in] bus - dbus connection
506 *
507 * @return total power reading
508 */
509int64_t getPowerReading(sdbusplus::bus::bus& bus);
510
511/** @struct GetPowerReadingRequest
512 *
513 * DCMI Get Power Reading command request.
514 * Refer DCMI specification Version 1.1 Section 6.6.1
515 */
516struct GetPowerReadingRequest
517{
Patrick Venture0b02be92018-08-31 11:55:55 -0700518 uint8_t groupID; //!< Group extension identification.
519 uint8_t mode; //!< Mode
520 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600521} __attribute__((packed));
522
523/** @struct GetPowerReadingResponse
524 *
525 * DCMI Get Power Reading command response.
526 * Refer DCMI specification Version 1.1 Section 6.6.1
527 */
528struct GetPowerReadingResponse
529{
Patrick Venture0b02be92018-08-31 11:55:55 -0700530 uint8_t groupID; //!< Group extension identification.
531 uint16_t currentPower; //!< Current power in watts
532 uint16_t minimumPower; //!< Minimum power over sampling duration
533 //!< in watts
534 uint16_t maximumPower; //!< Maximum power over sampling duration
535 //!< in watts
536 uint16_t averagePower; //!< Average power over sampling duration
537 //!< in watts
538 uint32_t timeStamp; //!< IPMI specification based time stamp
539 uint32_t timeFrame; //!< Statistics reporting time period in milli
540 //!< seconds.
541 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600542} __attribute__((packed));
543
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600544/** @struct GetSensorInfoRequest
545 *
546 * DCMI payload for Get Sensor Info request
547 */
548struct GetSensorInfoRequest
549{
Patrick Venture0b02be92018-08-31 11:55:55 -0700550 uint8_t groupID; //!< Group extension identification.
551 uint8_t sensorType; //!< Type of the sensor
552 uint8_t entityId; //!< Entity ID
553 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
554 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600555} __attribute__((packed));
556
557/** @struct GetSensorInfoResponseHdr
558 *
559 * DCMI header for Get Sensor Info response
560 */
561struct GetSensorInfoResponseHdr
562{
Patrick Venture0b02be92018-08-31 11:55:55 -0700563 uint8_t groupID; //!< Group extension identification.
564 uint8_t numInstances; //!< No. of instances for requested id
565 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600566} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600567/**
568 * @brief Parameters for DCMI Configuration Parameters
569 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700570enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600571{
572 ActivateDHCP = 1,
573 DiscoveryConfig,
574 DHCPTiming1,
575 DHCPTiming2,
576 DHCPTiming3,
577};
578
579/** @struct SetConfParamsRequest
580 *
581 * DCMI Set DCMI Configuration Parameters Command.
582 * Refer DCMI specification Version 1.1 Section 6.1.2
583 */
584struct SetConfParamsRequest
585{
Patrick Venture0b02be92018-08-31 11:55:55 -0700586 uint8_t groupID; //!< Group extension identification.
587 uint8_t paramSelect; //!< Parameter selector.
588 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
589 //!< have one set).
590 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600591} __attribute__((packed));
592
593/** @struct SetConfParamsResponse
594 *
595 * DCMI Set DCMI Configuration Parameters Command response.
596 * Refer DCMI specification Version 1.1 Section 6.1.2
597 */
598struct SetConfParamsResponse
599{
Patrick Venture0b02be92018-08-31 11:55:55 -0700600 uint8_t groupID; //!< Group extension identification.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600601} __attribute__((packed));
602
603/** @struct GetConfParamsRequest
604 *
605 * DCMI Get DCMI Configuration Parameters Command.
606 * Refer DCMI specification Version 1.1 Section 6.1.3
607 */
608struct GetConfParamsRequest
609{
Patrick Venture0b02be92018-08-31 11:55:55 -0700610 uint8_t groupID; //!< Group extension identification.
611 uint8_t paramSelect; //!< Parameter selector.
612 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
613 //!< under a given Parameter selector value. 00h if
614 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600615} __attribute__((packed));
616
617/** @struct GetConfParamsResponse
618 *
619 * DCMI Get DCMI Configuration Parameters Command response.
620 * Refer DCMI specification Version 1.1 Section 6.1.3
621 */
622struct GetConfParamsResponse
623{
Patrick Venture0b02be92018-08-31 11:55:55 -0700624 uint8_t groupID; //!< Group extension identification.
625 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
626 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
627 uint8_t paramRevision; //!< Parameter Revision = 01h.
628 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600629
630} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600631
Tom Josephbe5eaa12017-07-12 19:54:44 +0530632} // namespace dcmi