All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: "f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"hkallweit1@gmail.com" <hkallweit1@gmail.com>,
	"maxime.chevallier@bootlin.com" <maxime.chevallier@bootlin.com>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: Re: [RFC PATCH net-next 7/9] net: dsa: Move the phylink driver calls into port.c
Date: Thu, 23 May 2019 23:03:17 +0100	[thread overview]
Message-ID: <20190523220317.g4k7b3k3edcaxod5@shell.armlinux.org.uk> (raw)
In-Reply-To: <20190523011958.14944-8-ioana.ciornei@nxp.com>

On Thu, May 23, 2019 at 01:20:41AM +0000, Ioana Ciornei wrote:
> diff --git a/net/dsa/port.c b/net/dsa/port.c
> index ed8ba9daa3ba..d0f955e8b731 100644
> --- a/net/dsa/port.c
> +++ b/net/dsa/port.c
> @@ -422,6 +422,102 @@ static struct phy_device *dsa_port_get_phy_device(struct dsa_port *dp)
>  	return phydev;
>  }
>  
> +void dsa_port_phylink_validate(struct dsa_port *dp,
> +			       unsigned long *supported,
> +			       struct phylink_link_state *state)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->phylink_validate)
> +		return;

No, really not acceptable.  If there's no phylink_validate function,
then simply returning is going to produce what I'd term "unpredictable"
results.  This callback will be called with various modes in
"supported", and if you simply return without any modification,
you're basically saying that you support _anything_ that the supported
mask throws at you.

> +
> +	ds->ops->phylink_validate(ds, dp->index, supported, state);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_validate);
> +
> +int dsa_port_phylink_mac_link_state(struct dsa_port *dp,
> +				    struct phylink_link_state *state)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	/* Only called for SGMII and 802.3z */
> +	if (!ds->ops->phylink_mac_link_state)
> +		return -EOPNOTSUPP;
> +
> +	return ds->ops->phylink_mac_link_state(ds, dp->index, state);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_mac_link_state);
> +
> +void dsa_port_phylink_mac_config(struct dsa_port *dp,
> +				 unsigned int mode,
> +				 const struct phylink_link_state *state)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->phylink_mac_config)
> +		return;

If you don't implement this, what's the point?

> +
> +	ds->ops->phylink_mac_config(ds, dp->index, mode, state);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_mac_config);
> +
> +void dsa_port_phylink_mac_an_restart(struct dsa_port *dp)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->phylink_mac_an_restart)
> +		return;
> +
> +	ds->ops->phylink_mac_an_restart(ds, dp->index);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_mac_an_restart);
> +
> +void dsa_port_phylink_mac_link_down(struct dsa_port *dp,
> +				    unsigned int mode,
> +				    phy_interface_t interface,
> +				    struct phy_device *phydev)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->phylink_mac_link_down) {
> +		if (ds->ops->adjust_link && phydev)
> +			ds->ops->adjust_link(ds, dp->index, phydev);
> +		return;
> +	}
> +
> +	ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_mac_link_down);
> +
> +void dsa_port_phylink_mac_link_up(struct dsa_port *dp,
> +				  unsigned int mode,
> +				  phy_interface_t interface,
> +				  struct phy_device *phydev)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->phylink_mac_link_up) {
> +		if (ds->ops->adjust_link && phydev)
> +			ds->ops->adjust_link(ds, dp->index, phydev);
> +		return;
> +	}
> +
> +	ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_mac_link_up);
> +
> +void dsa_port_phylink_fixed_state(struct dsa_port *dp,
> +				  struct phylink_link_state *state)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +
> +	/* No need to check that this operation is valid, the callback would
> +	 * not be called if it was not.
> +	 */
> +	ds->ops->phylink_fixed_state(ds, dp->index, state);
> +}
> +EXPORT_SYMBOL(dsa_port_phylink_fixed_state);
> +
>  static int dsa_port_setup_phy_of(struct dsa_port *dp, bool enable)
>  {
>  	struct dsa_switch *ds = dp->ds;
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 9892ca1f6859..308066da8a0f 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1169,25 +1169,16 @@ static void dsa_slave_phylink_validate(struct net_device *dev,
>  				       struct phylink_link_state *state)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
> -
> -	if (!ds->ops->phylink_validate)
> -		return;

Ah, this is where it came from - but still wrong for the reasons I
stated above, though it makes it not a bug you're introducing, but
one that pre-exists.

>  
> -	ds->ops->phylink_validate(ds, dp->index, supported, state);
> +	dsa_port_phylink_validate(dp, supported, state);
>  }
>  
>  static int dsa_slave_phylink_mac_link_state(struct net_device *dev,
>  					    struct phylink_link_state *state)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
> -
> -	/* Only called for SGMII and 802.3z */
> -	if (!ds->ops->phylink_mac_link_state)
> -		return -EOPNOTSUPP;
>  
> -	return ds->ops->phylink_mac_link_state(ds, dp->index, state);
> +	return dsa_port_phylink_mac_link_state(dp, state);
>  }
>  
>  static void dsa_slave_phylink_mac_config(struct net_device *dev,
> @@ -1195,23 +1186,15 @@ static void dsa_slave_phylink_mac_config(struct net_device *dev,
>  					 const struct phylink_link_state *state)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
> -
> -	if (!ds->ops->phylink_mac_config)
> -		return;
>  
> -	ds->ops->phylink_mac_config(ds, dp->index, mode, state);
> +	dsa_port_phylink_mac_config(dp, mode, state);
>  }
>  
>  static void dsa_slave_phylink_mac_an_restart(struct net_device *dev)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
> -
> -	if (!ds->ops->phylink_mac_an_restart)
> -		return;
>  
> -	ds->ops->phylink_mac_an_restart(ds, dp->index);
> +	dsa_port_phylink_mac_an_restart(dp);
>  }
>  
>  static void dsa_slave_phylink_mac_link_down(struct net_device *dev,
> @@ -1219,15 +1202,8 @@ static void dsa_slave_phylink_mac_link_down(struct net_device *dev,
>  					    phy_interface_t interface)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
> -
> -	if (!ds->ops->phylink_mac_link_down) {
> -		if (ds->ops->adjust_link && dev->phydev)
> -			ds->ops->adjust_link(ds, dp->index, dev->phydev);
> -		return;
> -	}
>  
> -	ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface);
> +	dsa_port_phylink_mac_link_down(dp, mode, interface, dev->phydev);
>  }
>  
>  static void dsa_slave_phylink_mac_link_up(struct net_device *dev,
> @@ -1236,15 +1212,8 @@ static void dsa_slave_phylink_mac_link_up(struct net_device *dev,
>  					  struct phy_device *phydev)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
>  
> -	if (!ds->ops->phylink_mac_link_up) {
> -		if (ds->ops->adjust_link && dev->phydev)
> -			ds->ops->adjust_link(ds, dp->index, dev->phydev);
> -		return;
> -	}
> -
> -	ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev);
> +	dsa_port_phylink_mac_link_up(dp, mode, interface, phydev);
>  }
>  
>  static const struct phylink_mac_ops dsa_slave_phylink_mac_ops = {
> @@ -1268,12 +1237,8 @@ static void dsa_slave_phylink_fixed_state(struct net_device *dev,
>  					  struct phylink_link_state *state)
>  {
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
> -	struct dsa_switch *ds = dp->ds;
>  
> -	/* No need to check that this operation is valid, the callback would
> -	 * not be called if it was not.
> -	 */
> -	ds->ops->phylink_fixed_state(ds, dp->index, state);
> +	dsa_port_phylink_fixed_state(dp, state);
>  }
>  
>  /* slave device setup *******************************************************/
> -- 
> 2.21.0
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  parent reply	other threads:[~2019-05-23 22:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  1:20 [RFC PATCH net-next 0/9] Decoupling PHYLINK from struct net_device Ioana Ciornei
2019-05-23  1:20 ` [RFC PATCH net-next 1/9] net: phy: Add phy_sysfs_create_links helper function Ioana Ciornei
2019-05-23  2:00   ` Florian Fainelli
2019-05-23  1:20 ` [RFC PATCH net-next 2/9] net: phy: Guard against the presence of a netdev Ioana Ciornei
2019-05-23  2:02   ` Florian Fainelli
2019-05-23 22:18   ` Andrew Lunn
2019-05-24 10:30     ` Ioana Ciornei
2019-05-24 13:10       ` Andrew Lunn
2019-05-24 13:55         ` Ioana Ciornei
2019-05-23  1:20 ` [RFC PATCH net-next 3/9] net: phy: Add phy_standalone sysfs entry Ioana Ciornei
2019-05-23  2:05   ` Florian Fainelli
2019-05-24 10:52     ` Ioana Ciornei
2019-05-23  1:20 ` [RFC PATCH net-next 4/9] net: phylink: Add phylink_mac_link_{up,down} wrapper functions Ioana Ciornei
2019-05-23  2:05   ` Florian Fainelli
2019-05-23  1:20 ` [RFC PATCH net-next 5/9] net: phylink: Add phylink_create_raw Ioana Ciornei
2019-05-23  2:25   ` Florian Fainelli
2019-05-23  2:29     ` Florian Fainelli
2019-05-23 12:10       ` Ioana Ciornei
2019-05-23 14:32         ` Florian Fainelli
2019-05-23 20:32           ` Vladimir Oltean
2019-05-23 21:30             ` Florian Fainelli
2019-05-23 21:27   ` Russell King - ARM Linux admin
2019-05-23 21:37     ` Vladimir Oltean
2019-05-23 21:55   ` Russell King - ARM Linux admin
2019-05-23 22:04     ` Vladimir Oltean
2019-05-23 22:35       ` Russell King - ARM Linux admin
2019-05-23  1:20 ` [RFC PATCH net-next 7/9] net: dsa: Move the phylink driver calls into port.c Ioana Ciornei
2019-05-23  2:13   ` Florian Fainelli
2019-05-23 22:03   ` Russell King - ARM Linux admin [this message]
2019-05-23  1:20 ` [RFC PATCH net-next 6/9] net: phylink: Make fixed link notifier calls edge-triggered Ioana Ciornei
2019-05-23  1:20 ` [RFC PATCH net-next 8/9] net: dsa: Use PHYLINK for the CPU/DSA ports Ioana Ciornei
2019-05-23  2:17   ` Florian Fainelli
2019-05-23 20:01     ` Vladimir Oltean
2019-05-24 13:19       ` Andrew Lunn
2019-05-24 13:44         ` Vladimir Oltean
2019-05-23  1:20 ` [RFC PATCH net-next 9/9] net: dsa: sja1105: Fix broken fixed-link interfaces on user ports Ioana Ciornei
2019-05-23  2:26   ` Florian Fainelli
2019-05-23 15:12 ` [RFC PATCH net-next 0/9] Decoupling PHYLINK from struct net_device Maxime Chevallier

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=20190523220317.g4k7b3k3edcaxod5@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.