Skip to content

Commit

Permalink
Re-add lwip as git submodule
Browse files Browse the repository at this point in the history
Checked out to lastest release as it includes fix applied in Matter
repository as well as some stuff referred to in repository issues.

PBUF_POOL_BUFSIZE does not use sizeof anymore (it is used in one if in
the lwip upstream code). Additionally removed turning off sanity checks
that were necessary due to aforementioned sizeof usage.

Added LwIPLog to Bouffalolab Logging as I couldnt find it defined
anywhere for this platform.

Signed-off-by: Alexander Mazuruk <[email protected]>
  • Loading branch information
aalexanderr committed Feb 22, 2024
1 parent e7f08eb commit 2398817
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/lwip/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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" ]

Expand Down
4 changes: 4 additions & 0 deletions src/lwip/standalone/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
#define __STDC_LIMIT_MACROS
#endif

#if CHIP_HAVE_CONFIG_H
#include <lwip/lwip_buildconfig.h>
#endif

/* Include some files for defining library routines */
#include <inttypes.h>
#include <limits.h>
Expand Down
17 changes: 3 additions & 14 deletions src/lwip/standalone/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__

#if CHIP_HAVE_CONFIG_H
#include <lwip/lwip_buildconfig.h>
#endif

#include <stdlib.h>

/**
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions src/lwip/standalone/pbuf_pool_assert.c
Original file line number Diff line number Diff line change
@@ -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.");
95 changes: 85 additions & 10 deletions third_party/lwip/lwip.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)) {
Expand All @@ -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
}
Expand All @@ -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) {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -162,14 +216,14 @@ 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",
"${_lwip_root}/src/core/ipv6/inet6.c",
"${_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",
]
Expand All @@ -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",
Expand All @@ -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" ]
}
Expand All @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions third_party/lwip/repo
Submodule repo added at 84fde1

0 comments on commit 2398817

Please sign in to comment.