diff mbox

[ovs-dev,v2,1/2] netdev-linux: correctly detect port speed bits beyond 16bit

Message ID 1448840944-11232-2-git-send-email-simon.horman@netronome.com
State Accepted
Headers show

Commit Message

Simon Horman Nov. 29, 2015, 11:49 p.m. UTC
This includes bits for:
* Backplane
* 1000 baseKX (full duplex)
* All speeds of 10Gbit and above other than 10000 baseT (full duplex).

Signed-off-by: Simon Horman <simon.horman@netronome.com>

---

v2
* Include compatibility code as suggested by Ben Pfaff
---
 lib/netdev-linux.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Ben Pfaff Nov. 30, 2015, 12:07 a.m. UTC | #1
On Mon, Nov 30, 2015 at 08:49:03AM +0900, Simon Horman wrote:
> This includes bits for:
> * Backplane
> * 1000 baseKX (full duplex)
> * All speeds of 10Gbit and above other than 10000 baseT (full duplex).
> 
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> 
> ---
> 
> v2
> * Include compatibility code as suggested by Ben Pfaff

Thanks Simon, applied to master.
diff mbox

Patch

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index ed78868896d9..1d1a22bf1341 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -139,6 +139,18 @@  struct tpacket_auxdata {
     uint16_t tp_vlan_tpid;
 };
 
+/* Linux 2.6.27 introduced ethtool_cmd_speed
+ *
+ * To avoid revisiting problems reported with using configure to detect
+ * compatibility (see report at
+ * http://openvswitch.org/pipermail/dev/2014-October/047978.html)
+ * unconditionally replace ethtool_cmd_speed. */
+#define ethtool_cmd_speed rpl_ethtool_cmd_speed
+static inline uint32_t rpl_ethtool_cmd_speed(const struct ethtool_cmd *ep)
+{
+        return ep->speed | (ep->speed_hi << 16);
+}
+
 /* Linux 2.6.35 introduced IFLA_STATS64 and rtnl_link_stats64.
  *
  * Tests for rtnl_link_stats64 don't seem to consistently work, e.g. on
@@ -1847,7 +1859,7 @@  netdev_linux_read_features(struct netdev_linux *netdev)
     }
 
     /* Current settings. */
-    speed = ecmd.speed;
+    speed = ethtool_cmd_speed(&ecmd);
     if (speed == SPEED_10) {
         netdev->current = ecmd.duplex ? NETDEV_F_10MB_FD : NETDEV_F_10MB_HD;
     } else if (speed == SPEED_100) {