xref: /openbmc/bmcweb/features/redfish/lib/processor.hpp (revision c951448acb5c81a69569326c080b1a50e5678cbf)
1ac6a4445SGunnar Mills /*
2ac6a4445SGunnar Mills // Copyright (c) 2018 Intel Corporation
3ac6a4445SGunnar Mills //
4ac6a4445SGunnar Mills // Licensed under the Apache License, Version 2.0 (the "License");
5ac6a4445SGunnar Mills // you may not use this file except in compliance with the License.
6ac6a4445SGunnar Mills // You may obtain a copy of the License at
7ac6a4445SGunnar Mills //
8ac6a4445SGunnar Mills //      http://www.apache.org/licenses/LICENSE-2.0
9ac6a4445SGunnar Mills //
10ac6a4445SGunnar Mills // Unless required by applicable law or agreed to in writing, software
11ac6a4445SGunnar Mills // distributed under the License is distributed on an "AS IS" BASIS,
12ac6a4445SGunnar Mills // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ac6a4445SGunnar Mills // See the License for the specific language governing permissions and
14ac6a4445SGunnar Mills // limitations under the License.
15ac6a4445SGunnar Mills */
16ac6a4445SGunnar Mills #pragma once
17ac6a4445SGunnar Mills 
18ac6a4445SGunnar Mills #include "health.hpp"
19ac6a4445SGunnar Mills 
20ac6a4445SGunnar Mills #include <boost/container/flat_map.hpp>
21ac6a4445SGunnar Mills #include <node.hpp>
22dba0c291SJonathan Doman #include <sdbusplus/message/native_types.hpp>
23dba0c291SJonathan Doman #include <sdbusplus/utility/dedup_variant.hpp>
24ac6a4445SGunnar Mills #include <utils/collection.hpp>
25ac6a4445SGunnar Mills #include <utils/json_utils.hpp>
26ac6a4445SGunnar Mills 
27ac6a4445SGunnar Mills namespace redfish
28ac6a4445SGunnar Mills {
29ac6a4445SGunnar Mills 
30ac6a4445SGunnar Mills using InterfacesProperties = boost::container::flat_map<
31ac6a4445SGunnar Mills     std::string,
32ac6a4445SGunnar Mills     boost::container::flat_map<std::string, dbus::utility::DbusVariantType>>;
33ac6a4445SGunnar Mills 
34*c951448aSJonathan Doman // Map of service name to list of interfaces
35*c951448aSJonathan Doman using MapperServiceMap =
36*c951448aSJonathan Doman     std::vector<std::pair<std::string, std::vector<std::string>>>;
37*c951448aSJonathan Doman 
38*c951448aSJonathan Doman // Map of object paths to MapperServiceMaps
39*c951448aSJonathan Doman using MapperGetSubTreeResponse =
40*c951448aSJonathan Doman     std::vector<std::pair<std::string, MapperServiceMap>>;
41*c951448aSJonathan Doman 
42*c951448aSJonathan Doman // Interfaces which imply a D-Bus object represents a Processor
43*c951448aSJonathan Doman constexpr std::array<const char*, 2> processorInterfaces = {
44*c951448aSJonathan Doman     "xyz.openbmc_project.Inventory.Item.Cpu",
45*c951448aSJonathan Doman     "xyz.openbmc_project.Inventory.Item.Accelerator"};
462bab9831SJonathan Doman 
47ac6a4445SGunnar Mills inline void
48ac6a4445SGunnar Mills     getCpuDataByInterface(const std::shared_ptr<AsyncResp>& aResp,
49ac6a4445SGunnar Mills                           const InterfacesProperties& cpuInterfacesProperties)
50ac6a4445SGunnar Mills {
51ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG << "Get CPU resources by interface.";
52ac6a4445SGunnar Mills 
53ac6a4445SGunnar Mills     // Added for future purpose. Once present and functional attributes added
54ac6a4445SGunnar Mills     // in busctl call, need to add actual logic to fetch original values.
55ac6a4445SGunnar Mills     bool present = false;
56ac6a4445SGunnar Mills     const bool functional = true;
57ac6a4445SGunnar Mills     auto health = std::make_shared<HealthPopulate>(aResp);
58ac6a4445SGunnar Mills     health->populate();
59ac6a4445SGunnar Mills 
60ac6a4445SGunnar Mills     for (const auto& interface : cpuInterfacesProperties)
61ac6a4445SGunnar Mills     {
62ac6a4445SGunnar Mills         for (const auto& property : interface.second)
63ac6a4445SGunnar Mills         {
64ac6a4445SGunnar Mills             if (property.first == "CoreCount")
65ac6a4445SGunnar Mills             {
66ac6a4445SGunnar Mills                 const uint16_t* coresCount =
67ac6a4445SGunnar Mills                     std::get_if<uint16_t>(&property.second);
68ac6a4445SGunnar Mills                 if (coresCount == nullptr)
69ac6a4445SGunnar Mills                 {
70ac6a4445SGunnar Mills                     // Important property not in desired type
71ac6a4445SGunnar Mills                     messages::internalError(aResp->res);
72ac6a4445SGunnar Mills                     return;
73ac6a4445SGunnar Mills                 }
74ac6a4445SGunnar Mills                 if (*coresCount == 0)
75ac6a4445SGunnar Mills                 {
76ac6a4445SGunnar Mills                     // Slot is not populated, set status end return
77ac6a4445SGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "Absent";
78ac6a4445SGunnar Mills                     // HTTP Code will be set up automatically, just return
79ac6a4445SGunnar Mills                     return;
80ac6a4445SGunnar Mills                 }
81ac6a4445SGunnar Mills                 aResp->res.jsonValue["Status"]["State"] = "Enabled";
82ac6a4445SGunnar Mills                 present = true;
83ac6a4445SGunnar Mills                 aResp->res.jsonValue["TotalCores"] = *coresCount;
84ac6a4445SGunnar Mills             }
85dc3fa667SJonathan Doman             else if (property.first == "MaxSpeedInMhz")
86dc3fa667SJonathan Doman             {
87dc3fa667SJonathan Doman                 const uint32_t* value = std::get_if<uint32_t>(&property.second);
88dc3fa667SJonathan Doman                 if (value != nullptr)
89dc3fa667SJonathan Doman                 {
90dc3fa667SJonathan Doman                     aResp->res.jsonValue["MaxSpeedMHz"] = *value;
91dc3fa667SJonathan Doman                 }
92dc3fa667SJonathan Doman             }
93ac6a4445SGunnar Mills             else if (property.first == "Socket")
94ac6a4445SGunnar Mills             {
95ac6a4445SGunnar Mills                 const std::string* value =
96ac6a4445SGunnar Mills                     std::get_if<std::string>(&property.second);
97ac6a4445SGunnar Mills                 if (value != nullptr)
98ac6a4445SGunnar Mills                 {
99ac6a4445SGunnar Mills                     aResp->res.jsonValue["Socket"] = *value;
100ac6a4445SGunnar Mills                 }
101ac6a4445SGunnar Mills             }
102ac6a4445SGunnar Mills             else if (property.first == "ThreadCount")
103ac6a4445SGunnar Mills             {
104dc3fa667SJonathan Doman                 const uint16_t* value = std::get_if<uint16_t>(&property.second);
105ac6a4445SGunnar Mills                 if (value != nullptr)
106ac6a4445SGunnar Mills                 {
107ac6a4445SGunnar Mills                     aResp->res.jsonValue["TotalThreads"] = *value;
108ac6a4445SGunnar Mills                 }
109ac6a4445SGunnar Mills             }
110ac6a4445SGunnar Mills             else if (property.first == "Family")
111ac6a4445SGunnar Mills             {
112ac6a4445SGunnar Mills                 const std::string* value =
113ac6a4445SGunnar Mills                     std::get_if<std::string>(&property.second);
114ac6a4445SGunnar Mills                 if (value != nullptr)
115ac6a4445SGunnar Mills                 {
116ac6a4445SGunnar Mills                     aResp->res.jsonValue["ProcessorId"]["EffectiveFamily"] =
117ac6a4445SGunnar Mills                         *value;
118ac6a4445SGunnar Mills                 }
119ac6a4445SGunnar Mills             }
120ac6a4445SGunnar Mills             else if (property.first == "Id")
121ac6a4445SGunnar Mills             {
122ac6a4445SGunnar Mills                 const uint64_t* value = std::get_if<uint64_t>(&property.second);
123ac6a4445SGunnar Mills                 if (value != nullptr && *value != 0)
124ac6a4445SGunnar Mills                 {
125ac6a4445SGunnar Mills                     present = true;
126ac6a4445SGunnar Mills                     aResp->res
127ac6a4445SGunnar Mills                         .jsonValue["ProcessorId"]["IdentificationRegisters"] =
128ac6a4445SGunnar Mills                         boost::lexical_cast<std::string>(*value);
129ac6a4445SGunnar Mills                 }
130ac6a4445SGunnar Mills             }
131ac6a4445SGunnar Mills         }
132ac6a4445SGunnar Mills     }
133ac6a4445SGunnar Mills 
134ac6a4445SGunnar Mills     if (present == false)
135ac6a4445SGunnar Mills     {
136ac6a4445SGunnar Mills         aResp->res.jsonValue["Status"]["State"] = "Absent";
137ac6a4445SGunnar Mills         aResp->res.jsonValue["Status"]["Health"] = "OK";
138ac6a4445SGunnar Mills     }
139ac6a4445SGunnar Mills     else
140ac6a4445SGunnar Mills     {
141ac6a4445SGunnar Mills         aResp->res.jsonValue["Status"]["State"] = "Enabled";
142ac6a4445SGunnar Mills         if (functional)
143ac6a4445SGunnar Mills         {
144ac6a4445SGunnar Mills             aResp->res.jsonValue["Status"]["Health"] = "OK";
145ac6a4445SGunnar Mills         }
146ac6a4445SGunnar Mills         else
147ac6a4445SGunnar Mills         {
148ac6a4445SGunnar Mills             aResp->res.jsonValue["Status"]["Health"] = "Critical";
149ac6a4445SGunnar Mills         }
150ac6a4445SGunnar Mills     }
151ac6a4445SGunnar Mills 
152ac6a4445SGunnar Mills     return;
153ac6a4445SGunnar Mills }
154ac6a4445SGunnar Mills 
155ac6a4445SGunnar Mills inline void getCpuDataByService(std::shared_ptr<AsyncResp> aResp,
156ac6a4445SGunnar Mills                                 const std::string& cpuId,
157ac6a4445SGunnar Mills                                 const std::string& service,
158ac6a4445SGunnar Mills                                 const std::string& objPath)
159ac6a4445SGunnar Mills {
160ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG << "Get available system cpu resources by service.";
161ac6a4445SGunnar Mills 
162ac6a4445SGunnar Mills     crow::connections::systemBus->async_method_call(
163ac6a4445SGunnar Mills         [cpuId, service, objPath, aResp{std::move(aResp)}](
164ac6a4445SGunnar Mills             const boost::system::error_code ec,
165ac6a4445SGunnar Mills             const dbus::utility::ManagedObjectType& dbusData) {
166ac6a4445SGunnar Mills             if (ec)
167ac6a4445SGunnar Mills             {
168ac6a4445SGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error";
169ac6a4445SGunnar Mills                 messages::internalError(aResp->res);
170ac6a4445SGunnar Mills                 return;
171ac6a4445SGunnar Mills             }
172ac6a4445SGunnar Mills             aResp->res.jsonValue["Id"] = cpuId;
173ac6a4445SGunnar Mills             aResp->res.jsonValue["Name"] = "Processor";
174ac6a4445SGunnar Mills             aResp->res.jsonValue["ProcessorType"] = "CPU";
175ac6a4445SGunnar Mills 
176ac6a4445SGunnar Mills             bool slotPresent = false;
177ac6a4445SGunnar Mills             std::string corePath = objPath + "/core";
178ac6a4445SGunnar Mills             size_t totalCores = 0;
179ac6a4445SGunnar Mills             for (const auto& object : dbusData)
180ac6a4445SGunnar Mills             {
181ac6a4445SGunnar Mills                 if (object.first.str == objPath)
182ac6a4445SGunnar Mills                 {
183ac6a4445SGunnar Mills                     getCpuDataByInterface(aResp, object.second);
184ac6a4445SGunnar Mills                 }
185ac6a4445SGunnar Mills                 else if (boost::starts_with(object.first.str, corePath))
186ac6a4445SGunnar Mills                 {
187ac6a4445SGunnar Mills                     for (const auto& interface : object.second)
188ac6a4445SGunnar Mills                     {
189ac6a4445SGunnar Mills                         if (interface.first ==
190ac6a4445SGunnar Mills                             "xyz.openbmc_project.Inventory.Item")
191ac6a4445SGunnar Mills                         {
192ac6a4445SGunnar Mills                             for (const auto& property : interface.second)
193ac6a4445SGunnar Mills                             {
194ac6a4445SGunnar Mills                                 if (property.first == "Present")
195ac6a4445SGunnar Mills                                 {
196ac6a4445SGunnar Mills                                     const bool* present =
197ac6a4445SGunnar Mills                                         std::get_if<bool>(&property.second);
198ac6a4445SGunnar Mills                                     if (present != nullptr)
199ac6a4445SGunnar Mills                                     {
200ac6a4445SGunnar Mills                                         if (*present == true)
201ac6a4445SGunnar Mills                                         {
202ac6a4445SGunnar Mills                                             slotPresent = true;
203ac6a4445SGunnar Mills                                             totalCores++;
204ac6a4445SGunnar Mills                                         }
205ac6a4445SGunnar Mills                                     }
206ac6a4445SGunnar Mills                                 }
207ac6a4445SGunnar Mills                             }
208ac6a4445SGunnar Mills                         }
209ac6a4445SGunnar Mills                     }
210ac6a4445SGunnar Mills                 }
211ac6a4445SGunnar Mills             }
212ac6a4445SGunnar Mills             // In getCpuDataByInterface(), state and health are set
213ac6a4445SGunnar Mills             // based on the present and functional status. If core
214ac6a4445SGunnar Mills             // count is zero, then it has a higher precedence.
215ac6a4445SGunnar Mills             if (slotPresent)
216ac6a4445SGunnar Mills             {
217ac6a4445SGunnar Mills                 if (totalCores == 0)
218ac6a4445SGunnar Mills                 {
219ac6a4445SGunnar Mills                     // Slot is not populated, set status end return
220ac6a4445SGunnar Mills                     aResp->res.jsonValue["Status"]["State"] = "Absent";
221ac6a4445SGunnar Mills                     aResp->res.jsonValue["Status"]["Health"] = "OK";
222ac6a4445SGunnar Mills                 }
223ac6a4445SGunnar Mills                 aResp->res.jsonValue["TotalCores"] = totalCores;
224ac6a4445SGunnar Mills             }
225ac6a4445SGunnar Mills             return;
226ac6a4445SGunnar Mills         },
227ac6a4445SGunnar Mills         service, "/xyz/openbmc_project/inventory",
228ac6a4445SGunnar Mills         "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
229ac6a4445SGunnar Mills }
230ac6a4445SGunnar Mills 
231ac6a4445SGunnar Mills inline void getCpuAssetData(std::shared_ptr<AsyncResp> aResp,
232ac6a4445SGunnar Mills                             const std::string& service,
233ac6a4445SGunnar Mills                             const std::string& objPath)
234ac6a4445SGunnar Mills {
235ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG << "Get Cpu Asset Data";
236ac6a4445SGunnar Mills     crow::connections::systemBus->async_method_call(
237ac6a4445SGunnar Mills         [objPath, aResp{std::move(aResp)}](
238ac6a4445SGunnar Mills             const boost::system::error_code ec,
239ac6a4445SGunnar Mills             const boost::container::flat_map<
240ac6a4445SGunnar Mills                 std::string, std::variant<std::string, uint32_t, uint16_t,
241ac6a4445SGunnar Mills                                           bool>>& properties) {
242ac6a4445SGunnar Mills             if (ec)
243ac6a4445SGunnar Mills             {
244ac6a4445SGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error";
245ac6a4445SGunnar Mills                 messages::internalError(aResp->res);
246ac6a4445SGunnar Mills                 return;
247ac6a4445SGunnar Mills             }
248ac6a4445SGunnar Mills 
249ac6a4445SGunnar Mills             for (const auto& property : properties)
250ac6a4445SGunnar Mills             {
251ac6a4445SGunnar Mills                 if (property.first == "SerialNumber")
252ac6a4445SGunnar Mills                 {
253ac6a4445SGunnar Mills                     const std::string* sn =
254ac6a4445SGunnar Mills                         std::get_if<std::string>(&property.second);
255ac6a4445SGunnar Mills                     if (sn != nullptr && !sn->empty())
256ac6a4445SGunnar Mills                     {
257ac6a4445SGunnar Mills                         aResp->res.jsonValue["SerialNumber"] = *sn;
258ac6a4445SGunnar Mills                     }
259ac6a4445SGunnar Mills                 }
260ac6a4445SGunnar Mills                 else if (property.first == "Model")
261ac6a4445SGunnar Mills                 {
262ac6a4445SGunnar Mills                     const std::string* model =
263ac6a4445SGunnar Mills                         std::get_if<std::string>(&property.second);
264ac6a4445SGunnar Mills                     if (model != nullptr && !model->empty())
265ac6a4445SGunnar Mills                     {
266ac6a4445SGunnar Mills                         aResp->res.jsonValue["Model"] = *model;
267ac6a4445SGunnar Mills                     }
268ac6a4445SGunnar Mills                 }
269ac6a4445SGunnar Mills                 else if (property.first == "Manufacturer")
270ac6a4445SGunnar Mills                 {
271ac6a4445SGunnar Mills 
272ac6a4445SGunnar Mills                     const std::string* mfg =
273ac6a4445SGunnar Mills                         std::get_if<std::string>(&property.second);
274ac6a4445SGunnar Mills                     if (mfg != nullptr)
275ac6a4445SGunnar Mills                     {
276ac6a4445SGunnar Mills                         aResp->res.jsonValue["Manufacturer"] = *mfg;
277ac6a4445SGunnar Mills 
278ac6a4445SGunnar Mills                         // Otherwise would be unexpected.
279ac6a4445SGunnar Mills                         if (mfg->find("Intel") != std::string::npos)
280ac6a4445SGunnar Mills                         {
281ac6a4445SGunnar Mills                             aResp->res.jsonValue["ProcessorArchitecture"] =
282ac6a4445SGunnar Mills                                 "x86";
283ac6a4445SGunnar Mills                             aResp->res.jsonValue["InstructionSet"] = "x86-64";
284ac6a4445SGunnar Mills                         }
285ac6a4445SGunnar Mills                         else if (mfg->find("IBM") != std::string::npos)
286ac6a4445SGunnar Mills                         {
287ac6a4445SGunnar Mills                             aResp->res.jsonValue["ProcessorArchitecture"] =
288ac6a4445SGunnar Mills                                 "Power";
289ac6a4445SGunnar Mills                             aResp->res.jsonValue["InstructionSet"] = "PowerISA";
290ac6a4445SGunnar Mills                         }
291ac6a4445SGunnar Mills                     }
292ac6a4445SGunnar Mills                 }
293cba4f448SSunnySrivastava1984                 else if (property.first == "PartNumber")
294cba4f448SSunnySrivastava1984                 {
295cba4f448SSunnySrivastava1984                     const std::string* partNumber =
296cba4f448SSunnySrivastava1984                         std::get_if<std::string>(&property.second);
297cba4f448SSunnySrivastava1984 
298cba4f448SSunnySrivastava1984                     if (partNumber == nullptr)
299cba4f448SSunnySrivastava1984                     {
300cba4f448SSunnySrivastava1984                         messages::internalError(aResp->res);
301cba4f448SSunnySrivastava1984                         return;
302cba4f448SSunnySrivastava1984                     }
303cba4f448SSunnySrivastava1984                     aResp->res.jsonValue["PartNumber"] = *partNumber;
304cba4f448SSunnySrivastava1984                 }
305cba4f448SSunnySrivastava1984                 else if (property.first == "SparePartNumber")
306cba4f448SSunnySrivastava1984                 {
307cba4f448SSunnySrivastava1984                     const std::string* sparePartNumber =
308cba4f448SSunnySrivastava1984                         std::get_if<std::string>(&property.second);
309cba4f448SSunnySrivastava1984 
310cba4f448SSunnySrivastava1984                     if (sparePartNumber == nullptr)
311cba4f448SSunnySrivastava1984                     {
312cba4f448SSunnySrivastava1984                         messages::internalError(aResp->res);
313cba4f448SSunnySrivastava1984                         return;
314cba4f448SSunnySrivastava1984                     }
315cba4f448SSunnySrivastava1984                     aResp->res.jsonValue["SparePartNumber"] = *sparePartNumber;
316cba4f448SSunnySrivastava1984                 }
317ac6a4445SGunnar Mills             }
318ac6a4445SGunnar Mills         },
319ac6a4445SGunnar Mills         service, objPath, "org.freedesktop.DBus.Properties", "GetAll",
320ac6a4445SGunnar Mills         "xyz.openbmc_project.Inventory.Decorator.Asset");
321ac6a4445SGunnar Mills }
322ac6a4445SGunnar Mills 
323ac6a4445SGunnar Mills inline void getCpuRevisionData(std::shared_ptr<AsyncResp> aResp,
324ac6a4445SGunnar Mills                                const std::string& service,
325ac6a4445SGunnar Mills                                const std::string& objPath)
326ac6a4445SGunnar Mills {
327ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG << "Get Cpu Revision Data";
328ac6a4445SGunnar Mills     crow::connections::systemBus->async_method_call(
329ac6a4445SGunnar Mills         [objPath, aResp{std::move(aResp)}](
330ac6a4445SGunnar Mills             const boost::system::error_code ec,
331ac6a4445SGunnar Mills             const boost::container::flat_map<
332ac6a4445SGunnar Mills                 std::string, std::variant<std::string, uint32_t, uint16_t,
333ac6a4445SGunnar Mills                                           bool>>& properties) {
334ac6a4445SGunnar Mills             if (ec)
335ac6a4445SGunnar Mills             {
336ac6a4445SGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error";
337ac6a4445SGunnar Mills                 messages::internalError(aResp->res);
338ac6a4445SGunnar Mills                 return;
339ac6a4445SGunnar Mills             }
340ac6a4445SGunnar Mills 
341ac6a4445SGunnar Mills             for (const auto& property : properties)
342ac6a4445SGunnar Mills             {
343ac6a4445SGunnar Mills                 if (property.first == "Version")
344ac6a4445SGunnar Mills                 {
345ac6a4445SGunnar Mills                     const std::string* ver =
346ac6a4445SGunnar Mills                         std::get_if<std::string>(&property.second);
347ac6a4445SGunnar Mills                     if (ver != nullptr)
348ac6a4445SGunnar Mills                     {
349ac6a4445SGunnar Mills                         aResp->res.jsonValue["Version"] = *ver;
350ac6a4445SGunnar Mills                     }
351ac6a4445SGunnar Mills                     break;
352ac6a4445SGunnar Mills                 }
353ac6a4445SGunnar Mills             }
354ac6a4445SGunnar Mills         },
355ac6a4445SGunnar Mills         service, objPath, "org.freedesktop.DBus.Properties", "GetAll",
356ac6a4445SGunnar Mills         "xyz.openbmc_project.Inventory.Decorator.Revision");
357ac6a4445SGunnar Mills }
358ac6a4445SGunnar Mills 
359ac6a4445SGunnar Mills inline void getAcceleratorDataByService(std::shared_ptr<AsyncResp> aResp,
360ac6a4445SGunnar Mills                                         const std::string& acclrtrId,
361ac6a4445SGunnar Mills                                         const std::string& service,
362ac6a4445SGunnar Mills                                         const std::string& objPath)
363ac6a4445SGunnar Mills {
364ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG
365ac6a4445SGunnar Mills         << "Get available system Accelerator resources by service.";
366ac6a4445SGunnar Mills     crow::connections::systemBus->async_method_call(
367ac6a4445SGunnar Mills         [acclrtrId, aResp{std::move(aResp)}](
368ac6a4445SGunnar Mills             const boost::system::error_code ec,
369ac6a4445SGunnar Mills             const boost::container::flat_map<
370ac6a4445SGunnar Mills                 std::string, std::variant<std::string, uint32_t, uint16_t,
371ac6a4445SGunnar Mills                                           bool>>& properties) {
372ac6a4445SGunnar Mills             if (ec)
373ac6a4445SGunnar Mills             {
374ac6a4445SGunnar Mills                 BMCWEB_LOG_DEBUG << "DBUS response error";
375ac6a4445SGunnar Mills                 messages::internalError(aResp->res);
376ac6a4445SGunnar Mills                 return;
377ac6a4445SGunnar Mills             }
378ac6a4445SGunnar Mills             aResp->res.jsonValue["Id"] = acclrtrId;
379ac6a4445SGunnar Mills             aResp->res.jsonValue["Name"] = "Processor";
380ac6a4445SGunnar Mills             const bool* accPresent = nullptr;
381ac6a4445SGunnar Mills             const bool* accFunctional = nullptr;
382ac6a4445SGunnar Mills 
383ac6a4445SGunnar Mills             for (const auto& property : properties)
384ac6a4445SGunnar Mills             {
385ac6a4445SGunnar Mills                 if (property.first == "Functional")
386ac6a4445SGunnar Mills                 {
387ac6a4445SGunnar Mills                     accFunctional = std::get_if<bool>(&property.second);
388ac6a4445SGunnar Mills                 }
389ac6a4445SGunnar Mills                 else if (property.first == "Present")
390ac6a4445SGunnar Mills                 {
391ac6a4445SGunnar Mills                     accPresent = std::get_if<bool>(&property.second);
392ac6a4445SGunnar Mills                 }
393ac6a4445SGunnar Mills             }
394ac6a4445SGunnar Mills 
395ac6a4445SGunnar Mills             std::string state = "Enabled";
396ac6a4445SGunnar Mills             std::string health = "OK";
397ac6a4445SGunnar Mills 
398ac6a4445SGunnar Mills             if (accPresent != nullptr && *accPresent == false)
399ac6a4445SGunnar Mills             {
400ac6a4445SGunnar Mills                 state = "Absent";
401ac6a4445SGunnar Mills             }
402ac6a4445SGunnar Mills 
403ac6a4445SGunnar Mills             if ((accFunctional != nullptr) && (*accFunctional == false))
404ac6a4445SGunnar Mills             {
405ac6a4445SGunnar Mills                 if (state == "Enabled")
406ac6a4445SGunnar Mills                 {
407ac6a4445SGunnar Mills                     health = "Critical";
408ac6a4445SGunnar Mills                 }
409ac6a4445SGunnar Mills             }
410ac6a4445SGunnar Mills 
411ac6a4445SGunnar Mills             aResp->res.jsonValue["Status"]["State"] = state;
412ac6a4445SGunnar Mills             aResp->res.jsonValue["Status"]["Health"] = health;
413ac6a4445SGunnar Mills             aResp->res.jsonValue["ProcessorType"] = "Accelerator";
414ac6a4445SGunnar Mills         },
415ac6a4445SGunnar Mills         service, objPath, "org.freedesktop.DBus.Properties", "GetAll", "");
416ac6a4445SGunnar Mills }
417ac6a4445SGunnar Mills 
418dba0c291SJonathan Doman // OperatingConfig D-Bus Types
419dba0c291SJonathan Doman using TurboProfileProperty = std::vector<std::tuple<uint32_t, size_t>>;
420dba0c291SJonathan Doman using BaseSpeedPrioritySettingsProperty =
421dba0c291SJonathan Doman     std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>;
422dba0c291SJonathan Doman // uint32_t and size_t may or may not be the same type, requiring a dedup'd
423dba0c291SJonathan Doman // variant
424dba0c291SJonathan Doman using OperatingConfigProperties = std::vector<std::pair<
425dba0c291SJonathan Doman     std::string,
426dba0c291SJonathan Doman     sdbusplus::utility::dedup_variant<uint32_t, size_t, TurboProfileProperty,
427dba0c291SJonathan Doman                                       BaseSpeedPrioritySettingsProperty>>>;
428dba0c291SJonathan Doman 
429dba0c291SJonathan Doman /**
430dba0c291SJonathan Doman  * Fill out the HighSpeedCoreIDs in a Processor resource from the given
431dba0c291SJonathan Doman  * OperatingConfig D-Bus property.
432dba0c291SJonathan Doman  *
433dba0c291SJonathan Doman  * @param[in,out]   aResp               Async HTTP response.
434dba0c291SJonathan Doman  * @param[in]       baseSpeedSettings   Full list of base speed priority groups,
435dba0c291SJonathan Doman  *                                      to use to determine the list of high
436dba0c291SJonathan Doman  *                                      speed cores.
437dba0c291SJonathan Doman  */
438dba0c291SJonathan Doman inline void highSpeedCoreIdsHandler(
439dba0c291SJonathan Doman     const std::shared_ptr<AsyncResp>& aResp,
440dba0c291SJonathan Doman     const BaseSpeedPrioritySettingsProperty& baseSpeedSettings)
441dba0c291SJonathan Doman {
442dba0c291SJonathan Doman     // The D-Bus property does not indicate which bucket is the "high
443dba0c291SJonathan Doman     // priority" group, so let's discern that by looking for the one with
444dba0c291SJonathan Doman     // highest base frequency.
445dba0c291SJonathan Doman     auto highPriorityGroup = baseSpeedSettings.cend();
446dba0c291SJonathan Doman     uint32_t highestBaseSpeed = 0;
447dba0c291SJonathan Doman     for (auto it = baseSpeedSettings.cbegin(); it != baseSpeedSettings.cend();
448dba0c291SJonathan Doman          ++it)
449dba0c291SJonathan Doman     {
450dba0c291SJonathan Doman         const uint32_t baseFreq = std::get<uint32_t>(*it);
451dba0c291SJonathan Doman         if (baseFreq > highestBaseSpeed)
452dba0c291SJonathan Doman         {
453dba0c291SJonathan Doman             highestBaseSpeed = baseFreq;
454dba0c291SJonathan Doman             highPriorityGroup = it;
455dba0c291SJonathan Doman         }
456dba0c291SJonathan Doman     }
457dba0c291SJonathan Doman 
458dba0c291SJonathan Doman     nlohmann::json& jsonCoreIds = aResp->res.jsonValue["HighSpeedCoreIDs"];
459dba0c291SJonathan Doman     jsonCoreIds = nlohmann::json::array();
460dba0c291SJonathan Doman 
461dba0c291SJonathan Doman     // There may not be any entries in the D-Bus property, so only populate
462dba0c291SJonathan Doman     // if there was actually something there.
463dba0c291SJonathan Doman     if (highPriorityGroup != baseSpeedSettings.cend())
464dba0c291SJonathan Doman     {
465dba0c291SJonathan Doman         jsonCoreIds = std::get<std::vector<uint32_t>>(*highPriorityGroup);
466dba0c291SJonathan Doman     }
467dba0c291SJonathan Doman }
468dba0c291SJonathan Doman 
469dba0c291SJonathan Doman /**
470dba0c291SJonathan Doman  * Fill out OperatingConfig related items in a Processor resource by requesting
471dba0c291SJonathan Doman  * data from the given D-Bus object.
472dba0c291SJonathan Doman  *
473dba0c291SJonathan Doman  * @param[in,out]   aResp       Async HTTP response.
474dba0c291SJonathan Doman  * @param[in]       cpuId       CPU D-Bus name.
475dba0c291SJonathan Doman  * @param[in]       service     D-Bus service to query.
476dba0c291SJonathan Doman  * @param[in]       objPath     D-Bus object to query.
477dba0c291SJonathan Doman  */
478dba0c291SJonathan Doman inline void getCpuConfigData(const std::shared_ptr<AsyncResp>& aResp,
479dba0c291SJonathan Doman                              const std::string& cpuId,
480dba0c291SJonathan Doman                              const std::string& service,
481dba0c291SJonathan Doman                              const std::string& objPath)
482dba0c291SJonathan Doman {
483dba0c291SJonathan Doman     BMCWEB_LOG_INFO << "Getting CPU operating configs for " << cpuId;
484dba0c291SJonathan Doman 
485dba0c291SJonathan Doman     // First, GetAll CurrentOperatingConfig properties on the object
486dba0c291SJonathan Doman     crow::connections::systemBus->async_method_call(
487dba0c291SJonathan Doman         [aResp, cpuId, service](
488dba0c291SJonathan Doman             const boost::system::error_code ec,
489dba0c291SJonathan Doman             const std::vector<
490dba0c291SJonathan Doman                 std::pair<std::string,
491dba0c291SJonathan Doman                           std::variant<sdbusplus::message::object_path, bool>>>&
492dba0c291SJonathan Doman                 properties) {
493dba0c291SJonathan Doman             if (ec)
494dba0c291SJonathan Doman             {
495dba0c291SJonathan Doman                 BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", "
496dba0c291SJonathan Doman                                    << ec.message();
497dba0c291SJonathan Doman                 messages::internalError(aResp->res);
498dba0c291SJonathan Doman                 return;
499dba0c291SJonathan Doman             }
500dba0c291SJonathan Doman 
501dba0c291SJonathan Doman             nlohmann::json& json = aResp->res.jsonValue;
502dba0c291SJonathan Doman 
503dba0c291SJonathan Doman             for (const auto& [dbusPropName, variantVal] : properties)
504dba0c291SJonathan Doman             {
505dba0c291SJonathan Doman                 if (dbusPropName == "AppliedConfig")
506dba0c291SJonathan Doman                 {
507dba0c291SJonathan Doman                     const sdbusplus::message::object_path* dbusPathWrapper =
508dba0c291SJonathan Doman                         std::get_if<sdbusplus::message::object_path>(
509dba0c291SJonathan Doman                             &variantVal);
510dba0c291SJonathan Doman                     if (dbusPathWrapper == nullptr)
511dba0c291SJonathan Doman                     {
512dba0c291SJonathan Doman                         continue;
513dba0c291SJonathan Doman                     }
514dba0c291SJonathan Doman 
515dba0c291SJonathan Doman                     const std::string& dbusPath = dbusPathWrapper->str;
516dba0c291SJonathan Doman                     std::string uri = "/redfish/v1/Systems/system/Processors/" +
517dba0c291SJonathan Doman                                       cpuId + "/OperatingConfigs";
518dba0c291SJonathan Doman                     json["OperatingConfigs"] = {{"@odata.id", uri}};
519dba0c291SJonathan Doman 
520dba0c291SJonathan Doman                     // Reuse the D-Bus config object name for the Redfish
521dba0c291SJonathan Doman                     // URI
522dba0c291SJonathan Doman                     size_t baseNamePos = dbusPath.rfind('/');
523dba0c291SJonathan Doman                     if (baseNamePos == std::string::npos ||
524dba0c291SJonathan Doman                         baseNamePos == (dbusPath.size() - 1))
525dba0c291SJonathan Doman                     {
526dba0c291SJonathan Doman                         // If the AppliedConfig was somehow not a valid path,
527dba0c291SJonathan Doman                         // skip adding any more properties, since everything
528dba0c291SJonathan Doman                         // else is tied to this applied config.
529dba0c291SJonathan Doman                         messages::internalError(aResp->res);
530dba0c291SJonathan Doman                         break;
531dba0c291SJonathan Doman                     }
532dba0c291SJonathan Doman                     uri += '/';
533dba0c291SJonathan Doman                     uri += dbusPath.substr(baseNamePos + 1);
534dba0c291SJonathan Doman                     json["AppliedOperatingConfig"] = {{"@odata.id", uri}};
535dba0c291SJonathan Doman 
536dba0c291SJonathan Doman                     // Once we found the current applied config, queue another
537dba0c291SJonathan Doman                     // request to read the base freq core ids out of that
538dba0c291SJonathan Doman                     // config.
539dba0c291SJonathan Doman                     crow::connections::systemBus->async_method_call(
540dba0c291SJonathan Doman                         [aResp](
541dba0c291SJonathan Doman                             const boost::system::error_code ec,
542dba0c291SJonathan Doman                             const std::variant<
543dba0c291SJonathan Doman                                 BaseSpeedPrioritySettingsProperty>& property) {
544dba0c291SJonathan Doman                             if (ec)
545dba0c291SJonathan Doman                             {
546dba0c291SJonathan Doman                                 BMCWEB_LOG_WARNING
547dba0c291SJonathan Doman                                     << "D-Bus Property Get error: " << ec;
548dba0c291SJonathan Doman                                 messages::internalError(aResp->res);
549dba0c291SJonathan Doman                                 return;
550dba0c291SJonathan Doman                             }
551dba0c291SJonathan Doman                             auto baseSpeedList =
552dba0c291SJonathan Doman                                 std::get_if<BaseSpeedPrioritySettingsProperty>(
553dba0c291SJonathan Doman                                     &property);
554dba0c291SJonathan Doman                             if (baseSpeedList != nullptr)
555dba0c291SJonathan Doman                             {
556dba0c291SJonathan Doman                                 highSpeedCoreIdsHandler(aResp, *baseSpeedList);
557dba0c291SJonathan Doman                             }
558dba0c291SJonathan Doman                         },
559dba0c291SJonathan Doman                         service, dbusPath, "org.freedesktop.DBus.Properties",
560dba0c291SJonathan Doman                         "Get",
561dba0c291SJonathan Doman                         "xyz.openbmc_project.Inventory.Item.Cpu."
562dba0c291SJonathan Doman                         "OperatingConfig",
563dba0c291SJonathan Doman                         "BaseSpeedPrioritySettings");
564dba0c291SJonathan Doman                 }
565dba0c291SJonathan Doman                 else if (dbusPropName == "BaseSpeedPriorityEnabled")
566dba0c291SJonathan Doman                 {
567dba0c291SJonathan Doman                     const bool* state = std::get_if<bool>(&variantVal);
568dba0c291SJonathan Doman                     if (state != nullptr)
569dba0c291SJonathan Doman                     {
570dba0c291SJonathan Doman                         json["BaseSpeedPriorityState"] =
571dba0c291SJonathan Doman                             *state ? "Enabled" : "Disabled";
572dba0c291SJonathan Doman                     }
573dba0c291SJonathan Doman                 }
574dba0c291SJonathan Doman             }
575dba0c291SJonathan Doman         },
576dba0c291SJonathan Doman         service, objPath, "org.freedesktop.DBus.Properties", "GetAll",
577dba0c291SJonathan Doman         "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig");
578dba0c291SJonathan Doman }
579dba0c291SJonathan Doman 
580cba4f448SSunnySrivastava1984 /**
581cba4f448SSunnySrivastava1984  * @brief Fill out location info of a processor by
582cba4f448SSunnySrivastava1984  * requesting data from the given D-Bus object.
583cba4f448SSunnySrivastava1984  *
584cba4f448SSunnySrivastava1984  * @param[in,out]   aResp       Async HTTP response.
585cba4f448SSunnySrivastava1984  * @param[in]       service     D-Bus service to query.
586cba4f448SSunnySrivastava1984  * @param[in]       objPath     D-Bus object to query.
587cba4f448SSunnySrivastava1984  */
588cba4f448SSunnySrivastava1984 inline void getCpuLocationCode(std::shared_ptr<AsyncResp> aResp,
589cba4f448SSunnySrivastava1984                                const std::string& service,
590cba4f448SSunnySrivastava1984                                const std::string& objPath)
591cba4f448SSunnySrivastava1984 {
592cba4f448SSunnySrivastava1984     BMCWEB_LOG_DEBUG << "Get Cpu Location Data";
593cba4f448SSunnySrivastava1984     crow::connections::systemBus->async_method_call(
594cba4f448SSunnySrivastava1984         [objPath,
595cba4f448SSunnySrivastava1984          aResp{std::move(aResp)}](const boost::system::error_code ec,
596cba4f448SSunnySrivastava1984                                   const std::variant<std::string>& property) {
597cba4f448SSunnySrivastava1984             if (ec)
598cba4f448SSunnySrivastava1984             {
599cba4f448SSunnySrivastava1984                 BMCWEB_LOG_DEBUG << "DBUS response error";
600cba4f448SSunnySrivastava1984                 messages::internalError(aResp->res);
601cba4f448SSunnySrivastava1984                 return;
602cba4f448SSunnySrivastava1984             }
603cba4f448SSunnySrivastava1984 
604cba4f448SSunnySrivastava1984             const std::string* value = std::get_if<std::string>(&property);
605cba4f448SSunnySrivastava1984 
606cba4f448SSunnySrivastava1984             if (value == nullptr)
607cba4f448SSunnySrivastava1984             {
608cba4f448SSunnySrivastava1984                 // illegal value
609cba4f448SSunnySrivastava1984                 BMCWEB_LOG_DEBUG << "Location code value error";
610cba4f448SSunnySrivastava1984                 messages::internalError(aResp->res);
611cba4f448SSunnySrivastava1984                 return;
612cba4f448SSunnySrivastava1984             }
613cba4f448SSunnySrivastava1984 
614cba4f448SSunnySrivastava1984             aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
615cba4f448SSunnySrivastava1984                 *value;
616cba4f448SSunnySrivastava1984         },
617cba4f448SSunnySrivastava1984         service, objPath, "org.freedesktop.DBus.Properties", "Get",
618cba4f448SSunnySrivastava1984         "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode");
619cba4f448SSunnySrivastava1984 }
620cba4f448SSunnySrivastava1984 
621*c951448aSJonathan Doman /**
622*c951448aSJonathan Doman  * Find the D-Bus object representing the requested Processor, and call the
623*c951448aSJonathan Doman  * handler with the results. If matching object is not found, add 404 error to
624*c951448aSJonathan Doman  * response and don't call the handler.
625*c951448aSJonathan Doman  *
626*c951448aSJonathan Doman  * @param[in,out]   resp            Async HTTP response.
627*c951448aSJonathan Doman  * @param[in]       processorId     Redfish Processor Id.
628*c951448aSJonathan Doman  * @param[in]       handler         Callback to continue processing request upon
629*c951448aSJonathan Doman  *                                  successfully finding object.
630*c951448aSJonathan Doman  */
631*c951448aSJonathan Doman template <typename Handler>
632*c951448aSJonathan Doman inline void getProcessorObject(const std::shared_ptr<AsyncResp>& resp,
633*c951448aSJonathan Doman                                const std::string& processorId,
634*c951448aSJonathan Doman                                Handler&& handler)
635ac6a4445SGunnar Mills {
636ac6a4445SGunnar Mills     BMCWEB_LOG_DEBUG << "Get available system processor resources.";
637ac6a4445SGunnar Mills 
638*c951448aSJonathan Doman     // GetSubTree on all interfaces which provide info about a Processor
639ac6a4445SGunnar Mills     crow::connections::systemBus->async_method_call(
640*c951448aSJonathan Doman         [resp, processorId, handler = std::forward<Handler>(handler)](
641*c951448aSJonathan Doman             boost::system::error_code ec,
642*c951448aSJonathan Doman             const MapperGetSubTreeResponse& subtree) mutable {
643ac6a4445SGunnar Mills             if (ec)
644ac6a4445SGunnar Mills             {
645*c951448aSJonathan Doman                 BMCWEB_LOG_DEBUG << "DBUS response error: " << ec;
646*c951448aSJonathan Doman                 messages::internalError(resp->res);
647ac6a4445SGunnar Mills                 return;
648ac6a4445SGunnar Mills             }
6492bab9831SJonathan Doman             for (const auto& [objectPath, serviceMap] : subtree)
650ac6a4445SGunnar Mills             {
6512bab9831SJonathan Doman                 // Ignore any objects which don't end with our desired cpu name
6522bab9831SJonathan Doman                 if (!boost::ends_with(objectPath, processorId))
653ac6a4445SGunnar Mills                 {
6542bab9831SJonathan Doman                     continue;
655ac6a4445SGunnar Mills                 }
6562bab9831SJonathan Doman 
657*c951448aSJonathan Doman                 bool found = false;
658*c951448aSJonathan Doman                 // Filter out objects that don't have the CPU-specific
659*c951448aSJonathan Doman                 // interfaces to make sure we can return 404 on non-CPUs
660*c951448aSJonathan Doman                 // (e.g. /redfish/../Processors/dimm0)
6612bab9831SJonathan Doman                 for (const auto& [serviceName, interfaceList] : serviceMap)
662ac6a4445SGunnar Mills                 {
663*c951448aSJonathan Doman                     if (std::find_first_of(
664*c951448aSJonathan Doman                             interfaceList.begin(), interfaceList.end(),
665*c951448aSJonathan Doman                             processorInterfaces.begin(),
666*c951448aSJonathan Doman                             processorInterfaces.end()) != interfaceList.end())
6672bab9831SJonathan Doman                     {
668*c951448aSJonathan Doman                         found = true;
669*c951448aSJonathan Doman                         break;
670*c951448aSJonathan Doman                     }
671*c951448aSJonathan Doman                 }
672*c951448aSJonathan Doman 
673*c951448aSJonathan Doman                 if (!found)
6742bab9831SJonathan Doman                 {
675*c951448aSJonathan Doman                     continue;
676ac6a4445SGunnar Mills                 }
677*c951448aSJonathan Doman 
678*c951448aSJonathan Doman                 // Process the first object which does match our cpu name and
679*c951448aSJonathan Doman                 // required interfaces, and potentially ignore any other
680*c951448aSJonathan Doman                 // matching objects. Assume all interfaces we want to process
681*c951448aSJonathan Doman                 // must be on the same object path.
682*c951448aSJonathan Doman 
683*c951448aSJonathan Doman                 handler(resp, processorId, objectPath, serviceMap);
684ac6a4445SGunnar Mills                 return;
685ac6a4445SGunnar Mills             }
686*c951448aSJonathan Doman             messages::resourceNotFound(resp->res, "Processor", processorId);
687ac6a4445SGunnar Mills         },
688ac6a4445SGunnar Mills         "xyz.openbmc_project.ObjectMapper",
689ac6a4445SGunnar Mills         "/xyz/openbmc_project/object_mapper",
690ac6a4445SGunnar Mills         "xyz.openbmc_project.ObjectMapper", "GetSubTree",
6912bab9831SJonathan Doman         "/xyz/openbmc_project/inventory", 0,
692cba4f448SSunnySrivastava1984         std::array<const char*, 6>{
6932bab9831SJonathan Doman             "xyz.openbmc_project.Inventory.Decorator.Asset",
6942bab9831SJonathan Doman             "xyz.openbmc_project.Inventory.Decorator.Revision",
6952bab9831SJonathan Doman             "xyz.openbmc_project.Inventory.Item.Cpu",
696cba4f448SSunnySrivastava1984             "xyz.openbmc_project.Inventory.Decorator.LocationCode",
697dba0c291SJonathan Doman             "xyz.openbmc_project.Inventory.Item.Accelerator",
698dba0c291SJonathan Doman             "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"});
699ac6a4445SGunnar Mills }
700ac6a4445SGunnar Mills 
701*c951448aSJonathan Doman inline void getProcessorData(const std::shared_ptr<AsyncResp>& aResp,
702*c951448aSJonathan Doman                              const std::string& processorId,
703*c951448aSJonathan Doman                              const std::string& objectPath,
704*c951448aSJonathan Doman                              const MapperServiceMap& serviceMap)
705*c951448aSJonathan Doman {
706*c951448aSJonathan Doman     for (const auto& [serviceName, interfaceList] : serviceMap)
707*c951448aSJonathan Doman     {
708*c951448aSJonathan Doman         for (const auto& interface : interfaceList)
709*c951448aSJonathan Doman         {
710*c951448aSJonathan Doman             if (interface == "xyz.openbmc_project.Inventory.Decorator.Asset")
711*c951448aSJonathan Doman             {
712*c951448aSJonathan Doman                 getCpuAssetData(aResp, serviceName, objectPath);
713*c951448aSJonathan Doman             }
714*c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Inventory."
715*c951448aSJonathan Doman                                   "Decorator.Revision")
716*c951448aSJonathan Doman             {
717*c951448aSJonathan Doman                 getCpuRevisionData(aResp, serviceName, objectPath);
718*c951448aSJonathan Doman             }
719*c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Inventory.Item.Cpu")
720*c951448aSJonathan Doman             {
721*c951448aSJonathan Doman                 getCpuDataByService(aResp, processorId, serviceName,
722*c951448aSJonathan Doman                                     objectPath);
723*c951448aSJonathan Doman             }
724*c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Inventory."
725*c951448aSJonathan Doman                                   "Item.Accelerator")
726*c951448aSJonathan Doman             {
727*c951448aSJonathan Doman                 getAcceleratorDataByService(aResp, processorId, serviceName,
728*c951448aSJonathan Doman                                             objectPath);
729*c951448aSJonathan Doman             }
730*c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Control.Processor."
731*c951448aSJonathan Doman                                   "CurrentOperatingConfig")
732*c951448aSJonathan Doman             {
733*c951448aSJonathan Doman                 getCpuConfigData(aResp, processorId, serviceName, objectPath);
734*c951448aSJonathan Doman             }
735*c951448aSJonathan Doman             else if (interface == "xyz.openbmc_project.Inventory."
736*c951448aSJonathan Doman                                   "Decorator.LocationCode")
737*c951448aSJonathan Doman             {
738*c951448aSJonathan Doman                 getCpuLocationCode(aResp, serviceName, objectPath);
739*c951448aSJonathan Doman             }
740*c951448aSJonathan Doman         }
741*c951448aSJonathan Doman     }
742*c951448aSJonathan Doman }
743*c951448aSJonathan Doman 
744dba0c291SJonathan Doman /**
745dba0c291SJonathan Doman  * Request all the properties for the given D-Bus object and fill out the
746dba0c291SJonathan Doman  * related entries in the Redfish OperatingConfig response.
747dba0c291SJonathan Doman  *
748dba0c291SJonathan Doman  * @param[in,out]   aResp       Async HTTP response.
749dba0c291SJonathan Doman  * @param[in]       service     D-Bus service name to query.
750dba0c291SJonathan Doman  * @param[in]       objPath     D-Bus object to query.
751dba0c291SJonathan Doman  */
752dba0c291SJonathan Doman inline void getOperatingConfigData(const std::shared_ptr<AsyncResp>& aResp,
753dba0c291SJonathan Doman                                    const std::string& service,
754dba0c291SJonathan Doman                                    const std::string& objPath)
755dba0c291SJonathan Doman {
756dba0c291SJonathan Doman     crow::connections::systemBus->async_method_call(
757dba0c291SJonathan Doman         [aResp](boost::system::error_code ec,
758dba0c291SJonathan Doman                 const OperatingConfigProperties& properties) {
759dba0c291SJonathan Doman             if (ec)
760dba0c291SJonathan Doman             {
761dba0c291SJonathan Doman                 BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", "
762dba0c291SJonathan Doman                                    << ec.message();
763dba0c291SJonathan Doman                 messages::internalError(aResp->res);
764dba0c291SJonathan Doman                 return;
765dba0c291SJonathan Doman             }
766dba0c291SJonathan Doman 
767dba0c291SJonathan Doman             nlohmann::json& json = aResp->res.jsonValue;
768dba0c291SJonathan Doman             for (const auto& [key, variant] : properties)
769dba0c291SJonathan Doman             {
770dba0c291SJonathan Doman                 if (key == "AvailableCoreCount")
771dba0c291SJonathan Doman                 {
772dba0c291SJonathan Doman                     const size_t* cores = std::get_if<size_t>(&variant);
773dba0c291SJonathan Doman                     if (cores != nullptr)
774dba0c291SJonathan Doman                     {
775dba0c291SJonathan Doman                         json["TotalAvailableCoreCount"] = *cores;
776dba0c291SJonathan Doman                     }
777dba0c291SJonathan Doman                 }
778dba0c291SJonathan Doman                 else if (key == "BaseSpeed")
779dba0c291SJonathan Doman                 {
780dba0c291SJonathan Doman                     const uint32_t* speed = std::get_if<uint32_t>(&variant);
781dba0c291SJonathan Doman                     if (speed != nullptr)
782dba0c291SJonathan Doman                     {
783dba0c291SJonathan Doman                         json["BaseSpeedMHz"] = *speed;
784dba0c291SJonathan Doman                     }
785dba0c291SJonathan Doman                 }
786dba0c291SJonathan Doman                 else if (key == "MaxJunctionTemperature")
787dba0c291SJonathan Doman                 {
788dba0c291SJonathan Doman                     const uint32_t* temp = std::get_if<uint32_t>(&variant);
789dba0c291SJonathan Doman                     if (temp != nullptr)
790dba0c291SJonathan Doman                     {
791dba0c291SJonathan Doman                         json["MaxJunctionTemperatureCelsius"] = *temp;
792dba0c291SJonathan Doman                     }
793dba0c291SJonathan Doman                 }
794dba0c291SJonathan Doman                 else if (key == "MaxSpeed")
795dba0c291SJonathan Doman                 {
796dba0c291SJonathan Doman                     const uint32_t* speed = std::get_if<uint32_t>(&variant);
797dba0c291SJonathan Doman                     if (speed != nullptr)
798dba0c291SJonathan Doman                     {
799dba0c291SJonathan Doman                         json["MaxSpeedMHz"] = *speed;
800dba0c291SJonathan Doman                     }
801dba0c291SJonathan Doman                 }
802dba0c291SJonathan Doman                 else if (key == "PowerLimit")
803dba0c291SJonathan Doman                 {
804dba0c291SJonathan Doman                     const uint32_t* tdp = std::get_if<uint32_t>(&variant);
805dba0c291SJonathan Doman                     if (tdp != nullptr)
806dba0c291SJonathan Doman                     {
807dba0c291SJonathan Doman                         json["TDPWatts"] = *tdp;
808dba0c291SJonathan Doman                     }
809dba0c291SJonathan Doman                 }
810dba0c291SJonathan Doman                 else if (key == "TurboProfile")
811dba0c291SJonathan Doman                 {
812dba0c291SJonathan Doman                     const auto* turboList =
813dba0c291SJonathan Doman                         std::get_if<TurboProfileProperty>(&variant);
814dba0c291SJonathan Doman                     if (turboList == nullptr)
815dba0c291SJonathan Doman                     {
816dba0c291SJonathan Doman                         continue;
817dba0c291SJonathan Doman                     }
818dba0c291SJonathan Doman 
819dba0c291SJonathan Doman                     nlohmann::json& turboArray = json["TurboProfile"];
820dba0c291SJonathan Doman                     turboArray = nlohmann::json::array();
821dba0c291SJonathan Doman                     for (const auto& [turboSpeed, coreCount] : *turboList)
822dba0c291SJonathan Doman                     {
823dba0c291SJonathan Doman                         turboArray.push_back({{"ActiveCoreCount", coreCount},
824dba0c291SJonathan Doman                                               {"MaxSpeedMHz", turboSpeed}});
825dba0c291SJonathan Doman                     }
826dba0c291SJonathan Doman                 }
827dba0c291SJonathan Doman                 else if (key == "BaseSpeedPrioritySettings")
828dba0c291SJonathan Doman                 {
829dba0c291SJonathan Doman                     const auto* baseSpeedList =
830dba0c291SJonathan Doman                         std::get_if<BaseSpeedPrioritySettingsProperty>(
831dba0c291SJonathan Doman                             &variant);
832dba0c291SJonathan Doman                     if (baseSpeedList == nullptr)
833dba0c291SJonathan Doman                     {
834dba0c291SJonathan Doman                         continue;
835dba0c291SJonathan Doman                     }
836dba0c291SJonathan Doman 
837dba0c291SJonathan Doman                     nlohmann::json& baseSpeedArray =
838dba0c291SJonathan Doman                         json["BaseSpeedPrioritySettings"];
839dba0c291SJonathan Doman                     baseSpeedArray = nlohmann::json::array();
840dba0c291SJonathan Doman                     for (const auto& [baseSpeed, coreList] : *baseSpeedList)
841dba0c291SJonathan Doman                     {
842dba0c291SJonathan Doman                         baseSpeedArray.push_back(
843dba0c291SJonathan Doman                             {{"CoreCount", coreList.size()},
844dba0c291SJonathan Doman                              {"CoreIDs", coreList},
845dba0c291SJonathan Doman                              {"BaseSpeedMHz", baseSpeed}});
846dba0c291SJonathan Doman                     }
847dba0c291SJonathan Doman                 }
848dba0c291SJonathan Doman             }
849dba0c291SJonathan Doman         },
850dba0c291SJonathan Doman         service, objPath, "org.freedesktop.DBus.Properties", "GetAll",
851dba0c291SJonathan Doman         "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig");
852dba0c291SJonathan Doman }
853dba0c291SJonathan Doman 
854dba0c291SJonathan Doman class OperatingConfigCollection : public Node
855dba0c291SJonathan Doman {
856dba0c291SJonathan Doman   public:
857dba0c291SJonathan Doman     OperatingConfigCollection(App& app) :
858dba0c291SJonathan Doman         Node(app,
859dba0c291SJonathan Doman              "/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/",
860dba0c291SJonathan Doman              std::string())
861dba0c291SJonathan Doman     {
862dba0c291SJonathan Doman         // Defined by Redfish spec privilege registry
863dba0c291SJonathan Doman         entityPrivileges = {
864dba0c291SJonathan Doman             {boost::beast::http::verb::get, {{"Login"}}},
865dba0c291SJonathan Doman             {boost::beast::http::verb::head, {{"Login"}}},
866dba0c291SJonathan Doman             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
867dba0c291SJonathan Doman             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
868dba0c291SJonathan Doman             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
869dba0c291SJonathan Doman             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
870dba0c291SJonathan Doman     }
871dba0c291SJonathan Doman 
872dba0c291SJonathan Doman   private:
873dba0c291SJonathan Doman     void doGet(crow::Response& res, const crow::Request& req,
874dba0c291SJonathan Doman                const std::vector<std::string>& params) override
875dba0c291SJonathan Doman     {
876dba0c291SJonathan Doman         if (params.size() != 1)
877dba0c291SJonathan Doman         {
878dba0c291SJonathan Doman             messages::internalError(res);
879dba0c291SJonathan Doman             res.end();
880dba0c291SJonathan Doman             return;
881dba0c291SJonathan Doman         }
882dba0c291SJonathan Doman 
883dba0c291SJonathan Doman         const std::string& cpuName = params[0];
884dba0c291SJonathan Doman         res.jsonValue["@odata.type"] =
885dba0c291SJonathan Doman             "#OperatingConfigCollection.OperatingConfigCollection";
886dba0c291SJonathan Doman         res.jsonValue["@odata.id"] = req.url;
887dba0c291SJonathan Doman         res.jsonValue["Name"] = "Operating Config Collection";
888dba0c291SJonathan Doman 
889dba0c291SJonathan Doman         auto asyncResp = std::make_shared<AsyncResp>(res);
890dba0c291SJonathan Doman 
891dba0c291SJonathan Doman         // First find the matching CPU object so we know how to constrain our
892dba0c291SJonathan Doman         // search for related Config objects.
893dba0c291SJonathan Doman         crow::connections::systemBus->async_method_call(
894dba0c291SJonathan Doman             [asyncResp, cpuName](const boost::system::error_code ec,
895dba0c291SJonathan Doman                                  const std::vector<std::string>& objects) {
896dba0c291SJonathan Doman                 if (ec)
897dba0c291SJonathan Doman                 {
898dba0c291SJonathan Doman                     BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", "
899dba0c291SJonathan Doman                                        << ec.message();
900dba0c291SJonathan Doman                     messages::internalError(asyncResp->res);
901dba0c291SJonathan Doman                     return;
902dba0c291SJonathan Doman                 }
903dba0c291SJonathan Doman 
904dba0c291SJonathan Doman                 for (const std::string& object : objects)
905dba0c291SJonathan Doman                 {
906dba0c291SJonathan Doman                     if (!boost::ends_with(object, cpuName))
907dba0c291SJonathan Doman                     {
908dba0c291SJonathan Doman                         continue;
909dba0c291SJonathan Doman                     }
910dba0c291SJonathan Doman 
911dba0c291SJonathan Doman                     // Not expected that there will be multiple matching CPU
912dba0c291SJonathan Doman                     // objects, but if there are just use the first one.
913dba0c291SJonathan Doman 
914dba0c291SJonathan Doman                     // Use the common search routine to construct the Collection
915dba0c291SJonathan Doman                     // of all Config objects under this CPU.
916dba0c291SJonathan Doman                     collection_util::getCollectionMembers(
917dba0c291SJonathan Doman                         asyncResp,
918dba0c291SJonathan Doman                         "/redfish/v1/Systems/system/Processors/" + cpuName +
919dba0c291SJonathan Doman                             "/OperatingConfigs",
920dba0c291SJonathan Doman                         {"xyz.openbmc_project.Inventory.Item.Cpu."
921dba0c291SJonathan Doman                          "OperatingConfig"},
922dba0c291SJonathan Doman                         object.c_str());
923dba0c291SJonathan Doman                     return;
924dba0c291SJonathan Doman                 }
925dba0c291SJonathan Doman             },
926dba0c291SJonathan Doman             "xyz.openbmc_project.ObjectMapper",
927dba0c291SJonathan Doman             "/xyz/openbmc_project/object_mapper",
928dba0c291SJonathan Doman             "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
929dba0c291SJonathan Doman             "/xyz/openbmc_project/inventory", 0,
930dba0c291SJonathan Doman             std::array<const char*, 1>{"xyz.openbmc_project.Control.Processor."
931dba0c291SJonathan Doman                                        "CurrentOperatingConfig"});
932dba0c291SJonathan Doman     }
933dba0c291SJonathan Doman };
934dba0c291SJonathan Doman 
935dba0c291SJonathan Doman class OperatingConfig : public Node
936dba0c291SJonathan Doman {
937dba0c291SJonathan Doman   public:
938dba0c291SJonathan Doman     OperatingConfig(App& app) :
939dba0c291SJonathan Doman         Node(app,
940dba0c291SJonathan Doman              "/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/"
941dba0c291SJonathan Doman              "<str>/",
942dba0c291SJonathan Doman              std::string(), std::string())
943dba0c291SJonathan Doman     {
944dba0c291SJonathan Doman         // Defined by Redfish spec privilege registry
945dba0c291SJonathan Doman         entityPrivileges = {
946dba0c291SJonathan Doman             {boost::beast::http::verb::get, {{"Login"}}},
947dba0c291SJonathan Doman             {boost::beast::http::verb::head, {{"Login"}}},
948dba0c291SJonathan Doman             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
949dba0c291SJonathan Doman             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
950dba0c291SJonathan Doman             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
951dba0c291SJonathan Doman             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
952dba0c291SJonathan Doman     }
953dba0c291SJonathan Doman 
954dba0c291SJonathan Doman   private:
955dba0c291SJonathan Doman     void doGet(crow::Response& res, const crow::Request& req,
956dba0c291SJonathan Doman                const std::vector<std::string>& params) override
957dba0c291SJonathan Doman     {
958dba0c291SJonathan Doman         if (params.size() != 2)
959dba0c291SJonathan Doman         {
960dba0c291SJonathan Doman             messages::internalError(res);
961dba0c291SJonathan Doman             res.end();
962dba0c291SJonathan Doman             return;
963dba0c291SJonathan Doman         }
964dba0c291SJonathan Doman 
965dba0c291SJonathan Doman         const std::string& cpuName = params[0];
966dba0c291SJonathan Doman         const std::string& configName = params[1];
967dba0c291SJonathan Doman 
968dba0c291SJonathan Doman         auto asyncResp = std::make_shared<AsyncResp>(res);
969dba0c291SJonathan Doman 
970dba0c291SJonathan Doman         // Ask for all objects implementing OperatingConfig so we can search for
971dba0c291SJonathan Doman         // one with a matching name
972dba0c291SJonathan Doman         crow::connections::systemBus->async_method_call(
973dba0c291SJonathan Doman             [asyncResp, cpuName, configName,
974dba0c291SJonathan Doman              reqUrl{req.url}](boost::system::error_code ec,
975dba0c291SJonathan Doman                               const MapperGetSubTreeResponse& subtree) {
976dba0c291SJonathan Doman                 if (ec)
977dba0c291SJonathan Doman                 {
978dba0c291SJonathan Doman                     BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", "
979dba0c291SJonathan Doman                                        << ec.message();
980dba0c291SJonathan Doman                     messages::internalError(asyncResp->res);
981dba0c291SJonathan Doman                     return;
982dba0c291SJonathan Doman                 }
983dba0c291SJonathan Doman                 const std::string expectedEnding = cpuName + '/' + configName;
984dba0c291SJonathan Doman                 for (const auto& [objectPath, serviceMap] : subtree)
985dba0c291SJonathan Doman                 {
986dba0c291SJonathan Doman                     // Ignore any configs without matching cpuX/configY
987dba0c291SJonathan Doman                     if (!boost::ends_with(objectPath, expectedEnding) ||
988dba0c291SJonathan Doman                         serviceMap.empty())
989dba0c291SJonathan Doman                     {
990dba0c291SJonathan Doman                         continue;
991dba0c291SJonathan Doman                     }
992dba0c291SJonathan Doman 
993dba0c291SJonathan Doman                     nlohmann::json& json = asyncResp->res.jsonValue;
994dba0c291SJonathan Doman                     json["@odata.type"] =
995dba0c291SJonathan Doman                         "#OperatingConfig.v1_0_0.OperatingConfig";
996dba0c291SJonathan Doman                     json["@odata.id"] = reqUrl;
997dba0c291SJonathan Doman                     json["Name"] = "Processor Profile";
998dba0c291SJonathan Doman                     json["Id"] = configName;
999dba0c291SJonathan Doman 
1000dba0c291SJonathan Doman                     // Just use the first implementation of the object - not
1001dba0c291SJonathan Doman                     // expected that there would be multiple matching services
1002dba0c291SJonathan Doman                     getOperatingConfigData(asyncResp, serviceMap.begin()->first,
1003dba0c291SJonathan Doman                                            objectPath);
1004dba0c291SJonathan Doman                     return;
1005dba0c291SJonathan Doman                 }
1006dba0c291SJonathan Doman                 messages::resourceNotFound(asyncResp->res, "OperatingConfig",
1007dba0c291SJonathan Doman                                            configName);
1008dba0c291SJonathan Doman             },
1009dba0c291SJonathan Doman             "xyz.openbmc_project.ObjectMapper",
1010dba0c291SJonathan Doman             "/xyz/openbmc_project/object_mapper",
1011dba0c291SJonathan Doman             "xyz.openbmc_project.ObjectMapper", "GetSubTree",
1012dba0c291SJonathan Doman             "/xyz/openbmc_project/inventory", 0,
1013dba0c291SJonathan Doman             std::array<const char*, 1>{
1014dba0c291SJonathan Doman                 "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"});
1015dba0c291SJonathan Doman     }
1016dba0c291SJonathan Doman };
1017dba0c291SJonathan Doman 
1018ac6a4445SGunnar Mills class ProcessorCollection : public Node
1019ac6a4445SGunnar Mills {
1020ac6a4445SGunnar Mills   public:
1021ac6a4445SGunnar Mills     /*
1022ac6a4445SGunnar Mills      * Default Constructor
1023ac6a4445SGunnar Mills      */
1024ac6a4445SGunnar Mills     ProcessorCollection(App& app) :
1025ac6a4445SGunnar Mills         Node(app, "/redfish/v1/Systems/system/Processors/")
1026ac6a4445SGunnar Mills     {
1027ac6a4445SGunnar Mills         entityPrivileges = {
1028ac6a4445SGunnar Mills             {boost::beast::http::verb::get, {{"Login"}}},
1029ac6a4445SGunnar Mills             {boost::beast::http::verb::head, {{"Login"}}},
1030ac6a4445SGunnar Mills             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
1031ac6a4445SGunnar Mills             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
1032ac6a4445SGunnar Mills             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
1033ac6a4445SGunnar Mills             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
1034ac6a4445SGunnar Mills     }
1035ac6a4445SGunnar Mills 
1036ac6a4445SGunnar Mills   private:
1037ac6a4445SGunnar Mills     /**
1038ac6a4445SGunnar Mills      * Functions triggers appropriate requests on DBus
1039ac6a4445SGunnar Mills      */
1040ac6a4445SGunnar Mills     void doGet(crow::Response& res, const crow::Request&,
1041ac6a4445SGunnar Mills                const std::vector<std::string>&) override
1042ac6a4445SGunnar Mills     {
1043ac6a4445SGunnar Mills         res.jsonValue["@odata.type"] =
1044ac6a4445SGunnar Mills             "#ProcessorCollection.ProcessorCollection";
1045ac6a4445SGunnar Mills         res.jsonValue["Name"] = "Processor Collection";
1046ac6a4445SGunnar Mills 
10479dedf572SGunnar Mills         res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Processors";
1048ac6a4445SGunnar Mills         auto asyncResp = std::make_shared<AsyncResp>(res);
1049ac6a4445SGunnar Mills 
105005030b8eSGunnar Mills         collection_util::getCollectionMembers(
105105030b8eSGunnar Mills             asyncResp, "/redfish/v1/Systems/system/Processors",
1052*c951448aSJonathan Doman             std::vector<const char*>(processorInterfaces.begin(),
1053*c951448aSJonathan Doman                                      processorInterfaces.end()));
1054ac6a4445SGunnar Mills     }
1055ac6a4445SGunnar Mills };
1056ac6a4445SGunnar Mills 
1057ac6a4445SGunnar Mills class Processor : public Node
1058ac6a4445SGunnar Mills {
1059ac6a4445SGunnar Mills   public:
1060ac6a4445SGunnar Mills     /*
1061ac6a4445SGunnar Mills      * Default Constructor
1062ac6a4445SGunnar Mills      */
1063ac6a4445SGunnar Mills     Processor(App& app) :
1064ac6a4445SGunnar Mills         Node(app, "/redfish/v1/Systems/system/Processors/<str>/", std::string())
1065ac6a4445SGunnar Mills     {
1066ac6a4445SGunnar Mills         entityPrivileges = {
1067ac6a4445SGunnar Mills             {boost::beast::http::verb::get, {{"Login"}}},
1068ac6a4445SGunnar Mills             {boost::beast::http::verb::head, {{"Login"}}},
1069ac6a4445SGunnar Mills             {boost::beast::http::verb::patch, {{"ConfigureComponents"}}},
1070ac6a4445SGunnar Mills             {boost::beast::http::verb::put, {{"ConfigureComponents"}}},
1071ac6a4445SGunnar Mills             {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}},
1072ac6a4445SGunnar Mills             {boost::beast::http::verb::post, {{"ConfigureComponents"}}}};
1073ac6a4445SGunnar Mills     }
1074ac6a4445SGunnar Mills 
1075ac6a4445SGunnar Mills   private:
1076ac6a4445SGunnar Mills     /**
1077ac6a4445SGunnar Mills      * Functions triggers appropriate requests on DBus
1078ac6a4445SGunnar Mills      */
1079ac6a4445SGunnar Mills     void doGet(crow::Response& res, const crow::Request&,
1080ac6a4445SGunnar Mills                const std::vector<std::string>& params) override
1081ac6a4445SGunnar Mills     {
1082ac6a4445SGunnar Mills         // Check if there is required param, truly entering this shall be
1083ac6a4445SGunnar Mills         // impossible
1084ac6a4445SGunnar Mills         if (params.size() != 1)
1085ac6a4445SGunnar Mills         {
1086ac6a4445SGunnar Mills             messages::internalError(res);
1087ac6a4445SGunnar Mills 
1088ac6a4445SGunnar Mills             res.end();
1089ac6a4445SGunnar Mills             return;
1090ac6a4445SGunnar Mills         }
1091ac6a4445SGunnar Mills         const std::string& processorId = params[0];
1092cba4f448SSunnySrivastava1984         res.jsonValue["@odata.type"] = "#Processor.v1_11_0.Processor";
1093ac6a4445SGunnar Mills         res.jsonValue["@odata.id"] =
1094ac6a4445SGunnar Mills             "/redfish/v1/Systems/system/Processors/" + processorId;
1095ac6a4445SGunnar Mills 
1096ac6a4445SGunnar Mills         auto asyncResp = std::make_shared<AsyncResp>(res);
1097ac6a4445SGunnar Mills 
1098*c951448aSJonathan Doman         getProcessorObject(asyncResp, processorId, getProcessorData);
1099ac6a4445SGunnar Mills     }
1100ac6a4445SGunnar Mills };
1101ac6a4445SGunnar Mills 
1102ac6a4445SGunnar Mills } // namespace redfish
1103