Skip to contentSkip to conversation

rtase: Workaround for TX hang caused by hardware packet parsing

PATCH Applied Justin Lai 3 participants 3 messages Jul 9 – Jul 21

Subsystems (4)
lore
Share & tools
lore

Justin Lai

author maintainer
#0 lore raw

PATCH v5 1/1 rtase: Workaround for TX hang caused by hardware packet parsing

The hardware performs packet parsing before packet transmission. Parsing incomplete IPv4, IPv6, TCP, or UDP headers may trigger a TX hang because the hardware parser expects additional protocol header data that is not present in the packet.

The hardware performs additional PTP parsing on UDP packets identified by destination ports 319/320 at the expected UDP destination port offset.

If such a packet has transport data smaller than RTASE_MIN_PAD_LEN, the hardware parser expects additional packet data and may trigger a TX hang.

To avoid these hardware issues, the driver applies the following workarounds.

Drop malformed packets that may trigger this hardware issue before transmission.

For IPv4 non-initial fragments, the hardware does not check the fragment offset before parsing the expected transport header location. As a result, these packets are still subject to transport header parsing even though they do not contain a transport header. If the transport data is shorter than the minimum transport header required by the hardware parser, pad the transport data to the minimum transport header length required by the hardware parser. Packets that also match the hardware PTP parsing conditions continue to follow the corresponding workaround.

For IPv6 fragmented packets, neither of the above hardware issues occurs because the hardware only continues packet parsing when the IPv6 Base Header Next Header field directly indicates UDP. Packets carrying a Fragment Header do not continue through the subsequent packet parsing stages.

For packets identified for hardware PTP parsing, pad the transport data so it reaches RTASE_MIN_PAD_LEN before transmission.

Fixes d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")

---
v4 -> v5:
- Drop packets that may trigger a TX hang during hardware packet parsing.
- Pad IPv4 non-initial fragments when the transport data is shorter than the minimum transport header required by the hardware parser.

v3 -> v4:
- Derive the L3 protocol and network offset from Ethernet/VLAN headers instead of relying on vlan_get_protocol().
- Reject malformed packets when the computed UDP offset exceeds skb->len.

v2 -> v3:
- Remove dependency on skb_transport_header_was_set().
- Determine UDP header offset from IPv4/IPv6 headers.
- Use skb_header_pointer() for UDP header access.
- Add non-linear skb handling.

v1 -> v2:
- Remove RTASE_SHORT_PKT_THRESH and the packet length check.
- Check transport data length before parsing the UDP header.
- Add Fixes tag.
- Add Cc: [email protected].
- Target net tree.

---
 drivers/net/ethernet/realtek/rtase/rtase.h    |   8 +
 .../net/ethernet/realtek/rtase/rtase_main.c   | 197 ++++++++++++++++++
 2 files changed, 205 insertions(+)
drivers/net/ethernet/realtek/rtase/rtase.h +8 -0
index 9bd6872474c1..03b12d83f6e9 100644
@@ -192,6 +192,12 @@ enum rtase_sw_flag_content {
 	RTASE_SWF_MSIX_ENABLED = BIT(2),
 };
 
+enum rtase_parse_result {
+	RTASE_PARSE_OK,
+	RTASE_PARSE_SKIP,
+	RTASE_PARSE_DROP,
+};
+
 #define RSVD_MASK 0x3FFFC000
 
 struct rtase_tx_desc {
@@ -363,4 +369,6 @@ struct rtase_private {
 
 #define RTASE_MSS_MASK GENMASK(28, 18)
 
+#define RTASE_MIN_PAD_LEN 47
+
 #endif /* RTASE_H */
drivers/net/ethernet/realtek/rtase/rtase_main.c +197 -0

215 lines not on this page · raw message

Signature · 1 line
2.40.1
reviewer Reviewed-by on v5 1/1
#1 lore raw
Quoted 35 lines · Justin Lai

The hardware performs packet parsing before packet transmission. Parsing incomplete IPv4, IPv6, TCP, or UDP headers may trigger a TX hang because the hardware parser expects additional protocol header data that is not present in the packet.

The hardware performs additional PTP parsing on UDP packets identified by destination ports 319/320 at the expected UDP destination port offset.

If such a packet has transport data smaller than RTASE_MIN_PAD_LEN, the hardware parser expects additional packet data and may trigger a TX hang.

To avoid these hardware issues, the driver applies the following workarounds.

Drop malformed packets that may trigger this hardware issue before transmission.

For IPv4 non-initial fragments, the hardware does not check the fragment offset before parsing the expected transport header location. As a result, these packets are still subject to transport header parsing even though they do not contain a transport header. If the transport data is shorter than the minimum transport header required by the hardware parser, pad the transport data to the minimum transport header length required by the hardware parser. Packets that also match the hardware PTP parsing conditions continue to follow the corresponding workaround.

For IPv6 fragmented packets, neither of the above hardware issues occurs because the hardware only continues packet parsing when the IPv6 Base Header Next Header field directly indicates UDP. Packets carrying a Fragment Header do not continue through the subsequent packet parsing stages.

Quoted 6 lines

For packets identified for hardware PTP parsing, pad the transport data so it reaches RTASE_MIN_PAD_LEN before transmission.

Fixes d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")

FTR, the AI-generated reviews of this patch on both sashiko.dev and
https://netdev-ai.bots.linux.dev/sashiko/ flag issues. However, I do not believe they should impede progress of this patch.

#2 lore raw
In reply to Justin Lai
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 9 Jul 2026 18:34:56 +0800 you wrote:

The hardware performs packet parsing before packet transmission. Parsing incomplete IPv4, IPv6, TCP, or UDP headers may trigger a TX hang because the hardware parser expects additional protocol header data that is not present in the packet.

The hardware performs additional PTP parsing on UDP packets identified by destination ports 319/320 at the expected UDP destination port offset.

[...]

Here is the summary with links:
- [net,v5] rtase: Workaround for TX hang caused by hardware packet parsing

    https://git.kernel.org/netdev/net/c/1c50efa1faf3

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html