netdev: delete macro CONFIG_NETDEV_CHECKSUM with nuttx

not need CONFIG_NETDEV_CHECKSUM with nuttx

Signed-off-by: daichuan <daichuan@xiaomi.com>
This commit is contained in:
daichuan
2026-01-19 14:29:59 +08:00
committed by Xiang Xiao
parent 99bf7c3c5f
commit b01f8b04e9
7 changed files with 54 additions and 55 deletions
+4 -13
View File
@@ -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.
-4
View File
@@ -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
-6
View File
@@ -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 */
+1 -3
View File
@@ -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})
-10
View File
@@ -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
-2
View File
@@ -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
+49 -17
View File
@@ -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);
}
else
{
return -EINVAL;
return offsetof(struct udp_hdr_s, udpchksum);
}
#endif
return offset;
#ifdef CONFIG_NET_TCP
if (proto == IP_PROTO_TCP)
{
return offsetof(struct tcp_hdr_s, tcpchksum);
}
#endif
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 */