From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: 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>,
Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Nicolai Buchwitz" <nb@tipi-net.de>,
"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>,
"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH net-next v7 0/3] net: macb: implement ethtool set channels count operation
Date: Wed, 18 Nov 2026 21:53:22 +0100 [thread overview]
Message-ID: <20261118-macb-set-channels-v7-0-2dbc00f686af@bootlin.com> (raw)
Add support for changing the active number of queues.
Tested on Mobileye EyeQ5.
If the interface is running, use context swapping to realloc rings on
the fly. To avoid introducing bugs with stale ENST config, we start by
fixing how ENST config gets applied in the first patch.
One pretty significant change to our context swapping implementation:
the set_channels callback needs to be able to fail in the context
swapping window. If it failed, then we keep using the old context and
don't reconfigure HW. From its standpoint, it got disabled then
re-enabled with no change to its rings.
I tried *not fixing* TAPRIO/ENST but that was hard, so instead I preface
this series with a commit reworking how ENST works. We now handle
close/open and refuse set_channels if a queue-to-be-disabled had an
ENST schedule attached.
Have a nice day,
Thanks,
Théo
---
Changes in v7:
- Patch 1 (new ENST patch):
- Preface the series by a patch fixing TAPRIO ENST config across
interface flap and context swap operations.
- It does so by storing a cached ENST config in bp and restoring it
on context swap and link-up. Previously we could only write the
ENST registers on TAPRIO callbacks.
- Patch 2 (ethtool set_channels implementation):
- Fix context swap rollback: if the window failed (set_channels is the
first context swap that can fail), then we need to *not* write HW
ring cursors and *not* reset DQL.
- macb_interrupt(): avoid NULL ptr deref when reading bp->ctx fields.
- macb_poll_controller(): avoid bp->ctx NULL ptr deref by using
bp->configured_num_queues rather than bp->ctx->num_queues.
- gem_get_rx_ring_count(): use bp->configured_num_queues rather than
bp->max_num_queues.
- at91ether_open(): assign `bp->ctx->num_queues = 1` to avoid breaking
shared code that iterates on queues (suspend PM ops mostly).
- Patch 3 (Tx SRAM segment distribution):
- DCFG6 register has 4 bits to tell us the # of segments, not 3.
- The config of the # of segments per queue is 3 bits (not 2): fix
distribution algorithm to allow going up to the limit. I don't
know of any hardware on which this could have an incidence.
- SRAM segment distribution is also done at context swap end, for
this new set_channels callback.
- Rebase onto latest net-next/main (d6816d9a93b6); tiny conflict inside
macb_config caps.
- Link to v6: https://patch.msgid.link/20261113-macb-set-channels-v6-0-5de59d9e7f02@bootlin.com
Changes in v6:
- Rebase onto latest net-next/main (573af8015529). This means rebasing
onto context swapping, which is now used on set_channels requests.
- Move the QUEUE_DISABLE caps patch out into a separate series.
https://lore.kernel.org/netdev/20261113-macb-caps-v1-0-42e0984b2f09@bootlin.com/
- Drop kunit tests. Thanks Jakub.
- Fix the TAPRIO gate test if qdisc is destroyed while the interface is
down (because bp->taprio_gated_queues was stall in that case).
Thanks Nicolai.
- Link to v5: https://patch.msgid.link/20261016-macb-set-channels-v5-0-90ce0c0b8e75@bootlin.com
Changes in v5:
- New patch: add missing MACB_CAPS_QUEUE_DISABLE to 3 compatibles based
on publicly available datasheets. That means they can benefit from
the set_channels implementation.
- set_channels patch:
- Refuse set_channels if it disables a queue with active TAPRIO.
- Use TBQP.QUEUE_DISABLE bit to also disable transmit; previously we
only disabled the receive engine.
- Migrate code to newly introduced macb_queue_isr_clear() helper.
- Adapt to newly introduced macb_quiesce_start(), where we want to
synchronize_irq() on all queues, even the disabled ones.
- IRQ handler now self-disarms on disabled queues.
- Drop `old_count` unused stack variable.
- Only allow TAPRIO rules on active queues.
- Fix comments style and text in macb_set_channels(); in particular
mention we'll use context-swapping once it is available.
- Distribute SRAM segments patch:
- Introduce GEM_TXQSEGALLOC_MASK(q) and use field_prep|get() macros.
- Introduce capability for this feature, as many publicly available
GEM datasheets don't document the registers.
- Remove upper register support. Lower register is enough to handle 8
queues, which is the max we support.
- Add edge case kunit for num_segments=128.
- Introduce static_assert(MACB_MAX_QUEUES == 8) in
gem_sram_distribute_segments() to signal that code will need
updating if/when the constant changes.
- Update To/Cc list: drop Nicolas and Claudiu, add Conor and Nicolai.
- Rebase onto latest net-next/main (6b3e73774815).
- Link to v4: https://patch.msgid.link/20260317-macb-set-channels-v4-0-1bd4f4ffcfca@bootlin.com
Changes in v4:
- macb_set_channels(): drop `count == old_count` check, it is redundant
with both netlink and ioctl codepaths. See early returns in
ethnl_set_channels() and ethtool_set_channels(). Discussion @ V2.
- Rebase to latest net-next (8737d7194d6d); nothing to report.
- Link to v3: https://patch.msgid.link/20260313-macb-set-channels-v3-0-c66b7781ddb8@bootlin.com
Changes in v3:
- Makefile: fix compilation of kunit tests. This bug was hidden before
because everything was builtin so it ended up linked together anyway.
Now macb.o is the amalgation of macb_{main,ptp,utils}.o and
macb_test.o is the amalgation of macb_{kunit,utils}.o.
- Kconfig CONFIG_MACB_KUNIT_TEST entry:
- Turn into tristate; no good reason to restrict to bool.
- Drop "depends on MACB". We do not need to compile the full MACB
driver to test gem_sram_distribute_segments().
- Add usual MODULE_*() macros to macb_kunit.c.
- Drop unused init value of `ret` in macb_set_channels().
- Rebase to latest net-next; nothing to report.
- Link to v2: https://patch.msgid.link/20260311-macb-set-channels-v2-0-982693a1f5fc@bootlin.com
Changes in v2:
- Move gem_sram_distribute_segments() from macb_main.c to macb_utils.c
and kunit tests from macb_main.c to macb_kunit.c.
- macb_set_channels():
- Add comment about MACB_CAPS_QUEUE_DISABLE.
- Refuse operation if netif_running(), with code comment.
- Drop useless sanity checks on ch->{combined,rx,tx}_count.
- Add help text to CONFIG_MACB_KUNIT_TEST.
- Fix `checkpatch --max-line-length=80` warnings.
- Rebase onto latest net-next; nothing to report.
- Link to v1: https://lore.kernel.org/r/20260305-macb-set-channels-v1-0-28e3a96a3dc3@bootlin.com
To: Conor Dooley <conor.dooley@microchip.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: David S. Miller <davem@davemloft.net>
To: Eric Dumazet <edumazet@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Nicolai Buchwitz <nb@tipi-net.de>
Cc: Paolo Valerio <pvalerio@redhat.com>
Cc: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Benoît Monin <benoit.monin@bootlin.com>
Cc: Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
Théo Lebrun (3):
net: macb: cache ENST config across link down/up
net: macb: implement ethtool_ops.get|set_channels()
net: macb: distribute evenly Tx SRAM segments
drivers/net/ethernet/cadence/macb.h | 66 +++-
drivers/net/ethernet/cadence/macb_main.c | 512 +++++++++++++++++++++----------
2 files changed, 397 insertions(+), 181 deletions(-)
---
base-commit: d6816d9a93b66a12bf01e10037e377f3333ad6cc
change-id: 20260305-macb-set-channels-5bf6e07f3270
Best regards,
--
Théo Lebrun <theo.lebrun@bootlin.com>
next reply other threads:[~2026-11-18 20:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 20:53 Théo Lebrun [this message]
2026-11-18 20:53 ` [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 3/3] net: macb: distribute evenly Tx SRAM segments 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=20261118-macb-set-channels-v7-0-2dbc00f686af@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=linux@armlinux.org.uk \
--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®