zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.53k stars 6.46k forks source link

net: checksum offloading not working for virtual network interfaces used for Virtual LAN (VLAN) #78724

Open stomschik-ask opened 3 days ago

stomschik-ask commented 3 days ago

Describe the bug The checksum offloading capabilities of an Ethernet interface are not respected for virtual network interfaces as the function need_calc_checksum() in "net_if.c" always returns true for the virtual interfaces. This increases CPU utilization as checksums are calculated in software even though they would be automatically calculated by the Ethernet MAC. Even worse, some Ethernet MACs require the checksum to be cleared to zero for TX checksum offloading as otherwise an incorrect checksum will be generated by the Ethernet MAC (for example NXP MIMXRT1060-EVK).

To Reproduce Use the Virtual LAN sample

  1. disable IPv6 as IPv6 will disable TX/RX checksum offloading on i.MX RT1060 (CONFIG_NET_IPV6=n)
  2. west build --pristine -b mimxrt1060_evk samples/net/vlan
  3. west flash
  4. From PC, ping 192.0.2.1 (untagged, working)
  5. From PC, ping 198.51.100.1 (VLAN 100, request timed out)
  6. Incorrect checksum (0xffff) for IP header and ICMP message will be shown in Wireshark for the Echo reply

Expected behavior TX/RX checksum offloading should also work on virtual network interfaces used for Virtual LAN (VLAN).

Impact TX/RX checksum offloading can be disabled for i.MX RT1060 by setting CONFIG_ETH_NXP_ENET_HW_ACCELERATION=n. Therefore, impact is mainly the increased CPU utilization.

Environment:

jukkar commented 3 days ago

@stomschik-ask I have a fix proposal at #78745. Would you be able to check if it works for you?

stomschik-ask commented 4 hours ago

Thanks, the fix is working fine for me.