Report NIC link status via netlink carrier state
Update Redfish to use a DBus boolean value specifically intended for
communicating the NIC link state. Existing Intel server boards have a
NCSI channel with a speed value always assigned to 100Mbps. This makes
identifying link state impossible via the network speed value. The
DBus boolean uses the netlink carrier on/off state which is more
accurate.
Tested:
BMC Console commands:
ip link set down dev eth0
Get managers/bmc/eth0 state ;; LinkStatus is LinkDown
ip link set up dev eth0
Get managers/bmc/eth0 state ;; LinkStatus is LinkUp
Remove NIC cable from RJ45 connector
Get managers/bmc/eth0 state ;; LinkStatus is LinkDown
Insert NIC cable into RJ45 connector
Get managers/bmc/eth0 state ;; LinkStatus is LinkUp
Change-Id: I93d3f716a0afc563e3312e99b4a4163187985521
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index b6f3baa..4998a95 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -97,6 +97,7 @@
bool NTPEnabled;
bool HostNameEnabled;
bool SendHostNameEnabled;
+ bool linkUp;
std::string DHCPEnabled;
std::string operatingMode;
std::string hostname;
@@ -265,6 +266,15 @@
ethData.speed = *speed;
}
}
+ else if (propertyPair.first == "LinkUp")
+ {
+ const bool *linkUp =
+ std::get_if<bool>(&propertyPair.second);
+ if (linkUp != nullptr)
+ {
+ ethData.linkUp = *linkUp;
+ }
+ }
else if (propertyPair.first == "Nameservers")
{
const std::vector<std::string> *nameservers =
@@ -1616,7 +1626,6 @@
json_response["InterfaceEnabled"] = true;
if (ethData.speed == 0)
{
- json_response["LinkStatus"] = "NoLink";
json_response["Status"] = {
{"Health", "OK"},
{"State", "Disabled"},
@@ -1624,12 +1633,13 @@
}
else
{
- json_response["LinkStatus"] = "LinkUp";
json_response["Status"] = {
{"Health", "OK"},
{"State", "Enabled"},
};
}
+
+ json_response["LinkStatus"] = ethData.linkUp ? "LinkUp" : "LinkDown";
json_response["SpeedMbps"] = ethData.speed;
json_response["MACAddress"] = ethData.mac_address;
json_response["DHCPv4"]["DHCPEnabled"] =