SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "manager.hpp" |
| 4 | |
Santosh Puranik | f2d3b53 | 2022-04-19 06:44:07 -0500 | [diff] [blame^] | 5 | #include "bios_handler.hpp" |
Santosh Puranik | bf78ed8 | 2022-04-20 13:17:04 +0530 | [diff] [blame] | 6 | #include "common_utility.hpp" |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 7 | #include "editor_impl.hpp" |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 8 | #include "gpioMonitor.hpp" |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 9 | #include "ibm_vpd_utils.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 10 | #include "ipz_parser.hpp" |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 11 | #include "reader_impl.hpp" |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 12 | #include "vpd_exceptions.hpp" |
| 13 | |
Santosh Puranik | d40e42d | 2022-03-23 13:58:06 +0530 | [diff] [blame] | 14 | #include <filesystem> |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 15 | #include <phosphor-logging/elog-errors.hpp> |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 16 | |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 17 | using namespace openpower::vpd::manager; |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 18 | using namespace openpower::vpd::constants; |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 19 | using namespace openpower::vpd::inventory; |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 20 | using namespace openpower::vpd::manager::editor; |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 21 | using namespace openpower::vpd::manager::reader; |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 22 | using namespace std; |
| 23 | using namespace openpower::vpd::parser; |
| 24 | using namespace openpower::vpd::exceptions; |
| 25 | using namespace phosphor::logging; |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 26 | |
| 27 | namespace openpower |
| 28 | { |
| 29 | namespace vpd |
| 30 | { |
| 31 | namespace manager |
| 32 | { |
| 33 | Manager::Manager(sdbusplus::bus::bus&& bus, const char* busName, |
Priyanga Ramasamy | 9d14934 | 2020-07-16 23:41:26 +0530 | [diff] [blame] | 34 | const char* objPath, const char* /*iFace*/) : |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 35 | ServerObject<ManagerIface>(bus, objPath), |
| 36 | _bus(std::move(bus)), _manager(_bus, objPath) |
| 37 | { |
| 38 | _bus.request_name(busName); |
| 39 | } |
| 40 | |
| 41 | void Manager::run() |
| 42 | { |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 43 | try |
| 44 | { |
| 45 | processJSON(); |
Sunny Srivastava | ecb5c7d | 2021-09-02 07:20:24 -0500 | [diff] [blame] | 46 | listenHostState(); |
Santosh Puranik | b62f605 | 2022-04-06 18:37:54 +0530 | [diff] [blame] | 47 | listenAssetTag(); |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 48 | |
Santosh Puranik | f2d3b53 | 2022-04-19 06:44:07 -0500 | [diff] [blame^] | 49 | // Create an instance of the BIOS handler |
| 50 | BiosHandler biosHandler{_bus, *this}; |
| 51 | |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 52 | auto event = sdeventplus::Event::get_default(); |
| 53 | GpioMonitor gpioMon1(jsonFile, event); |
| 54 | |
| 55 | _bus.attach_event(event.get(), SD_EVENT_PRIORITY_IMPORTANT); |
| 56 | cout << "VPD manager event loop started\n"; |
| 57 | event.loop(); |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 58 | } |
| 59 | catch (const std::exception& e) |
| 60 | { |
| 61 | std::cerr << e.what() << "\n"; |
| 62 | } |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 63 | } |
| 64 | |
Sunny Srivastava | ecb5c7d | 2021-09-02 07:20:24 -0500 | [diff] [blame] | 65 | void Manager::listenHostState() |
| 66 | { |
| 67 | static std::shared_ptr<sdbusplus::bus::match::match> hostState = |
| 68 | std::make_shared<sdbusplus::bus::match::match>( |
| 69 | _bus, |
| 70 | sdbusplus::bus::match::rules::propertiesChanged( |
| 71 | "/xyz/openbmc_project/state/host0", |
| 72 | "xyz.openbmc_project.State.Host"), |
| 73 | [this](sdbusplus::message::message& msg) { |
| 74 | hostStateCallBack(msg); |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | void Manager::hostStateCallBack(sdbusplus::message::message& msg) |
| 79 | { |
| 80 | if (msg.is_method_error()) |
| 81 | { |
| 82 | std::cerr << "Error in reading signal " << std::endl; |
| 83 | } |
| 84 | |
| 85 | Path object; |
| 86 | PropertyMap propMap; |
| 87 | msg.read(object, propMap); |
| 88 | const auto itr = propMap.find("CurrentHostState"); |
| 89 | if (itr != propMap.end()) |
| 90 | { |
| 91 | if (auto hostState = std::get_if<std::string>(&(itr->second))) |
| 92 | { |
| 93 | // implies system is moving from standby to power on state |
| 94 | if (*hostState == "xyz.openbmc_project.State.Host.HostState." |
| 95 | "TransitioningToRunning") |
| 96 | { |
| 97 | // check and perfrom recollection for FRUs replaceable at |
| 98 | // standby. |
| 99 | performVPDRecollection(); |
| 100 | return; |
| 101 | } |
| 102 | } |
| 103 | std::cerr << "Failed to read Host state" << std::endl; |
| 104 | } |
| 105 | } |
| 106 | |
Santosh Puranik | b62f605 | 2022-04-06 18:37:54 +0530 | [diff] [blame] | 107 | void Manager::listenAssetTag() |
| 108 | { |
| 109 | static std::shared_ptr<sdbusplus::bus::match::match> assetMatcher = |
| 110 | std::make_shared<sdbusplus::bus::match::match>( |
| 111 | _bus, |
| 112 | sdbusplus::bus::match::rules::propertiesChanged( |
| 113 | "/xyz/openbmc_project/inventory/system", |
| 114 | "xyz.openbmc_project.Inventory.Decorator.AssetTag"), |
| 115 | [this](sdbusplus::message::message& msg) { |
| 116 | assetTagCallback(msg); |
| 117 | }); |
| 118 | } |
| 119 | |
| 120 | void Manager::assetTagCallback(sdbusplus::message::message& msg) |
| 121 | { |
| 122 | if (msg.is_method_error()) |
| 123 | { |
| 124 | std::cerr << "Error in reading signal " << std::endl; |
| 125 | } |
| 126 | |
| 127 | Path object; |
| 128 | PropertyMap propMap; |
| 129 | msg.read(object, propMap); |
| 130 | const auto itr = propMap.find("AssetTag"); |
| 131 | if (itr != propMap.end()) |
| 132 | { |
| 133 | if (auto assetTag = std::get_if<std::string>(&(itr->second))) |
| 134 | { |
| 135 | // Call Notify to persist the AssetTag |
| 136 | inventory::ObjectMap objectMap = { |
| 137 | {std::string{"/system"}, |
| 138 | {{"xyz.openbmc_project.Inventory.Decorator.AssetTag", |
| 139 | {{"AssetTag", *assetTag}}}}}}; |
| 140 | |
| 141 | common::utility::callPIM(std::move(objectMap)); |
| 142 | } |
| 143 | else |
| 144 | { |
| 145 | std::cerr << "Failed to read asset tag" << std::endl; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 150 | void Manager::processJSON() |
| 151 | { |
Santosh Puranik | 0246a4d | 2020-11-04 16:57:39 +0530 | [diff] [blame] | 152 | std::ifstream json(INVENTORY_JSON_SYM_LINK, std::ios::binary); |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 153 | |
| 154 | if (!json) |
| 155 | { |
| 156 | throw std::runtime_error("json file not found"); |
| 157 | } |
| 158 | |
| 159 | jsonFile = nlohmann::json::parse(json); |
| 160 | if (jsonFile.find("frus") == jsonFile.end()) |
| 161 | { |
| 162 | throw std::runtime_error("frus group not found in json"); |
| 163 | } |
| 164 | |
| 165 | const nlohmann::json& groupFRUS = |
| 166 | jsonFile["frus"].get_ref<const nlohmann::json::object_t&>(); |
| 167 | for (const auto& itemFRUS : groupFRUS.items()) |
| 168 | { |
| 169 | const std::vector<nlohmann::json>& groupEEPROM = |
| 170 | itemFRUS.value().get_ref<const nlohmann::json::array_t&>(); |
| 171 | for (const auto& itemEEPROM : groupEEPROM) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 172 | { |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 173 | bool isMotherboard = false; |
Santosh Puranik | a0b2391 | 2022-02-10 13:37:09 +0530 | [diff] [blame] | 174 | std::string redundantPath; |
| 175 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 176 | if (itemEEPROM["extraInterfaces"].find( |
| 177 | "xyz.openbmc_project.Inventory.Item.Board.Motherboard") != |
| 178 | itemEEPROM["extraInterfaces"].end()) |
| 179 | { |
| 180 | isMotherboard = true; |
| 181 | } |
Santosh Puranik | a0b2391 | 2022-02-10 13:37:09 +0530 | [diff] [blame] | 182 | if (itemEEPROM.find("redundantEeprom") != itemEEPROM.end()) |
| 183 | { |
| 184 | redundantPath = itemEEPROM["redundantEeprom"] |
| 185 | .get_ref<const nlohmann::json::string_t&>(); |
| 186 | } |
| 187 | frus.emplace( |
| 188 | itemEEPROM["inventoryPath"] |
| 189 | .get_ref<const nlohmann::json::string_t&>(), |
| 190 | std::make_tuple(itemFRUS.key(), redundantPath, isMotherboard)); |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 191 | |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 192 | if (itemEEPROM["extraInterfaces"].find(IBM_LOCATION_CODE_INF) != |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 193 | itemEEPROM["extraInterfaces"].end()) |
| 194 | { |
| 195 | fruLocationCode.emplace( |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 196 | itemEEPROM["extraInterfaces"][IBM_LOCATION_CODE_INF] |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 197 | ["LocationCode"] |
| 198 | .get_ref<const nlohmann::json::string_t&>(), |
| 199 | itemEEPROM["inventoryPath"] |
| 200 | .get_ref<const nlohmann::json::string_t&>()); |
| 201 | } |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 202 | |
Sunny Srivastava | ecb5c7d | 2021-09-02 07:20:24 -0500 | [diff] [blame] | 203 | if (itemEEPROM.value("replaceableAtStandby", false)) |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 204 | { |
| 205 | replaceableFrus.emplace_back(itemFRUS.key()); |
| 206 | } |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void Manager::writeKeyword(const sdbusplus::message::object_path path, |
| 212 | const std::string recordName, |
| 213 | const std::string keyword, const Binary value) |
| 214 | { |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 215 | try |
| 216 | { |
Santosh Puranik | 8c79681 | 2021-12-01 19:17:56 +0530 | [diff] [blame] | 217 | std::string objPath{path}; |
| 218 | // Strip any inventory prefix in path |
| 219 | if (objPath.find(INVENTORY_PATH) == 0) |
| 220 | { |
| 221 | objPath = objPath.substr(sizeof(INVENTORY_PATH) - 1); |
| 222 | } |
| 223 | |
| 224 | if (frus.find(objPath) == frus.end()) |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 225 | { |
| 226 | throw std::runtime_error("Inventory path not found"); |
| 227 | } |
| 228 | |
Santosh Puranik | a0b2391 | 2022-02-10 13:37:09 +0530 | [diff] [blame] | 229 | inventory::Path vpdFilePath = std::get<0>(frus.find(objPath)->second); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 230 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 231 | // instantiate editor class to update the data |
Santosh Puranik | 8c79681 | 2021-12-01 19:17:56 +0530 | [diff] [blame] | 232 | EditorImpl edit(vpdFilePath, jsonFile, recordName, keyword, objPath); |
Santosh Puranik | a0b2391 | 2022-02-10 13:37:09 +0530 | [diff] [blame] | 233 | |
| 234 | uint32_t offset = 0; |
| 235 | // Setup offset, if any |
| 236 | for (const auto& item : jsonFile["frus"][vpdFilePath]) |
| 237 | { |
| 238 | if (item.find("offset") != item.end()) |
| 239 | { |
| 240 | offset = item["offset"]; |
| 241 | break; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | edit.updateKeyword(value, offset, true); |
| 246 | |
| 247 | // If we have a redundant EEPROM to update, then update just the EEPROM, |
| 248 | // not the cache since that is already done when we updated the primary |
| 249 | if (!std::get<1>(frus.find(objPath)->second).empty()) |
| 250 | { |
| 251 | EditorImpl edit(std::get<1>(frus.find(objPath)->second), jsonFile, |
| 252 | recordName, keyword); |
| 253 | edit.updateKeyword(value, offset, false); |
| 254 | } |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 255 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 256 | // if it is a motehrboard FRU need to check for location expansion |
Santosh Puranik | a0b2391 | 2022-02-10 13:37:09 +0530 | [diff] [blame] | 257 | if (std::get<2>(frus.find(objPath)->second)) |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 258 | { |
| 259 | if (recordName == "VCEN" && (keyword == "FC" || keyword == "SE")) |
| 260 | { |
| 261 | edit.expandLocationCode("fcs"); |
| 262 | } |
| 263 | else if (recordName == "VSYS" && |
| 264 | (keyword == "TM" || keyword == "SE")) |
| 265 | { |
| 266 | edit.expandLocationCode("mts"); |
| 267 | } |
| 268 | } |
| 269 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 270 | return; |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 271 | } |
| 272 | catch (const std::exception& e) |
| 273 | { |
| 274 | std::cerr << e.what() << std::endl; |
| 275 | } |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 276 | } |
| 277 | |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 278 | ListOfPaths |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 279 | Manager::getFRUsByUnexpandedLocationCode(const LocationCode locationCode, |
| 280 | const NodeNumber nodeNumber) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 281 | { |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 282 | ReaderImpl read; |
| 283 | return read.getFrusAtLocation(locationCode, nodeNumber, fruLocationCode); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 284 | } |
| 285 | |
SunnySrivastava1984 | 1356d7e | 2020-04-24 04:29:35 -0500 | [diff] [blame] | 286 | ListOfPaths |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 287 | Manager::getFRUsByExpandedLocationCode(const LocationCode locationCode) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 288 | { |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 289 | ReaderImpl read; |
| 290 | return read.getFRUsByExpandedLocationCode(locationCode, fruLocationCode); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 291 | } |
| 292 | |
SunnySrivastava1984 | fb5815a | 2020-04-24 08:03:52 -0500 | [diff] [blame] | 293 | LocationCode Manager::getExpandedLocationCode(const LocationCode locationCode, |
| 294 | const NodeNumber nodeNumber) |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 295 | { |
SunnySrivastava1984 | bca5aaa | 2020-04-21 05:31:04 -0500 | [diff] [blame] | 296 | ReaderImpl read; |
| 297 | return read.getExpandedLocationCode(locationCode, nodeNumber, |
| 298 | fruLocationCode); |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 299 | } |
SunnySrivastava1984 | de3c60d | 2020-02-03 10:34:33 -0600 | [diff] [blame] | 300 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 301 | void Manager::performVPDRecollection() |
| 302 | { |
| 303 | // get list of FRUs replaceable at standby |
| 304 | for (const auto& item : replaceableFrus) |
| 305 | { |
| 306 | const vector<nlohmann::json>& groupEEPROM = jsonFile["frus"][item]; |
| 307 | const nlohmann::json& singleFru = groupEEPROM[0]; |
| 308 | |
| 309 | const string& inventoryPath = |
| 310 | singleFru["inventoryPath"] |
| 311 | .get_ref<const nlohmann::json::string_t&>(); |
| 312 | |
Santosh Puranik | d40e42d | 2022-03-23 13:58:06 +0530 | [diff] [blame] | 313 | bool prePostActionRequired = false; |
| 314 | |
| 315 | if ((jsonFile["frus"][item].at(0)).find("preAction") != |
| 316 | jsonFile["frus"][item].at(0).end()) |
| 317 | { |
| 318 | if (!executePreAction(jsonFile, item)) |
| 319 | { |
| 320 | // if the FRU has preAction defined then its execution should |
| 321 | // pass to ensure bind/unbind of data. |
| 322 | // preAction execution failed. should not call bind/unbind. |
| 323 | log<level::ERR>( |
| 324 | "Pre-Action execution failed for the FRU", |
| 325 | entry("ERROR=%s", |
| 326 | ("Inventory path: " + inventoryPath).c_str())); |
| 327 | continue; |
| 328 | } |
| 329 | prePostActionRequired = true; |
| 330 | } |
| 331 | |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 332 | if ((singleFru.find("devAddress") == singleFru.end()) || |
| 333 | (singleFru.find("driverType") == singleFru.end()) || |
| 334 | (singleFru.find("busType") == singleFru.end())) |
| 335 | { |
| 336 | // The FRUs is marked for replacement but missing mandatory |
| 337 | // fields for recollection. Skip to another replaceable fru. |
| 338 | log<level::ERR>( |
| 339 | "Recollection Failed as mandatory field missing in Json", |
| 340 | entry("ERROR=%s", |
| 341 | ("Recollection failed for " + inventoryPath).c_str())); |
| 342 | continue; |
| 343 | } |
| 344 | |
| 345 | string str = "echo "; |
| 346 | string deviceAddress = singleFru["devAddress"]; |
| 347 | const string& driverType = singleFru["driverType"]; |
| 348 | const string& busType = singleFru["busType"]; |
| 349 | |
| 350 | // devTreeStatus flag is present in json as false to mention |
| 351 | // that the EEPROM is not mentioned in device tree. If this flag |
| 352 | // is absent consider the value to be true, i.e EEPROM is |
| 353 | // mentioned in device tree |
| 354 | if (!singleFru.value("devTreeStatus", true)) |
| 355 | { |
| 356 | auto pos = deviceAddress.find('-'); |
| 357 | if (pos != string::npos) |
| 358 | { |
| 359 | string busNum = deviceAddress.substr(0, pos); |
| 360 | deviceAddress = |
| 361 | "0x" + deviceAddress.substr(pos + 1, string::npos); |
| 362 | |
| 363 | string deleteDevice = str + deviceAddress + " > /sys/bus/" + |
| 364 | busType + "/devices/" + busType + "-" + |
| 365 | busNum + "/delete_device"; |
| 366 | executeCmd(deleteDevice); |
| 367 | |
| 368 | string addDevice = str + driverType + " " + deviceAddress + |
| 369 | " > /sys/bus/" + busType + "/devices/" + |
| 370 | busType + "-" + busNum + "/new_device"; |
| 371 | executeCmd(addDevice); |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | log<level::ERR>( |
| 376 | "Wrong format of device address in Json", |
| 377 | entry( |
| 378 | "ERROR=%s", |
| 379 | ("Recollection failed for " + inventoryPath).c_str())); |
| 380 | continue; |
| 381 | } |
| 382 | } |
| 383 | else |
| 384 | { |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 385 | executeCmd(createBindUnbindDriverCmnd(deviceAddress, busType, |
| 386 | driverType, "/unbind")); |
| 387 | executeCmd(createBindUnbindDriverCmnd(deviceAddress, busType, |
| 388 | driverType, "/bind")); |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 389 | } |
Santosh Puranik | d40e42d | 2022-03-23 13:58:06 +0530 | [diff] [blame] | 390 | |
| 391 | // this check is added to avoid file system expensive call in case not |
| 392 | // required. |
| 393 | if (prePostActionRequired) |
| 394 | { |
| 395 | // Check if device showed up (test for file) |
| 396 | if (!filesystem::exists(item)) |
| 397 | { |
| 398 | // If not, then take failure postAction |
| 399 | executePostFailAction(jsonFile, item); |
| 400 | } |
| 401 | } |
SunnySrivastava1984 | 9a19554 | 2020-09-07 06:04:50 -0500 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
SunnySrivastava1984 | b59fd09 | 2020-02-03 09:58:56 -0600 | [diff] [blame] | 405 | } // namespace manager |
| 406 | } // namespace vpd |
Alpana Kumari | b17dd3b | 2020-10-01 00:18:10 -0500 | [diff] [blame] | 407 | } // namespace openpower |