Observed on BMCs in real use communicating with a USB NCM gadget over an EHCI host controller, where bulk TCP traffic caused steady tx_dropped growth and retransmits. Tracing the link with kprobes and the kfree_skb tracepoint during iperf3 TCP runs confirmed that every drop came from cdc_ncm_txpath_bh() calling usbnet_start_xmit(NULL, ...) into a stopped TX queue. cdc_ncm_fill_tx_frame() only learns that an NTB is full when it is given a datagram that no longer fits. It then hands the NTB to usbnet and parks that datagram in tx_rem_skb for the next NTB. If the stack sends nothing more, only the TX timer is left to send it. With 16 KiB NTBs usbnet allows 5 TX URBs in flight at high speed. When the NTB that was just handed over is the fifth, usbnet stops the TX queue. The timer then builds an NTB for the parked datagram and calls usbnet_start_xmit(NULL, ...) directly, bypassing the qdisc. Since commit ad70411a978d ("usbnet: fix kernel crash after disconnect") usbnet_start_xmit() frees what it is given while the queue is stopped, so the datagram is lost and counted in tx_dropped. A bulk TCP sender hits this several times per second. Send the NTB as soon as another datagram of the interface MTU, with a VLAN tag, would not fit, provided no datagram is still parked in tx_rem_skb. Nothing is parked on that path, so cdc_ncm holds no datagram when usbnet stops the queue for a full TX queue, and the timer has nothing to flush into it. An NTB also no longer waits for the next datagram to arrive before it is sent. tx_rem_skb is still used when a datagram needs a new NDP that does not fit, as with several MBIM sessions. The cost is that an NTB is closed while it could still take a datagram smaller than the MTU. With 16 KiB NTBs and a 1500 byte MTU this does not change the 10 full size frames per NTB. Tested on an NPCM730 BMC (EHCI host, Linux 7.3.6 with BQL and fq_codel) running 30 s iperf3 IPv6 TCP streams to an NCM gadget, same board before and after: tx_dropped Mbit/s (before -> after) 1 stream, fwd 106 -> 0 119.8 -> 141.0 4 streams, fwd 128 -> 0 164.3 -> 172.4 1 stream, bidir 51 -> 0 39.5/118.3 -> 73.0/107.7 4 streams, bidir 62 -> 0 36.7/150.3 -> 78.0/130.2 4 streams, MSS 512 81 -> 0 129.2 -> 152.8 Fixes: ad70411a978d ("usbnet: fix kernel crash after disconnect") Signed-off-by: William A. Kennington III --- v2: - Replace the timer re-arm polling from v1 with closing the NTB as soon as another full-MTU (plus VLAN) datagram would not fit, so no datagram is parked in tx_rem_skb when usbnet stops the TX queue. - Add real-hardware discovery/trace validation and same-board Linux 7.3.6 (with BQL and fq_codel) test results. Mainline usbnet BQL still hits these drops because DQL's limit exceeds the 5-URB (80 KiB) TX ring cap. v1: https://lore.kernel.org/r/20261118034122.315979-1-william@wkennington.com drivers/net/usb/cdc_ncm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index e92dc7f011ea..7fbce4846a04 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1369,6 +1370,22 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign) ctx->tx_reason_ndp_full++; /* count reason for transmitting */ break; } + + /* Send now if another full size datagram would not fit. + * Accepting one more would park it in tx_rem_skb after + * this NTB has been handed to usbnet. If that NTB fills + * the TX queue, usbnet stops the queue and drops the NTB + * the timer builds for the parked datagram. + */ + if (!ctx->tx_rem_skb && n + 1 < ctx->tx_max_datagrams && + skb_out->len + ctx->tx_modulus + ctx->tx_remainder + + READ_ONCE(dev->net->mtu) + cdc_ncm_eth_hlen(dev) + + VLAN_HLEN + delayed_ndp_size > ctx->tx_curr_size) { + ready2send = 1; + ctx->tx_reason_ntb_full++; /* count reason for transmitting */ + n++; + break; + } } /* free up any dangling skb */ -- 2.56.1.839.g22a8290db9-goog