blob: 793a03c32b79d6f267f7165ed6f3494884d68a94 [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
Patrick Venture0b02be92018-08-31 11:55:55 -07005#include <sdbusplus/bus.hpp>
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -05006
7#include <map>
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;
Kirill Pakhomova2573622018-11-02 19:00:18 +030046static constexpr auto gDCMISensorsConfig =
Deepak Kodihalli0b459552018-02-06 06:25:12 -060047 "/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";
Jian Zhang958806d2022-12-13 13:37:09 +080052static constexpr auto dhcpObj = "/xyz/openbmc_project/network/dhcp";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060053static 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";
Kirill Pakhomova2573622018-11-02 19:00:18 +030058static constexpr auto gDCMICapabilitiesConfig =
59 "/usr/share/ipmi-providers/dcmi_cap.json";
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +030060static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement";
61static constexpr auto gDCMIPowerMgmtSupported = 0x1;
Kirill Pakhomovdb5d9b02018-11-06 19:17:51 +030062static constexpr auto gMaxSELEntriesMask = 0xFFF;
63static constexpr auto gByteBitSize = 8;
Tom Josephbe5eaa12017-07-12 19:54:44 +053064
65namespace assettag
66{
67
Patrick Venture0b02be92018-08-31 11:55:55 -070068using ObjectPath = std::string;
69using Service = std::string;
70using Interfaces = std::vector<std::string>;
71using ObjectTree = std::map<ObjectPath, std::map<Service, Interfaces>>;
Tom Josephbe5eaa12017-07-12 19:54:44 +053072
Patrick Venture0b02be92018-08-31 11:55:55 -070073} // namespace assettag
Tom Josephbe5eaa12017-07-12 19:54:44 +053074
Deepak Kodihalliee717d72018-01-24 04:53:09 -060075namespace temp_readings
76{
Patrick Venture0b02be92018-08-31 11:55:55 -070077static constexpr auto maxDataSets = 8;
78static constexpr auto maxTemp = 127; // degrees C
Deepak Kodihalliee717d72018-01-24 04:53:09 -060079
Patrick Venture0b02be92018-08-31 11:55:55 -070080/** @struct Response
81 *
82 * DCMI payload for Get Temperature Readings response
83 */
84struct Response
85{
Deepak Kodihalliee717d72018-01-24 04:53:09 -060086#if BYTE_ORDER == LITTLE_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070087 uint8_t temperature : 7; //!< Temperature reading in Celsius
88 uint8_t sign : 1; //!< Sign bit
Deepak Kodihalliee717d72018-01-24 04:53:09 -060089#endif
90#if BYTE_ORDER == BIG_ENDIAN
Patrick Venture0b02be92018-08-31 11:55:55 -070091 uint8_t sign : 1; //!< Sign bit
92 uint8_t temperature : 7; //!< Temperature reading in Celsius
Deepak Kodihalliee717d72018-01-24 04:53:09 -060093#endif
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050094 uint8_t instance; //!< Entity instance number
Patrick Venture0b02be92018-08-31 11:55:55 -070095} __attribute__((packed));
Deepak Kodihalliee717d72018-01-24 04:53:09 -060096
Patrick Venture0b02be92018-08-31 11:55:55 -070097using ResponseList = std::vector<Response>;
98using Value = uint8_t;
99using Sign = bool;
100using Temperature = std::tuple<Value, Sign>;
101} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600102
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600103namespace sensor_info
104{
Patrick Venture0b02be92018-08-31 11:55:55 -0700105static constexpr auto maxRecords = 8;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600106
Patrick Venture0b02be92018-08-31 11:55:55 -0700107/** @struct Response
108 *
109 * DCMI payload for Get Sensor Info response
110 */
111struct Response
112{
113 uint8_t recordIdLsb; //!< SDR record id LS byte
114 uint8_t recordIdMsb; //!< SDR record id MS byte
115} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600116
Patrick Venture0b02be92018-08-31 11:55:55 -0700117using ResponseList = std::vector<Response>;
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600118} // namespace sensor_info
119
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530120static constexpr auto groupExtId = 0xDC;
121
122static constexpr auto assetTagMaxOffset = 62;
123static constexpr auto assetTagMaxSize = 63;
124static constexpr auto maxBytes = 16;
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300125static constexpr size_t maxCtrlIdStrLen = 63;
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530126
127/** @struct GetAssetTagRequest
128 *
129 * DCMI payload for Get Asset Tag command request.
130 */
131struct GetAssetTagRequest
132{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700133 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 tagLength; //!< Total asset tag length.
Tom Joseph6f6dd4d2017-07-12 20:07:11 +0530144} __attribute__((packed));
145
Tom Joseph545dd232017-07-12 20:20:49 +0530146/** @struct SetAssetTagRequest
147 *
148 * DCMI payload for Set Asset Tag command request.
149 */
150struct SetAssetTagRequest
151{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700152 uint8_t offset; //!< Offset to write.
153 uint8_t bytes; //!< Number of bytes to write.
Tom Joseph545dd232017-07-12 20:20:49 +0530154} __attribute__((packed));
155
156/** @struct SetAssetTagResponse
157 *
158 * DCMI payload for Set Asset Tag command response.
159 */
160struct SetAssetTagResponse
161{
Patrick Venture0b02be92018-08-31 11:55:55 -0700162 uint8_t tagLength; //!< Total asset tag length.
Tom Joseph545dd232017-07-12 20:20:49 +0530163} __attribute__((packed));
164
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +0300165/** @brief Check whether DCMI power management is supported
166 * in the DCMI Capabilities config file.
167 *
168 * @return True if DCMI power management is supported
169 */
170bool isDCMIPowerMgmtSupported();
171
Tom Josephbe5eaa12017-07-12 19:54:44 +0530172/** @brief Read the object tree to fetch the object path that implemented the
173 * Asset tag interface.
174 *
175 * @param[in,out] objectTree - object tree
176 *
177 * @return On success return the object tree with the object path that
178 * implemented the AssetTag interface.
179 */
180void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
181
182/** @brief Read the asset tag of the server
183 *
184 * @return On success return the asset tag.
185 */
186std::string readAssetTag();
187
Tom Josephbe5b9892017-07-15 00:55:23 +0530188/** @brief Write the asset tag to the asset tag DBUS property
189 *
190 * @param[in] assetTag - Asset Tag to be written to the property.
191 */
192void writeAssetTag(const std::string& assetTag);
193
Tom Josephb9d86f42017-07-26 18:03:47 +0530194/** @brief Read the current power cap value
195 *
196 * @param[in] bus - dbus connection
197 *
198 * @return On success return the power cap value.
199 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500200uint32_t getPcap(sdbusplus::bus_t& bus);
Tom Josephb9d86f42017-07-26 18:03:47 +0530201
202/** @brief Check if the power capping is enabled
203 *
204 * @param[in] bus - dbus connection
205 *
206 * @return true if the powerCap is enabled and false if the powercap
207 * is disabled.
208 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500209bool getPcapEnabled(sdbusplus::bus_t& bus);
Tom Josephb9d86f42017-07-26 18:03:47 +0530210
Tom Josephb9d86f42017-07-26 18:03:47 +0530211/** @struct GetPowerLimitResponse
212 *
213 * DCMI payload for Get Power Limit command response.
214 */
215struct GetPowerLimitResponse
216{
Patrick Venture0b02be92018-08-31 11:55:55 -0700217 uint16_t reserved; //!< Reserved.
218 uint8_t exceptionAction; //!< Exception action.
219 uint16_t powerLimit; //!< Power limit requested in watts.
220 uint32_t correctionTime; //!< Correction time limit in milliseconds.
221 uint16_t reserved1; //!< Reserved.
222 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Josephb9d86f42017-07-26 18:03:47 +0530223} __attribute__((packed));
224
Tom Joseph46fa37d2017-07-26 18:11:55 +0530225/** @brief Set the power cap value
226 *
227 * @param[in] bus - dbus connection
228 * @param[in] powerCap - power cap value
229 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500230void setPcap(sdbusplus::bus_t& bus, const uint32_t powerCap);
Tom Joseph46fa37d2017-07-26 18:11:55 +0530231
232/** @struct SetPowerLimitRequest
233 *
234 * DCMI payload for Set Power Limit command request.
235 */
236struct SetPowerLimitRequest
237{
Patrick Venture0b02be92018-08-31 11:55:55 -0700238 uint16_t reserved; //!< Reserved
239 uint8_t reserved1; //!< Reserved
240 uint8_t exceptionAction; //!< Exception action.
241 uint16_t powerLimit; //!< Power limit requested in watts.
242 uint32_t correctionTime; //!< Correction time limit in milliseconds.
243 uint16_t reserved2; //!< Reserved.
244 uint16_t samplingPeriod; //!< Statistics sampling period in seconds.
Tom Joseph46fa37d2017-07-26 18:11:55 +0530245} __attribute__((packed));
246
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530247/** @brief Enable or disable the power capping
248 *
249 * @param[in] bus - dbus connection
250 * @param[in] enabled - enable/disable
251 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500252void setPcapEnable(sdbusplus::bus_t& bus, bool enabled);
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530253
254/** @struct ApplyPowerLimitRequest
255 *
256 * DCMI payload for Activate/Deactivate Power Limit command request.
257 */
258struct ApplyPowerLimitRequest
259{
Patrick Venture0b02be92018-08-31 11:55:55 -0700260 uint8_t powerLimitAction; //!< Power limit activation
261 uint16_t reserved; //!< Reserved
Tom Joseph6c8d51b2017-07-26 18:18:06 +0530262} __attribute__((packed));
263
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300264/** @struct GetMgmntCtrlIdStrRequest
265 *
266 * DCMI payload for Get Management Controller Identifier String cmd request.
267 */
268struct GetMgmntCtrlIdStrRequest
269{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700270 uint8_t offset; //!< Offset to read.
271 uint8_t bytes; //!< Number of bytes to read.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300272} __attribute__((packed));
273
274/** @struct GetMgmntCtrlIdStrResponse
275 *
276 * DCMI payload for Get Management Controller Identifier String cmd response.
277 */
278struct GetMgmntCtrlIdStrResponse
279{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700280 uint8_t strLen; //!< ID string length.
281 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300282} __attribute__((packed));
283
284/** @struct SetMgmntCtrlIdStrRequest
285 *
286 * DCMI payload for Set Management Controller Identifier String cmd request.
287 */
288struct SetMgmntCtrlIdStrRequest
289{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700290 uint8_t offset; //!< Offset to write.
291 uint8_t bytes; //!< Number of bytes to read.
292 char data[]; //!< ID string
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300293} __attribute__((packed));
294
295/** @struct GetMgmntCtrlIdStrResponse
296 *
297 * DCMI payload for Get Management Controller Identifier String cmd response.
298 */
299struct SetMgmntCtrlIdStrResponse
300{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700301 uint8_t offset; //!< Last Offset Written.
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +0300302} __attribute__((packed));
303
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600304/** @enum DCMICapParameters
305 *
306 * DCMI Capability parameters
307 */
308enum class DCMICapParameters
309{
310 SUPPORTED_DCMI_CAPS = 0x01, //!< Supported DCMI Capabilities
311 MANDATORY_PLAT_ATTRIBUTES = 0x02, //!< Mandatory Platform Attributes
312 OPTIONAL_PLAT_ATTRIBUTES = 0x03, //!< Optional Platform Attributes
313 MANAGEABILITY_ACCESS_ATTRIBUTES = 0x04, //!< Manageability Access Attributes
314};
315
316/** @struct GetDCMICapRequest
317 *
318 * DCMI payload for Get capabilities cmd request.
319 */
320struct GetDCMICapRequest
321{
William A. Kennington III5d06cc62019-04-25 02:10:55 -0700322 uint8_t param; //!< Capability parameter selector.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600323} __attribute__((packed));
324
325/** @struct GetDCMICapRequest
326 *
327 * DCMI payload for Get capabilities cmd response.
328 */
329struct GetDCMICapResponse
330{
Patrick Venture0b02be92018-08-31 11:55:55 -0700331 uint8_t major; //!< DCMI Specification Conformance - major ver
332 uint8_t minor; //!< DCMI Specification Conformance - minor ver
333 uint8_t paramRevision; //!< Parameter Revision = 02h
334 uint8_t data[]; //!< Capability array
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600335} __attribute__((packed));
336
337/** @struct DCMICap
338 *
339 * DCMI capabilities protocol info.
340 */
341struct DCMICap
342{
Patrick Venture0b02be92018-08-31 11:55:55 -0700343 std::string name; //!< Name of DCMI capability.
344 uint8_t bytePosition; //!< Starting byte number from DCMI spec.
345 uint8_t position; //!< bit position from the DCMI spec.
346 uint8_t length; //!< Length of the value from DCMI spec.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600347};
348
349using DCMICapList = std::vector<DCMICap>;
350
351/** @struct DCMICapEntry
352 *
353 * DCMI capabilities list and size for each parameter.
354 */
355struct DCMICapEntry
356{
Patrick Venture0b02be92018-08-31 11:55:55 -0700357 uint8_t size; //!< Size of capability array in bytes.
358 DCMICapList capList; //!< List of capabilities for a parameter.
Dhruvaraj Subhashchandrane29be412018-01-16 05:11:56 -0600359};
360
361using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
362
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600363/** @struct GetTempReadingsRequest
364 *
365 * DCMI payload for Get Temperature Readings request
366 */
367struct GetTempReadingsRequest
368{
Patrick Venture0b02be92018-08-31 11:55:55 -0700369 uint8_t sensorType; //!< Type of the sensor
370 uint8_t entityId; //!< Entity ID
371 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
372 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600373} __attribute__((packed));
374
375/** @struct GetTempReadingsResponse
376 *
377 * DCMI header for Get Temperature Readings response
378 */
379struct GetTempReadingsResponseHdr
380{
Patrick Venture0b02be92018-08-31 11:55:55 -0700381 uint8_t numInstances; //!< No. of instances for requested id
382 uint8_t numDataSets; //!< No. of sets of temperature data
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600383} __attribute__((packed));
384
Kirill Pakhomova2573622018-11-02 19:00:18 +0300385/** @brief Parse out JSON config file.
386 *
387 * @param[in] configFile - JSON config file name
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600388 *
389 * @return A json object
390 */
Kirill Pakhomova2573622018-11-02 19:00:18 +0300391Json parseJSONConfig(const std::string& configFile);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600392
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600393namespace temp_readings
394{
Patrick Venture0b02be92018-08-31 11:55:55 -0700395/** @brief Read temperature from a d-bus object, scale it as per dcmi
396 * get temperature reading requirements.
397 *
398 * @param[in] dbusService - the D-Bus service
399 * @param[in] dbusPath - the D-Bus path
400 *
401 * @return A temperature reading
402 */
403Temperature readTemp(const std::string& dbusService,
404 const std::string& dbusPath);
Deepak Kodihallib1e8fba2018-01-24 04:57:10 -0600405
Patrick Venture0b02be92018-08-31 11:55:55 -0700406/** @brief Read temperatures and fill up DCMI response for the Get
407 * Temperature Readings command. This looks at a specific
408 * instance.
409 *
410 * @param[in] type - one of "inlet", "cpu", "baseboard"
411 * @param[in] instance - A non-zero Entity instance number
412 *
413 * @return A tuple, containing a temperature reading and the
414 * number of instances.
415 */
416std::tuple<Response, NumInstances> read(const std::string& type,
417 uint8_t instance);
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600418
Patrick Venture0b02be92018-08-31 11:55:55 -0700419/** @brief Read temperatures and fill up DCMI response for the Get
420 * Temperature Readings command. This looks at a range of
421 * instances.
422 *
423 * @param[in] type - one of "inlet", "cpu", "baseboard"
424 * @param[in] instanceStart - Entity instance start index
425 *
426 * @return A tuple, containing a list of temperature readings and the
427 * number of instances.
428 */
429std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
430 uint8_t instanceStart);
431} // namespace temp_readings
Deepak Kodihalliee717d72018-01-24 04:53:09 -0600432
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600433namespace sensor_info
434{
Patrick Venture0b02be92018-08-31 11:55:55 -0700435/** @brief Create response from JSON config.
436 *
437 * @param[in] config - JSON config info about DCMI sensors
438 *
439 * @return Sensor info response
440 */
441Response createFromJson(const Json& config);
Deepak Kodihallidd4cff12018-02-06 06:48:29 -0600442
Patrick Venture0b02be92018-08-31 11:55:55 -0700443/** @brief Read sensor info and fill up DCMI response for the Get
444 * Sensor Info command. This looks at a specific
445 * instance.
446 *
447 * @param[in] type - one of "inlet", "cpu", "baseboard"
448 * @param[in] instance - A non-zero Entity instance number
449 * @param[in] config - JSON config info about DCMI sensors
450 *
451 * @return A tuple, containing a sensor info response and
452 * number of instances.
453 */
454std::tuple<Response, NumInstances> read(const std::string& type,
455 uint8_t instance, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600456
Patrick Venture0b02be92018-08-31 11:55:55 -0700457/** @brief Read sensor info and fill up DCMI response for the Get
458 * Sensor Info command. This looks at a range of
459 * instances.
460 *
461 * @param[in] type - one of "inlet", "cpu", "baseboard"
462 * @param[in] instanceStart - Entity instance start index
463 * @param[in] config - JSON config info about DCMI sensors
464 *
465 * @return A tuple, containing a list of sensor info responses and the
466 * number of instances.
467 */
468std::tuple<ResponseList, NumInstances>
469 readAll(const std::string& type, uint8_t instanceStart, const Json& config);
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600470} // namespace sensor_info
471
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600472/** @brief Read power reading from power reading sensor object
473 *
474 * @param[in] bus - dbus connection
475 *
476 * @return total power reading
477 */
Patrick Williams5d82f472022-07-22 19:26:53 -0500478int64_t getPowerReading(sdbusplus::bus_t& bus);
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600479
480/** @struct GetPowerReadingRequest
481 *
482 * DCMI Get Power Reading command request.
483 * Refer DCMI specification Version 1.1 Section 6.6.1
484 */
485struct GetPowerReadingRequest
486{
Patrick Venture0b02be92018-08-31 11:55:55 -0700487 uint8_t mode; //!< Mode
488 uint8_t modeAttribute; //!< Mode Attributes
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600489} __attribute__((packed));
490
491/** @struct GetPowerReadingResponse
492 *
493 * DCMI Get Power Reading command response.
494 * Refer DCMI specification Version 1.1 Section 6.6.1
495 */
496struct GetPowerReadingResponse
497{
Patrick Venture0b02be92018-08-31 11:55:55 -0700498 uint16_t currentPower; //!< Current power in watts
499 uint16_t minimumPower; //!< Minimum power over sampling duration
500 //!< in watts
501 uint16_t maximumPower; //!< Maximum power over sampling duration
502 //!< in watts
503 uint16_t averagePower; //!< Average power over sampling duration
504 //!< in watts
505 uint32_t timeStamp; //!< IPMI specification based time stamp
506 uint32_t timeFrame; //!< Statistics reporting time period in milli
507 //!< seconds.
508 uint8_t powerReadingState; //!< Power Reading State
Marri Devender Rao66c5fda2018-01-18 10:48:37 -0600509} __attribute__((packed));
510
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600511/** @struct GetSensorInfoRequest
512 *
513 * DCMI payload for Get Sensor Info request
514 */
515struct GetSensorInfoRequest
516{
Patrick Venture0b02be92018-08-31 11:55:55 -0700517 uint8_t sensorType; //!< Type of the sensor
518 uint8_t entityId; //!< Entity ID
519 uint8_t entityInstance; //!< Entity Instance (0 means all instances)
520 uint8_t instanceStart; //!< Instance start (used if instance is 0)
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600521} __attribute__((packed));
522
523/** @struct GetSensorInfoResponseHdr
524 *
525 * DCMI header for Get Sensor Info response
526 */
527struct GetSensorInfoResponseHdr
528{
Patrick Venture0b02be92018-08-31 11:55:55 -0700529 uint8_t numInstances; //!< No. of instances for requested id
530 uint8_t numRecords; //!< No. of record ids in the response
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600531} __attribute__((packed));
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600532/**
533 * @brief Parameters for DCMI Configuration Parameters
534 */
Patrick Venture0b02be92018-08-31 11:55:55 -0700535enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600536{
537 ActivateDHCP = 1,
538 DiscoveryConfig,
539 DHCPTiming1,
540 DHCPTiming2,
541 DHCPTiming3,
542};
543
544/** @struct SetConfParamsRequest
545 *
546 * DCMI Set DCMI Configuration Parameters Command.
547 * Refer DCMI specification Version 1.1 Section 6.1.2
548 */
549struct SetConfParamsRequest
550{
Patrick Venture0b02be92018-08-31 11:55:55 -0700551 uint8_t paramSelect; //!< Parameter selector.
552 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
553 //!< have one set).
554 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600555} __attribute__((packed));
556
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600557/** @struct GetConfParamsRequest
558 *
559 * DCMI Get DCMI Configuration Parameters Command.
560 * Refer DCMI specification Version 1.1 Section 6.1.3
561 */
562struct GetConfParamsRequest
563{
Patrick Venture0b02be92018-08-31 11:55:55 -0700564 uint8_t paramSelect; //!< Parameter selector.
565 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
566 //!< under a given Parameter selector value. 00h if
567 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600568} __attribute__((packed));
569
570/** @struct GetConfParamsResponse
571 *
572 * DCMI Get DCMI Configuration Parameters Command response.
573 * Refer DCMI specification Version 1.1 Section 6.1.3
574 */
575struct GetConfParamsResponse
576{
Patrick Venture0b02be92018-08-31 11:55:55 -0700577 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
578 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
579 uint8_t paramRevision; //!< Parameter Revision = 01h.
580 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600581} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600582
Tom Josephbe5eaa12017-07-12 19:54:44 +0530583} // namespace dcmi