All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: Vladimir Oltean <olteanv@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	UNGLinuxDriver@microchip.com,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Colin Foster <colin.foster@in-advantage.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: dsa: felix: provide own phylink MAC operations
Date: Mon, 15 Apr 2024 17:49:01 +0100	[thread overview]
Message-ID: <Zh1afZNFnl0DObX0@shell.armlinux.org.uk> (raw)
In-Reply-To: <20240415160150.yejcazpjqvn7vhxu@skbuf>

On Mon, Apr 15, 2024 at 07:01:50PM +0300, Vladimir Oltean wrote:
> On Mon, Apr 15, 2024 at 04:24:45PM +0100, Russell King (Oracle) wrote:
> > Looking at these three, isn't there good reason to merge the allocation
> > and initialisation of struct dsa_switch together in all three drivers?
> > All three are basically doing the same thing:
> > 
> > felix_vsc9959.c:
> >         ds->dev = &pdev->dev;
> >         ds->num_ports = felix->info->num_ports;
> >         ds->num_tx_queues = felix->info->num_tx_queues;
> >         ds->ops = &felix_switch_ops;
> >         ds->priv = ocelot;
> >         felix->ds = ds;
> > 
> > ocelot_ext.c:
> >         ds->dev = dev;
> >         ds->num_ports = felix->info->num_ports;
> >         ds->num_tx_queues = felix->info->num_tx_queues;
> >         ds->ops = &felix_switch_ops;
> >         ds->priv = ocelot;
> >         felix->ds = ds;
> > 
> > seville_vsc9953.c:
> >         ds->dev = &pdev->dev;
> >         ds->num_ports = felix->info->num_ports;
> >         ds->ops = &felix_switch_ops;
> >         ds->priv = ocelot;
> >         felix->ds = ds;
> 
> Yes, there is :)
> 
> If dev_set_drvdata() were to be used instead of platform_set_drvdata()/
> pci_set_drvdata(), there's room for even more common code.
> 
> > Also, I note that felix->info->num_tx_queues on seville_vsc9953.c
> > is set to OCELOT_NUM_TC, which is defined to be 8, and is the same
> > value for ocelot_ext and felix_vsc9959. Presumably this unintentionally
> > missing from seville_vsc9953.c... because why initialise a private
> > struct member to a non-zero value and then not use it.
> > 
> > An alternative would be to initialise .num_tx_queues in seville_vsc9953.c
> > to zero.
> 
> It makes me wonder why felix->info->num_tx_queues even exists...
> 
> It was introduced by commit de143c0e274b ("net: dsa: felix: Configure
> Time-Aware Scheduler via taprio offload") at a time when vsc9959
> (LS1028A) was the only switch supported by the driver. It seems
> unnecessary.
> 
> 8 traffic classes, and 1 queue per traffic class, is a common
> architectural feature of all switches in the family. So they could all
> just set OCELOT_NUM_TC in the common allocation function and be fine
> (and remove felix->info->num_tx_queues).
> 
> When num_tx_queues=0, this is implicitly converted to 1 by dsa_user_create(),
> and this is good enough for basic operation for a switch port. The tc
> qdisc offload layer works with netdev TX queues, so for QoS offload we
> need to pretend we have multiple TX queues. The VSC9953, like ocelot_ext,
> doesn't export QoS offload, so it doesn't really matter. But we can
> definitely set num_tx_queues=8 for all switches.
> 
> > If we had common code doing this initialisation, then it wouldn't be
> > missed... and neither would have _this_ addition of the phylink MAC
> > ops missed the other two drivers - so I think that's something which
> > should be done as a matter of course - and thus there will be no need
> > to export these two data structures, just an initialisation (and
> > destruction) function. I don't think we would even need the destruction
> > function if we used devm_kzalloc().
> > 
> > Good idea?
> 
> Looking again at the driver, I see it's not very consistent in its use of
> devres... It is used elsewhere, including in felix_pci_probe() itself:
> devm_request_threaded_irq().
> 
> Yes, I think the use of devres here would be an improvement.
> 
> Note that felix_pci_probe() will still have to call pci_disable_device()
> on the error teardown path.
> 
> For even more consistency, it would be great if the error teardown
> labels were called after what they do, rather than after the path that
> triggered them. Example:
> - goto err_pci_enable -> goto out
> - goto err_alloc_felix -> goto out_pci_disable

Sounds like there's an opportunity to beneficially clean this driver
up before I make this change, so I'll hold off this patch until that's
happened. I probably don't have the spare cycles for that.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2024-04-15 16:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12 15:15 [PATCH net-next] net: dsa: felix: provide own phylink MAC operations Russell King (Oracle)
2024-04-15 10:34 ` Vladimir Oltean
2024-04-15 15:24   ` Russell King (Oracle)
2024-04-15 16:01     ` Vladimir Oltean
2024-04-15 16:49       ` Russell King (Oracle) [this message]
2024-04-15 20:13         ` Vladimir Oltean
2024-04-15 21:12           ` Russell King (Oracle)
2024-04-15 13:29 ` Colin Foster
  -- strict thread matches above, loose matches on Subject: below --
2024-05-28 15:15 Russell King (Oracle)
2024-05-29 14:30 ` Vladimir Oltean
2024-05-30  2:00 ` patchwork-bot+netdevbpf

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=Zh1afZNFnl0DObX0@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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 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.