summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@linux.intel.com>2021-03-26 01:45:09 +0300
committerJason M. Bills <jason.m.bills@linux.intel.com>2021-03-27 01:41:36 +0300
commit12bef3e1bf292dec5ac15af9fb41e86f7bcfb0cb (patch)
tree608a905372f3f545d2686e29512ae3f5f5b4a78c /meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager
parent0a1ece0568a37de9f17fd6e0bcdfd2cad2c6503f (diff)
downloadopenbmc-12bef3e1bf292dec5ac15af9fb41e86f7bcfb0cb.tar.xz
Update to internal 0.43
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch24
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch351
2 files changed, 369 insertions, 6 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
index c518d943f..fdd2ba6e3 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0001-Improve-initialization-of-I2C-sensors.patch
@@ -1,4 +1,4 @@
-From 2048226878a80fefcbcbe999fd826cc7c02ed9e4 Mon Sep 17 00:00:00 2001
+From 85e7b2d9ede4bb33e02f48ea1d4691d2154fc4a5 Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <johnathanx.mantey@intel.com>
Date: Tue, 13 Oct 2020 15:00:51 -0700
Subject: [PATCH] Improve initialization of I2C sensors
@@ -32,15 +32,15 @@ missing after AC cycles.
Change-Id: I118df674162677d66e7d211b089430fce384086b
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
---
- include/devices.hpp | 153 +++++++++++++++++++----------------
+ include/devices.hpp | 165 ++++++++++++++++++++-----------------
src/Overlay.cpp | 192 ++++++++++++++++++++++++++++++++++----------
- 2 files changed, 233 insertions(+), 112 deletions(-)
+ 2 files changed, 239 insertions(+), 118 deletions(-)
diff --git a/include/devices.hpp b/include/devices.hpp
-index acbfb95..1f25864 100644
+index c375b1c..b7dc7d0 100644
--- a/include/devices.hpp
+++ b/include/devices.hpp
-@@ -31,99 +31,116 @@ struct CmpStr
+@@ -31,105 +31,122 @@ struct CmpStr
struct ExportTemplate
{
@@ -65,12 +65,18 @@ index acbfb95..1f25864 100644
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
- {"24C64", ExportTemplate("24c64 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+- {"ADM1266",
+- ExportTemplate("adm1266 $Address",
+- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+ {{"24C02",
+ ExportTemplate("24c02 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", false)},
+ {"24C64",
+ ExportTemplate("24c64 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", false)},
++ {"ADM1266", ExportTemplate("adm1266 $Address",
++ "/sys/bus/i2c/devices/i2c-$Bus/new_device",
++ "new_device", "delete_device", false)},
{"ADM1272",
- ExportTemplate("adm1272 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
@@ -152,8 +158,14 @@ index acbfb95..1f25864 100644
{"MAX31730",
- ExportTemplate("max31730 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+- {"MAX34440",
+- ExportTemplate("max34440 $Address",
+- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
+ ExportTemplate("max31730 $Address", "/sys/bus/i2c/devices/i2c-$Bus",
+ "new_device", "delete_device", true)},
++ {"MAX34440", ExportTemplate("max34440 $Address",
++ "/sys/bus/i2c/devices/i2c-$Bus/new_device",
++ "new_device", "delete_device", true)},
{"MAX34451",
- ExportTemplate("max34451 $Address",
- "/sys/bus/i2c/devices/i2c-$Bus/new_device")},
@@ -471,5 +483,5 @@ index cb6ed10..7a3089e 100644
linkMux(name, static_cast<size_t>(*bus), static_cast<size_t>(*address),
*channels);
--
-2.26.2
+2.17.1
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
new file mode 100644
index 000000000..88e86f68c
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
@@ -0,0 +1,351 @@
+From 1e8b3e0fe4ce9aa87a35f6c3ba6e506873d5455c Mon Sep 17 00:00:00 2001
+From: mansijos <mansi.joshi@intel.com>
+Date: Fri, 12 Feb 2021 11:26:57 +0530
+Subject: [PATCH] Entity-manager: Add support to update assetTag
+
+Asset tag is an updateable property from User level interface like
+Redfish. User-level interface will update Asset tag in entity-manager,
+which will further update the needed FRU interface property exposed.
+
+Tested:
+Successfully updated in assetTag interface as well as in fru interface
+while using set-property and using redfish as well.
+The new value is preserved after BMC resets.
+
+Change-Id: Iab8b24344d1a27486ceafe21aa2b4496706a2944
+Signed-off-by: mansijos <mansi.joshi@intel.com>
+---
+ include/EntityManager.hpp | 15 ++--
+ src/EntityManager.cpp | 148 ++++++++++++++++++++++++++++++++------
+ 2 files changed, 135 insertions(+), 28 deletions(-)
+
+diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
+index 5867556..a4e9922 100644
+--- a/include/EntityManager.hpp
++++ b/include/EntityManager.hpp
+@@ -29,13 +29,16 @@
+ #include <list>
+ #include <string>
+
+-using DBusProbeObjectT = boost::container::flat_map<
+- std::string,
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>>;
+-
+ using FoundDeviceT =
+ std::vector<boost::container::flat_map<std::string, BasicVariantType>>;
+
++using FoundDeviceInfoT = std::vector<
++ std::tuple<boost::container::flat_map<std::string, BasicVariantType>,
++ std::string, std::string, std::string>>;
++
++using DBusProbeObjectT =
++ boost::container::flat_map<std::string, FoundDeviceInfoT>;
++
+ struct PerformScan : std::enable_shared_from_this<PerformScan>
+ {
+
+@@ -62,12 +65,12 @@ struct PerformProbe : std::enable_shared_from_this<PerformProbe>
+ {
+ PerformProbe(const std::vector<std::string>& probeCommand,
+ std::shared_ptr<PerformScan>& scanPtr,
+- std::function<void(FoundDeviceT&)>&& callback);
++ std::function<void(FoundDeviceInfoT&)>&& callback);
+ virtual ~PerformProbe();
+
+ std::vector<std::string> _probeCommand;
+ std::shared_ptr<PerformScan> scan;
+- std::function<void(FoundDeviceT&)> _callback;
++ std::function<void(FoundDeviceInfoT&)> _callback;
+ };
+
+ inline void logDeviceAdded(const nlohmann::json& record)
+diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
+index aa1df20..cd73675 100644
+--- a/src/EntityManager.cpp
++++ b/src/EntityManager.cpp
+@@ -47,9 +47,14 @@ constexpr const char* lastConfiguration = "/tmp/configuration/last.json";
+ constexpr const char* currentConfiguration = "/var/configuration/system.json";
+ constexpr const char* globalSchema = "global.json";
+ constexpr const int32_t MAX_MAPPER_DEPTH = 0;
++constexpr const char* foundObject = "FoundProbe";
+
+ constexpr const bool DEBUG = false;
+
++using foundProbeData = std::map<std::string, std::string>;
++static foundProbeData foundData;
++static std::map<std::string, foundProbeData> mapFoundData;
++
+ struct cmp_str
+ {
+ bool operator()(const char* a, const char* b) const
+@@ -169,7 +174,10 @@ void getInterfaces(
+ return;
+ }
+
+- scan->dbusProbeObjects[std::get<2>(call)].emplace_back(resp);
++ // Save the dbus info along with device info
++ scan->dbusProbeObjects[std::get<2>(call)].emplace_back(
++ std::make_tuple(resp, std::get<0>(call), std::get<1>(call),
++ std::get<2>(call)));
+ },
+ std::get<0>(call), std::get<1>(call), "org.freedesktop.DBus.Properties",
+ "GetAll", std::get<2>(call));
+@@ -274,11 +282,10 @@ void findDbusObjects(std::vector<std::shared_ptr<PerformProbe>>&& probeVector,
+ // probes dbus interface dictionary for a key with a value that matches a regex
+ bool probeDbus(const std::string& interface,
+ const std::map<std::string, nlohmann::json>& matches,
+- FoundDeviceT& devices, std::shared_ptr<PerformScan> scan,
++ FoundDeviceInfoT& devices, std::shared_ptr<PerformScan> scan,
+ bool& foundProbe)
+ {
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+- dbusObject = scan->dbusProbeObjects[interface];
++ FoundDeviceInfoT& dbusObject = scan->dbusProbeObjects[interface];
+ if (dbusObject.empty())
+ {
+ foundProbe = false;
+@@ -287,8 +294,9 @@ bool probeDbus(const std::string& interface,
+ foundProbe = true;
+
+ bool foundMatch = false;
+- for (auto& device : dbusObject)
++ for (auto& deviceInfo : dbusObject)
+ {
++ auto& device = std::get<0>(deviceInfo);
+ bool deviceMatches = true;
+ for (auto& match : matches)
+ {
+@@ -305,7 +313,7 @@ bool probeDbus(const std::string& interface,
+ }
+ if (deviceMatches)
+ {
+- devices.emplace_back(device);
++ devices.emplace_back(deviceInfo);
+ foundMatch = true;
+ deviceMatches = false; // for next iteration
+ }
+@@ -315,11 +323,8 @@ bool probeDbus(const std::string& interface,
+
+ // default probe entry point, iterates a list looking for specific types to
+ // call specific probe functions
+-bool probe(
+- const std::vector<std::string>& probeCommand,
+- std::shared_ptr<PerformScan> scan,
+- std::vector<boost::container::flat_map<std::string, BasicVariantType>>&
+- foundDevs)
++bool probe(const std::vector<std::string>& probeCommand,
++ std::shared_ptr<PerformScan> scan, FoundDeviceInfoT& foundDevs)
+ {
+ const static std::regex command(R"(\((.*)\))");
+ std::smatch match;
+@@ -449,8 +454,9 @@ bool probe(
+ // probe passed, but empty device
+ if (ret && foundDevs.size() == 0)
+ {
+- foundDevs.emplace_back(
+- boost::container::flat_map<std::string, BasicVariantType>{});
++ foundDevs.emplace_back(std::make_tuple(
++ boost::container::flat_map<std::string, BasicVariantType>{},
++ std::string{}, std::string{}, std::string{}));
+ }
+ if (matchOne && ret)
+ {
+@@ -465,13 +471,13 @@ bool probe(
+
+ PerformProbe::PerformProbe(const std::vector<std::string>& probeCommand,
+ std::shared_ptr<PerformScan>& scanPtr,
+- std::function<void(FoundDeviceT&)>&& callback) :
++ std::function<void(FoundDeviceInfoT&)>&& callback) :
+ _probeCommand(probeCommand),
+ scan(scanPtr), _callback(std::move(callback))
+ {}
+ PerformProbe::~PerformProbe()
+ {
+- FoundDeviceT foundDevs;
++ FoundDeviceInfoT foundDevs;
+ if (probe(_probeCommand, scan, foundDevs))
+ {
+ _callback(foundDevs);
+@@ -556,6 +562,47 @@ void addArrayToDbus(const std::string& name, const nlohmann::json& array,
+ }
+ }
+
++template <typename PropertyType>
++bool persistAssetTag(const PropertyType& newVal,
++ const std::string& jsonPointerString)
++{
++ std::size_t found = jsonPointerString.find_last_of("/\\");
++ std::string jsonPointerPath = jsonPointerString.substr(0, found);
++
++ auto it = mapFoundData.find(jsonPointerPath);
++ if (it == mapFoundData.end())
++ {
++ std::cerr << "Error in finding jsonPointerPath in mapFoundData"
++ << "\n";
++ return false;
++ }
++
++ foundProbeData& tmpMap = it->second;
++ auto foundConn = tmpMap.find("foundConn");
++ auto foundPath = tmpMap.find("foundPath");
++ auto foundIntf = tmpMap.find("foundIntf");
++ if (foundConn == tmpMap.end() || foundPath == tmpMap.end() ||
++ foundIntf == tmpMap.end())
++ {
++ std::cerr << "No prob object data is avaliable in foundProbeData"
++ << "\n";
++ return false;
++ }
++
++ SYSTEM_BUS->async_method_call(
++ [](const boost::system::error_code& ec) {
++ if (ec)
++ {
++ std::cerr << "Error setting AssetTag in FRU interface " << ec
++ << "\n";
++ }
++ },
++ foundConn->second, foundPath->second, "org.freedesktop.DBus.Properties",
++ "Set", foundIntf->second, "PRODUCT_ASSET_TAG",
++ std::variant<PropertyType>(newVal));
++ return true;
++}
++
+ template <typename PropertyType>
+ void addProperty(const std::string& propertyName, const PropertyType& value,
+ sdbusplus::asio::dbus_interface* iface,
+@@ -568,11 +615,21 @@ void addProperty(const std::string& propertyName, const PropertyType& value,
+ iface->register_property(propertyName, value);
+ return;
+ }
++
+ iface->register_property(
+ propertyName, value,
+- [&systemConfiguration,
++ [propertyName, &systemConfiguration,
+ jsonPointerString{std::string(jsonPointerString)}](
+ const PropertyType& newVal, PropertyType& val) {
++ if (propertyName == "AssetTag")
++ {
++ if (!persistAssetTag(newVal, jsonPointerString))
++ {
++ std::cerr << "error setting AssetTag in FRU interface\n";
++ return -1;
++ }
++ }
++
+ val = newVal;
+ if (!setJsonFromPointer(jsonPointerString, val,
+ systemConfiguration))
+@@ -970,6 +1027,11 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ populateInterfaceFromJson(systemConfiguration, jsonPointerPath,
+ boardIface, boardValues, objServer);
+ jsonPointerPath += "/";
++
++ std::string foundConn;
++ std::string foundPath;
++ std::string foundIntf;
++
+ // iterate through board properties
+ for (auto& boardField : boardValues.items())
+ {
+@@ -979,9 +1041,32 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ createInterface(objServer, boardName, boardField.key(),
+ boardKeyOrig);
+
+- populateInterfaceFromJson(systemConfiguration,
+- jsonPointerPath + boardField.key(),
+- iface, boardField.value(), objServer);
++ if (boardField.key() == "FoundProbe")
++ {
++ foundConn = boardField.value()["Connection"];
++ foundPath = boardField.value()["Path"];
++ foundIntf = boardField.value()["Interface"];
++ }
++ if (boardField.key() ==
++ "xyz.openbmc_project.Inventory.Decorator.AssetTag")
++ {
++ foundData["foundConn"] = foundConn;
++ foundData["foundPath"] = foundPath;
++ foundData["foundIntf"] = foundIntf;
++ mapFoundData[jsonPointerPath + boardField.key()] =
++ foundData;
++
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer,
++ sdbusplus::asio::PropertyPermission::readWrite);
++ }
++ else
++ {
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer);
++ }
+ }
+ }
+
+@@ -1278,7 +1363,7 @@ void PerformScan::run()
+ auto thisRef = shared_from_this();
+ auto probePointer = std::make_shared<PerformProbe>(
+ probeCommand, thisRef,
+- [&, recordPtr, probeName](FoundDeviceT& foundDevices) {
++ [&, recordPtr, probeName](FoundDeviceInfoT& foundDevices) {
+ _passed = true;
+
+ std::set<nlohmann::json> usedNames;
+@@ -1294,7 +1379,8 @@ void PerformScan::run()
+ for (auto itr = foundDevices.begin();
+ itr != foundDevices.end();)
+ {
+- std::string recordName = getRecordName(*itr, probeName);
++ std::string recordName =
++ getRecordName(std::get<0>(*itr), probeName);
+
+ auto fromLastJson = lastJson.find(recordName);
+ if (fromLastJson != lastJson.end())
+@@ -1328,6 +1414,15 @@ void PerformScan::run()
+ continue;
+ }
+
++ nlohmann::json recordVal = *recordPtr;
++ // Save the dbus connection, path and interface info
++ // of the device
++ recordVal[foundObject]["Connection"] =
++ std::get<1>(*itr);
++ recordVal[foundObject]["Path"] = std::get<2>(*itr);
++ recordVal[foundObject]["Interface"] =
++ std::get<3>(*itr);
++
+ int index = std::stoi(
+ nameIt->get<std::string>().substr(indexIdx),
+ nullptr, 0);
+@@ -1349,8 +1444,9 @@ void PerformScan::run()
+
+ std::optional<std::string> replaceStr;
+
+- for (auto& foundDevice : foundDevices)
++ for (auto& foundDeviceInfo : foundDevices)
+ {
++ auto& foundDevice = std::get<0>(foundDeviceInfo);
+ nlohmann::json record = *recordPtr;
+ std::string recordName =
+ getRecordName(foundDevice, probeName);
+@@ -1382,6 +1478,14 @@ void PerformScan::run()
+ }
+ }
+
++ // Save the dbus connection, path and interface info
++ // of the device
++ record[foundObject]["Connection"] =
++ std::get<1>(foundDeviceInfo);
++ record[foundObject]["Path"] = std::get<2>(foundDeviceInfo);
++ record[foundObject]["Interface"] =
++ std::get<3>(foundDeviceInfo);
++
+ if (replaceStr)
+ {
+ std::cerr << "Duplicates found, replacing "
+--
+2.17.1
+