| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | // Copyright (c) 2018 Intel Corporation | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | */ | 
|  | 16 | #pragma once | 
|  | 17 |  | 
| Willy Tu | 13451e3 | 2023-05-24 16:08:18 -0700 | [diff] [blame] | 18 | #include "bmcweb_config.h" | 
|  | 19 |  | 
| Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 20 | #include "app.hpp" | 
|  | 21 | #include "dbus_utility.hpp" | 
| James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 22 | #include "health.hpp" | 
| Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 23 | #include "query.hpp" | 
|  | 24 | #include "registries/privilege_registry.hpp" | 
|  | 25 | #include "utils/collection.hpp" | 
|  | 26 | #include "utils/dbus_utils.hpp" | 
|  | 27 | #include "utils/hex_utils.hpp" | 
|  | 28 | #include "utils/json_utils.hpp" | 
| James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 29 |  | 
| George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 30 | #include <boost/system/error_code.hpp> | 
| Ed Tanous | ef4c65b | 2023-04-24 15:28:50 -0700 | [diff] [blame] | 31 | #include <boost/url/format.hpp> | 
| Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 32 | #include <nlohmann/json.hpp> | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 33 | #include <sdbusplus/asio/property.hpp> | 
|  | 34 | #include <sdbusplus/unpack_properties.hpp> | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 35 |  | 
| George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 36 | #include <array> | 
|  | 37 | #include <string_view> | 
|  | 38 |  | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 39 | namespace redfish | 
|  | 40 | { | 
|  | 41 |  | 
| Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 42 | inline std::string translateMemoryTypeToRedfish(const std::string& memoryType) | 
|  | 43 | { | 
|  | 44 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR") | 
|  | 45 | { | 
|  | 46 | return "DDR"; | 
|  | 47 | } | 
|  | 48 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2") | 
|  | 49 | { | 
|  | 50 | return "DDR2"; | 
|  | 51 | } | 
|  | 52 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR3") | 
|  | 53 | { | 
|  | 54 | return "DDR3"; | 
|  | 55 | } | 
|  | 56 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR4") | 
|  | 57 | { | 
|  | 58 | return "DDR4"; | 
|  | 59 | } | 
|  | 60 | if (memoryType == | 
|  | 61 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR4E_SDRAM") | 
|  | 62 | { | 
|  | 63 | return "DDR4E_SDRAM"; | 
|  | 64 | } | 
| Mansi Joshi | 11a2f0f | 2021-07-19 14:33:27 +0530 | [diff] [blame] | 65 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR5") | 
|  | 66 | { | 
|  | 67 | return "DDR5"; | 
|  | 68 | } | 
| Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 69 | if (memoryType == | 
|  | 70 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.LPDDR4_SDRAM") | 
|  | 71 | { | 
|  | 72 | return "LPDDR4_SDRAM"; | 
|  | 73 | } | 
|  | 74 | if (memoryType == | 
|  | 75 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.LPDDR3_SDRAM") | 
|  | 76 | { | 
|  | 77 | return "LPDDR3_SDRAM"; | 
|  | 78 | } | 
|  | 79 | if (memoryType == | 
|  | 80 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2_SDRAM_FB_DIMM") | 
|  | 81 | { | 
|  | 82 | return "DDR2_SDRAM_FB_DIMM"; | 
|  | 83 | } | 
| George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 84 | if (memoryType == | 
|  | 85 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2_SDRAM_FB_DIMM_PROB") | 
| Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 86 | { | 
|  | 87 | return "DDR2_SDRAM_FB_DIMM_PROBE"; | 
|  | 88 | } | 
|  | 89 | if (memoryType == | 
|  | 90 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR_SGRAM") | 
|  | 91 | { | 
|  | 92 | return "DDR_SGRAM"; | 
|  | 93 | } | 
|  | 94 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.ROM") | 
|  | 95 | { | 
|  | 96 | return "ROM"; | 
|  | 97 | } | 
|  | 98 | if (memoryType == | 
|  | 99 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.SDRAM") | 
|  | 100 | { | 
|  | 101 | return "SDRAM"; | 
|  | 102 | } | 
|  | 103 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.EDO") | 
|  | 104 | { | 
|  | 105 | return "EDO"; | 
|  | 106 | } | 
|  | 107 | if (memoryType == | 
|  | 108 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.FastPageMode") | 
|  | 109 | { | 
|  | 110 | return "FastPageMode"; | 
|  | 111 | } | 
|  | 112 | if (memoryType == | 
|  | 113 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.PipelinedNibble") | 
|  | 114 | { | 
|  | 115 | return "PipelinedNibble"; | 
|  | 116 | } | 
|  | 117 | if (memoryType == | 
|  | 118 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.Logical") | 
|  | 119 | { | 
|  | 120 | return "Logical"; | 
|  | 121 | } | 
|  | 122 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM") | 
|  | 123 | { | 
|  | 124 | return "HBM"; | 
|  | 125 | } | 
|  | 126 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM2") | 
|  | 127 | { | 
|  | 128 | return "HBM2"; | 
|  | 129 | } | 
| Tyson Tuckerbear | ce34d51 | 2022-09-13 16:26:15 -0700 | [diff] [blame] | 130 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM3") | 
|  | 131 | { | 
|  | 132 | return "HBM3"; | 
|  | 133 | } | 
| Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 134 | // This is values like Other or Unknown | 
|  | 135 | // Also D-Bus values: | 
|  | 136 | // DRAM | 
|  | 137 | // EDRAM | 
|  | 138 | // VRAM | 
|  | 139 | // SRAM | 
|  | 140 | // RAM | 
|  | 141 | // FLASH | 
|  | 142 | // EEPROM | 
|  | 143 | // FEPROM | 
|  | 144 | // EPROM | 
|  | 145 | // CDRAM | 
|  | 146 | // ThreeDRAM | 
|  | 147 | // RDRAM | 
|  | 148 | // FBD2 | 
|  | 149 | // LPDDR_SDRAM | 
|  | 150 | // LPDDR2_SDRAM | 
| Mansi Joshi | 11a2f0f | 2021-07-19 14:33:27 +0530 | [diff] [blame] | 151 | // LPDDR5_SDRAM | 
| Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 152 | return ""; | 
|  | 153 | } | 
|  | 154 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 155 | inline void dimmPropToHex(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 156 | const char* key, const uint16_t* value, | 
|  | 157 | const nlohmann::json::json_pointer& jsonPtr) | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 158 | { | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 159 | if (value == nullptr) | 
|  | 160 | { | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 161 | return; | 
|  | 162 | } | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 163 | asyncResp->res.jsonValue[jsonPtr][key] = "0x" + intToHexString(*value, 4); | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 164 | } | 
|  | 165 |  | 
| zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 166 | inline void getPersistentMemoryProperties( | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 167 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 168 | const dbus::utility::DBusPropertiesMap& properties, | 
| Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 169 | const nlohmann::json::json_pointer& jsonPtr) | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 170 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 171 | const uint16_t* moduleManufacturerID = nullptr; | 
|  | 172 | const uint16_t* moduleProductID = nullptr; | 
|  | 173 | const uint16_t* subsystemVendorID = nullptr; | 
|  | 174 | const uint16_t* subsystemDeviceID = nullptr; | 
|  | 175 | const uint64_t* volatileRegionSizeLimitInKiB = nullptr; | 
|  | 176 | const uint64_t* pmRegionSizeLimitInKiB = nullptr; | 
|  | 177 | const uint64_t* volatileSizeInKiB = nullptr; | 
|  | 178 | const uint64_t* pmSizeInKiB = nullptr; | 
|  | 179 | const uint64_t* cacheSizeInKB = nullptr; | 
|  | 180 | const uint64_t* voltaileRegionMaxSizeInKib = nullptr; | 
|  | 181 | const uint64_t* pmRegionMaxSizeInKiB = nullptr; | 
|  | 182 | const uint64_t* allocationIncrementInKiB = nullptr; | 
|  | 183 | const uint64_t* allocationAlignmentInKiB = nullptr; | 
|  | 184 | const uint64_t* volatileRegionNumberLimit = nullptr; | 
|  | 185 | const uint64_t* pmRegionNumberLimit = nullptr; | 
|  | 186 | const uint64_t* spareDeviceCount = nullptr; | 
|  | 187 | const bool* isSpareDeviceInUse = nullptr; | 
|  | 188 | const bool* isRankSpareEnabled = nullptr; | 
|  | 189 | const std::vector<uint32_t>* maxAveragePowerLimitmW = nullptr; | 
|  | 190 | const bool* configurationLocked = nullptr; | 
|  | 191 | const std::string* allowedMemoryModes = nullptr; | 
|  | 192 | const std::string* memoryMedia = nullptr; | 
|  | 193 | const bool* configurationLockCapable = nullptr; | 
|  | 194 | const bool* dataLockCapable = nullptr; | 
|  | 195 | const bool* passphraseCapable = nullptr; | 
|  | 196 | const uint64_t* maxPassphraseCount = nullptr; | 
|  | 197 | const uint64_t* passphraseLockLimit = nullptr; | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 198 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 199 | const bool success = sdbusplus::unpackPropertiesNoThrow( | 
|  | 200 | dbus_utils::UnpackErrorPrinter(), properties, "ModuleManufacturerID", | 
|  | 201 | moduleManufacturerID, "ModuleProductID", moduleProductID, | 
|  | 202 | "SubsystemVendorID", subsystemVendorID, "SubsystemDeviceID", | 
|  | 203 | subsystemDeviceID, "VolatileRegionSizeLimitInKiB", | 
|  | 204 | volatileRegionSizeLimitInKiB, "PmRegionSizeLimitInKiB", | 
|  | 205 | pmRegionSizeLimitInKiB, "VolatileSizeInKiB", volatileSizeInKiB, | 
|  | 206 | "PmSizeInKiB", pmSizeInKiB, "CacheSizeInKB", cacheSizeInKB, | 
|  | 207 | "VoltaileRegionMaxSizeInKib", voltaileRegionMaxSizeInKib, | 
|  | 208 | "PmRegionMaxSizeInKiB", pmRegionMaxSizeInKiB, | 
|  | 209 | "AllocationIncrementInKiB", allocationIncrementInKiB, | 
|  | 210 | "AllocationAlignmentInKiB", allocationAlignmentInKiB, | 
|  | 211 | "VolatileRegionNumberLimit", volatileRegionNumberLimit, | 
|  | 212 | "PmRegionNumberLimit", pmRegionNumberLimit, "SpareDeviceCount", | 
|  | 213 | spareDeviceCount, "IsSpareDeviceInUse", isSpareDeviceInUse, | 
|  | 214 | "IsRankSpareEnabled", isRankSpareEnabled, "MaxAveragePowerLimitmW", | 
|  | 215 | maxAveragePowerLimitmW, "ConfigurationLocked", configurationLocked, | 
|  | 216 | "AllowedMemoryModes", allowedMemoryModes, "MemoryMedia", memoryMedia, | 
|  | 217 | "ConfigurationLockCapable", configurationLockCapable, "DataLockCapable", | 
|  | 218 | dataLockCapable, "PassphraseCapable", passphraseCapable, | 
|  | 219 | "MaxPassphraseCount", maxPassphraseCount, "PassphraseLockLimit", | 
|  | 220 | passphraseLockLimit); | 
|  | 221 |  | 
|  | 222 | if (!success) | 
|  | 223 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 224 | messages::internalError(asyncResp->res); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 225 | return; | 
|  | 226 | } | 
|  | 227 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 228 | dimmPropToHex(asyncResp, "ModuleManufacturerID", moduleManufacturerID, | 
|  | 229 | jsonPtr); | 
|  | 230 | dimmPropToHex(asyncResp, "ModuleProductID", moduleProductID, jsonPtr); | 
|  | 231 | dimmPropToHex(asyncResp, "MemorySubsystemControllerManufacturerID", | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 232 | subsystemVendorID, jsonPtr); | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 233 | dimmPropToHex(asyncResp, "MemorySubsystemControllerProductID", | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 234 | subsystemDeviceID, jsonPtr); | 
|  | 235 |  | 
|  | 236 | if (volatileRegionSizeLimitInKiB != nullptr) | 
|  | 237 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 238 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeLimitMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 239 | (*volatileRegionSizeLimitInKiB) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 240 | } | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 241 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 242 | if (pmRegionSizeLimitInKiB != nullptr) | 
|  | 243 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 244 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeLimitMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 245 | (*pmRegionSizeLimitInKiB) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 246 | } | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 247 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 248 | if (volatileSizeInKiB != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 249 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 250 | asyncResp->res.jsonValue[jsonPtr]["VolatileSizeMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 251 | (*volatileSizeInKiB) >> 10; | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | if (pmSizeInKiB != nullptr) | 
|  | 255 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 256 | asyncResp->res.jsonValue[jsonPtr]["NonVolatileSizeMiB"] = | 
|  | 257 | (*pmSizeInKiB) >> 10; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 258 | } | 
|  | 259 |  | 
|  | 260 | if (cacheSizeInKB != nullptr) | 
|  | 261 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 262 | asyncResp->res.jsonValue[jsonPtr]["CacheSizeMiB"] = | 
|  | 263 | (*cacheSizeInKB >> 10); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 264 | } | 
|  | 265 |  | 
|  | 266 | if (voltaileRegionMaxSizeInKib != nullptr) | 
|  | 267 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 268 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeMaxMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 269 | (*voltaileRegionMaxSizeInKib) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 270 | } | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 271 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 272 | if (pmRegionMaxSizeInKiB != nullptr) | 
|  | 273 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 274 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeMaxMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 275 | (*pmRegionMaxSizeInKiB) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 276 | } | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 277 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 278 | if (allocationIncrementInKiB != nullptr) | 
|  | 279 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 280 | asyncResp->res.jsonValue[jsonPtr]["AllocationIncrementMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 281 | (*allocationIncrementInKiB) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 282 | } | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 283 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 284 | if (allocationAlignmentInKiB != nullptr) | 
|  | 285 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 286 | asyncResp->res.jsonValue[jsonPtr]["AllocationAlignmentMiB"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 287 | (*allocationAlignmentInKiB) >> 10; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 288 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 289 |  | 
|  | 290 | if (volatileRegionNumberLimit != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 291 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 292 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionNumberLimit"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 293 | *volatileRegionNumberLimit; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 294 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 295 |  | 
|  | 296 | if (pmRegionNumberLimit != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 297 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 298 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionNumberLimit"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 299 | *pmRegionNumberLimit; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 300 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 301 |  | 
|  | 302 | if (spareDeviceCount != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 303 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 304 | asyncResp->res.jsonValue[jsonPtr]["SpareDeviceCount"] = | 
|  | 305 | *spareDeviceCount; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 306 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 307 |  | 
|  | 308 | if (isSpareDeviceInUse != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 309 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 310 | asyncResp->res.jsonValue[jsonPtr]["IsSpareDeviceEnabled"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 311 | *isSpareDeviceInUse; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 312 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 313 |  | 
|  | 314 | if (isRankSpareEnabled != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 315 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 316 | asyncResp->res.jsonValue[jsonPtr]["IsRankSpareEnabled"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 317 | *isRankSpareEnabled; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 318 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 319 |  | 
|  | 320 | if (maxAveragePowerLimitmW != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 321 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 322 | asyncResp->res.jsonValue[jsonPtr]["MaxTDPMilliWatts"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 323 | *maxAveragePowerLimitmW; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 324 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 325 |  | 
|  | 326 | if (configurationLocked != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 327 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 328 | asyncResp->res.jsonValue[jsonPtr]["ConfigurationLocked"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 329 | *configurationLocked; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 330 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 331 |  | 
|  | 332 | if (allowedMemoryModes != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 333 | { | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 334 | constexpr const std::array<const char*, 3> values{"Volatile", "PMEM", | 
|  | 335 | "Block"}; | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 336 |  | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 337 | for (const char* v : values) | 
|  | 338 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 339 | if (allowedMemoryModes->ends_with(v)) | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 340 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 341 | asyncResp->res.jsonValue[jsonPtr]["OperatingMemoryModes"] | 
|  | 342 | .push_back(v); | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 343 | break; | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 344 | } | 
|  | 345 | } | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 346 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 347 |  | 
|  | 348 | if (memoryMedia != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 349 | { | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 350 | constexpr const std::array<const char*, 3> values{"DRAM", "NAND", | 
|  | 351 | "Intel3DXPoint"}; | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 352 |  | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 353 | for (const char* v : values) | 
| Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 354 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 355 | if (memoryMedia->ends_with(v)) | 
| Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 356 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 357 | asyncResp->res.jsonValue[jsonPtr]["MemoryMedia"].push_back(v); | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 358 | break; | 
| Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 359 | } | 
| Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 360 | } | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 361 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 362 |  | 
|  | 363 | if (configurationLockCapable != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 364 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 365 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] | 
|  | 366 | ["ConfigurationLockCapable"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 367 | *configurationLockCapable; | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 368 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 369 |  | 
|  | 370 | if (dataLockCapable != nullptr) | 
| Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 371 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 372 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] | 
|  | 373 | ["DataLockCapable"] = *dataLockCapable; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 374 | } | 
|  | 375 |  | 
|  | 376 | if (passphraseCapable != nullptr) | 
|  | 377 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 378 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] | 
|  | 379 | ["PassphraseCapable"] = *passphraseCapable; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 380 | } | 
|  | 381 |  | 
|  | 382 | if (maxPassphraseCount != nullptr) | 
|  | 383 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 384 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] | 
|  | 385 | ["MaxPassphraseCount"] = *maxPassphraseCount; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 386 | } | 
|  | 387 |  | 
|  | 388 | if (passphraseLockLimit != nullptr) | 
|  | 389 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 390 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] | 
|  | 391 | ["PassphraseLockLimit"] = *passphraseLockLimit; | 
| James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 392 | } | 
|  | 393 | } | 
|  | 394 |  | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 395 | inline void | 
|  | 396 | assembleDimmProperties(std::string_view dimmId, | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 397 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
| Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 398 | const dbus::utility::DBusPropertiesMap& properties, | 
|  | 399 | const nlohmann::json::json_pointer& jsonPtr) | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 400 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 401 | asyncResp->res.jsonValue[jsonPtr]["Id"] = dimmId; | 
|  | 402 | asyncResp->res.jsonValue[jsonPtr]["Name"] = "DIMM Slot"; | 
|  | 403 | asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Enabled"; | 
|  | 404 | asyncResp->res.jsonValue[jsonPtr]["Status"]["Health"] = "OK"; | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 405 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 406 | const uint16_t* memoryDataWidth = nullptr; | 
|  | 407 | const size_t* memorySizeInKB = nullptr; | 
|  | 408 | const std::string* partNumber = nullptr; | 
|  | 409 | const std::string* serialNumber = nullptr; | 
|  | 410 | const std::string* manufacturer = nullptr; | 
|  | 411 | const uint16_t* revisionCode = nullptr; | 
|  | 412 | const bool* present = nullptr; | 
|  | 413 | const uint16_t* memoryTotalWidth = nullptr; | 
|  | 414 | const std::string* ecc = nullptr; | 
|  | 415 | const std::string* formFactor = nullptr; | 
|  | 416 | const std::vector<uint16_t>* allowedSpeedsMT = nullptr; | 
|  | 417 | const uint8_t* memoryAttributes = nullptr; | 
|  | 418 | const uint16_t* memoryConfiguredSpeedInMhz = nullptr; | 
|  | 419 | const std::string* memoryType = nullptr; | 
| Jayaprakash Mutyala | 6fde597 | 2023-06-15 07:56:58 +0000 | [diff] [blame^] | 420 | const std::uint8_t* channel = nullptr; | 
|  | 421 | const std::uint8_t* memoryController = nullptr; | 
|  | 422 | const std::uint8_t* slot = nullptr; | 
|  | 423 | const std::uint8_t* socket = nullptr; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 424 | const std::string* sparePartNumber = nullptr; | 
|  | 425 | const std::string* model = nullptr; | 
|  | 426 | const std::string* locationCode = nullptr; | 
|  | 427 |  | 
|  | 428 | const bool success = sdbusplus::unpackPropertiesNoThrow( | 
|  | 429 | dbus_utils::UnpackErrorPrinter(), properties, "MemoryDataWidth", | 
|  | 430 | memoryDataWidth, "MemorySizeInKB", memorySizeInKB, "PartNumber", | 
| Nikhil Namjoshi | 656472d | 2022-09-13 20:54:44 +0000 | [diff] [blame] | 431 | partNumber, "SerialNumber", serialNumber, "Manufacturer", manufacturer, | 
|  | 432 | "RevisionCode", revisionCode, "Present", present, "MemoryTotalWidth", | 
|  | 433 | memoryTotalWidth, "ECC", ecc, "FormFactor", formFactor, | 
|  | 434 | "AllowedSpeedsMT", allowedSpeedsMT, "MemoryAttributes", | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 435 | memoryAttributes, "MemoryConfiguredSpeedInMhz", | 
|  | 436 | memoryConfiguredSpeedInMhz, "MemoryType", memoryType, "Channel", | 
|  | 437 | channel, "MemoryController", memoryController, "Slot", slot, "Socket", | 
|  | 438 | socket, "SparePartNumber", sparePartNumber, "Model", model, | 
|  | 439 | "LocationCode", locationCode); | 
|  | 440 |  | 
|  | 441 | if (!success) | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 442 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 443 | messages::internalError(asyncResp->res); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 444 | return; | 
|  | 445 | } | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 446 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 447 | if (memoryDataWidth != nullptr) | 
|  | 448 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 449 | asyncResp->res.jsonValue[jsonPtr]["DataWidthBits"] = *memoryDataWidth; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 450 | } | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 451 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 452 | if (memorySizeInKB != nullptr) | 
|  | 453 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 454 | asyncResp->res.jsonValue[jsonPtr]["CapacityMiB"] = | 
|  | 455 | (*memorySizeInKB >> 10); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 456 | } | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 457 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 458 | if (partNumber != nullptr) | 
|  | 459 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 460 | asyncResp->res.jsonValue[jsonPtr]["PartNumber"] = *partNumber; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 461 | } | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 462 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 463 | if (serialNumber != nullptr) | 
|  | 464 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 465 | asyncResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 466 | } | 
|  | 467 |  | 
|  | 468 | if (manufacturer != nullptr) | 
|  | 469 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 470 | asyncResp->res.jsonValue[jsonPtr]["Manufacturer"] = *manufacturer; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 471 | } | 
|  | 472 |  | 
|  | 473 | if (revisionCode != nullptr) | 
|  | 474 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 475 | asyncResp->res.jsonValue[jsonPtr]["FirmwareRevision"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 476 | std::to_string(*revisionCode); | 
|  | 477 | } | 
|  | 478 |  | 
|  | 479 | if (present != nullptr && !*present) | 
|  | 480 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 481 | asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Absent"; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 482 | } | 
|  | 483 |  | 
|  | 484 | if (memoryTotalWidth != nullptr) | 
|  | 485 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 486 | asyncResp->res.jsonValue[jsonPtr]["BusWidthBits"] = *memoryTotalWidth; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 487 | } | 
|  | 488 |  | 
|  | 489 | if (ecc != nullptr) | 
|  | 490 | { | 
|  | 491 | constexpr const std::array<const char*, 4> values{ | 
|  | 492 | "NoECC", "SingleBitECC", "MultiBitECC", "AddressParity"}; | 
|  | 493 |  | 
|  | 494 | for (const char* v : values) | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 495 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 496 | if (ecc->ends_with(v)) | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 497 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 498 | asyncResp->res.jsonValue[jsonPtr]["ErrorCorrection"] = v; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 499 | break; | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 500 | } | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 501 | } | 
|  | 502 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 503 |  | 
|  | 504 | if (formFactor != nullptr) | 
|  | 505 | { | 
|  | 506 | constexpr const std::array<const char*, 11> values{ | 
|  | 507 | "RDIMM",       "UDIMM",       "SO_DIMM",      "LRDIMM", | 
|  | 508 | "Mini_RDIMM",  "Mini_UDIMM",  "SO_RDIMM_72b", "SO_UDIMM_72b", | 
|  | 509 | "SO_DIMM_16b", "SO_DIMM_32b", "Die"}; | 
|  | 510 |  | 
|  | 511 | for (const char* v : values) | 
|  | 512 | { | 
|  | 513 | if (formFactor->ends_with(v)) | 
|  | 514 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 515 | asyncResp->res.jsonValue[jsonPtr]["BaseModuleType"] = v; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 516 | break; | 
|  | 517 | } | 
|  | 518 | } | 
|  | 519 | } | 
|  | 520 |  | 
|  | 521 | if (allowedSpeedsMT != nullptr) | 
|  | 522 | { | 
|  | 523 | nlohmann::json& jValue = | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 524 | asyncResp->res.jsonValue[jsonPtr]["AllowedSpeedsMHz"]; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 525 | jValue = nlohmann::json::array(); | 
|  | 526 | for (uint16_t subVal : *allowedSpeedsMT) | 
|  | 527 | { | 
|  | 528 | jValue.push_back(subVal); | 
|  | 529 | } | 
|  | 530 | } | 
|  | 531 |  | 
|  | 532 | if (memoryAttributes != nullptr) | 
|  | 533 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 534 | asyncResp->res.jsonValue[jsonPtr]["RankCount"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 535 | static_cast<uint64_t>(*memoryAttributes); | 
|  | 536 | } | 
|  | 537 |  | 
|  | 538 | if (memoryConfiguredSpeedInMhz != nullptr) | 
|  | 539 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 540 | asyncResp->res.jsonValue[jsonPtr]["OperatingSpeedMhz"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 541 | *memoryConfiguredSpeedInMhz; | 
|  | 542 | } | 
|  | 543 |  | 
|  | 544 | if (memoryType != nullptr) | 
|  | 545 | { | 
|  | 546 | std::string memoryDeviceType = | 
|  | 547 | translateMemoryTypeToRedfish(*memoryType); | 
|  | 548 | // Values like "Unknown" or "Other" will return empty | 
|  | 549 | // so just leave off | 
|  | 550 | if (!memoryDeviceType.empty()) | 
|  | 551 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 552 | asyncResp->res.jsonValue[jsonPtr]["MemoryDeviceType"] = | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 553 | memoryDeviceType; | 
|  | 554 | } | 
|  | 555 | if (memoryType->find("DDR") != std::string::npos) | 
|  | 556 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 557 | asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = "DRAM"; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 558 | } | 
|  | 559 | else if (memoryType->ends_with("Logical")) | 
|  | 560 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 561 | asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = "IntelOptane"; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 562 | } | 
|  | 563 | } | 
|  | 564 |  | 
|  | 565 | if (channel != nullptr) | 
|  | 566 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 567 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Channel"] = | 
|  | 568 | *channel; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 569 | } | 
|  | 570 |  | 
|  | 571 | if (memoryController != nullptr) | 
|  | 572 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 573 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"] | 
|  | 574 | ["MemoryController"] = *memoryController; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 575 | } | 
|  | 576 |  | 
|  | 577 | if (slot != nullptr) | 
|  | 578 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 579 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Slot"] = *slot; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 580 | } | 
|  | 581 |  | 
|  | 582 | if (socket != nullptr) | 
|  | 583 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 584 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Socket"] = *socket; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 585 | } | 
|  | 586 |  | 
|  | 587 | if (sparePartNumber != nullptr) | 
|  | 588 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 589 | asyncResp->res.jsonValue[jsonPtr]["SparePartNumber"] = *sparePartNumber; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 590 | } | 
|  | 591 |  | 
|  | 592 | if (model != nullptr) | 
|  | 593 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 594 | asyncResp->res.jsonValue[jsonPtr]["Model"] = *model; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 595 | } | 
|  | 596 |  | 
|  | 597 | if (locationCode != nullptr) | 
|  | 598 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 599 | asyncResp->res.jsonValue[jsonPtr]["Location"]["PartLocation"] | 
|  | 600 | ["ServiceLabel"] = *locationCode; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 601 | } | 
|  | 602 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 603 | getPersistentMemoryProperties(asyncResp, properties, jsonPtr); | 
| Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 604 | } | 
|  | 605 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 606 | inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, | 
| Ed Tanous | 80789c8 | 2020-08-19 09:19:09 -0700 | [diff] [blame] | 607 | const std::string& dimmId, | 
|  | 608 | const std::string& service, | 
|  | 609 | const std::string& objPath) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 610 | { | 
| Willy Tu | 13451e3 | 2023-05-24 16:08:18 -0700 | [diff] [blame] | 611 | if constexpr (bmcwebEnableHealthPopulate) | 
|  | 612 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 613 | auto health = std::make_shared<HealthPopulate>(asyncResp); | 
| Willy Tu | 13451e3 | 2023-05-24 16:08:18 -0700 | [diff] [blame] | 614 | health->selfPath = objPath; | 
|  | 615 | health->populate(); | 
|  | 616 | } | 
| James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 617 |  | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 618 | BMCWEB_LOG_DEBUG << "Get available system components."; | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 619 | sdbusplus::asio::getAllProperties( | 
|  | 620 | *crow::connections::systemBus, service, objPath, "", | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 621 | [dimmId, asyncResp{std::move(asyncResp)}]( | 
| Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 622 | const boost::system::error_code& ec, | 
| Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 623 | const dbus::utility::DBusPropertiesMap& properties) { | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 624 | if (ec) | 
|  | 625 | { | 
|  | 626 | BMCWEB_LOG_DEBUG << "DBUS response error"; | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 627 | messages::internalError(asyncResp->res); | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 628 | return; | 
|  | 629 | } | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 630 | assembleDimmProperties(dimmId, asyncResp, properties, ""_json_pointer); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 631 | }); | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 632 | } | 
|  | 633 |  | 
| Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 634 | inline void assembleDimmPartitionData( | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 635 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
| Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 636 | const dbus::utility::DBusPropertiesMap& properties, | 
|  | 637 | const nlohmann::json::json_pointer& regionPtr) | 
| Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 638 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 639 | const std::string* memoryClassification = nullptr; | 
|  | 640 | const uint64_t* offsetInKiB = nullptr; | 
|  | 641 | const std::string* partitionId = nullptr; | 
|  | 642 | const bool* passphraseState = nullptr; | 
|  | 643 | const uint64_t* sizeInKiB = nullptr; | 
|  | 644 |  | 
|  | 645 | const bool success = sdbusplus::unpackPropertiesNoThrow( | 
|  | 646 | dbus_utils::UnpackErrorPrinter(), properties, "MemoryClassification", | 
|  | 647 | memoryClassification, "OffsetInKiB", offsetInKiB, "PartitionId", | 
|  | 648 | partitionId, "PassphraseState", passphraseState, "SizeInKiB", | 
|  | 649 | sizeInKiB); | 
|  | 650 |  | 
|  | 651 | if (!success) | 
| Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 652 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 653 | messages::internalError(asyncResp->res); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 654 | return; | 
| Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 655 | } | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 656 |  | 
|  | 657 | nlohmann::json::object_t partition; | 
|  | 658 |  | 
|  | 659 | if (memoryClassification != nullptr) | 
|  | 660 | { | 
|  | 661 | partition["MemoryClassification"] = *memoryClassification; | 
|  | 662 | } | 
|  | 663 |  | 
|  | 664 | if (offsetInKiB != nullptr) | 
|  | 665 | { | 
|  | 666 | partition["OffsetMiB"] = (*offsetInKiB >> 10); | 
|  | 667 | } | 
|  | 668 |  | 
|  | 669 | if (partitionId != nullptr) | 
|  | 670 | { | 
|  | 671 | partition["RegionId"] = *partitionId; | 
|  | 672 | } | 
|  | 673 |  | 
|  | 674 | if (passphraseState != nullptr) | 
|  | 675 | { | 
|  | 676 | partition["PassphraseEnabled"] = *passphraseState; | 
|  | 677 | } | 
|  | 678 |  | 
|  | 679 | if (sizeInKiB != nullptr) | 
|  | 680 | { | 
|  | 681 | partition["SizeMiB"] = (*sizeInKiB >> 10); | 
|  | 682 | } | 
|  | 683 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 684 | asyncResp->res.jsonValue[regionPtr].emplace_back(std::move(partition)); | 
| Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 685 | } | 
|  | 686 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 687 | inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, | 
| Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 688 | const std::string& service, | 
|  | 689 | const std::string& path) | 
| James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 690 | { | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 691 | sdbusplus::asio::getAllProperties( | 
|  | 692 | *crow::connections::systemBus, service, path, | 
|  | 693 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition", | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 694 | [asyncResp{std::move(asyncResp)}]( | 
| Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 695 | const boost::system::error_code& ec, | 
| Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 696 | const dbus::utility::DBusPropertiesMap& properties) { | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 697 | if (ec) | 
|  | 698 | { | 
|  | 699 | BMCWEB_LOG_DEBUG << "DBUS response error"; | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 700 | messages::internalError(asyncResp->res); | 
| James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 701 |  | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 702 | return; | 
|  | 703 | } | 
| Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 704 | nlohmann::json::json_pointer regionPtr = "/Regions"_json_pointer; | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 705 | assembleDimmPartitionData(asyncResp, properties, regionPtr); | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 706 | } | 
| James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 707 |  | 
| Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 708 | ); | 
| James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 709 | } | 
|  | 710 |  | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 711 | inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, | 
| Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 712 | const std::string& dimmId) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 713 | { | 
|  | 714 | BMCWEB_LOG_DEBUG << "Get available system dimm resources."; | 
| George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 715 | constexpr std::array<std::string_view, 2> dimmInterfaces = { | 
|  | 716 | "xyz.openbmc_project.Inventory.Item.Dimm", | 
|  | 717 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"}; | 
|  | 718 | dbus::utility::getSubTree( | 
|  | 719 | "/xyz/openbmc_project/inventory", 0, dimmInterfaces, | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 720 | [dimmId, asyncResp{std::move(asyncResp)}]( | 
| George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 721 | const boost::system::error_code& ec, | 
| Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 722 | const dbus::utility::MapperGetSubTreeResponse& subtree) { | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 723 | if (ec) | 
|  | 724 | { | 
|  | 725 | BMCWEB_LOG_DEBUG << "DBUS response error"; | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 726 | messages::internalError(asyncResp->res); | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 727 |  | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 728 | return; | 
|  | 729 | } | 
|  | 730 | bool found = false; | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 731 | for (const auto& [rawPath, object] : subtree) | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 732 | { | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 733 | sdbusplus::message::object_path path(rawPath); | 
|  | 734 | for (const auto& [service, interfaces] : object) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 735 | { | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 736 | for (const auto& interface : interfaces) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 737 | { | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 738 | if (interface == | 
|  | 739 | "xyz.openbmc_project.Inventory.Item.Dimm" && | 
|  | 740 | path.filename() == dimmId) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 741 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 742 | getDimmDataByService(asyncResp, dimmId, service, | 
|  | 743 | rawPath); | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 744 | found = true; | 
|  | 745 | } | 
| James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 746 |  | 
| Nan Zhou | 76686dc | 2022-06-17 23:01:51 +0000 | [diff] [blame] | 747 | // partitions are separate as there can be multiple | 
|  | 748 | // per | 
|  | 749 | // device, i.e. | 
|  | 750 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1 | 
|  | 751 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2 | 
|  | 752 | if (interface == | 
|  | 753 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" && | 
|  | 754 | path.parent_path().filename() == dimmId) | 
|  | 755 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 756 | getDimmPartitionData(asyncResp, service, rawPath); | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 757 | } | 
|  | 758 | } | 
|  | 759 | } | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 760 | } | 
|  | 761 | // Object not found | 
|  | 762 | if (!found) | 
|  | 763 | { | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 764 | messages::resourceNotFound(asyncResp->res, "Memory", dimmId); | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 765 | return; | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 766 | } | 
|  | 767 | // Set @odata only if object is found | 
| Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 768 | asyncResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory"; | 
|  | 769 | asyncResp->res.jsonValue["@odata.id"] = | 
| Ed Tanous | ef4c65b | 2023-04-24 15:28:50 -0700 | [diff] [blame] | 770 | boost::urls::format("/redfish/v1/Systems/system/Memory/{}", dimmId); | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 771 | return; | 
| George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 772 | }); | 
| Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 773 | } | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 774 |  | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 775 | inline void requestRoutesMemoryCollection(App& app) | 
| Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 776 | { | 
| Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 777 | /** | 
|  | 778 | * Functions triggers appropriate requests on DBus | 
|  | 779 | */ | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 780 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/") | 
| Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 781 | .privileges(redfish::privileges::getMemoryCollection) | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 782 | .methods(boost::beast::http::verb::get)( | 
| Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 783 | [&app](const crow::Request& req, | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 784 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
|  | 785 | const std::string& systemName) { | 
| Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 786 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 787 | { | 
|  | 788 | return; | 
|  | 789 | } | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 790 | if (systemName != "system") | 
|  | 791 | { | 
|  | 792 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", | 
|  | 793 | systemName); | 
|  | 794 | return; | 
|  | 795 | } | 
|  | 796 |  | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 797 | asyncResp->res.jsonValue["@odata.type"] = | 
|  | 798 | "#MemoryCollection.MemoryCollection"; | 
|  | 799 | asyncResp->res.jsonValue["Name"] = "Memory Module Collection"; | 
|  | 800 | asyncResp->res.jsonValue["@odata.id"] = | 
|  | 801 | "/redfish/v1/Systems/system/Memory"; | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 802 |  | 
| George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 803 | constexpr std::array<std::string_view, 1> interfaces{ | 
|  | 804 | "xyz.openbmc_project.Inventory.Item.Dimm"}; | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 805 | collection_util::getCollectionMembers( | 
| Willy Tu | ae9031f | 2022-09-27 05:48:07 +0000 | [diff] [blame] | 806 | asyncResp, boost::urls::url("/redfish/v1/Systems/system/Memory"), | 
| George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 807 | interfaces); | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 808 | }); | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 809 | } | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 810 |  | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 811 | inline void requestRoutesMemory(App& app) | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 812 | { | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 813 | /** | 
|  | 814 | * Functions triggers appropriate requests on DBus | 
|  | 815 | */ | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 816 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/<str>/") | 
| Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 817 | .privileges(redfish::privileges::getMemory) | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 818 | .methods(boost::beast::http::verb::get)( | 
| Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 819 | [&app](const crow::Request& req, | 
|  | 820 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 821 | const std::string& systemName, const std::string& dimmId) { | 
| Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 822 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 823 | { | 
|  | 824 | return; | 
|  | 825 | } | 
| Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 826 | if (systemName != "system") | 
|  | 827 | { | 
|  | 828 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", | 
|  | 829 | systemName); | 
|  | 830 | return; | 
|  | 831 | } | 
|  | 832 |  | 
| Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 833 | getDimmData(asyncResp, dimmId); | 
|  | 834 | }); | 
| John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 835 | } | 
| Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 836 |  | 
|  | 837 | } // namespace redfish |