From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Nicolai Buchwitz" <nb@tipi-net.de>
Cc: "Conor Dooley" <conor.dooley@microchip.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Paolo Valerio" <pvalerio@redhat.com>,
"Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Benoît Monin" <benoit.monin@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH net-next v5 2/3] net: macb: implement ethtool_ops.get|set_channels()
Date: Fri, 13 Nov 2026 18:38:41 +0100 [thread overview]
Message-ID: <DMU9LNJOVW85.UJLCC6X6EON3@bootlin.com> (raw)
In-Reply-To: <45fae7a00024b7d07cd3250d4f2b5b48@tipi-net.de>
On Mon Oct 19, 2026 at 2:52 PM CEST, Nicolai Buchwitz wrote:
> On 16.10.2026 18:58, Théo Lebrun wrote:
>> bp->num_queues is the total number of queues and is constant from
>> probe.
>> Introduce bp->max_num_queues which takes the current role of
>> bp->num_queues and allow `0 < bp->num_queues <= bp->max_num_queues`.
>> MACB/GEM does not know about Rx/Tx specific queues; it only has
>> combined queues.
>>
>> set_channels is reserved to devices with MACB_CAPS_QUEUE_DISABLE.
>> The tieoff workaround would not work as packets would still be routed
>> into queues with a tieoff descriptor.
>>
>> Implement .set_channels() operation by refusing if netif_running(). We
>> need context-swapping support upstream for proper on-the-fly channel
>> count change.
>>
>> Note we refuse the operation if any TAPRIO rules are in place on queues
>> that would get disabled. If we allow the operation to take place, then
>> a transmission window would be reserved but unusable.
>>
>> Nit: fix an alignment issue inside gem_ethtool_ops which does not
>> deserve its own patch.
>>
>> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
>> ---
>
>> [...]
>
>> --- a/drivers/net/ethernet/cadence/macb_main.c
>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>
>> [...]
>
>> +static int macb_set_channels(struct net_device *netdev,
>> + struct ethtool_channels *ch)
>> +{
>> + struct macb *bp = netdev_priv(netdev);
>> + unsigned int count = ch->combined_count;
>> + int ret;
>> +
>> + /* MACB_CAPS_QUEUE_DISABLE means that the field QUEUE_DISABLE/BIT0 in
>> + * the per-queue RBQP/TBQP registers disable Tx/Rx queues. If we
>> don't
>> + * have that capability we can have multiple queues but we must
>> always
>> + * run with all enabled.
>> + */
>> + if (!(bp->caps & MACB_CAPS_QUEUE_DISABLE))
>> + return -EOPNOTSUPP;
>> +
>> + /* TODO: reuse context swapping once it is merged. */
>
> Once context swapping is merged, this needs to be addressed in v6 ;-)
Done! The patch changed a lot, for the better. num_queues is now part of
the context, as any context "parameter" should be. It had no place in
the global interface struct.
This highlights a few callbacks that are reading num_queues while
interface might be down. I've not attempted to fix those yet. :-)
https://lore.kernel.org/netdev/20261113-macb-set-channels-v6-0-5de59d9e7f02@bootlin.com/
>
>> + if (netif_running(bp->netdev))
>> + return -EBUSY;
>> +
>> + /* If we allow disable a queue which has TAPRIO active, we'll keep a
>> + * transmission window which will be unusable.
>> + */
>> + if (bp->taprio_gated_queues >> count) {
>> + netdev_err(bp->netdev, "TAPRIO schedule gates queues >= %u; destroy
>> the qdisc before reducing channels\n",
>> + count);
>> + return -EBUSY;
>> + }
>
> I think this can get stuck:
>
> - delete the taprio qdisc after the link has been down for a while
> - device is is runtime suspend
> - taprio setup bails out before _destroy() is called
> - ethtool -L keeps failing with -EBUSY, even though there is no qdisc
> anymore
>
> Something like:
>
> ip link set eth0 up
> tc qdisc replace dev eth0 root taprio ... flags 0x2
> ip link set eth0 down
> sleep 1
> tc qdisc del dev eth0 root
> ethtool -L eth0 combined 1
Good catch. I was able to reproduce this. Fixed by running
// macb_taprio_destroy()
netdev_reset_tc(netdev);
bp->taprio_gated_queues = 0;
Even if the interface is down.
We skip over the hardware reconfig however.
Thanks for the review,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-11-13 17:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 16:58 [PATCH net-next v5 0/3] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-10-16 16:58 ` [PATCH net-next v5 1/3] net: macb: add QUEUE_DISABLE capability to 3 compatibles Théo Lebrun
2026-10-19 11:32 ` Nicolai Buchwitz
2026-11-13 17:34 ` Théo Lebrun
2026-10-16 16:58 ` [PATCH net-next v5 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-10-19 12:52 ` Nicolai Buchwitz
2026-11-13 17:38 ` Théo Lebrun [this message]
2026-10-16 16:58 ` [PATCH net-next v5 3/3] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-10-19 12:58 ` Nicolai Buchwitz
2026-11-13 18:01 ` Théo Lebrun
2026-10-21 3:08 ` Jakub Kicinski
2026-11-13 18:02 ` Théo Lebrun
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=DMU9LNJOVW85.UJLCC6X6EON3@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=benoit.monin@bootlin.com \
--cc=conor.dooley@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pvalerio@redhat.com \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.kondratiev@mobileye.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
all inboxes | Powered by JetHome®