linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin Foster <colin.foster@in-advantage.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH v1 net-next 4/6] net: dsa: ocelot: felix: add per-device-per-port quirks
Date: Mon, 22 Nov 2021 08:20:12 -0800	[thread overview]
Message-ID: <20211122162012.GB29931@DESKTOP-LAINLKC.localdomain> (raw)
In-Reply-To: <20211121171324.j6kxclyhaheihpja@skbuf>

On Sun, Nov 21, 2021 at 05:13:25PM +0000, Vladimir Oltean wrote:
> On Fri, Nov 19, 2021 at 02:43:11PM -0800, Colin Foster wrote:
> > Initial Felix-driver products (VSC9959 and VSC9953) both had quirks
> > where the PCS was in charge of rate adaptation. In the case of the
> > VSC7512 there is a differnce in that some ports (ports 0-3) don't have
> > a PCS and others might have different quirks based on how they are
> > configured.
> > 
> > This adds a generic method by which any port can have any quirks that
> > are handled by each device's driver.
> > 
> > Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> > ---
> >  drivers/net/dsa/ocelot/felix.c           | 20 +++++++++++++++++---
> >  drivers/net/dsa/ocelot/felix.h           |  4 ++++
> >  drivers/net/dsa/ocelot/felix_vsc9959.c   |  1 +
> >  drivers/net/dsa/ocelot/seville_vsc9953.c |  1 +
> >  4 files changed, 23 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> > index 2a90a703162d..5be2baa83bd8 100644
> > --- a/drivers/net/dsa/ocelot/felix.c
> > +++ b/drivers/net/dsa/ocelot/felix.c
> > @@ -824,14 +824,25 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
> >  		phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs);
> >  }
> >  
> > +unsigned long felix_quirks_have_rate_adaptation(struct ocelot *ocelot,
> > +						int port)
> > +{
> > +	return FELIX_MAC_QUIRKS;
> > +}
> > +EXPORT_SYMBOL(felix_quirks_have_rate_adaptation);
> > +
> 
> I would prefer if you don't introduce an actual virtual function for
> this. An unsigned long bitmask constant per device family should be
> enough. Even if we end up in a situation where internal PHY ports have
> one set of quirks and SERDES ports another, I would rather keep all
> quirks in a global namespace from 0 to 31, or whatever. So the quirks
> can be per device, instead or per port, and they can still say "this
> device's internal PHY ports need this", or "this device's SERDES ports
> need that". Does that make sense?

That makes sense. I'll be able to get that into v2. Hopefully I'm not
too far from getting the additional ports working, which is when I'll
finish the PCS logic.

> 
> >  static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port,
> >  					unsigned int link_an_mode,
> >  					phy_interface_t interface)
> >  {
> >  	struct ocelot *ocelot = ds->priv;
> > +	unsigned long quirks;
> > +	struct felix *felix;
> >  
> > +	felix = ocelot_to_felix(ocelot);
> > +	quirks = felix->info->get_quirks_for_port(ocelot, port);
> >  	ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface,
> > -				     FELIX_MAC_QUIRKS);
> > +				     quirks);
> >  }
> >  
> >  static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
> > @@ -842,11 +853,14 @@ static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port,
> >  				      bool tx_pause, bool rx_pause)
> >  {
> >  	struct ocelot *ocelot = ds->priv;
> > -	struct felix *felix = ocelot_to_felix(ocelot);
> > +	unsigned long quirks;
> > +	struct felix *felix;
> >  
> > +	felix = ocelot_to_felix(ocelot);
> > +	quirks = felix->info->get_quirks_for_port(ocelot, port);
> >  	ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode,
> >  				   interface, speed, duplex, tx_pause, rx_pause,
> > -				   FELIX_MAC_QUIRKS);
> > +				   quirks);
> >  
> >  	if (felix->info->port_sched_speed_set)
> >  		felix->info->port_sched_speed_set(ocelot, port, speed);
> > diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
> > index 515bddc012c0..251463f7e882 100644
> > --- a/drivers/net/dsa/ocelot/felix.h
> > +++ b/drivers/net/dsa/ocelot/felix.h
> > @@ -52,6 +52,7 @@ struct felix_info {
> >  					u32 speed);
> >  	struct regmap *(*init_regmap)(struct ocelot *ocelot,
> >  				      struct resource *res);
> > +	unsigned long (*get_quirks_for_port)(struct ocelot *ocelot, int port);
> >  };
> >  
> >  extern const struct dsa_switch_ops felix_switch_ops;
> > @@ -72,4 +73,7 @@ struct felix {
> >  struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port);
> >  int felix_netdev_to_port(struct net_device *dev);
> >  
> > +unsigned long felix_quirks_have_rate_adaptation(struct ocelot *ocelot,
> > +						int port);
> > +
> >  #endif
> > diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> > index 4ddec3325f61..7fc5cf28b7d9 100644
> > --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> > +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> > @@ -2166,6 +2166,7 @@ static const struct felix_info felix_info_vsc9959 = {
> >  	.port_setup_tc		= vsc9959_port_setup_tc,
> >  	.port_sched_speed_set	= vsc9959_sched_speed_set,
> >  	.init_regmap		= ocelot_regmap_init,
> > +	.get_quirks_for_port	= felix_quirks_have_rate_adaptation,
> >  };
> >  
> >  static irqreturn_t felix_irq_handler(int irq, void *data)
> > diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
> > index ce30464371e2..c996fc45dc5e 100644
> > --- a/drivers/net/dsa/ocelot/seville_vsc9953.c
> > +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
> > @@ -1188,6 +1188,7 @@ static const struct felix_info seville_info_vsc9953 = {
> >  	.phylink_validate	= vsc9953_phylink_validate,
> >  	.prevalidate_phy_mode	= vsc9953_prevalidate_phy_mode,
> >  	.init_regmap		= ocelot_regmap_init,
> > +	.get_quirks_for_port	= felix_quirks_have_rate_adaptation,
> >  };
> >  
> >  static int seville_probe(struct platform_device *pdev)
> > -- 
> > 2.25.1
> >

  reply	other threads:[~2021-11-22 16:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 22:43 [PATCH v1 net-next 0/6] prepare ocelot for external interface control Colin Foster
2021-11-19 22:43 ` [PATCH v1 net-next 1/6] net: dsa: ocelot: remove unnecessary pci_bar variables Colin Foster
2021-11-19 22:43 ` [PATCH v1 net-next 2/6] net: dsa: ocelot: felix: Remove requirement for PCS in felix devices Colin Foster
2021-11-19 22:43 ` [PATCH v1 net-next 3/6] net: dsa: ocelot: felix: add interface for custom regmaps Colin Foster
2021-11-21 17:19   ` Vladimir Oltean
2021-11-22 16:45     ` Colin Foster
2021-12-04  0:11       ` Colin Foster
2021-12-04 12:07         ` Vladimir Oltean
2021-11-19 22:43 ` [PATCH v1 net-next 4/6] net: dsa: ocelot: felix: add per-device-per-port quirks Colin Foster
2021-11-21 17:13   ` Vladimir Oltean
2021-11-22 16:20     ` Colin Foster [this message]
2021-11-19 22:43 ` [PATCH v1 net-next 5/6] net: mscc: ocelot: split register definitions to a separate file Colin Foster
2021-11-20  1:16   ` kernel test robot
2021-11-20  3:23   ` kernel test robot
2021-11-21 17:09   ` Vladimir Oltean
2021-11-22 16:14     ` Colin Foster
2021-11-19 22:43 ` [PATCH v1 net-next 6/6] net: mscc: ocelot: expose ocelot wm functions Colin Foster
2021-11-21 17:07   ` Vladimir Oltean

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=20211122162012.GB29931@DESKTOP-LAINLKC.localdomain \
    --to=colin.foster@in-advantage.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).