Patrick Venture | 46470a3 | 2018-09-07 19:26:25 -0700 | [diff] [blame] | 1 | #pragma once |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include "nlohmann/json.hpp" |
| 4 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 5 | #include <sdbusplus/bus.hpp> |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 6 | |
| 7 | #include <map> |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 11 | namespace dcmi |
| 12 | { |
| 13 | |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 14 | using NumInstances = size_t; |
| 15 | using Json = nlohmann::json; |
| 16 | |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 17 | enum Commands |
| 18 | { |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 19 | SET_CONF_PARAMS = 0x12, |
| 20 | GET_CONF_PARAMS = 0x13, |
Ratan Gupta | 11ddbd2 | 2017-08-05 11:59:39 +0530 | [diff] [blame] | 21 | }; |
| 22 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 23 | static constexpr auto propIntf = "org.freedesktop.DBus.Properties"; |
| 24 | static constexpr auto assetTagIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 25 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 26 | static constexpr auto assetTagProp = "AssetTag"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 27 | static constexpr auto networkServiceName = "xyz.openbmc_project.Network"; |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 28 | static constexpr auto networkConfigObj = "/xyz/openbmc_project/network/config"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 29 | static constexpr auto networkConfigIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 30 | "xyz.openbmc_project.Network.SystemConfiguration"; |
Vladislav Vovchenko | 8f7a6f6 | 2017-08-17 00:31:14 +0300 | [diff] [blame] | 31 | static constexpr auto hostNameProp = "HostName"; |
Deepak Kodihalli | ee717d7 | 2018-01-24 04:53:09 -0600 | [diff] [blame] | 32 | static constexpr auto temperatureSensorType = 0x01; |
Vernon Mauery | cce9ffd | 2023-07-27 14:15:17 -0700 | [diff] [blame] | 33 | static constexpr size_t maxInstances = 255; |
| 34 | static constexpr uint8_t maxRecords = 8; |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 35 | static constexpr auto gDCMISensorsConfig = |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 36 | "/usr/share/ipmi-providers/dcmi_sensors.json"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 37 | static constexpr auto ethernetIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 38 | "xyz.openbmc_project.Network.EthernetInterface"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 39 | static constexpr auto ethernetDefaultChannelNum = 0x1; |
| 40 | static constexpr auto networkRoot = "/xyz/openbmc_project/network"; |
Jian Zhang | 958806d | 2022-12-13 13:37:09 +0800 | [diff] [blame] | 41 | static constexpr auto dhcpObj = "/xyz/openbmc_project/network/dhcp"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 42 | static constexpr auto dhcpIntf = |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 43 | "xyz.openbmc_project.Network.DHCPConfiguration"; |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 44 | static constexpr auto systemBusName = "org.freedesktop.systemd1"; |
| 45 | static constexpr auto systemPath = "/org/freedesktop/systemd1"; |
| 46 | static constexpr auto systemIntf = "org.freedesktop.systemd1.Manager"; |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 47 | static constexpr auto gDCMICapabilitiesConfig = |
| 48 | "/usr/share/ipmi-providers/dcmi_cap.json"; |
Kirill Pakhomov | 2c2af2c | 2018-11-06 16:06:10 +0300 | [diff] [blame] | 49 | static constexpr auto gDCMIPowerMgmtCapability = "PowerManagement"; |
| 50 | static constexpr auto gDCMIPowerMgmtSupported = 0x1; |
Kirill Pakhomov | db5d9b0 | 2018-11-06 19:17:51 +0300 | [diff] [blame] | 51 | static constexpr auto gMaxSELEntriesMask = 0xFFF; |
| 52 | static constexpr auto gByteBitSize = 8; |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 53 | |
Tom Joseph | 6f6dd4d | 2017-07-12 20:07:11 +0530 | [diff] [blame] | 54 | static constexpr auto groupExtId = 0xDC; |
| 55 | |
Kirill Pakhomov | 2c2af2c | 2018-11-06 16:06:10 +0300 | [diff] [blame] | 56 | /** @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 | */ |
| 61 | bool isDCMIPowerMgmtSupported(); |
| 62 | |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 63 | /** @brief Parse out JSON config file. |
| 64 | * |
| 65 | * @param[in] configFile - JSON config file name |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 66 | * |
| 67 | * @return A json object |
| 68 | */ |
Kirill Pakhomov | a257362 | 2018-11-02 19:00:18 +0300 | [diff] [blame] | 69 | Json parseJSONConfig(const std::string& configFile); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 70 | |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 71 | /** |
| 72 | * @brief Parameters for DCMI Configuration Parameters |
| 73 | */ |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 74 | enum class DCMIConfigParameters : uint8_t |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 75 | { |
| 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 | */ |
| 88 | struct SetConfParamsRequest |
| 89 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 90 | 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 Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 94 | } __attribute__((packed)); |
| 95 | |
Nagaraju Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 96 | /** @struct GetConfParamsRequest |
| 97 | * |
| 98 | * DCMI Get DCMI Configuration Parameters Command. |
| 99 | * Refer DCMI specification Version 1.1 Section 6.1.3 |
| 100 | */ |
| 101 | struct GetConfParamsRequest |
| 102 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 103 | 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 Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 107 | } __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 | */ |
| 114 | struct GetConfParamsResponse |
| 115 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 116 | 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 Goruganti | 22be97b | 2018-02-07 01:19:59 -0600 | [diff] [blame] | 120 | } __attribute__((packed)); |
Deepak Kodihalli | 0b45955 | 2018-02-06 06:25:12 -0600 | [diff] [blame] | 121 | |
Tom Joseph | be5eaa1 | 2017-07-12 19:54:44 +0530 | [diff] [blame] | 122 | } // namespace dcmi |