Skip to content

Conversation

@13627105546
Copy link
Contributor

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

All existing network applications function correctly

@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 3 times, most recently from bc64464 to 7520a52 Compare August 29, 2025 17:10
Implementation of main hardware verification and uninstallation functions

Signed-off-by: daichuan <[email protected]>
Fix compilation errors and add build files

Signed-off-by: daichuan <[email protected]>
@13627105546 13627105546 force-pushed the hardware-checksum-offload branch from 7520a52 to d17e875 Compare August 29, 2025 17:18
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 <[email protected]>
@13627105546 13627105546 force-pushed the hardware-checksum-offload branch from d17e875 to f60daab Compare August 29, 2025 17:29
logic.

config NETDEV_CHECKSUM
bool "netdev hardware checksum"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool "netdev hardware checksum"
bool "Enable support to netdev checksum in Hardware"


config NETDEV_CHECKSUM
bool "netdev hardware checksum"
default n
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is something that depends on chip supporting it, shouldn't it have a "depends on ARCH_HAVE_NETDEV_CHKSUM_HW" ?

@xiaoxiang781216 @raiden00pl please comment

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants