xref: /openbmc/bmcweb/features/redfish/lib/processor.hpp (revision 4d0c0c422007722f94c7cd3a2c66cec4ab2a03e3)
140e9b92eSEd Tanous // SPDX-License-Identifier: Apache-2.0
240e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright OpenBMC Authors
340e9b92eSEd Tanous // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation
4ac6a4445SGunnar Mills #pragma once
5ac6a4445SGunnar Mills 
6d7857201SEd Tanous #include "bmcweb_config.h"
7d7857201SEd Tanous 
83ccb3adbSEd Tanous #include "app.hpp"
9d7857201SEd Tanous #include "async_resp.hpp"
1098eafce5SGeorge Liu #include "dbus_singleton.hpp"
117a1dbc48SGeorge Liu #include "dbus_utility.hpp"
121e1e598dSJonathan Doman #include "error_messages.hpp"
13dfbf7de5SChris Cain #include "generated/enums/processor.hpp"
14539d8c6bSEd Tanous #include "generated/enums/resource.hpp"
15d7857201SEd Tanous #include "http_request.hpp"
1698eafce5SGeorge Liu #include "led.hpp"
17d7857201SEd Tanous #include "logging.hpp"
183ccb3adbSEd Tanous #include "query.hpp"
193ccb3adbSEd Tanous #include "registries/privilege_registry.hpp"
203ccb3adbSEd Tanous #include "utils/collection.hpp"
213ccb3adbSEd Tanous #include "utils/dbus_utils.hpp"
22d7857201SEd Tanous #include "utils/hex_utils.hpp"
233ccb3adbSEd Tanous #include "utils/json_utils.hpp"
24ac6a4445SGunnar Mills 
25d7857201SEd Tanous #include <boost/beast/http/field.hpp>
26d7857201SEd Tanous #include <boost/beast/http/verb.hpp>
27e99073f5SGeorge Liu #include <boost/system/error_code.hpp>
28ef4c65b7SEd Tanous #include <boost/url/format.hpp>
29dba0c291SJonathan Doman #include <sdbusplus/message/native_types.hpp>
30351053f2SKrzysztof Grobelny #include <sdbusplus/unpack_properties.hpp>
31ac6a4445SGunnar Mills 
32d7857201SEd Tanous #include <algorithm>
337a1dbc48SGeorge Liu #include <array>
34d7857201SEd Tanous #include <cstddef>
35d7857201SEd Tanous #include <cstdint>
36d7857201SEd Tanous #include <format>
37d7857201SEd Tanous #include <functional>
38b9d679d1SMichael Shen #include <limits>
39d7857201SEd Tanous #include <memory>
40d7857201SEd Tanous #include <optional>
413544d2a7SEd Tanous #include <ranges>
423c569218SEd Tanous #include <string>
437a1dbc48SGeorge Liu #include <string_view>
44d7857201SEd Tanous #include <tuple>
45d7857201SEd Tanous #include <utility>
46d7857201SEd Tanous #include <variant>
47d7857201SEd Tanous #include <vector>
487a1dbc48SGeorge Liu 
49ac6a4445SGunnar Mills namespace redfish
50ac6a4445SGunnar Mills {
51ac6a4445SGunnar Mills 
52c951448aSJonathan Doman // Interfaces which imply a D-Bus object represents a Processor
537a1dbc48SGeorge Liu constexpr std::array<std::string_view, 2> processorInterfaces = {
54c951448aSJonathan Doman     "xyz.openbmc_project.Inventory.Item.Cpu",
55c951448aSJonathan Doman     "xyz.openbmc_project.Inventory.Item.Accelerator"};
562bab9831SJonathan Doman 
5771b82f26SSharad Yadav /**
5871b82f26SSharad Yadav  * @brief Fill out uuid info of a processor by
5971b82f26SSharad Yadav  * requesting data from the given D-Bus object.
6071b82f26SSharad Yadav  *
61ac106bf6SEd Tanous  * @param[in,out]   asyncResp       Async HTTP response.
6271b82f26SSharad Yadav  * @param[in]       service     D-Bus service to query.
6371b82f26SSharad Yadav  * @param[in]       objPath     D-Bus object to query.
6471b82f26SSharad Yadav  */
65ac106bf6SEd Tanous inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
6671b82f26SSharad Yadav                              const std::string& service,
6771b82f26SSharad Yadav                              const std::string& objPath)
6871b82f26SSharad Yadav {
6962598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get Processor UUID");
70deae6a78SEd Tanous     dbus::utility::getProperty<std::string>(
71deae6a78SEd Tanous         service, objPath, "xyz.openbmc_project.Common.UUID", "UUID",
72ac106bf6SEd Tanous         [objPath, asyncResp{std::move(asyncResp)}](
73ac106bf6SEd Tanous             const boost::system::error_code& ec, const std::string& property) {
7471b82f26SSharad Yadav             if (ec)
7571b82f26SSharad Yadav             {
7662598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
77ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
7871b82f26SSharad Yadav                 return;
7971b82f26SSharad Yadav             }
80ac106bf6SEd Tanous             asyncResp->res.jsonValue["UUID"] = property;
811e1e598dSJonathan Doman         });
8271b82f26SSharad Yadav }
8371b82f26SSharad Yadav 
84711ac7a9SEd Tanous inline void getCpuDataByInterface(
85ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
8680f79a40SMichael Shen     const dbus::utility::DBusInterfacesMap& cpuInterfacesProperties)
87ac6a4445SGunnar Mills {
8862598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get CPU resources by interface.");
89ac6a4445SGunnar Mills 
90a1649ec6SChicago Duan     // Set the default value of state
91539d8c6bSEd Tanous     asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
92539d8c6bSEd Tanous     asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
93ac6a4445SGunnar Mills 
94ac6a4445SGunnar Mills     for (const auto& interface : cpuInterfacesProperties)
95ac6a4445SGunnar Mills     {
96ac6a4445SGunnar Mills         for (const auto& property : interface.second)
97ac6a4445SGunnar Mills         {
98a1649ec6SChicago Duan             if (property.first == "Present")
99ac6a4445SGunnar Mills             {
100a1649ec6SChicago Duan                 const bool* cpuPresent = std::get_if<bool>(&property.second);
101a1649ec6SChicago Duan                 if (cpuPresent == nullptr)
102ac6a4445SGunnar Mills                 {
103ac6a4445SGunnar Mills                     // Important property not in desired type
104ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
105ac6a4445SGunnar Mills                     return;
106ac6a4445SGunnar Mills                 }
107e05aec50SEd Tanous                 if (!*cpuPresent)
108ac6a4445SGunnar Mills                 {
109a1649ec6SChicago Duan                     // Slot is not populated
110539d8c6bSEd Tanous                     asyncResp->res.jsonValue["Status"]["State"] =
111539d8c6bSEd Tanous                         resource::State::Absent;
112a1649ec6SChicago Duan                 }
113a1649ec6SChicago Duan             }
114a1649ec6SChicago Duan             else if (property.first == "Functional")
115a1649ec6SChicago Duan             {
116a1649ec6SChicago Duan                 const bool* cpuFunctional = std::get_if<bool>(&property.second);
117a1649ec6SChicago Duan                 if (cpuFunctional == nullptr)
118a1649ec6SChicago Duan                 {
119ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
120ac6a4445SGunnar Mills                     return;
121ac6a4445SGunnar Mills                 }
122e05aec50SEd Tanous                 if (!*cpuFunctional)
123a1649ec6SChicago Duan                 {
124539d8c6bSEd Tanous                     asyncResp->res.jsonValue["Status"]["Health"] =
125539d8c6bSEd Tanous                         resource::Health::Critical;
126a1649ec6SChicago Duan                 }
127a1649ec6SChicago Duan             }
128a1649ec6SChicago Duan             else if (property.first == "CoreCount")
129a1649ec6SChicago Duan             {
130a1649ec6SChicago Duan                 const uint16_t* coresCount =
131a1649ec6SChicago Duan                     std::get_if<uint16_t>(&property.second);
132a1649ec6SChicago Duan                 if (coresCount == nullptr)
133a1649ec6SChicago Duan                 {
134ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
135a1649ec6SChicago Duan                     return;
136a1649ec6SChicago Duan                 }
137ac106bf6SEd Tanous                 asyncResp->res.jsonValue["TotalCores"] = *coresCount;
138ac6a4445SGunnar Mills             }
139dc3fa667SJonathan Doman             else if (property.first == "MaxSpeedInMhz")
140dc3fa667SJonathan Doman             {
141dc3fa667SJonathan Doman                 const uint32_t* value = std::get_if<uint32_t>(&property.second);
142dc3fa667SJonathan Doman                 if (value != nullptr)
143dc3fa667SJonathan Doman                 {
144ac106bf6SEd Tanous                     asyncResp->res.jsonValue["MaxSpeedMHz"] = *value;
145dc3fa667SJonathan Doman                 }
146dc3fa667SJonathan Doman             }
147ac6a4445SGunnar Mills             else if (property.first == "Socket")
148ac6a4445SGunnar Mills             {
149ac6a4445SGunnar Mills                 const std::string* value =
150ac6a4445SGunnar Mills                     std::get_if<std::string>(&property.second);
151ac6a4445SGunnar Mills                 if (value != nullptr)
152ac6a4445SGunnar Mills                 {
153ac106bf6SEd Tanous                     asyncResp->res.jsonValue["Socket"] = *value;
154ac6a4445SGunnar Mills                 }
155ac6a4445SGunnar Mills             }
156ac6a4445SGunnar Mills             else if (property.first == "ThreadCount")
157ac6a4445SGunnar Mills             {
158dc3fa667SJonathan Doman                 const uint16_t* value = std::get_if<uint16_t>(&property.second);
159ac6a4445SGunnar Mills                 if (value != nullptr)
160ac6a4445SGunnar Mills                 {
161ac106bf6SEd Tanous                     asyncResp->res.jsonValue["TotalThreads"] = *value;
162ac6a4445SGunnar Mills                 }
163ac6a4445SGunnar Mills             }
1641930fbd4SBrandon Kim             else if (property.first == "EffectiveFamily")
165ac6a4445SGunnar Mills             {
1661930fbd4SBrandon Kim                 const uint16_t* value = std::get_if<uint16_t>(&property.second);
1676169de2cSBrad Bishop                 if (value != nullptr && *value != 2)
168ac6a4445SGunnar Mills                 {
169ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorId"]["EffectiveFamily"] =
170866e4862SEd Tanous                         "0x" + intToHexString(*value, 4);
171ac6a4445SGunnar Mills                 }
172ac6a4445SGunnar Mills             }
1731930fbd4SBrandon Kim             else if (property.first == "EffectiveModel")
1741930fbd4SBrandon Kim             {
1751930fbd4SBrandon Kim                 const uint16_t* value = std::get_if<uint16_t>(&property.second);
1761930fbd4SBrandon Kim                 if (value == nullptr)
1771930fbd4SBrandon Kim                 {
178ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
1791930fbd4SBrandon Kim                     return;
1801930fbd4SBrandon Kim                 }
1816169de2cSBrad Bishop                 if (*value != 0)
1826169de2cSBrad Bishop                 {
183ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorId"]["EffectiveModel"] =
184866e4862SEd Tanous                         "0x" + intToHexString(*value, 4);
1851930fbd4SBrandon Kim                 }
1866169de2cSBrad Bishop             }
187ac6a4445SGunnar Mills             else if (property.first == "Id")
188ac6a4445SGunnar Mills             {
189ac6a4445SGunnar Mills                 const uint64_t* value = std::get_if<uint64_t>(&property.second);
190ac6a4445SGunnar Mills                 if (value != nullptr && *value != 0)
191ac6a4445SGunnar Mills                 {
192ac106bf6SEd Tanous                     asyncResp->res
193ac6a4445SGunnar Mills                         .jsonValue["ProcessorId"]["IdentificationRegisters"] =
194866e4862SEd Tanous                         "0x" + intToHexString(*value, 16);
195ac6a4445SGunnar Mills                 }
196ac6a4445SGunnar Mills             }
1971930fbd4SBrandon Kim             else if (property.first == "Microcode")
1981930fbd4SBrandon Kim             {
1991930fbd4SBrandon Kim                 const uint32_t* value = std::get_if<uint32_t>(&property.second);
2001930fbd4SBrandon Kim                 if (value == nullptr)
2011930fbd4SBrandon Kim                 {
202ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
2031930fbd4SBrandon Kim                     return;
2041930fbd4SBrandon Kim                 }
2056169de2cSBrad Bishop                 if (*value != 0)
2066169de2cSBrad Bishop                 {
207ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorId"]["MicrocodeInfo"] =
208866e4862SEd Tanous                         "0x" + intToHexString(*value, 8);
2091930fbd4SBrandon Kim                 }
2106169de2cSBrad Bishop             }
2111930fbd4SBrandon Kim             else if (property.first == "Step")
2121930fbd4SBrandon Kim             {
2131930fbd4SBrandon Kim                 const uint16_t* value = std::get_if<uint16_t>(&property.second);
2141930fbd4SBrandon Kim                 if (value == nullptr)
2151930fbd4SBrandon Kim                 {
216ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
2171930fbd4SBrandon Kim                     return;
2181930fbd4SBrandon Kim                 }
219b9d679d1SMichael Shen                 if (*value != std::numeric_limits<uint16_t>::max())
2206169de2cSBrad Bishop                 {
221ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorId"]["Step"] =
222866e4862SEd Tanous                         "0x" + intToHexString(*value, 4);
2231930fbd4SBrandon Kim                 }
224ac6a4445SGunnar Mills             }
225ac6a4445SGunnar Mills         }
226ac6a4445SGunnar Mills     }
2276169de2cSBrad Bishop }
228ac6a4445SGunnar Mills 
229bd79bce8SPatrick Williams inline void getCpuDataByService(
230bd79bce8SPatrick Williams     std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& cpuId,
231bd79bce8SPatrick Williams     const std::string& service, const std::string& objPath)
232ac6a4445SGunnar Mills {
23362598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get available system cpu resources by service.");
234ac6a4445SGunnar Mills 
2355eb468daSGeorge Liu     sdbusplus::message::object_path path("/xyz/openbmc_project/inventory");
2365eb468daSGeorge Liu     dbus::utility::getManagedObjects(
2375eb468daSGeorge Liu         service, path,
238ac106bf6SEd Tanous         [cpuId, service, objPath, asyncResp{std::move(asyncResp)}](
2395e7e2dc5SEd Tanous             const boost::system::error_code& ec,
240ac6a4445SGunnar Mills             const dbus::utility::ManagedObjectType& dbusData) {
241ac6a4445SGunnar Mills             if (ec)
242ac6a4445SGunnar Mills             {
24362598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
244ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
245ac6a4445SGunnar Mills                 return;
246ac6a4445SGunnar Mills             }
247ac106bf6SEd Tanous             asyncResp->res.jsonValue["Id"] = cpuId;
248ac106bf6SEd Tanous             asyncResp->res.jsonValue["Name"] = "Processor";
249539d8c6bSEd Tanous             asyncResp->res.jsonValue["ProcessorType"] =
250539d8c6bSEd Tanous                 processor::ProcessorType::CPU;
251ac6a4445SGunnar Mills 
252ac6a4445SGunnar Mills             for (const auto& object : dbusData)
253ac6a4445SGunnar Mills             {
254ac6a4445SGunnar Mills                 if (object.first.str == objPath)
255ac6a4445SGunnar Mills                 {
256ac106bf6SEd Tanous                     getCpuDataByInterface(asyncResp, object.second);
257ac6a4445SGunnar Mills                 }
258ac6a4445SGunnar Mills             }
259ac6a4445SGunnar Mills             return;
2605eb468daSGeorge Liu         });
261ac6a4445SGunnar Mills }
262ac6a4445SGunnar Mills 
263dfbf7de5SChris Cain /**
264dfbf7de5SChris Cain  * @brief Translates throttle cause DBUS property to redfish.
265dfbf7de5SChris Cain  *
266dfbf7de5SChris Cain  * @param[in] dbusSource    The throttle cause from DBUS
267dfbf7de5SChris Cain  *
268dfbf7de5SChris Cain  * @return Returns as a string, the throttle cause in Redfish terms. If
269dfbf7de5SChris Cain  * translation cannot be done, returns "Unknown" throttle reason.
270dfbf7de5SChris Cain  */
271504af5a0SPatrick Williams inline processor::ThrottleCause dbusToRfThrottleCause(
272504af5a0SPatrick Williams     const std::string& dbusSource)
273dfbf7de5SChris Cain {
274dfbf7de5SChris Cain     if (dbusSource ==
275dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.ClockLimit")
276dfbf7de5SChris Cain     {
277dfbf7de5SChris Cain         return processor::ThrottleCause::ClockLimit;
278dfbf7de5SChris Cain     }
279dfbf7de5SChris Cain     if (dbusSource ==
280dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.ManagementDetectedFault")
281dfbf7de5SChris Cain     {
282dfbf7de5SChris Cain         return processor::ThrottleCause::ManagementDetectedFault;
283dfbf7de5SChris Cain     }
284dfbf7de5SChris Cain     if (dbusSource ==
285dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.PowerLimit")
286dfbf7de5SChris Cain     {
287dfbf7de5SChris Cain         return processor::ThrottleCause::PowerLimit;
288dfbf7de5SChris Cain     }
289dfbf7de5SChris Cain     if (dbusSource ==
290dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.ThermalLimit")
291dfbf7de5SChris Cain     {
292dfbf7de5SChris Cain         return processor::ThrottleCause::ThermalLimit;
293dfbf7de5SChris Cain     }
294dfbf7de5SChris Cain     if (dbusSource ==
295dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle.ThrottleReasons.Unknown")
296dfbf7de5SChris Cain     {
297dfbf7de5SChris Cain         return processor::ThrottleCause::Unknown;
298dfbf7de5SChris Cain     }
299dfbf7de5SChris Cain     return processor::ThrottleCause::Invalid;
300dfbf7de5SChris Cain }
301dfbf7de5SChris Cain 
302504af5a0SPatrick Williams inline void readThrottleProperties(
303504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
304dfbf7de5SChris Cain     const boost::system::error_code& ec,
305dfbf7de5SChris Cain     const dbus::utility::DBusPropertiesMap& properties)
306dfbf7de5SChris Cain {
307dfbf7de5SChris Cain     if (ec)
308dfbf7de5SChris Cain     {
30962598e31SEd Tanous         BMCWEB_LOG_ERROR("Processor Throttle getAllProperties error {}", ec);
310ac106bf6SEd Tanous         messages::internalError(asyncResp->res);
311dfbf7de5SChris Cain         return;
312dfbf7de5SChris Cain     }
313dfbf7de5SChris Cain 
314dfbf7de5SChris Cain     const bool* status = nullptr;
315dfbf7de5SChris Cain     const std::vector<std::string>* causes = nullptr;
316dfbf7de5SChris Cain 
317dfbf7de5SChris Cain     if (!sdbusplus::unpackPropertiesNoThrow(dbus_utils::UnpackErrorPrinter(),
318dfbf7de5SChris Cain                                             properties, "Throttled", status,
319dfbf7de5SChris Cain                                             "ThrottleCauses", causes))
320dfbf7de5SChris Cain     {
321ac106bf6SEd Tanous         messages::internalError(asyncResp->res);
322dfbf7de5SChris Cain         return;
323dfbf7de5SChris Cain     }
324dfbf7de5SChris Cain 
325ac106bf6SEd Tanous     asyncResp->res.jsonValue["Throttled"] = *status;
326dfbf7de5SChris Cain     nlohmann::json::array_t rCauses;
327dfbf7de5SChris Cain     for (const std::string& cause : *causes)
328dfbf7de5SChris Cain     {
329dfbf7de5SChris Cain         processor::ThrottleCause rfCause = dbusToRfThrottleCause(cause);
330dfbf7de5SChris Cain         if (rfCause == processor::ThrottleCause::Invalid)
331dfbf7de5SChris Cain         {
332ac106bf6SEd Tanous             messages::internalError(asyncResp->res);
333dfbf7de5SChris Cain             return;
334dfbf7de5SChris Cain         }
335dfbf7de5SChris Cain 
336dfbf7de5SChris Cain         rCauses.emplace_back(rfCause);
337dfbf7de5SChris Cain     }
338ac106bf6SEd Tanous     asyncResp->res.jsonValue["ThrottleCauses"] = std::move(rCauses);
339dfbf7de5SChris Cain }
340dfbf7de5SChris Cain 
341bd79bce8SPatrick Williams inline void getThrottleProperties(
342bd79bce8SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
343bd79bce8SPatrick Williams     const std::string& service, const std::string& objectPath)
344dfbf7de5SChris Cain {
34562598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get processor throttle resources");
346dfbf7de5SChris Cain 
347deae6a78SEd Tanous     dbus::utility::getAllProperties(
348deae6a78SEd Tanous         service, objectPath, "xyz.openbmc_project.Control.Power.Throttle",
349ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec,
350dfbf7de5SChris Cain                     const dbus::utility::DBusPropertiesMap& properties) {
351ac106bf6SEd Tanous             readThrottleProperties(asyncResp, ec, properties);
352dfbf7de5SChris Cain         });
353dfbf7de5SChris Cain }
354dfbf7de5SChris Cain 
355ac106bf6SEd Tanous inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
356ac6a4445SGunnar Mills                             const std::string& service,
357ac6a4445SGunnar Mills                             const std::string& objPath)
358ac6a4445SGunnar Mills {
35962598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get Cpu Asset Data");
360deae6a78SEd Tanous     dbus::utility::getAllProperties(
361deae6a78SEd Tanous         service, objPath, "xyz.openbmc_project.Inventory.Decorator.Asset",
362ac106bf6SEd Tanous         [objPath, asyncResp{std::move(asyncResp)}](
3635e7e2dc5SEd Tanous             const boost::system::error_code& ec,
364351053f2SKrzysztof Grobelny             const dbus::utility::DBusPropertiesMap& properties) {
365ac6a4445SGunnar Mills             if (ec)
366ac6a4445SGunnar Mills             {
36762598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
368ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
369ac6a4445SGunnar Mills                 return;
370ac6a4445SGunnar Mills             }
371ac6a4445SGunnar Mills 
372351053f2SKrzysztof Grobelny             const std::string* serialNumber = nullptr;
373351053f2SKrzysztof Grobelny             const std::string* model = nullptr;
374351053f2SKrzysztof Grobelny             const std::string* manufacturer = nullptr;
375351053f2SKrzysztof Grobelny             const std::string* partNumber = nullptr;
376351053f2SKrzysztof Grobelny             const std::string* sparePartNumber = nullptr;
377351053f2SKrzysztof Grobelny 
378351053f2SKrzysztof Grobelny             const bool success = sdbusplus::unpackPropertiesNoThrow(
379351053f2SKrzysztof Grobelny                 dbus_utils::UnpackErrorPrinter(), properties, "SerialNumber",
380351053f2SKrzysztof Grobelny                 serialNumber, "Model", model, "Manufacturer", manufacturer,
381351053f2SKrzysztof Grobelny                 "PartNumber", partNumber, "SparePartNumber", sparePartNumber);
382351053f2SKrzysztof Grobelny 
383351053f2SKrzysztof Grobelny             if (!success)
384ac6a4445SGunnar Mills             {
385ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
386351053f2SKrzysztof Grobelny                 return;
387ac6a4445SGunnar Mills             }
388351053f2SKrzysztof Grobelny 
389351053f2SKrzysztof Grobelny             if (serialNumber != nullptr && !serialNumber->empty())
390ac6a4445SGunnar Mills             {
391ac106bf6SEd Tanous                 asyncResp->res.jsonValue["SerialNumber"] = *serialNumber;
392351053f2SKrzysztof Grobelny             }
393351053f2SKrzysztof Grobelny 
394351053f2SKrzysztof Grobelny             if ((model != nullptr) && !model->empty())
395ac6a4445SGunnar Mills             {
396ac106bf6SEd Tanous                 asyncResp->res.jsonValue["Model"] = *model;
397ac6a4445SGunnar Mills             }
398ac6a4445SGunnar Mills 
399351053f2SKrzysztof Grobelny             if (manufacturer != nullptr)
400ac6a4445SGunnar Mills             {
401ac106bf6SEd Tanous                 asyncResp->res.jsonValue["Manufacturer"] = *manufacturer;
402ac6a4445SGunnar Mills 
403ac6a4445SGunnar Mills                 // Otherwise would be unexpected.
404351053f2SKrzysztof Grobelny                 if (manufacturer->find("Intel") != std::string::npos)
405ac6a4445SGunnar Mills                 {
406ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorArchitecture"] = "x86";
407ac106bf6SEd Tanous                     asyncResp->res.jsonValue["InstructionSet"] = "x86-64";
408ac6a4445SGunnar Mills                 }
409351053f2SKrzysztof Grobelny                 else if (manufacturer->find("IBM") != std::string::npos)
410ac6a4445SGunnar Mills                 {
411ac106bf6SEd Tanous                     asyncResp->res.jsonValue["ProcessorArchitecture"] = "Power";
412ac106bf6SEd Tanous                     asyncResp->res.jsonValue["InstructionSet"] = "PowerISA";
413ac6a4445SGunnar Mills                 }
414*4d0c0c42SRebecca Cran                 else if (manufacturer->find("Ampere") != std::string::npos)
415*4d0c0c42SRebecca Cran                 {
416*4d0c0c42SRebecca Cran                     asyncResp->res.jsonValue["ProcessorArchitecture"] = "ARM";
417*4d0c0c42SRebecca Cran                     asyncResp->res.jsonValue["InstructionSet"] = "ARM-A64";
418*4d0c0c42SRebecca Cran                 }
419ac6a4445SGunnar Mills             }
420cba4f448SSunnySrivastava1984 
421351053f2SKrzysztof Grobelny             if (partNumber != nullptr)
422cba4f448SSunnySrivastava1984             {
423ac106bf6SEd Tanous                 asyncResp->res.jsonValue["PartNumber"] = *partNumber;
424cba4f448SSunnySrivastava1984             }
425cba4f448SSunnySrivastava1984 
4266169de2cSBrad Bishop             if (sparePartNumber != nullptr && !sparePartNumber->empty())
427cba4f448SSunnySrivastava1984             {
428ac106bf6SEd Tanous                 asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
429cba4f448SSunnySrivastava1984             }
430351053f2SKrzysztof Grobelny         });
431ac6a4445SGunnar Mills }
432ac6a4445SGunnar Mills 
433ac106bf6SEd Tanous inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
434ac6a4445SGunnar Mills                                const std::string& service,
435ac6a4445SGunnar Mills                                const std::string& objPath)
436ac6a4445SGunnar Mills {
43762598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get Cpu Revision Data");
438deae6a78SEd Tanous     dbus::utility::getAllProperties(
439deae6a78SEd Tanous         service, objPath, "xyz.openbmc_project.Inventory.Decorator.Revision",
440ac106bf6SEd Tanous         [objPath, asyncResp{std::move(asyncResp)}](
4415e7e2dc5SEd Tanous             const boost::system::error_code& ec,
442351053f2SKrzysztof Grobelny             const dbus::utility::DBusPropertiesMap& properties) {
443ac6a4445SGunnar Mills             if (ec)
444ac6a4445SGunnar Mills             {
44562598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
446ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
447ac6a4445SGunnar Mills                 return;
448ac6a4445SGunnar Mills             }
449ac6a4445SGunnar Mills 
450351053f2SKrzysztof Grobelny             const std::string* version = nullptr;
451351053f2SKrzysztof Grobelny 
452351053f2SKrzysztof Grobelny             const bool success = sdbusplus::unpackPropertiesNoThrow(
453bd79bce8SPatrick Williams                 dbus_utils::UnpackErrorPrinter(), properties, "Version",
454bd79bce8SPatrick Williams                 version);
455351053f2SKrzysztof Grobelny 
456351053f2SKrzysztof Grobelny             if (!success)
457ac6a4445SGunnar Mills             {
458ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
459351053f2SKrzysztof Grobelny                 return;
460351053f2SKrzysztof Grobelny             }
461351053f2SKrzysztof Grobelny 
462351053f2SKrzysztof Grobelny             if (version != nullptr)
463ac6a4445SGunnar Mills             {
464ac106bf6SEd Tanous                 asyncResp->res.jsonValue["Version"] = *version;
465ac6a4445SGunnar Mills             }
466351053f2SKrzysztof Grobelny         });
467ac6a4445SGunnar Mills }
468ac6a4445SGunnar Mills 
4698d1b46d7Szhanghch05 inline void getAcceleratorDataByService(
470ac106bf6SEd Tanous     std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& acclrtrId,
4718d1b46d7Szhanghch05     const std::string& service, const std::string& objPath)
472ac6a4445SGunnar Mills {
47362598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get available system Accelerator resources by service.");
474deae6a78SEd Tanous     dbus::utility::getAllProperties(
475deae6a78SEd Tanous         service, objPath, "",
476ac106bf6SEd Tanous         [acclrtrId, asyncResp{std::move(asyncResp)}](
4775e7e2dc5SEd Tanous             const boost::system::error_code& ec,
478351053f2SKrzysztof Grobelny             const dbus::utility::DBusPropertiesMap& properties) {
479ac6a4445SGunnar Mills             if (ec)
480ac6a4445SGunnar Mills             {
48162598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
482ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
483ac6a4445SGunnar Mills                 return;
484ac6a4445SGunnar Mills             }
485ac6a4445SGunnar Mills 
486351053f2SKrzysztof Grobelny             const bool* functional = nullptr;
487351053f2SKrzysztof Grobelny             const bool* present = nullptr;
488351053f2SKrzysztof Grobelny 
489351053f2SKrzysztof Grobelny             const bool success = sdbusplus::unpackPropertiesNoThrow(
490351053f2SKrzysztof Grobelny                 dbus_utils::UnpackErrorPrinter(), properties, "Functional",
491351053f2SKrzysztof Grobelny                 functional, "Present", present);
492351053f2SKrzysztof Grobelny 
493351053f2SKrzysztof Grobelny             if (!success)
494ac6a4445SGunnar Mills             {
495ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
496351053f2SKrzysztof Grobelny                 return;
497ac6a4445SGunnar Mills             }
498ac6a4445SGunnar Mills 
499ac6a4445SGunnar Mills             std::string state = "Enabled";
500ac6a4445SGunnar Mills             std::string health = "OK";
501ac6a4445SGunnar Mills 
502351053f2SKrzysztof Grobelny             if (present != nullptr && !*present)
503ac6a4445SGunnar Mills             {
504ac6a4445SGunnar Mills                 state = "Absent";
505ac6a4445SGunnar Mills             }
506ac6a4445SGunnar Mills 
507351053f2SKrzysztof Grobelny             if (functional != nullptr && !*functional)
508ac6a4445SGunnar Mills             {
509ac6a4445SGunnar Mills                 if (state == "Enabled")
510ac6a4445SGunnar Mills                 {
511ac6a4445SGunnar Mills                     health = "Critical";
512ac6a4445SGunnar Mills                 }
513ac6a4445SGunnar Mills             }
514ac6a4445SGunnar Mills 
515ac106bf6SEd Tanous             asyncResp->res.jsonValue["Id"] = acclrtrId;
516ac106bf6SEd Tanous             asyncResp->res.jsonValue["Name"] = "Processor";
517ac106bf6SEd Tanous             asyncResp->res.jsonValue["Status"]["State"] = state;
518ac106bf6SEd Tanous             asyncResp->res.jsonValue["Status"]["Health"] = health;
519539d8c6bSEd Tanous             asyncResp->res.jsonValue["ProcessorType"] =
520539d8c6bSEd Tanous                 processor::ProcessorType::Accelerator;
521351053f2SKrzysztof Grobelny         });
522ac6a4445SGunnar Mills }
523ac6a4445SGunnar Mills 
524dba0c291SJonathan Doman // OperatingConfig D-Bus Types
525dba0c291SJonathan Doman using TurboProfileProperty = std::vector<std::tuple<uint32_t, size_t>>;
526dba0c291SJonathan Doman using BaseSpeedPrioritySettingsProperty =
527dba0c291SJonathan Doman     std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>;
528dba0c291SJonathan Doman // uint32_t and size_t may or may not be the same type, requiring a dedup'd
529dba0c291SJonathan Doman // variant
530dba0c291SJonathan Doman 
531dba0c291SJonathan Doman /**
532dba0c291SJonathan Doman  * Fill out the HighSpeedCoreIDs in a Processor resource from the given
533dba0c291SJonathan Doman  * OperatingConfig D-Bus property.
534dba0c291SJonathan Doman  *
535ac106bf6SEd Tanous  * @param[in,out]   asyncResp           Async HTTP response.
536dba0c291SJonathan Doman  * @param[in]       baseSpeedSettings   Full list of base speed priority groups,
537dba0c291SJonathan Doman  *                                      to use to determine the list of high
538dba0c291SJonathan Doman  *                                      speed cores.
539dba0c291SJonathan Doman  */
540dba0c291SJonathan Doman inline void highSpeedCoreIdsHandler(
541ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
542dba0c291SJonathan Doman     const BaseSpeedPrioritySettingsProperty& baseSpeedSettings)
543dba0c291SJonathan Doman {
544dba0c291SJonathan Doman     // The D-Bus property does not indicate which bucket is the "high
545dba0c291SJonathan Doman     // priority" group, so let's discern that by looking for the one with
546dba0c291SJonathan Doman     // highest base frequency.
547dba0c291SJonathan Doman     auto highPriorityGroup = baseSpeedSettings.cend();
548dba0c291SJonathan Doman     uint32_t highestBaseSpeed = 0;
549dba0c291SJonathan Doman     for (auto it = baseSpeedSettings.cbegin(); it != baseSpeedSettings.cend();
550dba0c291SJonathan Doman          ++it)
551dba0c291SJonathan Doman     {
552dba0c291SJonathan Doman         const uint32_t baseFreq = std::get<uint32_t>(*it);
553dba0c291SJonathan Doman         if (baseFreq > highestBaseSpeed)
554dba0c291SJonathan Doman         {
555dba0c291SJonathan Doman             highestBaseSpeed = baseFreq;
556dba0c291SJonathan Doman             highPriorityGroup = it;
557dba0c291SJonathan Doman         }
558dba0c291SJonathan Doman     }
559dba0c291SJonathan Doman 
560ac106bf6SEd Tanous     nlohmann::json& jsonCoreIds = asyncResp->res.jsonValue["HighSpeedCoreIDs"];
561dba0c291SJonathan Doman     jsonCoreIds = nlohmann::json::array();
562dba0c291SJonathan Doman 
563dba0c291SJonathan Doman     // There may not be any entries in the D-Bus property, so only populate
564dba0c291SJonathan Doman     // if there was actually something there.
565dba0c291SJonathan Doman     if (highPriorityGroup != baseSpeedSettings.cend())
566dba0c291SJonathan Doman     {
567dba0c291SJonathan Doman         jsonCoreIds = std::get<std::vector<uint32_t>>(*highPriorityGroup);
568dba0c291SJonathan Doman     }
569dba0c291SJonathan Doman }
570dba0c291SJonathan Doman 
571dba0c291SJonathan Doman /**
572dba0c291SJonathan Doman  * Fill out OperatingConfig related items in a Processor resource by requesting
573dba0c291SJonathan Doman  * data from the given D-Bus object.
574dba0c291SJonathan Doman  *
575ac106bf6SEd Tanous  * @param[in,out]   asyncResp       Async HTTP response.
576dba0c291SJonathan Doman  * @param[in]       cpuId       CPU D-Bus name.
577dba0c291SJonathan Doman  * @param[in]       service     D-Bus service to query.
578dba0c291SJonathan Doman  * @param[in]       objPath     D-Bus object to query.
579dba0c291SJonathan Doman  */
580504af5a0SPatrick Williams inline void getCpuConfigData(
581504af5a0SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
582ac106bf6SEd Tanous     const std::string& cpuId, const std::string& service,
583dba0c291SJonathan Doman     const std::string& objPath)
584dba0c291SJonathan Doman {
58562598e31SEd Tanous     BMCWEB_LOG_INFO("Getting CPU operating configs for {}", cpuId);
586dba0c291SJonathan Doman 
587dba0c291SJonathan Doman     // First, GetAll CurrentOperatingConfig properties on the object
588deae6a78SEd Tanous     dbus::utility::getAllProperties(
589deae6a78SEd Tanous         service, objPath,
590351053f2SKrzysztof Grobelny         "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
591ac106bf6SEd Tanous         [asyncResp, cpuId,
5925e7e2dc5SEd Tanous          service](const boost::system::error_code& ec,
593351053f2SKrzysztof Grobelny                   const dbus::utility::DBusPropertiesMap& properties) {
594dba0c291SJonathan Doman             if (ec)
595dba0c291SJonathan Doman             {
59662598e31SEd Tanous                 BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
597ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
598dba0c291SJonathan Doman                 return;
599dba0c291SJonathan Doman             }
600dba0c291SJonathan Doman 
601ac106bf6SEd Tanous             nlohmann::json& json = asyncResp->res.jsonValue;
602dba0c291SJonathan Doman 
603351053f2SKrzysztof Grobelny             const sdbusplus::message::object_path* appliedConfig = nullptr;
604351053f2SKrzysztof Grobelny             const bool* baseSpeedPriorityEnabled = nullptr;
605351053f2SKrzysztof Grobelny 
606351053f2SKrzysztof Grobelny             const bool success = sdbusplus::unpackPropertiesNoThrow(
607351053f2SKrzysztof Grobelny                 dbus_utils::UnpackErrorPrinter(), properties, "AppliedConfig",
608351053f2SKrzysztof Grobelny                 appliedConfig, "BaseSpeedPriorityEnabled",
609351053f2SKrzysztof Grobelny                 baseSpeedPriorityEnabled);
610351053f2SKrzysztof Grobelny 
611351053f2SKrzysztof Grobelny             if (!success)
612dba0c291SJonathan Doman             {
613ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
614351053f2SKrzysztof Grobelny                 return;
615dba0c291SJonathan Doman             }
616dba0c291SJonathan Doman 
617351053f2SKrzysztof Grobelny             if (appliedConfig != nullptr)
618351053f2SKrzysztof Grobelny             {
619351053f2SKrzysztof Grobelny                 const std::string& dbusPath = appliedConfig->str;
6201476687dSEd Tanous                 nlohmann::json::object_t operatingConfig;
621ef4c65b7SEd Tanous                 operatingConfig["@odata.id"] = boost::urls::format(
622253f11b8SEd Tanous                     "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
623253f11b8SEd Tanous                     BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId);
6241476687dSEd Tanous                 json["OperatingConfigs"] = std::move(operatingConfig);
625dba0c291SJonathan Doman 
626dba0c291SJonathan Doman                 // Reuse the D-Bus config object name for the Redfish
627dba0c291SJonathan Doman                 // URI
628dba0c291SJonathan Doman                 size_t baseNamePos = dbusPath.rfind('/');
629dba0c291SJonathan Doman                 if (baseNamePos == std::string::npos ||
630dba0c291SJonathan Doman                     baseNamePos == (dbusPath.size() - 1))
631dba0c291SJonathan Doman                 {
632dba0c291SJonathan Doman                     // If the AppliedConfig was somehow not a valid path,
633dba0c291SJonathan Doman                     // skip adding any more properties, since everything
634dba0c291SJonathan Doman                     // else is tied to this applied config.
635ac106bf6SEd Tanous                     messages::internalError(asyncResp->res);
636351053f2SKrzysztof Grobelny                     return;
637dba0c291SJonathan Doman                 }
6381476687dSEd Tanous                 nlohmann::json::object_t appliedOperatingConfig;
639ef4c65b7SEd Tanous                 appliedOperatingConfig["@odata.id"] = boost::urls::format(
640253f11b8SEd Tanous                     "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
641253f11b8SEd Tanous                     BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuId,
642253f11b8SEd Tanous                     dbusPath.substr(baseNamePos + 1));
643bd79bce8SPatrick Williams                 json["AppliedOperatingConfig"] =
644bd79bce8SPatrick Williams                     std::move(appliedOperatingConfig);
645dba0c291SJonathan Doman 
646dba0c291SJonathan Doman                 // Once we found the current applied config, queue another
647dba0c291SJonathan Doman                 // request to read the base freq core ids out of that
648dba0c291SJonathan Doman                 // config.
649deae6a78SEd Tanous                 dbus::utility::getProperty<BaseSpeedPrioritySettingsProperty>(
650deae6a78SEd Tanous                     service, dbusPath,
6511e1e598dSJonathan Doman                     "xyz.openbmc_project.Inventory.Item.Cpu."
6521e1e598dSJonathan Doman                     "OperatingConfig",
6531e1e598dSJonathan Doman                     "BaseSpeedPrioritySettings",
654bd79bce8SPatrick Williams                     [asyncResp](const boost::system::error_code& ec2,
655bd79bce8SPatrick Williams                                 const BaseSpeedPrioritySettingsProperty&
656bd79bce8SPatrick Williams                                     baseSpeedList) {
6578a592810SEd Tanous                         if (ec2)
658dba0c291SJonathan Doman                         {
659bd79bce8SPatrick Williams                             BMCWEB_LOG_WARNING("D-Bus Property Get error: {}",
660bd79bce8SPatrick Williams                                                ec2);
661ac106bf6SEd Tanous                             messages::internalError(asyncResp->res);
662dba0c291SJonathan Doman                             return;
663dba0c291SJonathan Doman                         }
6641e1e598dSJonathan Doman 
665ac106bf6SEd Tanous                         highSpeedCoreIdsHandler(asyncResp, baseSpeedList);
6661e1e598dSJonathan Doman                     });
667dba0c291SJonathan Doman             }
668351053f2SKrzysztof Grobelny 
669351053f2SKrzysztof Grobelny             if (baseSpeedPriorityEnabled != nullptr)
670dba0c291SJonathan Doman             {
671dba0c291SJonathan Doman                 json["BaseSpeedPriorityState"] =
672351053f2SKrzysztof Grobelny                     *baseSpeedPriorityEnabled ? "Enabled" : "Disabled";
673dba0c291SJonathan Doman             }
674351053f2SKrzysztof Grobelny         });
675dba0c291SJonathan Doman }
676dba0c291SJonathan Doman 
677cba4f448SSunnySrivastava1984 /**
678cba4f448SSunnySrivastava1984  * @brief Fill out location info of a processor by
679cba4f448SSunnySrivastava1984  * requesting data from the given D-Bus object.
680cba4f448SSunnySrivastava1984  *
681ac106bf6SEd Tanous  * @param[in,out]   asyncResp       Async HTTP response.
682cba4f448SSunnySrivastava1984  * @param[in]       service     D-Bus service to query.
683cba4f448SSunnySrivastava1984  * @param[in]       objPath     D-Bus object to query.
684cba4f448SSunnySrivastava1984  */
685ac106bf6SEd Tanous inline void getCpuLocationCode(std::shared_ptr<bmcweb::AsyncResp> asyncResp,
686cba4f448SSunnySrivastava1984                                const std::string& service,
687cba4f448SSunnySrivastava1984                                const std::string& objPath)
688cba4f448SSunnySrivastava1984 {
68962598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get Cpu Location Data");
690deae6a78SEd Tanous     dbus::utility::getProperty<std::string>(
691deae6a78SEd Tanous         service, objPath,
6921e1e598dSJonathan Doman         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
693ac106bf6SEd Tanous         [objPath, asyncResp{std::move(asyncResp)}](
694ac106bf6SEd Tanous             const boost::system::error_code& ec, const std::string& property) {
695cba4f448SSunnySrivastava1984             if (ec)
696cba4f448SSunnySrivastava1984             {
69762598e31SEd Tanous                 BMCWEB_LOG_DEBUG("DBUS response error");
698ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
699cba4f448SSunnySrivastava1984                 return;
700cba4f448SSunnySrivastava1984             }
701cba4f448SSunnySrivastava1984 
702bd79bce8SPatrick Williams             asyncResp->res
703bd79bce8SPatrick Williams                 .jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
7041e1e598dSJonathan Doman                 property;
7051e1e598dSJonathan Doman         });
706cba4f448SSunnySrivastava1984 }
707cba4f448SSunnySrivastava1984 
708c951448aSJonathan Doman /**
70949e429caSJonathan Doman  * Populate the unique identifier in a Processor resource by requesting data
71049e429caSJonathan Doman  * from the given D-Bus object.
71149e429caSJonathan Doman  *
712ac106bf6SEd Tanous  * @param[in,out]   asyncResp   Async HTTP response.
71349e429caSJonathan Doman  * @param[in]       service     D-Bus service to query.
71449e429caSJonathan Doman  * @param[in]       objPath     D-Bus object to query.
71549e429caSJonathan Doman  */
716ac106bf6SEd Tanous inline void getCpuUniqueId(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
71749e429caSJonathan Doman                            const std::string& service,
71849e429caSJonathan Doman                            const std::string& objectPath)
71949e429caSJonathan Doman {
72062598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get CPU UniqueIdentifier");
721deae6a78SEd Tanous     dbus::utility::getProperty<std::string>(
722deae6a78SEd Tanous         service, objectPath,
7231e1e598dSJonathan Doman         "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier",
7241e1e598dSJonathan Doman         "UniqueIdentifier",
725ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec,
726ac106bf6SEd Tanous                     const std::string& id) {
7271e1e598dSJonathan Doman             if (ec)
72849e429caSJonathan Doman             {
72962598e31SEd Tanous                 BMCWEB_LOG_ERROR("Failed to read cpu unique id: {}", ec);
730ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
73149e429caSJonathan Doman                 return;
73249e429caSJonathan Doman             }
733ac106bf6SEd Tanous             asyncResp->res
734ac106bf6SEd Tanous                 .jsonValue["ProcessorId"]["ProtectedIdentificationNumber"] = id;
7351e1e598dSJonathan Doman         });
73649e429caSJonathan Doman }
73749e429caSJonathan Doman 
73898eafce5SGeorge Liu inline void handleProcessorSubtree(
73998eafce5SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
74098eafce5SGeorge Liu     const std::string& processorId,
74198eafce5SGeorge Liu     const std::function<
74298eafce5SGeorge Liu         void(const std::string& objectPath,
74398eafce5SGeorge Liu              const dbus::utility::MapperServiceMap& serviceMap)>& callback,
74498eafce5SGeorge Liu     const boost::system::error_code& ec,
74598eafce5SGeorge Liu     const dbus::utility::MapperGetSubTreeResponse& subtree)
74698eafce5SGeorge Liu {
74798eafce5SGeorge Liu     if (ec)
74898eafce5SGeorge Liu     {
74998eafce5SGeorge Liu         BMCWEB_LOG_ERROR("DBUS response error: {}", ec);
75098eafce5SGeorge Liu         messages::internalError(asyncResp->res);
75198eafce5SGeorge Liu         return;
75298eafce5SGeorge Liu     }
75398eafce5SGeorge Liu     for (const auto& [objectPath, serviceMap] : subtree)
75498eafce5SGeorge Liu     {
75598eafce5SGeorge Liu         // Ignore any objects which don't end with our desired cpu name
75698eafce5SGeorge Liu         sdbusplus::message::object_path path(objectPath);
75798eafce5SGeorge Liu         if (path.filename() == processorId)
75898eafce5SGeorge Liu         {
75998eafce5SGeorge Liu             // Filter out objects that don't have the CPU-specific
76098eafce5SGeorge Liu             // interfaces to make sure we can return 404 on non-CPUs
76198eafce5SGeorge Liu             // (e.g. /redfish/../Processors/dimm0)
76298eafce5SGeorge Liu             for (const auto& [serviceName, interfaceList] : serviceMap)
76398eafce5SGeorge Liu             {
76498eafce5SGeorge Liu                 if (std::ranges::find_first_of(interfaceList,
76598eafce5SGeorge Liu                                                processorInterfaces) !=
76698eafce5SGeorge Liu                     interfaceList.end())
76798eafce5SGeorge Liu                 {
76898eafce5SGeorge Liu                     // Process the first object which matches cpu name and
76998eafce5SGeorge Liu                     // required interfaces, and potentially ignore any other
77098eafce5SGeorge Liu                     // matching objects. Assume all interfaces we want to
77198eafce5SGeorge Liu                     // process must be on the same object path.
77298eafce5SGeorge Liu 
77398eafce5SGeorge Liu                     callback(objectPath, serviceMap);
77498eafce5SGeorge Liu                     return;
77598eafce5SGeorge Liu                 }
77698eafce5SGeorge Liu             }
77798eafce5SGeorge Liu         }
77898eafce5SGeorge Liu     }
77998eafce5SGeorge Liu     messages::resourceNotFound(asyncResp->res, "Processor", processorId);
78098eafce5SGeorge Liu }
78198eafce5SGeorge Liu 
78249e429caSJonathan Doman /**
783c951448aSJonathan Doman  * Find the D-Bus object representing the requested Processor, and call the
784c951448aSJonathan Doman  * handler with the results. If matching object is not found, add 404 error to
785c951448aSJonathan Doman  * response and don't call the handler.
786c951448aSJonathan Doman  *
78798eafce5SGeorge Liu  * @param[in,out]   asyncResp       Async HTTP response.
788c951448aSJonathan Doman  * @param[in]       processorId     Redfish Processor Id.
78998eafce5SGeorge Liu  * @param[in]       callback        Callback to continue processing request upon
790c951448aSJonathan Doman  *                                  successfully finding object.
791c951448aSJonathan Doman  */
79298eafce5SGeorge Liu inline void getProcessorObject(
79398eafce5SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
794c951448aSJonathan Doman     const std::string& processorId,
79598eafce5SGeorge Liu     std::function<void(const std::string& objectPath,
79698eafce5SGeorge Liu                        const dbus::utility::MapperServiceMap& serviceMap)>&&
79798eafce5SGeorge Liu         callback)
798ac6a4445SGunnar Mills {
79962598e31SEd Tanous     BMCWEB_LOG_DEBUG("Get available system processor resources.");
800ac6a4445SGunnar Mills 
801c951448aSJonathan Doman     // GetSubTree on all interfaces which provide info about a Processor
802dfbf7de5SChris Cain     constexpr std::array<std::string_view, 9> interfaces = {
803e99073f5SGeorge Liu         "xyz.openbmc_project.Common.UUID",
804e99073f5SGeorge Liu         "xyz.openbmc_project.Inventory.Decorator.Asset",
805e99073f5SGeorge Liu         "xyz.openbmc_project.Inventory.Decorator.Revision",
806e99073f5SGeorge Liu         "xyz.openbmc_project.Inventory.Item.Cpu",
807e99073f5SGeorge Liu         "xyz.openbmc_project.Inventory.Decorator.LocationCode",
808e99073f5SGeorge Liu         "xyz.openbmc_project.Inventory.Item.Accelerator",
809e99073f5SGeorge Liu         "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
810dfbf7de5SChris Cain         "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier",
811dfbf7de5SChris Cain         "xyz.openbmc_project.Control.Power.Throttle"};
812e99073f5SGeorge Liu     dbus::utility::getSubTree(
813e99073f5SGeorge Liu         "/xyz/openbmc_project/inventory", 0, interfaces,
81498eafce5SGeorge Liu         [asyncResp, processorId, callback{std::move(callback)}](
815e99073f5SGeorge Liu             const boost::system::error_code& ec,
816e99073f5SGeorge Liu             const dbus::utility::MapperGetSubTreeResponse& subtree) {
81798eafce5SGeorge Liu             handleProcessorSubtree(asyncResp, processorId, callback, ec,
81898eafce5SGeorge Liu                                    subtree);
819e99073f5SGeorge Liu         });
820ac6a4445SGunnar Mills }
821ac6a4445SGunnar Mills 
822bd79bce8SPatrick Williams inline void getProcessorData(
823bd79bce8SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
824bd79bce8SPatrick Williams     const std::string& processorId, const std::string& objectPath,
8255df6eda2SShantappa Teekappanavar     const dbus::utility::MapperServiceMap& serviceMap)
826c951448aSJonathan Doman {
82798eafce5SGeorge Liu     asyncResp->res.addHeader(
82898eafce5SGeorge Liu         boost::beast::http::field::link,
82998eafce5SGeorge Liu         "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
83098eafce5SGeorge Liu     asyncResp->res.jsonValue["@odata.type"] = "#Processor.v1_18_0.Processor";
83198eafce5SGeorge Liu     asyncResp->res.jsonValue["@odata.id"] =
83298eafce5SGeorge Liu         boost::urls::format("/redfish/v1/Systems/{}/Processors/{}",
83398eafce5SGeorge Liu                             BMCWEB_REDFISH_SYSTEM_URI_NAME, processorId);
83498eafce5SGeorge Liu 
835c951448aSJonathan Doman     for (const auto& [serviceName, interfaceList] : serviceMap)
836c951448aSJonathan Doman     {
837c951448aSJonathan Doman         for (const auto& interface : interfaceList)
838c951448aSJonathan Doman         {
839c951448aSJonathan Doman             if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset")
840c951448aSJonathan Doman             {
841ac106bf6SEd Tanous                 getCpuAssetData(asyncResp, serviceName, objectPath);
842c951448aSJonathan Doman             }
8430fda0f12SGeorge Liu             else if (interface ==
8440fda0f12SGeorge Liu                      "xyz.openbmc_project.Inventory.Decorator.Revision")
845c951448aSJonathan Doman             {
846ac106bf6SEd Tanous                 getCpuRevisionData(asyncResp, serviceName, objectPath);
847c951448aSJonathan Doman             }
848c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Inventory.Item.Cpu")
849c951448aSJonathan Doman             {
850ac106bf6SEd Tanous                 getCpuDataByService(asyncResp, processorId, serviceName,
851c951448aSJonathan Doman                                     objectPath);
852c951448aSJonathan Doman             }
8530fda0f12SGeorge Liu             else if (interface ==
8540fda0f12SGeorge Liu                      "xyz.openbmc_project.Inventory.Item.Accelerator")
855c951448aSJonathan Doman             {
856ac106bf6SEd Tanous                 getAcceleratorDataByService(asyncResp, processorId, serviceName,
857c951448aSJonathan Doman                                             objectPath);
858c951448aSJonathan Doman             }
8590fda0f12SGeorge Liu             else if (
8600fda0f12SGeorge Liu                 interface ==
8610fda0f12SGeorge Liu                 "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig")
862c951448aSJonathan Doman             {
863ac106bf6SEd Tanous                 getCpuConfigData(asyncResp, processorId, serviceName,
864ac106bf6SEd Tanous                                  objectPath);
865c951448aSJonathan Doman             }
8660fda0f12SGeorge Liu             else if (interface ==
8670fda0f12SGeorge Liu                      "xyz.openbmc_project.Inventory.Decorator.LocationCode")
868c951448aSJonathan Doman             {
869ac106bf6SEd Tanous                 getCpuLocationCode(asyncResp, serviceName, objectPath);
870c951448aSJonathan Doman             }
87171b82f26SSharad Yadav             else if (interface == "xyz.openbmc_project.Common.UUID")
87271b82f26SSharad Yadav             {
873ac106bf6SEd Tanous                 getProcessorUUID(asyncResp, serviceName, objectPath);
87471b82f26SSharad Yadav             }
8750fda0f12SGeorge Liu             else if (interface ==
8760fda0f12SGeorge Liu                      "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier")
87749e429caSJonathan Doman             {
878ac106bf6SEd Tanous                 getCpuUniqueId(asyncResp, serviceName, objectPath);
87949e429caSJonathan Doman             }
880dfbf7de5SChris Cain             else if (interface == "xyz.openbmc_project.Control.Power.Throttle")
881dfbf7de5SChris Cain             {
882ac106bf6SEd Tanous                 getThrottleProperties(asyncResp, serviceName, objectPath);
883dfbf7de5SChris Cain             }
88498eafce5SGeorge Liu             else if (interface == "xyz.openbmc_project.Association.Definitions")
88598eafce5SGeorge Liu             {
88698eafce5SGeorge Liu                 getLocationIndicatorActive(asyncResp, objectPath);
88798eafce5SGeorge Liu             }
888c951448aSJonathan Doman         }
889c951448aSJonathan Doman     }
890c951448aSJonathan Doman }
891c951448aSJonathan Doman 
892dba0c291SJonathan Doman /**
893dba0c291SJonathan Doman  * Request all the properties for the given D-Bus object and fill out the
894dba0c291SJonathan Doman  * related entries in the Redfish OperatingConfig response.
895dba0c291SJonathan Doman  *
896ac106bf6SEd Tanous  * @param[in,out]   asyncResp       Async HTTP response.
897dba0c291SJonathan Doman  * @param[in]       service     D-Bus service name to query.
898dba0c291SJonathan Doman  * @param[in]       objPath     D-Bus object to query.
899dba0c291SJonathan Doman  */
900bd79bce8SPatrick Williams inline void getOperatingConfigData(
901bd79bce8SPatrick Williams     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
902bd79bce8SPatrick Williams     const std::string& service, const std::string& objPath)
903dba0c291SJonathan Doman {
904deae6a78SEd Tanous     dbus::utility::getAllProperties(
905deae6a78SEd Tanous         service, objPath,
906351053f2SKrzysztof Grobelny         "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig",
907ac106bf6SEd Tanous         [asyncResp](const boost::system::error_code& ec,
908351053f2SKrzysztof Grobelny                     const dbus::utility::DBusPropertiesMap& properties) {
909dba0c291SJonathan Doman             if (ec)
910dba0c291SJonathan Doman             {
91162598e31SEd Tanous                 BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message());
912ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
913dba0c291SJonathan Doman                 return;
914dba0c291SJonathan Doman             }
915dba0c291SJonathan Doman 
916351053f2SKrzysztof Grobelny             const size_t* availableCoreCount = nullptr;
917351053f2SKrzysztof Grobelny             const uint32_t* baseSpeed = nullptr;
918351053f2SKrzysztof Grobelny             const uint32_t* maxJunctionTemperature = nullptr;
919351053f2SKrzysztof Grobelny             const uint32_t* maxSpeed = nullptr;
920351053f2SKrzysztof Grobelny             const uint32_t* powerLimit = nullptr;
921351053f2SKrzysztof Grobelny             const TurboProfileProperty* turboProfile = nullptr;
922351053f2SKrzysztof Grobelny             const BaseSpeedPrioritySettingsProperty* baseSpeedPrioritySettings =
923351053f2SKrzysztof Grobelny                 nullptr;
924351053f2SKrzysztof Grobelny 
925351053f2SKrzysztof Grobelny             const bool success = sdbusplus::unpackPropertiesNoThrow(
926bd79bce8SPatrick Williams                 dbus_utils::UnpackErrorPrinter(), properties,
927bd79bce8SPatrick Williams                 "AvailableCoreCount", availableCoreCount, "BaseSpeed",
928bd79bce8SPatrick Williams                 baseSpeed, "MaxJunctionTemperature", maxJunctionTemperature,
929bd79bce8SPatrick Williams                 "MaxSpeed", maxSpeed, "PowerLimit", powerLimit, "TurboProfile",
930bd79bce8SPatrick Williams                 turboProfile, "BaseSpeedPrioritySettings",
931bd79bce8SPatrick Williams                 baseSpeedPrioritySettings);
932351053f2SKrzysztof Grobelny 
933351053f2SKrzysztof Grobelny             if (!success)
934dba0c291SJonathan Doman             {
935ac106bf6SEd Tanous                 messages::internalError(asyncResp->res);
936351053f2SKrzysztof Grobelny                 return;
937dba0c291SJonathan Doman             }
938dba0c291SJonathan Doman 
939ac106bf6SEd Tanous             nlohmann::json& json = asyncResp->res.jsonValue;
940351053f2SKrzysztof Grobelny 
941351053f2SKrzysztof Grobelny             if (availableCoreCount != nullptr)
942351053f2SKrzysztof Grobelny             {
943351053f2SKrzysztof Grobelny                 json["TotalAvailableCoreCount"] = *availableCoreCount;
944351053f2SKrzysztof Grobelny             }
945351053f2SKrzysztof Grobelny 
946351053f2SKrzysztof Grobelny             if (baseSpeed != nullptr)
947351053f2SKrzysztof Grobelny             {
948351053f2SKrzysztof Grobelny                 json["BaseSpeedMHz"] = *baseSpeed;
949351053f2SKrzysztof Grobelny             }
950351053f2SKrzysztof Grobelny 
951351053f2SKrzysztof Grobelny             if (maxJunctionTemperature != nullptr)
952351053f2SKrzysztof Grobelny             {
953351053f2SKrzysztof Grobelny                 json["MaxJunctionTemperatureCelsius"] = *maxJunctionTemperature;
954351053f2SKrzysztof Grobelny             }
955351053f2SKrzysztof Grobelny 
956351053f2SKrzysztof Grobelny             if (maxSpeed != nullptr)
957351053f2SKrzysztof Grobelny             {
958351053f2SKrzysztof Grobelny                 json["MaxSpeedMHz"] = *maxSpeed;
959351053f2SKrzysztof Grobelny             }
960351053f2SKrzysztof Grobelny 
961351053f2SKrzysztof Grobelny             if (powerLimit != nullptr)
962351053f2SKrzysztof Grobelny             {
963351053f2SKrzysztof Grobelny                 json["TDPWatts"] = *powerLimit;
964351053f2SKrzysztof Grobelny             }
965351053f2SKrzysztof Grobelny 
966351053f2SKrzysztof Grobelny             if (turboProfile != nullptr)
967351053f2SKrzysztof Grobelny             {
968dba0c291SJonathan Doman                 nlohmann::json& turboArray = json["TurboProfile"];
969dba0c291SJonathan Doman                 turboArray = nlohmann::json::array();
970351053f2SKrzysztof Grobelny                 for (const auto& [turboSpeed, coreCount] : *turboProfile)
971dba0c291SJonathan Doman                 {
9721476687dSEd Tanous                     nlohmann::json::object_t turbo;
9731476687dSEd Tanous                     turbo["ActiveCoreCount"] = coreCount;
9741476687dSEd Tanous                     turbo["MaxSpeedMHz"] = turboSpeed;
975b2ba3072SPatrick Williams                     turboArray.emplace_back(std::move(turbo));
976dba0c291SJonathan Doman                 }
977dba0c291SJonathan Doman             }
978dba0c291SJonathan Doman 
979351053f2SKrzysztof Grobelny             if (baseSpeedPrioritySettings != nullptr)
980351053f2SKrzysztof Grobelny             {
981bd79bce8SPatrick Williams                 nlohmann::json& baseSpeedArray =
982bd79bce8SPatrick Williams                     json["BaseSpeedPrioritySettings"];
983dba0c291SJonathan Doman                 baseSpeedArray = nlohmann::json::array();
984351053f2SKrzysztof Grobelny                 for (const auto& [baseSpeedMhz, coreList] :
985351053f2SKrzysztof Grobelny                      *baseSpeedPrioritySettings)
986dba0c291SJonathan Doman                 {
9871476687dSEd Tanous                     nlohmann::json::object_t speed;
9881476687dSEd Tanous                     speed["CoreCount"] = coreList.size();
9891476687dSEd Tanous                     speed["CoreIDs"] = coreList;
990351053f2SKrzysztof Grobelny                     speed["BaseSpeedMHz"] = baseSpeedMhz;
991b2ba3072SPatrick Williams                     baseSpeedArray.emplace_back(std::move(speed));
992dba0c291SJonathan Doman                 }
993dba0c291SJonathan Doman             }
994351053f2SKrzysztof Grobelny         });
995dba0c291SJonathan Doman }
996dba0c291SJonathan Doman 
9973cde86f1SJonathan Doman /**
9983cde86f1SJonathan Doman  * Handle the PATCH operation of the AppliedOperatingConfig property. Do basic
9993cde86f1SJonathan Doman  * validation of the input data, and then set the D-Bus property.
10003cde86f1SJonathan Doman  *
10013cde86f1SJonathan Doman  * @param[in,out]   resp            Async HTTP response.
10023cde86f1SJonathan Doman  * @param[in]       processorId     Processor's Id.
10033cde86f1SJonathan Doman  * @param[in]       appliedConfigUri    New property value to apply.
10043cde86f1SJonathan Doman  * @param[in]       cpuObjectPath   Path of CPU object to modify.
10053cde86f1SJonathan Doman  * @param[in]       serviceMap      Service map for CPU object.
10063cde86f1SJonathan Doman  */
10073cde86f1SJonathan Doman inline void patchAppliedOperatingConfig(
10083cde86f1SJonathan Doman     const std::shared_ptr<bmcweb::AsyncResp>& resp,
10093cde86f1SJonathan Doman     const std::string& processorId, const std::string& appliedConfigUri,
10105df6eda2SShantappa Teekappanavar     const std::string& cpuObjectPath,
10115df6eda2SShantappa Teekappanavar     const dbus::utility::MapperServiceMap& serviceMap)
10123cde86f1SJonathan Doman {
10133cde86f1SJonathan Doman     // Check that the property even exists by checking for the interface
10143cde86f1SJonathan Doman     const std::string* controlService = nullptr;
10153cde86f1SJonathan Doman     for (const auto& [serviceName, interfaceList] : serviceMap)
10163cde86f1SJonathan Doman     {
10173544d2a7SEd Tanous         if (std::ranges::find(interfaceList,
10183cde86f1SJonathan Doman                               "xyz.openbmc_project.Control.Processor."
10193cde86f1SJonathan Doman                               "CurrentOperatingConfig") != interfaceList.end())
10203cde86f1SJonathan Doman         {
10213cde86f1SJonathan Doman             controlService = &serviceName;
10223cde86f1SJonathan Doman             break;
10233cde86f1SJonathan Doman         }
10243cde86f1SJonathan Doman     }
10253cde86f1SJonathan Doman 
10263cde86f1SJonathan Doman     if (controlService == nullptr)
10273cde86f1SJonathan Doman     {
10283cde86f1SJonathan Doman         messages::internalError(resp->res);
10293cde86f1SJonathan Doman         return;
10303cde86f1SJonathan Doman     }
10313cde86f1SJonathan Doman 
10323cde86f1SJonathan Doman     // Check that the config URI is a child of the cpu URI being patched.
1033253f11b8SEd Tanous     std::string expectedPrefix(std::format("/redfish/v1/Systems/{}/Processors/",
1034253f11b8SEd Tanous                                            BMCWEB_REDFISH_SYSTEM_URI_NAME));
10353cde86f1SJonathan Doman     expectedPrefix += processorId;
10363cde86f1SJonathan Doman     expectedPrefix += "/OperatingConfigs/";
103711ba3979SEd Tanous     if (!appliedConfigUri.starts_with(expectedPrefix) ||
10383cde86f1SJonathan Doman         expectedPrefix.size() == appliedConfigUri.size())
10393cde86f1SJonathan Doman     {
104087c44966SAsmitha Karunanithi         messages::propertyValueIncorrect(resp->res, "AppliedOperatingConfig",
104187c44966SAsmitha Karunanithi                                          appliedConfigUri);
10423cde86f1SJonathan Doman         return;
10433cde86f1SJonathan Doman     }
10443cde86f1SJonathan Doman 
10453cde86f1SJonathan Doman     // Generate the D-Bus path of the OperatingConfig object, by assuming it's a
10463cde86f1SJonathan Doman     // direct child of the CPU object.
10473cde86f1SJonathan Doman     // Strip the expectedPrefix from the config URI to get the "filename", and
10483cde86f1SJonathan Doman     // append to the CPU's path.
10493cde86f1SJonathan Doman     std::string configBaseName = appliedConfigUri.substr(expectedPrefix.size());
10503cde86f1SJonathan Doman     sdbusplus::message::object_path configPath(cpuObjectPath);
10513cde86f1SJonathan Doman     configPath /= configBaseName;
10523cde86f1SJonathan Doman 
105362598e31SEd Tanous     BMCWEB_LOG_INFO("Setting config to {}", configPath.str);
10543cde86f1SJonathan Doman 
10553cde86f1SJonathan Doman     // Set the property, with handler to check error responses
105687c44966SAsmitha Karunanithi     setDbusProperty(
1057e93abac6SGinu George         resp, "AppliedOperatingConfig", *controlService, cpuObjectPath,
10589ae226faSGeorge Liu         "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
1059e93abac6SGinu George         "AppliedConfig", configPath);
10603cde86f1SJonathan Doman }
10613cde86f1SJonathan Doman 
1062bd79bce8SPatrick Williams inline void handleProcessorHead(
1063bd79bce8SPatrick Williams     crow::App& app, const crow::Request& req,
1064ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1065bd79bce8SPatrick Williams     const std::string& /* systemName */, const std::string& /* processorId */)
106671a24ca4SNikhil Namjoshi {
1067ac106bf6SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
106871a24ca4SNikhil Namjoshi     {
106971a24ca4SNikhil Namjoshi         return;
107071a24ca4SNikhil Namjoshi     }
1071ac106bf6SEd Tanous     asyncResp->res.addHeader(
107271a24ca4SNikhil Namjoshi         boost::beast::http::field::link,
107371a24ca4SNikhil Namjoshi         "</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
107471a24ca4SNikhil Namjoshi }
107571a24ca4SNikhil Namjoshi 
107671a24ca4SNikhil Namjoshi inline void handleProcessorCollectionHead(
107771a24ca4SNikhil Namjoshi     crow::App& app, const crow::Request& req,
1078ac106bf6SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
107971a24ca4SNikhil Namjoshi     const std::string& /* systemName */)
108071a24ca4SNikhil Namjoshi {
1081ac106bf6SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
108271a24ca4SNikhil Namjoshi     {
108371a24ca4SNikhil Namjoshi         return;
108471a24ca4SNikhil Namjoshi     }
1085ac106bf6SEd Tanous     asyncResp->res.addHeader(
108671a24ca4SNikhil Namjoshi         boost::beast::http::field::link,
108771a24ca4SNikhil Namjoshi         "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby");
108871a24ca4SNikhil Namjoshi }
108971a24ca4SNikhil Namjoshi 
109098eafce5SGeorge Liu inline void handleProcessorGet(
109198eafce5SGeorge Liu     App& app, const crow::Request& req,
109298eafce5SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
109398eafce5SGeorge Liu     const std::string& systemName, const std::string& processorId)
109498eafce5SGeorge Liu {
109598eafce5SGeorge Liu     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
109698eafce5SGeorge Liu     {
109798eafce5SGeorge Liu         return;
109898eafce5SGeorge Liu     }
109998eafce5SGeorge Liu     if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
110098eafce5SGeorge Liu     {
110198eafce5SGeorge Liu         // Option currently returns no systems.  TBD
110298eafce5SGeorge Liu         messages::resourceNotFound(asyncResp->res, "ComputerSystem",
110398eafce5SGeorge Liu                                    systemName);
110498eafce5SGeorge Liu         return;
110598eafce5SGeorge Liu     }
110698eafce5SGeorge Liu     if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
110798eafce5SGeorge Liu     {
110898eafce5SGeorge Liu         messages::resourceNotFound(asyncResp->res, "ComputerSystem",
110998eafce5SGeorge Liu                                    systemName);
111098eafce5SGeorge Liu         return;
111198eafce5SGeorge Liu     }
111298eafce5SGeorge Liu 
111398eafce5SGeorge Liu     getProcessorObject(
111498eafce5SGeorge Liu         asyncResp, processorId,
111598eafce5SGeorge Liu         std::bind_front(getProcessorData, asyncResp, processorId));
111698eafce5SGeorge Liu }
111798eafce5SGeorge Liu 
111898eafce5SGeorge Liu inline void doPatchProcessor(
111998eafce5SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
112098eafce5SGeorge Liu     const std::string& processorId,
112198eafce5SGeorge Liu     const std::optional<std::string>& appliedConfigUri,
112298eafce5SGeorge Liu     std::optional<bool> locationIndicatorActive, const std::string& objectPath,
112398eafce5SGeorge Liu     const dbus::utility::MapperServiceMap& serviceMap)
112498eafce5SGeorge Liu {
112598eafce5SGeorge Liu     if (appliedConfigUri)
112698eafce5SGeorge Liu     {
112798eafce5SGeorge Liu         patchAppliedOperatingConfig(asyncResp, processorId, *appliedConfigUri,
112898eafce5SGeorge Liu                                     objectPath, serviceMap);
112998eafce5SGeorge Liu     }
113098eafce5SGeorge Liu 
113198eafce5SGeorge Liu     if (locationIndicatorActive)
113298eafce5SGeorge Liu     {
113398eafce5SGeorge Liu         // Utility function handles reporting errors
113498eafce5SGeorge Liu         setLocationIndicatorActive(asyncResp, objectPath,
113598eafce5SGeorge Liu                                    *locationIndicatorActive);
113698eafce5SGeorge Liu     }
113798eafce5SGeorge Liu }
113898eafce5SGeorge Liu 
113998eafce5SGeorge Liu inline void handleProcessorPatch(
114098eafce5SGeorge Liu     App& app, const crow::Request& req,
114198eafce5SGeorge Liu     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
114298eafce5SGeorge Liu     const std::string& systemName, const std::string& processorId)
114398eafce5SGeorge Liu {
114498eafce5SGeorge Liu     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
114598eafce5SGeorge Liu     {
114698eafce5SGeorge Liu         return;
114798eafce5SGeorge Liu     }
114898eafce5SGeorge Liu     if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
114998eafce5SGeorge Liu     {
115098eafce5SGeorge Liu         // Option currently returns no systems.  TBD
115198eafce5SGeorge Liu         messages::resourceNotFound(asyncResp->res, "ComputerSystem",
115298eafce5SGeorge Liu                                    systemName);
115398eafce5SGeorge Liu         return;
115498eafce5SGeorge Liu     }
115598eafce5SGeorge Liu     if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
115698eafce5SGeorge Liu     {
115798eafce5SGeorge Liu         messages::resourceNotFound(asyncResp->res, "ComputerSystem",
115898eafce5SGeorge Liu                                    systemName);
115998eafce5SGeorge Liu         return;
116098eafce5SGeorge Liu     }
116198eafce5SGeorge Liu 
116298eafce5SGeorge Liu     std::optional<std::string> appliedConfigUri;
116398eafce5SGeorge Liu     std::optional<bool> locationIndicatorActive;
116498eafce5SGeorge Liu     if (!json_util::readJsonPatch(
116598eafce5SGeorge Liu             req, asyncResp->res,                                  //
116698eafce5SGeorge Liu             "AppliedOperatingConfig/@odata.id", appliedConfigUri, //
116798eafce5SGeorge Liu             "LocationIndicatorActive", locationIndicatorActive    //
116898eafce5SGeorge Liu             ))
116998eafce5SGeorge Liu     {
117098eafce5SGeorge Liu         return;
117198eafce5SGeorge Liu     }
117298eafce5SGeorge Liu 
117398eafce5SGeorge Liu     // Check for 404 and find matching D-Bus object, then run
117498eafce5SGeorge Liu     // property patch handlers if that all succeeds.
117598eafce5SGeorge Liu     getProcessorObject(
117698eafce5SGeorge Liu         asyncResp, processorId,
117798eafce5SGeorge Liu         std::bind_front(doPatchProcessor, asyncResp, processorId,
117898eafce5SGeorge Liu                         appliedConfigUri, locationIndicatorActive));
117998eafce5SGeorge Liu }
118098eafce5SGeorge Liu 
11817e860f15SJohn Edward Broadbent inline void requestRoutesOperatingConfigCollection(App& app)
1182dba0c291SJonathan Doman {
11837f3e84a1SEd Tanous     BMCWEB_ROUTE(app,
11847f3e84a1SEd Tanous                  "/redfish/v1/Systems/<str>/Processors/<str>/OperatingConfigs/")
1185ed398213SEd Tanous         .privileges(redfish::privileges::getOperatingConfigCollection)
1186bd79bce8SPatrick Williams         .methods(
1187bd79bce8SPatrick Williams             boost::beast::http::verb::
1188bd79bce8SPatrick Williams                 get)([&app](const crow::Request& req,
118945ca1b86SEd Tanous                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1190bd79bce8SPatrick Williams                             const std::string& systemName,
1191bd79bce8SPatrick Williams                             const std::string& cpuName) {
11923ba00073SCarson Labrado             if (!redfish::setUpRedfishRoute(app, req, asyncResp))
119345ca1b86SEd Tanous             {
119445ca1b86SEd Tanous                 return;
119545ca1b86SEd Tanous             }
11967f3e84a1SEd Tanous 
119725b54dbaSEd Tanous             if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
11987f3e84a1SEd Tanous             {
11997f3e84a1SEd Tanous                 // Option currently returns no systems.  TBD
12007f3e84a1SEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
12017f3e84a1SEd Tanous                                            systemName);
12027f3e84a1SEd Tanous                 return;
12037f3e84a1SEd Tanous             }
12047f3e84a1SEd Tanous 
1205253f11b8SEd Tanous             if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
12067f3e84a1SEd Tanous             {
12077f3e84a1SEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
12087f3e84a1SEd Tanous                                            systemName);
12097f3e84a1SEd Tanous                 return;
12107f3e84a1SEd Tanous             }
12118d1b46d7Szhanghch05             asyncResp->res.jsonValue["@odata.type"] =
1212dba0c291SJonathan Doman                 "#OperatingConfigCollection.OperatingConfigCollection";
1213ef4c65b7SEd Tanous             asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
1214253f11b8SEd Tanous                 "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
1215253f11b8SEd Tanous                 BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName);
12160fda0f12SGeorge Liu             asyncResp->res.jsonValue["Name"] = "Operating Config Collection";
1217dba0c291SJonathan Doman 
12187e860f15SJohn Edward Broadbent             // First find the matching CPU object so we know how to
12197e860f15SJohn Edward Broadbent             // constrain our search for related Config objects.
12207a1dbc48SGeorge Liu             const std::array<std::string_view, 1> interfaces = {
12217a1dbc48SGeorge Liu                 "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"};
12227a1dbc48SGeorge Liu             dbus::utility::getSubTreePaths(
12237a1dbc48SGeorge Liu                 "/xyz/openbmc_project/inventory", 0, interfaces,
1224bd79bce8SPatrick Williams                 [asyncResp,
1225bd79bce8SPatrick Williams                  cpuName](const boost::system::error_code& ec,
1226bd79bce8SPatrick Williams                           const dbus::utility::MapperGetSubTreePathsResponse&
1227bd79bce8SPatrick Williams                               objects) {
1228dba0c291SJonathan Doman                     if (ec)
1229dba0c291SJonathan Doman                     {
1230bd79bce8SPatrick Williams                         BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec,
1231bd79bce8SPatrick Williams                                            ec.message());
1232dba0c291SJonathan Doman                         messages::internalError(asyncResp->res);
1233dba0c291SJonathan Doman                         return;
1234dba0c291SJonathan Doman                     }
1235dba0c291SJonathan Doman 
1236dba0c291SJonathan Doman                     for (const std::string& object : objects)
1237dba0c291SJonathan Doman                     {
123811ba3979SEd Tanous                         if (!object.ends_with(cpuName))
1239dba0c291SJonathan Doman                         {
1240dba0c291SJonathan Doman                             continue;
1241dba0c291SJonathan Doman                         }
1242dba0c291SJonathan Doman 
12437e860f15SJohn Edward Broadbent                         // Not expected that there will be multiple matching
12447e860f15SJohn Edward Broadbent                         // CPU objects, but if there are just use the first
12457e860f15SJohn Edward Broadbent                         // one.
1246dba0c291SJonathan Doman 
12477e860f15SJohn Edward Broadbent                         // Use the common search routine to construct the
12487e860f15SJohn Edward Broadbent                         // Collection of all Config objects under this CPU.
12497a1dbc48SGeorge Liu                         constexpr std::array<std::string_view, 1> interface{
12505a39f77aSPatrick Williams                             "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
1251dba0c291SJonathan Doman                         collection_util::getCollectionMembers(
1252dba0c291SJonathan Doman                             asyncResp,
1253ef4c65b7SEd Tanous                             boost::urls::format(
1254253f11b8SEd Tanous                                 "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs",
1255253f11b8SEd Tanous                                 BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName),
125636b5f1edSLakshmi Yadlapati                             interface, object);
1257dba0c291SJonathan Doman                         return;
1258dba0c291SJonathan Doman                     }
12597a1dbc48SGeorge Liu                 });
12607e860f15SJohn Edward Broadbent         });
1261dba0c291SJonathan Doman }
1262dba0c291SJonathan Doman 
12637e860f15SJohn Edward Broadbent inline void requestRoutesOperatingConfig(App& app)
1264dba0c291SJonathan Doman {
12657e860f15SJohn Edward Broadbent     BMCWEB_ROUTE(
12667e860f15SJohn Edward Broadbent         app,
12677f3e84a1SEd Tanous         "/redfish/v1/Systems/<str>/Processors/<str>/OperatingConfigs/<str>/")
1268ed398213SEd Tanous         .privileges(redfish::privileges::getOperatingConfig)
1269bd79bce8SPatrick Williams         .methods(
1270bd79bce8SPatrick Williams             boost::beast::http::verb::
1271bd79bce8SPatrick Williams                 get)([&app](const crow::Request& req,
127245ca1b86SEd Tanous                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
1273bd79bce8SPatrick Williams                             const std::string& systemName,
1274bd79bce8SPatrick Williams                             const std::string& cpuName,
12757f3e84a1SEd Tanous                             const std::string& configName) {
12763ba00073SCarson Labrado             if (!redfish::setUpRedfishRoute(app, req, asyncResp))
127745ca1b86SEd Tanous             {
127845ca1b86SEd Tanous                 return;
127945ca1b86SEd Tanous             }
128025b54dbaSEd Tanous             if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
12817f3e84a1SEd Tanous             {
12827f3e84a1SEd Tanous                 // Option currently returns no systems.  TBD
12837f3e84a1SEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
12847f3e84a1SEd Tanous                                            systemName);
12857f3e84a1SEd Tanous                 return;
12867f3e84a1SEd Tanous             }
12877f3e84a1SEd Tanous 
1288253f11b8SEd Tanous             if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
12897f3e84a1SEd Tanous             {
12907f3e84a1SEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
12917f3e84a1SEd Tanous                                            systemName);
12927f3e84a1SEd Tanous                 return;
12937f3e84a1SEd Tanous             }
12947e860f15SJohn Edward Broadbent             // Ask for all objects implementing OperatingConfig so we can search
12957e860f15SJohn Edward Broadbent             // for one with a matching name
1296e99073f5SGeorge Liu             constexpr std::array<std::string_view, 1> interfaces = {
1297e99073f5SGeorge Liu                 "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"};
1298e99073f5SGeorge Liu             dbus::utility::getSubTree(
1299e99073f5SGeorge Liu                 "/xyz/openbmc_project/inventory", 0, interfaces,
130039662a3bSEd Tanous                 [asyncResp, cpuName, configName](
1301e99073f5SGeorge Liu                     const boost::system::error_code& ec,
13025df6eda2SShantappa Teekappanavar                     const dbus::utility::MapperGetSubTreeResponse& subtree) {
1303dba0c291SJonathan Doman                     if (ec)
1304dba0c291SJonathan Doman                     {
1305bd79bce8SPatrick Williams                         BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec,
1306bd79bce8SPatrick Williams                                            ec.message());
1307dba0c291SJonathan Doman                         messages::internalError(asyncResp->res);
1308dba0c291SJonathan Doman                         return;
1309dba0c291SJonathan Doman                     }
1310bd79bce8SPatrick Williams                     const std::string expectedEnding =
1311bd79bce8SPatrick Williams                         cpuName + '/' + configName;
1312dba0c291SJonathan Doman                     for (const auto& [objectPath, serviceMap] : subtree)
1313dba0c291SJonathan Doman                     {
1314dba0c291SJonathan Doman                         // Ignore any configs without matching cpuX/configY
1315bd79bce8SPatrick Williams                         if (!objectPath.ends_with(expectedEnding) ||
1316bd79bce8SPatrick Williams                             serviceMap.empty())
1317dba0c291SJonathan Doman                         {
1318dba0c291SJonathan Doman                             continue;
1319dba0c291SJonathan Doman                         }
1320dba0c291SJonathan Doman 
1321dba0c291SJonathan Doman                         nlohmann::json& json = asyncResp->res.jsonValue;
1322bd79bce8SPatrick Williams                         json["@odata.type"] =
1323bd79bce8SPatrick Williams                             "#OperatingConfig.v1_0_0.OperatingConfig";
1324ef4c65b7SEd Tanous                         json["@odata.id"] = boost::urls::format(
1325253f11b8SEd Tanous                             "/redfish/v1/Systems/{}/Processors/{}/OperatingConfigs/{}",
1326bd79bce8SPatrick Williams                             BMCWEB_REDFISH_SYSTEM_URI_NAME, cpuName,
1327bd79bce8SPatrick Williams                             configName);
1328dba0c291SJonathan Doman                         json["Name"] = "Processor Profile";
1329dba0c291SJonathan Doman                         json["Id"] = configName;
1330dba0c291SJonathan Doman 
1331dba0c291SJonathan Doman                         // Just use the first implementation of the object - not
13327e860f15SJohn Edward Broadbent                         // expected that there would be multiple matching
13337e860f15SJohn Edward Broadbent                         // services
1334bd79bce8SPatrick Williams                         getOperatingConfigData(
1335bd79bce8SPatrick Williams                             asyncResp, serviceMap.begin()->first, objectPath);
1336dba0c291SJonathan Doman                         return;
1337dba0c291SJonathan Doman                     }
1338bd79bce8SPatrick Williams                     messages::resourceNotFound(asyncResp->res,
1339bd79bce8SPatrick Williams                                                "OperatingConfig", configName);
1340e99073f5SGeorge Liu                 });
13417e860f15SJohn Edward Broadbent         });
1342ac6a4445SGunnar Mills }
1343ac6a4445SGunnar Mills 
13447e860f15SJohn Edward Broadbent inline void requestRoutesProcessorCollection(App& app)
13457e860f15SJohn Edward Broadbent {
1346ac6a4445SGunnar Mills     /**
1347ac6a4445SGunnar Mills      * Functions triggers appropriate requests on DBus
1348ac6a4445SGunnar Mills      */
134922d268cbSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/")
135071a24ca4SNikhil Namjoshi         .privileges(redfish::privileges::headProcessorCollection)
135171a24ca4SNikhil Namjoshi         .methods(boost::beast::http::verb::head)(
135271a24ca4SNikhil Namjoshi             std::bind_front(handleProcessorCollectionHead, std::ref(app)));
135371a24ca4SNikhil Namjoshi 
135471a24ca4SNikhil Namjoshi     BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/")
1355ed398213SEd Tanous         .privileges(redfish::privileges::getProcessorCollection)
1356bd79bce8SPatrick Williams         .methods(
1357bd79bce8SPatrick Williams             boost::beast::http::verb::
1358bd79bce8SPatrick Williams                 get)([&app](const crow::Request& req,
135922d268cbSEd Tanous                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
136022d268cbSEd Tanous                             const std::string& systemName) {
13613ba00073SCarson Labrado             if (!redfish::setUpRedfishRoute(app, req, asyncResp))
136245ca1b86SEd Tanous             {
136345ca1b86SEd Tanous                 return;
136445ca1b86SEd Tanous             }
136525b54dbaSEd Tanous             if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM)
13667f3e84a1SEd Tanous             {
13677f3e84a1SEd Tanous                 // Option currently returns no systems.  TBD
13687f3e84a1SEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
13697f3e84a1SEd Tanous                                            systemName);
13707f3e84a1SEd Tanous                 return;
13717f3e84a1SEd Tanous             }
13727f3e84a1SEd Tanous 
1373253f11b8SEd Tanous             if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME)
137422d268cbSEd Tanous             {
137522d268cbSEd Tanous                 messages::resourceNotFound(asyncResp->res, "ComputerSystem",
137622d268cbSEd Tanous                                            systemName);
137722d268cbSEd Tanous                 return;
137822d268cbSEd Tanous             }
137922d268cbSEd Tanous 
138071a24ca4SNikhil Namjoshi             asyncResp->res.addHeader(
138171a24ca4SNikhil Namjoshi                 boost::beast::http::field::link,
138271a24ca4SNikhil Namjoshi                 "</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby");
138371a24ca4SNikhil Namjoshi 
13848d1b46d7Szhanghch05             asyncResp->res.jsonValue["@odata.type"] =
1385ac6a4445SGunnar Mills                 "#ProcessorCollection.ProcessorCollection";
13868d1b46d7Szhanghch05             asyncResp->res.jsonValue["Name"] = "Processor Collection";
1387ac6a4445SGunnar Mills 
13888d1b46d7Szhanghch05             asyncResp->res.jsonValue["@odata.id"] =
1389253f11b8SEd Tanous                 std::format("/redfish/v1/Systems/{}/Processors",
1390253f11b8SEd Tanous                             BMCWEB_REDFISH_SYSTEM_URI_NAME);
1391ac6a4445SGunnar Mills 
139205030b8eSGunnar Mills             collection_util::getCollectionMembers(
1393ae9031f0SWilly Tu                 asyncResp,
1394253f11b8SEd Tanous                 boost::urls::format("/redfish/v1/Systems/{}/Processors",
1395253f11b8SEd Tanous                                     BMCWEB_REDFISH_SYSTEM_URI_NAME),
139636b5f1edSLakshmi Yadlapati                 processorInterfaces, "/xyz/openbmc_project/inventory");
13977e860f15SJohn Edward Broadbent         });
1398ac6a4445SGunnar Mills }
1399ac6a4445SGunnar Mills 
14007e860f15SJohn Edward Broadbent inline void requestRoutesProcessor(App& app)
14017e860f15SJohn Edward Broadbent {
1402ac6a4445SGunnar Mills     /**
1403ac6a4445SGunnar Mills      * Functions triggers appropriate requests on DBus
1404ac6a4445SGunnar Mills      */
14057e860f15SJohn Edward Broadbent 
140622d268cbSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/")
140771a24ca4SNikhil Namjoshi         .privileges(redfish::privileges::headProcessor)
140871a24ca4SNikhil Namjoshi         .methods(boost::beast::http::verb::head)(
140971a24ca4SNikhil Namjoshi             std::bind_front(handleProcessorHead, std::ref(app)));
141071a24ca4SNikhil Namjoshi 
141171a24ca4SNikhil Namjoshi     BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/")
1412ed398213SEd Tanous         .privileges(redfish::privileges::getProcessor)
141398eafce5SGeorge Liu         .methods(boost::beast::http::verb::get)(
141498eafce5SGeorge Liu             std::bind_front(handleProcessorGet, std::ref(app)));
14153cde86f1SJonathan Doman 
141622d268cbSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Processors/<str>/")
1417ed398213SEd Tanous         .privileges(redfish::privileges::patchProcessor)
14187e860f15SJohn Edward Broadbent         .methods(boost::beast::http::verb::patch)(
141998eafce5SGeorge Liu             std::bind_front(handleProcessorPatch, std::ref(app)));
14203cde86f1SJonathan Doman }
1421ac6a4445SGunnar Mills 
1422ac6a4445SGunnar Mills } // namespace redfish
1423