Skip to contentSkip to conversation

e1000e: work around TSO erratum that corrupts data and hangs Tx

PATCH Superseded Andre Brait 2 participants 5 messages Oct 20 – Oct 21

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 e1000e: work around TSO erratum that corrupts data and hangs Tx

On I219, a TSO packet whose first buffer is long and has a 4 KB boundary just after the TCP checksum field makes the NIC send corrupted data and then hang the Tx DMA. Forwarded VM traffic (tun/vhost-net) produces such packets, so hosts bridging guests onto an I219 hit it within minutes:

e1000e 0000:00:1f.6 eno1: Detected Hardware Unit Hang

Right before the hang the receiver gets TCP segments carrying data from 128 bytes earlier in the stream, with a valid checksum.

This is the erratum Intel documents for the 82571/82572 (#76), 82574 (#17) and 82583V (#7): if the first buffer is larger than
3 * (max_read_request - 4) bytes and a 4 KB boundary falls just after the headers, a read is repeated, wrong data goes out with a correct checksum, and the Tx DMA hangs. e1000e never implemented the documented workaround.

Apply it to all e1000e parts: limit the first data descriptor of a TSO packet to 3 * (max_read_request - 4) bytes (372 on the I219, where pcie_get_readrq() returns 128). The rest of the linear part goes into the next descriptor, which e1000_xmit_frame() already reserves; the NIC still segments the packet.

Tested on I219-LM (8086:15bb), v7.0.14, byte-verified traffic:

                                        unpatched        patched
  packets placed inside the window [1]  hang in seconds  no hang
  guest traffic, TCP timestamps on      hang at 387 s    60 min ok
  guest traffic, TCP timestamps off     hang at 402 s    40 min ok
  guest traffic, VLAN tag from stack    hang at 1176 s   40 min ok

[1] 785-1013 packets at each of 10 offsets, 54- to 70-byte headers

Unpatched, data was corrupted at every hang. Patched, no corruption, no Tx timeouts or drops, and hardware TSO stayed in use (26.5M segments).

Developed with an AI coding assistant (Claude); details below the cut.

Fixes bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)")
Assisted-by LLM

---

Notes:
This is a follow-up to a first attempt at fixing this issue
(https://lore.kernel.org/netdev/[email protected]/).

Gabriel replied that the stack can still move the headers after ndo_features_check, which made me look further. The condition that patch relied on, TSO headers crossing a 4 KB boundary, turned out to be only part of the problem.

The NIC hangs, after sending TCP segments with the wrong data and a valid checksum, when the first buffer of a TSO packet is long and a 4 KB boundary falls 1 to 16 bytes after the start of the TCP checksum field. The headers do not have to cross the boundary: with TCP timestamps off (54-byte headers), a packet whose headers end 10 bytes before it hangs the NIC too, and the first patch did not catch that. Forwarded VM traffic hits this because tun/vhost-net builds linear TSO buffers at arbitrary offsets.

Intel documents the same failure as a TSO erratum for the 82571/82572, 82574 and 82583V: a first buffer longer than
3 * (max_read_request - 4) bytes with a 4 KB boundary just after the headers. Its workaround is to keep the headers in a first buffer no longer than that, which removes the long-buffer condition no matter where the boundary falls. This patch applies it to all e1000e parts; on the I219 it prevented the hang at every offset in the window.

The full investigation, tools, captures and raw results are at
https://github.com/andrebrait/e1000e-i219-tso-hang/tree/08c29e379bac

Summary of the runs. "ts on/off" is TCP timestamps in the guest (66- or 54-byte headers); "VLAN" has the stack insert a VLAN tag (rx/txvlan off, timestamps on). "hang <Xm": every run hung, the slowest within X minutes; "ok Xm": ran X minutes without a hang.

ts on ts off VLAN placed [1]
unpatched hang <27m hang <7m hang <20m hang <12m
first patch ok 252m hang <6m ok 72m -
check in xmit [2] ok 60m hang <2m ok 47m -
SPT/KBL regs [3] - - - hang <1m
split at 4 KB [4] - - - hang <1m
this patch ok 60m ok 40m ok 40m ok

[1] buffer placed so the 4 KB boundary falls inside the window; "ok" means about 1000 packets per offset without a hang
[2] an attempt to redo the first patch in e1000_xmit_frame(), on the final layout, segmenting in the driver; it could also stall the queue when it returned NETDEV_TX_BUSY
[3] the existing SPT/KBL IOSFPC/TARC0 workaround, extended to CNP
[4] first descriptor ending at the 4 KB boundary

Every hang came with corrupted data, except the two with the 4 KB split.

Limits:
- Tested only on I219-LM (CNP); an I219-V hung the same way in production. The 8257x parts are covered by the erratum but untested here. Runtime-tested on 7.0.14; builds with W=1 on dev-queue.
- The I219 window (1-16 bytes after tucso) differs from the documented 8257x one (64 bytes after the headers). Intel may know whether the engine differs, and the I219's actual max_read_request.
- Not addressed here: since 95ecba62e2fd the netdev watchdog may never reset a hung e1000e (bugzilla.kernel.org 118721, comments 29-30).

The AI ran as an agent with SSH access to my two test hosts. I set the test requirements (byte-checked traffic, controls that must fail first, identical setups) and reviewed the results and the code.

 drivers/net/ethernet/intel/e1000e/e1000.h  |  1 +
 drivers/net/ethernet/intel/e1000e/netdev.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
drivers/net/ethernet/intel/e1000e/e1000.h +1 -0
index 63ebe0037..704284188 100644
@@ -219,6 +219,7 @@ struct e1000_adapter {
 	/* Tx - one ring per active queue */
 	struct e1000_ring *tx_ring ____cacheline_aligned_in_smp;
 	u32 tx_fifo_limit;
+	u32 tx_hdr_buf_max;
 
 	struct napi_struct napi;
 
drivers/net/ethernet/intel/e1000e/netdev.c +11 -0
index 834a5b888..f5f5d2230 100644
@@ -4143,6 +4143,15 @@ void e1000e_reset(struct e1000_adapter *adapter)
 	adapter->tx_fifo_limit = min_t(u32, ((er32(PBA) >> 16) << 10) - 96,
 				       24 << 10);
 
+	/* TSO erratum (82571/82572 #76, 82574 #17, 82583V #7, also seen on
+	 * I219): when the first buffer of a TSO packet is larger than
+	 * 3 * (max_read_request - 4) bytes and a 4 KB boundary lies just
+	 * after its headers, the NIC repeats a read, sends wrong data with a
+	 * correct checksum and then hangs. Keep the headers in a first buffer
+	 * no larger than that.
+	 */
+	adapter->tx_hdr_buf_max = 3 * (pcie_get_readrq(adapter->pdev) - 4);
+
 	/* Disable Adaptive Interrupt Moderation if 2 full packets cannot
 	 * fit in receive buffer.
 	 */
@@ -5632,6 +5641,8 @@ static int e1000_tx_map(struct e1000_ring *tx_ring, struct sk_buff *skb,
 	while (len) {
 		buffer_info = &tx_ring->buffer_info[i];
 		size = min(len, max_per_txd);
+		if (!offset && skb_is_gso(skb))
+			size = min(size, adapter->tx_hdr_buf_max);
 
 		buffer_info->length = size;
 		buffer_info->time_stamp = jiffies;
Signature · 1 line
2.56.0
#1 lore raw
Quoted 18 lines · On Wed, 21 Oct 2026 01:02:11 +0200 Andre Brait <[email protected]> wrote:

On I219, a TSO packet whose first buffer is long and has a 4 KB boundary just after the TCP checksum field makes the NIC send corrupted data and then hang the Tx DMA. Forwarded VM traffic (tun/vhost-net) produces such packets, so hosts bridging guests onto an I219 hit it within minutes:

e1000e 0000:00:1f.6 eno1: Detected Hardware Unit Hang

Right before the hang the receiver gets TCP segments carrying data from 128 bytes earlier in the stream, with a valid checksum.

This is the erratum Intel documents for the 82571/82572 (#76), 82574 (#17) and 82583V (#7): if the first buffer is larger than
3 * (max_read_request - 4) bytes and a 4 KB boundary falls just after the headers, a read is repeated, wrong data goes out with a correct checksum, and the Tx DMA hangs. e1000e never implemented the documented workaround.

Quoted 4 lines

Apply it to all e1000e parts: limit the first data descriptor of a TSO packet to 3 * (max_read_request - 4) bytes (372 on the I219, where pcie_get_readrq() returns 128). The rest of the linear part goes into the next descriptor, which e1000_xmit_frame() already reserves;

Aren't you using an additional descriptor over and above those the code might already use?
So either it was reserving one too many, or you need to reserve another one.

I'm not actually sure all the logic there is actually needed. The code calculates the number of descriptors the packet is expected to need and gets the packet requeued if there aren't enough, but there is also the 'post transmit' check that stops the transmit if there isn't enough room for a full length packet.
If the latter is valid you don't need the former.
Although a sanity check that the ring isn't being wrapped might not do any harm.

David

Quoted 2 lines

the NIC
still segments the packet.

...

#2 lore raw
Quoted 8 lines · David Laight
Quoted 4 lines

Apply it to all e1000e parts: limit the first data descriptor of a TSO packet to 3 * (max_read_request - 4) bytes (372 on the I219, where pcie_get_readrq() returns 128). The rest of the linear part goes into the next descriptor, which e1000_xmit_frame() already reserves;

Aren't you using an additional descriptor over and above those the code might already use?
So either it was reserving one too many, or you need to reserve another one.

You're right that the split can use one more descriptor than before. The count already covers it, though: the bare count++ in e1000_xmit_frame() is never used by e1000_tx_map(). It comes from e1000, where that descriptor pays for the 4-byte TSO sentinel ("premature desc write-backs in TSO mode"); e1000e dropped the sentinel but kept the count++. With this patch the linear part takes
1 + DIV_ROUND_UP(len - 372, tx_fifo_limit) descriptors instead of DIV_ROUND_UP(len, tx_fifo_limit), at most one more, so it uses exactly that spare.

If we want the count to say so, I see two ways:

a) Count the split explicitly and keep the spare:

if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL)) count++;
count++;
+ /* the headers go in a first buffer of at most tx_hdr_buf_max */
+ if (mss && len > adapter->tx_hdr_buf_max)
+ count++;
count += DIV_ROUND_UP(len, adapter->tx_fifo_limit);

The split pays for its own descriptor and the old spare stays a spare.

b) Replace the spare with the explicit count:

if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL)) count++;
- count++;
+ if (mss && len > adapter->tx_hdr_buf_max)
+ count++;
count += DIV_ROUND_UP(len, adapter->tx_fifo_limit);

The count becomes exact, and one lower for every other packet.

Neither fixes a bug I have seen: the reservation already covers the split, and in about 3.5 hours of test traffic on the patched driver the ring reached its stop threshold over 300,000 times without a stall. b also changes the reservation for every other packet, which I haven't tested. So I'd keep the patch as it is, the smallest change that fixes the bug, and leave the descriptor accounting for a separate cleanup.

If you'd rather have the dependency explicit, I'm happy to fold a) into a v3; it only reserves one more descriptor for those TSO packets.

Quoted 8 lines

I'm not actually sure all the logic there is actually needed. The code calculates the number of descriptors the packet is expected to need and gets the packet requeued if there aren't enough, but there is also the 'post transmit' check that stops the transmit if there isn't enough room for a full length packet.
If the latter is valid you don't need the former.
Although a sanity check that the ring isn't being wrapped might not do any harm.

The post-transmit check reserves (MAX_SKB_FRAGS + 1) * DIV_ROUND_UP(PAGE_SIZE, tx_fifo_limit) + 4, which assumes no buffer is larger than a page. The linear part and high-order frags can be, so the per-packet count is still needed.

Andre

#3 lore raw
Quoted 8 lines · On Wed, 21 Oct 2026 12:49:16 +0200 André Brait <[email protected]> wrote:
Quoted 5 lines · David Laight
Quoted 4 lines

Apply it to all e1000e parts: limit the first data descriptor of a TSO packet to 3 * (max_read_request - 4) bytes (372 on the I219, where pcie_get_readrq() returns 128). The rest of the linear part goes into the next descriptor, which e1000_xmit_frame() already reserves;

Quoted 7 lines
Quoted 3 lines

Aren't you using an additional descriptor over and above those the code might already use?
So either it was reserving one too many, or you need to reserve another one.

You're right that the split can use one more descriptor than before. The count already covers it, though: the bare count++ in e1000_xmit_frame() is never used by e1000_tx_map().

You could just comment that that count++ is in case the linear part has the extra fragment.
(Indeed the other count++ could be unconditional as well, you aren't going to notice if a transmit fails to fit by one descriptor.)

Quoted 4 lines

It comes from e1000,
where that descriptor pays for the 4-byte TSO sentinel ("premature desc write-backs in TSO mode"); e1000e dropped the sentinel but kept the count++.

Put that in the commit message.

Quoted 20 lines

With this patch the linear part takes
1 + DIV_ROUND_UP(len - 372, tx_fifo_limit) descriptors instead of DIV_ROUND_UP(len, tx_fifo_limit), at most one more, so it uses exactly that spare.

If we want the count to say so, I see two ways:

a) Count the split explicitly and keep the spare:

if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL)) count++;
count++;
+ /* the headers go in a first buffer of at most tx_hdr_buf_max */
+ if (mss && len > adapter->tx_hdr_buf_max)
+ count++;
count += DIV_ROUND_UP(len, adapter->tx_fifo_limit);

The split pays for its own descriptor and the old spare stays a spare.

Quoted 8 lines

b) Replace the spare with the explicit count:

if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL)) count++;
- count++;
+ if (mss && len > adapter->tx_hdr_buf_max)
+ count++;
count += DIV_ROUND_UP(len, adapter->tx_fifo_limit);

c) Adjust the DIV_ROUND_UP() for the linear part.
I think:

    DIV_ROUND_UP(len + adapter->tx_fifo_limit - 372, adapter->tx_fifo_limit)

is right.

Although I wonder if you really want to be doing all those divides? I'm guessing that tx_fifo_limit is usually 24k (and the actual buffer larger). So the result is almost always 1.
(Indeed, does TSO and checksum insertion work if the packets are longer than the real buffer?)

Quoted 9 lines

The count becomes exact, and one lower for every other packet.

Neither fixes a bug I have seen: the reservation already covers the split, and in about 3.5 hours of test traffic on the patched driver the ring reached its stop threshold over 300,000 times without a stall. b also changes the reservation for every other packet, which I haven't tested. So I'd keep the patch as it is, the smallest change that fixes the bug, and leave the descriptor accounting for a separate cleanup.

It'll only matter if you are transmitting packets that need more descriptors than the post-transmit check.
Otherwise that check disables transmit first and you don't bounce off the 'just enough space' check.

Quoted 13 lines

If you'd rather have the dependency explicit, I'm happy to fold a) into a v3; it only reserves one more descriptor for those TSO packets.

Quoted 8 lines

I'm not actually sure all the logic there is actually needed. The code calculates the number of descriptors the packet is expected to need and gets the packet requeued if there aren't enough, but there is also the 'post transmit' check that stops the transmit if there isn't enough room for a full length packet.
If the latter is valid you don't need the former.
Although a sanity check that the ring isn't being wrapped might not do any harm.

Quoted 3 lines

The post-transmit check reserves (MAX_SKB_FRAGS + 1) * DIV_ROUND_UP(PAGE_SIZE, tx_fifo_limit) + 4, which assumes no buffer is larger than a page.

That limit is constant (for the device) - so could be pre-calculated.

It has to be said that I've always thought that check should be for a 'reasonable packet' whereas the docs sort of imply it should be for the largest packet and the driver should never really return 'I couldn't do it'.

David

Quoted 4 lines

The linear part and high-order frags can be, so the per-packet count is still needed.

Andre

#4 lore raw

Hi David,

Quoted 4 lines

You could just comment that that count++ is in case the linear part has the extra fragment.

Put that in the commit message.

Will do both in v3.

Quoted 4 lines

c) Adjust the DIV_ROUND_UP() for the linear part.
I think:

    DIV_ROUND_UP(len + adapter->tx_fifo_limit - 372, adapter->tx_fifo_limit)

is right.

For TSO packets, yes, although it would need min(tx_hdr_buf_max, tx_fifo_limit) for parts with a larger max_read_request, and without an mss check it also changes the count for every other packet. I'd keep that, the unconditional context count++ and pre-calculating the post-transmit limit for a separate cleanup.

Quoted 3 lines

Although I wonder if you really want to be doing all those divides? I'm guessing that tx_fifo_limit is usually 24k (and the actual buffer larger). So the result is almost always 1.

Not on the I219. PBA reads 0x0006001a there, 26 KB for Rx and only 6 KB for Tx, so tx_fifo_limit is 6048; in the ring dumps from my test host, 127,676 data descriptors were exactly that size:
https://github.com/andrebrait/e1000e-i219-tso-hang/blob/5f247ecec758/evidence/related/tx-allocation.txt
Page fragments of up to 32 KB take several descriptors each, so the divides do matter there.

Quoted 2 lines

(Indeed, does TSO and checksum insertion work if the packets are longer than the real buffer?)

TSO does: in a 3-minute window on the patched driver, 39,725 of 40,223 TSO packets were larger than 6048 bytes, up to 65,226 (45 segments), and the receiver verified every byte:
https://github.com/andrebrait/e1000e-i219-tso-hang/blob/5f247ecec758/evidence/related/tso-larger-than-tx-buffer.txt
Only each descriptor has to fit, hence the cap. Plain checksum insertion only sees frames up to the MTU; for jumbo frames e1000e_reset() moves space from Rx to Tx to fit two full frames. I haven't tested jumbo frames. Nothing in the patch depends on the MTU (it only shortens the first descriptor of a TSO packet), so I don't expect it to change their behaviour, but I can run the same tests with jumbo frames if you'd like.

Andre