Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
On Sun, Jun 11, 2023 at 09:24:14AM +0100, Simon Glass wrote: > Hi, > > On Wed, 7 Jun 2023 at 10:47, Ilias Apalodimas > wrote: > > > > Hi Maxim, > > > > On Tue, 6 Jun 2023 at 17:33, Maxim Uvarov wrote: > > > > > > Greetings, > > > > > > I implemented the tftp client (that was quick due to lwip has example app > > > for tftp), and did some more measurements. > > > I uploaded patches here if somebody want to do his own measurements: > > > https://github.com/muvarov/uboot-lwip > > > > > > measure 1: > > > 976K - total (total means lwip with all 3 commands ping, tftp, wget) > > > 971K - total - tftp (total, but disable/minus tftp) > > > 965K - total - tftp - wget (disable tftp and wget) > > > 963K - total - tftp - wget - ping (disable tftp, wget, ping) > > > 931K - no lwip > > > > > > result 1: lwip tftp (+ udp protocol) protocol 976-971k = 5kb > > > result 2: lwip ping command 965- 963 = 2kb > > > result 3: lwip wget command 971- 965 = 6kb > > > result 4: lwip core stack with apps 976 - 931 = 45kb > > > > So tftp = 5kb, wget = 6kb ping =2kb and lwip = 32kb > > > > > > > > measure 2: > > > 890K - no CONFIG_NET_CMD > > > 930K - + lwip tftp only > > > 937K - + full lwip (ping wget tftp) > > > > > > result 1: 937-890=47kb ( lwip + all 3 commands) > > > result 2: 937-930=7kb (ping and lwip command) > > > > I am not sure I understand this measurement. How is this different > > from measurement 1 where the entire binary was 976K? > > > > > > > > measure 3: > > > 904K - no lwip, CMD_NET_TFTP=y > > > 900K - no lwip, CMD_NET_TFTP=n > > > result 1: original u-boot tftp command 904-900=4kb > > > 890K - no lwip, CMD_NET=n > > > result 2: 900-890=10k original u-boot net/IP stack. > > > > > > My findings for all that measurements and lwip configuration: > > > 1. The original u-boot net stack (packet process and up layers) is 10k vs > > > lwip 40k (the very minimal settings were 30k). > > > 2. Network applications size is about the same 4kb for tftp original > > > command 5kb for lwip. > > > 3. It's quite easy to reuse LWIP examples to implement the same > > > functionality for the U-boot. > > > 4. I still think that there are other criterias which might have more > > > priority than size (bug free code, code reuse, development speed, > > > compatible API to posix and etc). > > > > Yes, there are other criteria and certainly having a complete network > > stack might be worth it in many cases, but we need to keep in mind > > 30kb might be a lot for some systems. > > > > I personally think this is decent and we can optimize lwip more in the > > future. Tom, Simon, how about adding lwip as 'experimental' and > > making it depend on !CMD_NET or something similar? > > That seems OK to me, but we don't really want two network stacks, so > we'd need to set an expectation that we would move to lwip. Yes, we'll need to move on to evaluating that once we can show and use lwip as a replacement for most cases. > I wonder why it is so large? I saw mention of it supporting multiple > buffers and perhaps having a fuller implementation of the protocols. > But it makes U-Boot's stack seem super-slim in comparison. I wonder if > lwip could support just a single buffer and reduced functionality in > other areas? Well, right. Seeing what space related tuneables we can introduce and/or further tune down will be of interest. But that will be easier to do once it's easier to try out lwip in U-Boot itself. -- Tom signature.asc Description: PGP signature
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Hi, On Wed, 7 Jun 2023 at 10:47, Ilias Apalodimas wrote: > > Hi Maxim, > > On Tue, 6 Jun 2023 at 17:33, Maxim Uvarov wrote: > > > > Greetings, > > > > I implemented the tftp client (that was quick due to lwip has example app > > for tftp), and did some more measurements. > > I uploaded patches here if somebody want to do his own measurements: > > https://github.com/muvarov/uboot-lwip > > > > measure 1: > > 976K - total (total means lwip with all 3 commands ping, tftp, wget) > > 971K - total - tftp (total, but disable/minus tftp) > > 965K - total - tftp - wget (disable tftp and wget) > > 963K - total - tftp - wget - ping (disable tftp, wget, ping) > > 931K - no lwip > > > > result 1: lwip tftp (+ udp protocol) protocol 976-971k = 5kb > > result 2: lwip ping command 965- 963 = 2kb > > result 3: lwip wget command 971- 965 = 6kb > > result 4: lwip core stack with apps 976 - 931 = 45kb > > So tftp = 5kb, wget = 6kb ping =2kb and lwip = 32kb > > > > > measure 2: > > 890K - no CONFIG_NET_CMD > > 930K - + lwip tftp only > > 937K - + full lwip (ping wget tftp) > > > > result 1: 937-890=47kb ( lwip + all 3 commands) > > result 2: 937-930=7kb (ping and lwip command) > > I am not sure I understand this measurement. How is this different > from measurement 1 where the entire binary was 976K? > > > > > measure 3: > > 904K - no lwip, CMD_NET_TFTP=y > > 900K - no lwip, CMD_NET_TFTP=n > > result 1: original u-boot tftp command 904-900=4kb > > 890K - no lwip, CMD_NET=n > > result 2: 900-890=10k original u-boot net/IP stack. > > > > My findings for all that measurements and lwip configuration: > > 1. The original u-boot net stack (packet process and up layers) is 10k vs > > lwip 40k (the very minimal settings were 30k). > > 2. Network applications size is about the same 4kb for tftp original > > command 5kb for lwip. > > 3. It's quite easy to reuse LWIP examples to implement the same > > functionality for the U-boot. > > 4. I still think that there are other criterias which might have more > > priority than size (bug free code, code reuse, development speed, > > compatible API to posix and etc). > > Yes, there are other criteria and certainly having a complete network > stack might be worth it in many cases, but we need to keep in mind > 30kb might be a lot for some systems. > > I personally think this is decent and we can optimize lwip more in the > future. Tom, Simon, how about adding lwip as 'experimental' and > making it depend on !CMD_NET or something similar? That seems OK to me, but we don't really want two network stacks, so we'd need to set an expectation that we would move to lwip. I wonder why it is so large? I saw mention of it supporting multiple buffers and perhaps having a fuller implementation of the protocols. But it makes U-Boot's stack seem super-slim in comparison. I wonder if lwip could support just a single buffer and reduced functionality in other areas? Regards, Simon > > Thanks > /Ilias > > > > BR, > > Maxim. > > > > On Thu, 25 May 2023 at 02:18, Simon Goldschmidt wrote: > >> > >> Hi Maxim, Tom, > >> > >> On 24.05.2023 16:05, Maxim Uvarov wrote: > >> > On Tue, 23 May 2023 at 03:23, Tom Rini wrote: > >> > > >> >> On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > >> >>> On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > >> >>> > >> On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > >> > Hi Maxim > >> > > >> > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > >> wrote: > >> >> > >> >> My measurements for binary after LTO looks like: > >> >> > >> >> U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > >> >> 870728| 915000| 912560 | > >> 41832| 4.8 > >> > > >> > > >> > I think you'll need to analyze that a bit more. First of all I don't > >> > think the '+ping' tab is useful. What is is trying to achieve? > >> > >> >>> > >> >>> To show the difference of extra bytes if we add a ping app on top. > >> >>> > >> >>> > >> > - How was LWIP compiled? > >> > >> >>> > >> >>> It has a really huge configuration. I tried to turn off everything off > >> >>> everything what can impact on size but still make http app work: > >> >>> #define LWIP_HAVE_LOOPIF0 > >> >>> #define LWIP_NETCONN0 > >> >>> #define LWIP_SOCKET 0 > >> >>> #define SO_REUSE0 > >> >>> #define LWIP_STATS 0 > >> >>> #define PPP_SUPPORT 0 > >> >>> > >> >>> Disabling loopback: > >> >>> #define LWIP_NETIF_LOOPBACK 0 > >> >>> can lower to 912288 bytes. > >> >>> > >> >>> And it's the same compilation option (optimization for size) as the > >> >>> main > >> >>> u-boot. I will do more experiments, but I think the goal is not to turn > >> >> off > >> >>> everything. > >> >>> > >> >>> > >> > - Was ipv6 supported? > >> > >> >>> > >> >>> No. I.e. when
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
On Thu, Jun 8, 2023 at 6:56 PM Ilias Apalodimas wrote: > > Thanks Maxim, > > On Thu, 8 Jun 2023 at 13:14, Maxim Uvarov wrote: > > > > Ilias asked to make more clear results to compare the original stack and > > LWIP stack. So the difference between the current U-boot stack and the LWIP > > stack with 3 network commands is: > > a) 18Kb - ls -lh size > > b) 15Kb - bloat-o-meter script total line report. > > > > BOM=linux/scripts/bloat-o-meter (script) > > > > 1. 893K - U-boot CMD_NET=n > > 2. 928K - U-boot CMD_NET=y TFTP=y PING=y WGET=y > > BOM 1-2: Total: Before=692286, After=722283, chg +4.33% > > 3. 940K - U-boot CMD_NET=n, LWIP_TFTP=y LWIP_PING=y LWIP_PING=y > > BOM 1-3: Total: Before=692286, After=738425, chg +6.66% > > That's much more readable! I discussed this with Tom over IRC and the > size difference is certainly a reasonable trade-off for the extra > functionality. Yes, this looks great! I'm also sure with a closer look there could be further optimisations here in time as well. I feel having a widely used IP stack that's also widely audited is a big win here, it will also provide things like HTTP, DNS and IPv6 without having to reinvent the wheel. > Can you tidy up the series and include DHCP and PXE done through LWIP? I'll look forward to this. > Thanks > /Ilias > > > > BOM 2-3: > > > > add/remove: 287/203 grow/shrink: 3/11 up/down: 43459/-27317 (16142) > > Function old new delta > > tcp_input -3588 +3588 > > tcp_receive-2884 +2884 > > ip4_reass -1760 +1760 > > tcp_output -1400 +1400 > > tcp_write -1300 +1300 > > tcp_slowtmr-1172 +1172 > > httpc_tcp_recv -1044 +1044 > > tftp_recv - 888+888 > > ip4_input - 700+700 > > ip4_frag - 632+632 > > icmp_input - 604+604 > > udp_input - 596+596 > > etharp_input - 512+512 > > tcp_split_unsent_seg - 500+500 > > ip4addr_aton - 492+492 > > tcp_alloc - 484+484 > > ip4_output_if_src - 476+476 > > tcp_close_shutdown - 448+448 > > etharp_query - 436+436 > > httpc_init_connection_common.constprop - 416+416 > > udp_sendto_if_src - 408+408 > > etharp_output - 404+404 > > arp_table - 400+400 > > tcp_connect- 396+396 > > pbuf_alloc - 376+376 > > etharp_find_entry - 372+372 > > tcp_abandon- 368+368 > > tcp_zero_window_probe - 356+356 > > raw_sendto_if_src - 328+328 > > pbuf_copy_partial_pbuf - 328+328 > > ip_reass_free_complete_datagram- 328+328 > > tcp_create_segment - 300+300 > > raw_input - 292+292 > > uboot_lwip_init- 284+284 > > ethernet_input - 284+284 > > etharp_raw - 284+284 > > tcp_output_alloc_header_common.constprop - 280+280 > > cmds - 280+280 > > udp_bind - 276+276 > > tcp_oos_insert_segment - 276+276 > > ip_reass_remove_oldest_datagram- 272+272 > > icmp_send_response - 268+268 > > netif_add - 260+260 > > ping_send - 244+244 > > tcp_rexmit - 232+232 > > tcp_parseopt - 220+220 > > tcp_free_acked_segments.constprop - 220+220 > > send_request - 220+220 > > inet_chksum_pseudo - 216+216 > > ip4addr_ntoa_r - 212+212 > > do_lwip_ping - 212+212 > >
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Thanks Maxim, On Thu, 8 Jun 2023 at 13:14, Maxim Uvarov wrote: > > Ilias asked to make more clear results to compare the original stack and LWIP > stack. So the difference between the current U-boot stack and the LWIP stack > with 3 network commands is: > a) 18Kb - ls -lh size > b) 15Kb - bloat-o-meter script total line report. > > BOM=linux/scripts/bloat-o-meter (script) > > 1. 893K - U-boot CMD_NET=n > 2. 928K - U-boot CMD_NET=y TFTP=y PING=y WGET=y > BOM 1-2: Total: Before=692286, After=722283, chg +4.33% > 3. 940K - U-boot CMD_NET=n, LWIP_TFTP=y LWIP_PING=y LWIP_PING=y > BOM 1-3: Total: Before=692286, After=738425, chg +6.66% That's much more readable! I discussed this with Tom over IRC and the size difference is certainly a reasonable trade-off for the extra functionality. Can you tidy up the series and include DHCP and PXE done through LWIP? Thanks /Ilias > > BOM 2-3: > > add/remove: 287/203 grow/shrink: 3/11 up/down: 43459/-27317 (16142) > Function old new delta > tcp_input -3588 +3588 > tcp_receive-2884 +2884 > ip4_reass -1760 +1760 > tcp_output -1400 +1400 > tcp_write -1300 +1300 > tcp_slowtmr-1172 +1172 > httpc_tcp_recv -1044 +1044 > tftp_recv - 888+888 > ip4_input - 700+700 > ip4_frag - 632+632 > icmp_input - 604+604 > udp_input - 596+596 > etharp_input - 512+512 > tcp_split_unsent_seg - 500+500 > ip4addr_aton - 492+492 > tcp_alloc - 484+484 > ip4_output_if_src - 476+476 > tcp_close_shutdown - 448+448 > etharp_query - 436+436 > httpc_init_connection_common.constprop - 416+416 > udp_sendto_if_src - 408+408 > etharp_output - 404+404 > arp_table - 400+400 > tcp_connect- 396+396 > pbuf_alloc - 376+376 > etharp_find_entry - 372+372 > tcp_abandon- 368+368 > tcp_zero_window_probe - 356+356 > raw_sendto_if_src - 328+328 > pbuf_copy_partial_pbuf - 328+328 > ip_reass_free_complete_datagram- 328+328 > tcp_create_segment - 300+300 > raw_input - 292+292 > uboot_lwip_init- 284+284 > ethernet_input - 284+284 > etharp_raw - 284+284 > tcp_output_alloc_header_common.constprop - 280+280 > cmds - 280+280 > udp_bind - 276+276 > tcp_oos_insert_segment - 276+276 > ip_reass_remove_oldest_datagram- 272+272 > icmp_send_response - 268+268 > netif_add - 260+260 > ping_send - 244+244 > tcp_rexmit - 232+232 > tcp_parseopt - 220+220 > tcp_free_acked_segments.constprop - 220+220 > send_request - 220+220 > inet_chksum_pseudo - 216+216 > ip4addr_ntoa_r - 212+212 > do_lwip_ping - 212+212 > tcp_enqueue_flags - 208+208 > etharp_output_to_arp_index - 208+208 > netif_set_addr - 204+204 > tcp_fasttmr- 200+200 > tcp_rexmit_rto_prepare - 196+196 > tcp_process_refused_data - 196+196 > send_data - 196+196 > lwip_wget - 192+192 >
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Ilias asked to make more clear results to compare the original stack and LWIP stack. So the difference between the current U-boot stack and the LWIP stack with 3 network commands is: a) 18Kb - ls -lh size b) 15Kb - bloat-o-meter script total line report. BOM=linux/scripts/bloat-o-meter (script) 1. 893K - U-boot CMD_NET=n 2. 928K - U-boot CMD_NET=y TFTP=y PING=y WGET=y BOM 1-2: Total: Before=692286, After=722283, chg +4.33% 3. 940K - U-boot CMD_NET=n, LWIP_TFTP=y LWIP_PING=y LWIP_PING=y BOM 1-3: Total: Before=692286, After=738425, chg +6.66% BOM 2-3: add/remove: 287/203 grow/shrink: 3/11 up/down: 43459/-27317 (16142) Function old new delta tcp_input -3588 +3588 tcp_receive-2884 +2884 ip4_reass -1760 +1760 tcp_output -1400 +1400 tcp_write -1300 +1300 tcp_slowtmr-1172 +1172 httpc_tcp_recv -1044 +1044 tftp_recv - 888+888 ip4_input - 700+700 ip4_frag - 632+632 icmp_input - 604+604 udp_input - 596+596 etharp_input - 512+512 tcp_split_unsent_seg - 500+500 ip4addr_aton - 492+492 tcp_alloc - 484+484 ip4_output_if_src - 476+476 tcp_close_shutdown - 448+448 etharp_query - 436+436 httpc_init_connection_common.constprop - 416+416 udp_sendto_if_src - 408+408 etharp_output - 404+404 arp_table - 400+400 tcp_connect- 396+396 pbuf_alloc - 376+376 etharp_find_entry - 372+372 tcp_abandon- 368+368 tcp_zero_window_probe - 356+356 raw_sendto_if_src - 328+328 pbuf_copy_partial_pbuf - 328+328 ip_reass_free_complete_datagram- 328+328 tcp_create_segment - 300+300 raw_input - 292+292 uboot_lwip_init- 284+284 ethernet_input - 284+284 etharp_raw - 284+284 tcp_output_alloc_header_common.constprop - 280+280 cmds - 280+280 udp_bind - 276+276 tcp_oos_insert_segment - 276+276 ip_reass_remove_oldest_datagram- 272+272 icmp_send_response - 268+268 netif_add - 260+260 ping_send - 244+244 tcp_rexmit - 232+232 tcp_parseopt - 220+220 tcp_free_acked_segments.constprop - 220+220 send_request - 220+220 inet_chksum_pseudo - 216+216 ip4addr_ntoa_r - 212+212 do_lwip_ping - 212+212 tcp_enqueue_flags - 208+208 etharp_output_to_arp_index - 208+208 netif_set_addr - 204+204 tcp_fasttmr- 200+200 tcp_rexmit_rto_prepare - 196+196 tcp_process_refused_data - 196+196 send_data - 196+196 lwip_wget - 192+192 ethernet_output- 192+192 ping_recv - 188+188 pbuf_memcmp- 184+184 pbuf_copy_partial - 184+184 httpc_free_state - 180+180 tcp_send_fin - 172+172 httpc_recv - 168+168
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
On Wed, May 24, 2023 at 10:18:13PM +0200, Simon Goldschmidt wrote: > Hi Maxim, Tom, > > On 24.05.2023 16:05, Maxim Uvarov wrote: > > On Tue, 23 May 2023 at 03:23, Tom Rini wrote: > > > > > On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > > > > On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > > > > > > > > > On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > > > > > > Hi Maxim > > > > > > > > > > > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > > > > > wrote: > > > > > > > > > > > > > > My measurements for binary after LTO looks like: > > > > > > > > > > > > > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > > > > > > > 870728| 915000| 912560 | > > > > > 41832| 4.8 > > > > > > > > > > > > > > > > > > I think you'll need to analyze that a bit more. First of all I > > > > > > don't > > > > > > think the '+ping' tab is useful. What is is trying to achieve? > > > > > > > > > > > > > To show the difference of extra bytes if we add a ping app on top. > > > > > > > > > > > > > > - How was LWIP compiled? > > > > > > > > > > > > > It has a really huge configuration. I tried to turn off everything off > > > > everything what can impact on size but still make http app work: > > > > #define LWIP_HAVE_LOOPIF0 > > > > #define LWIP_NETCONN0 > > > > #define LWIP_SOCKET 0 > > > > #define SO_REUSE0 > > > > #define LWIP_STATS 0 > > > > #define PPP_SUPPORT 0 > > > > > > > > Disabling loopback: > > > > #define LWIP_NETIF_LOOPBACK 0 > > > > can lower to 912288 bytes. > > > > > > > > And it's the same compilation option (optimization for size) as the main > > > > u-boot. I will do more experiments, but I think the goal is not to turn > > > off > > > > everything. > > > > > > > > > > > > > > - Was ipv6 supported? > > > > > > > > > > > > > No. I.e. when I sent results it was enabled on the compilation stage > > > > but > > > > not used. I just checked that size remains the same if IPv6 is not even > > > > compiled. > > > > > > > > > > > > > > - Can we strip it down even further? > > > > > > > > > > > > > > > > > > > There is always room for optimization. I think I tried to turn off > > > > everything that is configurable with defines. I can play with disable IP > > > > reassembly and things like that or figure out which functions have more > > > > size and if it's possible to exclude them. > > > > > > > > > > > > > > In general please give as much information as you can with what we > > > > > > gain in functionality from LWIP with those extra bytes of code. > > > > > > > > > > > > > > The main idea is to reuse a maintainable IP stack outside of U-boot. > > > LWIP > > > > can give a nice separation between IP stack code and network application > > > > code. I.e. application should not take care about any TCP details > > > > (SYN, > > > > ACK, retransmission, reassembly etc) and should open connection and use > > > > functions similar to recv() and send() to transfer data. Data means > > > > application data, no network packets. And LWIP allows > > > > us to do that. > > > > Because LWIP has an API similar to sockets, it has to be very easy to > > > port > > > > a linux application to LWIP. Then you can test it with a tap device. > > > > Then > > > > copy sources to U-boot, add a small integration layer (cmd command to > > > > call), compile and use. > > > > > > > > So my suggestion was: > > > > - do not maintain new network stack code in the current U-boot. Use > > > > lwip > > > > sources as an external project. All bugs related to network stack go to > > > > lwip project first, then sync with U-boot. > > > > - maintain network apps code* or > > > >-- inside U-boot. Write our own code for application and maintain it > > > > inside U-boot. > > > >-- inside LWIP. Add examples to LWIP which are suitable for both > > > U-boot > > > > and LWIP. > > > > > > > > * Let's define a U-boot network application as a cmd command. It might > > > > be > > > > ping, wget (http or https download), telnet, arp dns etc.. > > > > > > > > Let's consider the real use case, like HTTPS download client. We need to > > > > enable TLS connection, validate certificates, then do http download. > > > > Looking at the current code of wget command it's quite difficult to > > > > implement this due to the application having some protol level things. > > > > On > > > > the other side we can find embedTLS examples to do https download on > > > > sockets. If LWIP socket API is ported then the only thing you need to do > > > is > > > > change socket() -> lwip_socket(), recv()->lwip_recv(), > > > send()->lwip_send() > > > > and etc, even function names are similar. If LWIP socket API is not > > > > supported, then use callback API for recv() and send(), which are also > > > > easy. > > > > > > >
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
On Wed, 7 Jun 2023 at 15:47, Ilias Apalodimas wrote: > Hi Maxim, > > On Tue, 6 Jun 2023 at 17:33, Maxim Uvarov wrote: > > > > Greetings, > > > > I implemented the tftp client (that was quick due to lwip has example > app for tftp), and did some more measurements. > > I uploaded patches here if somebody want to do his own measurements: > > https://github.com/muvarov/uboot-lwip > > > > measure 1: > > 976K - total (total means lwip with all 3 commands ping, tftp, wget) > > 971K - total - tftp (total, but disable/minus tftp) > > 965K - total - tftp - wget (disable tftp and wget) > > 963K - total - tftp - wget - ping (disable tftp, wget, ping) > > 931K - no lwip > > > > result 1: lwip tftp (+ udp protocol) protocol 976-971k = 5kb > > result 2: lwip ping command 965- 963 = 2kb > > result 3: lwip wget command 971- 965 = 6kb > > result 4: lwip core stack with apps 976 - 931 = 45kb > > So tftp = 5kb, wget = 6kb ping =2kb and lwip = 32kb > > tftp also compiles in the UDP stack. So if there will be one more UDP application, then this size will be lower. > > > > measure 2: > > 890K - no CONFIG_NET_CMD > > 930K - + lwip tftp only > > 937K - + full lwip (ping wget tftp) > > > > result 1: 937-890=47kb ( lwip + all 3 commands) > > result 2: 937-930=7kb (ping and lwip command) > > I am not sure I understand this measurement. How is this different > from measurement 1 where the entire binary was 976K? > > This is when NET_CMD is off and LWIP is off also. First measurement had NET_CMD=y. (moved numbers to separate changes due to u-boot can not just enable only tfpt command due to a compilation error and had to fix it.). > > > measure 3: > > 904K - no lwip, CMD_NET_TFTP=y > > 900K - no lwip, CMD_NET_TFTP=n > > result 1: original u-boot tftp command 904-900=4kb > > 890K - no lwip, CMD_NET=n > > result 2: 900-890=10k original u-boot net/IP stack. > > > > My findings for all that measurements and lwip configuration: > > 1. The original u-boot net stack (packet process and up layers) is 10k > vs lwip 40k (the very minimal settings were 30k). > > 2. Network applications size is about the same 4kb for tftp original > command 5kb for lwip. > > 3. It's quite easy to reuse LWIP examples to implement the same > functionality for the U-boot. > > 4. I still think that there are other criterias which might have more > priority than size (bug free code, code reuse, development speed, > compatible API to posix and etc). > > Yes, there are other criteria and certainly having a complete network > stack might be worth it in many cases, but we need to keep in mind > 30kb might be a lot for some systems. > > I personally think this is decent and we can optimize lwip more in the > future. Tom, Simon, how about adding lwip as 'experimental' and > making it depend on !CMD_NET or something similar? > > Thanks > /Ilias > > > > BR, > > Maxim. > > > > On Thu, 25 May 2023 at 02:18, Simon Goldschmidt > wrote: > >> > >> Hi Maxim, Tom, > >> > >> On 24.05.2023 16:05, Maxim Uvarov wrote: > >> > On Tue, 23 May 2023 at 03:23, Tom Rini wrote: > >> > > >> >> On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > >> >>> On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > >> >>> > >> On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > >> > Hi Maxim > >> > > >> > On Mon, 22 May 2023 at 12:01, Maxim Uvarov < > maxim.uva...@linaro.org> > >> wrote: > >> >> > >> >> My measurements for binary after LTO looks like: > >> >> > >> >> U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > >> >> 870728| 915000| 912560 > | > >> 41832| 4.8 > >> > > >> > > >> > I think you'll need to analyze that a bit more. First of all I > don't > >> > think the '+ping' tab is useful. What is is trying to achieve? > >> > >> >>> > >> >>> To show the difference of extra bytes if we add a ping app on top. > >> >>> > >> >>> > >> > - How was LWIP compiled? > >> > >> >>> > >> >>> It has a really huge configuration. I tried to turn off everything > off > >> >>> everything what can impact on size but still make http app work: > >> >>> #define LWIP_HAVE_LOOPIF0 > >> >>> #define LWIP_NETCONN0 > >> >>> #define LWIP_SOCKET 0 > >> >>> #define SO_REUSE0 > >> >>> #define LWIP_STATS 0 > >> >>> #define PPP_SUPPORT 0 > >> >>> > >> >>> Disabling loopback: > >> >>> #define LWIP_NETIF_LOOPBACK 0 > >> >>> can lower to 912288 bytes. > >> >>> > >> >>> And it's the same compilation option (optimization for size) as the > main > >> >>> u-boot. I will do more experiments, but I think the goal is not to > turn > >> >> off > >> >>> everything. > >> >>> > >> >>> > >> > - Was ipv6 supported? > >> > >> >>> > >> >>> No. I.e. when I sent results it was enabled on the compilation > stage but > >> >>> not used. I just checked that size
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Hi Maxim, On Tue, 6 Jun 2023 at 17:33, Maxim Uvarov wrote: > > Greetings, > > I implemented the tftp client (that was quick due to lwip has example app for > tftp), and did some more measurements. > I uploaded patches here if somebody want to do his own measurements: > https://github.com/muvarov/uboot-lwip > > measure 1: > 976K - total (total means lwip with all 3 commands ping, tftp, wget) > 971K - total - tftp (total, but disable/minus tftp) > 965K - total - tftp - wget (disable tftp and wget) > 963K - total - tftp - wget - ping (disable tftp, wget, ping) > 931K - no lwip > > result 1: lwip tftp (+ udp protocol) protocol 976-971k = 5kb > result 2: lwip ping command 965- 963 = 2kb > result 3: lwip wget command 971- 965 = 6kb > result 4: lwip core stack with apps 976 - 931 = 45kb So tftp = 5kb, wget = 6kb ping =2kb and lwip = 32kb > > measure 2: > 890K - no CONFIG_NET_CMD > 930K - + lwip tftp only > 937K - + full lwip (ping wget tftp) > > result 1: 937-890=47kb ( lwip + all 3 commands) > result 2: 937-930=7kb (ping and lwip command) I am not sure I understand this measurement. How is this different from measurement 1 where the entire binary was 976K? > > measure 3: > 904K - no lwip, CMD_NET_TFTP=y > 900K - no lwip, CMD_NET_TFTP=n > result 1: original u-boot tftp command 904-900=4kb > 890K - no lwip, CMD_NET=n > result 2: 900-890=10k original u-boot net/IP stack. > > My findings for all that measurements and lwip configuration: > 1. The original u-boot net stack (packet process and up layers) is 10k vs > lwip 40k (the very minimal settings were 30k). > 2. Network applications size is about the same 4kb for tftp original command > 5kb for lwip. > 3. It's quite easy to reuse LWIP examples to implement the same functionality > for the U-boot. > 4. I still think that there are other criterias which might have more > priority than size (bug free code, code reuse, development speed, compatible > API to posix and etc). Yes, there are other criteria and certainly having a complete network stack might be worth it in many cases, but we need to keep in mind 30kb might be a lot for some systems. I personally think this is decent and we can optimize lwip more in the future. Tom, Simon, how about adding lwip as 'experimental' and making it depend on !CMD_NET or something similar? Thanks /Ilias > > BR, > Maxim. > > On Thu, 25 May 2023 at 02:18, Simon Goldschmidt wrote: >> >> Hi Maxim, Tom, >> >> On 24.05.2023 16:05, Maxim Uvarov wrote: >> > On Tue, 23 May 2023 at 03:23, Tom Rini wrote: >> > >> >> On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: >> >>> On Mon, 22 May 2023 at 10:20, Tom Rini wrote: >> >>> >> On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: >> > Hi Maxim >> > >> > On Mon, 22 May 2023 at 12:01, Maxim Uvarov >> wrote: >> >> >> >> My measurements for binary after LTO looks like: >> >> >> >> U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % >> >> 870728| 915000| 912560 | >> 41832| 4.8 >> > >> > >> > I think you'll need to analyze that a bit more. First of all I don't >> > think the '+ping' tab is useful. What is is trying to achieve? >> >> >>> >> >>> To show the difference of extra bytes if we add a ping app on top. >> >>> >> >>> >> > - How was LWIP compiled? >> >> >>> >> >>> It has a really huge configuration. I tried to turn off everything off >> >>> everything what can impact on size but still make http app work: >> >>> #define LWIP_HAVE_LOOPIF0 >> >>> #define LWIP_NETCONN0 >> >>> #define LWIP_SOCKET 0 >> >>> #define SO_REUSE0 >> >>> #define LWIP_STATS 0 >> >>> #define PPP_SUPPORT 0 >> >>> >> >>> Disabling loopback: >> >>> #define LWIP_NETIF_LOOPBACK 0 >> >>> can lower to 912288 bytes. >> >>> >> >>> And it's the same compilation option (optimization for size) as the main >> >>> u-boot. I will do more experiments, but I think the goal is not to turn >> >> off >> >>> everything. >> >>> >> >>> >> > - Was ipv6 supported? >> >> >>> >> >>> No. I.e. when I sent results it was enabled on the compilation stage but >> >>> not used. I just checked that size remains the same if IPv6 is not even >> >>> compiled. >> >>> >> >>> >> > - Can we strip it down even further? >> > >> >> >>> >> >>> There is always room for optimization. I think I tried to turn off >> >>> everything that is configurable with defines. I can play with disable IP >> >>> reassembly and things like that or figure out which functions have more >> >>> size and if it's possible to exclude them. >> >>> >> >>> >> > In general please give as much information as you can with what we >> > gain in functionality from LWIP with those extra bytes of code. >> >> >> >>> The main idea is to reuse a maintainable IP
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Greetings, I implemented the tftp client (that was quick due to lwip has example app for tftp), and did some more measurements. I uploaded patches here if somebody want to do his own measurements: https://github.com/muvarov/uboot-lwip measure 1: 976K - total (total means lwip with all 3 commands ping, tftp, wget) 971K - total - tftp (total, but disable/minus tftp) 965K - total - tftp - wget (disable tftp and wget) 963K - total - tftp - wget - ping (disable tftp, wget, ping) 931K - no lwip result 1: lwip tftp (+ udp protocol) protocol 976-971k = 5kb result 2: lwip ping command 965- 963 = 2kb result 3: lwip wget command 971- 965 = 6kb result 4: lwip core stack with apps 976 - 931 = 45kb measure 2: 890K - no CONFIG_NET_CMD 930K - + lwip tftp only 937K - + full lwip (ping wget tftp) result 1: 937-890=47kb ( lwip + all 3 commands) result 2: 937-930=7kb (ping and lwip command) measure 3: 904K - no lwip, CMD_NET_TFTP=y 900K - no lwip, CMD_NET_TFTP=n result 1: original u-boot tftp command 904-900=4kb 890K - no lwip, CMD_NET=n result 2: 900-890=10k original u-boot net/IP stack. My findings for all that measurements and lwip configuration: 1. The original u-boot net stack (packet process and up layers) is 10k vs lwip 40k (the very minimal settings were 30k). 2. Network applications size is about the same 4kb for tftp original command 5kb for lwip. 3. It's quite easy to reuse LWIP examples to implement the same functionality for the U-boot. 4. I still think that there are other criterias which might have more priority than size (bug free code, code reuse, development speed, compatible API to posix and etc). BR, Maxim. On Thu, 25 May 2023 at 02:18, Simon Goldschmidt wrote: > Hi Maxim, Tom, > > On 24.05.2023 16:05, Maxim Uvarov wrote: > > On Tue, 23 May 2023 at 03:23, Tom Rini wrote: > > > >> On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > >>> On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > >>> > On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > > Hi Maxim > > > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > wrote: > >> > >> My measurements for binary after LTO looks like: > >> > >> U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > >> 870728| 915000| 912560 | > 41832| 4.8 > > > > > > I think you'll need to analyze that a bit more. First of all I don't > > think the '+ping' tab is useful. What is is trying to achieve? > > >>> > >>> To show the difference of extra bytes if we add a ping app on top. > >>> > >>> > > - How was LWIP compiled? > > >>> > >>> It has a really huge configuration. I tried to turn off everything off > >>> everything what can impact on size but still make http app work: > >>> #define LWIP_HAVE_LOOPIF0 > >>> #define LWIP_NETCONN0 > >>> #define LWIP_SOCKET 0 > >>> #define SO_REUSE0 > >>> #define LWIP_STATS 0 > >>> #define PPP_SUPPORT 0 > >>> > >>> Disabling loopback: > >>> #define LWIP_NETIF_LOOPBACK 0 > >>> can lower to 912288 bytes. > >>> > >>> And it's the same compilation option (optimization for size) as the > main > >>> u-boot. I will do more experiments, but I think the goal is not to turn > >> off > >>> everything. > >>> > >>> > > - Was ipv6 supported? > > >>> > >>> No. I.e. when I sent results it was enabled on the compilation stage > but > >>> not used. I just checked that size remains the same if IPv6 is not even > >>> compiled. > >>> > >>> > > - Can we strip it down even further? > > > > >>> > >>> There is always room for optimization. I think I tried to turn off > >>> everything that is configurable with defines. I can play with disable > IP > >>> reassembly and things like that or figure out which functions have more > >>> size and if it's possible to exclude them. > >>> > >>> > > In general please give as much information as you can with what we > > gain in functionality from LWIP with those extra bytes of code. > > > >>> The main idea is to reuse a maintainable IP stack outside of U-boot. > >> LWIP > >>> can give a nice separation between IP stack code and network > application > >>> code. I.e. application should not take care about any TCP details > (SYN, > >>> ACK, retransmission, reassembly etc) and should open connection and use > >>> functions similar to recv() and send() to transfer data. Data means > >>> application data, no network packets. And LWIP allows > >>> us to do that. > >>> Because LWIP has an API similar to sockets, it has to be very easy to > >> port > >>> a linux application to LWIP. Then you can test it with a tap device. > Then > >>> copy sources to U-boot, add a small integration layer (cmd command to > >>> call), compile and use. > >>> > >>> So my suggestion was: > >>> - do not maintain new network stack code
Re: [lwip-devel] [RFC PATCH 0/5] LWIP stack integration
Hi Maxim, Tom, On 24.05.2023 16:05, Maxim Uvarov wrote: On Tue, 23 May 2023 at 03:23, Tom Rini wrote: On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: On Mon, 22 May 2023 at 10:20, Tom Rini wrote: On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: Hi Maxim On Mon, 22 May 2023 at 12:01, Maxim Uvarov wrote: My measurements for binary after LTO looks like: U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % 870728| 915000| 912560 | 41832| 4.8 I think you'll need to analyze that a bit more. First of all I don't think the '+ping' tab is useful. What is is trying to achieve? To show the difference of extra bytes if we add a ping app on top. - How was LWIP compiled? It has a really huge configuration. I tried to turn off everything off everything what can impact on size but still make http app work: #define LWIP_HAVE_LOOPIF0 #define LWIP_NETCONN0 #define LWIP_SOCKET 0 #define SO_REUSE0 #define LWIP_STATS 0 #define PPP_SUPPORT 0 Disabling loopback: #define LWIP_NETIF_LOOPBACK 0 can lower to 912288 bytes. And it's the same compilation option (optimization for size) as the main u-boot. I will do more experiments, but I think the goal is not to turn off everything. - Was ipv6 supported? No. I.e. when I sent results it was enabled on the compilation stage but not used. I just checked that size remains the same if IPv6 is not even compiled. - Can we strip it down even further? There is always room for optimization. I think I tried to turn off everything that is configurable with defines. I can play with disable IP reassembly and things like that or figure out which functions have more size and if it's possible to exclude them. In general please give as much information as you can with what we gain in functionality from LWIP with those extra bytes of code. The main idea is to reuse a maintainable IP stack outside of U-boot. LWIP can give a nice separation between IP stack code and network application code. I.e. application should not take care about any TCP details (SYN, ACK, retransmission, reassembly etc) and should open connection and use functions similar to recv() and send() to transfer data. Data means application data, no network packets. And LWIP allows us to do that. Because LWIP has an API similar to sockets, it has to be very easy to port a linux application to LWIP. Then you can test it with a tap device. Then copy sources to U-boot, add a small integration layer (cmd command to call), compile and use. So my suggestion was: - do not maintain new network stack code in the current U-boot. Use lwip sources as an external project. All bugs related to network stack go to lwip project first, then sync with U-boot. - maintain network apps code* or -- inside U-boot. Write our own code for application and maintain it inside U-boot. -- inside LWIP. Add examples to LWIP which are suitable for both U-boot and LWIP. * Let's define a U-boot network application as a cmd command. It might be ping, wget (http or https download), telnet, arp dns etc.. Let's consider the real use case, like HTTPS download client. We need to enable TLS connection, validate certificates, then do http download. Looking at the current code of wget command it's quite difficult to implement this due to the application having some protol level things. On the other side we can find embedTLS examples to do https download on sockets. If LWIP socket API is ported then the only thing you need to do is change socket() -> lwip_socket(), recv()->lwip_recv(), send()->lwip_send() and etc, even function names are similar. If LWIP socket API is not supported, then use callback API for recv() and send(), which are also easy. So yes we add extra bytes, but that will allow us to write more complex apps, use standard debug tools, use applications with very minimal integration changes, use help from the LWIP community to fix protocol bugs, etc.. Bunch of things already implemented there: - ipv6 - dhcp - snmp - igmp - dns - tcp and udp and raw. - loopback - netconn - socket - stats - ppp (I just followed configurable defines). And please make sure to disable the previous support, my guess fro that much growth is that you didn't. # CONFIG_PROT_TCP is not set # CONFIG_PROT_UDP is not set # CONFIG_UDP_CHECKSUM is not set # CONFIG_UDP_FUNCTION_FASTBOOT is not set # CONFIG_CMD_WGET is not set I think you need to step back and figure out a better way to measure the size change and growth. I am not interested in a path that long term means two networking stacks in U-Boot. I am not interested in massively growing the overall binary size for every platform. Given how much larger just TCP support is, that's strongly implying a huge growth for the older use cases too. But I
Re: [RFC PATCH 0/5] LWIP stack integration
On Tue, 23 May 2023 at 03:23, Tom Rini wrote: > On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > > On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > > > > > On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > > > > Hi Maxim > > > > > > > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > > > wrote: > > > > > > > > > > My measurements for binary after LTO looks like: > > > > > > > > > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > > > > > 870728| 915000| 912560 | > > > 41832| 4.8 > > > > > > > > > > > > I think you'll need to analyze that a bit more. First of all I don't > > > > think the '+ping' tab is useful. What is is trying to achieve? > > > > > > > To show the difference of extra bytes if we add a ping app on top. > > > > > > > > - How was LWIP compiled? > > > > > > > It has a really huge configuration. I tried to turn off everything off > > everything what can impact on size but still make http app work: > > #define LWIP_HAVE_LOOPIF0 > > #define LWIP_NETCONN0 > > #define LWIP_SOCKET 0 > > #define SO_REUSE0 > > #define LWIP_STATS 0 > > #define PPP_SUPPORT 0 > > > > Disabling loopback: > > #define LWIP_NETIF_LOOPBACK 0 > > can lower to 912288 bytes. > > > > And it's the same compilation option (optimization for size) as the main > > u-boot. I will do more experiments, but I think the goal is not to turn > off > > everything. > > > > > > > > - Was ipv6 supported? > > > > > > > No. I.e. when I sent results it was enabled on the compilation stage but > > not used. I just checked that size remains the same if IPv6 is not even > > compiled. > > > > > > > > - Can we strip it down even further? > > > > > > > > > > > There is always room for optimization. I think I tried to turn off > > everything that is configurable with defines. I can play with disable IP > > reassembly and things like that or figure out which functions have more > > size and if it's possible to exclude them. > > > > > > > > In general please give as much information as you can with what we > > > > gain in functionality from LWIP with those extra bytes of code. > > > > > > > > The main idea is to reuse a maintainable IP stack outside of U-boot. > LWIP > > can give a nice separation between IP stack code and network application > > code. I.e. application should not take care about any TCP details (SYN, > > ACK, retransmission, reassembly etc) and should open connection and use > > functions similar to recv() and send() to transfer data. Data means > > application data, no network packets. And LWIP allows > > us to do that. > > Because LWIP has an API similar to sockets, it has to be very easy to > port > > a linux application to LWIP. Then you can test it with a tap device. Then > > copy sources to U-boot, add a small integration layer (cmd command to > > call), compile and use. > > > > So my suggestion was: > > - do not maintain new network stack code in the current U-boot. Use lwip > > sources as an external project. All bugs related to network stack go to > > lwip project first, then sync with U-boot. > > - maintain network apps code* or > > -- inside U-boot. Write our own code for application and maintain it > > inside U-boot. > > -- inside LWIP. Add examples to LWIP which are suitable for both > U-boot > > and LWIP. > > > > * Let's define a U-boot network application as a cmd command. It might be > > ping, wget (http or https download), telnet, arp dns etc.. > > > > Let's consider the real use case, like HTTPS download client. We need to > > enable TLS connection, validate certificates, then do http download. > > Looking at the current code of wget command it's quite difficult to > > implement this due to the application having some protol level things. On > > the other side we can find embedTLS examples to do https download on > > sockets. If LWIP socket API is ported then the only thing you need to do > is > > change socket() -> lwip_socket(), recv()->lwip_recv(), > send()->lwip_send() > > and etc, even function names are similar. If LWIP socket API is not > > supported, then use callback API for recv() and send(), which are also > > easy. > > > > So yes we add extra bytes, but that will allow us to write more complex > > apps, use standard debug tools, use applications with very minimal > > integration changes, use help from the LWIP community to fix protocol > bugs, > > etc.. > > Bunch of things already implemented there: > > - ipv6 > > - dhcp > > - snmp > > - igmp > > - dns > > - tcp and udp and raw. > > - loopback > > - netconn > > - socket > > - stats > > - ppp > > (I just followed configurable defines). > > > > > > And please make sure to disable the previous support, my guess fro that > > > much growth is that you didn't. > > > > > > > # CONFIG_PROT_TCP is not set > > # CONFIG_PROT_UDP is not set > >
Re: [RFC PATCH 0/5] LWIP stack integration
On Mon, May 22, 2023 at 12:40:49PM -0400, Maxim Uvarov wrote: > On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > > > On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > > > Hi Maxim > > > > > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > > wrote: > > > > > > > > My measurements for binary after LTO looks like: > > > > > > > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > > > > 870728| 915000| 912560 | > > 41832| 4.8 > > > > > > > > > I think you'll need to analyze that a bit more. First of all I don't > > > think the '+ping' tab is useful. What is is trying to achieve? > > > > To show the difference of extra bytes if we add a ping app on top. > > > > > - How was LWIP compiled? > > > > It has a really huge configuration. I tried to turn off everything off > everything what can impact on size but still make http app work: > #define LWIP_HAVE_LOOPIF0 > #define LWIP_NETCONN0 > #define LWIP_SOCKET 0 > #define SO_REUSE0 > #define LWIP_STATS 0 > #define PPP_SUPPORT 0 > > Disabling loopback: > #define LWIP_NETIF_LOOPBACK 0 > can lower to 912288 bytes. > > And it's the same compilation option (optimization for size) as the main > u-boot. I will do more experiments, but I think the goal is not to turn off > everything. > > > > > - Was ipv6 supported? > > > > No. I.e. when I sent results it was enabled on the compilation stage but > not used. I just checked that size remains the same if IPv6 is not even > compiled. > > > > > - Can we strip it down even further? > > > > > > > There is always room for optimization. I think I tried to turn off > everything that is configurable with defines. I can play with disable IP > reassembly and things like that or figure out which functions have more > size and if it's possible to exclude them. > > > > > In general please give as much information as you can with what we > > > gain in functionality from LWIP with those extra bytes of code. > > > > > The main idea is to reuse a maintainable IP stack outside of U-boot. LWIP > can give a nice separation between IP stack code and network application > code. I.e. application should not take care about any TCP details (SYN, > ACK, retransmission, reassembly etc) and should open connection and use > functions similar to recv() and send() to transfer data. Data means > application data, no network packets. And LWIP allows > us to do that. > Because LWIP has an API similar to sockets, it has to be very easy to port > a linux application to LWIP. Then you can test it with a tap device. Then > copy sources to U-boot, add a small integration layer (cmd command to > call), compile and use. > > So my suggestion was: > - do not maintain new network stack code in the current U-boot. Use lwip > sources as an external project. All bugs related to network stack go to > lwip project first, then sync with U-boot. > - maintain network apps code* or > -- inside U-boot. Write our own code for application and maintain it > inside U-boot. > -- inside LWIP. Add examples to LWIP which are suitable for both U-boot > and LWIP. > > * Let's define a U-boot network application as a cmd command. It might be > ping, wget (http or https download), telnet, arp dns etc.. > > Let's consider the real use case, like HTTPS download client. We need to > enable TLS connection, validate certificates, then do http download. > Looking at the current code of wget command it's quite difficult to > implement this due to the application having some protol level things. On > the other side we can find embedTLS examples to do https download on > sockets. If LWIP socket API is ported then the only thing you need to do is > change socket() -> lwip_socket(), recv()->lwip_recv(), send()->lwip_send() > and etc, even function names are similar. If LWIP socket API is not > supported, then use callback API for recv() and send(), which are also > easy. > > So yes we add extra bytes, but that will allow us to write more complex > apps, use standard debug tools, use applications with very minimal > integration changes, use help from the LWIP community to fix protocol bugs, > etc.. > Bunch of things already implemented there: > - ipv6 > - dhcp > - snmp > - igmp > - dns > - tcp and udp and raw. > - loopback > - netconn > - socket > - stats > - ppp > (I just followed configurable defines). > > > And please make sure to disable the previous support, my guess fro that > > much growth is that you didn't. > > > > # CONFIG_PROT_TCP is not set > # CONFIG_PROT_UDP is not set > # CONFIG_UDP_CHECKSUM is not set > # CONFIG_UDP_FUNCTION_FASTBOOT is not set > # CONFIG_CMD_WGET is not set I think you need to step back and figure out a better way to measure the size change and growth. I am not interested in a path that long term means two networking stacks in U-Boot. I
Re: [RFC PATCH 0/5] LWIP stack integration
On Mon, 22 May 2023 at 10:20, Tom Rini wrote: > On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > > Hi Maxim > > > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov > wrote: > > > > > > My measurements for binary after LTO looks like: > > > > > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > > > 870728| 915000| 912560 | > 41832| 4.8 > > > > > > I think you'll need to analyze that a bit more. First of all I don't > > think the '+ping' tab is useful. What is is trying to achieve? > To show the difference of extra bytes if we add a ping app on top. > > - How was LWIP compiled? > It has a really huge configuration. I tried to turn off everything off everything what can impact on size but still make http app work: #define LWIP_HAVE_LOOPIF0 #define LWIP_NETCONN0 #define LWIP_SOCKET 0 #define SO_REUSE0 #define LWIP_STATS 0 #define PPP_SUPPORT 0 Disabling loopback: #define LWIP_NETIF_LOOPBACK 0 can lower to 912288 bytes. And it's the same compilation option (optimization for size) as the main u-boot. I will do more experiments, but I think the goal is not to turn off everything. > > - Was ipv6 supported? > No. I.e. when I sent results it was enabled on the compilation stage but not used. I just checked that size remains the same if IPv6 is not even compiled. > > - Can we strip it down even further? > > > There is always room for optimization. I think I tried to turn off everything that is configurable with defines. I can play with disable IP reassembly and things like that or figure out which functions have more size and if it's possible to exclude them. > > In general please give as much information as you can with what we > > gain in functionality from LWIP with those extra bytes of code. > > The main idea is to reuse a maintainable IP stack outside of U-boot. LWIP can give a nice separation between IP stack code and network application code. I.e. application should not take care about any TCP details (SYN, ACK, retransmission, reassembly etc) and should open connection and use functions similar to recv() and send() to transfer data. Data means application data, no network packets. And LWIP allows us to do that. Because LWIP has an API similar to sockets, it has to be very easy to port a linux application to LWIP. Then you can test it with a tap device. Then copy sources to U-boot, add a small integration layer (cmd command to call), compile and use. So my suggestion was: - do not maintain new network stack code in the current U-boot. Use lwip sources as an external project. All bugs related to network stack go to lwip project first, then sync with U-boot. - maintain network apps code* or -- inside U-boot. Write our own code for application and maintain it inside U-boot. -- inside LWIP. Add examples to LWIP which are suitable for both U-boot and LWIP. * Let's define a U-boot network application as a cmd command. It might be ping, wget (http or https download), telnet, arp dns etc.. Let's consider the real use case, like HTTPS download client. We need to enable TLS connection, validate certificates, then do http download. Looking at the current code of wget command it's quite difficult to implement this due to the application having some protol level things. On the other side we can find embedTLS examples to do https download on sockets. If LWIP socket API is ported then the only thing you need to do is change socket() -> lwip_socket(), recv()->lwip_recv(), send()->lwip_send() and etc, even function names are similar. If LWIP socket API is not supported, then use callback API for recv() and send(), which are also easy. So yes we add extra bytes, but that will allow us to write more complex apps, use standard debug tools, use applications with very minimal integration changes, use help from the LWIP community to fix protocol bugs, etc.. Bunch of things already implemented there: - ipv6 - dhcp - snmp - igmp - dns - tcp and udp and raw. - loopback - netconn - socket - stats - ppp (I just followed configurable defines). And please make sure to disable the previous support, my guess fro that > much growth is that you didn't. > # CONFIG_PROT_TCP is not set # CONFIG_PROT_UDP is not set # CONFIG_UDP_CHECKSUM is not set # CONFIG_UDP_FUNCTION_FASTBOOT is not set # CONFIG_CMD_WGET is not set BR, Maxim. > > -- > Tom >
Re: [RFC PATCH 0/5] LWIP stack integration
On Mon, May 22, 2023 at 04:33:57PM +0300, Ilias Apalodimas wrote: > Hi Maxim > > On Mon, 22 May 2023 at 12:01, Maxim Uvarov wrote: > > > > My measurements for binary after LTO looks like: > > > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > > 870728| 915000| 912560 | 41832 > > | 4.8 > > > I think you'll need to analyze that a bit more. First of all I don't > think the '+ping' tab is useful. What is is trying to achieve? > - How was LWIP compiled? > - Was ipv6 supported? > - Can we strip it down even further? > > In general please give as much information as you can with what we > gain in functionality from LWIP with those extra bytes of code. And please make sure to disable the previous support, my guess fro that much growth is that you didn't. -- Tom signature.asc Description: PGP signature
Re: [RFC PATCH 0/5] LWIP stack integration
Hi Maxim On Mon, 22 May 2023 at 12:01, Maxim Uvarov wrote: > > My measurements for binary after LTO looks like: > > U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % > 870728| 915000| 912560 | 41832| > 4.8 I think you'll need to analyze that a bit more. First of all I don't think the '+ping' tab is useful. What is is trying to achieve? - How was LWIP compiled? - Was ipv6 supported? - Can we strip it down even further? In general please give as much information as you can with what we gain in functionality from LWIP with those extra bytes of code. Thanks /Ilias > BR, > Maxim. > > On Fri, 19 May 2023 at 09:52, Tom Rini wrote: >> >> On Fri, May 19, 2023 at 04:17:06PM +0300, Ilias Apalodimas wrote: >> > Hi Tom, >> > >> > Apologies for being late to the party >> > >> > > On Thu, May 11, 2023 at 09:52:04AM -0400, Tom Rini wrote: >> > > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: >> > > >> > > > Greetings, >> > > > >> > > > This RFC patchset is an attempt to try to use an already existing IP >> > > > network stack inside U-boot. >> > > > U-Boot recently got basic TCP/IP support, implementing wget, but in >> > > > order to get a full IP stack >> > > > with new features (e.g ipv6), it would be preferable to use an >> > > > established embedded ip library, >> > > > instead of rewriting the code from scratch. >> > > > >> > > > For this experiment LWIP network stack was selected: >> > > > https://savannah.nongnu.org/git/?group=lwip >> > > > >> > > > LWIP main features include: >> > > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE >> > > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA >> > > > (Zeroconf), >> > > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) >> > > > - APIs: specialized APIs for enhanced performance, optional >> > > > Berkeley-alike socket API >> > > > - Extended features: IP forwarding over multiple network interfaces, >> > > > TCP congestion control, >> > > > RTT estimation and fast recovery/fast retransmit >> > > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, >> > > > ping, NetBIOS nameserver, >> > > > mDNS responder, MQTT client, TFTP server. >> > > > >> > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a >> > > > widely used open-source >> > > > TCP/IP stack designed for embedded systems for U-boot. That will allow >> > > > using already >> > > > written network applications for microcontrollers. >> > > > >> > > > lwIP is licensed under a BSD-style license: >> > > > http://lwip.wikia.com/wiki/License. >> > > > Which should be compatible with u-boot. >> > > > >> > > > In the current RFC I tried to use minimal changes to better see how >> > > > LWIP code can be embedded into >> > > > U-boot. Patches implement ping and wget commands work. Both commands >> > > > are currently copy pasting and >> > > > reusing lwIP examples. Whether we want to add the final application >> > > > in U-Boot or lwIP is up to >> > > > discussion, but the current approach was the easiest one for an RFC. >> > > >> > > I'm honestly not sure this is the most useful way of doing an RFC. The >> > > long term goal would be that we replace our existing net/ with lwIP, >> > > yes? So what I'd see as more valuable is what it looks like to limit >> > > yourself to either sandbox or some QEMU target, disable the current >> > > network stack, and instead use lwIP to support just cmd/net.c so that >> > > the scope of the conversion is visible. Then the size comparison you do >> > > should be between platform + net + cmd/net.c (and the rest of networking >> > > turned off) and platform + lwip + cmd/net.c converted. >> > >> > This might be a bit too much imho. How about replacing the TCP stack which >> > is new an under heavy devel as well. If we do that we could replace lwip >> > with the version Maxim proposes and check the difference between >> > U-boot + homegrown TCP + wget >> > U-Boot + LWIP (for tcp only) + new wget >> > >> > That would give us an idea before trying to replace the UDP portion which >> > is way bigger >> >> I guess we can try that as a starting point and see what things look >> like. My gut feeling however is that's not going to look like a win. >> >> -- >> Tom
Re: [RFC PATCH 0/5] LWIP stack integration
My measurements for binary after LTO looks like: U-boot WGET | LWIP WGET + ping | LWIP WGET| diff bytes| diff % 870728| 915000| 912560 | 41832 | 4.8 BR, Maxim. On Fri, 19 May 2023 at 09:52, Tom Rini wrote: > On Fri, May 19, 2023 at 04:17:06PM +0300, Ilias Apalodimas wrote: > > Hi Tom, > > > > Apologies for being late to the party > > > > > On Thu, May 11, 2023 at 09:52:04AM -0400, Tom Rini wrote: > > > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > > > > > > > Greetings, > > > > > > > > This RFC patchset is an attempt to try to use an already existing IP > network stack inside U-boot. > > > > U-Boot recently got basic TCP/IP support, implementing wget, but in > order to get a full IP stack > > > > with new features (e.g ipv6), it would be preferable to use an > established embedded ip library, > > > > instead of rewriting the code from scratch. > > > > > > > > For this experiment LWIP network stack was selected: > > > > https://savannah.nongnu.org/git/?group=lwip > > > > > > > > LWIP main features include: > > > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, > PPPoE > > > > - DHCP client, DNS client (incl. mDNS hostname resolver), > AutoIP/APIPA (Zeroconf), > > > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > > > - APIs: specialized APIs for enhanced performance, optional > Berkeley-alike socket API > > > > - Extended features: IP forwarding over multiple network interfaces, > TCP congestion control, > > > > RTT estimation and fast recovery/fast retransmit > > > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, > ping, NetBIOS nameserver, > > > > mDNS responder, MQTT client, TFTP server. > > > > > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a > widely used open-source > > > > TCP/IP stack designed for embedded systems for U-boot. That will > allow using already > > > > written network applications for microcontrollers. > > > > > > > > lwIP is licensed under a BSD-style license: > http://lwip.wikia.com/wiki/License. > > > > Which should be compatible with u-boot. > > > > > > > > In the current RFC I tried to use minimal changes to better see how > LWIP code can be embedded into > > > > U-boot. Patches implement ping and wget commands work. Both commands > are currently copy pasting and > > > > reusing lwIP examples. Whether we want to add the final application > in U-Boot or lwIP is up to > > > > discussion, but the current approach was the easiest one for an RFC. > > > > > > I'm honestly not sure this is the most useful way of doing an RFC. The > > > long term goal would be that we replace our existing net/ with lwIP, > > > yes? So what I'd see as more valuable is what it looks like to limit > > > yourself to either sandbox or some QEMU target, disable the current > > > network stack, and instead use lwIP to support just cmd/net.c so that > > > the scope of the conversion is visible. Then the size comparison you > do > > > should be between platform + net + cmd/net.c (and the rest of > networking > > > turned off) and platform + lwip + cmd/net.c converted. > > > > This might be a bit too much imho. How about replacing the TCP stack > which > > is new an under heavy devel as well. If we do that we could replace lwip > > with the version Maxim proposes and check the difference between > > U-boot + homegrown TCP + wget > > U-Boot + LWIP (for tcp only) + new wget > > > > That would give us an idea before trying to replace the UDP portion which > > is way bigger > > I guess we can try that as a starting point and see what things look > like. My gut feeling however is that's not going to look like a win. > > -- > Tom >
Re: [RFC PATCH 0/5] LWIP stack integration
On Fri, May 19, 2023 at 04:17:06PM +0300, Ilias Apalodimas wrote: > Hi Tom, > > Apologies for being late to the party > > > On Thu, May 11, 2023 at 09:52:04AM -0400, Tom Rini wrote: > > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > > > > > Greetings, > > > > > > This RFC patchset is an attempt to try to use an already existing IP > > > network stack inside U-boot. > > > U-Boot recently got basic TCP/IP support, implementing wget, but in order > > > to get a full IP stack > > > with new features (e.g ipv6), it would be preferable to use an > > > established embedded ip library, > > > instead of rewriting the code from scratch. > > > > > > For this experiment LWIP network stack was selected: > > > https://savannah.nongnu.org/git/?group=lwip > > > > > > LWIP main features include: > > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > > > (Zeroconf), > > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > > - APIs: specialized APIs for enhanced performance, optional > > > Berkeley-alike socket API > > > - Extended features: IP forwarding over multiple network interfaces, TCP > > > congestion control, > > > RTT estimation and fast recovery/fast retransmit > > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > > > NetBIOS nameserver, > > > mDNS responder, MQTT client, TFTP server. > > > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > > > used open-source > > > TCP/IP stack designed for embedded systems for U-boot. That will allow > > > using already > > > written network applications for microcontrollers. > > > > > > lwIP is licensed under a BSD-style license: > > > http://lwip.wikia.com/wiki/License. > > > Which should be compatible with u-boot. > > > > > > In the current RFC I tried to use minimal changes to better see how LWIP > > > code can be embedded into > > > U-boot. Patches implement ping and wget commands work. Both commands are > > > currently copy pasting and > > > reusing lwIP examples. Whether we want to add the final application in > > > U-Boot or lwIP is up to > > > discussion, but the current approach was the easiest one for an RFC. > > > > I'm honestly not sure this is the most useful way of doing an RFC. The > > long term goal would be that we replace our existing net/ with lwIP, > > yes? So what I'd see as more valuable is what it looks like to limit > > yourself to either sandbox or some QEMU target, disable the current > > network stack, and instead use lwIP to support just cmd/net.c so that > > the scope of the conversion is visible. Then the size comparison you do > > should be between platform + net + cmd/net.c (and the rest of networking > > turned off) and platform + lwip + cmd/net.c converted. > > This might be a bit too much imho. How about replacing the TCP stack which > is new an under heavy devel as well. If we do that we could replace lwip > with the version Maxim proposes and check the difference between > U-boot + homegrown TCP + wget > U-Boot + LWIP (for tcp only) + new wget > > That would give us an idea before trying to replace the UDP portion which > is way bigger I guess we can try that as a starting point and see what things look like. My gut feeling however is that's not going to look like a win. -- Tom signature.asc Description: PGP signature
Re: [RFC PATCH 0/5] LWIP stack integration
Hi Tom, Apologies for being late to the party > On Thu, May 11, 2023 at 09:52:04AM -0400, Tom Rini wrote: > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > > > Greetings, > > > > This RFC patchset is an attempt to try to use an already existing IP > > network stack inside U-boot. > > U-Boot recently got basic TCP/IP support, implementing wget, but in order > > to get a full IP stack > > with new features (e.g ipv6), it would be preferable to use an established > > embedded ip library, > > instead of rewriting the code from scratch. > > > > For this experiment LWIP network stack was selected: > > https://savannah.nongnu.org/git/?group=lwip > > > > LWIP main features include: > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > > (Zeroconf), > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > - APIs: specialized APIs for enhanced performance, optional Berkeley-alike > > socket API > > - Extended features: IP forwarding over multiple network interfaces, TCP > > congestion control, > > RTT estimation and fast recovery/fast retransmit > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > > NetBIOS nameserver, > > mDNS responder, MQTT client, TFTP server. > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > > used open-source > > TCP/IP stack designed for embedded systems for U-boot. That will allow > > using already > > written network applications for microcontrollers. > > > > lwIP is licensed under a BSD-style license: > > http://lwip.wikia.com/wiki/License. > > Which should be compatible with u-boot. > > > > In the current RFC I tried to use minimal changes to better see how LWIP > > code can be embedded into > > U-boot. Patches implement ping and wget commands work. Both commands are > > currently copy pasting and > > reusing lwIP examples. Whether we want to add the final application in > > U-Boot or lwIP is up to > > discussion, but the current approach was the easiest one for an RFC. > > I'm honestly not sure this is the most useful way of doing an RFC. The > long term goal would be that we replace our existing net/ with lwIP, > yes? So what I'd see as more valuable is what it looks like to limit > yourself to either sandbox or some QEMU target, disable the current > network stack, and instead use lwIP to support just cmd/net.c so that > the scope of the conversion is visible. Then the size comparison you do > should be between platform + net + cmd/net.c (and the rest of networking > turned off) and platform + lwip + cmd/net.c converted. This might be a bit too much imho. How about replacing the TCP stack which is new an under heavy devel as well. If we do that we could replace lwip with the version Maxim proposes and check the difference between U-boot + homegrown TCP + wget U-Boot + LWIP (for tcp only) + new wget That would give us an idea before trying to replace the UDP portion which is way bigger Regards /Ilias > > -- > Tom
Re: [RFC PATCH 0/5] LWIP stack integration
On Mon, May 15, 2023 at 11:25:58AM -0400, Maxim Uvarov wrote: > On Thu, 11 May 2023 at 09:52, Tom Rini wrote: > > > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > > > > > Greetings, > > > > > > This RFC patchset is an attempt to try to use an already existing IP > > network stack inside U-boot. > > > U-Boot recently got basic TCP/IP support, implementing wget, but in > > order to get a full IP stack > > > with new features (e.g ipv6), it would be preferable to use an > > established embedded ip library, > > > instead of rewriting the code from scratch. > > > > > > For this experiment LWIP network stack was selected: > > > https://savannah.nongnu.org/git/?group=lwip > > > > > > LWIP main features include: > > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > > (Zeroconf), > > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > > - APIs: specialized APIs for enhanced performance, optional > > Berkeley-alike socket API > > > - Extended features: IP forwarding over multiple network interfaces, TCP > > congestion control, > > > RTT estimation and fast recovery/fast retransmit > > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > > NetBIOS nameserver, > > > mDNS responder, MQTT client, TFTP server. > > > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a > > widely used open-source > > > TCP/IP stack designed for embedded systems for U-boot. That will allow > > using already > > > written network applications for microcontrollers. > > > > > > lwIP is licensed under a BSD-style license: > > http://lwip.wikia.com/wiki/License. > > > Which should be compatible with u-boot. > > > > > > In the current RFC I tried to use minimal changes to better see how LWIP > > code can be embedded into > > > U-boot. Patches implement ping and wget commands work. Both commands are > > currently copy pasting and > > > reusing lwIP examples. Whether we want to add the final application in > > U-Boot or lwIP is up to > > > discussion, but the current approach was the easiest one for an RFC. > > > > I'm honestly not sure this is the most useful way of doing an RFC. The > > long term goal would be that we replace our existing net/ with lwIP, > > yes? So what I'd see as more valuable is what it looks like to limit > > yourself to either sandbox or some QEMU target, disable the current > > network stack, and instead use lwIP to support just cmd/net.c so that > > the scope of the conversion is visible. Then the size comparison you do > > should be between platform + net + cmd/net.c (and the rest of networking > > turned off) and platform + lwip + cmd/net.c converted. > > > > -- > > Tom > > > > Is there any acceptance criteria for size? If we say that additing lwip > will add about 48kb and removing current code will also release some kbs. > How size is critical here or it's just numbers good to know? Well, the text portion of a current sandbox build (with LTO off, so adding up sizes is easier to do quickly) net/ is 46kB. But that includes v6 and fastboot and so on. So, it's a matter of discussion. If replacing the network stack but maintaining the same level of functionality causes us to grow by single digit kilobytes, we can maybe justify it due to easier to maintain. If it's smaller, that's great and an argument in favor of it. But if we're growing everything by tens of kilobytes, that's a lot harder to justify but maybe shows we need to work with upstream as perhaps some things need to be more configurable, or otherwise something to investigate. -- Tom signature.asc Description: PGP signature
Re: [RFC PATCH 0/5] LWIP stack integration
On Thu, 11 May 2023 at 09:52, Tom Rini wrote: > On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > > > Greetings, > > > > This RFC patchset is an attempt to try to use an already existing IP > network stack inside U-boot. > > U-Boot recently got basic TCP/IP support, implementing wget, but in > order to get a full IP stack > > with new features (e.g ipv6), it would be preferable to use an > established embedded ip library, > > instead of rewriting the code from scratch. > > > > For this experiment LWIP network stack was selected: > > https://savannah.nongnu.org/git/?group=lwip > > > > LWIP main features include: > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > (Zeroconf), > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > - APIs: specialized APIs for enhanced performance, optional > Berkeley-alike socket API > > - Extended features: IP forwarding over multiple network interfaces, TCP > congestion control, > > RTT estimation and fast recovery/fast retransmit > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > NetBIOS nameserver, > > mDNS responder, MQTT client, TFTP server. > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a > widely used open-source > > TCP/IP stack designed for embedded systems for U-boot. That will allow > using already > > written network applications for microcontrollers. > > > > lwIP is licensed under a BSD-style license: > http://lwip.wikia.com/wiki/License. > > Which should be compatible with u-boot. > > > > In the current RFC I tried to use minimal changes to better see how LWIP > code can be embedded into > > U-boot. Patches implement ping and wget commands work. Both commands are > currently copy pasting and > > reusing lwIP examples. Whether we want to add the final application in > U-Boot or lwIP is up to > > discussion, but the current approach was the easiest one for an RFC. > > I'm honestly not sure this is the most useful way of doing an RFC. The > long term goal would be that we replace our existing net/ with lwIP, > yes? So what I'd see as more valuable is what it looks like to limit > yourself to either sandbox or some QEMU target, disable the current > network stack, and instead use lwIP to support just cmd/net.c so that > the scope of the conversion is visible. Then the size comparison you do > should be between platform + net + cmd/net.c (and the rest of networking > turned off) and platform + lwip + cmd/net.c converted. > > -- > Tom > Is there any acceptance criteria for size? If we say that additing lwip will add about 48kb and removing current code will also release some kbs. How size is critical here or it's just numbers good to know? BR, Maxim.
Re: [RFC PATCH 0/5] LWIP stack integration
On Mon, 8 May 2023 at 17:23, Simon Glass wrote: > > Hi Maxim, > > On Fri, 5 May 2023 at 04:50, Maxim Uvarov wrote: > > > > Greetings, > > > > This RFC patchset is an attempt to try to use an already existing IP > > network stack inside U-boot. > > U-Boot recently got basic TCP/IP support, implementing wget, but in order > > to get a full IP stack > > with new features (e.g ipv6), it would be preferable to use an established > > embedded ip library, > > instead of rewriting the code from scratch. > > > > For this experiment LWIP network stack was selected: > > https://savannah.nongnu.org/git/?group=lwip > > > > LWIP main features include: > > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > > (Zeroconf), > > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > > - APIs: specialized APIs for enhanced performance, optional Berkeley-alike > > socket API > > - Extended features: IP forwarding over multiple network interfaces, TCP > > congestion control, > > RTT estimation and fast recovery/fast retransmit > > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > > NetBIOS nameserver, > > mDNS responder, MQTT client, TFTP server. > > > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > > used open-source > > TCP/IP stack designed for embedded systems for U-boot. That will allow > > using already > > written network applications for microcontrollers. > > > > lwIP is licensed under a BSD-style license: > > http://lwip.wikia.com/wiki/License. > > Which should be compatible with u-boot. > > > > In the current RFC I tried to use minimal changes to better see how LWIP > > code can be embedded into > > U-boot. Patches implement ping and wget commands work. Both commands are > > currently copy pasting and > > reusing lwIP examples. Whether we want to add the final application in > > U-Boot or lwIP is up to > > discussion, but the current approach was the easiest one for an RFC. > > > > Looking for your comments, > > Best regards, > > Maxim. > > > > Maxim Uvarov (5): > > add lwip-external submodule > > lib/lwip: compile-in core files > > add doc/README.lwip > > add doc/README.lwip.size > > lwip: implement wget command from http_client.c example > > > > .gitignore | 5 + > > .gitmodules| 3 + > > doc/README.lwip| 90 + > > doc/README.lwip.size | 291 +++ > > include/net.h | 2 +- > > lib/Kconfig| 2 + > > lib/Makefile | 2 + > > lib/lwip/Kconfig | 12 + > > lib/lwip/Makefile | 86 + > > lib/lwip/apps/http/lwip-wget.c | 67 > > lib/lwip/apps/http/rmstatic.patch | 47 +++ > > lib/lwip/apps/ping/lwip_ping.c | 33 ++ > > lib/lwip/apps/ping/lwip_ping.h | 19 + > > lib/lwip/apps/ping/ping.h | 0 > > lib/lwip/apps/ping/rmstatic.patch | 32 ++ > > lib/lwip/cmd-lwip.c| 129 +++ > > lib/lwip/lwip-external | 1 + > > lib/lwip/lwipopts.h| 484 + > > lib/lwip/port/if.c | 256 + > > lib/lwip/port/include/arch/cc.h| 41 +++ > > lib/lwip/port/include/arch/sys_arch.h | 78 > > lib/lwip/port/include/arch/u-sockets.h | 26 ++ > > lib/lwip/port/include/limits.h | 0 > > lib/lwip/port/sys-arch.c | 7 + > > net/eth-uclass.c | 4 +- > > net/net.c | 14 + > > 26 files changed, 1729 insertions(+), 2 deletions(-) > > create mode 100644 .gitmodules > > create mode 100644 doc/README.lwip > > create mode 100644 doc/README.lwip.size > > create mode 100644 lib/lwip/Kconfig > > create mode 100644 lib/lwip/Makefile > > create mode 100644 lib/lwip/apps/http/lwip-wget.c > > create mode 100644 lib/lwip/apps/http/rmstatic.patch > > create mode 100644 lib/lwip/apps/ping/lwip_ping.c > > create mode 100644 lib/lwip/apps/ping/lwip_ping.h > > create mode 100644 lib/lwip/apps/ping/ping.h > > create mode 100644 lib/lwip/apps/ping/rmstatic.patch > > create mode 100644 lib/lwip/cmd-lwip.c > > create mode 16 lib/lwip/lwip-external > > create mode 100644 lib/lwip/lwipopts.h > > create mode 100644 lib/lwip/port/if.c > > create mode 100644 lib/lwip/port/include/arch/cc.h > > create mode 100644 lib/lwip/port/include/arch/sys_arch.h > > create mode 100644 lib/lwip/port/include/arch/u-sockets.h > > create mode 100644 lib/lwip/port/include/limits.h > > create mode 100644 lib/lwip/port/sys-arch.c > > > > -- > > 2.30.2 > > > > I don't know much about lwip but I certainly think we should be open > to changing the network stack, if it is better. > >
Re: [RFC PATCH 0/5] LWIP stack integration
On Fri, May 05, 2023 at 10:25:24AM +, Maxim Uvarov wrote: > Greetings, > > This RFC patchset is an attempt to try to use an already existing IP network > stack inside U-boot. > U-Boot recently got basic TCP/IP support, implementing wget, but in order to > get a full IP stack > with new features (e.g ipv6), it would be preferable to use an established > embedded ip library, > instead of rewriting the code from scratch. > > For this experiment LWIP network stack was selected: > https://savannah.nongnu.org/git/?group=lwip > > LWIP main features include: > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > (Zeroconf), > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > - APIs: specialized APIs for enhanced performance, optional Berkeley-alike > socket API > - Extended features: IP forwarding over multiple network interfaces, TCP > congestion control, > RTT estimation and fast recovery/fast retransmit > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > NetBIOS nameserver, > mDNS responder, MQTT client, TFTP server. > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > used open-source > TCP/IP stack designed for embedded systems for U-boot. That will allow using > already > written network applications for microcontrollers. > > lwIP is licensed under a BSD-style license: > http://lwip.wikia.com/wiki/License. > Which should be compatible with u-boot. > > In the current RFC I tried to use minimal changes to better see how LWIP code > can be embedded into > U-boot. Patches implement ping and wget commands work. Both commands are > currently copy pasting and > reusing lwIP examples. Whether we want to add the final application in > U-Boot or lwIP is up to > discussion, but the current approach was the easiest one for an RFC. I'm honestly not sure this is the most useful way of doing an RFC. The long term goal would be that we replace our existing net/ with lwIP, yes? So what I'd see as more valuable is what it looks like to limit yourself to either sandbox or some QEMU target, disable the current network stack, and instead use lwIP to support just cmd/net.c so that the scope of the conversion is visible. Then the size comparison you do should be between platform + net + cmd/net.c (and the rest of networking turned off) and platform + lwip + cmd/net.c converted. -- Tom signature.asc Description: PGP signature
Re: [RFC PATCH 0/5] LWIP stack integration
Hi Maxim, On Fri, 5 May 2023 at 04:50, Maxim Uvarov wrote: > > Greetings, > > This RFC patchset is an attempt to try to use an already existing IP network > stack inside U-boot. > U-Boot recently got basic TCP/IP support, implementing wget, but in order to > get a full IP stack > with new features (e.g ipv6), it would be preferable to use an established > embedded ip library, > instead of rewriting the code from scratch. > > For this experiment LWIP network stack was selected: > https://savannah.nongnu.org/git/?group=lwip > > LWIP main features include: > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > (Zeroconf), > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > - APIs: specialized APIs for enhanced performance, optional Berkeley-alike > socket API > - Extended features: IP forwarding over multiple network interfaces, TCP > congestion control, > RTT estimation and fast recovery/fast retransmit > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > NetBIOS nameserver, > mDNS responder, MQTT client, TFTP server. > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > used open-source > TCP/IP stack designed for embedded systems for U-boot. That will allow using > already > written network applications for microcontrollers. > > lwIP is licensed under a BSD-style license: > http://lwip.wikia.com/wiki/License. > Which should be compatible with u-boot. > > In the current RFC I tried to use minimal changes to better see how LWIP code > can be embedded into > U-boot. Patches implement ping and wget commands work. Both commands are > currently copy pasting and > reusing lwIP examples. Whether we want to add the final application in > U-Boot or lwIP is up to > discussion, but the current approach was the easiest one for an RFC. > > Looking for your comments, > Best regards, > Maxim. > > Maxim Uvarov (5): > add lwip-external submodule > lib/lwip: compile-in core files > add doc/README.lwip > add doc/README.lwip.size > lwip: implement wget command from http_client.c example > > .gitignore | 5 + > .gitmodules| 3 + > doc/README.lwip| 90 + > doc/README.lwip.size | 291 +++ > include/net.h | 2 +- > lib/Kconfig| 2 + > lib/Makefile | 2 + > lib/lwip/Kconfig | 12 + > lib/lwip/Makefile | 86 + > lib/lwip/apps/http/lwip-wget.c | 67 > lib/lwip/apps/http/rmstatic.patch | 47 +++ > lib/lwip/apps/ping/lwip_ping.c | 33 ++ > lib/lwip/apps/ping/lwip_ping.h | 19 + > lib/lwip/apps/ping/ping.h | 0 > lib/lwip/apps/ping/rmstatic.patch | 32 ++ > lib/lwip/cmd-lwip.c| 129 +++ > lib/lwip/lwip-external | 1 + > lib/lwip/lwipopts.h| 484 + > lib/lwip/port/if.c | 256 + > lib/lwip/port/include/arch/cc.h| 41 +++ > lib/lwip/port/include/arch/sys_arch.h | 78 > lib/lwip/port/include/arch/u-sockets.h | 26 ++ > lib/lwip/port/include/limits.h | 0 > lib/lwip/port/sys-arch.c | 7 + > net/eth-uclass.c | 4 +- > net/net.c | 14 + > 26 files changed, 1729 insertions(+), 2 deletions(-) > create mode 100644 .gitmodules > create mode 100644 doc/README.lwip > create mode 100644 doc/README.lwip.size > create mode 100644 lib/lwip/Kconfig > create mode 100644 lib/lwip/Makefile > create mode 100644 lib/lwip/apps/http/lwip-wget.c > create mode 100644 lib/lwip/apps/http/rmstatic.patch > create mode 100644 lib/lwip/apps/ping/lwip_ping.c > create mode 100644 lib/lwip/apps/ping/lwip_ping.h > create mode 100644 lib/lwip/apps/ping/ping.h > create mode 100644 lib/lwip/apps/ping/rmstatic.patch > create mode 100644 lib/lwip/cmd-lwip.c > create mode 16 lib/lwip/lwip-external > create mode 100644 lib/lwip/lwipopts.h > create mode 100644 lib/lwip/port/if.c > create mode 100644 lib/lwip/port/include/arch/cc.h > create mode 100644 lib/lwip/port/include/arch/sys_arch.h > create mode 100644 lib/lwip/port/include/arch/u-sockets.h > create mode 100644 lib/lwip/port/include/limits.h > create mode 100644 lib/lwip/port/sys-arch.c > > -- > 2.30.2 > I don't know much about lwip but I certainly think we should be open to changing the network stack, if it is better. Regards, Simon
[RFC PATCH 0/5] LWIP stack integration
Greetings, This RFC patchset is an attempt to try to use an already existing IP network stack inside U-boot. U-Boot recently got basic TCP/IP support, implementing wget, but in order to get a full IP stack with new features (e.g ipv6), it would be preferable to use an established embedded ip library, instead of rewriting the code from scratch. For this experiment LWIP network stack was selected: https://savannah.nongnu.org/git/?group=lwip LWIP main features include: - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) - APIs: specialized APIs for enhanced performance, optional Berkeley-alike socket API - Extended features: IP forwarding over multiple network interfaces, TCP congestion control, RTT estimation and fast recovery/fast retransmit - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, NetBIOS nameserver, mDNS responder, MQTT client, TFTP server. This RFC work is a demo to enable lwIP (lightweight IP) which is a widely used open-source TCP/IP stack designed for embedded systems for U-boot. That will allow using already written network applications for microcontrollers. lwIP is licensed under a BSD-style license: http://lwip.wikia.com/wiki/License. Which should be compatible with u-boot. In the current RFC I tried to use minimal changes to better see how LWIP code can be embedded into U-boot. Patches implement ping and wget commands work. Both commands are currently copy pasting and reusing lwIP examples. Whether we want to add the final application in U-Boot or lwIP is up to discussion, but the current approach was the easiest one for an RFC. Looking for your comments, Best regards, Maxim. Maxim Uvarov (5): add lwip-external submodule lib/lwip: compile-in core files add doc/README.lwip add doc/README.lwip.size lwip: implement wget command from http_client.c example .gitignore | 5 + .gitmodules| 3 + doc/README.lwip| 90 + doc/README.lwip.size | 291 +++ include/net.h | 2 +- lib/Kconfig| 2 + lib/Makefile | 2 + lib/lwip/Kconfig | 12 + lib/lwip/Makefile | 86 + lib/lwip/apps/http/lwip-wget.c | 67 lib/lwip/apps/http/rmstatic.patch | 47 +++ lib/lwip/apps/ping/lwip_ping.c | 33 ++ lib/lwip/apps/ping/lwip_ping.h | 19 + lib/lwip/apps/ping/ping.h | 0 lib/lwip/apps/ping/rmstatic.patch | 32 ++ lib/lwip/cmd-lwip.c| 129 +++ lib/lwip/lwip-external | 1 + lib/lwip/lwipopts.h| 484 + lib/lwip/port/if.c | 256 + lib/lwip/port/include/arch/cc.h| 41 +++ lib/lwip/port/include/arch/sys_arch.h | 78 lib/lwip/port/include/arch/u-sockets.h | 26 ++ lib/lwip/port/include/limits.h | 0 lib/lwip/port/sys-arch.c | 7 + net/eth-uclass.c | 4 +- net/net.c | 14 + 26 files changed, 1729 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 100644 doc/README.lwip create mode 100644 doc/README.lwip.size create mode 100644 lib/lwip/Kconfig create mode 100644 lib/lwip/Makefile create mode 100644 lib/lwip/apps/http/lwip-wget.c create mode 100644 lib/lwip/apps/http/rmstatic.patch create mode 100644 lib/lwip/apps/ping/lwip_ping.c create mode 100644 lib/lwip/apps/ping/lwip_ping.h create mode 100644 lib/lwip/apps/ping/ping.h create mode 100644 lib/lwip/apps/ping/rmstatic.patch create mode 100644 lib/lwip/cmd-lwip.c create mode 16 lib/lwip/lwip-external create mode 100644 lib/lwip/lwipopts.h create mode 100644 lib/lwip/port/if.c create mode 100644 lib/lwip/port/include/arch/cc.h create mode 100644 lib/lwip/port/include/arch/sys_arch.h create mode 100644 lib/lwip/port/include/arch/u-sockets.h create mode 100644 lib/lwip/port/include/limits.h create mode 100644 lib/lwip/port/sys-arch.c -- 2.30.2
Re: [RFC PATCH 0/5] LWIP stack integration
+cc Tom and Simon at least on the cover letter so they can take a peek On Fri, 5 May 2023 at 13:25, Maxim Uvarov wrote: > > Greetings, > > This RFC patchset is an attempt to try to use an already existing IP network > stack inside U-boot. > U-Boot recently got basic TCP/IP support, implementing wget, but in order to > get a full IP stack > with new features (e.g ipv6), it would be preferable to use an established > embedded ip library, > instead of rewriting the code from scratch. > > For this experiment LWIP network stack was selected: > https://savannah.nongnu.org/git/?group=lwip > > LWIP main features include: > - Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE > - DHCP client, DNS client (incl. mDNS hostname resolver), AutoIP/APIPA > (Zeroconf), > SNMP agent (v1, v2c, v3, private MIB support & MIB compiler) > - APIs: specialized APIs for enhanced performance, optional Berkeley-alike > socket API > - Extended features: IP forwarding over multiple network interfaces, TCP > congestion control, > RTT estimation and fast recovery/fast retransmit > - Addon applications: HTTP(S) server, SNTP client, SMTP(S) client, ping, > NetBIOS nameserver, > mDNS responder, MQTT client, TFTP server. > > This RFC work is a demo to enable lwIP (lightweight IP) which is a widely > used open-source > TCP/IP stack designed for embedded systems for U-boot. That will allow using > already > written network applications for microcontrollers. > > lwIP is licensed under a BSD-style license: > http://lwip.wikia.com/wiki/License. > Which should be compatible with u-boot. > > In the current RFC I tried to use minimal changes to better see how LWIP code > can be embedded into > U-boot. Patches implement ping and wget commands work. Both commands are > currently copy pasting and > reusing lwIP examples. Whether we want to add the final application in > U-Boot or lwIP is up to > discussion, but the current approach was the easiest one for an RFC. > > Looking for your comments, > Best regards, > Maxim. > > Maxim Uvarov (5): > add lwip-external submodule > lib/lwip: compile-in core files > add doc/README.lwip > add doc/README.lwip.size > lwip: implement wget command from http_client.c example > > .gitignore | 5 + > .gitmodules| 3 + > doc/README.lwip| 90 + > doc/README.lwip.size | 291 +++ > include/net.h | 2 +- > lib/Kconfig| 2 + > lib/Makefile | 2 + > lib/lwip/Kconfig | 12 + > lib/lwip/Makefile | 86 + > lib/lwip/apps/http/lwip-wget.c | 67 > lib/lwip/apps/http/rmstatic.patch | 47 +++ > lib/lwip/apps/ping/lwip_ping.c | 33 ++ > lib/lwip/apps/ping/lwip_ping.h | 19 + > lib/lwip/apps/ping/ping.h | 0 > lib/lwip/apps/ping/rmstatic.patch | 32 ++ > lib/lwip/cmd-lwip.c| 129 +++ > lib/lwip/lwip-external | 1 + > lib/lwip/lwipopts.h| 484 + > lib/lwip/port/if.c | 256 + > lib/lwip/port/include/arch/cc.h| 41 +++ > lib/lwip/port/include/arch/sys_arch.h | 78 > lib/lwip/port/include/arch/u-sockets.h | 26 ++ > lib/lwip/port/include/limits.h | 0 > lib/lwip/port/sys-arch.c | 7 + > net/eth-uclass.c | 4 +- > net/net.c | 14 + > 26 files changed, 1729 insertions(+), 2 deletions(-) > create mode 100644 .gitmodules > create mode 100644 doc/README.lwip > create mode 100644 doc/README.lwip.size > create mode 100644 lib/lwip/Kconfig > create mode 100644 lib/lwip/Makefile > create mode 100644 lib/lwip/apps/http/lwip-wget.c > create mode 100644 lib/lwip/apps/http/rmstatic.patch > create mode 100644 lib/lwip/apps/ping/lwip_ping.c > create mode 100644 lib/lwip/apps/ping/lwip_ping.h > create mode 100644 lib/lwip/apps/ping/ping.h > create mode 100644 lib/lwip/apps/ping/rmstatic.patch > create mode 100644 lib/lwip/cmd-lwip.c > create mode 16 lib/lwip/lwip-external > create mode 100644 lib/lwip/lwipopts.h > create mode 100644 lib/lwip/port/if.c > create mode 100644 lib/lwip/port/include/arch/cc.h > create mode 100644 lib/lwip/port/include/arch/sys_arch.h > create mode 100644 lib/lwip/port/include/arch/u-sockets.h > create mode 100644 lib/lwip/port/include/limits.h > create mode 100644 lib/lwip/port/sys-arch.c > > -- > 2.30.2 >