summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-common/recipes-phosphor/interfaces/bmcweb/0003-add-new-cpu-fields.patch
blob: 1e4f2efd7a40e9925ffc08c7d302d8b41798d72b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
From 644dc71f3ff13fbc620d6ea8bff89736dc7cc691 Mon Sep 17 00:00:00 2001
From: eportnov <eportnov@ibs.ru>
Date: Fri, 8 Jul 2022 10:31:14 +0300
Subject: [PATCH] add new cpu fields

---
 redfish-core/lib/processor.hpp | 106 +++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 2a0e028..a83211a 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -66,6 +66,77 @@ inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> aResp,
         });
 }
 
+inline std::string translateInstructionSetTypeToRedfish(const std::string& instructionSetType)
+{
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.ARM_A32")
+    {
+        return "ARM-A32";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.ARM_A64")
+    {
+        return "ARM-A64";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.IA_64")
+    {
+        return "IA-64";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.MIPS32")
+    {
+        return "MIPS32";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.MIPS64")
+    {
+        return "MIPS64";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.OEM")
+    {
+        return "OEM";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.PowerISA")
+    {
+        return "PowerISA";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.x86")
+    {
+        return "x86";
+    }
+    if (instructionSetType == "xyz.openbmc_project.Inventory.Item.Cpu.Instruction.x86_64")
+    {
+        return "x86-64";
+    }
+    return "";
+}
+
+inline std::string translateProcessorArchTypeToRedfish(const std::string& processorArchType)
+{
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.ARM")
+    {
+        return "ARM";
+    }
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.IA_64")
+    {
+        return "IA-64";
+    }
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.MIPS")
+    {
+        return "MIPS";
+    }
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.OEM")
+    {
+        return "OEM";
+    }
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.Power")
+    {
+        return "Power";
+    }
+    if (processorArchType == "xyz.openbmc_project.Inventory.Item.Cpu.ProcessorArchitecture.x86")
+    {
+        return "x86";
+    }
+    return "";
+}
+
+
 inline void getCpuDataByInterface(
     const std::shared_ptr<bmcweb::AsyncResp>& aResp,
     const dbus::utility::DBusInteracesMap& cpuInterfacesProperties)
@@ -144,6 +215,41 @@ inline void getCpuDataByInterface(
                     aResp->res.jsonValue["TotalThreads"] = *value;
                 }
             }
+            else if (property.first == "InstructionSet")
+            {
+                const std::string* value =
+                    std::get_if<std::string>(&property.second);
+                if (value != nullptr)
+                {
+                    aResp->res.jsonValue["InstructionSet"] = translateInstructionSetTypeToRedfish(*value);
+                }
+            }
+            else if (property.first == "Version")
+            {
+                const std::string* value =
+                    std::get_if<std::string>(&property.second);
+                if (value != nullptr)
+                {
+                    aResp->res.jsonValue["Version"] = *value;
+                }
+            }
+            else if (property.first == "ProcessorArchitecture")
+            {
+                const std::string* value =
+                    std::get_if<std::string>(&property.second);
+                if (value != nullptr)
+                {
+                    aResp->res.jsonValue["ProcessorArchitecture"] = translateProcessorArchTypeToRedfish(*value);
+                }
+            }
+            else if (property.first == "MinSpeedMHz")
+            {
+                const uint32_t* value = std::get_if<uint32_t>(&property.second);
+                if (value != nullptr)
+                {
+                    aResp->res.jsonValue["MinSpeedMHz"] = *value;
+                }
+            }
             else if (property.first == "EffectiveFamily")
             {
                 const uint16_t* value = std::get_if<uint16_t>(&property.second);