fastboot: lift restrictions on !NET_LWIP for USB
PATCH 1/3 fastboot: lift restrictions on !NET_LWIP for USB
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
---
Alternatively, we could add the defines and stub functions to the lwip header.
--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)
cmd/fastboot.c +4 -0
@@ -16,6 +16,7 @@#include <linux/printk.h> #include <linux/stringify.h> +#if CONFIG_IS_ENABLED (NET )static int do_fastboot_udp (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size) {
@@ -55,6 +56,7 @@ static int do_fastboot_tcp(int argc, char *const argv[], return CMD_RET_SUCCESS; } +#endif static int do_fastboot_usb (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size)
@@ -160,10 +162,12 @@ NXTARG:fastboot_init ((void *)buf_addr, buf_size); +#if CONFIG_IS_ENABLED (NET )if (!strcmp (argv[1 ],"udp" ))return do_fastboot_udp (argc, argv, buf_addr, buf_size);if (!strcmp (argv[1 ],"tcp" ))return do_fastboot_tcp (argc, argv, buf_addr, buf_size); +#endif if (!strcmp (argv[1 ],"usb" )) { argv++; argc--;
drivers/fastboot/Kconfig +0 -1
@@ -1,6 +1,5 @@ menu "Fastboot support" depends on CMDLINE - depends on !NET_LWIP config FASTBOOT bool
drivers/fastboot/fb_common.c +4 -0
@@ -183,11 +183,15 @@ void fastboot_handle_boot(int command, bool success)switch (command) {case FASTBOOT_COMMAND_BOOT :fastboot_boot (); +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif break ;case FASTBOOT_COMMAND_CONTINUE : +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif break ;case FASTBOOT_COMMAND_REBOOT :
Signature · 1 line
2.39.5
Sorry this should have been individual patches. Please read the subject as "[PATCH 1/1]" or just "[PATCH]".
-michael
Hi Michael,
Quoted 17 lines · Michael Walle
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
Signed-off-by Michael Walle <[email protected]>---
Alternatively, we could add the defines and stub functions to the lwip header.--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)
[...]
Thanks,
Signature · 1 line
Jerome
Hi Michael,
Thank you for the patch.
Quoted 9 lines · Michael Walle
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
Signed-off-by Michael Walle <[email protected]>
checkpatch.pl reports some issues with this:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD
<snip>
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible <snip>
Some occurences below could be fixed. Could you please have a look?
Quoted 14 lines
---
Alternatively, we could add the defines and stub functions to the lwip header.--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)cmd/fastboot.c +0
-0
cmd/fastboot.c line 19
Quoted 4 lines
cmd/fastboot.c +1
-0@@ -16,6 +16,7 @@#include <linux/printk.h> #include <linux/stringify.h> +#if CONFIG_IS_ENABLED (NET )
I think this can be dropped. I hope that since it's a static function, -if there are no users in the file- the compiler will optimize it out.
Note: I have not verified this, so I might be wrong.
If you measure and see size changes between keeping the #if and not keeping it, please ignore this comment.
Quoted 12 lines
cmd/fastboot.c +1
-0static int do_fastboot_udp (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size) {@@ -55,6 +56,7 @@ static int do_fastboot_tcp(int argc, char *const argv[], return CMD_RET_SUCCESS; } +#endif static int do_fastboot_usb (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size)
cmd/fastboot.c NXTARG: · line 170
Quoted 9 lines
cmd/fastboot.c +2
-0@@ -160,10 +162,12 @@ NXTARG:fastboot_init ((void *)buf_addr, buf_size); +#if CONFIG_IS_ENABLED (NET )if (!strcmp (argv[1 ],"udp" ))return do_fastboot_udp (argc, argv, buf_addr, buf_size);if (!strcmp (argv[1 ],"tcp" ))return do_fastboot_tcp (argc, argv, buf_addr, buf_size); +#endif
This can be replaced with:
if (IS_ENABLED(CONFIG_NET)) {
if (!strcmp(argv[1], "udp"))
return do_fastboot_udp(argc, argv, buf_addr, buf_size);
if (!strcmp(argv[1], "tcp"))
return do_fastboot_tcp(argc, argv, buf_addr, buf_size);
}Quoted 19 lines
cmd/fastboot.c +0
-0if (!strcmp (argv[1 ],"usb" )) { argv++; argc--;drivers/fastboot/Kconfig +0
-1@@ -1,6 +1,5 @@ menu "Fastboot support" depends on CMDLINE - depends on !NET_LWIP config FASTBOOT booldrivers/fastboot/fb_common.c +0
-0
drivers/fastboot/fb_common.c void fastboot_handle_boot(int command, bool success) · line 188
Quoted 6 lines
drivers/fastboot/fb_common.c +2
-0@@ -183,11 +183,15 @@ void fastboot_handle_boot(int command, bool success)switch (command) {case FASTBOOT_COMMAND_BOOT :fastboot_boot (); +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif
This can be replaced with:
if (IS_ENABLED((CONFIG_NET)) net_set_state(NETLOOP_SUCCESS);
drivers/fastboot/fb_common.c void fastboot_handle_boot(int command, bool success) · line 194
Quoted 6 lines
drivers/fastboot/fb_common.c +2
-0break ;case FASTBOOT_COMMAND_CONTINUE : +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif
Same here.
Quoted 5 lines
drivers/fastboot/fb_common.c +0
-0break ;case FASTBOOT_COMMAND_REBOOT :Signature · 1 line
2.39.5
Hi Mattijs,
Quoted 12 lines
Quoted 9 lines
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
Signed-off-by Michael Walle <[email protected]>checkpatch.pl reports some issues with this:
Quoted 7 lines
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD<snip>
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible <snip>Some occurences below could be fixed. Could you please have a look?
I've seen these. More below.
Quoted 4 lines
Quoted 4 lines
---
Alternatively, we could add the defines and stub functions to the lwip header.
This is relevant :)
Quoted 14 lines
Quoted 14 lines
--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)cmd/fastboot.c +0
-0@@ -16,6 +16,7 @@#include <linux/printk.h> #include <linux/stringify.h>
Quoted 8 lines
cmd/fastboot.c line 19
Quoted 1 line
cmd/fastboot.c +1
-0+#if CONFIG_IS_ENABLED (NET )I think this can be dropped. I hope that since it's a static function, -if there are no users in the file- the compiler will optimize it out.
Note: I have not verified this, so I might be wrong.If you measure and see size changes between keeping the #if and not keeping it, please ignore this comment.
No, because net_loop(), net_set_state() and NETLOOP_SUCCESS is only defined in net-legacy.h. Thus we need this ifdeffery.. Unless of course, we add the enums and function stubs to the new lwip net inlcude. I don't know if that's a good idea though.
-michael
Quoted 77 lines
Quoted 13 lines
cmd/fastboot.c +1
-0static int do_fastboot_udp (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size) {@@ -55,6 +56,7 @@ static int do_fastboot_tcp(int argc, char *const argv[], return CMD_RET_SUCCESS; } +#endif static int do_fastboot_usb (int argc,char *const argv[],uintptr_t buf_addr,size_t buf_size)cmd/fastboot.c NXTARG: · line 170
Quoted 9 lines
cmd/fastboot.c +2
-0@@ -160,10 +162,12 @@ NXTARG:fastboot_init ((void *)buf_addr, buf_size); +#if CONFIG_IS_ENABLED (NET )if (!strcmp (argv[1 ],"udp" ))return do_fastboot_udp (argc, argv, buf_addr, buf_size);if (!strcmp (argv[1 ],"tcp" ))return do_fastboot_tcp (argc, argv, buf_addr, buf_size); +#endif This can be replaced with:
if (IS_ENABLED(CONFIG_NET)) { if (!strcmp(argv[1], "udp")) return do_fastboot_udp(argc, argv, buf_addr, buf_size); if (!strcmp(argv[1], "tcp")) return do_fastboot_tcp(argc, argv, buf_addr, buf_size); }Quoted 19 lines
cmd/fastboot.c +0
-0if (!strcmp (argv[1 ],"usb" )) { argv++; argc--;drivers/fastboot/Kconfig +0
-1@@ -1,6 +1,5 @@ menu "Fastboot support" depends on CMDLINE - depends on !NET_LWIP config FASTBOOT booldrivers/fastboot/fb_common.c +0
-0drivers/fastboot/fb_common.c void fastboot_handle_boot(int command, bool success) · line 188
Quoted 6 lines
drivers/fastboot/fb_common.c +2
-0@@ -183,11 +183,15 @@ void fastboot_handle_boot(int command, bool success)switch (command) {case FASTBOOT_COMMAND_BOOT :fastboot_boot (); +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif This can be replaced with:
if (IS_ENABLED((CONFIG_NET)) net_set_state(NETLOOP_SUCCESS);drivers/fastboot/fb_common.c void fastboot_handle_boot(int command, bool success) · line 194
Quoted 6 lines
drivers/fastboot/fb_common.c +2
-0break ;case FASTBOOT_COMMAND_CONTINUE : +#if CONFIG_IS_ENABLED (NET )net_set_state (NETLOOP_SUCCESS ); +#endif Same here.
Quoted 5 lines
drivers/fastboot/fb_common.c +0
-0break ;case FASTBOOT_COMMAND_REBOOT :Signature · 1 line
2.39.5
Quoted 16 lines · Michael Walle
Hi Mattijs,
Quoted 14 lines
Quoted 9 lines
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
Signed-off-by Michael Walle <[email protected]>checkpatch.pl reports some issues with this:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD
Quoted 7 lines
Quoted 5 lines
<snip>
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible <snip>Some occurences below could be fixed. Could you please have a look?
I've seen these. More below.
That is also my least favorite checkpatch warning, and it's a warning not an error. Best judgement is needed about making things readable rather than just silencing checkpatch.
Quoted 28 lines
Quoted 5 lines
Quoted 5 lines
---
Alternatively, we could add the defines and stub functions to the lwip header.This is relevant :)
Quoted 20 lines
Quoted 11 lines
--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)cmd/fastboot.c +0
-0cmd/fastboot.c line 19
Quoted 4 lines
cmd/fastboot.c +1
-0@@ -16,6 +16,7 @@#include <linux/printk.h> #include <linux/stringify.h> +#if CONFIG_IS_ENABLED (NET )I think this can be dropped. I hope that since it's a static function, -if there are no users in the file- the compiler will optimize it out.
Note: I have not verified this, so I might be wrong.
Quoted 7 lines
Quoted 2 lines
If you measure and see size changes between keeping the #if and not keeping it, please ignore this comment.
No, because
net_loop(),net_set_state()andNETLOOP_SUCCESSis only defined innet-legacy.h. Thus we need this ifdeffery.. Unless of course, we add the enums and function stubs to the new lwip net inlcude. I don't know if that's a good idea though.
Yeah, I'm not sure that's worth it either, or at least as maybe only a future clean-up or investigate more. Perhaps filing an issue on source.denx.de on the -net tree so it's not forgotten?
Signature · 1 line
Tom
Mattijs Korpershoek
Reviewed-byHi Michael, Tom,
Quoted 21 lines · Tom Rini
Quoted 20 lines · Michael Walle
Hi Mattijs,
Quoted 18 lines
Quoted 9 lines
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
Signed-off-by Michael Walle <[email protected]>checkpatch.pl reports some issues with this:
$ ./scripts/checkpatch.pl --strict --u-boot --git HEAD^..HEAD<snip>
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible <snip>
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Some occurences below could be fixed. Could you please have a look?
I've seen these. More below.
That is also my least favorite checkpatch warning, and it's a warning not an error. Best judgement is needed about making things readable rather than just silencing checkpatch.
I think that using if (IS_ENABLED(CONFIG...) is more readable in this case.
However ...
Quoted 29 lines
Quoted 29 lines
Quoted 6 lines
Quoted 6 lines
---
Alternatively, we could add the defines and stub functions to the lwip header.This is relevant :)
Quoted 20 lines
Quoted 11 lines
--- cmd/fastboot.c | 4 ++++ drivers/fastboot/Kconfig | 1 - drivers/fastboot/fb_common.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-)cmd/fastboot.c +0
-0cmd/fastboot.c line 19
Quoted 4 lines
cmd/fastboot.c +1
-0@@ -16,6 +16,7 @@#include <linux/printk.h> #include <linux/stringify.h> +#if CONFIG_IS_ENABLED (NET )I think this can be dropped. I hope that since it's a static function, -if there are no users in the file- the compiler will optimize it out.
Note: I have not verified this, so I might be wrong.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
If you measure and see size changes between keeping the #if and not keeping it, please ignore this comment.
No, because
net_loop(),net_set_state()andNETLOOP_SUCCESSis only defined innet-legacy.h. Thus we need this ifdeffery.. Unless of course, we add the enums and function stubs to the new lwip net inlcude. I don't know if that's a good idea though.
... my suggestion does not work without adding the defines and stub functions to the lwip header.
Apologies about that :( And thank you for being patient with my remarks.
This patch is fine as-is, and I don't want ifdeffery vs if IS_ENABLED to block this contribution.
Quoted 4 lines
Yeah, I'm not sure that's worth it either, or at least as maybe only a future clean-up or investigate more. Perhaps filing an issue on source.denx.de on the -net tree so it's not forgotten?
I'd like to do this future cleanup. I could not file an issue on
https://source.denx.de/u-boot/custodians/u-boot-net so I have opened one in the -dfu tree here:
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/issues/5
Quoted 3 lines
Signature · 2 lines
-- Tom
Hi,
Quoted 9 lines · Michael Walle
Fastboot works either over TCP, UDP or USB. The latter doesn't have anything to do with networking, thus should work just fine with regardless which network stack is selected. In practice, header symbols are used inside common code paths. Add some ifdeffery to guard against that.
This will make fastboot over USB work with the new LWIP stack.
[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/3] fastboot: lift restrictions on !NET_LWIP for USB
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/d3c9f810f2b317ba376b4d9556e63a043b210355
--
Mattijs