Patchwork dpaa_eth: Add dpaa_change_carrier()

login
register
mail settings
Submitter Joakim Tjernlund
Date Dec. 6, 2018, 3:32 p.m.
Message ID <20181206153215.5711-1-joakim.tjernlund@infinera.com>
Download mbox | patch
Permalink /patch/674247/
State New
Headers show

Comments

Joakim Tjernlund - Dec. 6, 2018, 3:32 p.m.
This allows to control carrier from /sys/class/net/ethX/carrier

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Madalin Bucur - Dec. 7, 2018, 8:36 a.m.
> -----Original Message-----
> From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> Sent: Thursday, December 6, 2018 5:32 PM
> To: netdev @ vger . kernel . org <netdev@vger.kernel.org>; Madalin-
> cristian Bucur <madalin.bucur@nxp.com>
> Cc: jocke@infinera.com <joakim.tjernlund@infinera.com>
> Subject: [PATCH] dpaa_eth: Add dpaa_change_carrier()
> 
> This allows to control carrier from /sys/class/net/ethX/carrier

Hi,

can you please explain why it's needed?

Thanks,
Madalin

> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> ---
>  drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> index a202c50d6fc7..0e93dfa6df0a 100644
> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -2502,12 +2502,23 @@ static int dpaa_ioctl(struct net_device *net_dev,
> struct ifreq *rq, int cmd)
>  	return phy_mii_ioctl(net_dev->phydev, rq, cmd);
>  }
> 
> +static int dpaa_change_carrier(struct net_device *dev, bool new_carrier)
> +{
> +	struct phy_device *phydev = dev->phydev;
> +
> +	if (phydev && phydev->phy_link_change)
> +		phydev->phy_link_change(phydev, new_carrier, 1);
> +
> +	return 0;
> +}
> +
>  static const struct net_device_ops dpaa_ops = {
>  	.ndo_open = dpaa_open,
>  	.ndo_start_xmit = dpaa_start_xmit,
>  	.ndo_stop = dpaa_eth_stop,
>  	.ndo_tx_timeout = dpaa_tx_timeout,
>  	.ndo_get_stats64 = dpaa_get_stats64,
> +	.ndo_change_carrier = dpaa_change_carrier,
>  	.ndo_set_mac_address = dpaa_set_mac_address,
>  	.ndo_validate_addr = eth_validate_addr,
>  	.ndo_set_rx_mode = dpaa_set_rx_mode,
> --
> 2.18.1
Andrew Lunn - Dec. 7, 2018, 9:15 a.m.
On Fri, Dec 07, 2018 at 08:36:48AM +0000, Madalin-cristian Bucur wrote:
> > -----Original Message-----
> > From: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> > Sent: Thursday, December 6, 2018 5:32 PM
> > To: netdev @ vger . kernel . org <netdev@vger.kernel.org>; Madalin-
> > cristian Bucur <madalin.bucur@nxp.com>
> > Cc: jocke@infinera.com <joakim.tjernlund@infinera.com>
> > Subject: [PATCH] dpaa_eth: Add dpaa_change_carrier()
> > 
> > This allows to control carrier from /sys/class/net/ethX/carrier
> 
> Hi,
> 
> can you please explain why it's needed?

Hi Madelin

See the patch:

[PATCH] gianfar: Add gfar_change_carrier()

Which is basically the same.

A better approach is being discussed. So for the moment, to stop DaveM
from merging this not knowing it is related to that patch:

NACK

	Andrew

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index a202c50d6fc7..0e93dfa6df0a 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2502,12 +2502,23 @@  static int dpaa_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
 	return phy_mii_ioctl(net_dev->phydev, rq, cmd);
 }
 
+static int dpaa_change_carrier(struct net_device *dev, bool new_carrier)
+{
+	struct phy_device *phydev = dev->phydev;
+
+	if (phydev && phydev->phy_link_change)
+		phydev->phy_link_change(phydev, new_carrier, 1);
+
+	return 0;
+}
+
 static const struct net_device_ops dpaa_ops = {
 	.ndo_open = dpaa_open,
 	.ndo_start_xmit = dpaa_start_xmit,
 	.ndo_stop = dpaa_eth_stop,
 	.ndo_tx_timeout = dpaa_tx_timeout,
 	.ndo_get_stats64 = dpaa_get_stats64,
+	.ndo_change_carrier = dpaa_change_carrier,
 	.ndo_set_mac_address = dpaa_set_mac_address,
 	.ndo_validate_addr = eth_validate_addr,
 	.ndo_set_rx_mode = dpaa_set_rx_mode,