backports: complete backport of translation of MMD EEE registers
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>
Tue, 8 Apr 2014 02:01:42 +0000 (02:01 +0000)
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>
Wed, 9 Apr 2014 01:16:22 +0000 (18:16 -0700)
Commit b32607dd was already partially backported, this complets that
backport.

mcgrof@ergon ~/linux-next (git::master)$ git describe --contains b32607dd
v3.7-rc1~145^2~292

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
backport/backport-include/linux/mdio.h

index 5b1c0c34613a125c78c4c91c13350d2246929fe0..a1f3e95d735e8ad038253a62d64fed46e0c32736 100644 (file)
@@ -53,6 +53,35 @@ static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
 
        return adv;
 }
+
+#define ethtool_adv_to_mmd_eee_adv_t LINUX_BACKPORT(ethtool_adv_to_mmd_eee_adv_t)
+/**
+ * ethtool_adv_to_mmd_eee_adv_t
+ * @adv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement settings
+ * to EEE advertisements for the MMD EEE Advertisement (7.60) and
+ * MMD EEE Link Partner Ability (7.61) registers.
+ */
+static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv)
+{
+       u16 reg = 0;
+
+       if (adv & ADVERTISED_100baseT_Full)
+               reg |= MDIO_EEE_100TX;
+       if (adv & ADVERTISED_1000baseT_Full)
+               reg |= MDIO_EEE_1000T;
+       if (adv & ADVERTISED_10000baseT_Full)
+               reg |= MDIO_EEE_10GT;
+       if (adv & ADVERTISED_1000baseKX_Full)
+               reg |= MDIO_EEE_1000KX;
+       if (adv & ADVERTISED_10000baseKX4_Full)
+               reg |= MDIO_EEE_10GKX4;
+       if (adv & ADVERTISED_10000baseKR_Full)
+               reg |= MDIO_EEE_10GKR;
+
+       return reg;
+}
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */
 
 #endif /* __BACKPORT_LINUX_MDIO_H */