netdev-linux: correctly detect port speed bits beyond 16bit
authorSimon Horman <simon.horman@netronome.com>
Sun, 29 Nov 2015 23:49:03 +0000 (08:49 +0900)
committerBen Pfaff <blp@ovn.org>
Mon, 30 Nov 2015 00:05:21 +0000 (16:05 -0800)
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>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/netdev-linux.c

index ed78868..1d1a22b 100644 (file)
@@ -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) {