diff mbox series

[v2,01/14] net: introduce alternative implementation as net-lwip/

Message ID 923f66b4a74d9c91c6d661e96dced8e1cbcdc7e0.1716566960.git.jerome.forissier@linaro.org
State New
Headers show
Series Introduce the lwIP network stack | expand

Commit Message

Jerome Forissier May 24, 2024, 4:19 p.m. UTC
Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by
adding a new net-lwip/ directory and the NET_LWIP symbol. At this
point, enabling NET_LWIP simply disables NET. Subsequent commits will
introduce the lwIP code, re-work the NETDEVICE integration and port
some of the NET commands and features to lwIP.

SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols
that are part of NET (such as arp_init(), arp_timeout_check(),
arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be
added later.

Similarly, DFU_TFTP is not compatible with NET_LWIP because it depends
on net_loop(), tftp_timeout_ms, tftp_timeout_count_max. Let's add a
dependency on !NET_LWIP for now.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 Kconfig                    |  2 ++
 Makefile                   |  2 +-
 common/Kconfig             |  2 +-
 common/spl/Kconfig         |  1 +
 drivers/dfu/Kconfig        |  2 +-
 drivers/fastboot/Kconfig   |  4 ++--
 drivers/net/phy/Kconfig    |  2 +-
 drivers/usb/gadget/Kconfig |  2 +-
 net-lwip/Kconfig           | 15 +++++++++++++++
 net/Kconfig                |  1 +
 10 files changed, 26 insertions(+), 7 deletions(-)
 create mode 100644 net-lwip/Kconfig

Comments

Tom Rini May 27, 2024, 3:34 p.m. UTC | #1
On Fri, May 24, 2024 at 06:19:55PM +0200, Jerome Forissier wrote:

> Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by
> adding a new net-lwip/ directory and the NET_LWIP symbol. At this
> point, enabling NET_LWIP simply disables NET. Subsequent commits will
> introduce the lwIP code, re-work the NETDEVICE integration and port
> some of the NET commands and features to lwIP.
> 
> SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols
> that are part of NET (such as arp_init(), arp_timeout_check(),
> arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be
> added later.
> 
> Similarly, DFU_TFTP is not compatible with NET_LWIP because it depends
> on net_loop(), tftp_timeout_ms, tftp_timeout_count_max. Let's add a
> dependency on !NET_LWIP for now.
> 
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
[snip]
> diff --git a/Kconfig b/Kconfig
> index 82df59f176e..758256ab121 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -747,6 +747,8 @@ source "env/Kconfig"
>  
>  source "net/Kconfig"
>  
> +source "net-lwip/Kconfig"
> +
>  source "drivers/Kconfig"
>  
>  source "fs/Kconfig"

I think we need to instead rework this to a choice statement instead so
that in the end we have something like:
choice "Networking stack"
config NO_NET
  bool "No networking support"
config NET
  bool "Legacy U-Boot networking stack"
config NET_LWIP
  bool "Use lwIP for networking stack"

if NET_LEGACY
source "net/Kconfig"
endif

if NET_LWIP
source "net-lwip/Kconfig"
endif

And then SPL_NET still depends on !NET_LWIP for now and we sort out the
problems with different networking stacks in SPL vs full U-Boot later
on.
Ilias Apalodimas May 28, 2024, 11:53 a.m. UTC | #2
On Mon, May 27, 2024 at 09:34:34AM -0600, Tom Rini wrote:
> On Fri, May 24, 2024 at 06:19:55PM +0200, Jerome Forissier wrote:
>
> > Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by
> > adding a new net-lwip/ directory and the NET_LWIP symbol. At this
> > point, enabling NET_LWIP simply disables NET. Subsequent commits will
> > introduce the lwIP code, re-work the NETDEVICE integration and port
> > some of the NET commands and features to lwIP.
> >
> > SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols
> > that are part of NET (such as arp_init(), arp_timeout_check(),
> > arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be
> > added later.
> >
> > Similarly, DFU_TFTP is not compatible with NET_LWIP because it depends
> > on net_loop(), tftp_timeout_ms, tftp_timeout_count_max. Let's add a
> > dependency on !NET_LWIP for now.
> >
> > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> [snip]
> > diff --git a/Kconfig b/Kconfig
> > index 82df59f176e..758256ab121 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -747,6 +747,8 @@ source "env/Kconfig"
> >
> >  source "net/Kconfig"
> >
> > +source "net-lwip/Kconfig"
> > +
> >  source "drivers/Kconfig"
> >
> >  source "fs/Kconfig"
>
> I think we need to instead rework this to a choice statement instead so
> that in the end we have something like:

+ 1

> choice "Networking stack"
> config NO_NET
>   bool "No networking support"
> config NET
>   bool "Legacy U-Boot networking stack"
> config NET_LWIP
>   bool "Use lwIP for networking stack"
>
> if NET_LEGACY
> source "net/Kconfig"
> endif
>
> if NET_LWIP
> source "net-lwip/Kconfig"
> endif
>
> And then SPL_NET still depends on !NET_LWIP for now and we sort out the
> problems with different networking stacks in SPL vs full U-Boot later
> on.

That's an excellent idea tbh. We can now decouple SPL and u-boot proper
using different stacks and fix the more difficult to debug SPL issues in
time. Once we feel happy we can switch over to LWIP completely

Thanks
/Ilias
>
> --
> Tom
Jerome Forissier June 5, 2024, 5:48 p.m. UTC | #3
On 5/27/24 17:34, Tom Rini wrote:
> On Fri, May 24, 2024 at 06:19:55PM +0200, Jerome Forissier wrote:
> 
>> Prepare the introduction of the lwIP (lightweight IP) TCP/IP stack by
>> adding a new net-lwip/ directory and the NET_LWIP symbol. At this
>> point, enabling NET_LWIP simply disables NET. Subsequent commits will
>> introduce the lwIP code, re-work the NETDEVICE integration and port
>> some of the NET commands and features to lwIP.
>>
>> SPL_NET cannot be enabled when NET_LWIP=y. SPL_NET pulls some symbols
>> that are part of NET (such as arp_init(), arp_timeout_check(),
>> arp_receive(), net_arp_wait_packet_ip()). lwIP support in SPL may be
>> added later.
>>
>> Similarly, DFU_TFTP is not compatible with NET_LWIP because it depends
>> on net_loop(), tftp_timeout_ms, tftp_timeout_count_max. Let's add a
>> dependency on !NET_LWIP for now.
>>
>> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> [snip]
>> diff --git a/Kconfig b/Kconfig
>> index 82df59f176e..758256ab121 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -747,6 +747,8 @@ source "env/Kconfig"
>>  
>>  source "net/Kconfig"
>>  
>> +source "net-lwip/Kconfig"
>> +
>>  source "drivers/Kconfig"
>>  
>>  source "fs/Kconfig"
> 
> I think we need to instead rework this to a choice statement instead so
> that in the end we have something like:
> choice "Networking stack"
> config NO_NET
>   bool "No networking support"
> config NET
>   bool "Legacy U-Boot networking stack"
> config NET_LWIP
>   bool "Use lwIP for networking stack"
> 
> if NET_LEGACY
> source "net/Kconfig"
> endif
> 
> if NET_LWIP
> source "net-lwip/Kconfig"
> endif
> 
> And then SPL_NET still depends on !NET_LWIP for now and we sort out the
> problems with different networking stacks in SPL vs full U-Boot later
> on.

Done in v3. Thanks.
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 82df59f176e..758256ab121 100644
--- a/Kconfig
+++ b/Kconfig
@@ -747,6 +747,8 @@  source "env/Kconfig"
 
 source "net/Kconfig"
 
+source "net-lwip/Kconfig"
+
 source "drivers/Kconfig"
 
 source "fs/Kconfig"
diff --git a/Makefile b/Makefile
index 79b28c2d81f..3df9c45a17c 100644
--- a/Makefile
+++ b/Makefile
@@ -859,7 +859,7 @@  libs-$(CONFIG_OF_EMBED) += dts/
 libs-y += env/
 libs-y += lib/
 libs-y += fs/
-libs-y += net/
+libs-$(CONFIG_NET) += net/
 libs-y += disk/
 libs-y += drivers/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
diff --git a/common/Kconfig b/common/Kconfig
index 5e3070e9253..807b726384d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -424,7 +424,7 @@  config LOGF_FUNC_PAD
 
 config LOG_SYSLOG
 	bool "Log output to syslog server"
-	depends on NET
+	depends on NET || NET_LWIP
 	help
 	  Enables a log driver which broadcasts log records via UDP port 514
 	  to syslog servers.
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 6405374bcc1..f67f0a859db 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1055,6 +1055,7 @@  config SPL_DM_SPI_FLASH
 
 config SPL_NET
 	bool "Support networking"
+	depends on !NET_LWIP
 	help
 	  Enable support for network devices (such as Ethernet) in SPL.
 	  This permits SPL to load U-Boot over a network link rather than
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 0360d9da142..c6bce82eb10 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -11,7 +11,7 @@  config DFU_OVER_USB
 
 config DFU_OVER_TFTP
 	bool
-	depends on NET
+	depends on NET && !NET_LWIP
 
 if DFU
 config DFU_WRITE_ALT
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 70207573de2..05e988166fb 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -27,7 +27,7 @@  config USB_FUNCTION_FASTBOOT
 	  This enables the USB part of the fastboot gadget.
 
 config UDP_FUNCTION_FASTBOOT
-	depends on NET
+	depends on NET || NET_LWIP
 	select FASTBOOT
 	bool "Enable fastboot protocol over UDP"
 	help
@@ -41,7 +41,7 @@  config UDP_FUNCTION_FASTBOOT_PORT
 	  The fastboot protocol requires a UDP port number.
 
 config TCP_FUNCTION_FASTBOOT
-	depends on NET
+	depends on NET || NET_LWIP
 	select FASTBOOT
 	bool "Enable fastboot protocol over TCP"
 	help
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 3d96938eaba..738752d29c2 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -11,7 +11,7 @@  config MV88E6352_SWITCH
 
 menuconfig PHYLIB
 	bool "Ethernet PHY (physical media interface) support"
-	depends on NET
+	depends on NET || NET_LWIP
 	help
 	  Enable Ethernet PHY (physical media interface) support.
 
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 4621a6fd5e6..03fe3bca197 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -224,7 +224,7 @@  endif # USB_GADGET_DOWNLOAD
 
 config USB_ETHER
 	bool "USB Ethernet Gadget"
-	depends on NET
+	depends on NET || NET_LWIP
 	default y if ARCH_SUNXI && USB_MUSB_GADGET
 	help
 	  Creates an Ethernet network device through a USB peripheral
diff --git a/net-lwip/Kconfig b/net-lwip/Kconfig
new file mode 100644
index 00000000000..f8e0481964f
--- /dev/null
+++ b/net-lwip/Kconfig
@@ -0,0 +1,15 @@ 
+#
+# Network configuration (with lwIP stack)
+#
+
+menuconfig NET_LWIP
+	bool "Networking support (lwIP stack) -- EXPERIMENTAL"
+	help
+	  Include networking support based on the lwIP (lightweight IP)
+	  TCP/IP stack (https://nongnu.org/lwip). This is a replacement for
+	  the default U-Boot network stack and applications located in net/
+	  and enabled via CONFIG_NET as well as other pieces of code that
+	  depend on CONFIG_NET (such as cmd/net.c enabled via CONFIG_CMD_NET).
+	  Therefore the two symbols CONFIG_NET and CONFIG_NET_LWIP are mutually
+	  exclusive.
+	  NOTE: This is currently a placeholder.
diff --git a/net/Kconfig b/net/Kconfig
index 5dff6336293..04b81dd4976 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -6,6 +6,7 @@  menuconfig NET
 	bool "Networking support"
 	default y
 	imply NETDEVICES
+	depends on !NET_LWIP
 
 if NET