netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <sebastian.hesselbarth@gmail.com>,
	<sergei.shtylyov@cogentembedded.com>, <afleming@gmail.com>,
	<kyle@moffetthome.net>, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v2 1/9] net: phy: report link partner features through ethtool
Date: Fri, 6 Dec 2013 13:01:30 -0800	[thread overview]
Message-ID: <1386363698-8407-2-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1386363698-8407-1-git-send-email-f.fainelli@gmail.com>

The PHY library already reads the MII_STAT1000 and MII_LPA registers in
genphy_read_status(), so extend it to also populate the PHY device link
partner advertised features such that we can feed this back into ethtool
when asked for it in phy_ethtool_gset().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c        | 1 +
 drivers/net/phy/phy_device.c | 6 ++++++
 include/linux/phy.h          | 5 +++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 36c6994..05cb8fe 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -289,6 +289,7 @@ int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd)
 	cmd->supported = phydev->supported;
 
 	cmd->advertising = phydev->advertising;
+	cmd->lp_advertising = phydev->lp_advertising;
 
 	ethtool_cmd_speed_set(cmd, phydev->speed);
 	cmd->duplex = phydev->duplex;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index d6447b3..6db3659 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -839,6 +839,8 @@ int genphy_read_status(struct phy_device *phydev)
 	if (err)
 		return err;
 
+	phydev->lp_advertising = 0;
+
 	if (AUTONEG_ENABLE == phydev->autoneg) {
 		if (phydev->supported & (SUPPORTED_1000baseT_Half
 					| SUPPORTED_1000baseT_Full)) {
@@ -852,6 +854,8 @@ int genphy_read_status(struct phy_device *phydev)
 			if (adv < 0)
 				return adv;
 
+			phydev->lp_advertising =
+				mii_stat1000_to_ethtool_lpa_t(lpagb);
 			lpagb &= adv << 2;
 		}
 
@@ -860,6 +864,8 @@ int genphy_read_status(struct phy_device *phydev)
 		if (lpa < 0)
 			return lpa;
 
+		phydev->lp_advertising |= mii_lpa_to_ethtool_lpa_t(lpa);
+
 		adv = phy_read(phydev, MII_ADVERTISE);
 
 		if (adv < 0)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7ff751a..90a666e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -287,8 +287,8 @@ struct phy_c45_device_ids {
  * adjust_state: Callback for the enet driver to respond to
  * changes in the state machine.
  *
- * speed, duplex, pause, supported, advertising, and
- * autoneg are used like in mii_if_info
+ * speed, duplex, pause, supported, advertising, lp_advertising,
+ * and autoneg are used like in mii_if_info
  *
  * interrupts currently only supports enabled or disabled,
  * but could be changed in the future to support enabling
@@ -340,6 +340,7 @@ struct phy_device {
 	/* See mii.h for more info */
 	u32 supported;
 	u32 advertising;
+	u32 lp_advertising;
 
 	int autoneg;
 
-- 
1.8.3.2

  reply	other threads:[~2013-12-06 21:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 21:01 [PATCH net-next v2 0/9] net: phy: consolidate PHY reset Florian Fainelli
2013-12-06 21:01 ` Florian Fainelli [this message]
2013-12-06 21:01 ` [PATCH net-next v2 2/9] net: phy: use phy_init_hw instead of open-coding it Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 3/9] net: greth: use phy_read_status() Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 4/9] net: bfin_mac: do not reset PHY after phy_start() Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 5/9] net: phy: consolidate PHY reset in phy_init_hw() Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 6/9] net: mv643xx_eth: use phy_init_hw to reset PHY Florian Fainelli
2013-12-09 20:09   ` Sebastian Hesselbarth
2013-12-06 21:01 ` [PATCH net-next v2 7/9] net: pxa168_eth: use phy_init_hw for PHY reset Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 8/9] net: tc35815: " Florian Fainelli
2013-12-06 21:01 ` [PATCH net-next v2 9/9] net: sh_eth: do not issue a wild PHY reset through BMCR Florian Fainelli
2013-12-10  1:39 ` [PATCH net-next v2 0/9] net: phy: consolidate PHY reset David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386363698-8407-2-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=afleming@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kyle@moffetthome.net \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).