PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 3 | #include "common_utility.hpp" |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 4 | #include "defines.hpp" |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 5 | #include "ibm_vpd_utils.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 6 | #include "ipz_parser.hpp" |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 7 | #include "keyword_vpd_parser.hpp" |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 8 | #include "memory_vpd_parser.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 9 | #include "parser_factory.hpp" |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 10 | #include "vpd_exceptions.hpp" |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 11 | |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 12 | #include <assert.h> |
Alpana Kumari | 8ea3f6d | 2020-04-02 00:26:07 -0500 | [diff] [blame] | 13 | #include <ctype.h> |
| 14 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 15 | #include <CLI/CLI.hpp> |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 16 | #include <algorithm> |
alpana07 | 7ce6872 | 2021-07-25 13:23:59 -0500 | [diff] [blame] | 17 | #include <boost/algorithm/string.hpp> |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 18 | #include <cstdarg> |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 19 | #include <exception> |
PriyangaRamasamy | 83a1d5d | 2020-04-30 19:15:43 +0530 | [diff] [blame] | 20 | #include <filesystem> |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 21 | #include <fstream> |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 22 | #include <gpiod.hpp> |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 23 | #include <iostream> |
| 24 | #include <iterator> |
| 25 | #include <nlohmann/json.hpp> |
Andrew Geissler | 280197e | 2020-12-08 20:51:49 -0600 | [diff] [blame] | 26 | #include <phosphor-logging/log.hpp> |
alpana07 | 7ce6872 | 2021-07-25 13:23:59 -0500 | [diff] [blame] | 27 | #include <regex> |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 28 | |
| 29 | using namespace std; |
| 30 | using namespace openpower::vpd; |
| 31 | using namespace CLI; |
| 32 | using namespace vpd::keyword::parser; |
PriyangaRamasamy | 83a1d5d | 2020-04-30 19:15:43 +0530 | [diff] [blame] | 33 | using namespace openpower::vpd::constants; |
| 34 | namespace fs = filesystem; |
| 35 | using json = nlohmann::json; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 36 | using namespace openpower::vpd::parser::factory; |
SunnySrivastava1984 | 945a02d | 2020-05-06 01:55:41 -0500 | [diff] [blame] | 37 | using namespace openpower::vpd::inventory; |
Alpana Kumari | a00936f | 2020-04-14 07:15:46 -0500 | [diff] [blame] | 38 | using namespace openpower::vpd::memory::parser; |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 39 | using namespace openpower::vpd::parser::interface; |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 40 | using namespace openpower::vpd::exceptions; |
Andrew Geissler | 280197e | 2020-12-08 20:51:49 -0600 | [diff] [blame] | 41 | using namespace phosphor::logging; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 42 | |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 43 | // Map to hold record, kwd pair which can be re-stored at standby. |
| 44 | // The list of keywords for VSYS record is as per the S0 system. Should |
| 45 | // be updated for another type of systems |
| 46 | static const std::unordered_map<std::string, std::vector<std::string>> |
Sunny Srivastava | 01e6c63 | 2022-02-28 03:38:46 -0600 | [diff] [blame] | 47 | svpdKwdMap{{"VSYS", {"BR", "TM", "SE", "SU", "RB", "WN"}}, |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 48 | {"VCEN", {"FC", "SE"}}, |
| 49 | {"LXR0", {"LX"}}}; |
| 50 | |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 51 | /** |
Santosh Puranik | 8589375 | 2020-11-10 21:31:43 +0530 | [diff] [blame] | 52 | * @brief Returns the power state for chassis0 |
| 53 | */ |
| 54 | static auto getPowerState() |
| 55 | { |
| 56 | // TODO: How do we handle multiple chassis? |
| 57 | string powerState{}; |
| 58 | auto bus = sdbusplus::bus::new_default(); |
| 59 | auto properties = |
| 60 | bus.new_method_call("xyz.openbmc_project.State.Chassis", |
| 61 | "/xyz/openbmc_project/state/chassis0", |
| 62 | "org.freedesktop.DBus.Properties", "Get"); |
| 63 | properties.append("xyz.openbmc_project.State.Chassis"); |
| 64 | properties.append("CurrentPowerState"); |
| 65 | auto result = bus.call(properties); |
| 66 | if (!result.is_method_error()) |
| 67 | { |
| 68 | variant<string> val; |
| 69 | result.read(val); |
| 70 | if (auto pVal = get_if<string>(&val)) |
| 71 | { |
| 72 | powerState = *pVal; |
| 73 | } |
| 74 | } |
| 75 | cout << "Power state is: " << powerState << endl; |
| 76 | return powerState; |
| 77 | } |
| 78 | |
| 79 | /** |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 80 | * @brief Expands location codes |
| 81 | */ |
| 82 | static auto expandLocationCode(const string& unexpanded, const Parsed& vpdMap, |
| 83 | bool isSystemVpd) |
| 84 | { |
| 85 | auto expanded{unexpanded}; |
| 86 | static constexpr auto SYSTEM_OBJECT = "/system/chassis/motherboard"; |
| 87 | static constexpr auto VCEN_IF = "com.ibm.ipzvpd.VCEN"; |
| 88 | static constexpr auto VSYS_IF = "com.ibm.ipzvpd.VSYS"; |
| 89 | size_t idx = expanded.find("fcs"); |
| 90 | try |
| 91 | { |
| 92 | if (idx != string::npos) |
| 93 | { |
| 94 | string fc{}; |
| 95 | string se{}; |
| 96 | if (isSystemVpd) |
| 97 | { |
| 98 | const auto& fcData = vpdMap.at("VCEN").at("FC"); |
| 99 | const auto& seData = vpdMap.at("VCEN").at("SE"); |
| 100 | fc = string(fcData.data(), fcData.size()); |
| 101 | se = string(seData.data(), seData.size()); |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | fc = readBusProperty(SYSTEM_OBJECT, VCEN_IF, "FC"); |
| 106 | se = readBusProperty(SYSTEM_OBJECT, VCEN_IF, "SE"); |
| 107 | } |
| 108 | |
Alpana Kumari | 81671f6 | 2021-02-10 02:21:59 -0600 | [diff] [blame] | 109 | // TODO: See if ND0 can be placed in the JSON |
| 110 | expanded.replace(idx, 3, fc.substr(0, 4) + ".ND0." + se); |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 111 | } |
| 112 | else |
| 113 | { |
| 114 | idx = expanded.find("mts"); |
| 115 | if (idx != string::npos) |
| 116 | { |
| 117 | string mt{}; |
| 118 | string se{}; |
| 119 | if (isSystemVpd) |
| 120 | { |
| 121 | const auto& mtData = vpdMap.at("VSYS").at("TM"); |
| 122 | const auto& seData = vpdMap.at("VSYS").at("SE"); |
| 123 | mt = string(mtData.data(), mtData.size()); |
| 124 | se = string(seData.data(), seData.size()); |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | mt = readBusProperty(SYSTEM_OBJECT, VSYS_IF, "TM"); |
| 129 | se = readBusProperty(SYSTEM_OBJECT, VSYS_IF, "SE"); |
| 130 | } |
| 131 | |
| 132 | replace(mt.begin(), mt.end(), '-', '.'); |
| 133 | expanded.replace(idx, 3, mt + "." + se); |
| 134 | } |
| 135 | } |
| 136 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 137 | catch (const exception& e) |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 138 | { |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 139 | cerr << "Failed to expand location code with exception: " << e.what() |
| 140 | << "\n"; |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 141 | } |
| 142 | return expanded; |
| 143 | } |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 144 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 145 | /** |
| 146 | * @brief Populate FRU specific interfaces. |
| 147 | * |
| 148 | * This is a common method which handles both |
| 149 | * ipz and keyword specific interfaces thus, |
| 150 | * reducing the code redundancy. |
| 151 | * @param[in] map - Reference to the innermost keyword-value map. |
| 152 | * @param[in] preIntrStr - Reference to the interface string. |
| 153 | * @param[out] interfaces - Reference to interface map. |
| 154 | */ |
| 155 | template <typename T> |
| 156 | static void populateFruSpecificInterfaces(const T& map, |
| 157 | const string& preIntrStr, |
| 158 | inventory::InterfaceMap& interfaces) |
| 159 | { |
| 160 | inventory::PropertyMap prop; |
| 161 | |
| 162 | for (const auto& kwVal : map) |
| 163 | { |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 164 | auto kw = kwVal.first; |
| 165 | |
| 166 | if (kw[0] == '#') |
| 167 | { |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 168 | kw = string("PD_") + kw[1]; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 169 | } |
Alpana Kumari | 8ea3f6d | 2020-04-02 00:26:07 -0500 | [diff] [blame] | 170 | else if (isdigit(kw[0])) |
| 171 | { |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 172 | kw = string("N_") + kw; |
Alpana Kumari | 8ea3f6d | 2020-04-02 00:26:07 -0500 | [diff] [blame] | 173 | } |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 174 | if constexpr (is_same<T, KeywordVpdMap>::value) |
| 175 | { |
| 176 | if (get_if<Binary>(&kwVal.second)) |
| 177 | { |
| 178 | Binary vec(get_if<Binary>(&kwVal.second)->begin(), |
| 179 | get_if<Binary>(&kwVal.second)->end()); |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 180 | prop.emplace(move(kw), move(vec)); |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | if (kw == "MemorySizeInKB") |
| 185 | { |
| 186 | inventory::PropertyMap memProp; |
| 187 | auto memVal = get_if<size_t>(&kwVal.second); |
| 188 | if (memVal) |
| 189 | { |
| 190 | memProp.emplace(move(kw), |
| 191 | ((*memVal) * CONVERT_MB_TO_KB)); |
| 192 | interfaces.emplace( |
| 193 | "xyz.openbmc_project.Inventory.Item.Dimm", |
| 194 | move(memProp)); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | cerr << "MemorySizeInKB value not found in vpd map\n"; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | else |
| 204 | { |
| 205 | Binary vec(kwVal.second.begin(), kwVal.second.end()); |
| 206 | prop.emplace(move(kw), move(vec)); |
| 207 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | interfaces.emplace(preIntrStr, move(prop)); |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * @brief Populate Interfaces. |
| 215 | * |
| 216 | * This method populates common and extra interfaces to dbus. |
| 217 | * @param[in] js - json object |
| 218 | * @param[out] interfaces - Reference to interface map |
| 219 | * @param[in] vpdMap - Reference to the parsed vpd map. |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 220 | * @param[in] isSystemVpd - Denotes whether we are collecting the system VPD. |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 221 | */ |
| 222 | template <typename T> |
| 223 | static void populateInterfaces(const nlohmann::json& js, |
| 224 | inventory::InterfaceMap& interfaces, |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 225 | const T& vpdMap, bool isSystemVpd) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 226 | { |
| 227 | for (const auto& ifs : js.items()) |
| 228 | { |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 229 | string inf = ifs.key(); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 230 | inventory::PropertyMap props; |
| 231 | |
| 232 | for (const auto& itr : ifs.value().items()) |
| 233 | { |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 234 | const string& busProp = itr.key(); |
| 235 | |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 236 | if (itr.value().is_boolean()) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 237 | { |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 238 | props.emplace(busProp, itr.value().get<bool>()); |
| 239 | } |
| 240 | else if (itr.value().is_string()) |
| 241 | { |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 242 | if (busProp == "LocationCode" && inf == IBM_LOCATION_CODE_INF) |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 243 | { |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 244 | std::string prop; |
| 245 | if constexpr (is_same<T, Parsed>::value) |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 246 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 247 | // TODO deprecate the com.ibm interface later |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 248 | prop = expandLocationCode(itr.value().get<string>(), |
| 249 | vpdMap, isSystemVpd); |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 250 | } |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 251 | else if constexpr (is_same<T, KeywordVpdMap>::value) |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 252 | { |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 253 | // Send empty Parsed object to expandLocationCode api. |
| 254 | prop = expandLocationCode(itr.value().get<string>(), |
| 255 | Parsed{}, false); |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 256 | } |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 257 | props.emplace(busProp, prop); |
| 258 | interfaces.emplace(XYZ_LOCATION_CODE_INF, props); |
| 259 | interfaces.emplace(IBM_LOCATION_CODE_INF, props); |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 260 | } |
| 261 | else |
| 262 | { |
| 263 | props.emplace(busProp, itr.value().get<string>()); |
| 264 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 265 | } |
Santosh Puranik | ed609af | 2021-06-21 11:30:07 +0530 | [diff] [blame] | 266 | else if (itr.value().is_array()) |
| 267 | { |
| 268 | try |
| 269 | { |
| 270 | props.emplace(busProp, itr.value().get<Binary>()); |
| 271 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 272 | catch (const nlohmann::detail::type_error& e) |
Santosh Puranik | ed609af | 2021-06-21 11:30:07 +0530 | [diff] [blame] | 273 | { |
| 274 | std::cerr << "Type exception: " << e.what() << "\n"; |
| 275 | // Ignore any type errors |
| 276 | } |
| 277 | } |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 278 | else if (itr.value().is_object()) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 279 | { |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 280 | const string& rec = itr.value().value("recordName", ""); |
| 281 | const string& kw = itr.value().value("keywordName", ""); |
| 282 | const string& encoding = itr.value().value("encoding", ""); |
| 283 | |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 284 | if constexpr (is_same<T, Parsed>::value) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 285 | { |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 286 | if (!rec.empty() && !kw.empty() && vpdMap.count(rec) && |
| 287 | vpdMap.at(rec).count(kw)) |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 288 | { |
| 289 | auto encoded = |
| 290 | encodeKeyword(vpdMap.at(rec).at(kw), encoding); |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 291 | props.emplace(busProp, encoded); |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 292 | } |
| 293 | } |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 294 | else if constexpr (is_same<T, KeywordVpdMap>::value) |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 295 | { |
| 296 | if (!kw.empty() && vpdMap.count(kw)) |
| 297 | { |
Alpana Kumari | 3ab26a7 | 2021-04-05 19:09:19 +0000 | [diff] [blame] | 298 | auto kwValue = get_if<Binary>(&vpdMap.at(kw)); |
| 299 | auto uintValue = get_if<size_t>(&vpdMap.at(kw)); |
| 300 | |
| 301 | if (kwValue) |
| 302 | { |
| 303 | auto prop = |
| 304 | string((*kwValue).begin(), (*kwValue).end()); |
| 305 | |
| 306 | auto encoded = encodeKeyword(prop, encoding); |
| 307 | |
| 308 | props.emplace(busProp, encoded); |
| 309 | } |
| 310 | else if (uintValue) |
| 311 | { |
| 312 | props.emplace(busProp, *uintValue); |
| 313 | } |
Alpana Kumari | 31970de | 2020-02-17 06:49:57 -0600 | [diff] [blame] | 314 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 315 | } |
| 316 | } |
Matt Spinler | b1e64bb | 2021-09-08 09:57:48 -0500 | [diff] [blame] | 317 | else if (itr.value().is_number()) |
| 318 | { |
| 319 | // For now assume the value is a size_t. In the future it would |
| 320 | // be nice to come up with a way to get the type from the JSON. |
| 321 | props.emplace(busProp, itr.value().get<size_t>()); |
| 322 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 323 | } |
Priyanga Ramasamy | aa8a893 | 2022-01-27 09:12:41 -0600 | [diff] [blame^] | 324 | insertOrMerge(interfaces, inf, move(props)); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | |
Priyanga Ramasamy | 3723378 | 2021-12-09 03:14:02 -0600 | [diff] [blame] | 328 | /*API to reset EEPROM pointer to a safe position to avoid VPD corruption. |
| 329 | * Currently do reset only for DIMM VPD.*/ |
| 330 | static void resetEEPROMPointer(const nlohmann::json& js, const string& file, |
| 331 | ifstream& vpdFile) |
| 332 | { |
| 333 | for (const auto& item : js["frus"][file]) |
| 334 | { |
| 335 | if (item.find("extraInterfaces") != item.end()) |
| 336 | { |
| 337 | if (item["extraInterfaces"].find( |
| 338 | "xyz.openbmc_project.Inventory.Item.Dimm") != |
| 339 | item["extraInterfaces"].end()) |
| 340 | { |
| 341 | // moves the EEPROM pointer to 2048 'th byte. |
| 342 | vpdFile.seekg(2047, std::ios::beg); |
| 343 | // Read that byte and discard - to affirm the move |
| 344 | // operation. |
| 345 | char ch; |
| 346 | vpdFile.read(&ch, sizeof(ch)); |
| 347 | } |
| 348 | return; |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
alpana07 | 5cb3b1f | 2021-12-16 11:19:36 -0600 | [diff] [blame] | 353 | /** |
| 354 | * @brief This API checks if this FRU is pcie_devices. If yes then it further |
| 355 | * checks whether it is PASS1 planar. |
| 356 | */ |
| 357 | static bool isThisPcieOnPass1planar(const nlohmann::json& js, |
| 358 | const string& file) |
| 359 | { |
| 360 | auto isThisPCIeDev = false; |
| 361 | auto isPASS1 = false; |
| 362 | |
| 363 | // Check if it is a PCIE device |
| 364 | if (js["frus"].find(file) != js["frus"].end()) |
| 365 | { |
| 366 | if ((js["frus"][file].find("extraInterfaces") != |
| 367 | js["frus"][file].end())) |
| 368 | { |
| 369 | if (js["frus"][file]["extraInterfaces"].find( |
| 370 | "xyz.openbmc_project.Inventory.Item.PCIeDevice") != |
| 371 | js["frus"][file]["extraInterfaces"].end()) |
| 372 | { |
| 373 | isThisPCIeDev = true; |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | if (isThisPCIeDev) |
| 379 | { |
| 380 | // Collect SystemType to know if it is PASS1 planar. |
| 381 | auto bus = sdbusplus::bus::new_default(); |
| 382 | auto properties = bus.new_method_call( |
| 383 | INVENTORY_MANAGER_SERVICE, |
| 384 | "/xyz/openbmc_project/inventory/system/chassis/motherboard", |
| 385 | "org.freedesktop.DBus.Properties", "Get"); |
| 386 | properties.append("com.ibm.ipzvpd.VINI"); |
| 387 | properties.append("HW"); |
| 388 | auto result = bus.call(properties); |
| 389 | |
| 390 | inventory::Value val; |
| 391 | result.read(val); |
| 392 | if (auto pVal = get_if<Binary>(&val)) |
| 393 | { |
| 394 | auto hwVersion = *pVal; |
| 395 | if (hwVersion[1] < 2) |
| 396 | isPASS1 = true; |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | return (isThisPCIeDev && isPASS1); |
| 401 | } |
| 402 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 403 | static Binary getVpdDataInVector(const nlohmann::json& js, const string& file) |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 404 | { |
| 405 | uint32_t offset = 0; |
| 406 | // check if offset present? |
| 407 | for (const auto& item : js["frus"][file]) |
| 408 | { |
| 409 | if (item.find("offset") != item.end()) |
| 410 | { |
| 411 | offset = item["offset"]; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | // TODO: Figure out a better way to get max possible VPD size. |
Priyanga Ramasamy | 3c2a2b9 | 2021-12-22 00:09:38 -0600 | [diff] [blame] | 416 | auto maxVPDSize = std::min(std::filesystem::file_size(file), |
| 417 | static_cast<uintmax_t>(65504)); |
| 418 | |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 419 | Binary vpdVector; |
Priyanga Ramasamy | 3c2a2b9 | 2021-12-22 00:09:38 -0600 | [diff] [blame] | 420 | vpdVector.resize(maxVPDSize); |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 421 | ifstream vpdFile; |
| 422 | vpdFile.open(file, ios::binary); |
| 423 | |
| 424 | vpdFile.seekg(offset, ios_base::cur); |
Priyanga Ramasamy | 3c2a2b9 | 2021-12-22 00:09:38 -0600 | [diff] [blame] | 425 | vpdFile.read(reinterpret_cast<char*>(&vpdVector[0]), maxVPDSize); |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 426 | vpdVector.resize(vpdFile.gcount()); |
| 427 | |
Priyanga Ramasamy | 3723378 | 2021-12-09 03:14:02 -0600 | [diff] [blame] | 428 | resetEEPROMPointer(js, file, vpdFile); |
| 429 | |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 430 | return vpdVector; |
| 431 | } |
| 432 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 433 | /** This API will be called at the end of VPD collection to perform any post |
| 434 | * actions. |
| 435 | * |
| 436 | * @param[in] json - json object |
| 437 | * @param[in] file - eeprom file path |
| 438 | */ |
| 439 | static void postFailAction(const nlohmann::json& json, const string& file) |
| 440 | { |
| 441 | if ((json["frus"][file].at(0)).find("postActionFail") == |
| 442 | json["frus"][file].at(0).end()) |
| 443 | { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | uint8_t pinValue = 0; |
| 448 | string pinName; |
| 449 | |
| 450 | for (const auto& postAction : |
| 451 | (json["frus"][file].at(0))["postActionFail"].items()) |
| 452 | { |
| 453 | if (postAction.key() == "pin") |
| 454 | { |
| 455 | pinName = postAction.value(); |
| 456 | } |
| 457 | else if (postAction.key() == "value") |
| 458 | { |
| 459 | // Get the value to set |
| 460 | pinValue = postAction.value(); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | cout << "Setting GPIO: " << pinName << " to " << (int)pinValue << endl; |
| 465 | |
| 466 | try |
| 467 | { |
| 468 | gpiod::line outputLine = gpiod::find_line(pinName); |
| 469 | |
| 470 | if (!outputLine) |
| 471 | { |
| 472 | cout << "Couldn't find output line:" << pinName |
| 473 | << " on GPIO. Skipping...\n"; |
| 474 | |
| 475 | return; |
| 476 | } |
| 477 | outputLine.request( |
| 478 | {"Disable line", ::gpiod::line_request::DIRECTION_OUTPUT, 0}, |
| 479 | pinValue); |
| 480 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 481 | catch (const system_error&) |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 482 | { |
| 483 | cerr << "Failed to set post-action GPIO" << endl; |
| 484 | } |
| 485 | } |
| 486 | |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 487 | /** |
| 488 | * @brief This sets the appropriate value to presence GPIO based on device |
| 489 | * attached or not on expander GPIO, which enables that FRU's VPD collection. |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 490 | * |
| 491 | * @param[in] json - json object |
| 492 | * @param[in] file - eeprom file path |
| 493 | */ |
| 494 | static void preAction(const nlohmann::json& json, const string& file) |
| 495 | { |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 496 | if ((json["frus"][file].at(0)).find("presence") != |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 497 | json["frus"][file].at(0).end()) |
| 498 | { |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 499 | if (((json["frus"][file].at(0)["presence"]).find("pin") != |
| 500 | json["frus"][file].at(0)["presence"].end()) && |
| 501 | ((json["frus"][file].at(0)["presence"]).find("value") != |
| 502 | json["frus"][file].at(0)["presence"].end())) |
| 503 | { |
Sunny Srivastava | 2e14789 | 2022-02-22 00:48:26 -0600 | [diff] [blame] | 504 | string presPinName = json["frus"][file].at(0)["presence"]["pin"]; |
| 505 | Byte presPinValue = json["frus"][file].at(0)["presence"]["value"]; |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 506 | |
| 507 | try |
| 508 | { |
| 509 | gpiod::line presenceLine = gpiod::find_line(presPinName); |
| 510 | |
| 511 | if (!presenceLine) |
| 512 | { |
| 513 | cerr << "couldn't find presence line:" << presPinName |
| 514 | << "\n"; |
| 515 | return; |
| 516 | } |
| 517 | |
| 518 | presenceLine.request({"Read the presence line", |
| 519 | gpiod::line_request::DIRECTION_INPUT, 0}); |
| 520 | |
| 521 | Byte gpioData = presenceLine.get_value(); |
| 522 | |
| 523 | if (gpioData != presPinValue) |
| 524 | { |
| 525 | return; |
| 526 | } |
| 527 | } |
| 528 | catch (system_error&) |
| 529 | { |
| 530 | cerr << "Failed to get the presence GPIO for - " << presPinName |
| 531 | << endl; |
| 532 | return; |
| 533 | } |
| 534 | } |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 535 | } |
| 536 | |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 537 | if ((json["frus"][file].at(0)).find("preAction") != |
| 538 | json["frus"][file].at(0).end()) |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 539 | { |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 540 | if (((json["frus"][file].at(0)["preAction"]).find("pin") != |
| 541 | json["frus"][file].at(0)["preAction"].end()) && |
| 542 | ((json["frus"][file].at(0)["preAction"]).find("value") != |
| 543 | json["frus"][file].at(0)["preAction"].end())) |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 544 | { |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 545 | string pinName = json["frus"][file].at(0)["preAction"]["pin"]; |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 546 | // Get the value to set |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 547 | Byte pinValue = json["frus"][file].at(0)["preAction"]["value"]; |
| 548 | |
| 549 | cout << "Setting GPIO: " << pinName << " to " << (int)pinValue |
| 550 | << endl; |
| 551 | try |
| 552 | { |
| 553 | gpiod::line outputLine = gpiod::find_line(pinName); |
| 554 | |
| 555 | if (!outputLine) |
| 556 | { |
| 557 | cout << "Couldn't find output line:" << pinName |
| 558 | << " on GPIO. Skipping...\n"; |
| 559 | |
| 560 | return; |
| 561 | } |
| 562 | outputLine.request({"FRU pre-action", |
| 563 | ::gpiod::line_request::DIRECTION_OUTPUT, 0}, |
| 564 | pinValue); |
| 565 | } |
| 566 | catch (system_error&) |
| 567 | { |
| 568 | cerr << "Failed to set pre-action for GPIO - " << pinName |
| 569 | << endl; |
| 570 | return; |
| 571 | } |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 572 | } |
| 573 | } |
| 574 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 575 | // Now bind the device |
Alpana Kumari | 64b9f5f | 2022-02-19 13:25:58 -0600 | [diff] [blame] | 576 | if (json["frus"][file].at(0).find("devAddress") != |
| 577 | json["frus"][file].at(0).end()) |
| 578 | { |
| 579 | string bind = json["frus"][file].at(0).value("devAddress", ""); |
| 580 | cout << "Binding device " << bind << endl; |
| 581 | string bindCmd = string("echo \"") + bind + |
| 582 | string("\" > /sys/bus/i2c/drivers/at24/bind"); |
| 583 | cout << bindCmd << endl; |
| 584 | executeCmd(bindCmd); |
| 585 | } |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 586 | |
| 587 | // Check if device showed up (test for file) |
| 588 | if (!fs::exists(file)) |
| 589 | { |
| 590 | cout << "EEPROM " << file << " does not exist. Take failure action" |
| 591 | << endl; |
| 592 | // If not, then take failure postAction |
| 593 | postFailAction(json, file); |
| 594 | } |
| 595 | } |
| 596 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 597 | /** |
Santosh Puranik | d3a379a | 2021-08-23 19:12:59 +0530 | [diff] [blame] | 598 | * @brief Set certain one time properties in the inventory |
| 599 | * Use this function to insert the Functional and Enabled properties into the |
| 600 | * inventory map. This function first checks if the object in question already |
| 601 | * has these properties hosted on D-Bus, if the property is already there, it is |
| 602 | * not modified, hence the name "one time". If the property is not already |
| 603 | * present, it will be added to the map with a suitable default value (true for |
| 604 | * Functional and false for Enabled) |
| 605 | * |
| 606 | * @param[in] object - The inventory D-Bus obejct without the inventory prefix. |
| 607 | * @param[inout] interfaces - Reference to a map of inventory interfaces to |
| 608 | * which the properties will be attached. |
| 609 | */ |
| 610 | static void setOneTimeProperties(const std::string& object, |
| 611 | inventory::InterfaceMap& interfaces) |
| 612 | { |
| 613 | auto bus = sdbusplus::bus::new_default(); |
| 614 | auto objectPath = INVENTORY_PATH + object; |
| 615 | auto prop = bus.new_method_call("xyz.openbmc_project.Inventory.Manager", |
| 616 | objectPath.c_str(), |
| 617 | "org.freedesktop.DBus.Properties", "Get"); |
| 618 | prop.append("xyz.openbmc_project.State.Decorator.OperationalStatus"); |
| 619 | prop.append("Functional"); |
| 620 | try |
| 621 | { |
| 622 | auto result = bus.call(prop); |
| 623 | } |
| 624 | catch (const sdbusplus::exception::SdBusError& e) |
| 625 | { |
| 626 | // Treat as property unavailable |
| 627 | inventory::PropertyMap prop; |
| 628 | prop.emplace("Functional", true); |
| 629 | interfaces.emplace( |
| 630 | "xyz.openbmc_project.State.Decorator.OperationalStatus", |
| 631 | move(prop)); |
| 632 | } |
| 633 | prop = bus.new_method_call("xyz.openbmc_project.Inventory.Manager", |
| 634 | objectPath.c_str(), |
| 635 | "org.freedesktop.DBus.Properties", "Get"); |
| 636 | prop.append("xyz.openbmc_project.Object.Enable"); |
| 637 | prop.append("Enabled"); |
| 638 | try |
| 639 | { |
| 640 | auto result = bus.call(prop); |
| 641 | } |
| 642 | catch (const sdbusplus::exception::SdBusError& e) |
| 643 | { |
| 644 | // Treat as property unavailable |
| 645 | inventory::PropertyMap prop; |
| 646 | prop.emplace("Enabled", false); |
| 647 | interfaces.emplace("xyz.openbmc_project.Object.Enable", move(prop)); |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | /** |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 652 | * @brief Prime the Inventory |
| 653 | * Prime the inventory by populating only the location code, |
| 654 | * type interface and the inventory object for the frus |
| 655 | * which are not system vpd fru. |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 656 | * |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 657 | * @param[in] jsObject - Reference to vpd inventory json object |
| 658 | * @param[in] vpdMap - Reference to the parsed vpd map |
| 659 | * |
| 660 | * @returns Map of items in extraInterface. |
| 661 | */ |
| 662 | template <typename T> |
| 663 | inventory::ObjectMap primeInventory(const nlohmann::json& jsObject, |
| 664 | const T& vpdMap) |
| 665 | { |
| 666 | inventory::ObjectMap objects; |
| 667 | |
| 668 | for (auto& itemFRUS : jsObject["frus"].items()) |
| 669 | { |
| 670 | for (auto& itemEEPROM : itemFRUS.value()) |
| 671 | { |
Alpana Kumari | 2e6c6f7 | 2020-12-03 00:10:03 -0600 | [diff] [blame] | 672 | // Take pre actions if needed |
| 673 | if (itemEEPROM.find("preAction") != itemEEPROM.end()) |
| 674 | { |
| 675 | preAction(jsObject, itemFRUS.key()); |
| 676 | } |
| 677 | |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 678 | inventory::InterfaceMap interfaces; |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 679 | inventory::Object object(itemEEPROM.at("inventoryPath")); |
| 680 | |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 681 | if ((itemFRUS.key() != systemVpdFilePath) && |
| 682 | !itemEEPROM.value("noprime", false)) |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 683 | { |
Alpana Kumari | cfd7a75 | 2021-02-07 23:23:01 -0600 | [diff] [blame] | 684 | inventory::PropertyMap presProp; |
| 685 | presProp.emplace("Present", false); |
| 686 | interfaces.emplace("xyz.openbmc_project.Inventory.Item", |
Santosh Puranik | d3a379a | 2021-08-23 19:12:59 +0530 | [diff] [blame] | 687 | presProp); |
| 688 | setOneTimeProperties(object, interfaces); |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 689 | if (itemEEPROM.find("extraInterfaces") != itemEEPROM.end()) |
| 690 | { |
| 691 | for (const auto& eI : itemEEPROM["extraInterfaces"].items()) |
| 692 | { |
| 693 | inventory::PropertyMap props; |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 694 | if (eI.key() == IBM_LOCATION_CODE_INF) |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 695 | { |
| 696 | if constexpr (std::is_same<T, Parsed>::value) |
| 697 | { |
| 698 | for (auto& lC : eI.value().items()) |
| 699 | { |
| 700 | auto propVal = expandLocationCode( |
| 701 | lC.value().get<string>(), vpdMap, true); |
| 702 | |
| 703 | props.emplace(move(lC.key()), |
| 704 | move(propVal)); |
Santosh Puranik | b0f3749 | 2021-06-21 09:42:47 +0530 | [diff] [blame] | 705 | interfaces.emplace(XYZ_LOCATION_CODE_INF, |
| 706 | props); |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 707 | interfaces.emplace(move(eI.key()), |
| 708 | move(props)); |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | else if (eI.key().find("Inventory.Item.") != |
| 713 | string::npos) |
| 714 | { |
| 715 | interfaces.emplace(move(eI.key()), move(props)); |
| 716 | } |
Santosh Puranik | d3a379a | 2021-08-23 19:12:59 +0530 | [diff] [blame] | 717 | else if (eI.key() == |
| 718 | "xyz.openbmc_project.Inventory.Item") |
| 719 | { |
| 720 | for (auto& val : eI.value().items()) |
| 721 | { |
| 722 | if (val.key() == "PrettyName") |
| 723 | { |
| 724 | presProp.emplace(val.key(), |
| 725 | val.value().get<string>()); |
| 726 | } |
| 727 | } |
| 728 | // Use insert_or_assign here as we may already have |
| 729 | // inserted the present property only earlier in |
| 730 | // this function under this same interface. |
| 731 | interfaces.insert_or_assign(eI.key(), |
| 732 | move(presProp)); |
| 733 | } |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | objects.emplace(move(object), move(interfaces)); |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | return objects; |
| 741 | } |
| 742 | |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 743 | /** |
| 744 | * @brief This API executes command to set environment variable |
| 745 | * And then reboot the system |
| 746 | * @param[in] key -env key to set new value |
| 747 | * @param[in] value -value to set. |
| 748 | */ |
| 749 | void setEnvAndReboot(const string& key, const string& value) |
| 750 | { |
| 751 | // set env and reboot and break. |
| 752 | executeCmd("/sbin/fw_setenv", key, value); |
Andrew Geissler | 280197e | 2020-12-08 20:51:49 -0600 | [diff] [blame] | 753 | log<level::INFO>("Rebooting BMC to pick up new device tree"); |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 754 | // make dbus call to reboot |
| 755 | auto bus = sdbusplus::bus::new_default_system(); |
| 756 | auto method = bus.new_method_call( |
| 757 | "org.freedesktop.systemd1", "/org/freedesktop/systemd1", |
| 758 | "org.freedesktop.systemd1.Manager", "Reboot"); |
| 759 | bus.call_noreply(method); |
| 760 | } |
| 761 | |
| 762 | /* |
| 763 | * @brief This API checks for env var fitconfig. |
| 764 | * If not initialised OR updated as per the current system type, |
| 765 | * update this env var and reboot the system. |
| 766 | * |
| 767 | * @param[in] systemType IM kwd in vpd tells about which system type it is. |
| 768 | * */ |
| 769 | void setDevTreeEnv(const string& systemType) |
| 770 | { |
Alpana Kumari | 37e7270 | 2021-11-18 11:18:04 -0600 | [diff] [blame] | 771 | // Init with default dtb |
| 772 | string newDeviceTree = "conf-aspeed-bmc-ibm-rainier-p1.dtb"; |
Santosh Puranik | e5f177a | 2022-01-24 20:14:46 +0530 | [diff] [blame] | 773 | static const deviceTreeMap deviceTreeSystemTypeMap = { |
| 774 | {RAINIER_2U, "conf-aspeed-bmc-ibm-rainier-p1.dtb"}, |
| 775 | {RAINIER_2U_V2, "conf-aspeed-bmc-ibm-rainier.dtb"}, |
| 776 | {RAINIER_4U, "conf-aspeed-bmc-ibm-rainier-4u-p1.dtb"}, |
| 777 | {RAINIER_4U_V2, "conf-aspeed-bmc-ibm-rainier-4u.dtb"}, |
| 778 | {RAINIER_1S4U, "conf-aspeed-bmc-ibm-rainier-1s4u.dtb"}, |
| 779 | {EVEREST, "conf-aspeed-bmc-ibm-everest.dtb"}}; |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 780 | |
| 781 | if (deviceTreeSystemTypeMap.find(systemType) != |
| 782 | deviceTreeSystemTypeMap.end()) |
| 783 | { |
| 784 | newDeviceTree = deviceTreeSystemTypeMap.at(systemType); |
| 785 | } |
Alpana Kumari | 37e7270 | 2021-11-18 11:18:04 -0600 | [diff] [blame] | 786 | else |
| 787 | { |
| 788 | // System type not supported |
Alpana Kumari | ab1e22c | 2021-11-24 11:03:38 -0600 | [diff] [blame] | 789 | string err = "This System type not found/supported in dtb table " + |
| 790 | systemType + |
| 791 | ".Please check the HW and IM keywords in the system " |
| 792 | "VPD.Breaking..."; |
| 793 | |
| 794 | // map to hold additional data in case of logging pel |
| 795 | PelAdditionalData additionalData{}; |
| 796 | additionalData.emplace("DESCRIPTION", err); |
| 797 | createPEL(additionalData, PelSeverity::WARNING, |
| 798 | errIntfForInvalidSystemType); |
| 799 | exit(-1); |
Alpana Kumari | 37e7270 | 2021-11-18 11:18:04 -0600 | [diff] [blame] | 800 | } |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 801 | |
| 802 | string readVarValue; |
| 803 | bool envVarFound = false; |
| 804 | |
| 805 | vector<string> output = executeCmd("/sbin/fw_printenv"); |
| 806 | for (const auto& entry : output) |
| 807 | { |
| 808 | size_t pos = entry.find("="); |
| 809 | string key = entry.substr(0, pos); |
| 810 | if (key != "fitconfig") |
| 811 | { |
| 812 | continue; |
| 813 | } |
| 814 | |
| 815 | envVarFound = true; |
| 816 | if (pos + 1 < entry.size()) |
| 817 | { |
| 818 | readVarValue = entry.substr(pos + 1); |
| 819 | if (readVarValue.find(newDeviceTree) != string::npos) |
| 820 | { |
| 821 | // fitconfig is Updated. No action needed |
| 822 | break; |
| 823 | } |
| 824 | } |
| 825 | // set env and reboot and break. |
| 826 | setEnvAndReboot(key, newDeviceTree); |
| 827 | exit(0); |
| 828 | } |
| 829 | |
| 830 | // check If env var Not found |
| 831 | if (!envVarFound) |
| 832 | { |
| 833 | setEnvAndReboot("fitconfig", newDeviceTree); |
| 834 | } |
| 835 | } |
| 836 | |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 837 | /** |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 838 | * @brief API to call VPD manager to write VPD to EEPROM. |
| 839 | * @param[in] Object path. |
| 840 | * @param[in] record to be updated. |
| 841 | * @param[in] keyword to be updated. |
| 842 | * @param[in] keyword data to be updated |
| 843 | */ |
| 844 | void updateHardware(const string& objectName, const string& recName, |
| 845 | const string& kwdName, const Binary& data) |
| 846 | { |
| 847 | try |
| 848 | { |
| 849 | auto bus = sdbusplus::bus::new_default(); |
| 850 | auto properties = |
| 851 | bus.new_method_call(BUSNAME, OBJPATH, IFACE, "WriteKeyword"); |
| 852 | properties.append( |
| 853 | static_cast<sdbusplus::message::object_path>(objectName)); |
| 854 | properties.append(recName); |
| 855 | properties.append(kwdName); |
| 856 | properties.append(data); |
| 857 | bus.call(properties); |
| 858 | } |
Patrick Williams | 8be4334 | 2021-09-02 09:33:36 -0500 | [diff] [blame] | 859 | catch (const sdbusplus::exception::exception& e) |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 860 | { |
| 861 | std::string what = |
| 862 | "VPDManager WriteKeyword api failed for inventory path " + |
| 863 | objectName; |
| 864 | what += " record " + recName; |
| 865 | what += " keyword " + kwdName; |
| 866 | what += " with bus error = " + std::string(e.what()); |
| 867 | |
| 868 | // map to hold additional data in case of logging pel |
| 869 | PelAdditionalData additionalData{}; |
| 870 | additionalData.emplace("CALLOUT_INVENTORY_PATH", objectName); |
| 871 | additionalData.emplace("DESCRIPTION", what); |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 872 | createPEL(additionalData, PelSeverity::WARNING, errIntfForBusFailure); |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 873 | } |
| 874 | } |
| 875 | |
| 876 | /** |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 877 | * @brief An api to get list of blank system VPD properties. |
| 878 | * @param[in] vpdMap - IPZ vpd map. |
| 879 | * @param[in] objectPath - Object path for the FRU. |
| 880 | * @param[out] blankPropertyList - Properties which are blank in System VPD and |
| 881 | * needs to be updated as standby. |
| 882 | */ |
| 883 | void getListOfBlankSystemVpd(Parsed& vpdMap, const string& objectPath, |
| 884 | std::vector<RestoredEeproms>& blankPropertyList) |
| 885 | { |
| 886 | for (const auto& systemRecKwdPair : svpdKwdMap) |
| 887 | { |
| 888 | auto it = vpdMap.find(systemRecKwdPair.first); |
| 889 | |
| 890 | // check if record is found in map we got by parser |
| 891 | if (it != vpdMap.end()) |
| 892 | { |
| 893 | const auto& kwdListForRecord = systemRecKwdPair.second; |
| 894 | for (const auto& keyword : kwdListForRecord) |
| 895 | { |
| 896 | DbusPropertyMap& kwdValMap = it->second; |
| 897 | auto iterator = kwdValMap.find(keyword); |
| 898 | |
| 899 | if (iterator != kwdValMap.end()) |
| 900 | { |
| 901 | string& kwdValue = iterator->second; |
| 902 | |
| 903 | // check bus data |
| 904 | const string& recordName = systemRecKwdPair.first; |
| 905 | const string& busValue = readBusProperty( |
| 906 | objectPath, ipzVpdInf + recordName, keyword); |
| 907 | |
| 908 | if (busValue.find_first_not_of(' ') != string::npos) |
| 909 | { |
| 910 | if (kwdValue.find_first_not_of(' ') == string::npos) |
| 911 | { |
| 912 | // implies data is blank on EEPROM but not on cache. |
| 913 | // So EEPROM vpd update is required. |
| 914 | Binary busData(busValue.begin(), busValue.end()); |
| 915 | |
| 916 | blankPropertyList.push_back(std::make_tuple( |
| 917 | objectPath, recordName, keyword, busData)); |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | /** |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 927 | * @brief API to check if we need to restore system VPD |
| 928 | * This functionality is only applicable for IPZ VPD data. |
| 929 | * @param[in] vpdMap - IPZ vpd map |
| 930 | * @param[in] objectPath - Object path for the FRU |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 931 | */ |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 932 | void restoreSystemVPD(Parsed& vpdMap, const string& objectPath) |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 933 | { |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 934 | for (const auto& systemRecKwdPair : svpdKwdMap) |
| 935 | { |
| 936 | auto it = vpdMap.find(systemRecKwdPair.first); |
| 937 | |
| 938 | // check if record is found in map we got by parser |
| 939 | if (it != vpdMap.end()) |
| 940 | { |
| 941 | const auto& kwdListForRecord = systemRecKwdPair.second; |
| 942 | for (const auto& keyword : kwdListForRecord) |
| 943 | { |
| 944 | DbusPropertyMap& kwdValMap = it->second; |
| 945 | auto iterator = kwdValMap.find(keyword); |
| 946 | |
| 947 | if (iterator != kwdValMap.end()) |
| 948 | { |
| 949 | string& kwdValue = iterator->second; |
| 950 | |
| 951 | // check bus data |
| 952 | const string& recordName = systemRecKwdPair.first; |
| 953 | const string& busValue = readBusProperty( |
| 954 | objectPath, ipzVpdInf + recordName, keyword); |
| 955 | |
| 956 | if (busValue.find_first_not_of(' ') != string::npos) |
| 957 | { |
| 958 | if (kwdValue.find_first_not_of(' ') != string::npos) |
| 959 | { |
| 960 | // both the data are present, check for mismatch |
| 961 | if (busValue != kwdValue) |
| 962 | { |
| 963 | string errMsg = "VPD data mismatch on cache " |
| 964 | "and hardware for record: "; |
| 965 | errMsg += (*it).first; |
| 966 | errMsg += " and keyword: "; |
| 967 | errMsg += keyword; |
| 968 | |
| 969 | // data mismatch |
| 970 | PelAdditionalData additionalData; |
| 971 | additionalData.emplace("CALLOUT_INVENTORY_PATH", |
| 972 | objectPath); |
| 973 | |
| 974 | additionalData.emplace("DESCRIPTION", errMsg); |
| 975 | |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 976 | createPEL(additionalData, PelSeverity::WARNING, |
| 977 | errIntfForInvalidVPD); |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 978 | } |
| 979 | } |
| 980 | else |
| 981 | { |
| 982 | // implies hardware data is blank |
| 983 | // update the map |
| 984 | Binary busData(busValue.begin(), busValue.end()); |
| 985 | |
Sunny Srivastava | 90a63b9 | 2021-05-26 06:30:24 -0500 | [diff] [blame] | 986 | // update the map as well, so that cache data is not |
| 987 | // updated as blank while populating VPD map on Dbus |
| 988 | // in populateDBus Api |
| 989 | kwdValue = busValue; |
| 990 | } |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 991 | } |
| 992 | else if (kwdValue.find_first_not_of(' ') == string::npos) |
| 993 | { |
| 994 | string errMsg = "VPD is blank on both cache and " |
| 995 | "hardware for record: "; |
| 996 | errMsg += (*it).first; |
| 997 | errMsg += " and keyword: "; |
| 998 | errMsg += keyword; |
| 999 | errMsg += ". SSR need to update hardware VPD."; |
| 1000 | |
| 1001 | // both the data are blanks, log PEL |
| 1002 | PelAdditionalData additionalData; |
| 1003 | additionalData.emplace("CALLOUT_INVENTORY_PATH", |
| 1004 | objectPath); |
| 1005 | |
| 1006 | additionalData.emplace("DESCRIPTION", errMsg); |
| 1007 | |
| 1008 | // log PEL TODO: Block IPL |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1009 | createPEL(additionalData, PelSeverity::ERROR, |
| 1010 | errIntfForBlankSystemVPD); |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 1011 | continue; |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | } |
| 1016 | } |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | /** |
alpana07 | 7ce6872 | 2021-07-25 13:23:59 -0500 | [diff] [blame] | 1020 | * @brief This checks for is this FRU a processor |
| 1021 | * And if yes, then checks for is this primary |
| 1022 | * |
| 1023 | * @param[in] js- vpd json to get the information about this FRU |
| 1024 | * @param[in] filePath- FRU vpd |
| 1025 | * |
| 1026 | * @return true/false |
| 1027 | */ |
| 1028 | bool isThisPrimaryProcessor(nlohmann::json& js, const string& filePath) |
| 1029 | { |
| 1030 | bool isProcessor = false; |
| 1031 | bool isPrimary = false; |
| 1032 | |
| 1033 | for (const auto& item : js["frus"][filePath]) |
| 1034 | { |
| 1035 | if (item.find("extraInterfaces") != item.end()) |
| 1036 | { |
| 1037 | for (const auto& eI : item["extraInterfaces"].items()) |
| 1038 | { |
| 1039 | if (eI.key().find("Inventory.Item.Cpu") != string::npos) |
| 1040 | { |
| 1041 | isProcessor = true; |
| 1042 | } |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | if (isProcessor) |
| 1047 | { |
| 1048 | string cpuType = item.value("cpuType", ""); |
| 1049 | if (cpuType == "primary") |
| 1050 | { |
| 1051 | isPrimary = true; |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | return (isProcessor && isPrimary); |
| 1057 | } |
| 1058 | |
| 1059 | /** |
| 1060 | * @brief This finds DIMM vpd in vpd json and enables them by binding the device |
| 1061 | * driver |
| 1062 | * @param[in] js- vpd json to iterate through and take action if it is DIMM |
| 1063 | */ |
| 1064 | void doEnableAllDimms(nlohmann::json& js) |
| 1065 | { |
| 1066 | // iterate over each fru |
| 1067 | for (const auto& eachFru : js["frus"].items()) |
| 1068 | { |
| 1069 | // skip the driver binding if eeprom already exists |
| 1070 | if (fs::exists(eachFru.key())) |
| 1071 | { |
| 1072 | continue; |
| 1073 | } |
| 1074 | |
| 1075 | for (const auto& eachInventory : eachFru.value()) |
| 1076 | { |
| 1077 | if (eachInventory.find("extraInterfaces") != eachInventory.end()) |
| 1078 | { |
| 1079 | for (const auto& eI : eachInventory["extraInterfaces"].items()) |
| 1080 | { |
| 1081 | if (eI.key().find("Inventory.Item.Dimm") != string::npos) |
| 1082 | { |
| 1083 | string dimmVpd = eachFru.key(); |
| 1084 | // fetch it from |
| 1085 | // "/sys/bus/i2c/drivers/at24/414-0050/eeprom" |
| 1086 | |
| 1087 | regex matchPatern("([0-9]+-[0-9]{4})"); |
| 1088 | smatch matchFound; |
| 1089 | if (regex_search(dimmVpd, matchFound, matchPatern)) |
| 1090 | { |
| 1091 | vector<string> i2cReg; |
| 1092 | boost::split(i2cReg, matchFound.str(0), |
| 1093 | boost::is_any_of("-")); |
| 1094 | |
| 1095 | // remove 0s from begining |
| 1096 | const regex pattern("^0+(?!$)"); |
| 1097 | for (auto& i : i2cReg) |
| 1098 | { |
| 1099 | i = regex_replace(i, pattern, ""); |
| 1100 | } |
| 1101 | |
| 1102 | if (i2cReg.size() == 2) |
| 1103 | { |
| 1104 | // echo 24c32 0x50 > |
| 1105 | // /sys/bus/i2c/devices/i2c-16/new_device |
| 1106 | string cmnd = "echo 24c32 0x" + i2cReg[1] + |
| 1107 | " > /sys/bus/i2c/devices/i2c-" + |
| 1108 | i2cReg[0] + "/new_device"; |
| 1109 | |
| 1110 | executeCmd(cmnd); |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | } |
| 1115 | } |
| 1116 | } |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | /** |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 1121 | * @brief Populate Dbus. |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1122 | * This method invokes all the populateInterface functions |
| 1123 | * and notifies PIM about dbus object. |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 1124 | * @param[in] vpdMap - Either IPZ vpd map or Keyword vpd map based on the |
| 1125 | * input. |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1126 | * @param[in] js - Inventory json object |
| 1127 | * @param[in] filePath - Path of the vpd file |
| 1128 | * @param[in] preIntrStr - Interface string |
| 1129 | */ |
| 1130 | template <typename T> |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 1131 | static void populateDbus(T& vpdMap, nlohmann::json& js, const string& filePath) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1132 | { |
| 1133 | inventory::InterfaceMap interfaces; |
| 1134 | inventory::ObjectMap objects; |
| 1135 | inventory::PropertyMap prop; |
Shantappa Teekappanavar | 6aa5450 | 2021-12-09 12:59:56 -0600 | [diff] [blame] | 1136 | string ccinFromVpd; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1137 | |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 1138 | bool isSystemVpd = (filePath == systemVpdFilePath); |
| 1139 | if constexpr (is_same<T, Parsed>::value) |
| 1140 | { |
Shantappa Teekappanavar | 6aa5450 | 2021-12-09 12:59:56 -0600 | [diff] [blame] | 1141 | ccinFromVpd = getKwVal(vpdMap, "VINI", "CC"); |
| 1142 | transform(ccinFromVpd.begin(), ccinFromVpd.end(), ccinFromVpd.begin(), |
| 1143 | ::toupper); |
| 1144 | |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 1145 | if (isSystemVpd) |
| 1146 | { |
| 1147 | std::vector<std::string> interfaces = {motherBoardInterface}; |
| 1148 | // call mapper to check for object path creation |
| 1149 | MapperResponse subTree = |
| 1150 | getObjectSubtreeForInterfaces(pimPath, 0, interfaces); |
| 1151 | string mboardPath = |
| 1152 | js["frus"][filePath].at(0).value("inventoryPath", ""); |
| 1153 | |
| 1154 | // Attempt system VPD restore if we have a motherboard |
| 1155 | // object in the inventory. |
| 1156 | if ((subTree.size() != 0) && |
| 1157 | (subTree.find(pimPath + mboardPath) != subTree.end())) |
| 1158 | { |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 1159 | restoreSystemVPD(vpdMap, mboardPath); |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 1160 | } |
| 1161 | else |
| 1162 | { |
| 1163 | log<level::ERR>("No object path found"); |
| 1164 | } |
| 1165 | } |
alpana07 | 7ce6872 | 2021-07-25 13:23:59 -0500 | [diff] [blame] | 1166 | else |
| 1167 | { |
| 1168 | // check if it is processor vpd. |
| 1169 | auto isPrimaryCpu = isThisPrimaryProcessor(js, filePath); |
| 1170 | |
| 1171 | if (isPrimaryCpu) |
| 1172 | { |
| 1173 | auto ddVersion = getKwVal(vpdMap, "CRP0", "DD"); |
| 1174 | |
| 1175 | auto chipVersion = atoi(ddVersion.substr(1, 2).c_str()); |
| 1176 | |
| 1177 | if (chipVersion >= 2) |
| 1178 | { |
| 1179 | doEnableAllDimms(js); |
| 1180 | } |
| 1181 | } |
| 1182 | } |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 1183 | } |
| 1184 | |
Priyanga Ramasamy | 32c687f | 2022-01-04 23:14:03 -0600 | [diff] [blame] | 1185 | if (isSystemVpd) |
| 1186 | { |
| 1187 | string systemJsonName{}; |
| 1188 | if constexpr (is_same<T, Parsed>::value) |
| 1189 | { |
| 1190 | // pick the right system json |
| 1191 | systemJsonName = getSystemsJson(vpdMap); |
| 1192 | } |
| 1193 | |
| 1194 | fs::path target = systemJsonName; |
| 1195 | fs::path link = INVENTORY_JSON_SYM_LINK; |
| 1196 | |
| 1197 | // Create the directory for hosting the symlink |
| 1198 | fs::create_directories(VPD_FILES_PATH); |
| 1199 | // unlink the symlink previously created (if any) |
| 1200 | remove(INVENTORY_JSON_SYM_LINK); |
| 1201 | // create a new symlink based on the system |
| 1202 | fs::create_symlink(target, link); |
| 1203 | |
| 1204 | // Reloading the json |
| 1205 | ifstream inventoryJson(link); |
| 1206 | js = json::parse(inventoryJson); |
| 1207 | inventoryJson.close(); |
| 1208 | } |
| 1209 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1210 | for (const auto& item : js["frus"][filePath]) |
| 1211 | { |
| 1212 | const auto& objectPath = item["inventoryPath"]; |
| 1213 | sdbusplus::message::object_path object(objectPath); |
SunnySrivastava1984 | 9094d4f | 2020-08-05 09:32:29 -0500 | [diff] [blame] | 1214 | |
Shantappa Teekappanavar | 6aa5450 | 2021-12-09 12:59:56 -0600 | [diff] [blame] | 1215 | vector<string> ccinList; |
| 1216 | if (item.find("ccin") != item.end()) |
| 1217 | { |
| 1218 | for (const auto& cc : item["ccin"]) |
| 1219 | { |
| 1220 | string ccin = cc; |
| 1221 | transform(ccin.begin(), ccin.end(), ccin.begin(), ::toupper); |
| 1222 | ccinList.push_back(ccin); |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | if (!ccinFromVpd.empty() && !ccinList.empty() && |
| 1227 | (find(ccinList.begin(), ccinList.end(), ccinFromVpd) == |
| 1228 | ccinList.end())) |
| 1229 | { |
| 1230 | continue; |
| 1231 | } |
| 1232 | |
Priyanga Ramasamy | e3fed70 | 2022-01-11 01:05:32 -0600 | [diff] [blame] | 1233 | if ((isSystemVpd) || (item.value("noprime", false))) |
Santosh Puranik | d3a379a | 2021-08-23 19:12:59 +0530 | [diff] [blame] | 1234 | { |
Priyanga Ramasamy | e3fed70 | 2022-01-11 01:05:32 -0600 | [diff] [blame] | 1235 | |
| 1236 | // Populate one time properties for the system VPD and its sub-frus |
| 1237 | // and for other non-primeable frus. |
Santosh Puranik | d3a379a | 2021-08-23 19:12:59 +0530 | [diff] [blame] | 1238 | // For the remaining FRUs, this will get handled as a part of |
| 1239 | // priming the inventory. |
| 1240 | setOneTimeProperties(objectPath, interfaces); |
| 1241 | } |
| 1242 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1243 | // Populate the VPD keywords and the common interfaces only if we |
| 1244 | // are asked to inherit that data from the VPD, else only add the |
| 1245 | // extraInterfaces. |
| 1246 | if (item.value("inherit", true)) |
| 1247 | { |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 1248 | if constexpr (is_same<T, Parsed>::value) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1249 | { |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 1250 | // Each record in the VPD becomes an interface and all |
| 1251 | // keyword within the record are properties under that |
| 1252 | // interface. |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1253 | for (const auto& record : vpdMap) |
| 1254 | { |
| 1255 | populateFruSpecificInterfaces( |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 1256 | record.second, ipzVpdInf + record.first, interfaces); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1257 | } |
| 1258 | } |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 1259 | else if constexpr (is_same<T, KeywordVpdMap>::value) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1260 | { |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 1261 | populateFruSpecificInterfaces(vpdMap, kwdVpdInf, interfaces); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1262 | } |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 1263 | if (js.find("commonInterfaces") != js.end()) |
| 1264 | { |
| 1265 | populateInterfaces(js["commonInterfaces"], interfaces, vpdMap, |
| 1266 | isSystemVpd); |
| 1267 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1268 | } |
Santosh Puranik | 0859eb6 | 2020-03-16 02:56:29 -0500 | [diff] [blame] | 1269 | else |
| 1270 | { |
| 1271 | // Check if we have been asked to inherit specific record(s) |
Alpana Kumari | 58e2214 | 2020-05-05 00:22:12 -0500 | [diff] [blame] | 1272 | if constexpr (is_same<T, Parsed>::value) |
Santosh Puranik | 0859eb6 | 2020-03-16 02:56:29 -0500 | [diff] [blame] | 1273 | { |
| 1274 | if (item.find("copyRecords") != item.end()) |
| 1275 | { |
| 1276 | for (const auto& record : item["copyRecords"]) |
| 1277 | { |
| 1278 | const string& recordName = record; |
| 1279 | if (vpdMap.find(recordName) != vpdMap.end()) |
| 1280 | { |
| 1281 | populateFruSpecificInterfaces( |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 1282 | vpdMap.at(recordName), ipzVpdInf + recordName, |
Santosh Puranik | 0859eb6 | 2020-03-16 02:56:29 -0500 | [diff] [blame] | 1283 | interfaces); |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | } |
| 1288 | } |
Santosh Puranik | 32c4650 | 2022-02-10 08:55:07 +0530 | [diff] [blame] | 1289 | // Populate interfaces and properties that are common to every FRU |
| 1290 | // and additional interface that might be defined on a per-FRU |
| 1291 | // basis. |
| 1292 | if (item.find("extraInterfaces") != item.end()) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1293 | { |
Santosh Puranik | 32c4650 | 2022-02-10 08:55:07 +0530 | [diff] [blame] | 1294 | populateInterfaces(item["extraInterfaces"], interfaces, vpdMap, |
| 1295 | isSystemVpd); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1296 | } |
Priyanga Ramasamy | aa8a893 | 2022-01-27 09:12:41 -0600 | [diff] [blame^] | 1297 | inventory::PropertyMap presProp; |
| 1298 | presProp.emplace("Present", true); |
| 1299 | insertOrMerge(interfaces, invItemIntf, move(presProp)); |
| 1300 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1301 | objects.emplace(move(object), move(interfaces)); |
| 1302 | } |
| 1303 | |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 1304 | if (isSystemVpd) |
| 1305 | { |
| 1306 | inventory::ObjectMap primeObject = primeInventory(js, vpdMap); |
| 1307 | objects.insert(primeObject.begin(), primeObject.end()); |
Alpana Kumari | 65b8360 | 2020-09-01 00:24:56 -0500 | [diff] [blame] | 1308 | |
Alpana Kumari | f05effd | 2021-04-07 07:32:53 -0500 | [diff] [blame] | 1309 | // set the U-boot environment variable for device-tree |
| 1310 | if constexpr (is_same<T, Parsed>::value) |
| 1311 | { |
Santosh Puranik | e5f177a | 2022-01-24 20:14:46 +0530 | [diff] [blame] | 1312 | setDevTreeEnv(fs::path(getSystemsJson(vpdMap)).filename()); |
Alpana Kumari | f05effd | 2021-04-07 07:32:53 -0500 | [diff] [blame] | 1313 | } |
PriyangaRamasamy | 8e140a1 | 2020-04-13 19:24:03 +0530 | [diff] [blame] | 1314 | } |
| 1315 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1316 | // Notify PIM |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 1317 | common::utility::callPIM(move(objects)); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | int main(int argc, char** argv) |
| 1321 | { |
| 1322 | int rc = 0; |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1323 | json js{}; |
PriyangaRamasamy | c2fe40f | 2021-03-02 06:27:33 -0600 | [diff] [blame] | 1324 | Binary vpdVector{}; |
| 1325 | string file{}; |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1326 | // map to hold additional data in case of logging pel |
| 1327 | PelAdditionalData additionalData{}; |
| 1328 | |
| 1329 | // this is needed to hold base fru inventory path in case there is ECC or |
| 1330 | // vpd exception while parsing the file |
| 1331 | std::string baseFruInventoryPath = {}; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1332 | |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1333 | // severity for PEL |
| 1334 | PelSeverity pelSeverity = PelSeverity::WARNING; |
| 1335 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1336 | try |
| 1337 | { |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1338 | App app{"ibm-read-vpd - App to read IPZ format VPD, parse it and store " |
| 1339 | "in DBUS"}; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1340 | |
| 1341 | app.add_option("-f, --file", file, "File containing VPD (IPZ/KEYWORD)") |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1342 | ->required(); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1343 | |
| 1344 | CLI11_PARSE(app, argc, argv); |
| 1345 | |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1346 | // PEL severity should be ERROR in case of any system VPD failure |
| 1347 | if (file == systemVpdFilePath) |
| 1348 | { |
| 1349 | pelSeverity = PelSeverity::ERROR; |
| 1350 | } |
| 1351 | |
Santosh Puranik | 0246a4d | 2020-11-04 16:57:39 +0530 | [diff] [blame] | 1352 | auto jsonToParse = INVENTORY_JSON_DEFAULT; |
| 1353 | |
| 1354 | // If the symlink exists, it means it has been setup for us, switch the |
| 1355 | // path |
| 1356 | if (fs::exists(INVENTORY_JSON_SYM_LINK)) |
| 1357 | { |
| 1358 | jsonToParse = INVENTORY_JSON_SYM_LINK; |
| 1359 | } |
| 1360 | |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1361 | // Make sure that the file path we get is for a supported EEPROM |
Santosh Puranik | 0246a4d | 2020-11-04 16:57:39 +0530 | [diff] [blame] | 1362 | ifstream inventoryJson(jsonToParse); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1363 | if (!inventoryJson) |
| 1364 | { |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1365 | throw(VpdJsonException("Failed to access Json path", jsonToParse)); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1366 | } |
| 1367 | |
| 1368 | try |
| 1369 | { |
| 1370 | js = json::parse(inventoryJson); |
| 1371 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 1372 | catch (const json::parse_error& ex) |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1373 | { |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1374 | throw(VpdJsonException("Json parsing failed", jsonToParse)); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1375 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1376 | |
Santosh Puranik | 12e24ff | 2021-05-11 19:33:50 +0530 | [diff] [blame] | 1377 | // Do we have the mandatory "frus" section? |
| 1378 | if (js.find("frus") == js.end()) |
| 1379 | { |
| 1380 | throw(VpdJsonException("FRUs section not found in JSON", |
| 1381 | jsonToParse)); |
| 1382 | } |
| 1383 | |
PriyangaRamasamy | 647868e | 2020-09-08 17:03:19 +0530 | [diff] [blame] | 1384 | // Check if it's a udev path - patterned as(/ahb/ahb:apb/ahb:apb:bus@) |
| 1385 | if (file.find("/ahb:apb") != string::npos) |
| 1386 | { |
| 1387 | // Translate udev path to a generic /sys/bus/.. file path. |
| 1388 | udevToGenericPath(file); |
Santosh Puranik | 12e24ff | 2021-05-11 19:33:50 +0530 | [diff] [blame] | 1389 | |
| 1390 | if ((js["frus"].find(file) != js["frus"].end()) && |
Santosh Puranik | 50f60bf | 2021-05-26 17:55:06 +0530 | [diff] [blame] | 1391 | (file == systemVpdFilePath)) |
PriyangaRamasamy | 647868e | 2020-09-08 17:03:19 +0530 | [diff] [blame] | 1392 | { |
Sunny Srivastava | 3c24414 | 2022-01-11 08:47:04 -0600 | [diff] [blame] | 1393 | // We need manager service active to process restoring of |
| 1394 | // system VPD on hardware. So in case any system restore is |
| 1395 | // required, update hardware in the second trigger of parser |
| 1396 | // code for system vpd file path. |
| 1397 | |
| 1398 | std::vector<std::string> interfaces{motherBoardInterface}; |
| 1399 | |
| 1400 | // call mapper to check for object path creation |
| 1401 | MapperResponse subTree = |
| 1402 | getObjectSubtreeForInterfaces(pimPath, 0, interfaces); |
| 1403 | string mboardPath = |
| 1404 | js["frus"][file].at(0).value("inventoryPath", ""); |
| 1405 | |
| 1406 | // Attempt system VPD restore if we have a motherboard |
| 1407 | // object in the inventory. |
| 1408 | if ((subTree.size() != 0) && |
| 1409 | (subTree.find(pimPath + mboardPath) != subTree.end())) |
| 1410 | { |
| 1411 | vpdVector = getVpdDataInVector(js, file); |
| 1412 | ParserInterface* parser = |
| 1413 | ParserFactory::getParser(vpdVector); |
| 1414 | variant<KeywordVpdMap, Store> parseResult; |
| 1415 | parseResult = parser->parse(); |
| 1416 | |
| 1417 | if (auto pVal = get_if<Store>(&parseResult)) |
| 1418 | { |
| 1419 | // map to hold all the keywords whose value is blank and |
| 1420 | // needs to be updated at standby. |
| 1421 | vector<RestoredEeproms> blankSystemVpdProperties{}; |
| 1422 | getListOfBlankSystemVpd(pVal->getVpdMap(), mboardPath, |
| 1423 | blankSystemVpdProperties); |
| 1424 | |
| 1425 | // if system VPD restore is required, update the |
| 1426 | // EEPROM |
| 1427 | for (const auto& item : blankSystemVpdProperties) |
| 1428 | { |
| 1429 | updateHardware(get<0>(item), get<1>(item), |
| 1430 | get<2>(item), get<3>(item)); |
| 1431 | } |
| 1432 | } |
| 1433 | else |
| 1434 | { |
| 1435 | std::cout << "Not a valid format to restore system VPD" |
| 1436 | << std::endl; |
| 1437 | } |
| 1438 | // release the parser object |
| 1439 | ParserFactory::freeParser(parser); |
| 1440 | } |
| 1441 | else |
| 1442 | { |
| 1443 | log<level::ERR>("No object path found"); |
| 1444 | } |
PriyangaRamasamy | 647868e | 2020-09-08 17:03:19 +0530 | [diff] [blame] | 1445 | return 0; |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | if (file.empty()) |
| 1450 | { |
| 1451 | cerr << "The EEPROM path <" << file << "> is not valid."; |
| 1452 | return 0; |
| 1453 | } |
Santosh Puranik | 12e24ff | 2021-05-11 19:33:50 +0530 | [diff] [blame] | 1454 | if (js["frus"].find(file) == js["frus"].end()) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1455 | { |
Santosh Puranik | 88edeb6 | 2020-03-02 12:00:09 +0530 | [diff] [blame] | 1456 | return 0; |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1457 | } |
| 1458 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1459 | if (!fs::exists(file)) |
| 1460 | { |
| 1461 | cout << "Device path: " << file |
| 1462 | << " does not exist. Spurious udev event? Exiting." << endl; |
| 1463 | return 0; |
| 1464 | } |
| 1465 | |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1466 | baseFruInventoryPath = js["frus"][file][0]["inventoryPath"]; |
Santosh Puranik | 8589375 | 2020-11-10 21:31:43 +0530 | [diff] [blame] | 1467 | // Check if we can read the VPD file based on the power state |
Santosh Puranik | 27a5e95 | 2021-10-07 22:08:01 -0500 | [diff] [blame] | 1468 | // We skip reading VPD when the power is ON in two scenarios: |
| 1469 | // 1) The eeprom we are trying to read is that of the system VPD |
| 1470 | // 2) The JSON tells us that the FRU EEPROM cannot be read when |
| 1471 | // we are powered ON. |
| 1472 | if (js["frus"][file].at(0).value("powerOffOnly", false) || |
| 1473 | (file == systemVpdFilePath)) |
Santosh Puranik | 8589375 | 2020-11-10 21:31:43 +0530 | [diff] [blame] | 1474 | { |
| 1475 | if ("xyz.openbmc_project.State.Chassis.PowerState.On" == |
| 1476 | getPowerState()) |
| 1477 | { |
| 1478 | cout << "This VPD cannot be read when power is ON" << endl; |
| 1479 | return 0; |
| 1480 | } |
| 1481 | } |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1482 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1483 | try |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1484 | { |
PriyangaRamasamy | c2fe40f | 2021-03-02 06:27:33 -0600 | [diff] [blame] | 1485 | vpdVector = getVpdDataInVector(js, file); |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 1486 | ParserInterface* parser = ParserFactory::getParser(vpdVector); |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1487 | variant<KeywordVpdMap, Store> parseResult; |
| 1488 | parseResult = parser->parse(); |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 1489 | |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1490 | if (auto pVal = get_if<Store>(&parseResult)) |
| 1491 | { |
| 1492 | populateDbus(pVal->getVpdMap(), js, file); |
| 1493 | } |
| 1494 | else if (auto pVal = get_if<KeywordVpdMap>(&parseResult)) |
| 1495 | { |
| 1496 | populateDbus(*pVal, js, file); |
| 1497 | } |
| 1498 | |
| 1499 | // release the parser object |
| 1500 | ParserFactory::freeParser(parser); |
| 1501 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 1502 | catch (const exception& e) |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1503 | { |
| 1504 | postFailAction(js, file); |
PriyangaRamasamy | a504c3e | 2020-12-06 12:14:52 -0600 | [diff] [blame] | 1505 | throw; |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 1506 | } |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1507 | } |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1508 | catch (const VpdJsonException& ex) |
| 1509 | { |
| 1510 | additionalData.emplace("JSON_PATH", ex.getJsonPath()); |
| 1511 | additionalData.emplace("DESCRIPTION", ex.what()); |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1512 | createPEL(additionalData, pelSeverity, errIntfForJsonFailure); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1513 | |
| 1514 | cerr << ex.what() << "\n"; |
| 1515 | rc = -1; |
| 1516 | } |
| 1517 | catch (const VpdEccException& ex) |
| 1518 | { |
| 1519 | additionalData.emplace("DESCRIPTION", "ECC check failed"); |
| 1520 | additionalData.emplace("CALLOUT_INVENTORY_PATH", |
| 1521 | INVENTORY_PATH + baseFruInventoryPath); |
Sunny Srivastava | 0746eee | 2021-03-22 13:36:54 -0500 | [diff] [blame] | 1522 | createPEL(additionalData, pelSeverity, errIntfForEccCheckFail); |
PriyangaRamasamy | c2fe40f | 2021-03-02 06:27:33 -0600 | [diff] [blame] | 1523 | dumpBadVpd(file, vpdVector); |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1524 | cerr << ex.what() << "\n"; |
| 1525 | rc = -1; |
| 1526 | } |
| 1527 | catch (const VpdDataException& ex) |
| 1528 | { |
alpana07 | 5cb3b1f | 2021-12-16 11:19:36 -0600 | [diff] [blame] | 1529 | if (isThisPcieOnPass1planar(js, file)) |
| 1530 | { |
| 1531 | cout << "Pcie_device [" << file |
| 1532 | << "]'s VPD is not valid on PASS1 planar.Ignoring.\n"; |
| 1533 | rc = 0; |
| 1534 | } |
| 1535 | else |
| 1536 | { |
| 1537 | string errorMsg = |
| 1538 | "VPD file is either empty or invalid. Parser failed for ["; |
| 1539 | errorMsg += file; |
| 1540 | errorMsg += "], with error = " + std::string(ex.what()); |
| 1541 | |
| 1542 | additionalData.emplace("DESCRIPTION", errorMsg); |
| 1543 | additionalData.emplace("CALLOUT_INVENTORY_PATH", |
| 1544 | INVENTORY_PATH + baseFruInventoryPath); |
| 1545 | createPEL(additionalData, pelSeverity, errIntfForInvalidVPD); |
| 1546 | |
| 1547 | rc = -1; |
| 1548 | } |
SunnySrivastava1984 | a20be8e | 2020-08-26 02:00:50 -0500 | [diff] [blame] | 1549 | } |
Patrick Williams | 8e15b93 | 2021-10-06 13:04:22 -0500 | [diff] [blame] | 1550 | catch (const exception& e) |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1551 | { |
PriyangaRamasamy | c2fe40f | 2021-03-02 06:27:33 -0600 | [diff] [blame] | 1552 | dumpBadVpd(file, vpdVector); |
PriyangaRamasamy | abb87ed | 2019-11-19 17:25:35 +0530 | [diff] [blame] | 1553 | cerr << e.what() << "\n"; |
| 1554 | rc = -1; |
| 1555 | } |
| 1556 | |
| 1557 | return rc; |
Priyanga Ramasamy | 0d61c58 | 2022-01-21 04:38:22 -0600 | [diff] [blame] | 1558 | } |