[Mfg]: Ethernet interface carrier status support
Added support to return carrier status for NC-SI diagnostic
signal type.
Tested:
ipmitool raw 0x30 0x14 0x10 0 0 --> returns 0x01 as output
when BMC is in manufacturing mode.
Change-Id: Ibd2ee38e4cdb39c081e8a2df24305d9509d6fe78
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/src/manufacturingcommands.cpp b/src/manufacturingcommands.cpp
index 45d0630..1bbe14c 100644
--- a/src/manufacturingcommands.cpp
+++ b/src/manufacturingcommands.cpp
@@ -15,6 +15,7 @@
*/
#include <boost/container/flat_map.hpp>
+#include <fstream>
#include <ipmid/api.hpp>
#include <manufacturingcommands.hpp>
#include <oemcommands.hpp>
@@ -399,6 +400,23 @@
return ipmi::responseSuccess(sensorVal, std::nullopt);
}
break;
+ case SmSignalGet::smNcsiDiag:
+ {
+ constexpr const char* netBasePath = "/sys/class/net/eth";
+ constexpr const char* carrierSuffix = "/carrier";
+ std::ifstream netIfs(netBasePath + std::to_string(instance) +
+ carrierSuffix);
+ if (!netIfs.good())
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+ std::string carrier;
+ netIfs >> carrier;
+ resetMtmTimer(yield);
+ return ipmi::responseSuccess(
+ static_cast<uint8_t>(std::stoi(carrier)), std::nullopt);
+ }
+ break;
default:
return ipmi::responseInvalidFieldRequest();
break;