2013-08-20 05:38:24

by Matus Ujhelyi

[permalink] [raw]
Subject: [PATCH net-next v3] net: cpsw: Add support for wake-on-lan for cpsw

From: Matus Ujhelyi <[email protected]>

Some phy's can be configured to enable wake on lan (e.g. at803x or marvell 88E1318S).
There is no way how to enable wol on CPSW with such connected phys. This patch
adds this support. It is provided by calling the phy's related code.

Tested on board with at8030x connected phy. Wol interrupt line is
connected to GPIO0 on am335x.

Signed-off-by: Matus Ujhelyi <[email protected]>
---
drivers/net/ethernet/ti/cpsw.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 0fcf212..5d673bf 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1640,6 +1640,28 @@ static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
return -EOPNOTSUPP;
}

+static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
+{
+ struct cpsw_priv *priv = netdev_priv(ndev);
+ int slave_no = cpsw_slave_index(priv);
+ wol->supported = 0;
+ wol->wolopts = 0;
+
+ if (priv->slaves[slave_no].phy)
+ phy_ethtool_get_wol(priv->slaves[slave_no].phy, wol);
+}
+
+static int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
+{
+ struct cpsw_priv *priv = netdev_priv(ndev);
+ int slave_no = cpsw_slave_index(priv);
+
+ if (priv->slaves[slave_no].phy)
+ return phy_ethtool_set_wol(priv->slaves[slave_no].phy, wol);
+ else
+ return -EOPNOTSUPP;
+}
+
static const struct ethtool_ops cpsw_ethtool_ops = {
.get_drvinfo = cpsw_get_drvinfo,
.get_msglevel = cpsw_get_msglevel,
@@ -1653,6 +1675,8 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
.get_sset_count = cpsw_get_sset_count,
.get_strings = cpsw_get_strings,
.get_ethtool_stats = cpsw_get_ethtool_stats,
+ .get_wol = cpsw_get_wol,
+ .set_wol = cpsw_set_wol,
};

static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
--
1.7.9.5


2013-08-20 05:52:19

by Mugunthan V N

[permalink] [raw]
Subject: Re: [PATCH net-next v3] net: cpsw: Add support for wake-on-lan for cpsw

On Tuesday 20 August 2013 11:08 AM, [email protected] wrote:
> From: Matus Ujhelyi <[email protected]>
>
> Some phy's can be configured to enable wake on lan (e.g. at803x or marvell 88E1318S).
> There is no way how to enable wol on CPSW with such connected phys. This patch
> adds this support. It is provided by calling the phy's related code.
>
> Tested on board with at8030x connected phy. Wol interrupt line is
> connected to GPIO0 on am335x.
>
> Signed-off-by: Matus Ujhelyi <[email protected]>
> ---
> drivers/net/ethernet/ti/cpsw.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 0fcf212..5d673bf 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -1640,6 +1640,28 @@ static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
> return -EOPNOTSUPP;
> }
>
> +static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
> +{
> + struct cpsw_priv *priv = netdev_priv(ndev);
> + int slave_no = cpsw_slave_index(priv);
> + wol->supported = 0;
> + wol->wolopts = 0;

Please add a blank line after variable declaration before you start
updating wol structure as commented by Francois and Sergei.

Regards
Mugunthan V N

2013-08-20 13:40:56

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH net-next v3] net: cpsw: Add support for wake-on-lan for cpsw

Hello.

On 20-08-2013 9:38, [email protected] wrote:

> From: Matus Ujhelyi <[email protected]>

> Some phy's can be configured to enable wake on lan (e.g. at803x or marvell 88E1318S).
> There is no way how to enable wol on CPSW with such connected phys. This patch
> adds this support. It is provided by calling the phy's related code.

> Tested on board with at8030x connected phy. Wol interrupt line is
> connected to GPIO0 on am335x.

> Signed-off-by: Matus Ujhelyi <[email protected]>
> ---
> drivers/net/ethernet/ti/cpsw.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)

> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 0fcf212..5d673bf 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -1640,6 +1640,28 @@ static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
> return -EOPNOTSUPP;
> }
>
> +static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
> +{
> + struct cpsw_priv *priv = netdev_priv(ndev);
> + int slave_no = cpsw_slave_index(priv);

You should have put an empty line here, not below.

> + wol->supported = 0;
> + wol->wolopts = 0;
> +
> + if (priv->slaves[slave_no].phy)
> + phy_ethtool_get_wol(priv->slaves[slave_no].phy, wol);
> +}

WBR, Sergei