summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-network/network/phosphor-network/0005-Enable-conditional-use-of-ETHTOOL-features-in-the-NI.patch
blob: c05088990b6c701869492fa309a8db65e0d04c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From 6d3d50c506e2d6b4982ff6040af9fd61edaa8beb Mon Sep 17 00:00:00 2001
From: Johnathan Mantey <johnathanx.mantey@intel.com>
Date: Fri, 24 Jan 2020 13:30:39 -0800
Subject: [PATCH] Enable conditional use of ETHTOOL features in the NIC driver

The retrieval of the NIC speed, duplex, and autonegotiation
capabilities using the ETHTOOL driver extensions is not supported in
every NIC.

Depending on the driver, the use of the ETHTOOL_GSET command may
result in undesirable messages being printed by the kernel. In order
to avoid these kernel messages a compile time switch is added.  By
default the switch disables the use of the ETHTOOL features. Enable
the ETHTOOL feature by adding:
  EXTRA_OECONF_append = " --enable-nic-ethtool=yes"
to the phosphor-network bbappend file.

Tested:
Compiled the source without changing the bbappend file. The code
compiled as is, and after code was added that would cause a compile
time failure.
Loaded the code, and performed a Redfish read of the NIC.  The
SpeedMbps field was confirmed to be set to 0.

Enabled compiling the code by adding the EXTRA_OECONF entry to the
bbappend file. The code compiled as is, and failed to compile after
adding invalid code to the protected blocks.
Loaded the code, and performed a Redfish read of the NIC.  The
SpeedMbps reported the correct link speed.

Change-Id: If03e7d473d439ebb4a01b5d3f45e37ede2a5a84f
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
---
 Makefile.am            |  3 +++
 configure.ac           | 10 ++++++++++
 ethernet_interface.cpp | 13 ++++++++-----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2a54797..ff252fc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -99,6 +99,9 @@ phosphor_network_manager_CXXFLAGS = \
 		$(PHOSPHOR_LOGGING_CFLAGS) \
 		-DBOOST_ASIO_DISABLE_THREADS \
 		-flto
+if FEATURE_NIC_ETHTOOL
+phosphor_network_manager_CXXFLAGS += -DNIC_SUPPORTS_ETHTOOL
+endif
 
 xyz/openbmc_project/Network/VLAN/Create/server.cpp: xyz/openbmc_project/Network/VLAN/Create.interface.yaml xyz/openbmc_project/Network/VLAN/Create/server.hpp
 	@mkdir -p `dirname $@`
diff --git a/configure.ac b/configure.ac
index 00b23bc..fed3e09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,16 @@ AC_SUBST(DEFAULT_BUSNAME, ["$DEFAULT_BUSNAME"])
 AC_ARG_VAR(SYSTEMD_TARGET, "Target for starting this service")
 AS_IF([test "x$SYSTEMD_TARGET" == "x"], [SYSTEMD_TARGET="multi-user.target"])
 
+AC_ARG_ENABLE([nic_ethtool],
+    [  --enable-nic-ethtool  Enable/disable the use of ETHTOOL features in the NIC driver],
+    [case "${enableval}" in
+      yes) nic_ethtool=true ;;
+      no) nic_ethtool=false ;;
+      *) AC_MSG_ERROR([bad value ${nic_ethtool} for --enable-nic-ethtool]) ;;
+      esac],[nic_ethtool=false]
+      )
+AM_CONDITIONAL([FEATURE_NIC_ETHTOOL], [test x$nic_ethtool = xtrue])
+
 # Create configured output.
 AC_CONFIG_FILES([Makefile test/Makefile])
 AC_CONFIG_FILES([xyz.openbmc_project.Network.service])
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 7f81003..ba6195e 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -57,10 +57,12 @@ EthernetInterface::EthernetInterface(sdbusplus::bus::bus& bus,
     MacAddressIntf::mACAddress(getMACAddress(intfName));
     EthernetInterfaceIntf::nTPServers(getNTPServersFromConf());
     EthernetInterfaceIntf::nameservers(getNameServerFromConf());
+#if NIC_SUPPORTS_ETHTOOL
     InterfaceInfo ifInfo = EthernetInterface::getInterfaceInfo();
 
     EthernetInterfaceIntf::autoNeg(std::get<2>(ifInfo));
     EthernetInterfaceIntf::speed(std::get<0>(ifInfo));
+#endif
     getChannelPrivilege(intfName);
 
     // Emit deferred signal.
@@ -283,13 +285,13 @@ ObjectPath EthernetInterface::neighbor(std::string iPAddress,
     return objectPath;
 }
 
+#if NIC_SUPPORTS_ETHTOOL
 /*
-Note: We don't have support for  ethtool now
-will enable this code once we bring the ethtool
-in the image.
-TODO: https://github.com/openbmc/openbmc/issues/1484
+  Enable this code if your NIC driver supports the ETHTOOL features.
+  Do this by adding the following to your phosphor-network*.bbappend file.
+     EXTRA_OECONF_append = " --enable-nic-ethtool=yes"
+  The default compile mode is to omit getInterfaceInfo()
 */
-
 InterfaceInfo EthernetInterface::getInterfaceInfo() const
 {
     int sock{-1};
@@ -330,6 +332,7 @@ InterfaceInfo EthernetInterface::getInterfaceInfo() const
     }
     return std::make_tuple(speed, duplex, autoneg);
 }
+#endif
 
 /** @brief get the mac address of the interface.
  *  @return macaddress on success
-- 
2.24.1