Skip to content

Conversation

@13627105546
Copy link
Contributor

@13627105546 13627105546 commented Aug 29, 2025

Note: Please adhere to Contributing Guidelines.

Summary

This PR introduces hardware checksum offload support to the NuttX network protocol stack, enabling network devices to perform checksum calculations in hardware rather than software.
Key Changes:

  • Added NETDEV_TX_CSUM and NETDEV_RX_CSUM feature flags in netdev.h to indicate hardware checksum capabilities
  • Implemented new checksum calculation functions ipv4_upperlayer_header_chksum() and ipv6_upperlayer_header_chksum()
  • Modified TCP/UDP send and receive paths to conditionally use hardware or software checksum based on device capabilities
  • Added netdev_checksum.c containing core checksum handling logic
  • Fixed compilation errors and updated build system configuration (CMake/Makefile)

Impact

Build Impact:

  • Adds new source file net/netdev/netdev_checksum.c
  • Updates CMake and Makefile build configurations
  • No impact on existing build processes for current configurations
    API Impact:
  • Extends usage of d_features field in struct net_driver_s
  • Introduces new checksum-related helper functions
  • Maintains full compatibility with existing network APIs
    Runtime Impact:
  • Network device drivers need to appropriately set NETDEV_TX_CSUM / NETDEV_RX_CSUM flags to enable hardware checksum
  • For devices not setting these flags, behavior remains identical to previous implementation
  • No breaking changes to existing network functionality

Testing

  • Hardware Verification (New Feature) :

  • Platform : Verified on an internal pre-release development board (Architecture: ARM Cortex-M series) equipped with an Ethernet MAC supporting hardware checksum offloading.

  • Driver Implementation : Implemented a custom driver setting NETDEV_TX_CSUM and NETDEV_RX_CSUM flags to utilize the new APIs.

  • Test Cases :

    • iperf : Verified TCP/UDP throughput stability and correctness. Confirmed that checksums were correctly inserted by hardware (verified via Wireshark on the peer PC).
    • ping : Verified ICMP Echo Request/Reply with hardware checksum generation.
    • udp/tcp_blaster : Ran stress tests to ensure no packet corruption under load.
  • Regression Testing (Software Fallback) :

  • Platform : Tested on sim:tcpblaster (NuttX Simulator) and stm32f4discovery:netnsh (Standard Cortex-M4 board without using the new HW checksum flags).

  • Purpose : To verify that the changes do NOT break existing drivers that rely on the software checksum stack.

  • Test Cases :

    • Ran standard ping , telnetd , and webserver examples.
    • Verified that the software checksum logic ( NETDEV_TX_CSUM flag NOT set) is correctly executed and packets are valid.

@github-actions github-actions bot added Area: Networking Effects networking subsystem Size: L The size of the change in this PR is large labels Aug 29, 2025
@13627105546 13627105546 force-pushed the hardware-checksum-offload branch 5 times, most recently from d17e875 to f60daab Compare August 29, 2025 17:29
@acassis
Copy link
Contributor

acassis commented Aug 30, 2025

@13627105546 since it is a new feature, please include basic Documentation to it. The documentation should be included at https://nuttx.apache.org/docs/latest/components/net/netdev.html as a new section

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Documentation

@linguini1
Copy link
Contributor

All existing network applications function correctly

How did you quantify this? Which applications did you run, on what hardware, and how did you verify that they worked correctly?

@acassis
Copy link
Contributor

acassis commented Sep 7, 2025

All existing network applications function correctly

How did you quantify this? Which applications did you run, on what hardware, and how did you verify that they worked correctly?

@13627105546 the Testing should have the list of boards and applications you tested: i.e. tested on esp32-devkitc running iperf, thttpd, telnet, etc...

@acassis
Copy link
Contributor

acassis commented Jan 15, 2026

ping @13627105546

@xiaoxiang781216
Copy link
Contributor

@13627105546 please fix the conflict

@13627105546 13627105546 force-pushed the hardware-checksum-offload branch 2 times, most recently from 879c936 to c2fde59 Compare January 19, 2026 03:24
Implementation of main hardware verification and uninstallation functions

Signed-off-by: daichuan <daichuan@xiaomi.com>
Fix compilation errors and add build files

Signed-off-by: daichuan <daichuan@xiaomi.com>
When supporting hardware checksum offloading, the network protocol stack
does not perform TCP/UDP pseudo-header checksum calculation.

Skip TCP/UDP pseudo header checksum calculation in network protocol stack

Signed-off-by: daichuan <daichuan@xiaomi.com>
not need CONFIG_NETDEV_CHECKSUM with nuttx

Signed-off-by: daichuan <daichuan@xiaomi.com>
@13627105546 13627105546 force-pushed the hardware-checksum-offload branch from fa80dd8 to 522c033 Compare January 19, 2026 08:15
@13627105546
Copy link
Contributor Author

All existing network applications function correctly

How did you quantify this? Which applications did you run, on what hardware, and how did you verify that they worked correctly?

@13627105546 the Testing should have the list of boards and applications you tested: i.e. tested on esp32-devkitc running iperf, thttpd, telnet, etc...

I have added the relevant descriptions. Could you kindly review them again?

@jerpelea jerpelea changed the title Hardware Checksum Offload Support for NuttX Network Stack net: Hardware Checksum Offload Support for NuttX Network Stack Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: BINFMT Area: Documentation Improvements or additions to documentation Area: Networking Effects networking subsystem Size: L The size of the change in this PR is large Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants