* [PATCH net-next] net: ag71xx: align the IP header behind DSA tags
@ 2026-10-07 17:44 Rosen Penev
2026-10-07 18:27 ` Andrew Lunn
2026-10-09 16:47 ` Simon Horman
0 siblings, 2 replies; 5+ messages in thread
From: Rosen Penev @ 2026-10-07 17:44 UTC (permalink / raw)
To: netdev
Cc: Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
The receive buffer offset includes NET_IP_ALIGN to get the IP header
aligned behind a 14 byte Ethernet header. Most ag71xx devices use DSA
switches whose tag sits in front of the EtherType, which moves the IP
header by another 2 bytes. Every access to the IP and TCP headers then
traps and gets emulated by the unaligned access handler, around 6 times
per forwarded frame.
Take the headroom needed by the DSA tagger into account when choosing
the offset.
TP-Link Archer C7 v2 (qca8k), median of 3 runs, Mbit/s:
before after
routed up 743 855
routed down 660 749
local receive 554 572
The unaligned instruction counter no longer moves while forwarding.
Assisted-by: LLM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/atheros/ag71xx.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 8a3c689f6825..414d26118d15 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -38,6 +38,7 @@
#include <linux/reset.h>
#include <linux/clk.h>
#include <linux/io.h>
+#include <net/dsa.h>
#include <net/selftests.h>
#define AG71XX_OOM_REFILL (1 + HZ / 10)
@@ -1396,6 +1397,24 @@ static void ag71xx_hw_disable(struct ag71xx *ag)
ag71xx_rings_cleanup(ag);
}
+static unsigned int ag71xx_rx_offset(struct ag71xx *ag)
+{
+ unsigned int align = NET_IP_ALIGN;
+
+ if (ag71xx_is(ag, AR7100) || ag71xx_is(ag, AR9130))
+ return NET_SKB_PAD;
+
+#if IS_ENABLED(CONFIG_NET_DSA)
+ /* A tag inserted in front of the EtherType shifts the IP header,
+ * compensate for it to avoid unaligned accesses in the stack.
+ */
+ if (netdev_uses_dsa(ag->ndev))
+ align = (align - ag->ndev->dsa_ptr->tag_ops->needed_headroom) & 3;
+#endif
+
+ return NET_SKB_PAD + align;
+}
+
static int ag71xx_open(struct net_device *ndev)
{
struct ag71xx *ag = netdev_priv(ndev);
@@ -1410,6 +1429,7 @@ static int ag71xx_open(struct net_device *ndev)
}
max_frame_len = ag71xx_max_frame_len(ndev->mtu);
+ ag->rx_buf_offset = ag71xx_rx_offset(ag);
ag->rx_buf_size =
SKB_DATA_ALIGN(max_frame_len + NET_SKB_PAD + NET_IP_ALIGN);
@@ -1874,10 +1894,6 @@ static int ag71xx_probe(struct platform_device *pdev)
ndev->min_mtu = 68;
ndev->max_mtu = dcfg->max_frame_len - ag71xx_max_frame_len(0);
- ag->rx_buf_offset = NET_SKB_PAD;
- if (!ag71xx_is(ag, AR7100) && !ag71xx_is(ag, AR9130))
- ag->rx_buf_offset += NET_IP_ALIGN;
-
if (ag71xx_is(ag, AR7100)) {
ag->tx_ring.desc_split = AG71XX_TX_RING_SPLIT;
tx_size *= AG71XX_TX_RING_DS_PER_PKT;
--
2.56.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next] net: ag71xx: align the IP header behind DSA tags
2026-10-07 17:44 [PATCH net-next] net: ag71xx: align the IP header behind DSA tags Rosen Penev
@ 2026-10-07 18:27 ` Andrew Lunn
2026-10-09 16:47 ` Simon Horman
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2026-10-07 18:27 UTC (permalink / raw)
To: Rosen Penev
Cc: netdev, Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
On Wed, Oct 07, 2026 at 10:44:49AM -0700, Rosen Penev wrote:
> The receive buffer offset includes NET_IP_ALIGN to get the IP header
> aligned behind a 14 byte Ethernet header. Most ag71xx devices use DSA
> switches whose tag sits in front of the EtherType, which moves the IP
> header by another 2 bytes. Every access to the IP and TCP headers then
> traps and gets emulated by the unaligned access handler, around 6 times
> per forwarded frame.
>
> Take the headroom needed by the DSA tagger into account when choosing
> the offset.
>
> TP-Link Archer C7 v2 (qca8k), median of 3 runs, Mbit/s:
>
> before after
> routed up 743 855
> routed down 660 749
> local receive 554 572
>
> The unaligned instruction counter no longer moves while forwarding.
>
> Assisted-by: LLM
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net-next] net: ag71xx: align the IP header behind DSA tags
2026-10-07 17:44 [PATCH net-next] net: ag71xx: align the IP header behind DSA tags Rosen Penev
2026-10-07 18:27 ` Andrew Lunn
@ 2026-10-09 16:47 ` Simon Horman
2026-10-09 22:27 ` Rosen Penev
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2026-10-09 16:47 UTC (permalink / raw)
To: Rosen Penev
Cc: netdev, Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
On Wed, Oct 07, 2026 at 10:44:49AM -0700, Rosen Penev wrote:
> The receive buffer offset includes NET_IP_ALIGN to get the IP header
> aligned behind a 14 byte Ethernet header. Most ag71xx devices use DSA
> switches whose tag sits in front of the EtherType, which moves the IP
> header by another 2 bytes. Every access to the IP and TCP headers then
> traps and gets emulated by the unaligned access handler, around 6 times
> per forwarded frame.
>
> Take the headroom needed by the DSA tagger into account when choosing
> the offset.
>
> TP-Link Archer C7 v2 (qca8k), median of 3 runs, Mbit/s:
>
> before after
> routed up 743 855
> routed down 660 749
> local receive 554 572
>
> The unaligned instruction counter no longer moves while forwarding.
>
> Assisted-by: LLM
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Unfortunately this patch did not apply cleanly to net-next at the time it
was posted, so our CI did not run.
Please rebase and repost.
--
pw-bot: changes-requested
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ag71xx: align the IP header behind DSA tags
2026-10-09 16:47 ` Simon Horman
@ 2026-10-09 22:27 ` Rosen Penev
2026-10-09 22:33 ` Rosen Penev
0 siblings, 1 reply; 5+ messages in thread
From: Rosen Penev @ 2026-10-09 22:27 UTC (permalink / raw)
To: Simon Horman
Cc: netdev, Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
On Fri, Oct 9, 2026 at 9:47 AM Simon Horman <horms@kernel.org> wrote:
>
> On Wed, Oct 07, 2026 at 10:44:49AM -0700, Rosen Penev wrote:
> > The receive buffer offset includes NET_IP_ALIGN to get the IP header
> > aligned behind a 14 byte Ethernet header. Most ag71xx devices use DSA
> > switches whose tag sits in front of the EtherType, which moves the IP
> > header by another 2 bytes. Every access to the IP and TCP headers then
> > traps and gets emulated by the unaligned access handler, around 6 times
> > per forwarded frame.
> >
> > Take the headroom needed by the DSA tagger into account when choosing
> > the offset.
> >
> > TP-Link Archer C7 v2 (qca8k), median of 3 runs, Mbit/s:
> >
> > before after
> > routed up 743 855
> > routed down 660 749
> > local receive 554 572
> >
> > The unaligned instruction counter no longer moves while forwarding.
> >
> > Assisted-by: LLM
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
>
> Unfortunately this patch did not apply cleanly to net-next at the time it
> was posted, so our CI did not run.
It appears I was careless and sent it ahead of local commits. Will resend.
>
> Please rebase and repost.
>
> --
> pw-bot: changes-requested
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: ag71xx: align the IP header behind DSA tags
2026-10-09 22:27 ` Rosen Penev
@ 2026-10-09 22:33 ` Rosen Penev
0 siblings, 0 replies; 5+ messages in thread
From: Rosen Penev @ 2026-10-09 22:33 UTC (permalink / raw)
To: Simon Horman
Cc: netdev, Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, open list
On Fri, Oct 9, 2026 at 3:27 PM Rosen Penev <rosenp@gmail.com> wrote:
>
> On Fri, Oct 9, 2026 at 9:47 AM Simon Horman <horms@kernel.org> wrote:
> >
> > On Wed, Oct 07, 2026 at 10:44:49AM -0700, Rosen Penev wrote:
> > > The receive buffer offset includes NET_IP_ALIGN to get the IP header
> > > aligned behind a 14 byte Ethernet header. Most ag71xx devices use DSA
> > > switches whose tag sits in front of the EtherType, which moves the IP
> > > header by another 2 bytes. Every access to the IP and TCP headers then
> > > traps and gets emulated by the unaligned access handler, around 6 times
> > > per forwarded frame.
> > >
> > > Take the headroom needed by the DSA tagger into account when choosing
> > > the offset.
> > >
> > > TP-Link Archer C7 v2 (qca8k), median of 3 runs, Mbit/s:
> > >
> > > before after
> > > routed up 743 855
> > > routed down 660 749
> > > local receive 554 572
> > >
> > > The unaligned instruction counter no longer moves while forwarding.
> > >
> > > Assisted-by: LLM
> > > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> >
> > Unfortunately this patch did not apply cleanly to net-next at the time it
> > was posted, so our CI did not run.
> It appears I was careless and sent it ahead of local commits. Will resend.
I see the issue
A different patch removes the comment:
For our NAPI weight bigger does *NOT* mean better - it means more
so git am fails but git apply works.
> >
> > Please rebase and repost.
> >
> > --
> > pw-bot: changes-requested
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-09 22:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 17:44 [PATCH net-next] net: ag71xx: align the IP header behind DSA tags Rosen Penev
2026-10-07 18:27 ` Andrew Lunn
2026-10-09 16:47 ` Simon Horman
2026-10-09 22:27 ` Rosen Penev
2026-10-09 22:33 ` Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox