All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioana Ciornei <ioana.ciornei@nxp.com>
To: linux@armlinux.org.uk, f.fainelli@gmail.com, andrew@lunn.ch,
	hkallweit1@gmail.com, maxime.chevallier@bootlin.com,
	olteanv@gmail.com, thomas.petazzoni@bootlin.com,
	davem@davemloft.net, vivien.didelot@gmail.com
Cc: netdev@vger.kernel.org, Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH 11/11] net: dsa: sja1105: Fix broken fixed-link interfaces on user ports
Date: Tue, 28 May 2019 00:22:07 +0300	[thread overview]
Message-ID: <1558992127-26008-12-git-send-email-ioana.ciornei@nxp.com> (raw)
In-Reply-To: <1558992127-26008-1-git-send-email-ioana.ciornei@nxp.com>

From: Vladimir Oltean <olteanv@gmail.com>

PHYLIB and PHYLINK handle fixed-link interfaces differently. PHYLIB
wraps them in a software PHY ("pseudo fixed link") phydev construct such
that .adjust_link driver callbacks see an unified API. Whereas PHYLINK
simply creates a phylink_link_state structure and passes it to
.mac_config.

At the time the driver was introduced, DSA was using PHYLIB for the
CPU/cascade ports (the ones with no net devices) and PHYLINK for
everything else.

As explained below:

commit aab9c4067d2389d0adfc9c53806437df7b0fe3d5
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Thu May 10 13:17:36 2018 -0700

  net: dsa: Plug in PHYLINK support

  Drivers that utilize fixed links for user-facing ports (e.g: bcm_sf2)
  will need to implement phylink_mac_ops from now on to preserve
  functionality, since PHYLINK *does not* create a phy_device instance
  for fixed links.

In the above patch, DSA guards the .phylink_mac_config callback against
a NULL phydev pointer.  Therefore, .adjust_link is not called in case of
a fixed-link user port.

This patch fixes the situation by converting the driver from using
.adjust_link to .phylink_mac_config.  This can be done now in a unified
fashion for both slave and CPU/cascade ports because DSA now uses
PHYLINK for all ports.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/sja1105/sja1105_main.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 0663b78a2f6c..cfdefd9f1905 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -734,15 +734,16 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port,
 	return sja1105_clocking_setup_port(priv, port);
 }
 
-static void sja1105_adjust_link(struct dsa_switch *ds, int port,
-				struct phy_device *phydev)
+static void sja1105_mac_config(struct dsa_switch *ds, int port,
+			       unsigned int link_an_mode,
+			       const struct phylink_link_state *state)
 {
 	struct sja1105_private *priv = ds->priv;
 
-	if (!phydev->link)
+	if (!state->link)
 		sja1105_adjust_port_config(priv, port, 0, false);
 	else
-		sja1105_adjust_port_config(priv, port, phydev->speed, true);
+		sja1105_adjust_port_config(priv, port, state->speed, true);
 }
 
 static void sja1105_phylink_validate(struct dsa_switch *ds, int port,
@@ -1515,9 +1516,9 @@ static int sja1105_set_ageing_time(struct dsa_switch *ds,
 static const struct dsa_switch_ops sja1105_switch_ops = {
 	.get_tag_protocol	= sja1105_get_tag_protocol,
 	.setup			= sja1105_setup,
-	.adjust_link		= sja1105_adjust_link,
 	.set_ageing_time	= sja1105_set_ageing_time,
 	.phylink_validate	= sja1105_phylink_validate,
+	.phylink_mac_config	= sja1105_mac_config,
 	.get_strings		= sja1105_get_strings,
 	.get_ethtool_stats	= sja1105_get_ethtool_stats,
 	.get_sset_count		= sja1105_get_sset_count,
-- 
2.21.0


      parent reply	other threads:[~2019-05-27 21:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 21:21 [PATCH 00/11] Decoupling PHYLINK from struct net_device Ioana Ciornei
2019-05-27 21:21 ` [PATCH 01/11] net: phy: Add phy_sysfs_create_links helper function Ioana Ciornei
2019-05-27 23:32   ` Fabio Estevam
2019-05-28  6:53     ` Ioana Ciornei
2019-05-27 21:21 ` [PATCH 02/11] net: phy: Guard against the presence of a netdev Ioana Ciornei
2019-05-27 21:21 ` [PATCH 03/11] net: phy: Check against net_device being NULL Ioana Ciornei
2019-05-27 23:07   ` kbuild test robot
2019-05-28  2:27   ` kbuild test robot
2019-05-28 15:50   ` Andrew Lunn
2019-05-28 15:51   ` Andrew Lunn
2019-05-27 21:22 ` [PATCH 04/11] net: phy: Add phy_standalone sysfs entry Ioana Ciornei
2019-05-28  2:00   ` Florian Fainelli
2019-05-27 21:22 ` [PATCH 05/11] net: phylink: Add phylink_mac_link_{up,down} wrapper functions Ioana Ciornei
2019-05-27 21:22 ` [PATCH 06/11] net: phylink: Add struct phylink_config to PHYLINK API Ioana Ciornei
2019-05-28  1:51   ` Florian Fainelli
2019-05-27 21:22 ` [PATCH 07/11] net: phylink: Add PHYLINK_DEV operation type Ioana Ciornei
2019-05-28  2:01   ` Florian Fainelli
2019-05-28 17:11     ` Ioana Ciornei
2019-05-27 21:22 ` [PATCH 08/11] net: phylink: Add phylink_{printk,err,warn,info,dbg} macros Ioana Ciornei
2019-05-28  1:53   ` Florian Fainelli
2019-05-27 21:22 ` [PATCH 09/11] net: dsa: Move the phylink driver calls into port.c Ioana Ciornei
2019-05-28  2:02   ` Florian Fainelli
2019-05-27 21:22 ` [PATCH 10/11] net: dsa: Use PHYLINK for the CPU/DSA ports Ioana Ciornei
2019-05-28  1:55   ` Florian Fainelli
2019-05-28  3:36   ` kbuild test robot
2019-05-28  3:36   ` [RFC PATCH] net: dsa: dsa_port_phylink_register() can be static kbuild test robot
2019-05-29  2:35   ` [net] 9dd6d07682: kernel_BUG_at_drivers/net/phy/mdio_bus.c kernel test robot
2019-05-29  2:35     ` kernel test robot
2019-05-29 16:11     ` Ioana Ciornei
2019-05-29 16:25       ` Russell King - ARM Linux admin
2019-05-29 20:08         ` Ioana Ciornei
2019-05-29 23:03           ` Andrew Lunn
2019-05-29 23:03             ` Andrew Lunn
2019-05-27 21:22 ` Ioana Ciornei [this message]

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=1558992127-26008-12-git-send-email-ioana.ciornei@nxp.com \
    --to=ioana.ciornei@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vivien.didelot@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.