summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch')
-rw-r--r--meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch b/meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch
new file mode 100644
index 0000000000..4e98f67a57
--- /dev/null
+++ b/meta-ibs/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb/0002-Add-log-count-limitation-to-requestAdd.patch
@@ -0,0 +1,95 @@
+From e6bd7ce41f4729469617891e24f35abb195dfd5e Mon Sep 17 00:00:00 2001
+From: Helen Huang <he.huang@intel.com>
+Date: Mon, 31 May 2021 09:19:55 +0800
+Subject: [PATCH 2/3] Add log count limitation to requestAdd()
+
+To avoid log storm, add the log count limitation to
+requestAdd().
+
+Change-Id: I91894ff07fa252ed7746816535611a33b6f640ea
+Signed-off-by: Helen Huang <he.huang@intel.com>
+Signed-off-by: Andrey V.Kosteltsev <AKosteltsev@IBS.RU>
+---
+ ipmbbridged.cpp | 44 ++++++++++++++++++++++++++++++++++++++------
+ ipmbbridged.hpp | 3 +++
+ 2 files changed, 41 insertions(+), 6 deletions(-)
+
+diff --git a/ipmbbridged.cpp b/ipmbbridged.cpp
+index dec6ad2..3ffc1f7 100644
+--- a/ipmbbridged.cpp
++++ b/ipmbbridged.cpp
+@@ -916,12 +916,44 @@ std::tuple<int, uint8_t, uint8_t, uint8_t, uint8_t, std::vector<uint8_t>>
+
+ if (i2cRetryCnt == ipmbI2cNumberOfRetries)
+ {
+- std::string msgToLog =
+- "requestAdd: Sent to I2C failed after retries."
+- " busId=" +
+- std::to_string(ipmbBusId) + ", error=" + ec.message();
+- phosphor::logging::log<phosphor::logging::level::INFO>(
+- msgToLog.c_str());
++ if ((requestAddLogCount <= ipmbRequestAddLogLimit) ||
++ (!(requestAddLogCount % ipmbRequestAddLogInterval)) ||
++ (UINT_MAX == requestAddLogCount))
++ {
++ std::string msgToLog;
++ if (requestAddLogCount == ipmbRequestAddLogLimit)
++ {
++ msgToLog = "requestAdd: There are " +
++ std::to_string(ipmbRequestAddLogLimit - 1) +
++ " similiar logs."
++ " To avoid log storm, not all the logs for the "
++ "issue will be shown: ";
++ }
++ if (!(requestAddLogCount % ipmbRequestAddLogInterval) && (requestAddLogCount != 0))
++ {
++ msgToLog = "requestAdd: There are " +
++ std::to_string(requestAddLogCount) +
++ " similiar logs so far: ";
++ }
++ if (UINT_MAX == requestAddLogCount)
++ {
++ msgToLog = "requestAdd: There are " +
++ std::to_string(requestAddLogCount) +
++ " similiar logs,"
++ " The log count will be rolled back to zero: ";
++ }
++ msgToLog += "requestAdd: Sent to I2C failed after retries."
++ " busId=" +
++ std::to_string(ipmbBusId) +
++ ", error=" + ec.message();
++ phosphor::logging::log<phosphor::logging::level::INFO>(
++ msgToLog.c_str());
++ }
++ requestAddLogCount++;
++ }
++ else
++ {
++ requestAddLogCount = 0;
+ }
+
+ request->timer->expires_after(
+diff --git a/ipmbbridged.hpp b/ipmbbridged.hpp
+index c79ac63..eaba7ae 100644
+--- a/ipmbbridged.hpp
++++ b/ipmbbridged.hpp
+@@ -50,6 +50,8 @@ constexpr int ipmbMaxOutstandingRequestsCount = 64;
+ constexpr int ipmbNumberOfTries = 6;
+ constexpr uint64_t ipmbRequestRetryTimeout = 250; // ms
+
++constexpr int ipmbRequestAddLogLimit = 10;
++constexpr int ipmbRequestAddLogInterval = 100;
+ /**
+ * @brief Ipmb I2C communication
+ */
+@@ -313,6 +315,7 @@ class IpmbChannel
+ uint8_t ipmbBusId;
+ uint8_t channelIdx;
+
++ unsigned int requestAddLogCount = 0;
+ std::shared_ptr<IpmbCommandFilter> commandFilter;
+
+ // array storing outstanding requests
+--
+2.35.1
+