net: mana: add BQL support
Subsystems (6)
PATCH v3 1/1 net: mana: add BQL support
MANA doesn't support byte queue limits, so each TX queue can hold 256 WQEs by default, and up to 16384, of up to 64 KB TSO packets, before the qdisc layer sees any backpressure. This adds latency to all the flows sharing a queue, and defeats AQM qdiscs such as fq_codel, which rely on BQL to keep the driver queues short.
Report the bytes queued and completed to BQL, except for the XDP_TX and XDP_REDIRECT frames. These share the SQs, but bypass the qdisc and are sent even when the queue is stopped, so BQL can't hold them back. Counting them would let sustained XDP traffic keep the queue stopped, starving the stack, and the TX watchdog would then either fire while the completions still arrive, or, if the XDP sends refreshed trans_start, not fire when the completions stop. The XDP SKBs are marked in their skb->cb, next to the WQE size, so that their completions are skipped as well.
Reset the BQL state when destroying the queues, once their NAPI is disabled, since the SKBs still pending after a drain timeout are freed without being completed.
Lost TX completions can now stop a queue sooner: it also stops when the bytes in flight exceed the BQL limit, not only when the SQ is full, and the limit may never grow enough to cover the lost bytes. This includes the completions skipped by the WARN_ON_ONCE() early returns in mana_poll_tx_cq(), which already leak SQ space: completing the SKBs already freed there wouldn't reliably balance BQL, since mana_gd_poll_cq() has already consumed the CQEs of the rest of the batch. The TX watchdog then fires, as nothing refreshes the trans_start of a queue stopped by BQL, and its handler resets the queues along with their BQL state. The exception, as before this patch, is XDP traffic keeping the SQ full: each XDP send then stops the queue again, refreshing its trans_start.
Tested on two Standard_D16ds_v6 Azure VMs in a proximity placement group, where the throughput is capped at 10.6 Gbps, with the DUT alternately booting net-next (c1c1f0a31712) with and without this patch applied.
The throughput stays at the cap with 1, 8 and 64 TCP flows, and the idle TCP_RR latency doesn't change (p50 of 47 us with vs. without the patch). With 16 senders of 64-byte UDP packets, the DUT sends 3.7 to 4.0 Mpps without the patch and 3.7 to 4.1 Mpps with it. With bulk TCP flows sharing the queues, the netperf TCP_RR latency drops (medians of 6 runs):
16 queues, 64 flows: p50 4649 -> 2182 us, p99 5621 -> 2677 us
1 queue, 8 flows: p50 2554 -> 418 us, p99 2723 -> 624 us
The standing queue moves from the SQs to fq_codel, which now drops
packets: about 2500 qdisc drops and 88K TCP retransmissions per 48 s run with 64 flows, against at most 29 retransmissions before. The retransmissions are about 0.2% of the segments sent. The TCP_RR flows lose no packets, and the packets of the bulk flows are dropped before they reach the wire, so the goodput changes by less than 0.01%.
---
v2: Only count the bytes of the packets sent on a stopped queue, so that
XDP traffic doesn't keep the TX watchdog from firing on a queue stopped by BQL. (Sashiko)
v3: Leave the XDP frames out of BQL, rather than only counting the bytes
of the packets sent on a stopped queue, which let sustained XDP traffic keep a queue stopped and trip the TX watchdog with a large SQ, and let a stack packet past the BQL limit when the SQ filled. Note in the commit message that, as before this patch, XDP traffic keeping the SQ full holds the watchdog off, and why the early returns in mana_poll_tx_cq() are left alone. (Sashiko)
--- .../net/ethernet/microsoft/mana/mana_bpf.c | 2 +- drivers/net/ethernet/microsoft/mana/mana_en.c | 52 ++++++++++++++++--- include/net/mana/mana.h | 2 + 3 files changed, 48 insertions(+), 8 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_bpf.c +1 -1
@@ -21,7 +21,7 @@ void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev) ndevtxq =netdev_get_tx_queue (ndev, txq_idx);__netif_tx_lock (ndevtxq,smp_processor_id ()); - rc =mana_start_xmit (skb, ndev); + rc =__mana_start_xmit (skb, ndev, true);__netif_tx_unlock (ndevtxq);
drivers/net/ethernet/microsoft/mana/mana_en.c +45 -7
127 lines not on this page · raw message
include/net/mana/mana.h +2 -0
@@ -672,6 +672,8 @@ struct mana_port_context {u32 steer_cqe_coalescing; }; +netdev_tx_t __mana_start_xmit (struct sk_buff *skb,struct net_device *ndev, +bool xdp);netdev_tx_t mana_start_xmit (struct sk_buff *skb,struct net_device *ndev);int mana_config_rss (struct mana_port_context *ac,enum TRI_STATE rx,bool update_hash,bool update_tab);
Signature · 1 line
2.56.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] mana: unratelimited netdev_warn in __mana_start_xmit causes log spam under XDP load --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mana: unratelimited netdev_warn in __mana_start_xmit causes log spam under XDP load --
commit a6a9466a25f553494605c439f140071b9b0b7068
Author: Hamza Mahfooz <[email protected]>
net: mana: add BQL support
MANA doesn't support byte queue limits, so each TX queue can hold 256 WQEs by default, and up to 16384, of up to 64 KB TSO packets, before the qdisc layer sees any backpressure. This adds latency to all the flows sharing a queue, and defeats AQM qdiscs such as fq_codel. This patch adds BQL support by reporting the bytes queued and completed to BQL, except for XDP_TX and XDP_REDIRECT frames.
drivers/net/ethernet/microsoft/mana/mana_bpf.c void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev) · line 24
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +1
-1@@ -21,7 +21,7 @@ void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev) ndevtxq =netdev_get_tx_queue (ndev, txq_idx);__netif_tx_lock (ndevtxq,smp_processor_id ()); - rc =mana_start_xmit (skb, ndev); + rc =__mana_start_xmit (skb, ndev, true);
[Severity: High]
Does this allow unratelimited log spam under heavy XDP load?
XDP traffic directly calls the transmit path here without checking or honoring the stopped queue state. If the Send Queue fills up, __mana_start_xmit() unconditionally calls mana_gd_post_work_request(), which can return -ENOSPC.
When it fails, __mana_start_xmit() prints an unratelimited warning:
if (err) {
(void)skb_dequeue_tail(&txq->pending_skbs);
mana_unmap_skb(skb, apc);
netdev_warn(ndev, "Failed to post TX OOB: %d\n", err);
goto free_sgl_ptr;
}If XDP blasts packets into a full queue, could this print for every dropped packet and cause severe log spew?
Quoted 1 line
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0
-0__netif_tx_unlock (ndevtxq);
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 44 lines · On Wed, Oct 14, 2026 at 09:49:54PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mana: unratelimitednetdev_warnin__mana_start_xmitcauses log spam under XDP load --commit
a6a9466a25f553494605c439f140071b9b0b7068
Author: Hamza Mahfooz <[email protected]>net: mana: add BQL support
MANA doesn't support byte queue limits, so each TX queue can hold 256 WQEs by default, and up to 16384, of up to 64 KB TSO packets, before the qdisc layer sees any backpressure. This adds latency to all the flows sharing a queue, and defeats AQM qdiscs such as
fq_codel. This patch adds BQL support by reporting the bytes queued and completed to BQL, except forXDP_TXandXDP_REDIRECTframes.drivers/net/ethernet/microsoft/mana/mana_bpf.c void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev) · line 24
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_bpf.c +1
-1@@ -21,7 +21,7 @@ void mana_xdp_tx(struct sk_buff *skb, struct net_device *ndev) ndevtxq =netdev_get_tx_queue (ndev, txq_idx);__netif_tx_lock (ndevtxq,smp_processor_id ()); - rc =mana_start_xmit (skb, ndev); + rc =__mana_start_xmit (skb, ndev, true);[Severity: High]
Does this allow unratelimited log spam under heavy XDP load?XDP traffic directly calls the transmit path here without checking or honoring the stopped queue state. If the Send Queue fills up,
__mana_start_xmit()unconditionally callsmana_gd_post_work_request(), which can return-ENOSPC.When it fails,
__mana_start_xmit()prints an unratelimited warning:if (err) { (void)skb_dequeue_tail(&txq->pending_skbs); mana_unmap_skb(skb, apc); netdev_warn(ndev, "Failed to post TX OOB: %d\n", err); goto free_sgl_ptr; }
Quoted 3 lines
If XDP blasts packets into a full queue, could this print for every dropped packet and cause severe log spew?
This issue predates this patch (it was actually introduced when XDP support was first added with commit ed5356b53f07 ("net: mana: Add XDP support")), so it should be fixed as a seperate patch directed at the net tree.
Quoted 6 lines
Quoted 1 line
drivers/net/ethernet/microsoft/mana/mana_bpf.c +0
-0__netif_tx_unlock (ndevtxq);[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 67 lines
-----Original Message-----
From: Hamza Mahfooz <[email protected]>
Sent: Tuesday, October 13, 2026 5:50 PM
To: [email protected]
Cc: Haiyang Zhang <[email protected]>; Wei Liu <[email protected]>; Dexuan Cui <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Konstantin Taranov <[email protected]>; Simon Horman <[email protected]>; Alexei Starovoitov <[email protected]>; Daniel Borkmann <[email protected]>; Jesper Dangaard Brouer <[email protected]>; John Fastabend <[email protected]>; Stanislav Fomichev <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; Hamza Mahfooz <[email protected]>
Subject: [PATCH net-next v3] net: mana: add BQL supportMANA doesn't support byte queue limits, so each TX queue can hold 256 WQEs by default, and up to 16384, of up to 64 KB TSO packets, before the qdisc layer sees any backpressure. This adds latency to all the flows sharing a queue, and defeats AQM qdiscs such as
fq_codel, which rely on BQL to keep the driver queues short.Report the bytes queued and completed to BQL, except for the
XDP_TXandXDP_REDIRECTframes. These share the SQs, but bypass the qdisc and are sent even when the queue is stopped, so BQL can't hold them back. Counting them would let sustained XDP traffic keep the queue stopped, starving the stack, and the TX watchdog would then either fire while the completions still arrive, or, if the XDP sends refreshedtrans_start, not fire when the completions stop. The XDP SKBs are marked in theirskb->cb, next to the WQE size, so that their completions are skipped as well.Reset the BQL state when destroying the queues, once their NAPI is disabled, since the SKBs still pending after a drain timeout are freed without being completed.
Lost TX completions can now stop a queue sooner: it also stops when the bytes in flight exceed the BQL limit, not only when the SQ is full, and the limit may never grow enough to cover the lost bytes. This includes the completions skipped by the
WARN_ON_ONCE()early returns inmana_poll_tx_cq(), which already leak SQ space: completing the SKBs already freed there wouldn't reliably balance BQL, sincemana_gd_poll_cq()has already consumed the CQEs of the rest of the batch. The TX watchdog then fires, as nothing refreshes thetrans_startof a queue stopped by BQL, and its handler resets the queues along with their BQL state. The exception, as before this patch, is XDP traffic keeping the SQ full: each XDP send then stops the queue again, refreshing itstrans_start.Tested on two
Standard_D16ds_v6Azure VMs in a proximity placement group, where the throughput is capped at 10.6 Gbps, with the DUT alternately booting net-next (c1c1f0a31712) with and without this patch applied.The throughput stays at the cap with 1, 8 and 64 TCP flows, and the idle
TCP_RRlatency doesn't change (p50 of 47 us with vs. without the patch). With 16 senders of 64-byte UDP packets, the DUT sends 3.7 to 4.0 Mpps without the patch and 3.7 to 4.1 Mpps with it. With bulk TCP flows sharing the queues, the netperfTCP_RRlatency drops (medians of 6 runs):16 queues, 64 flows: p50 4649 -> 2182 us, p99 5621 -> 2677 us
1 queue, 8 flows: p50 2554 -> 418 us, p99 2723 -> 624 us
Quoted 8 lines
The standing queue moves from the SQs to
fq_codel, which now drops
packets: about 2500 qdisc drops and 88K TCP retransmissions per 48 s run with 64 flows, against at most 29 retransmissions before. The retransmissions are about 0.2% of the segments sent. TheTCP_RRflows lose no packets, and the packets of the bulk flows are dropped before they reach the wire, so the goodput changes by less than 0.01%.Signed-off-by Hamza Mahfooz <[email protected]>
Thank you!
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 16 lines · On Tue, 13 Oct 2026 17:49:37 -0400 you wrote:
MANA doesn't support byte queue limits, so each TX queue can hold 256 WQEs by default, and up to 16384, of up to 64 KB TSO packets, before the qdisc layer sees any backpressure. This adds latency to all the flows sharing a queue, and defeats AQM qdiscs such as
fq_codel, which rely on BQL to keep the driver queues short.Report the bytes queued and completed to BQL, except for the
XDP_TXandXDP_REDIRECTframes. These share the SQs, but bypass the qdisc and are sent even when the queue is stopped, so BQL can't hold them back. Counting them would let sustained XDP traffic keep the queue stopped, starving the stack, and the TX watchdog would then either fire while the completions still arrive, or, if the XDP sends refreshedtrans_start, not fire when the completions stop. The XDP SKBs are marked in theirskb->cb, next to the WQE size, so that their completions are skipped as well.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v3] net: mana: add BQL support
https://git.kernel.org/netdev/net-next/c/799cdeaa5c39
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html