diff --git a/.gitmodules b/.gitmodules index 06fb7f0e347951..6bc87375ff1ec0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -324,3 +324,7 @@ path = third_party/infineon/psoc6/psoc6_sdk/libs/lwip-network-interface-integration url = https://github.com/Infineon/lwip-network-interface-integration.git platforms = infineon +[submodule "third_party/lwip/repo"] + path = third_party/lwip/repo + url = https://github.com/lwip-tcpip/lwip.git + branch = master diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index c51383a944dc80..c4885bb809f2a9 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -204,6 +204,7 @@ if (current_os == "zephyr" || current_os == "mbed") { if (lwip_platform == "standalone") { public += [ "standalone/arch/sys_arch.h" ] sources += [ "standalone/sys_arch.c" ] + sources += [ "standalone/pbuf_pool_assert.c" ] } else if (lwip_platform == "cyw30739") { } else if (lwip_platform == "mt793x") { } else { @@ -219,8 +220,7 @@ if (current_os == "zephyr" || current_os == "mbed") { public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ] } else if (lwip_platform == "cc32xx") { public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ] - sources += - [ "${chip_root}/third_party/lwip/repo/lwip/src/apps/mdns/mdns.c" ] + sources += [ "${chip_root}/third_party/lwip/repo/src/apps/mdns/mdns.c" ] } else if (lwip_platform == "silabs") { public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] diff --git a/src/lwip/standalone/arch/cc.h b/src/lwip/standalone/arch/cc.h index adeadea3bbacc4..233d491cc0c8fc 100644 --- a/src/lwip/standalone/arch/cc.h +++ b/src/lwip/standalone/arch/cc.h @@ -56,6 +56,10 @@ #define __STDC_LIMIT_MACROS #endif +#if CHIP_HAVE_CONFIG_H +#include +#endif + /* Include some files for defining library routines */ #include #include diff --git a/src/lwip/standalone/lwipopts.h b/src/lwip/standalone/lwipopts.h index 84aa44e1c5c62a..c4fab1ec677739 100644 --- a/src/lwip/standalone/lwipopts.h +++ b/src/lwip/standalone/lwipopts.h @@ -28,10 +28,6 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ -#if CHIP_HAVE_CONFIG_H -#include -#endif - #include /** @@ -137,11 +133,12 @@ * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is * designed to accommodate single full size link-layer frame in one pbuf, including * the link-layer header and any link-layer encapsulation header, and the pbuf - * structure itself. + * structure itself. pbuf struct consists of 2 pointers, 2 u16_t, 4 u8_t. */ #define PBUF_POOL_BUFSIZE \ - LWIP_MEM_ALIGN_SIZE(PAYLOAD_MTU + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf) + 1) + LWIP_MEM_ALIGN_SIZE(PAYLOAD_MTU + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) + \ + LWIP_MEM_ALIGN_SIZE(2 * __SIZEOF_POINTER__ + (2 * 2) + (4 * 1) + 1) /** * TCP_SND_BUF: TCP sender buffer space (bytes). @@ -414,14 +411,6 @@ extern unsigned char gLwIP_DebugFlags; #endif -/** - * The WICED definition of PBUF_POOL_BUFSIZE includes a number of - * sizeof() instantiations which causes the C preprocessor to - * fail. Disable TCP configuration constant sanity checks to work - * around this. - */ -#define LWIP_DISABLE_TCP_SANITY_CHECKS (1) - /** * LwIP defaults the size of most mailboxes (i.e. message queues) to * zero (0). That generally makes RTOSes such as FreeRTOS very diff --git a/src/lwip/standalone/pbuf_pool_assert.c b/src/lwip/standalone/pbuf_pool_assert.c new file mode 100644 index 00000000000000..1e743e25d6377a --- /dev/null +++ b/src/lwip/standalone/pbuf_pool_assert.c @@ -0,0 +1,27 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "lwip/pbuf.h" +#include "lwipopts.h" + +/** + * PBUF_POOL_BUFSIZE, defined in lwipopts.h was previously using sizeof, but as it is used in other preprocessor macros in lwip + * code, it failed. Below is to make sure that current calculation aligns with previous. + */ +_Static_assert((LWIP_MEM_ALIGN_SIZE(2 * __SIZEOF_POINTER__ + (2 * 2) + (4 * 1) + 1) == + LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf) + 1)), + "PBUF_POOL_BUFFSIZE in lwipopts.h needs adjusting."); diff --git a/third_party/lwip/lwip.gni b/third_party/lwip/lwip.gni index 68d776be47472f..720e669510543a 100644 --- a/third_party/lwip/lwip.gni +++ b/third_party/lwip/lwip.gni @@ -19,7 +19,7 @@ import("//build_overrides/lwip.gni") # lwIP depends on external header files to compile. This template defines # a combined build of the lwIP sources plus target configuration. template("lwip_target") { - _lwip_root = "${lwip_root}/repo/lwip" + _lwip_root = "${lwip_root}/repo" lwip_target_name = target_name @@ -29,9 +29,12 @@ template("lwip_target") { "lwip_ipv4", "lwip_ipv6", "lwip_api", + "lwip_bridge", "lwip_ethernet", "lwip_slip", "lwip_6lowpan", + "lwip_6lowpan_ble", + "lwip_zep", ]) if (!defined(lwip_ipv4)) { @@ -43,6 +46,9 @@ template("lwip_target") { if (!defined(lwip_api)) { lwip_api = true } + if (!defined(lwip_bridge)) { + lwip_bridge = false + } if (!defined(lwip_ethernet)) { lwip_ethernet = true } @@ -52,9 +58,18 @@ template("lwip_target") { if (!defined(lwip_6lowpan)) { lwip_6lowpan = false } + if (!defined(lwip_6lowpan_ble)) { + lwip_6lowpan_ble = false + } + if (!defined(lwip_zep)) { + lwip_zep = false + } config("${lwip_target_name}_base_config") { - include_dirs = [ "${lwip_root}/repo/lwip/src/include" ] + include_dirs = [ + "${lwip_root}/repo/src/include", + "${lwip_root}/repo/contrib/addons/ipv6_static_routing/", + ] } source_set(lwip_target_name) { @@ -69,6 +84,11 @@ template("lwip_target") { # lwIP headers become empty if the relevant feature is disabled, so the # whole interface can be public regardless of build options. public += [ + "${_lwip_root}/contrib/addons/ipv6_static_routing/ip6_route_table.h", + "${_lwip_root}/src/include/lwip/acd.h", + "${_lwip_root}/src/include/lwip/altcp.h", + "${_lwip_root}/src/include/lwip/altcp_tcp.h", + "${_lwip_root}/src/include/lwip/altcp_tls.h", "${_lwip_root}/src/include/lwip/api.h", "${_lwip_root}/src/include/lwip/autoip.h", "${_lwip_root}/src/include/lwip/debug.h", @@ -77,21 +97,23 @@ template("lwip_target") { "${_lwip_root}/src/include/lwip/dhcp6.h", "${_lwip_root}/src/include/lwip/dns.h", "${_lwip_root}/src/include/lwip/err.h", + "${_lwip_root}/src/include/lwip/errno.h", "${_lwip_root}/src/include/lwip/etharp.h", "${_lwip_root}/src/include/lwip/ethip6.h", "${_lwip_root}/src/include/lwip/icmp.h", "${_lwip_root}/src/include/lwip/icmp6.h", - "${_lwip_root}/src/include/lwip/if.h", + "${_lwip_root}/src/include/lwip/if_api.h", "${_lwip_root}/src/include/lwip/igmp.h", "${_lwip_root}/src/include/lwip/inet.h", "${_lwip_root}/src/include/lwip/inet_chksum.h", "${_lwip_root}/src/include/lwip/init.h", "${_lwip_root}/src/include/lwip/ip.h", + "${_lwip_root}/src/include/lwip/ip4_addr.h", "${_lwip_root}/src/include/lwip/ip4_frag.h", "${_lwip_root}/src/include/lwip/ip6.h", "${_lwip_root}/src/include/lwip/ip6_addr.h", "${_lwip_root}/src/include/lwip/ip6_frag.h", - "${_lwip_root}/src/include/lwip/ip6_route_table.h", + "${_lwip_root}/src/include/lwip/ip6_zone.h", "${_lwip_root}/src/include/lwip/ip_addr.h", "${_lwip_root}/src/include/lwip/mem.h", "${_lwip_root}/src/include/lwip/memp.h", @@ -103,28 +125,62 @@ template("lwip_target") { "${_lwip_root}/src/include/lwip/netifapi.h", "${_lwip_root}/src/include/lwip/opt.h", "${_lwip_root}/src/include/lwip/pbuf.h", + "${_lwip_root}/src/include/lwip/priv/altcp_priv.h", + "${_lwip_root}/src/include/lwip/priv/api_msg.h", + "${_lwip_root}/src/include/lwip/priv/mem_priv.h", + "${_lwip_root}/src/include/lwip/priv/memp_priv.h", + "${_lwip_root}/src/include/lwip/priv/memp_std.h", + "${_lwip_root}/src/include/lwip/priv/nd6_priv.h", + "${_lwip_root}/src/include/lwip/priv/raw_priv.h", + "${_lwip_root}/src/include/lwip/priv/sockets_priv.h", "${_lwip_root}/src/include/lwip/priv/tcp_priv.h", "${_lwip_root}/src/include/lwip/priv/tcpip_priv.h", + "${_lwip_root}/src/include/lwip/prot/acd.h", "${_lwip_root}/src/include/lwip/prot/autoip.h", "${_lwip_root}/src/include/lwip/prot/dhcp.h", + "${_lwip_root}/src/include/lwip/prot/dhcp6.h", "${_lwip_root}/src/include/lwip/prot/dns.h", + "${_lwip_root}/src/include/lwip/prot/etharp.h", "${_lwip_root}/src/include/lwip/prot/ethernet.h", + "${_lwip_root}/src/include/lwip/prot/iana.h", "${_lwip_root}/src/include/lwip/prot/icmp6.h", + "${_lwip_root}/src/include/lwip/prot/ieee.h", "${_lwip_root}/src/include/lwip/prot/igmp.h", + "${_lwip_root}/src/include/lwip/prot/ip.h", + "${_lwip_root}/src/include/lwip/prot/ip4.h", + "${_lwip_root}/src/include/lwip/prot/ip6.h", "${_lwip_root}/src/include/lwip/prot/mld6.h", "${_lwip_root}/src/include/lwip/prot/nd6.h", + "${_lwip_root}/src/include/lwip/prot/tcp.h", + "${_lwip_root}/src/include/lwip/prot/udp.h", "${_lwip_root}/src/include/lwip/raw.h", + "${_lwip_root}/src/include/lwip/sio.h", "${_lwip_root}/src/include/lwip/snmp.h", "${_lwip_root}/src/include/lwip/sockets.h", "${_lwip_root}/src/include/lwip/stats.h", "${_lwip_root}/src/include/lwip/sys.h", "${_lwip_root}/src/include/lwip/tcp.h", + "${_lwip_root}/src/include/lwip/tcpbase.h", "${_lwip_root}/src/include/lwip/tcpip.h", "${_lwip_root}/src/include/lwip/timeouts.h", "${_lwip_root}/src/include/lwip/udp.h", + "${_lwip_root}/src/include/netif/bridgeif.h", + "${_lwip_root}/src/include/netif/bridgeif_opts.h", + "${_lwip_root}/src/include/netif/etharp.h", + "${_lwip_root}/src/include/netif/ethernet.h", + "${_lwip_root}/src/include/netif/ieee802154.h", + "${_lwip_root}/src/include/netif/lowpan6.h", + "${_lwip_root}/src/include/netif/lowpan6_ble.h", + "${_lwip_root}/src/include/netif/lowpan6_common.h", + "${_lwip_root}/src/include/netif/lowpan6_opts.h", + "${_lwip_root}/src/include/netif/slipif.h", + "${_lwip_root}/src/include/netif/zepif.h", ] sources += [ + "${_lwip_root}/src/core/altcp.c", + "${_lwip_root}/src/core/altcp_alloc.c", + "${_lwip_root}/src/core/altcp_tcp.c", "${_lwip_root}/src/core/def.c", "${_lwip_root}/src/core/dns.c", "${_lwip_root}/src/core/inet_chksum.c", @@ -142,13 +198,11 @@ template("lwip_target") { "${_lwip_root}/src/core/tcp_out.c", "${_lwip_root}/src/core/timeouts.c", "${_lwip_root}/src/core/udp.c", - "${_lwip_root}/src/include/lwip/priv/api_msg.h", - "${_lwip_root}/src/include/lwip/priv/memp_std.h", - "${_lwip_root}/src/include/lwip/priv/nd6_priv.h", ] if (lwip_ipv4) { sources += [ + "${_lwip_root}/src/core/ipv4/acd.c", "${_lwip_root}/src/core/ipv4/autoip.c", "${_lwip_root}/src/core/ipv4/dhcp.c", "${_lwip_root}/src/core/ipv4/etharp.c", @@ -162,6 +216,7 @@ template("lwip_target") { if (lwip_ipv6) { sources += [ + "${_lwip_root}/contrib/addons/ipv6_static_routing/ip6_route_table.c", "${_lwip_root}/src/core/ipv6/dhcp6.c", "${_lwip_root}/src/core/ipv6/ethip6.c", "${_lwip_root}/src/core/ipv6/icmp6.c", @@ -169,7 +224,6 @@ template("lwip_target") { "${_lwip_root}/src/core/ipv6/ip6.c", "${_lwip_root}/src/core/ipv6/ip6_addr.c", "${_lwip_root}/src/core/ipv6/ip6_frag.c", - "${_lwip_root}/src/core/ipv6/ip6_route_table.c", "${_lwip_root}/src/core/ipv6/mld6.c", "${_lwip_root}/src/core/ipv6/nd6.c", ] @@ -180,7 +234,7 @@ template("lwip_target") { "${_lwip_root}/src/api/api_lib.c", "${_lwip_root}/src/api/api_msg.c", "${_lwip_root}/src/api/err.c", - "${_lwip_root}/src/api/if.c", + "${_lwip_root}/src/api/if_api.c", "${_lwip_root}/src/api/netbuf.c", "${_lwip_root}/src/api/netdb.c", "${_lwip_root}/src/api/netifapi.c", @@ -189,6 +243,13 @@ template("lwip_target") { ] } + if (lwip_bridge) { + sources += [ + "${_lwip_root}/src/netif/bridgeif.c", + "${_lwip_root}/src/netif/bridgeif_fdb.c", + ] + } + if (lwip_ethernet) { sources += [ "${_lwip_root}/src/netif/ethernet.c" ] } @@ -198,7 +259,21 @@ template("lwip_target") { } if (lwip_6lowpan) { - sources += [ "${_lwip_root}/src/netif/lowpan6.c" ] + sources += [ + "${_lwip_root}/src/netif/lowpan6.c", + "${_lwip_root}/src/netif/lowpan6_common.c", + ] + } + + if (lwip_6lowpan_ble) { + sources += [ + "${_lwip_root}/src/netif/lowpan6_ble.c", + "${_lwip_root}/src/netif/lowpan6_common.c", + ] + } + + if (lwip_zep) { + sources += [ "${_lwip_root}/src/netif/zepif.c" ] } if (defined(lwip_remove_configs)) { diff --git a/third_party/lwip/repo b/third_party/lwip/repo new file mode 160000 index 00000000000000..84fde1ebbfe35b --- /dev/null +++ b/third_party/lwip/repo @@ -0,0 +1 @@ +Subproject commit 84fde1ebbfe35b3125fc2d89b8a456cbacf148e9