blob: d4745deda15d3cf7f397e04a05b8457eab9aaf05 [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{
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060019 SET_CONF_PARAMS = 0x12,
20 GET_CONF_PARAMS = 0x13,
Ratan Gupta11ddbd22017-08-05 11:59:39 +053021};
22
Tom Josephbe5eaa12017-07-12 19:54:44 +053023static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
24static constexpr auto assetTagIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070025 "xyz.openbmc_project.Inventory.Decorator.AssetTag";
Tom Josephbe5eaa12017-07-12 19:54:44 +053026static constexpr auto assetTagProp = "AssetTag";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030027static constexpr auto networkServiceName = "xyz.openbmc_project.Network";
Patrick Venture0b02be92018-08-31 11:55:55 -070028static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030029static constexpr auto networkConfigIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070030 "xyz.openbmc_project.Network.SystemConfiguration";
Vladislav Vovchenko8f7a6f62017-08-17 00:31:14 +030031static constexpr auto hostNameProp = "HostName";
Deepak Kodihalliee717d72018-01-24 04:53:09 -060032static constexpr auto temperatureSensorType = 0x01;
Vernon Mauerycce9ffd2023-07-27 14:15:17 -070033static constexpr size_t maxInstances = 255;
34static constexpr uint8_t maxRecords = 8;
Kirill Pakhomova2573622018-11-02 19:00:18 +030035static constexpr auto gDCMISensorsConfig =
Deepak Kodihalli0b459552018-02-06 06:25:12 -060036 "/usr/share/ipmi-providers/dcmi_sensors.json";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060037static constexpr auto ethernetIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070038 "xyz.openbmc_project.Network.EthernetInterface";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060039static constexpr auto ethernetDefaultChannelNum = 0x1;
40static constexpr auto networkRoot = "/xyz/openbmc_project/network";
Jian Zhang958806d2022-12-13 13:37:09 +080041static constexpr auto dhcpObj = "/xyz/openbmc_project/network/dhcp";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060042static constexpr auto dhcpIntf =
Patrick Venture0b02be92018-08-31 11:55:55 -070043 "xyz.openbmc_project.Network.DHCPConfiguration";
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060044static constexpr auto systemBusName = "org.freedesktop.systemd1";
45static constexpr auto systemPath = "/org/freedesktop/systemd1";
46static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager";
Kirill Pakhomova2573622018-11-02 19:00:18 +030047static constexpr auto gDCMICapabilitiesConfig =
48 "/usr/share/ipmi-providers/dcmi_cap.json";
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +030049static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement";
50static constexpr auto gDCMIPowerMgmtSupported = 0x1;
Kirill Pakhomovdb5d9b02018-11-06 19:17:51 +030051static constexpr auto gMaxSELEntriesMask = 0xFFF;
52static constexpr auto gByteBitSize = 8;
Tom Josephbe5eaa12017-07-12 19:54:44 +053053
Tom Joseph6f6dd4d2017-07-12 20:07:11 +053054static constexpr auto groupExtId = 0xDC;
55
Kirill Pakhomov2c2af2c2018-11-06 16:06:10 +030056/** @brief Check whether DCMI power management is supported
57 * in the DCMI Capabilities config file.
58 *
59 * @return True if DCMI power management is supported
60 */
61bool isDCMIPowerMgmtSupported();
62
Kirill Pakhomova2573622018-11-02 19:00:18 +030063/** @brief Parse out JSON config file.
64 *
65 * @param[in] configFile - JSON config file name
Deepak Kodihalli0b459552018-02-06 06:25:12 -060066 *
67 * @return A json object
68 */
Kirill Pakhomova2573622018-11-02 19:00:18 +030069Json parseJSONConfig(const std::string& configFile);
Deepak Kodihalli0b459552018-02-06 06:25:12 -060070
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060071/**
72 * @brief Parameters for DCMI Configuration Parameters
73 */
Patrick Venture0b02be92018-08-31 11:55:55 -070074enum class DCMIConfigParameters : uint8_t
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060075{
76 ActivateDHCP = 1,
77 DiscoveryConfig,
78 DHCPTiming1,
79 DHCPTiming2,
80 DHCPTiming3,
81};
82
83/** @struct SetConfParamsRequest
84 *
85 * DCMI Set DCMI Configuration Parameters Command.
86 * Refer DCMI specification Version 1.1 Section 6.1.2
87 */
88struct SetConfParamsRequest
89{
Patrick Venture0b02be92018-08-31 11:55:55 -070090 uint8_t paramSelect; //!< Parameter selector.
91 uint8_t setSelect; //!< Set Selector (use 00h for parameters that only
92 //!< have one set).
93 uint8_t data[]; //!< Configuration parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060094} __attribute__((packed));
95
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -060096/** @struct GetConfParamsRequest
97 *
98 * DCMI Get DCMI Configuration Parameters Command.
99 * Refer DCMI specification Version 1.1 Section 6.1.3
100 */
101struct GetConfParamsRequest
102{
Patrick Venture0b02be92018-08-31 11:55:55 -0700103 uint8_t paramSelect; //!< Parameter selector.
104 uint8_t setSelect; //!< Set Selector. Selects a given set of parameters
105 //!< under a given Parameter selector value. 00h if
106 //!< parameter doesn't use a Set Selector.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600107} __attribute__((packed));
108
109/** @struct GetConfParamsResponse
110 *
111 * DCMI Get DCMI Configuration Parameters Command response.
112 * Refer DCMI specification Version 1.1 Section 6.1.3
113 */
114struct GetConfParamsResponse
115{
Patrick Venture0b02be92018-08-31 11:55:55 -0700116 uint8_t major; //!< DCMI Spec Conformance - major ver = 01h.
117 uint8_t minor; //!< DCMI Spec Conformance - minor ver = 05h.
118 uint8_t paramRevision; //!< Parameter Revision = 01h.
119 uint8_t data[]; //!< Parameter data.
Nagaraju Goruganti22be97b2018-02-07 01:19:59 -0600120} __attribute__((packed));
Deepak Kodihalli0b459552018-02-06 06:25:12 -0600121
Tom Josephbe5eaa12017-07-12 19:54:44 +0530122} // namespace dcmi