184 lines
7.6 KiB
Diff
184 lines
7.6 KiB
Diff
|
|
From 68c17ec70055d351785b58d5e8f03970f31f5fe4 Mon Sep 17 00:00:00 2001
|
||
|
|
From: wangjue <jue.wang2@luxshare-ict.com>
|
||
|
|
Date: Thu, 24 Oct 2024 17:47:23 +0800
|
||
|
|
Subject: [PATCH] Update callback-manager to support dimm_fault LED
|
||
|
|
|
||
|
|
Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
|
||
|
|
---
|
||
|
|
callback-manager/include/callback_manager.hpp | 8 +--
|
||
|
|
callback-manager/src/callback_manager.cpp | 58 ++++++++++++++++---
|
||
|
|
2 files changed, 55 insertions(+), 11 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/callback-manager/include/callback_manager.hpp b/callback-manager/include/callback_manager.hpp
|
||
|
|
index 78a70a0..688c457 100644
|
||
|
|
--- a/callback-manager/include/callback_manager.hpp
|
||
|
|
+++ b/callback-manager/include/callback_manager.hpp
|
||
|
|
@@ -45,7 +45,7 @@ struct AssociationManager
|
||
|
|
|
||
|
|
void setLocalAssociations(const std::vector<std::string>& fatal,
|
||
|
|
const std::vector<std::string>& critical,
|
||
|
|
- const std::vector<std::string>& warning)
|
||
|
|
+ const std::vector<std::string>& dimmerr)
|
||
|
|
{
|
||
|
|
std::set<Association> result;
|
||
|
|
|
||
|
|
@@ -57,11 +57,11 @@ struct AssociationManager
|
||
|
|
}
|
||
|
|
for (const std::string& path : critical)
|
||
|
|
{
|
||
|
|
- result.emplace(threshold::warning, "", path);
|
||
|
|
+ result.emplace(threshold::critical, "", path);
|
||
|
|
}
|
||
|
|
- for (const std::string& path : warning)
|
||
|
|
+ for (const std::string& path : dimmerr)
|
||
|
|
{
|
||
|
|
- result.emplace(threshold::warning, "", path);
|
||
|
|
+ result.emplace("dimmFault", "", path);
|
||
|
|
}
|
||
|
|
association->set_property("Associations", result);
|
||
|
|
}
|
||
|
|
diff --git a/callback-manager/src/callback_manager.cpp b/callback-manager/src/callback_manager.cpp
|
||
|
|
index 4f02986..d7934af 100644
|
||
|
|
--- a/callback-manager/src/callback_manager.cpp
|
||
|
|
+++ b/callback-manager/src/callback_manager.cpp
|
||
|
|
@@ -60,6 +60,9 @@ boost::container::flat_map<std::string,
|
||
|
|
boost::container::flat_map<std::string,
|
||
|
|
boost::container::flat_map<std::string, bool>>
|
||
|
|
warningAssertMap;
|
||
|
|
+boost::container::flat_map<std::string,
|
||
|
|
+ boost::container::flat_map<std::string, bool>>
|
||
|
|
+ dimmerrAssertMap;
|
||
|
|
|
||
|
|
std::vector<std::string> assertedInMap(
|
||
|
|
const boost::container::flat_map<
|
||
|
|
@@ -92,8 +95,11 @@ void updateLedStatus(std::shared_ptr<sdbusplus::asio::connection>& conn,
|
||
|
|
std::vector<std::string> warningVector = assertedInMap(warningAssertMap);
|
||
|
|
bool warn = warningVector.size();
|
||
|
|
|
||
|
|
+ std::vector<std::string> dimmerrVector = assertedInMap(dimmerrAssertMap);
|
||
|
|
+ bool dimmerr = dimmerrVector.size();
|
||
|
|
+
|
||
|
|
associationManager->setLocalAssociations(fatalVector, criticalVector,
|
||
|
|
- warningVector);
|
||
|
|
+ dimmerrVector);
|
||
|
|
|
||
|
|
StatusSetting last = currentPriority;
|
||
|
|
std::vector<std::pair<std::string, std::variant<bool>>> ledsToSet;
|
||
|
|
@@ -133,11 +139,20 @@ void updateLedStatus(std::shared_ptr<sdbusplus::asio::connection>& conn,
|
||
|
|
{
|
||
|
|
currentPriority = StatusSetting::fault;
|
||
|
|
}
|
||
|
|
+ else if (dimmerr)
|
||
|
|
+ {
|
||
|
|
+ currentPriority = StatusSetting::dimmerr;
|
||
|
|
+ }
|
||
|
|
else
|
||
|
|
{
|
||
|
|
currentPriority = StatusSetting::ok;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ if constexpr (debug)
|
||
|
|
+ {
|
||
|
|
+ std::cout << "last: " << (int)last << " currentPriority: " << int(currentPriority) << std::endl;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
if (last != currentPriority || forceRefresh)
|
||
|
|
{
|
||
|
|
switch (currentPriority)
|
||
|
|
@@ -234,6 +249,7 @@ void createThresholdMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
warningAssertMap[message.get_path()]["high"] = assert;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ warningAssertMap.clear(); //ignore warning asserts
|
||
|
|
associationManager->setSensorAssociations(
|
||
|
|
assertedInMap(criticalAssertMap),
|
||
|
|
assertedInMap(warningAssertMap));
|
||
|
|
@@ -250,7 +266,8 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
"arg0namespace='" +
|
||
|
|
std::string(associationIface) + "'",
|
||
|
|
[&conn](sdbusplus::message_t& message) {
|
||
|
|
- if (message.get_path() == rootPath)
|
||
|
|
+ std::string getPath = message.get_path();
|
||
|
|
+ if (getPath.find(rootPath) != std::string::npos)
|
||
|
|
{
|
||
|
|
return; // it's us
|
||
|
|
}
|
||
|
|
@@ -258,6 +275,7 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
boost::container::flat_map<std::string,
|
||
|
|
std::variant<std::vector<Association>>>
|
||
|
|
values;
|
||
|
|
+
|
||
|
|
try
|
||
|
|
{
|
||
|
|
message.read(objectName, values);
|
||
|
|
@@ -293,6 +311,8 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
bool localCritical = false;
|
||
|
|
bool globalWarning = false;
|
||
|
|
bool globalCritical = false;
|
||
|
|
+ bool localDimmFault = false;
|
||
|
|
+ bool dimmfault = false;
|
||
|
|
|
||
|
|
for (const auto& [forward, reverse, path] : *associations)
|
||
|
|
{
|
||
|
|
@@ -301,10 +321,9 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
globalWarning = globalWarning ? true : reverse == "warning";
|
||
|
|
globalCritical =
|
||
|
|
globalCritical ? true : reverse == "critical";
|
||
|
|
-
|
||
|
|
if constexpr (1)
|
||
|
|
{
|
||
|
|
- std::cerr << "got global ";
|
||
|
|
+ //std::cerr << "got global ";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
@@ -312,7 +331,15 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
localWarning = localWarning ? true : reverse == "warning";
|
||
|
|
localCritical =
|
||
|
|
localCritical ? true : reverse == "critical";
|
||
|
|
+ localDimmFault =
|
||
|
|
+ localDimmFault ? true : reverse == "dimmfault";
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ if(path.find("DIMM_CPU") != std::string::npos) {
|
||
|
|
+ dimmfault = true;
|
||
|
|
+ dimmerrAssertMap[path]["association"] = localDimmFault;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
if (globalCritical && localCritical)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
@@ -323,9 +350,26 @@ void createAssociationMatch(std::shared_ptr<sdbusplus::asio::connection>& conn)
|
||
|
|
bool critical = globalWarning && localCritical;
|
||
|
|
bool warning = globalWarning && !critical;
|
||
|
|
|
||
|
|
- fatalAssertMap[message.get_path()]["association"] = fatal;
|
||
|
|
- criticalAssertMap[message.get_path()]["association"] = critical;
|
||
|
|
- warningAssertMap[message.get_path()]["association"] = warning;
|
||
|
|
+ if(!dimmfault) {
|
||
|
|
+ fatalAssertMap[message.get_path()]["association"] = fatal;
|
||
|
|
+ criticalAssertMap[message.get_path()]["association"] = critical;
|
||
|
|
+ warningAssertMap[message.get_path()]["association"] = warning;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ if constexpr (debug)
|
||
|
|
+ {
|
||
|
|
+ for (const auto& outerPair : dimmerrAssertMap) {
|
||
|
|
+ const std::string& dimmpath = outerPair.first;
|
||
|
|
+ const auto& innerMap = outerPair.second;
|
||
|
|
+
|
||
|
|
+ for (const auto& innerPair : innerMap) {
|
||
|
|
+ const std::string& attributeName = innerPair.first;
|
||
|
|
+ bool asserted = innerPair.second;
|
||
|
|
+ std::cout << "dimmerrAssert path: " << dimmpath << ", attribute: " << attributeName
|
||
|
|
+ << ", asserted: " << std::boolalpha << asserted << std::endl;
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
|
||
|
|
updateLedStatus(conn);
|
||
|
|
});
|
||
|
|
--
|
||
|
|
2.34.1
|
||
|
|
|