Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 18 | #include "dbus_singleton.hpp" |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 19 | #include "dbus_utility.hpp" |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 20 | #include "error_messages.hpp" |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 21 | #include "health.hpp" |
| 22 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 23 | #include <app.hpp> |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 24 | #include <boost/container/flat_map.hpp> |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 25 | #include <query.hpp> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 26 | #include <registries/privilege_registry.hpp> |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 27 | #include <sdbusplus/asio/property.hpp> |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 28 | #include <sdbusplus/message/native_types.hpp> |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 29 | #include <sdbusplus/unpack_properties.hpp> |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 30 | #include <sdbusplus/utility/dedup_variant.hpp> |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 31 | #include <utils/collection.hpp> |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 32 | #include <utils/dbus_utils.hpp> |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 33 | #include <utils/json_utils.hpp> |
| 34 | |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 35 | #include <array> |
| 36 | #include <string_view> |
| 37 | |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 38 | namespace redfish |
| 39 | { |
| 40 | |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 41 | // Interfaces which imply a D-Bus object represents a Processor |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 42 | constexpr std::array<std::string_view, 2> processorInterfaces = { |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 43 | "xyz.openbmc_project.Inventory.Item.Cpu", |
| 44 | "xyz.openbmc_project.Inventory.Item.Accelerator"}; |
Jonathan Doman | 2bab983 | 2020-12-02 15:27:40 -0800 | [diff] [blame] | 45 | |
Sharad Yadav | 71b82f2 | 2021-05-10 15:11:39 +0530 | [diff] [blame] | 46 | /** |
| 47 | * @brief Fill out uuid info of a processor by |
| 48 | * requesting data from the given D-Bus object. |
| 49 | * |
| 50 | * @param[in,out] aResp Async HTTP response. |
| 51 | * @param[in] service D-Bus service to query. |
| 52 | * @param[in] objPath D-Bus object to query. |
| 53 | */ |
| 54 | inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> aResp, |
| 55 | const std::string& service, |
| 56 | const std::string& objPath) |
| 57 | { |
| 58 | BMCWEB_LOG_DEBUG << "Get Processor UUID"; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 59 | sdbusplus::asio::getProperty<std::string>( |
| 60 | *crow::connections::systemBus, service, objPath, |
| 61 | "xyz.openbmc_project.Common.UUID", "UUID", |
| 62 | [objPath, aResp{std::move(aResp)}](const boost::system::error_code ec, |
| 63 | const std::string& property) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 64 | if (ec) |
| 65 | { |
| 66 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 67 | messages::internalError(aResp->res); |
| 68 | return; |
| 69 | } |
| 70 | aResp->res.jsonValue["UUID"] = property; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 71 | }); |
Sharad Yadav | 71b82f2 | 2021-05-10 15:11:39 +0530 | [diff] [blame] | 72 | } |
| 73 | |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 74 | inline void getCpuDataByInterface( |
| 75 | const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 76 | const dbus::utility::DBusInteracesMap& cpuInterfacesProperties) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 77 | { |
| 78 | BMCWEB_LOG_DEBUG << "Get CPU resources by interface."; |
| 79 | |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 80 | // Set the default value of state |
| 81 | aResp->res.jsonValue["Status"]["State"] = "Enabled"; |
| 82 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 83 | |
| 84 | for (const auto& interface : cpuInterfacesProperties) |
| 85 | { |
| 86 | for (const auto& property : interface.second) |
| 87 | { |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 88 | if (property.first == "Present") |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 89 | { |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 90 | const bool* cpuPresent = std::get_if<bool>(&property.second); |
| 91 | if (cpuPresent == nullptr) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 92 | { |
| 93 | // Important property not in desired type |
| 94 | messages::internalError(aResp->res); |
| 95 | return; |
| 96 | } |
Ed Tanous | e05aec5 | 2022-01-25 10:28:56 -0800 | [diff] [blame] | 97 | if (!*cpuPresent) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 98 | { |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 99 | // Slot is not populated |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 100 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | else if (property.first == "Functional") |
| 104 | { |
| 105 | const bool* cpuFunctional = std::get_if<bool>(&property.second); |
| 106 | if (cpuFunctional == nullptr) |
| 107 | { |
| 108 | messages::internalError(aResp->res); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 109 | return; |
| 110 | } |
Ed Tanous | e05aec5 | 2022-01-25 10:28:56 -0800 | [diff] [blame] | 111 | if (!*cpuFunctional) |
Chicago Duan | a1649ec | 2021-03-30 16:54:58 +0800 | [diff] [blame] | 112 | { |
| 113 | aResp->res.jsonValue["Status"]["Health"] = "Critical"; |
| 114 | } |
| 115 | } |
| 116 | else if (property.first == "CoreCount") |
| 117 | { |
| 118 | const uint16_t* coresCount = |
| 119 | std::get_if<uint16_t>(&property.second); |
| 120 | if (coresCount == nullptr) |
| 121 | { |
| 122 | messages::internalError(aResp->res); |
| 123 | return; |
| 124 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 125 | aResp->res.jsonValue["TotalCores"] = *coresCount; |
| 126 | } |
Jonathan Doman | dc3fa66 | 2020-10-26 23:10:24 -0700 | [diff] [blame] | 127 | else if (property.first == "MaxSpeedInMhz") |
| 128 | { |
| 129 | const uint32_t* value = std::get_if<uint32_t>(&property.second); |
| 130 | if (value != nullptr) |
| 131 | { |
| 132 | aResp->res.jsonValue["MaxSpeedMHz"] = *value; |
| 133 | } |
| 134 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 135 | else if (property.first == "Socket") |
| 136 | { |
| 137 | const std::string* value = |
| 138 | std::get_if<std::string>(&property.second); |
| 139 | if (value != nullptr) |
| 140 | { |
| 141 | aResp->res.jsonValue["Socket"] = *value; |
| 142 | } |
| 143 | } |
| 144 | else if (property.first == "ThreadCount") |
| 145 | { |
Jonathan Doman | dc3fa66 | 2020-10-26 23:10:24 -0700 | [diff] [blame] | 146 | const uint16_t* value = std::get_if<uint16_t>(&property.second); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 147 | if (value != nullptr) |
| 148 | { |
| 149 | aResp->res.jsonValue["TotalThreads"] = *value; |
| 150 | } |
| 151 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 152 | else if (property.first == "EffectiveFamily") |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 153 | { |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 154 | const uint16_t* value = std::get_if<uint16_t>(&property.second); |
Brad Bishop | 6169de2 | 2022-09-14 13:08:32 -0400 | [diff] [blame] | 155 | if (value != nullptr && *value != 2) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 156 | { |
| 157 | aResp->res.jsonValue["ProcessorId"]["EffectiveFamily"] = |
Ed Tanous | 866e486 | 2022-02-17 11:40:25 -0800 | [diff] [blame] | 158 | "0x" + intToHexString(*value, 4); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 159 | } |
| 160 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 161 | else if (property.first == "EffectiveModel") |
| 162 | { |
| 163 | const uint16_t* value = std::get_if<uint16_t>(&property.second); |
| 164 | if (value == nullptr) |
| 165 | { |
| 166 | messages::internalError(aResp->res); |
| 167 | return; |
| 168 | } |
Brad Bishop | 6169de2 | 2022-09-14 13:08:32 -0400 | [diff] [blame] | 169 | if (*value != 0) |
| 170 | { |
| 171 | aResp->res.jsonValue["ProcessorId"]["EffectiveModel"] = |
| 172 | "0x" + intToHexString(*value, 4); |
| 173 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 174 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 175 | else if (property.first == "Id") |
| 176 | { |
| 177 | const uint64_t* value = std::get_if<uint64_t>(&property.second); |
| 178 | if (value != nullptr && *value != 0) |
| 179 | { |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 180 | aResp->res |
| 181 | .jsonValue["ProcessorId"]["IdentificationRegisters"] = |
Ed Tanous | 866e486 | 2022-02-17 11:40:25 -0800 | [diff] [blame] | 182 | "0x" + intToHexString(*value, 16); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 183 | } |
| 184 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 185 | else if (property.first == "Microcode") |
| 186 | { |
| 187 | const uint32_t* value = std::get_if<uint32_t>(&property.second); |
| 188 | if (value == nullptr) |
| 189 | { |
| 190 | messages::internalError(aResp->res); |
| 191 | return; |
| 192 | } |
Brad Bishop | 6169de2 | 2022-09-14 13:08:32 -0400 | [diff] [blame] | 193 | if (*value != 0) |
| 194 | { |
| 195 | aResp->res.jsonValue["ProcessorId"]["MicrocodeInfo"] = |
| 196 | "0x" + intToHexString(*value, 8); |
| 197 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 198 | } |
| 199 | else if (property.first == "Step") |
| 200 | { |
| 201 | const uint16_t* value = std::get_if<uint16_t>(&property.second); |
| 202 | if (value == nullptr) |
| 203 | { |
| 204 | messages::internalError(aResp->res); |
| 205 | return; |
| 206 | } |
Brad Bishop | 6169de2 | 2022-09-14 13:08:32 -0400 | [diff] [blame] | 207 | if (*value != 0) |
| 208 | { |
| 209 | aResp->res.jsonValue["ProcessorId"]["Step"] = |
| 210 | "0x" + intToHexString(*value, 4); |
| 211 | } |
Brandon Kim | 1930fbd | 2021-09-14 17:52:51 -0700 | [diff] [blame] | 212 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 213 | } |
| 214 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 215 | } |
| 216 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 217 | inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> aResp, |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 218 | const std::string& cpuId, |
| 219 | const std::string& service, |
| 220 | const std::string& objPath) |
| 221 | { |
| 222 | BMCWEB_LOG_DEBUG << "Get available system cpu resources by service."; |
| 223 | |
| 224 | crow::connections::systemBus->async_method_call( |
| 225 | [cpuId, service, objPath, aResp{std::move(aResp)}]( |
| 226 | const boost::system::error_code ec, |
| 227 | const dbus::utility::ManagedObjectType& dbusData) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 228 | if (ec) |
| 229 | { |
| 230 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 231 | messages::internalError(aResp->res); |
| 232 | return; |
| 233 | } |
| 234 | aResp->res.jsonValue["Id"] = cpuId; |
| 235 | aResp->res.jsonValue["Name"] = "Processor"; |
| 236 | aResp->res.jsonValue["ProcessorType"] = "CPU"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 237 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 238 | bool slotPresent = false; |
| 239 | std::string corePath = objPath + "/core"; |
| 240 | size_t totalCores = 0; |
| 241 | for (const auto& object : dbusData) |
| 242 | { |
| 243 | if (object.first.str == objPath) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 244 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 245 | getCpuDataByInterface(aResp, object.second); |
| 246 | } |
Ed Tanous | 11ba397 | 2022-07-11 09:50:41 -0700 | [diff] [blame] | 247 | else if (object.first.str.starts_with(corePath)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 248 | { |
| 249 | for (const auto& interface : object.second) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 250 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 251 | if (interface.first == "xyz.openbmc_project.Inventory.Item") |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 252 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 253 | for (const auto& property : interface.second) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 254 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 255 | if (property.first == "Present") |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 256 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 257 | const bool* present = |
| 258 | std::get_if<bool>(&property.second); |
| 259 | if (present != nullptr) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 260 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 261 | if (*present) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 262 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 263 | slotPresent = true; |
| 264 | totalCores++; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 272 | } |
| 273 | // In getCpuDataByInterface(), state and health are set |
| 274 | // based on the present and functional status. If core |
| 275 | // count is zero, then it has a higher precedence. |
| 276 | if (slotPresent) |
| 277 | { |
| 278 | if (totalCores == 0) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 279 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 280 | // Slot is not populated, set status end return |
| 281 | aResp->res.jsonValue["Status"]["State"] = "Absent"; |
| 282 | aResp->res.jsonValue["Status"]["Health"] = "OK"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 283 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 284 | aResp->res.jsonValue["TotalCores"] = totalCores; |
| 285 | } |
| 286 | return; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 287 | }, |
| 288 | service, "/xyz/openbmc_project/inventory", |
| 289 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 290 | } |
| 291 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 292 | inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> aResp, |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 293 | const std::string& service, |
| 294 | const std::string& objPath) |
| 295 | { |
| 296 | BMCWEB_LOG_DEBUG << "Get Cpu Asset Data"; |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 297 | sdbusplus::asio::getAllProperties( |
| 298 | *crow::connections::systemBus, service, objPath, |
| 299 | "xyz.openbmc_project.Inventory.Decorator.Asset", |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 300 | [objPath, aResp{std::move(aResp)}]( |
| 301 | const boost::system::error_code ec, |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 302 | const dbus::utility::DBusPropertiesMap& properties) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 303 | if (ec) |
| 304 | { |
| 305 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 306 | messages::internalError(aResp->res); |
| 307 | return; |
| 308 | } |
| 309 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 310 | const std::string* serialNumber = nullptr; |
| 311 | const std::string* model = nullptr; |
| 312 | const std::string* manufacturer = nullptr; |
| 313 | const std::string* partNumber = nullptr; |
| 314 | const std::string* sparePartNumber = nullptr; |
| 315 | |
| 316 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 317 | dbus_utils::UnpackErrorPrinter(), properties, "SerialNumber", |
| 318 | serialNumber, "Model", model, "Manufacturer", manufacturer, |
| 319 | "PartNumber", partNumber, "SparePartNumber", sparePartNumber); |
| 320 | |
| 321 | if (!success) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 322 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 323 | messages::internalError(aResp->res); |
| 324 | return; |
| 325 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 326 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 327 | if (serialNumber != nullptr && !serialNumber->empty()) |
| 328 | { |
| 329 | aResp->res.jsonValue["SerialNumber"] = *serialNumber; |
| 330 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 331 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 332 | if ((model != nullptr) && !model->empty()) |
| 333 | { |
| 334 | aResp->res.jsonValue["Model"] = *model; |
| 335 | } |
| 336 | |
| 337 | if (manufacturer != nullptr) |
| 338 | { |
| 339 | aResp->res.jsonValue["Manufacturer"] = *manufacturer; |
| 340 | |
| 341 | // Otherwise would be unexpected. |
| 342 | if (manufacturer->find("Intel") != std::string::npos) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 343 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 344 | aResp->res.jsonValue["ProcessorArchitecture"] = "x86"; |
| 345 | aResp->res.jsonValue["InstructionSet"] = "x86-64"; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 346 | } |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 347 | else if (manufacturer->find("IBM") != std::string::npos) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 348 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 349 | aResp->res.jsonValue["ProcessorArchitecture"] = "Power"; |
| 350 | aResp->res.jsonValue["InstructionSet"] = "PowerISA"; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 351 | } |
| 352 | } |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 353 | |
| 354 | if (partNumber != nullptr) |
| 355 | { |
| 356 | aResp->res.jsonValue["PartNumber"] = *partNumber; |
| 357 | } |
| 358 | |
Brad Bishop | 6169de2 | 2022-09-14 13:08:32 -0400 | [diff] [blame] | 359 | if (sparePartNumber != nullptr && !sparePartNumber->empty()) |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 360 | { |
| 361 | aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber; |
| 362 | } |
| 363 | }); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 364 | } |
| 365 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 366 | inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> aResp, |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 367 | const std::string& service, |
| 368 | const std::string& objPath) |
| 369 | { |
| 370 | BMCWEB_LOG_DEBUG << "Get Cpu Revision Data"; |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 371 | sdbusplus::asio::getAllProperties( |
| 372 | *crow::connections::systemBus, service, objPath, |
| 373 | "xyz.openbmc_project.Inventory.Decorator.Revision", |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 374 | [objPath, aResp{std::move(aResp)}]( |
| 375 | const boost::system::error_code ec, |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 376 | const dbus::utility::DBusPropertiesMap& properties) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 377 | if (ec) |
| 378 | { |
| 379 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 380 | messages::internalError(aResp->res); |
| 381 | return; |
| 382 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 383 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 384 | const std::string* version = nullptr; |
| 385 | |
| 386 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 387 | dbus_utils::UnpackErrorPrinter(), properties, "Version", version); |
| 388 | |
| 389 | if (!success) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 390 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 391 | messages::internalError(aResp->res); |
| 392 | return; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 393 | } |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 394 | |
| 395 | if (version != nullptr) |
| 396 | { |
| 397 | aResp->res.jsonValue["Version"] = *version; |
| 398 | } |
| 399 | }); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 400 | } |
| 401 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 402 | inline void getAcceleratorDataByService( |
| 403 | std::shared_ptr<bmcweb::AsyncResp> aResp, const std::string& acclrtrId, |
| 404 | const std::string& service, const std::string& objPath) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 405 | { |
| 406 | BMCWEB_LOG_DEBUG |
| 407 | << "Get available system Accelerator resources by service."; |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 408 | sdbusplus::asio::getAllProperties( |
| 409 | *crow::connections::systemBus, service, objPath, "", |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 410 | [acclrtrId, aResp{std::move(aResp)}]( |
| 411 | const boost::system::error_code ec, |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 412 | const dbus::utility::DBusPropertiesMap& properties) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 413 | if (ec) |
| 414 | { |
| 415 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 416 | messages::internalError(aResp->res); |
| 417 | return; |
| 418 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 419 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 420 | const bool* functional = nullptr; |
| 421 | const bool* present = nullptr; |
| 422 | |
| 423 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 424 | dbus_utils::UnpackErrorPrinter(), properties, "Functional", |
| 425 | functional, "Present", present); |
| 426 | |
| 427 | if (!success) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 428 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 429 | messages::internalError(aResp->res); |
| 430 | return; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 431 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 432 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 433 | std::string state = "Enabled"; |
| 434 | std::string health = "OK"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 435 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 436 | if (present != nullptr && !*present) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 437 | { |
| 438 | state = "Absent"; |
| 439 | } |
| 440 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 441 | if (functional != nullptr && !*functional) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 442 | { |
| 443 | if (state == "Enabled") |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 444 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 445 | health = "Critical"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 446 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 447 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 448 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 449 | aResp->res.jsonValue["Id"] = acclrtrId; |
| 450 | aResp->res.jsonValue["Name"] = "Processor"; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 451 | aResp->res.jsonValue["Status"]["State"] = state; |
| 452 | aResp->res.jsonValue["Status"]["Health"] = health; |
| 453 | aResp->res.jsonValue["ProcessorType"] = "Accelerator"; |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 454 | }); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 455 | } |
| 456 | |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 457 | // OperatingConfig D-Bus Types |
| 458 | using TurboProfileProperty = std::vector<std::tuple<uint32_t, size_t>>; |
| 459 | using BaseSpeedPrioritySettingsProperty = |
| 460 | std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>; |
| 461 | // uint32_t and size_t may or may not be the same type, requiring a dedup'd |
| 462 | // variant |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * Fill out the HighSpeedCoreIDs in a Processor resource from the given |
| 466 | * OperatingConfig D-Bus property. |
| 467 | * |
| 468 | * @param[in,out] aResp Async HTTP response. |
| 469 | * @param[in] baseSpeedSettings Full list of base speed priority groups, |
| 470 | * to use to determine the list of high |
| 471 | * speed cores. |
| 472 | */ |
| 473 | inline void highSpeedCoreIdsHandler( |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 474 | const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 475 | const BaseSpeedPrioritySettingsProperty& baseSpeedSettings) |
| 476 | { |
| 477 | // The D-Bus property does not indicate which bucket is the "high |
| 478 | // priority" group, so let's discern that by looking for the one with |
| 479 | // highest base frequency. |
| 480 | auto highPriorityGroup = baseSpeedSettings.cend(); |
| 481 | uint32_t highestBaseSpeed = 0; |
| 482 | for (auto it = baseSpeedSettings.cbegin(); it != baseSpeedSettings.cend(); |
| 483 | ++it) |
| 484 | { |
| 485 | const uint32_t baseFreq = std::get<uint32_t>(*it); |
| 486 | if (baseFreq > highestBaseSpeed) |
| 487 | { |
| 488 | highestBaseSpeed = baseFreq; |
| 489 | highPriorityGroup = it; |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | nlohmann::json& jsonCoreIds = aResp->res.jsonValue["HighSpeedCoreIDs"]; |
| 494 | jsonCoreIds = nlohmann::json::array(); |
| 495 | |
| 496 | // There may not be any entries in the D-Bus property, so only populate |
| 497 | // if there was actually something there. |
| 498 | if (highPriorityGroup != baseSpeedSettings.cend()) |
| 499 | { |
| 500 | jsonCoreIds = std::get<std::vector<uint32_t>>(*highPriorityGroup); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * Fill out OperatingConfig related items in a Processor resource by requesting |
| 506 | * data from the given D-Bus object. |
| 507 | * |
| 508 | * @param[in,out] aResp Async HTTP response. |
| 509 | * @param[in] cpuId CPU D-Bus name. |
| 510 | * @param[in] service D-Bus service to query. |
| 511 | * @param[in] objPath D-Bus object to query. |
| 512 | */ |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 513 | inline void getCpuConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 514 | const std::string& cpuId, |
| 515 | const std::string& service, |
| 516 | const std::string& objPath) |
| 517 | { |
| 518 | BMCWEB_LOG_INFO << "Getting CPU operating configs for " << cpuId; |
| 519 | |
| 520 | // First, GetAll CurrentOperatingConfig properties on the object |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 521 | sdbusplus::asio::getAllProperties( |
| 522 | *crow::connections::systemBus, service, objPath, |
| 523 | "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig", |
| 524 | [aResp, cpuId, |
| 525 | service](const boost::system::error_code ec, |
| 526 | const dbus::utility::DBusPropertiesMap& properties) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 527 | if (ec) |
| 528 | { |
| 529 | BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " << ec.message(); |
| 530 | messages::internalError(aResp->res); |
| 531 | return; |
| 532 | } |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 533 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 534 | nlohmann::json& json = aResp->res.jsonValue; |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 535 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 536 | const sdbusplus::message::object_path* appliedConfig = nullptr; |
| 537 | const bool* baseSpeedPriorityEnabled = nullptr; |
| 538 | |
| 539 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 540 | dbus_utils::UnpackErrorPrinter(), properties, "AppliedConfig", |
| 541 | appliedConfig, "BaseSpeedPriorityEnabled", |
| 542 | baseSpeedPriorityEnabled); |
| 543 | |
| 544 | if (!success) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 545 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 546 | messages::internalError(aResp->res); |
| 547 | return; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 548 | } |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 549 | |
| 550 | if (appliedConfig != nullptr) |
| 551 | { |
| 552 | const std::string& dbusPath = appliedConfig->str; |
| 553 | std::string uri = "/redfish/v1/Systems/system/Processors/" + cpuId + |
| 554 | "/OperatingConfigs"; |
| 555 | nlohmann::json::object_t operatingConfig; |
| 556 | operatingConfig["@odata.id"] = uri; |
| 557 | json["OperatingConfigs"] = std::move(operatingConfig); |
| 558 | |
| 559 | // Reuse the D-Bus config object name for the Redfish |
| 560 | // URI |
| 561 | size_t baseNamePos = dbusPath.rfind('/'); |
| 562 | if (baseNamePos == std::string::npos || |
| 563 | baseNamePos == (dbusPath.size() - 1)) |
| 564 | { |
| 565 | // If the AppliedConfig was somehow not a valid path, |
| 566 | // skip adding any more properties, since everything |
| 567 | // else is tied to this applied config. |
| 568 | messages::internalError(aResp->res); |
| 569 | return; |
| 570 | } |
| 571 | uri += '/'; |
| 572 | uri += dbusPath.substr(baseNamePos + 1); |
| 573 | nlohmann::json::object_t appliedOperatingConfig; |
| 574 | appliedOperatingConfig["@odata.id"] = uri; |
| 575 | json["AppliedOperatingConfig"] = std::move(appliedOperatingConfig); |
| 576 | |
| 577 | // Once we found the current applied config, queue another |
| 578 | // request to read the base freq core ids out of that |
| 579 | // config. |
| 580 | sdbusplus::asio::getProperty<BaseSpeedPrioritySettingsProperty>( |
| 581 | *crow::connections::systemBus, service, dbusPath, |
| 582 | "xyz.openbmc_project.Inventory.Item.Cpu." |
| 583 | "OperatingConfig", |
| 584 | "BaseSpeedPrioritySettings", |
| 585 | [aResp]( |
| 586 | const boost::system::error_code ec2, |
| 587 | const BaseSpeedPrioritySettingsProperty& baseSpeedList) { |
| 588 | if (ec2) |
| 589 | { |
| 590 | BMCWEB_LOG_WARNING << "D-Bus Property Get error: " << ec2; |
| 591 | messages::internalError(aResp->res); |
| 592 | return; |
| 593 | } |
| 594 | |
| 595 | highSpeedCoreIdsHandler(aResp, baseSpeedList); |
| 596 | }); |
| 597 | } |
| 598 | |
| 599 | if (baseSpeedPriorityEnabled != nullptr) |
| 600 | { |
| 601 | json["BaseSpeedPriorityState"] = |
| 602 | *baseSpeedPriorityEnabled ? "Enabled" : "Disabled"; |
| 603 | } |
| 604 | }); |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 605 | } |
| 606 | |
SunnySrivastava1984 | cba4f44 | 2021-01-07 12:48:16 -0600 | [diff] [blame] | 607 | /** |
| 608 | * @brief Fill out location info of a processor by |
| 609 | * requesting data from the given D-Bus object. |
| 610 | * |
| 611 | * @param[in,out] aResp Async HTTP response. |
| 612 | * @param[in] service D-Bus service to query. |
| 613 | * @param[in] objPath D-Bus object to query. |
| 614 | */ |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 615 | inline void getCpuLocationCode(std::shared_ptr<bmcweb::AsyncResp> aResp, |
SunnySrivastava1984 | cba4f44 | 2021-01-07 12:48:16 -0600 | [diff] [blame] | 616 | const std::string& service, |
| 617 | const std::string& objPath) |
| 618 | { |
| 619 | BMCWEB_LOG_DEBUG << "Get Cpu Location Data"; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 620 | sdbusplus::asio::getProperty<std::string>( |
| 621 | *crow::connections::systemBus, service, objPath, |
| 622 | "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", |
| 623 | [objPath, aResp{std::move(aResp)}](const boost::system::error_code ec, |
| 624 | const std::string& property) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 625 | if (ec) |
| 626 | { |
| 627 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 628 | messages::internalError(aResp->res); |
| 629 | return; |
| 630 | } |
SunnySrivastava1984 | cba4f44 | 2021-01-07 12:48:16 -0600 | [diff] [blame] | 631 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 632 | aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = |
| 633 | property; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 634 | }); |
SunnySrivastava1984 | cba4f44 | 2021-01-07 12:48:16 -0600 | [diff] [blame] | 635 | } |
| 636 | |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 637 | /** |
Jonathan Doman | 49e429c | 2021-03-03 13:11:44 -0800 | [diff] [blame] | 638 | * Populate the unique identifier in a Processor resource by requesting data |
| 639 | * from the given D-Bus object. |
| 640 | * |
| 641 | * @param[in,out] aResp Async HTTP response. |
| 642 | * @param[in] service D-Bus service to query. |
| 643 | * @param[in] objPath D-Bus object to query. |
| 644 | */ |
| 645 | inline void getCpuUniqueId(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 646 | const std::string& service, |
| 647 | const std::string& objectPath) |
| 648 | { |
| 649 | BMCWEB_LOG_DEBUG << "Get CPU UniqueIdentifier"; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 650 | sdbusplus::asio::getProperty<std::string>( |
| 651 | *crow::connections::systemBus, service, objectPath, |
| 652 | "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier", |
| 653 | "UniqueIdentifier", |
| 654 | [aResp](boost::system::error_code ec, const std::string& id) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 655 | if (ec) |
| 656 | { |
| 657 | BMCWEB_LOG_ERROR << "Failed to read cpu unique id: " << ec; |
| 658 | messages::internalError(aResp->res); |
| 659 | return; |
| 660 | } |
| 661 | aResp->res.jsonValue["ProcessorId"]["ProtectedIdentificationNumber"] = |
| 662 | id; |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 663 | }); |
Jonathan Doman | 49e429c | 2021-03-03 13:11:44 -0800 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | /** |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 667 | * Find the D-Bus object representing the requested Processor, and call the |
| 668 | * handler with the results. If matching object is not found, add 404 error to |
| 669 | * response and don't call the handler. |
| 670 | * |
| 671 | * @param[in,out] resp Async HTTP response. |
| 672 | * @param[in] processorId Redfish Processor Id. |
| 673 | * @param[in] handler Callback to continue processing request upon |
| 674 | * successfully finding object. |
| 675 | */ |
| 676 | template <typename Handler> |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 677 | inline void getProcessorObject(const std::shared_ptr<bmcweb::AsyncResp>& resp, |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 678 | const std::string& processorId, |
| 679 | Handler&& handler) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 680 | { |
| 681 | BMCWEB_LOG_DEBUG << "Get available system processor resources."; |
| 682 | |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 683 | // GetSubTree on all interfaces which provide info about a Processor |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 684 | crow::connections::systemBus->async_method_call( |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 685 | [resp, processorId, handler = std::forward<Handler>(handler)]( |
| 686 | boost::system::error_code ec, |
Shantappa Teekappanavar | 5df6eda | 2022-01-18 12:29:28 -0600 | [diff] [blame] | 687 | const dbus::utility::MapperGetSubTreeResponse& subtree) mutable { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 688 | if (ec) |
| 689 | { |
| 690 | BMCWEB_LOG_DEBUG << "DBUS response error: " << ec; |
| 691 | messages::internalError(resp->res); |
| 692 | return; |
| 693 | } |
| 694 | for (const auto& [objectPath, serviceMap] : subtree) |
| 695 | { |
| 696 | // Ignore any objects which don't end with our desired cpu name |
Ed Tanous | 11ba397 | 2022-07-11 09:50:41 -0700 | [diff] [blame] | 697 | if (!objectPath.ends_with(processorId)) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 698 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 699 | continue; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 700 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 701 | |
| 702 | bool found = false; |
| 703 | // Filter out objects that don't have the CPU-specific |
| 704 | // interfaces to make sure we can return 404 on non-CPUs |
| 705 | // (e.g. /redfish/../Processors/dimm0) |
| 706 | for (const auto& [serviceName, interfaceList] : serviceMap) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 707 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 708 | if (std::find_first_of( |
| 709 | interfaceList.begin(), interfaceList.end(), |
| 710 | processorInterfaces.begin(), |
| 711 | processorInterfaces.end()) != interfaceList.end()) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 712 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 713 | found = true; |
| 714 | break; |
Jonathan Doman | 2bab983 | 2020-12-02 15:27:40 -0800 | [diff] [blame] | 715 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 716 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 717 | |
| 718 | if (!found) |
| 719 | { |
| 720 | continue; |
| 721 | } |
| 722 | |
| 723 | // Process the first object which does match our cpu name and |
| 724 | // required interfaces, and potentially ignore any other |
| 725 | // matching objects. Assume all interfaces we want to process |
| 726 | // must be on the same object path. |
| 727 | |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 728 | handler(objectPath, serviceMap); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 729 | return; |
| 730 | } |
| 731 | messages::resourceNotFound(resp->res, "Processor", processorId); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 732 | }, |
| 733 | "xyz.openbmc_project.ObjectMapper", |
| 734 | "/xyz/openbmc_project/object_mapper", |
| 735 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
Jonathan Doman | 2bab983 | 2020-12-02 15:27:40 -0800 | [diff] [blame] | 736 | "/xyz/openbmc_project/inventory", 0, |
Jonathan Doman | 49e429c | 2021-03-03 13:11:44 -0800 | [diff] [blame] | 737 | std::array<const char*, 8>{ |
Sharad Yadav | 71b82f2 | 2021-05-10 15:11:39 +0530 | [diff] [blame] | 738 | "xyz.openbmc_project.Common.UUID", |
Jonathan Doman | 2bab983 | 2020-12-02 15:27:40 -0800 | [diff] [blame] | 739 | "xyz.openbmc_project.Inventory.Decorator.Asset", |
| 740 | "xyz.openbmc_project.Inventory.Decorator.Revision", |
| 741 | "xyz.openbmc_project.Inventory.Item.Cpu", |
SunnySrivastava1984 | cba4f44 | 2021-01-07 12:48:16 -0600 | [diff] [blame] | 742 | "xyz.openbmc_project.Inventory.Decorator.LocationCode", |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 743 | "xyz.openbmc_project.Inventory.Item.Accelerator", |
Jonathan Doman | 49e429c | 2021-03-03 13:11:44 -0800 | [diff] [blame] | 744 | "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig", |
| 745 | "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier"}); |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 746 | } |
| 747 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 748 | inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 749 | const std::string& processorId, |
| 750 | const std::string& objectPath, |
Shantappa Teekappanavar | 5df6eda | 2022-01-18 12:29:28 -0600 | [diff] [blame] | 751 | const dbus::utility::MapperServiceMap& serviceMap) |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 752 | { |
| 753 | for (const auto& [serviceName, interfaceList] : serviceMap) |
| 754 | { |
| 755 | for (const auto& interface : interfaceList) |
| 756 | { |
| 757 | if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset") |
| 758 | { |
| 759 | getCpuAssetData(aResp, serviceName, objectPath); |
| 760 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 761 | else if (interface == |
| 762 | "xyz.openbmc_project.Inventory.Decorator.Revision") |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 763 | { |
| 764 | getCpuRevisionData(aResp, serviceName, objectPath); |
| 765 | } |
| 766 | else if (interface == "xyz.openbmc_project.Inventory.Item.Cpu") |
| 767 | { |
| 768 | getCpuDataByService(aResp, processorId, serviceName, |
| 769 | objectPath); |
| 770 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 771 | else if (interface == |
| 772 | "xyz.openbmc_project.Inventory.Item.Accelerator") |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 773 | { |
| 774 | getAcceleratorDataByService(aResp, processorId, serviceName, |
| 775 | objectPath); |
| 776 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 777 | else if ( |
| 778 | interface == |
| 779 | "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig") |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 780 | { |
| 781 | getCpuConfigData(aResp, processorId, serviceName, objectPath); |
| 782 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 783 | else if (interface == |
| 784 | "xyz.openbmc_project.Inventory.Decorator.LocationCode") |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 785 | { |
| 786 | getCpuLocationCode(aResp, serviceName, objectPath); |
| 787 | } |
Sharad Yadav | 71b82f2 | 2021-05-10 15:11:39 +0530 | [diff] [blame] | 788 | else if (interface == "xyz.openbmc_project.Common.UUID") |
| 789 | { |
| 790 | getProcessorUUID(aResp, serviceName, objectPath); |
| 791 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 792 | else if (interface == |
| 793 | "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier") |
Jonathan Doman | 49e429c | 2021-03-03 13:11:44 -0800 | [diff] [blame] | 794 | { |
| 795 | getCpuUniqueId(aResp, serviceName, objectPath); |
| 796 | } |
Jonathan Doman | c951448 | 2021-02-24 09:20:51 -0800 | [diff] [blame] | 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 801 | /** |
| 802 | * Request all the properties for the given D-Bus object and fill out the |
| 803 | * related entries in the Redfish OperatingConfig response. |
| 804 | * |
| 805 | * @param[in,out] aResp Async HTTP response. |
| 806 | * @param[in] service D-Bus service name to query. |
| 807 | * @param[in] objPath D-Bus object to query. |
| 808 | */ |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 809 | inline void |
| 810 | getOperatingConfigData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 811 | const std::string& service, |
| 812 | const std::string& objPath) |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 813 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 814 | sdbusplus::asio::getAllProperties( |
| 815 | *crow::connections::systemBus, service, objPath, |
| 816 | "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig", |
Ed Tanous | 914e2d5 | 2022-01-07 11:38:34 -0800 | [diff] [blame] | 817 | [aResp](const boost::system::error_code ec, |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 818 | const dbus::utility::DBusPropertiesMap& properties) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 819 | if (ec) |
| 820 | { |
| 821 | BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " << ec.message(); |
| 822 | messages::internalError(aResp->res); |
| 823 | return; |
| 824 | } |
| 825 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 826 | const size_t* availableCoreCount = nullptr; |
| 827 | const uint32_t* baseSpeed = nullptr; |
| 828 | const uint32_t* maxJunctionTemperature = nullptr; |
| 829 | const uint32_t* maxSpeed = nullptr; |
| 830 | const uint32_t* powerLimit = nullptr; |
| 831 | const TurboProfileProperty* turboProfile = nullptr; |
| 832 | const BaseSpeedPrioritySettingsProperty* baseSpeedPrioritySettings = |
| 833 | nullptr; |
| 834 | |
| 835 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 836 | dbus_utils::UnpackErrorPrinter(), properties, "AvailableCoreCount", |
| 837 | availableCoreCount, "BaseSpeed", baseSpeed, |
| 838 | "MaxJunctionTemperature", maxJunctionTemperature, "MaxSpeed", |
| 839 | maxSpeed, "PowerLimit", powerLimit, "TurboProfile", turboProfile, |
| 840 | "BaseSpeedPrioritySettings", baseSpeedPrioritySettings); |
| 841 | |
| 842 | if (!success) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 843 | { |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 844 | messages::internalError(aResp->res); |
| 845 | return; |
| 846 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 847 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 848 | nlohmann::json& json = aResp->res.jsonValue; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 849 | |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 850 | if (availableCoreCount != nullptr) |
| 851 | { |
| 852 | json["TotalAvailableCoreCount"] = *availableCoreCount; |
| 853 | } |
| 854 | |
| 855 | if (baseSpeed != nullptr) |
| 856 | { |
| 857 | json["BaseSpeedMHz"] = *baseSpeed; |
| 858 | } |
| 859 | |
| 860 | if (maxJunctionTemperature != nullptr) |
| 861 | { |
| 862 | json["MaxJunctionTemperatureCelsius"] = *maxJunctionTemperature; |
| 863 | } |
| 864 | |
| 865 | if (maxSpeed != nullptr) |
| 866 | { |
| 867 | json["MaxSpeedMHz"] = *maxSpeed; |
| 868 | } |
| 869 | |
| 870 | if (powerLimit != nullptr) |
| 871 | { |
| 872 | json["TDPWatts"] = *powerLimit; |
| 873 | } |
| 874 | |
| 875 | if (turboProfile != nullptr) |
| 876 | { |
| 877 | nlohmann::json& turboArray = json["TurboProfile"]; |
| 878 | turboArray = nlohmann::json::array(); |
| 879 | for (const auto& [turboSpeed, coreCount] : *turboProfile) |
| 880 | { |
| 881 | nlohmann::json::object_t turbo; |
| 882 | turbo["ActiveCoreCount"] = coreCount; |
| 883 | turbo["MaxSpeedMHz"] = turboSpeed; |
| 884 | turboArray.push_back(std::move(turbo)); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 885 | } |
| 886 | } |
Krzysztof Grobelny | 351053f | 2022-07-28 15:44:22 +0200 | [diff] [blame] | 887 | |
| 888 | if (baseSpeedPrioritySettings != nullptr) |
| 889 | { |
| 890 | nlohmann::json& baseSpeedArray = json["BaseSpeedPrioritySettings"]; |
| 891 | baseSpeedArray = nlohmann::json::array(); |
| 892 | for (const auto& [baseSpeedMhz, coreList] : |
| 893 | *baseSpeedPrioritySettings) |
| 894 | { |
| 895 | nlohmann::json::object_t speed; |
| 896 | speed["CoreCount"] = coreList.size(); |
| 897 | speed["CoreIDs"] = coreList; |
| 898 | speed["BaseSpeedMHz"] = baseSpeedMhz; |
| 899 | baseSpeedArray.push_back(std::move(speed)); |
| 900 | } |
| 901 | } |
| 902 | }); |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 903 | } |
| 904 | |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 905 | /** |
| 906 | * Handle the D-Bus response from attempting to set the CPU's AppliedConfig |
| 907 | * property. Main task is to translate error messages into Redfish errors. |
| 908 | * |
| 909 | * @param[in,out] resp HTTP response. |
| 910 | * @param[in] setPropVal Value which we attempted to set. |
| 911 | * @param[in] ec D-Bus response error code. |
| 912 | * @param[in] msg D-Bus response message. |
| 913 | */ |
| 914 | inline void |
| 915 | handleAppliedConfigResponse(const std::shared_ptr<bmcweb::AsyncResp>& resp, |
| 916 | const std::string& setPropVal, |
| 917 | boost::system::error_code ec, |
Patrick Williams | 59d494e | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 918 | const sdbusplus::message_t& msg) |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 919 | { |
| 920 | if (!ec) |
| 921 | { |
| 922 | BMCWEB_LOG_DEBUG << "Set Property succeeded"; |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | BMCWEB_LOG_DEBUG << "Set Property failed: " << ec; |
| 927 | |
| 928 | const sd_bus_error* dbusError = msg.get_error(); |
| 929 | if (dbusError == nullptr) |
| 930 | { |
| 931 | messages::internalError(resp->res); |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | // The asio error code doesn't know about our custom errors, so we have to |
| 936 | // parse the error string. Some of these D-Bus -> Redfish translations are a |
| 937 | // stretch, but it's good to try to communicate something vaguely useful. |
| 938 | if (strcmp(dbusError->name, |
| 939 | "xyz.openbmc_project.Common.Error.InvalidArgument") == 0) |
| 940 | { |
| 941 | // Service did not like the object_path we tried to set. |
| 942 | messages::propertyValueIncorrect( |
| 943 | resp->res, "AppliedOperatingConfig/@odata.id", setPropVal); |
| 944 | } |
| 945 | else if (strcmp(dbusError->name, |
| 946 | "xyz.openbmc_project.Common.Error.NotAllowed") == 0) |
| 947 | { |
| 948 | // Service indicates we can never change the config for this processor. |
| 949 | messages::propertyNotWritable(resp->res, "AppliedOperatingConfig"); |
| 950 | } |
| 951 | else if (strcmp(dbusError->name, |
| 952 | "xyz.openbmc_project.Common.Error.Unavailable") == 0) |
| 953 | { |
| 954 | // Service indicates the config cannot be changed right now, but maybe |
| 955 | // in a different system state. |
| 956 | messages::resourceInStandby(resp->res); |
| 957 | } |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 958 | else |
| 959 | { |
| 960 | messages::internalError(resp->res); |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | /** |
| 965 | * Handle the PATCH operation of the AppliedOperatingConfig property. Do basic |
| 966 | * validation of the input data, and then set the D-Bus property. |
| 967 | * |
| 968 | * @param[in,out] resp Async HTTP response. |
| 969 | * @param[in] processorId Processor's Id. |
| 970 | * @param[in] appliedConfigUri New property value to apply. |
| 971 | * @param[in] cpuObjectPath Path of CPU object to modify. |
| 972 | * @param[in] serviceMap Service map for CPU object. |
| 973 | */ |
| 974 | inline void patchAppliedOperatingConfig( |
| 975 | const std::shared_ptr<bmcweb::AsyncResp>& resp, |
| 976 | const std::string& processorId, const std::string& appliedConfigUri, |
Shantappa Teekappanavar | 5df6eda | 2022-01-18 12:29:28 -0600 | [diff] [blame] | 977 | const std::string& cpuObjectPath, |
| 978 | const dbus::utility::MapperServiceMap& serviceMap) |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 979 | { |
| 980 | // Check that the property even exists by checking for the interface |
| 981 | const std::string* controlService = nullptr; |
| 982 | for (const auto& [serviceName, interfaceList] : serviceMap) |
| 983 | { |
| 984 | if (std::find(interfaceList.begin(), interfaceList.end(), |
| 985 | "xyz.openbmc_project.Control.Processor." |
| 986 | "CurrentOperatingConfig") != interfaceList.end()) |
| 987 | { |
| 988 | controlService = &serviceName; |
| 989 | break; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | if (controlService == nullptr) |
| 994 | { |
| 995 | messages::internalError(resp->res); |
| 996 | return; |
| 997 | } |
| 998 | |
| 999 | // Check that the config URI is a child of the cpu URI being patched. |
| 1000 | std::string expectedPrefix("/redfish/v1/Systems/system/Processors/"); |
| 1001 | expectedPrefix += processorId; |
| 1002 | expectedPrefix += "/OperatingConfigs/"; |
Ed Tanous | 11ba397 | 2022-07-11 09:50:41 -0700 | [diff] [blame] | 1003 | if (!appliedConfigUri.starts_with(expectedPrefix) || |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 1004 | expectedPrefix.size() == appliedConfigUri.size()) |
| 1005 | { |
| 1006 | messages::propertyValueIncorrect( |
| 1007 | resp->res, "AppliedOperatingConfig/@odata.id", appliedConfigUri); |
| 1008 | return; |
| 1009 | } |
| 1010 | |
| 1011 | // Generate the D-Bus path of the OperatingConfig object, by assuming it's a |
| 1012 | // direct child of the CPU object. |
| 1013 | // Strip the expectedPrefix from the config URI to get the "filename", and |
| 1014 | // append to the CPU's path. |
| 1015 | std::string configBaseName = appliedConfigUri.substr(expectedPrefix.size()); |
| 1016 | sdbusplus::message::object_path configPath(cpuObjectPath); |
| 1017 | configPath /= configBaseName; |
| 1018 | |
| 1019 | BMCWEB_LOG_INFO << "Setting config to " << configPath.str; |
| 1020 | |
| 1021 | // Set the property, with handler to check error responses |
| 1022 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 914e2d5 | 2022-01-07 11:38:34 -0800 | [diff] [blame] | 1023 | [resp, appliedConfigUri](const boost::system::error_code ec, |
Patrick Williams | 59d494e | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 1024 | const sdbusplus::message_t& msg) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1025 | handleAppliedConfigResponse(resp, appliedConfigUri, ec, msg); |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 1026 | }, |
| 1027 | *controlService, cpuObjectPath, "org.freedesktop.DBus.Properties", |
| 1028 | "Set", "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig", |
Ed Tanous | 168e20c | 2021-12-13 14:39:53 -0800 | [diff] [blame] | 1029 | "AppliedConfig", dbus::utility::DbusVariantType(std::move(configPath))); |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 1030 | } |
| 1031 | |
Nikhil Namjoshi | 71a24ca | 2022-11-11 01:52:32 +0000 | [diff] [blame] | 1032 | inline void handleProcessorHead(crow::App& app, const crow::Request& req, |
| 1033 | const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 1034 | const std::string& /* systemName */, |
| 1035 | const std::string& /* processorId */) |
| 1036 | { |
| 1037 | if (!redfish::setUpRedfishRoute(app, req, aResp)) |
| 1038 | { |
| 1039 | return; |
| 1040 | } |
| 1041 | aResp->res.addHeader( |
| 1042 | boost::beast::http::field::link, |
| 1043 | "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby"); |
| 1044 | } |
| 1045 | |
| 1046 | inline void handleProcessorCollectionHead( |
| 1047 | crow::App& app, const crow::Request& req, |
| 1048 | const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 1049 | const std::string& /* systemName */) |
| 1050 | { |
| 1051 | if (!redfish::setUpRedfishRoute(app, req, aResp)) |
| 1052 | { |
| 1053 | return; |
| 1054 | } |
| 1055 | aResp->res.addHeader( |
| 1056 | boost::beast::http::field::link, |
| 1057 | "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby"); |
| 1058 | } |
| 1059 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1060 | inline void requestRoutesOperatingConfigCollection(App& app) |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 1061 | { |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 1062 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1063 | BMCWEB_ROUTE( |
| 1064 | app, "/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1065 | .privileges(redfish::privileges::getOperatingConfigCollection) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1066 | .methods(boost::beast::http::verb::get)( |
| 1067 | [&app](const crow::Request& req, |
| 1068 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 1069 | const std::string& cpuName) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 1070 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1071 | { |
| 1072 | return; |
| 1073 | } |
| 1074 | asyncResp->res.jsonValue["@odata.type"] = |
| 1075 | "#OperatingConfigCollection.OperatingConfigCollection"; |
| 1076 | asyncResp->res.jsonValue["@odata.id"] = req.url; |
| 1077 | asyncResp->res.jsonValue["Name"] = "Operating Config Collection"; |
| 1078 | |
| 1079 | // First find the matching CPU object so we know how to |
| 1080 | // constrain our search for related Config objects. |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1081 | const std::array<std::string_view, 1> interfaces = { |
| 1082 | "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"}; |
| 1083 | dbus::utility::getSubTreePaths( |
| 1084 | "/xyz/openbmc_project/inventory", 0, interfaces, |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1085 | [asyncResp, cpuName]( |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1086 | const boost::system::error_code& ec, |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1087 | const dbus::utility::MapperGetSubTreePathsResponse& objects) { |
| 1088 | if (ec) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1089 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1090 | BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " |
| 1091 | << ec.message(); |
| 1092 | messages::internalError(asyncResp->res); |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1093 | return; |
| 1094 | } |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 1095 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1096 | for (const std::string& object : objects) |
| 1097 | { |
Ed Tanous | 11ba397 | 2022-07-11 09:50:41 -0700 | [diff] [blame] | 1098 | if (!object.ends_with(cpuName)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1099 | { |
| 1100 | continue; |
| 1101 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 1102 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1103 | // Not expected that there will be multiple matching |
| 1104 | // CPU objects, but if there are just use the first |
| 1105 | // one. |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 1106 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1107 | // Use the common search routine to construct the |
| 1108 | // Collection of all Config objects under this CPU. |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1109 | constexpr std::array<std::string_view, 1> interface { |
| 1110 | "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig" |
| 1111 | }; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1112 | collection_util::getCollectionMembers( |
| 1113 | asyncResp, |
Willy Tu | ae9031f | 2022-09-27 05:48:07 +0000 | [diff] [blame] | 1114 | crow::utility::urlFromPieces("redfish", "v1", "Systems", |
| 1115 | "system", "Processors", |
| 1116 | cpuName, "OperatingConfigs"), |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1117 | interface, object.c_str()); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1118 | return; |
| 1119 | } |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1120 | }); |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 1121 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
| 1124 | inline void requestRoutesOperatingConfig(App& app) |
| 1125 | { |
| 1126 | BMCWEB_ROUTE( |
| 1127 | app, |
| 1128 | "/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1129 | .privileges(redfish::privileges::getOperatingConfig) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1130 | .methods(boost::beast::http::verb::get)( |
| 1131 | [&app](const crow::Request& req, |
| 1132 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 1133 | const std::string& cpuName, const std::string& configName) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 1134 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1135 | { |
| 1136 | return; |
| 1137 | } |
| 1138 | // Ask for all objects implementing OperatingConfig so we can search |
| 1139 | // for one with a matching name |
| 1140 | crow::connections::systemBus->async_method_call( |
| 1141 | [asyncResp, cpuName, configName, reqUrl{req.url}]( |
| 1142 | boost::system::error_code ec, |
| 1143 | const dbus::utility::MapperGetSubTreeResponse& subtree) { |
| 1144 | if (ec) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1145 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1146 | BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " |
| 1147 | << ec.message(); |
| 1148 | messages::internalError(asyncResp->res); |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1149 | return; |
| 1150 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1151 | const std::string expectedEnding = cpuName + '/' + configName; |
| 1152 | for (const auto& [objectPath, serviceMap] : subtree) |
| 1153 | { |
| 1154 | // Ignore any configs without matching cpuX/configY |
Ed Tanous | 11ba397 | 2022-07-11 09:50:41 -0700 | [diff] [blame] | 1155 | if (!objectPath.ends_with(expectedEnding) || serviceMap.empty()) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1156 | { |
| 1157 | continue; |
| 1158 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1159 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1160 | nlohmann::json& json = asyncResp->res.jsonValue; |
| 1161 | json["@odata.type"] = "#OperatingConfig.v1_0_0.OperatingConfig"; |
| 1162 | json["@odata.id"] = reqUrl; |
| 1163 | json["Name"] = "Processor Profile"; |
| 1164 | json["Id"] = configName; |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1165 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1166 | // Just use the first implementation of the object - not |
| 1167 | // expected that there would be multiple matching |
| 1168 | // services |
| 1169 | getOperatingConfigData(asyncResp, serviceMap.begin()->first, |
| 1170 | objectPath); |
| 1171 | return; |
| 1172 | } |
| 1173 | messages::resourceNotFound(asyncResp->res, "OperatingConfig", |
| 1174 | configName); |
| 1175 | }, |
| 1176 | "xyz.openbmc_project.ObjectMapper", |
| 1177 | "/xyz/openbmc_project/object_mapper", |
| 1178 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
| 1179 | "/xyz/openbmc_project/inventory", 0, |
| 1180 | std::array<const char*, 1>{ |
| 1181 | "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"}); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1182 | }); |
| 1183 | } |
Jonathan Doman | dba0c29 | 2020-12-02 15:34:13 -0800 | [diff] [blame] | 1184 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1185 | inline void requestRoutesProcessorCollection(App& app) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1186 | { |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1187 | /** |
| 1188 | * Functions triggers appropriate requests on DBus |
| 1189 | */ |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1190 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/") |
Nikhil Namjoshi | 71a24ca | 2022-11-11 01:52:32 +0000 | [diff] [blame] | 1191 | .privileges(redfish::privileges::headProcessorCollection) |
| 1192 | .methods(boost::beast::http::verb::head)( |
| 1193 | std::bind_front(handleProcessorCollectionHead, std::ref(app))); |
| 1194 | |
| 1195 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1196 | .privileges(redfish::privileges::getProcessorCollection) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1197 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1198 | [&app](const crow::Request& req, |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1199 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 1200 | const std::string& systemName) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 1201 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1202 | { |
| 1203 | return; |
| 1204 | } |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1205 | if (systemName != "system") |
| 1206 | { |
| 1207 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 1208 | systemName); |
| 1209 | return; |
| 1210 | } |
| 1211 | |
Nikhil Namjoshi | 71a24ca | 2022-11-11 01:52:32 +0000 | [diff] [blame] | 1212 | asyncResp->res.addHeader( |
| 1213 | boost::beast::http::field::link, |
| 1214 | "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby"); |
| 1215 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1216 | asyncResp->res.jsonValue["@odata.type"] = |
| 1217 | "#ProcessorCollection.ProcessorCollection"; |
| 1218 | asyncResp->res.jsonValue["Name"] = "Processor Collection"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1219 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1220 | asyncResp->res.jsonValue["@odata.id"] = |
| 1221 | "/redfish/v1/Systems/system/Processors"; |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1222 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1223 | collection_util::getCollectionMembers( |
Willy Tu | ae9031f | 2022-09-27 05:48:07 +0000 | [diff] [blame] | 1224 | asyncResp, |
| 1225 | boost::urls::url("/redfish/v1/Systems/system/Processors"), |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame^] | 1226 | processorInterfaces); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1227 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1228 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1229 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1230 | inline void requestRoutesProcessor(App& app) |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1231 | { |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1232 | /** |
| 1233 | * Functions triggers appropriate requests on DBus |
| 1234 | */ |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1235 | |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1236 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/") |
Nikhil Namjoshi | 71a24ca | 2022-11-11 01:52:32 +0000 | [diff] [blame] | 1237 | .privileges(redfish::privileges::headProcessor) |
| 1238 | .methods(boost::beast::http::verb::head)( |
| 1239 | std::bind_front(handleProcessorHead, std::ref(app))); |
| 1240 | |
| 1241 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1242 | .privileges(redfish::privileges::getProcessor) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1243 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1244 | [&app](const crow::Request& req, |
| 1245 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1246 | const std::string& systemName, |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1247 | const std::string& processorId) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 1248 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1249 | { |
| 1250 | return; |
| 1251 | } |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1252 | if (systemName != "system") |
| 1253 | { |
| 1254 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 1255 | systemName); |
| 1256 | return; |
| 1257 | } |
| 1258 | |
Nikhil Namjoshi | 71a24ca | 2022-11-11 01:52:32 +0000 | [diff] [blame] | 1259 | asyncResp->res.addHeader( |
| 1260 | boost::beast::http::field::link, |
| 1261 | "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby"); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1262 | asyncResp->res.jsonValue["@odata.type"] = |
| 1263 | "#Processor.v1_11_0.Processor"; |
| 1264 | asyncResp->res.jsonValue["@odata.id"] = |
| 1265 | "/redfish/v1/Systems/system/Processors/" + processorId; |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 1266 | |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 1267 | getProcessorObject( |
| 1268 | asyncResp, processorId, |
| 1269 | std::bind_front(getProcessorData, asyncResp, processorId)); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1270 | }); |
Jonathan Doman | 3cde86f | 2020-12-02 14:50:45 -0800 | [diff] [blame] | 1271 | |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1272 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1273 | .privileges(redfish::privileges::patchProcessor) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1274 | .methods(boost::beast::http::verb::patch)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1275 | [&app](const crow::Request& req, |
| 1276 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1277 | const std::string& systemName, |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1278 | const std::string& processorId) { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 1279 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1280 | { |
| 1281 | return; |
| 1282 | } |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1283 | if (systemName != "system") |
| 1284 | { |
| 1285 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 1286 | systemName); |
| 1287 | return; |
| 1288 | } |
| 1289 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1290 | std::optional<nlohmann::json> appliedConfigJson; |
| 1291 | if (!json_util::readJsonPatch(req, asyncResp->res, |
| 1292 | "AppliedOperatingConfig", |
| 1293 | appliedConfigJson)) |
| 1294 | { |
| 1295 | return; |
| 1296 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1297 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1298 | if (appliedConfigJson) |
| 1299 | { |
Ed Tanous | f8fe53e | 2022-06-30 15:55:45 -0700 | [diff] [blame] | 1300 | std::string appliedConfigUri; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1301 | if (!json_util::readJson(*appliedConfigJson, asyncResp->res, |
| 1302 | "@odata.id", appliedConfigUri)) |
| 1303 | { |
| 1304 | return; |
| 1305 | } |
| 1306 | // Check for 404 and find matching D-Bus object, then run |
| 1307 | // property patch handlers if that all succeeds. |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 1308 | getProcessorObject(asyncResp, processorId, |
| 1309 | std::bind_front(patchAppliedOperatingConfig, |
| 1310 | asyncResp, processorId, |
| 1311 | appliedConfigUri)); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1312 | } |
| 1313 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1314 | } |
Gunnar Mills | ac6a444 | 2020-10-14 14:55:29 -0500 | [diff] [blame] | 1315 | |
| 1316 | } // namespace redfish |