Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| 3 | // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 4 | #pragma once |
| 5 | |
Willy Tu | 13451e3 | 2023-05-24 16:08:18 -0700 | [diff] [blame] | 6 | #include "bmcweb_config.h" |
| 7 | |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 8 | #include "app.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 9 | #include "async_resp.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 10 | #include "dbus_utility.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 11 | #include "error_messages.hpp" |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 12 | #include "generated/enums/memory.hpp" |
| 13 | #include "generated/enums/resource.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 14 | #include "http_request.hpp" |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 15 | #include "led.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 16 | #include "logging.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 17 | #include "query.hpp" |
| 18 | #include "registries/privilege_registry.hpp" |
| 19 | #include "utils/collection.hpp" |
| 20 | #include "utils/dbus_utils.hpp" |
| 21 | #include "utils/hex_utils.hpp" |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 22 | #include "utils/json_utils.hpp" |
| 23 | |
| 24 | #include <asm-generic/errno.h> |
James Feist | 35e257a | 2020-06-05 13:30:51 -0700 | [diff] [blame] | 25 | |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 26 | #include <boost/beast/http/verb.hpp> |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 27 | #include <boost/system/error_code.hpp> |
Ed Tanous | ef4c65b | 2023-04-24 15:28:50 -0700 | [diff] [blame] | 28 | #include <boost/url/format.hpp> |
Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 29 | #include <nlohmann/json.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 30 | #include <sdbusplus/message/native_types.hpp> |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 31 | #include <sdbusplus/unpack_properties.hpp> |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 32 | |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 33 | #include <array> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 34 | #include <cstddef> |
| 35 | #include <cstdint> |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 36 | #include <functional> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 37 | #include <memory> |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 38 | #include <optional> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 39 | #include <string> |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 40 | #include <string_view> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 41 | #include <utility> |
| 42 | #include <vector> |
George Liu | 7a1dbc4 | 2022-12-07 16:03:22 +0800 | [diff] [blame] | 43 | |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 44 | namespace redfish |
| 45 | { |
| 46 | |
Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 47 | inline std::string translateMemoryTypeToRedfish(const std::string& memoryType) |
| 48 | { |
| 49 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR") |
| 50 | { |
| 51 | return "DDR"; |
| 52 | } |
| 53 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2") |
| 54 | { |
| 55 | return "DDR2"; |
| 56 | } |
| 57 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR3") |
| 58 | { |
| 59 | return "DDR3"; |
| 60 | } |
| 61 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR4") |
| 62 | { |
| 63 | return "DDR4"; |
| 64 | } |
| 65 | if (memoryType == |
| 66 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR4E_SDRAM") |
| 67 | { |
| 68 | return "DDR4E_SDRAM"; |
| 69 | } |
Mansi Joshi | 11a2f0f | 2021-07-19 14:33:27 +0530 | [diff] [blame] | 70 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR5") |
| 71 | { |
| 72 | return "DDR5"; |
| 73 | } |
Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 74 | if (memoryType == |
| 75 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.LPDDR4_SDRAM") |
| 76 | { |
| 77 | return "LPDDR4_SDRAM"; |
| 78 | } |
| 79 | if (memoryType == |
| 80 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.LPDDR3_SDRAM") |
| 81 | { |
| 82 | return "LPDDR3_SDRAM"; |
| 83 | } |
| 84 | if (memoryType == |
| 85 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2_SDRAM_FB_DIMM") |
| 86 | { |
| 87 | return "DDR2_SDRAM_FB_DIMM"; |
| 88 | } |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 89 | if (memoryType == |
| 90 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR2_SDRAM_FB_DIMM_PROB") |
Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 91 | { |
| 92 | return "DDR2_SDRAM_FB_DIMM_PROBE"; |
| 93 | } |
| 94 | if (memoryType == |
| 95 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.DDR_SGRAM") |
| 96 | { |
| 97 | return "DDR_SGRAM"; |
| 98 | } |
| 99 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.ROM") |
| 100 | { |
| 101 | return "ROM"; |
| 102 | } |
| 103 | if (memoryType == |
| 104 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.SDRAM") |
| 105 | { |
| 106 | return "SDRAM"; |
| 107 | } |
| 108 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.EDO") |
| 109 | { |
| 110 | return "EDO"; |
| 111 | } |
| 112 | if (memoryType == |
| 113 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.FastPageMode") |
| 114 | { |
| 115 | return "FastPageMode"; |
| 116 | } |
| 117 | if (memoryType == |
| 118 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.PipelinedNibble") |
| 119 | { |
| 120 | return "PipelinedNibble"; |
| 121 | } |
| 122 | if (memoryType == |
| 123 | "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.Logical") |
| 124 | { |
| 125 | return "Logical"; |
| 126 | } |
| 127 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM") |
| 128 | { |
| 129 | return "HBM"; |
| 130 | } |
| 131 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM2") |
| 132 | { |
| 133 | return "HBM2"; |
| 134 | } |
Tyson Tuckerbear | ce34d51 | 2022-09-13 16:26:15 -0700 | [diff] [blame] | 135 | if (memoryType == "xyz.openbmc_project.Inventory.Item.Dimm.DeviceType.HBM3") |
| 136 | { |
| 137 | return "HBM3"; |
| 138 | } |
Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 139 | // This is values like Other or Unknown |
| 140 | // Also D-Bus values: |
| 141 | // DRAM |
| 142 | // EDRAM |
| 143 | // VRAM |
| 144 | // SRAM |
| 145 | // RAM |
| 146 | // FLASH |
| 147 | // EEPROM |
| 148 | // FEPROM |
| 149 | // EPROM |
| 150 | // CDRAM |
| 151 | // ThreeDRAM |
| 152 | // RDRAM |
| 153 | // FBD2 |
| 154 | // LPDDR_SDRAM |
| 155 | // LPDDR2_SDRAM |
Mansi Joshi | 11a2f0f | 2021-07-19 14:33:27 +0530 | [diff] [blame] | 156 | // LPDDR5_SDRAM |
Gunnar Mills | 313efb1 | 2020-10-26 16:05:08 -0500 | [diff] [blame] | 157 | return ""; |
| 158 | } |
| 159 | |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 160 | inline void dimmPropToHex(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 161 | const char* key, const uint16_t* value, |
| 162 | const nlohmann::json::json_pointer& jsonPtr) |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 163 | { |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 164 | if (value == nullptr) |
| 165 | { |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 166 | return; |
| 167 | } |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 168 | asyncResp->res.jsonValue[jsonPtr][key] = "0x" + intToHexString(*value, 4); |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 171 | inline void getPersistentMemoryProperties( |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 172 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 173 | const dbus::utility::DBusPropertiesMap& properties, |
Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 174 | const nlohmann::json::json_pointer& jsonPtr) |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 175 | { |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 176 | const uint16_t* moduleManufacturerID = nullptr; |
| 177 | const uint16_t* moduleProductID = nullptr; |
| 178 | const uint16_t* subsystemVendorID = nullptr; |
| 179 | const uint16_t* subsystemDeviceID = nullptr; |
| 180 | const uint64_t* volatileRegionSizeLimitInKiB = nullptr; |
| 181 | const uint64_t* pmRegionSizeLimitInKiB = nullptr; |
| 182 | const uint64_t* volatileSizeInKiB = nullptr; |
| 183 | const uint64_t* pmSizeInKiB = nullptr; |
| 184 | const uint64_t* cacheSizeInKB = nullptr; |
| 185 | const uint64_t* voltaileRegionMaxSizeInKib = nullptr; |
| 186 | const uint64_t* pmRegionMaxSizeInKiB = nullptr; |
| 187 | const uint64_t* allocationIncrementInKiB = nullptr; |
| 188 | const uint64_t* allocationAlignmentInKiB = nullptr; |
| 189 | const uint64_t* volatileRegionNumberLimit = nullptr; |
| 190 | const uint64_t* pmRegionNumberLimit = nullptr; |
| 191 | const uint64_t* spareDeviceCount = nullptr; |
| 192 | const bool* isSpareDeviceInUse = nullptr; |
| 193 | const bool* isRankSpareEnabled = nullptr; |
| 194 | const std::vector<uint32_t>* maxAveragePowerLimitmW = nullptr; |
| 195 | const bool* configurationLocked = nullptr; |
| 196 | const std::string* allowedMemoryModes = nullptr; |
| 197 | const std::string* memoryMedia = nullptr; |
| 198 | const bool* configurationLockCapable = nullptr; |
| 199 | const bool* dataLockCapable = nullptr; |
| 200 | const bool* passphraseCapable = nullptr; |
| 201 | const uint64_t* maxPassphraseCount = nullptr; |
| 202 | const uint64_t* passphraseLockLimit = nullptr; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 203 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 204 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 205 | dbus_utils::UnpackErrorPrinter(), properties, "ModuleManufacturerID", |
| 206 | moduleManufacturerID, "ModuleProductID", moduleProductID, |
| 207 | "SubsystemVendorID", subsystemVendorID, "SubsystemDeviceID", |
| 208 | subsystemDeviceID, "VolatileRegionSizeLimitInKiB", |
| 209 | volatileRegionSizeLimitInKiB, "PmRegionSizeLimitInKiB", |
| 210 | pmRegionSizeLimitInKiB, "VolatileSizeInKiB", volatileSizeInKiB, |
| 211 | "PmSizeInKiB", pmSizeInKiB, "CacheSizeInKB", cacheSizeInKB, |
| 212 | "VoltaileRegionMaxSizeInKib", voltaileRegionMaxSizeInKib, |
| 213 | "PmRegionMaxSizeInKiB", pmRegionMaxSizeInKiB, |
| 214 | "AllocationIncrementInKiB", allocationIncrementInKiB, |
| 215 | "AllocationAlignmentInKiB", allocationAlignmentInKiB, |
| 216 | "VolatileRegionNumberLimit", volatileRegionNumberLimit, |
| 217 | "PmRegionNumberLimit", pmRegionNumberLimit, "SpareDeviceCount", |
| 218 | spareDeviceCount, "IsSpareDeviceInUse", isSpareDeviceInUse, |
| 219 | "IsRankSpareEnabled", isRankSpareEnabled, "MaxAveragePowerLimitmW", |
| 220 | maxAveragePowerLimitmW, "ConfigurationLocked", configurationLocked, |
| 221 | "AllowedMemoryModes", allowedMemoryModes, "MemoryMedia", memoryMedia, |
| 222 | "ConfigurationLockCapable", configurationLockCapable, "DataLockCapable", |
| 223 | dataLockCapable, "PassphraseCapable", passphraseCapable, |
| 224 | "MaxPassphraseCount", maxPassphraseCount, "PassphraseLockLimit", |
| 225 | passphraseLockLimit); |
| 226 | |
| 227 | if (!success) |
| 228 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 229 | messages::internalError(asyncResp->res); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 230 | return; |
| 231 | } |
| 232 | |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 233 | dimmPropToHex(asyncResp, "ModuleManufacturerID", moduleManufacturerID, |
| 234 | jsonPtr); |
| 235 | dimmPropToHex(asyncResp, "ModuleProductID", moduleProductID, jsonPtr); |
| 236 | dimmPropToHex(asyncResp, "MemorySubsystemControllerManufacturerID", |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 237 | subsystemVendorID, jsonPtr); |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 238 | dimmPropToHex(asyncResp, "MemorySubsystemControllerProductID", |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 239 | subsystemDeviceID, jsonPtr); |
| 240 | |
| 241 | if (volatileRegionSizeLimitInKiB != nullptr) |
| 242 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 243 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeLimitMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 244 | (*volatileRegionSizeLimitInKiB) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 245 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 246 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 247 | if (pmRegionSizeLimitInKiB != nullptr) |
| 248 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 249 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeLimitMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 250 | (*pmRegionSizeLimitInKiB) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 251 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 252 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 253 | if (volatileSizeInKiB != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 254 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 255 | asyncResp->res.jsonValue[jsonPtr]["VolatileSizeMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 256 | (*volatileSizeInKiB) >> 10; |
| 257 | } |
| 258 | |
| 259 | if (pmSizeInKiB != nullptr) |
| 260 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 261 | asyncResp->res.jsonValue[jsonPtr]["NonVolatileSizeMiB"] = |
| 262 | (*pmSizeInKiB) >> 10; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | if (cacheSizeInKB != nullptr) |
| 266 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 267 | asyncResp->res.jsonValue[jsonPtr]["CacheSizeMiB"] = |
| 268 | (*cacheSizeInKB >> 10); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | if (voltaileRegionMaxSizeInKib != nullptr) |
| 272 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 273 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionSizeMaxMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 274 | (*voltaileRegionMaxSizeInKib) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 275 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 276 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 277 | if (pmRegionMaxSizeInKiB != nullptr) |
| 278 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 279 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionSizeMaxMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 280 | (*pmRegionMaxSizeInKiB) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 281 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 282 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 283 | if (allocationIncrementInKiB != nullptr) |
| 284 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 285 | asyncResp->res.jsonValue[jsonPtr]["AllocationIncrementMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 286 | (*allocationIncrementInKiB) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 287 | } |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 288 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 289 | if (allocationAlignmentInKiB != nullptr) |
| 290 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 291 | asyncResp->res.jsonValue[jsonPtr]["AllocationAlignmentMiB"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 292 | (*allocationAlignmentInKiB) >> 10; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 293 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 294 | |
| 295 | if (volatileRegionNumberLimit != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 296 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 297 | asyncResp->res.jsonValue[jsonPtr]["VolatileRegionNumberLimit"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 298 | *volatileRegionNumberLimit; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 299 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 300 | |
| 301 | if (pmRegionNumberLimit != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 302 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 303 | asyncResp->res.jsonValue[jsonPtr]["PersistentRegionNumberLimit"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 304 | *pmRegionNumberLimit; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 305 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 306 | |
| 307 | if (spareDeviceCount != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 308 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 309 | asyncResp->res.jsonValue[jsonPtr]["SpareDeviceCount"] = |
| 310 | *spareDeviceCount; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 311 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 312 | |
| 313 | if (isSpareDeviceInUse != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 314 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 315 | asyncResp->res.jsonValue[jsonPtr]["IsSpareDeviceEnabled"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 316 | *isSpareDeviceInUse; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 317 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 318 | |
| 319 | if (isRankSpareEnabled != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 320 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 321 | asyncResp->res.jsonValue[jsonPtr]["IsRankSpareEnabled"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 322 | *isRankSpareEnabled; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 323 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 324 | |
| 325 | if (maxAveragePowerLimitmW != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 326 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 327 | asyncResp->res.jsonValue[jsonPtr]["MaxTDPMilliWatts"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 328 | *maxAveragePowerLimitmW; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 329 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 330 | |
| 331 | if (configurationLocked != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 332 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 333 | asyncResp->res.jsonValue[jsonPtr]["ConfigurationLocked"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 334 | *configurationLocked; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 335 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 336 | |
| 337 | if (allowedMemoryModes != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 338 | { |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 339 | constexpr const std::array<const char*, 3> values{"Volatile", "PMEM", |
| 340 | "Block"}; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 341 | |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 342 | for (const char* v : values) |
| 343 | { |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 344 | if (allowedMemoryModes->ends_with(v)) |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 345 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 346 | asyncResp->res.jsonValue[jsonPtr]["OperatingMemoryModes"] |
| 347 | .push_back(v); |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 348 | break; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 349 | } |
| 350 | } |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 351 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 352 | |
| 353 | if (memoryMedia != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 354 | { |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 355 | constexpr const std::array<const char*, 3> values{"DRAM", "NAND", |
| 356 | "Intel3DXPoint"}; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 357 | |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 358 | for (const char* v : values) |
Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 359 | { |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 360 | if (memoryMedia->ends_with(v)) |
Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 361 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 362 | asyncResp->res.jsonValue[jsonPtr]["MemoryMedia"].push_back(v); |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 363 | break; |
Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 364 | } |
Ed Tanous | 5fb91ba | 2020-09-28 15:41:28 -0700 | [diff] [blame] | 365 | } |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 366 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 367 | |
| 368 | if (configurationLockCapable != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 369 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 370 | asyncResp->res.jsonValue[jsonPtr]["SecurityCapabilities"] |
| 371 | ["ConfigurationLockCapable"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 372 | *configurationLockCapable; |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 373 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 374 | |
| 375 | if (dataLockCapable != nullptr) |
Jiaqing Zhao | 80badf7 | 2022-03-18 17:48:53 +0800 | [diff] [blame] | 376 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 377 | asyncResp->res |
| 378 | .jsonValue[jsonPtr]["SecurityCapabilities"]["DataLockCapable"] = |
| 379 | *dataLockCapable; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | if (passphraseCapable != nullptr) |
| 383 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 384 | asyncResp->res |
| 385 | .jsonValue[jsonPtr]["SecurityCapabilities"]["PassphraseCapable"] = |
| 386 | *passphraseCapable; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | if (maxPassphraseCount != nullptr) |
| 390 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 391 | asyncResp->res |
| 392 | .jsonValue[jsonPtr]["SecurityCapabilities"]["MaxPassphraseCount"] = |
| 393 | *maxPassphraseCount; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | if (passphraseLockLimit != nullptr) |
| 397 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 398 | asyncResp->res |
| 399 | .jsonValue[jsonPtr]["SecurityCapabilities"]["PassphraseLockLimit"] = |
| 400 | *passphraseLockLimit; |
James Feist | c50e7c6 | 2020-07-27 15:39:36 -0700 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 404 | inline void assembleDimmProperties( |
| 405 | std::string_view dimmId, |
| 406 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 407 | const dbus::utility::DBusPropertiesMap& properties, |
| 408 | const nlohmann::json::json_pointer& jsonPtr) |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 409 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 410 | asyncResp->res.jsonValue[jsonPtr]["Id"] = dimmId; |
| 411 | asyncResp->res.jsonValue[jsonPtr]["Name"] = "DIMM Slot"; |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 412 | asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = |
| 413 | resource::State::Enabled; |
| 414 | asyncResp->res.jsonValue[jsonPtr]["Status"]["Health"] = |
| 415 | resource::Health::OK; |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 416 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 417 | const uint16_t* memoryDataWidth = nullptr; |
| 418 | const size_t* memorySizeInKB = nullptr; |
| 419 | const std::string* partNumber = nullptr; |
| 420 | const std::string* serialNumber = nullptr; |
| 421 | const std::string* manufacturer = nullptr; |
| 422 | const uint16_t* revisionCode = nullptr; |
| 423 | const bool* present = nullptr; |
| 424 | const uint16_t* memoryTotalWidth = nullptr; |
| 425 | const std::string* ecc = nullptr; |
| 426 | const std::string* formFactor = nullptr; |
| 427 | const std::vector<uint16_t>* allowedSpeedsMT = nullptr; |
George Liu | 6995c1c | 2023-06-15 08:53:11 +0800 | [diff] [blame] | 428 | const size_t* memoryAttributes = nullptr; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 429 | const uint16_t* memoryConfiguredSpeedInMhz = nullptr; |
| 430 | const std::string* memoryType = nullptr; |
Jayaprakash Mutyala | 6fde597 | 2023-06-15 07:56:58 +0000 | [diff] [blame] | 431 | const std::uint8_t* channel = nullptr; |
| 432 | const std::uint8_t* memoryController = nullptr; |
| 433 | const std::uint8_t* slot = nullptr; |
| 434 | const std::uint8_t* socket = nullptr; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 435 | const std::string* sparePartNumber = nullptr; |
| 436 | const std::string* model = nullptr; |
| 437 | const std::string* locationCode = nullptr; |
George Liu | 7fe6d53 | 2024-03-06 09:01:37 +0800 | [diff] [blame] | 438 | const bool* functional = nullptr; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 439 | |
| 440 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 441 | dbus_utils::UnpackErrorPrinter(), properties, "MemoryDataWidth", |
| 442 | memoryDataWidth, "MemorySizeInKB", memorySizeInKB, "PartNumber", |
Nikhil Namjoshi | 656472d | 2022-09-13 20:54:44 +0000 | [diff] [blame] | 443 | partNumber, "SerialNumber", serialNumber, "Manufacturer", manufacturer, |
| 444 | "RevisionCode", revisionCode, "Present", present, "MemoryTotalWidth", |
| 445 | memoryTotalWidth, "ECC", ecc, "FormFactor", formFactor, |
| 446 | "AllowedSpeedsMT", allowedSpeedsMT, "MemoryAttributes", |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 447 | memoryAttributes, "MemoryConfiguredSpeedInMhz", |
| 448 | memoryConfiguredSpeedInMhz, "MemoryType", memoryType, "Channel", |
| 449 | channel, "MemoryController", memoryController, "Slot", slot, "Socket", |
| 450 | socket, "SparePartNumber", sparePartNumber, "Model", model, |
George Liu | 7fe6d53 | 2024-03-06 09:01:37 +0800 | [diff] [blame] | 451 | "LocationCode", locationCode, "Functional", functional); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 452 | |
| 453 | if (!success) |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 454 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 455 | messages::internalError(asyncResp->res); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 456 | return; |
| 457 | } |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 458 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 459 | if (memoryDataWidth != nullptr) |
| 460 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 461 | asyncResp->res.jsonValue[jsonPtr]["DataWidthBits"] = *memoryDataWidth; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 462 | } |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 463 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 464 | if (memorySizeInKB != nullptr) |
| 465 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 466 | asyncResp->res.jsonValue[jsonPtr]["CapacityMiB"] = |
| 467 | (*memorySizeInKB >> 10); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 468 | } |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 469 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 470 | if (partNumber != nullptr) |
| 471 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 472 | asyncResp->res.jsonValue[jsonPtr]["PartNumber"] = *partNumber; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 473 | } |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 474 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 475 | if (serialNumber != nullptr) |
| 476 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 477 | asyncResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | if (manufacturer != nullptr) |
| 481 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 482 | asyncResp->res.jsonValue[jsonPtr]["Manufacturer"] = *manufacturer; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | if (revisionCode != nullptr) |
| 486 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 487 | asyncResp->res.jsonValue[jsonPtr]["FirmwareRevision"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 488 | std::to_string(*revisionCode); |
| 489 | } |
| 490 | |
| 491 | if (present != nullptr && !*present) |
| 492 | { |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 493 | asyncResp->res.jsonValue[jsonPtr]["Status"]["State"] = |
| 494 | resource::State::Absent; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 495 | } |
| 496 | |
George Liu | 7fe6d53 | 2024-03-06 09:01:37 +0800 | [diff] [blame] | 497 | if (functional != nullptr) |
| 498 | { |
| 499 | if (!*functional) |
| 500 | { |
| 501 | asyncResp->res.jsonValue[jsonPtr]["Status"]["Health"] = |
| 502 | resource::Health::Critical; |
| 503 | } |
| 504 | } |
| 505 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 506 | if (memoryTotalWidth != nullptr) |
| 507 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 508 | asyncResp->res.jsonValue[jsonPtr]["BusWidthBits"] = *memoryTotalWidth; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | if (ecc != nullptr) |
| 512 | { |
| 513 | constexpr const std::array<const char*, 4> values{ |
| 514 | "NoECC", "SingleBitECC", "MultiBitECC", "AddressParity"}; |
| 515 | |
| 516 | for (const char* v : values) |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 517 | { |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 518 | if (ecc->ends_with(v)) |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 519 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 520 | asyncResp->res.jsonValue[jsonPtr]["ErrorCorrection"] = v; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 521 | break; |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 522 | } |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 523 | } |
| 524 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 525 | |
| 526 | if (formFactor != nullptr) |
| 527 | { |
| 528 | constexpr const std::array<const char*, 11> values{ |
| 529 | "RDIMM", "UDIMM", "SO_DIMM", "LRDIMM", |
| 530 | "Mini_RDIMM", "Mini_UDIMM", "SO_RDIMM_72b", "SO_UDIMM_72b", |
| 531 | "SO_DIMM_16b", "SO_DIMM_32b", "Die"}; |
| 532 | |
| 533 | for (const char* v : values) |
| 534 | { |
| 535 | if (formFactor->ends_with(v)) |
| 536 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 537 | asyncResp->res.jsonValue[jsonPtr]["BaseModuleType"] = v; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 538 | break; |
| 539 | } |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | if (allowedSpeedsMT != nullptr) |
| 544 | { |
| 545 | nlohmann::json& jValue = |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 546 | asyncResp->res.jsonValue[jsonPtr]["AllowedSpeedsMHz"]; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 547 | jValue = nlohmann::json::array(); |
| 548 | for (uint16_t subVal : *allowedSpeedsMT) |
| 549 | { |
| 550 | jValue.push_back(subVal); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | if (memoryAttributes != nullptr) |
| 555 | { |
George Liu | 6995c1c | 2023-06-15 08:53:11 +0800 | [diff] [blame] | 556 | asyncResp->res.jsonValue[jsonPtr]["RankCount"] = *memoryAttributes; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | if (memoryConfiguredSpeedInMhz != nullptr) |
| 560 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 561 | asyncResp->res.jsonValue[jsonPtr]["OperatingSpeedMhz"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 562 | *memoryConfiguredSpeedInMhz; |
| 563 | } |
| 564 | |
| 565 | if (memoryType != nullptr) |
| 566 | { |
| 567 | std::string memoryDeviceType = |
| 568 | translateMemoryTypeToRedfish(*memoryType); |
| 569 | // Values like "Unknown" or "Other" will return empty |
| 570 | // so just leave off |
| 571 | if (!memoryDeviceType.empty()) |
| 572 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 573 | asyncResp->res.jsonValue[jsonPtr]["MemoryDeviceType"] = |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 574 | memoryDeviceType; |
| 575 | } |
| 576 | if (memoryType->find("DDR") != std::string::npos) |
| 577 | { |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 578 | asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = |
| 579 | memory::MemoryType::DRAM; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 580 | } |
| 581 | else if (memoryType->ends_with("Logical")) |
| 582 | { |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 583 | asyncResp->res.jsonValue[jsonPtr]["MemoryType"] = |
| 584 | memory::MemoryType::IntelOptane; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | |
| 588 | if (channel != nullptr) |
| 589 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 590 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Channel"] = |
| 591 | *channel; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | if (memoryController != nullptr) |
| 595 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 596 | asyncResp->res |
| 597 | .jsonValue[jsonPtr]["MemoryLocation"]["MemoryController"] = |
| 598 | *memoryController; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | if (slot != nullptr) |
| 602 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 603 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Slot"] = *slot; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | if (socket != nullptr) |
| 607 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 608 | asyncResp->res.jsonValue[jsonPtr]["MemoryLocation"]["Socket"] = *socket; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | if (sparePartNumber != nullptr) |
| 612 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 613 | asyncResp->res.jsonValue[jsonPtr]["SparePartNumber"] = *sparePartNumber; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | if (model != nullptr) |
| 617 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 618 | asyncResp->res.jsonValue[jsonPtr]["Model"] = *model; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | if (locationCode != nullptr) |
| 622 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 623 | asyncResp->res |
| 624 | .jsonValue[jsonPtr]["Location"]["PartLocation"]["ServiceLabel"] = |
| 625 | *locationCode; |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 626 | } |
| 627 | |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 628 | getPersistentMemoryProperties(asyncResp, properties, jsonPtr); |
Nan Zhou | 9a5acea | 2022-05-17 21:12:43 +0000 | [diff] [blame] | 629 | } |
| 630 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 631 | inline void getDimmDataByService( |
| 632 | std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& dimmId, |
| 633 | const std::string& service, const std::string& objPath) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 634 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 635 | BMCWEB_LOG_DEBUG("Get available system components."); |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 636 | dbus::utility::getAllProperties( |
| 637 | service, objPath, "", |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 638 | [dimmId, asyncResp{std::move(asyncResp)}]( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 639 | const boost::system::error_code& ec, |
Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 640 | const dbus::utility::DBusPropertiesMap& properties) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 641 | if (ec) |
| 642 | { |
| 643 | BMCWEB_LOG_DEBUG("DBUS response error"); |
| 644 | messages::internalError(asyncResp->res); |
| 645 | return; |
| 646 | } |
| 647 | assembleDimmProperties(dimmId, asyncResp, properties, |
| 648 | ""_json_pointer); |
| 649 | }); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 650 | } |
| 651 | |
Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 652 | inline void assembleDimmPartitionData( |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 653 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
Nan Zhou | d7f04fd | 2022-05-01 01:11:07 +0000 | [diff] [blame] | 654 | const dbus::utility::DBusPropertiesMap& properties, |
| 655 | const nlohmann::json::json_pointer& regionPtr) |
Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 656 | { |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 657 | const std::string* memoryClassification = nullptr; |
| 658 | const uint64_t* offsetInKiB = nullptr; |
| 659 | const std::string* partitionId = nullptr; |
| 660 | const bool* passphraseState = nullptr; |
| 661 | const uint64_t* sizeInKiB = nullptr; |
| 662 | |
| 663 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 664 | dbus_utils::UnpackErrorPrinter(), properties, "MemoryClassification", |
| 665 | memoryClassification, "OffsetInKiB", offsetInKiB, "PartitionId", |
| 666 | partitionId, "PassphraseState", passphraseState, "SizeInKiB", |
| 667 | sizeInKiB); |
| 668 | |
| 669 | if (!success) |
Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 670 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 671 | messages::internalError(asyncResp->res); |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 672 | return; |
Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 673 | } |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 674 | |
| 675 | nlohmann::json::object_t partition; |
| 676 | |
| 677 | if (memoryClassification != nullptr) |
| 678 | { |
| 679 | partition["MemoryClassification"] = *memoryClassification; |
| 680 | } |
| 681 | |
| 682 | if (offsetInKiB != nullptr) |
| 683 | { |
| 684 | partition["OffsetMiB"] = (*offsetInKiB >> 10); |
| 685 | } |
| 686 | |
| 687 | if (partitionId != nullptr) |
| 688 | { |
| 689 | partition["RegionId"] = *partitionId; |
| 690 | } |
| 691 | |
| 692 | if (passphraseState != nullptr) |
| 693 | { |
| 694 | partition["PassphraseEnabled"] = *passphraseState; |
| 695 | } |
| 696 | |
| 697 | if (sizeInKiB != nullptr) |
| 698 | { |
| 699 | partition["SizeMiB"] = (*sizeInKiB >> 10); |
| 700 | } |
| 701 | |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 702 | asyncResp->res.jsonValue[regionPtr].emplace_back(std::move(partition)); |
Nan Zhou | ef00d7d | 2022-05-20 21:22:32 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 705 | inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 706 | const std::string& service, |
| 707 | const std::string& path) |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 708 | { |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 709 | dbus::utility::getAllProperties( |
| 710 | service, path, |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 711 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition", |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 712 | [asyncResp{std::move(asyncResp)}]( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 713 | const boost::system::error_code& ec, |
Ed Tanous | b9d36b4 | 2022-02-26 21:42:46 -0800 | [diff] [blame] | 714 | const dbus::utility::DBusPropertiesMap& properties) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 715 | if (ec) |
| 716 | { |
| 717 | BMCWEB_LOG_DEBUG("DBUS response error"); |
| 718 | messages::internalError(asyncResp->res); |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 719 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 720 | return; |
| 721 | } |
| 722 | nlohmann::json::json_pointer regionPtr = "/Regions"_json_pointer; |
| 723 | assembleDimmPartitionData(asyncResp, properties, regionPtr); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 724 | } |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 725 | |
Krzysztof Grobelny | c1343bf | 2022-08-31 13:15:26 +0200 | [diff] [blame] | 726 | ); |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 727 | } |
| 728 | |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 729 | inline void afterGetDimmData( |
| 730 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 731 | const std::string& dimmId, const boost::system::error_code& ec, |
| 732 | const dbus::utility::MapperGetSubTreeResponse& subtree) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 733 | { |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 734 | if (ec) |
| 735 | { |
| 736 | if (ec.value() != EBADR) |
| 737 | { |
| 738 | BMCWEB_LOG_ERROR("DBUS response error: {}", ec.value()); |
| 739 | messages::internalError(asyncResp->res); |
| 740 | } |
| 741 | return; |
| 742 | } |
James Feist | 45094ad | 2020-04-29 14:02:30 -0700 | [diff] [blame] | 743 | |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 744 | bool found = false; |
| 745 | for (const auto& [objectPath, serviceMap] : subtree) |
| 746 | { |
| 747 | sdbusplus::message::object_path path(objectPath); |
| 748 | |
| 749 | bool dimmInterface = false; |
| 750 | bool associationInterface = false; |
| 751 | /* Note: Multiple D-Bus objects can provide details for the Memory |
| 752 | * object: 1) Dimm is the primary object 2) Additional partitions could |
| 753 | * exist per Dimm. Only consider the object found if the Dimm is found. |
| 754 | */ |
| 755 | for (const auto& [serviceName, interfaceList] : serviceMap) |
| 756 | { |
| 757 | for (const auto& interface : interfaceList) |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 758 | { |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 759 | if (interface == "xyz.openbmc_project.Inventory.Item.Dimm" && |
| 760 | path.filename() == dimmId) |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 761 | { |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 762 | // Found the single Dimm |
| 763 | getDimmDataByService(asyncResp, dimmId, serviceName, |
| 764 | objectPath); |
| 765 | dimmInterface = true; |
| 766 | found = true; |
| 767 | } |
| 768 | else if (interface == |
| 769 | "xyz.openbmc_project.Association.Definitions") |
| 770 | { |
| 771 | /* Object has associations. If this object is also a Dimm |
| 772 | * then the association might provide the LED state |
| 773 | * information. After all interfaces for this object have |
| 774 | * been checked the LED information will be gathered if the |
| 775 | * object was a Dimm |
| 776 | */ |
| 777 | associationInterface = true; |
| 778 | } |
| 779 | else if ( |
| 780 | interface == |
| 781 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition" && |
| 782 | path.parent_path().filename() == dimmId) |
| 783 | { |
| 784 | // partitions are separate as there can be multiple per |
| 785 | // device, i.e. |
| 786 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition1 |
| 787 | // /xyz/openbmc_project/Inventory/Item/Dimm1/Partition2 |
| 788 | getDimmPartitionData(asyncResp, serviceName, objectPath); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 789 | } |
| 790 | } |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 791 | } |
| 792 | |
| 793 | /* If a Dimm has an Association check if it has a LED */ |
| 794 | if (associationInterface && dimmInterface) |
| 795 | { |
| 796 | getLocationIndicatorActive(asyncResp, objectPath); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | if (!found) |
| 801 | { |
| 802 | // Dimm object not found |
| 803 | messages::resourceNotFound(asyncResp->res, "Memory", dimmId); |
| 804 | return; |
| 805 | } |
| 806 | // Set @odata only if object is found |
| 807 | asyncResp->res.jsonValue["@odata.type"] = "#Memory.v1_11_0.Memory"; |
| 808 | asyncResp->res.jsonValue["@odata.id"] = |
| 809 | boost::urls::format("/redfish/v1/Systems/{}/Memory/{}", |
| 810 | BMCWEB_REDFISH_SYSTEM_URI_NAME, dimmId); |
| 811 | } |
| 812 | |
| 813 | inline void getDimmData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 814 | const std::string& dimmId) |
| 815 | { |
| 816 | BMCWEB_LOG_DEBUG("Get dimm path for {}", dimmId); |
| 817 | constexpr std::array<std::string_view, 2> interfaces = { |
| 818 | "xyz.openbmc_project.Inventory.Item.Dimm", |
| 819 | "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"}; |
| 820 | |
| 821 | dbus::utility::getSubTree( |
| 822 | "/xyz/openbmc_project/inventory", 0, interfaces, |
| 823 | [asyncResp, |
| 824 | dimmId](const boost::system::error_code& ec, |
| 825 | const dbus::utility::MapperGetSubTreeResponse& subtree) { |
| 826 | afterGetDimmData(asyncResp, dimmId, ec, subtree); |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 827 | }); |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 828 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 829 | |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 830 | inline void handleSetDimmData( |
| 831 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 832 | bool locationIndicatorActive, const std::string& dimmPath) |
| 833 | { |
| 834 | setLocationIndicatorActive(asyncResp, dimmPath, locationIndicatorActive); |
| 835 | } |
| 836 | |
| 837 | inline void afterGetValidDimmPath( |
| 838 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 839 | const std::string& dimmId, const boost::system::error_code& ec, |
| 840 | const dbus::utility::MapperGetSubTreePathsResponse& subtree, |
| 841 | const std::function<void(const std::string& dimmPath)>& callback) |
| 842 | { |
| 843 | if (ec) |
| 844 | { |
| 845 | if (ec.value() == EBADR) |
| 846 | { |
| 847 | /* Need to report error for PATCH */ |
| 848 | BMCWEB_LOG_WARNING("Dimm not found in inventory"); |
| 849 | messages::resourceNotFound(asyncResp->res, "Memory", dimmId); |
| 850 | } |
| 851 | else |
| 852 | { |
| 853 | BMCWEB_LOG_ERROR("DBUS response error: {}", ec.value()); |
| 854 | messages::internalError(asyncResp->res); |
| 855 | } |
| 856 | return; |
| 857 | } |
| 858 | |
| 859 | for (const auto& objectPath : subtree) |
| 860 | { |
| 861 | // Ignore any objects which don't end with our desired dimm name |
| 862 | sdbusplus::message::object_path path(objectPath); |
| 863 | if (path.filename() == dimmId) |
| 864 | { |
| 865 | callback(path); |
| 866 | return; |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | // Object not found |
| 871 | messages::resourceNotFound(asyncResp->res, "Memory", dimmId); |
| 872 | } |
| 873 | |
| 874 | inline void getValidDimmPath( |
| 875 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 876 | const std::string& dimmId, |
| 877 | std::function<void(const std::string& dimmPath)>&& callback) |
| 878 | { |
| 879 | BMCWEB_LOG_DEBUG("Get dimm path for {}", dimmId); |
| 880 | constexpr std::array<std::string_view, 1> interfaces = { |
| 881 | "xyz.openbmc_project.Inventory.Item.Dimm"}; |
| 882 | |
| 883 | dbus::utility::getSubTreePaths( |
| 884 | "/xyz/openbmc_project/inventory", 0, interfaces, |
| 885 | [asyncResp, dimmId, callback{std::move(callback)}]( |
| 886 | const boost::system::error_code& ec, |
| 887 | const dbus::utility::MapperGetSubTreePathsResponse& subtree) { |
| 888 | afterGetValidDimmPath(asyncResp, dimmId, ec, subtree, callback); |
| 889 | }); |
| 890 | } |
| 891 | |
| 892 | inline void handleMemoryPatch( |
| 893 | App& app, const crow::Request& req, |
| 894 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 895 | const std::string& systemName, const std::string& dimmId) |
| 896 | { |
| 897 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 898 | { |
| 899 | return; |
| 900 | } |
| 901 | |
| 902 | if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) |
| 903 | { |
| 904 | // Option currently returns no systems. TBD |
| 905 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 906 | systemName); |
| 907 | return; |
| 908 | } |
| 909 | |
| 910 | if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) |
| 911 | { |
| 912 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 913 | systemName); |
| 914 | return; |
| 915 | } |
| 916 | |
| 917 | std::optional<bool> locationIndicatorActive; |
| 918 | if (!json_util::readJsonPatch( // |
| 919 | req, asyncResp->res, // |
| 920 | "LocationIndicatorActive", locationIndicatorActive // |
| 921 | )) |
| 922 | { |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | if (locationIndicatorActive) |
| 927 | { |
| 928 | getValidDimmPath(asyncResp, dimmId, |
| 929 | std::bind_front(handleSetDimmData, asyncResp, |
| 930 | *locationIndicatorActive)); |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | inline void handleMemoryGet(App& app, const crow::Request& req, |
| 935 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 936 | const std::string& systemName, |
| 937 | const std::string& dimmId) |
| 938 | { |
| 939 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 940 | { |
| 941 | return; |
| 942 | } |
| 943 | |
| 944 | if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) |
| 945 | { |
| 946 | // Option currently returns no systems. TBD |
| 947 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 948 | systemName); |
| 949 | return; |
| 950 | } |
| 951 | |
| 952 | if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) |
| 953 | { |
| 954 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 955 | systemName); |
| 956 | return; |
| 957 | } |
| 958 | |
| 959 | getDimmData(asyncResp, dimmId); |
| 960 | } |
| 961 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 962 | inline void requestRoutesMemoryCollection(App& app) |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 963 | { |
Ed Tanous | 029573d | 2019-02-01 10:57:49 -0800 | [diff] [blame] | 964 | /** |
| 965 | * Functions triggers appropriate requests on DBus |
| 966 | */ |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 967 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 968 | .privileges(redfish::privileges::getMemoryCollection) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 969 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 970 | [&app](const crow::Request& req, |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 971 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 972 | const std::string& systemName) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 973 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 974 | { |
| 975 | return; |
| 976 | } |
| 977 | if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) |
| 978 | { |
| 979 | // Option currently returns no systems. TBD |
| 980 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 981 | systemName); |
| 982 | return; |
| 983 | } |
| 984 | if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) |
| 985 | { |
| 986 | messages::resourceNotFound(asyncResp->res, "ComputerSystem", |
| 987 | systemName); |
| 988 | return; |
| 989 | } |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 990 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 991 | asyncResp->res.jsonValue["@odata.type"] = |
| 992 | "#MemoryCollection.MemoryCollection"; |
| 993 | asyncResp->res.jsonValue["Name"] = "Memory Module Collection"; |
| 994 | asyncResp->res.jsonValue["@odata.id"] = |
| 995 | boost::urls::format("/redfish/v1/Systems/{}/Memory", |
| 996 | BMCWEB_REDFISH_SYSTEM_URI_NAME); |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 997 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 998 | constexpr std::array<std::string_view, 1> interfaces{ |
| 999 | "xyz.openbmc_project.Inventory.Item.Dimm"}; |
| 1000 | collection_util::getCollectionMembers( |
| 1001 | asyncResp, |
| 1002 | boost::urls::format("/redfish/v1/Systems/{}/Memory", |
| 1003 | BMCWEB_REDFISH_SYSTEM_URI_NAME), |
| 1004 | interfaces, "/xyz/openbmc_project/inventory"); |
| 1005 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1006 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1007 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1008 | inline void requestRoutesMemory(App& app) |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1009 | { |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1010 | /** |
| 1011 | * Functions triggers appropriate requests on DBus |
| 1012 | */ |
Ed Tanous | 22d268c | 2022-05-19 09:39:07 -0700 | [diff] [blame] | 1013 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1014 | .privileges(redfish::privileges::getMemory) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1015 | .methods(boost::beast::http::verb::get)( |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 1016 | std::bind_front(handleMemoryGet, std::ref(app))); |
Ed Tanous | 7f3e84a | 2022-12-28 16:22:54 -0800 | [diff] [blame] | 1017 | |
George Liu | 6980011 | 2020-10-10 11:41:08 +0800 | [diff] [blame^] | 1018 | BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/<str>/") |
| 1019 | .privileges(redfish::privileges::patchMemory) |
| 1020 | .methods(boost::beast::http::verb::patch)( |
| 1021 | std::bind_front(handleMemoryPatch, std::ref(app))); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1022 | } |
Rapkiewicz, Pawel | 443c293 | 2018-10-22 15:08:49 +0200 | [diff] [blame] | 1023 | |
| 1024 | } // namespace redfish |