Skip to contentSkip to conversation

ice: enable NETIF_F_HW_CSUM for GSO packets

PATCH In review Jakub Ramaseuski 2 participants 4 messages Mar 10 – Mar 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ice: enable NETIF_F_HW_CSUM for GSO packets

IPv4 over IPv6 GRE currently fails on E810 with skb_warn_bad_offload, while IPv6 over IPv6 GRE falls back to software segmentation. This happens because the kernel's GSO engine requires the generic HW_CSUM flag to trust the hardware with complex encapsulation offloads.

Add NETIF_F_HW_CSUM to the device's csumo_features to satisfy the network stack and unlock full hardware segmentation for GRE tunnels. To prevent checksum corruption on standard traffic, evaluate the packet in ice_features_check() and dynamically clear the NETIF_F_HW_CSUM bit if it is not a GSO frame. This forces the driver to fall back to safe, protocol-specific checksum features for non-GSO packets
while preserving the generic offload for tunnels.

Steps to reproduce:

Server Side (Receiver):

```
  #!/bin/bash
  DEV="enp65s0f0np0"

  # 1. Configure underlay device
  ip addr add 2011::11/64 dev $DEV
  ip addr add 192.168.42.11/24 dev $DEV
  ip link set $DEV up

  # 2. Create and configure IPv6 GRE tunnel
  ip link add gre1 type ip6gre local 2011::11 remote 2011::12 dev $DEV
  ip addr add 2023::11/64 dev gre1
  ip addr add 192.168.44.11/24 dev gre1
  ip link set gre1 up

  iperf3 -s
```

Client Side (Sender):

```
  #!/bin/bash
  DEV="enp65s0f0np0"

  # 1. Configure underlay device
  ip addr add 2011::12/64 dev $DEV
  ip addr add 192.168.42.12/24 dev $DEV
  ip link set $DEV up

  # 2. Create and configure IPv6 GRE tunnel
  ip link add gre1 type ip6gre local 2011::12 remote 2011::11 dev $DEV
  ip addr add 2023::12/64 dev gre1
  ip addr add 192.168.44.12/24 dev gre1
  ip link set gre1 up

  # 3. Execute Tests
  iperf3 -c 192.168.44.11 -t 20   # IPv4 over IPv6 GRE (Triggers bad_offload)
  iperf3 -c 2023::11 -t 20        # IPv6 over IPv6 GRE (Triggers SW fallback)
  iperf3 -c 192.168.42.11 -t 20   # Native IPv4 Baseline
  iperf3 -c 2011::11 -t 20        # Native IPv6 Baseline
```
---
 drivers/net/ethernet/intel/ice/ice_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +9 -0
index e7308e381e2f..9b4ad03e1a32 100644
@@ -3565,6 +3565,7 @@ void ice_set_netdev_features(struct net_device *netdev)
 
 	csumo_features = NETIF_F_RXCSUM	  |
 			 NETIF_F_IP_CSUM  |
+			 NETIF_F_HW_CSUM  |
 			 NETIF_F_SCTP_CRC |
 			 NETIF_F_IPV6_CSUM;
 
@@ -9789,6 +9790,14 @@ ice_features_check(struct sk_buff *skb,
 	if (skb->ip_summed != CHECKSUM_PARTIAL)
 		return features;
 
+	/* Hardware requires strictly-typed Tx descriptors for non-GSO frames.
+	 * Leaving generic NETIF_F_HW_CSUM enabled corrupts checksums,
+	 * causing TCP drops. We strip it here to force safe,
+	 * protocol-specific IPv4/IPv6 offloads instead.
+	 */
+	if (!gso)
+		features &= ~NETIF_F_HW_CSUM;
+
 	/* We cannot support GSO if the MSS is going to be less than
 	 * 64 bytes. If it is then we need to drop support for GSO.
 	 */
Signature · 1 line
2.52.0
#2 lore raw

Hi, Anthony,

Pardon me for asking, but is anything else required in this matter?

Regards,
Jakub Ramaseuski

Quoted 10 lines · Jakub Ramaseuski

For whom it may concern

I forgot to include Reviewed-by section that was to be copied from v1 of the patch
(to be found here: https://lore.kernel.org/intel-wired-lan/[email protected]/T/#u),
sorry for the inconvenience.

Regards,
Jakub Ramaseuski

maintainer
#3 lore raw
In reply to Jakub Ramaseuski

drivers/net/ethernet/intel/ice/ice_main.c void ice_set_netdev_features(struct net_device *netdev)

Quoted 67 lines · Jakub Ramaseuski

IPv4 over IPv6 GRE currently fails on E810 with skb_warn_bad_offload, while IPv6 over IPv6 GRE falls back to software segmentation. This happens because the kernel's GSO engine requires the generic HW_CSUM flag to trust the hardware with complex encapsulation offloads.

Add NETIF_F_HW_CSUM to the device's csumo_features to satisfy the network stack and unlock full hardware segmentation for GRE tunnels. To prevent checksum corruption on standard traffic, evaluate the packet in ice_features_check() and dynamically clear the NETIF_F_HW_CSUM bit if it is not a GSO frame. This forces the driver to fall back to safe, protocol-specific checksum features for non-GSO packets
while preserving the generic offload for tunnels.

Steps to reproduce:

Server Side (Receiver):

```
   #!/bin/bash
   DEV="enp65s0f0np0"

   # 1. Configure underlay device
   ip addr add 2011::11/64 dev $DEV
   ip addr add 192.168.42.11/24 dev $DEV
   ip link set $DEV up

   # 2. Create and configure IPv6 GRE tunnel
   ip link add gre1 type ip6gre local 2011::11 remote 2011::12 dev $DEV
   ip addr add 2023::11/64 dev gre1
   ip addr add 192.168.44.11/24 dev gre1
   ip link set gre1 up

   iperf3 -s
```

Client Side (Sender):

```
   #!/bin/bash
   DEV="enp65s0f0np0"

   # 1. Configure underlay device
   ip addr add 2011::12/64 dev $DEV
   ip addr add 192.168.42.12/24 dev $DEV
   ip link set $DEV up

   # 2. Create and configure IPv6 GRE tunnel
   ip link add gre1 type ip6gre local 2011::12 remote 2011::11 dev $DEV
   ip addr add 2023::12/64 dev gre1
   ip addr add 192.168.44.12/24 dev gre1
   ip link set gre1 up

   # 3. Execute Tests
   iperf3 -c 192.168.44.11 -t 20   # IPv4 over IPv6 GRE (Triggers bad_offload)
   iperf3 -c 2023::11 -t 20        # IPv6 over IPv6 GRE (Triggers SW fallback)
   iperf3 -c 192.168.42.11 -t 20   # Native IPv4 Baseline
   iperf3 -c 2011::11 -t 20        # Native IPv6 Baseline
```
---
  drivers/net/ethernet/intel/ice/ice_main.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +0 -0
index e7308e381e2f..9b4ad03e1a32 100644
@@ -3565,6 +3565,7 @@ void ice_set_netdev_features(struct net_device *netdev)

Hi Jakub,

Responding here as this has the code. I'm getting some clarifications on things internally which is what I'm waiting for. There's a couple of concerns here.

First, only E830 supports NETIF_F_HW_CSUM so advertising it for all hardware wouldn't seem appropriate.

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
  	csumo_features = NETIF_F_RXCSUM	  |
  			 NETIF_F_IP_CSUM  |
+			 NETIF_F_HW_CSUM  |
  			 NETIF_F_SCTP_CRC |
  			 NETIF_F_IPV6_CSUM;
 

drivers/net/ethernet/intel/ice/ice_main.c ice_features_check(struct sk_buff *skb, · line 9799

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +7 -0
@@ -9789,6 +9790,14 @@ ice_features_check(struct sk_buff *skb,
  	if (skb->ip_summed != CHECKSUM_PARTIAL)
  		return features;
 
+	/* Hardware requires strictly-typed Tx descriptors for non-GSO frames.
+	 * Leaving generic NETIF_F_HW_CSUM enabled corrupts checksums,
+	 * causing TCP drops. We strip it here to force safe,
+	 * protocol-specific IPv4/IPv6 offloads instead.
+	 */
+	if (!gso)
+		features &= ~NETIF_F_HW_CSUM;

Second is I suspect this would break the HW_CSUM feature for E830.

Thanks,
Tony

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
+
  	/* We cannot support GSO if the MSS is going to be less than
  	 * 64 bytes. If it is then we need to drop support for GSO.
  	 */