This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit b01f8b04e97893d61b17b6aa13909fc1fbc1709f
Author: daichuan <[email protected]>
AuthorDate: Mon Jan 19 14:29:59 2026 +0800

    netdev: delete macro CONFIG_NETDEV_CHECKSUM with nuttx
    
    not need CONFIG_NETDEV_CHECKSUM with nuttx
    
    Signed-off-by: daichuan <[email protected]>
---
 Documentation/components/net/netdev.rst | 17 +++------
 arch/Kconfig                            |  4 ---
 include/nuttx/net/netdev.h              |  6 ----
 net/netdev/CMakeLists.txt               |  4 +--
 net/netdev/Kconfig                      | 10 ------
 net/netdev/Make.defs                    |  2 --
 net/netdev/netdev_checksum.c            | 62 +++++++++++++++++++++++++--------
 7 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/Documentation/components/net/netdev.rst 
b/Documentation/components/net/netdev.rst
index 47aaaac50c2..f63668c3276 100644
--- a/Documentation/components/net/netdev.rst
+++ b/Documentation/components/net/netdev.rst
@@ -180,17 +180,10 @@ The structure :c:struct:`net_driver_s` includes fields to 
support hardware
 checksum offloading. This feature allows the network stack to delegate
 checksum calculation to the network device hardware, improving performance.
 
-Checksum Configuration Options
-------------------------------
-
-* :c:macro:`CONFIG_NETDEV_CHECKSUM`: Enable support for hardware checksum
-  offloading in the network stack. This option requires the architecture
-  to support it (:c:macro:`ARCH_HAVE_NETDEV_CHECKSUM_HW`).
-
 Implementation Details
 ----------------------
 
-When :c:macro:`CONFIG_NETDEV_CHECKSUM` is enabled, the driver should use the
+Drivers that support hardware checksum offloading should use the
 following helper functions to retrieve checksum offload information:
 
 * :c:func:`netdev_checksum_start`: Get the offset from the beginning of the
@@ -202,11 +195,9 @@ following helper functions to retrieve checksum offload 
information:
 
 .. code-block:: c
 
-   #ifdef CONFIG_NETDEV_CHECKSUM
-     int netdev_checksum_start(FAR struct net_driver_s *dev);
-     int netdev_checksum_offset(FAR struct net_driver_s *dev);
-     uint16_t netdev_upperlayer_header_checksum(FAR struct net_driver_s *dev);
-   #endif
+   int netdev_checksum_start(FAR struct net_driver_s *dev);
+   int netdev_checksum_offset(FAR struct net_driver_s *dev);
+   uint16_t netdev_upperlayer_header_checksum(FAR struct net_driver_s *dev);
 
 Drivers that support hardware checksum offloading should use these functions
 to configure the hardware accordingly before transmitting the packet.
diff --git a/arch/Kconfig b/arch/Kconfig
index 17daa230344..7e3396308ad 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -575,10 +575,6 @@ config ARCH_HAVE_FETCHADD
        bool
        default n
 
-config ARCH_HAVE_NETDEV_CHECKSUM_HW
-       bool
-       default n
-
 config ARCH_HAVE_RTC_SUBSECONDS
        bool
        default n
diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h
index 34699a0c4e9..23a3f2f5e5d 100644
--- a/include/nuttx/net/netdev.h
+++ b/include/nuttx/net/netdev.h
@@ -1310,9 +1310,7 @@ void netdev_statistics_log(FAR void *arg);
  *
  ****************************************************************************/
 
-#ifdef CONFIG_NETDEV_CHECKSUM
 int netdev_checksum_start(FAR struct net_driver_s *dev);
-#endif
 
 /****************************************************************************
  * Name: netdev_checksum_offset
@@ -1329,9 +1327,7 @@ int netdev_checksum_start(FAR struct net_driver_s *dev);
  *
  ****************************************************************************/
 
-#ifdef CONFIG_NETDEV_CHECKSUM
 int netdev_checksum_offset(FAR struct net_driver_s *dev);
-#endif
 
 /****************************************************************************
  * Name: netdev_upperlayer_header_checksum
@@ -1347,8 +1343,6 @@ int netdev_checksum_offset(FAR struct net_driver_s *dev);
  *
  ****************************************************************************/
 
-#ifdef CONFIG_NETDEV_CHECKSUM
 uint16_t netdev_upperlayer_header_checksum(FAR struct net_driver_s *dev);
-#endif
 
 #endif /* __INCLUDE_NUTTX_NET_NETDEV_H */
diff --git a/net/netdev/CMakeLists.txt b/net/netdev/CMakeLists.txt
index 1149a44d651..09073152739 100644
--- a/net/netdev/CMakeLists.txt
+++ b/net/netdev/CMakeLists.txt
@@ -57,8 +57,6 @@ if(CONFIG_NETDEV_RSS)
   list(APPEND SRCS netdev_notify_recvcpu.c)
 endif()
 
-if(CONFIG_NETDEV_CHECKSUM)
-  list(APPEND SRCS netdev_checksum.c)
-endif()
+list(APPEND SRCS netdev_checksum.c)
 
 target_sources(net PRIVATE ${SRCS})
diff --git a/net/netdev/Kconfig b/net/netdev/Kconfig
index 2ef6287564c..227b5c2d58f 100644
--- a/net/netdev/Kconfig
+++ b/net/netdev/Kconfig
@@ -99,14 +99,4 @@ config NETDOWN_NOTIFIER
                notifier, but was developed specifically to support SIGHUP 
poll()
                logic.
 
-config NETDEV_CHECKSUM
-       bool "Enable support to netdev checksum in Hardware"
-       default n
-       depends on ARCH_HAVE_NETDEV_CHECKSUM_HW
-       ---help---
-               To support hardware checksum calculation for network cards, we
-               need to know the starting position of the L4 layer header in
-               the iob buffer, as well as the offset of the checksum field
-               within the L4 layer.
-
 endmenu # Network Device Operations
diff --git a/net/netdev/Make.defs b/net/netdev/Make.defs
index 81551344a42..03611206814 100644
--- a/net/netdev/Make.defs
+++ b/net/netdev/Make.defs
@@ -48,9 +48,7 @@ ifeq ($(CONFIG_NETDEV_RSS),y)
 NETDEV_CSRCS += netdev_notify_recvcpu.c
 endif
 
-ifeq ($(CONFIG_NETDEV_CHECKSUM),y)
 NETDEV_CSRCS += netdev_checksum.c
-endif
 
 # Include netdev build support
 
diff --git a/net/netdev/netdev_checksum.c b/net/netdev/netdev_checksum.c
index d2c2cac7fe3..a2040976ba1 100644
--- a/net/netdev/netdev_checksum.c
+++ b/net/netdev/netdev_checksum.c
@@ -27,11 +27,10 @@
 #include <nuttx/net/netdev.h>
 #include <nuttx/net/udp.h>
 #include <nuttx/net/tcp.h>
+#include <nuttx/mm/iob.h>
 
 #include "netdev/netdev.h"
 
-#ifdef CONFIG_NETDEV_CHECKSUM
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
@@ -51,6 +50,8 @@
  *
  ****************************************************************************/
 
+#if defined(CONFIG_MM_IOB) && \
+    (defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6))
 static int32_t hardware_chksum_start(FAR struct iob_s *iob,
                                      uint16_t iphdrlen)
 {
@@ -68,6 +69,7 @@ static int32_t hardware_chksum_start(FAR struct iob_s *iob,
 
   return start;
 }
+#endif
 
 /****************************************************************************
  * Name: hardware_chksum_get_proto
@@ -83,23 +85,33 @@ static int32_t hardware_chksum_start(FAR struct iob_s *iob,
  *
  ****************************************************************************/
 
+#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
 static uint8_t hardware_chksum_get_proto(FAR struct net_driver_s *dev)
 {
-  uint8_t proto;
+  uint8_t proto = 0;
 
+#ifdef CONFIG_NET_IPv6
+#  ifdef CONFIG_NET_IPv4
   if (IFF_IS_IPv6(dev->d_flags))
+#  endif
     {
       FAR struct ipv6_hdr_s *ipv6 = IPv6BUF;
       proto = ipv6->proto;
     }
+#endif
+#ifdef CONFIG_NET_IPv4
+#  ifdef CONFIG_NET_IPv6
   else
+#  endif
     {
       FAR struct ipv4_hdr_s *ipv4 = IPv4BUF;
       proto = ipv4->proto;
     }
+#endif
 
   return proto;
 }
+#endif
 
 /****************************************************************************
  * Public Functions
@@ -123,9 +135,13 @@ static uint8_t hardware_chksum_get_proto(FAR struct 
net_driver_s *dev)
 
 int netdev_checksum_start(FAR struct net_driver_s *dev)
 {
-  int start;
+#ifdef CONFIG_MM_IOB
+  int start = -EINVAL;
 
+#ifdef CONFIG_NET_IPv6
+#  ifdef CONFIG_NET_IPv4
   if (IFF_IS_IPv6(dev->d_flags))
+#  endif
     {
       FAR struct ipv6_hdr_s *ipv6 =
         (FAR struct ipv6_hdr_s *)(IOB_DATA(dev->d_iob));
@@ -139,7 +155,11 @@ int netdev_checksum_start(FAR struct net_driver_s *dev)
           return -EINVAL;
         }
     }
+#endif
+#ifdef CONFIG_NET_IPv4
+#  ifdef CONFIG_NET_IPv6
   else
+#  endif
     {
       FAR struct ipv4_hdr_s *ipv4 =
         (FAR struct ipv4_hdr_s *)(IOB_DATA(dev->d_iob));
@@ -154,8 +174,12 @@ int netdev_checksum_start(FAR struct net_driver_s *dev)
           return -EINVAL;
         }
     }
+#endif
 
   return start;
+#else
+  return -EINVAL;
+#endif
 }
 
 /****************************************************************************
@@ -175,23 +199,25 @@ int netdev_checksum_start(FAR struct net_driver_s *dev)
 
 int netdev_checksum_offset(FAR struct net_driver_s *dev)
 {
-  int offset = 0;
+#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
   uint8_t proto = hardware_chksum_get_proto(dev);
+#endif
 
+#ifdef CONFIG_NET_UDP
   if (proto == IP_PROTO_UDP)
     {
-      offset = offsetof(struct udp_hdr_s, udpchksum);
-    }
-  else if (proto == IP_PROTO_TCP)
-    {
-      offset = offsetof(struct tcp_hdr_s, tcpchksum);
+      return offsetof(struct udp_hdr_s, udpchksum);
     }
-  else
+#endif
+
+#ifdef CONFIG_NET_TCP
+  if (proto == IP_PROTO_TCP)
     {
-      return -EINVAL;
+      return offsetof(struct tcp_hdr_s, tcpchksum);
     }
+#endif
 
-  return offset;
+  return -EINVAL;
 }
 
 /****************************************************************************
@@ -210,7 +236,10 @@ int netdev_checksum_offset(FAR struct net_driver_s *dev)
 
 uint16_t netdev_upperlayer_header_checksum(FAR struct net_driver_s *dev)
 {
+#ifdef CONFIG_NET_IPv6
+#  ifdef CONFIG_NET_IPv4
   if (IFF_IS_IPv6(dev->d_flags))
+#  endif
     {
       FAR struct ipv6_hdr_s *ipv6 = IPv6BUF;
 
@@ -218,15 +247,18 @@ uint16_t netdev_upperlayer_header_checksum(FAR struct 
net_driver_s *dev)
                                                  ipv6->proto,
                                                  IPv6_HDRLEN));
     }
+#endif
+#ifdef CONFIG_NET_IPv4
+#  ifdef CONFIG_NET_IPv6
   else
+#  endif
     {
       FAR struct ipv4_hdr_s *ipv4 = IPv4BUF;
 
       return HTONS(ipv4_upperlayer_header_chksum(dev,
                                                  ipv4->proto));
     }
+#endif
 
   return 0;
 }
-
-#endif /* CONFIG_NETDEV_CHECKSUM */

Reply via email to