Skip to contentSkip to conversation

PHYLIB: Add get_link ethtool helper function

PATCH NAK Nathaniel Case 2 participants 3 messages Jun 5, 2006 – Jun 12, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 PHYLIB: Add get_link ethtool helper function

This adds a phy_ethtool_get_link() function along the same lines as phy_ethtool_gset(). This provides drivers utilizing PHYLIB an alternative to using ethtool_op_get_link(). This is more desirable since the "Link detected" field in ethtool would actually reflect the state of the PHY register.

Patch depends on previous patch (0/2).

---

drivers/net/phy/phy.c +16 -0
@@ -301,6 +301,22 @@
 	return 0;
 }
 
+/* 
+ * phy_ethtool_get_link:
+ * A generic ethtool get_link function which is more accurate than
+ * the network interface carrier status since it queries the
+ * PHY directly.
+ */
+u32 phy_ethtool_get_link(struct phy_device *phydev)
+{
+	int err;
+
+	err = genphy_update_link(phydev);
+	if (err)
+		return 0;
+
+	return (u32) phydev->link;
+}
 
 /* Note that this function is currently incompatible with the
  * PHYCONTROL layer.  It changes registers without regard to
include/linux/phy.h +1 -0
@@ -374,6 +374,7 @@
 void phy_stop_machine(struct phy_device *phydev);
 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
 int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
+u32 phy_ethtool_get_link(struct phy_device *phydev);
 int phy_mii_ioctl(struct phy_device *phydev,
 		struct mii_ioctl_data *mii_data, int cmd);
 int phy_start_interrupts(struct phy_device *phydev);
#1 lore raw
Quoted 10 lines · Nathaniel Case

This adds a phy_ethtool_get_link() function along the same lines as phy_ethtool_gset(). This provides drivers utilizing PHYLIB an alternative to using ethtool_op_get_link(). This is more desirable since the "Link detected" field in ethtool would actually reflect the state of the PHY register.

Patch depends on previous patch (0/2).

NAK, needs an EXPORT

#2 lore raw
Quoted 6 lines · Jeff Garzik
Quoted 6 lines

This adds a phy_ethtool_get_link() function along the same lines as phy_ethtool_gset(). This provides drivers utilizing PHYLIB an alternative to using ethtool_op_get_link(). This is more desirable since the "Link detected" field in ethtool would actually reflect the state of the PHY register.

[snip]

Quoted 1 line

NAK, needs an EXPORT

In that case, shouldn't we EXPORT phy_ethtool_sset() and phy_ethtool_gset() in drivers/net/phy/phy.c as well?

- Nate Case <[email protected]>