lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 12 Dec 2018 10:34:56 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Joakim Tjernlund <joakim.tjernlund@...inera.com>,
        "netdev @ vger . kernel . org" <netdev@...r.kernel.org>,
        "claudiu . manoil @ nxp . com" <claudiu.manoil@....com>,
        Andrew Lunn <andrew@...n.ch>
Subject: Re: [PATCHv2] gianfar: Add gfar_change_carrier() for Fixed PHYs

On 12/12/18 4:33 AM, Joakim Tjernlund wrote:
> This allows to control carrier from /sys/class/net/ethX/carrier for
> Fixed PHYs.
> 
> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@...inera.com>
> ---
>  v2 - Only allow carrier changes for Fixed PHYs
> 
>  Florian: I have reimpl. this as I think you meant by registering
>           a Fixed PHY callback.
>  Andrew: Are happy with this as well?

Yes that is exactly what I had in mind, thanks for listening and
translating that into code :) Looking forward to the generic version
being submitted. Thanks!

> 
>  If this is OK I will sent the other 2 drivers.
> 
>  drivers/net/ethernet/freescale/gianfar.c | 26 ++++++++++++++++++++++++
>  drivers/net/ethernet/freescale/gianfar.h |  2 +-
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
> index 63daae120b2d..49971093e10f 100644
> --- a/drivers/net/ethernet/freescale/gianfar.c
> +++ b/drivers/net/ethernet/freescale/gianfar.c
> @@ -491,7 +491,28 @@ static int gfar_set_mac_addr(struct net_device *dev, void *p)
>  
>  	return 0;
>  }
> +static int gfar_fixed_phy_link_update(struct net_device *dev,
> +				      struct fixed_phy_status *status)
> +{
> +	struct gfar_private *priv;
> +
> +	if (dev && dev->phydev && status) {
> +		priv = netdev_priv(dev);
> +		status->link = !priv->no_carrier;
> +	}
> +	return 0;
> +}
> +static int gfar_change_carrier(struct net_device *dev, bool new_carrier)
> +{
> +	struct phy_device *phydev = dev->phydev;
> +	struct gfar_private *priv;
>  
> +	if (!phy_is_pseudo_fixed_link(phydev))
> +		return -EINVAL;
> +	priv = netdev_priv(dev);
> +	priv->no_carrier = !new_carrier;
> +	return 0;
> +}
>  static const struct net_device_ops gfar_netdev_ops = {
>  	.ndo_open = gfar_enet_open,
>  	.ndo_start_xmit = gfar_start_xmit,
> @@ -502,6 +523,7 @@ static const struct net_device_ops gfar_netdev_ops = {
>  	.ndo_tx_timeout = gfar_timeout,
>  	.ndo_do_ioctl = gfar_ioctl,
>  	.ndo_get_stats = gfar_get_stats,
> +	.ndo_change_carrier = gfar_change_carrier,
>  	.ndo_set_mac_address = gfar_set_mac_addr,
>  	.ndo_validate_addr = eth_validate_addr,
>  #ifdef CONFIG_NET_POLL_CONTROLLER
> @@ -1807,6 +1829,10 @@ static int init_phy(struct net_device *dev)
>  		return -ENODEV;
>  	}
>  
> +	if (phy_is_pseudo_fixed_link(phydev))
> +		fixed_phy_set_link_update(phydev,
> +					  gfar_fixed_phy_link_update);
> +
>  	if (interface == PHY_INTERFACE_MODE_SGMII)
>  		gfar_configure_serdes(dev);
>  
> diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
> index 5aa814799d70..94a64d2dcc6f 100644
> --- a/drivers/net/ethernet/freescale/gianfar.h
> +++ b/drivers/net/ethernet/freescale/gianfar.h
> @@ -1158,7 +1158,7 @@ struct gfar_private {
>  	int oldspeed;
>  	int oldduplex;
>  	int oldlink;
> -
> +	bool no_carrier;
>  	uint32_t msg_enable;
>  
>  	struct work_struct reset_task;
> 


-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ