diff mbox

[1/2] e100: power down PHY if WOL is not enabled

Message ID 1323830996-16388-1-git-send-email-Jiang.Wang@riverbed.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Jiang Wang Dec. 14, 2011, 2:49 a.m. UTC
Since the interface will not be used after being put down and WOL is disabled,
just power it off.
When bring up the interface, power on the PHY.

Signed-off-by: Jiang Wang <Jiang.Wang@riverbed.com>
---
 drivers/net/ethernet/intel/e100.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

Comments

Ben Hutchings Dec. 14, 2011, 8:30 p.m. UTC | #1
On Tue, 2011-12-13 at 18:49 -0800, Jiang Wang wrote:
> Since the interface will not be used after being put down and WOL is disabled,
> just power it off.
> When bring up the interface, power on the PHY.

Don't you need to cover the case where WOL is enabled while the
interface is down?

Ben.

> Signed-off-by: Jiang Wang <Jiang.Wang@riverbed.com>
> ---
>  drivers/net/ethernet/intel/e100.c |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
> index 5a2fdf7..9824e0a 100644
> --- a/drivers/net/ethernet/intel/e100.c
> +++ b/drivers/net/ethernet/intel/e100.c
> @@ -1449,6 +1449,14 @@ static int e100_phy_init(struct nic *nic)
>  		netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
>  			     "phy_addr = %d\n", nic->mii.phy_id);
>  
> +	/* Make sure power to the PHY is enabled */
> +	if (!(nic->flags & wol_magic)) {
> +		uint16_t phy_data;
> +		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
> +		phy_data &= ~BMCR_PDOWN;
> +		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
> +	}
> +
>  	/* Get phy ID */
>  	id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
>  	id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
> @@ -2261,6 +2269,15 @@ static void e100_down(struct nic *nic)
>  	napi_disable(&nic->napi);
>  	netif_stop_queue(nic->netdev);
>  	e100_hw_reset(nic);
> +
> +	/* If wake on LAN is not enabled, power down the PHY */
> +	if (!(nic->flags & wol_magic)) {
> +		uint16_t phy_data;
> +		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
> +		phy_data |= BMCR_PDOWN;
> +		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
> +	}
> +
>  	free_irq(nic->pdev->irq, nic->netdev);
>  	del_timer_sync(&nic->watchdog);
>  	netif_carrier_off(nic->netdev);
Jiang Wang Dec. 14, 2011, 9:59 p.m. UTC | #2
Hi Ben,

Do you mean the WOL is enabled but PHY is powered off somehow? That scenario should never happen. If WOL is enabled, there is no code to power off PHY.

Regards,

Jiang

-------------------------------------
Jiang Wang
Member of Technical Staff
Riverbed Technology
Tel: (408) 522-5109
Email: Jiang.Wang@riverbed.com
www.riverbed.com

-----Original Message-----
From: Ben Hutchings [mailto:bhutchings@solarflare.com] 

Sent: Wednesday, December 14, 2011 12:31 PM
To: Jiang Wang
Cc: Jeff Kirsher; Jesse Brandeburg; Bruce Allan; Carolyn Wyborny; Don Skidmore; Greg Rose; Peter P Waskiewicz Jr; Alex Duyck; John Ronciak; e1000-devel@lists.sourceforge.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Prasanna Panchamukhi; Chaitanya Lala; Francis St. Amant; miles.ito@intel.com
Subject: Re: [PATCH 1/2] e100: power down PHY if WOL is not enabled

On Tue, 2011-12-13 at 18:49 -0800, Jiang Wang wrote:
> Since the interface will not be used after being put down and WOL is 

> disabled, just power it off.

> When bring up the interface, power on the PHY.


Don't you need to cover the case where WOL is enabled while the interface is down?

Ben.

> Signed-off-by: Jiang Wang <Jiang.Wang@riverbed.com>

> ---

>  drivers/net/ethernet/intel/e100.c |   17 +++++++++++++++++

>  1 files changed, 17 insertions(+), 0 deletions(-)

> 

> diff --git a/drivers/net/ethernet/intel/e100.c 

> b/drivers/net/ethernet/intel/e100.c

> index 5a2fdf7..9824e0a 100644

> --- a/drivers/net/ethernet/intel/e100.c

> +++ b/drivers/net/ethernet/intel/e100.c

> @@ -1449,6 +1449,14 @@ static int e100_phy_init(struct nic *nic)

>  		netif_printk(nic, hw, KERN_DEBUG, nic->netdev,

>  			     "phy_addr = %d\n", nic->mii.phy_id);

>  

> +	/* Make sure power to the PHY is enabled */

> +	if (!(nic->flags & wol_magic)) {

> +		uint16_t phy_data;

> +		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);

> +		phy_data &= ~BMCR_PDOWN;

> +		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);

> +	}

> +

>  	/* Get phy ID */

>  	id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);

>  	id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2); @@ -2261,6 

> +2269,15 @@ static void e100_down(struct nic *nic)

>  	napi_disable(&nic->napi);

>  	netif_stop_queue(nic->netdev);

>  	e100_hw_reset(nic);

> +

> +	/* If wake on LAN is not enabled, power down the PHY */

> +	if (!(nic->flags & wol_magic)) {

> +		uint16_t phy_data;

> +		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);

> +		phy_data |= BMCR_PDOWN;

> +		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);

> +	}

> +

>  	free_irq(nic->pdev->irq, nic->netdev);

>  	del_timer_sync(&nic->watchdog);

>  	netif_carrier_off(nic->netdev);


--
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
Ben Hutchings Dec. 14, 2011, 10:07 p.m. UTC | #3
On Wed, 2011-12-14 at 21:59 +0000, Jiang Wang wrote:
> Hi Ben,
> 
> Do you mean the WOL is enabled but PHY is powered off somehow? That
> scenario should never happen. If WOL is enabled, there is no code to
> power off PHY.
[...]

Initial conditions: interface up, WOL off, PHY on.

1. Bring interface down. PHY is turned off.
2. Turn WOL on.  PHY is still off, but needs to be on.

Ben.
Jiang Wang Dec. 14, 2011, 10:16 p.m. UTC | #4
I see. I will add one more check for that. Thanks.

-------------------------------------
Jiang Wang
Member of Technical Staff
Riverbed Technology
Tel: (408) 522-5109
Email: Jiang.Wang@riverbed.com
www.riverbed.com


-----Original Message-----
From: Ben Hutchings [mailto:bhutchings@solarflare.com] 

Sent: Wednesday, December 14, 2011 2:08 PM
To: Jiang Wang
Cc: Jeff Kirsher; Jesse Brandeburg; Bruce Allan; Carolyn Wyborny; Don Skidmore; Greg Rose; Peter P Waskiewicz Jr; Alex Duyck; John Ronciak; e1000-devel@lists.sourceforge.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Prasanna Panchamukhi; Chaitanya Lala; Francis St. Amant; miles.ito@intel.com
Subject: RE: [PATCH 1/2] e100: power down PHY if WOL is not enabled

On Wed, 2011-12-14 at 21:59 +0000, Jiang Wang wrote:
> Hi Ben,

> 

> Do you mean the WOL is enabled but PHY is powered off somehow? That 

> scenario should never happen. If WOL is enabled, there is no code to 

> power off PHY.

[...]

Initial conditions: interface up, WOL off, PHY on.

1. Bring interface down. PHY is turned off.
2. Turn WOL on.  PHY is still off, but needs to be on.

Ben.

--
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
diff mbox

Patch

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 5a2fdf7..9824e0a 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -1449,6 +1449,14 @@  static int e100_phy_init(struct nic *nic)
 		netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
 			     "phy_addr = %d\n", nic->mii.phy_id);
 
+	/* Make sure power to the PHY is enabled */
+	if (!(nic->flags & wol_magic)) {
+		uint16_t phy_data;
+		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
+		phy_data &= ~BMCR_PDOWN;
+		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
+	}
+
 	/* Get phy ID */
 	id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
 	id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
@@ -2261,6 +2269,15 @@  static void e100_down(struct nic *nic)
 	napi_disable(&nic->napi);
 	netif_stop_queue(nic->netdev);
 	e100_hw_reset(nic);
+
+	/* If wake on LAN is not enabled, power down the PHY */
+	if (!(nic->flags & wol_magic)) {
+		uint16_t phy_data;
+		phy_data = mdio_read(nic->netdev, nic->mii.phy_id, MII_BMCR);
+		phy_data |= BMCR_PDOWN;
+		mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, phy_data);
+	}
+
 	free_irq(nic->pdev->irq, nic->netdev);
 	del_timer_sync(&nic->watchdog);
 	netif_carrier_off(nic->netdev);