mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Oleksij Rempel <linux@rempel-privat.de>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters
Date: Thu, 09 Sep 2021 12:36:50 +0200	[thread overview]
Message-ID: <4d2d9969fef304fd82f5f3b894f5bbbf6a1d6bc7.camel@pengutronix.de> (raw)
In-Reply-To: <0acb3e18-4016-fb18-087b-58eafb8b84ff@rempel-privat.de>

Am Donnerstag, dem 09.09.2021 um 12:24 +0200 schrieb Oleksij Rempel:
> Am 09.09.21 um 11:28 schrieb Lucas Stach:
> > Am Donnerstag, dem 09.09.2021 um 11:13 +0200 schrieb Oleksij Rempel:
> > > On some boards, forcing detection of all device will take noticeable more
> > > time. To reduce this time, we need to scan only for USB devices.
> > > 
> > > So, provide option do ifup by forcing only USB scan.
> > 
> > Why is this force detection even necessary? Is there a reason you can't
> > just put a eth-discover script in /env/network/ in the defaultenv of
> > this board to do the right thing when Barebox tries to bring up the
> > network interfaces?
> 
> This is board specific decision. The flag which indicate if board should
> do this is provided by the board code. So, if board code should set some
> flags anyway, why not to interpret this flags by some common code aswell?
> 
A force detect should never be necessary for any board to bring up the
interfaces needed for a standard boot target. The force detection is
something you would do manually when hacking on a board.

You can still make the USB scan conditional on some board specifics,
like the status of the eth0 interface, in the discover script.

Regards,
Lucas

> > Regards,
> > Lucas
> > 
> > > 
> > > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > > ---
> > >  Documentation/user/networking.rst |  3 +++
> > >  arch/arm/boards/skov-imx6/board.c |  2 +-
> > >  include/net.h                     |  1 +
> > >  net/ifup.c                        | 16 ++++++++++++++--
> > >  4 files changed, 19 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/Documentation/user/networking.rst b/Documentation/user/networking.rst
> > > index 9231ebde56..18936ff169 100644
> > > --- a/Documentation/user/networking.rst
> > > +++ b/Documentation/user/networking.rst
> > > @@ -55,6 +55,9 @@ device:
> > >  |                              |              | detected automatically during start (i.e. for  |
> > >  |                              |              | USB network adapters)                          |
> > >  +------------------------------+--------------+------------------------------------------------+
> > > +| global.net.ifup_detect_usb   | boolean      | Set to true if you use USB network adapter     |
> > > +|                              |              | and global.net.ifup_force_detect is too slow.  |
> > > ++------------------------------+--------------+------------------------------------------------+
> > > 
> > >  The first step for networking is configuring the network device. The network
> > >  device is usually ``eth0``. The current configuration can be viewed with the
> > > diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
> > > index 9a32e68f21..bd00c16157 100644
> > > --- a/arch/arm/boards/skov-imx6/board.c
> > > +++ b/arch/arm/boards/skov-imx6/board.c
> > > @@ -626,7 +626,7 @@ no_switch:
> > >  		pr_warn("Can't disable eth0\n");
> > >  	}
> > > 
> > > -	globalvar_set("net.ifup_force_detect", "true");
> > > +	globalvar_set("net.ifup_detect_usb", "true");
> > > 
> > >  	return 0;
> > >  }
> > > diff --git a/include/net.h b/include/net.h
> > > index aad28e4f4c..15cd921f56 100644
> > > --- a/include/net.h
> > > +++ b/include/net.h
> > > @@ -488,6 +488,7 @@ int net_icmp_send(struct net_connection *con, int len);
> > >  void led_trigger_network(enum led_trigger trigger);
> > > 
> > >  #define IFUP_FLAG_FORCE		(1 << 0)
> > > +#define IFUP_FLAG_USB		(1 << 1)
> > > 
> > >  int ifup_edev(struct eth_device *edev, unsigned flags);
> > >  int ifup(const char *name, unsigned flags);
> > > diff --git a/net/ifup.c b/net/ifup.c
> > > index 1870f74017..5cb2b52716 100644
> > > --- a/net/ifup.c
> > > +++ b/net/ifup.c
> > > @@ -20,6 +20,7 @@
> > >  #include <globalvar.h>
> > >  #include <magicvar.h>
> > >  #include <linux/stat.h>
> > > +#include <usb/usb.h>
> > > 
> > >  static int eth_discover(char *file)
> > >  {
> > > @@ -260,6 +261,7 @@ int ifdown(const char *ethname)
> > >  }
> > > 
> > >  static int net_ifup_force_detect;
> > > +static int net_ifup_detect_usb;
> > > 
> > >  int ifup_all(unsigned flags)
> > >  {
> > > @@ -282,6 +284,9 @@ int ifup_all(unsigned flags)
> > > 
> > >  	closedir(dir);
> > > 
> > > +	if ((flags & IFUP_FLAG_USB) || net_ifup_detect_usb)
> > > +		usb_rescan();
> > > +
> > >  	if ((flags & IFUP_FLAG_FORCE) || net_ifup_force_detect ||
> > >  	    list_empty(&netdev_list))
> > >  		device_detect_all();
> > > @@ -303,6 +308,7 @@ void ifdown_all(void)
> > >  static int ifup_all_init(void)
> > >  {
> > >  	globalvar_add_simple_bool("net.ifup_force_detect", &net_ifup_force_detect);
> > > +	globalvar_add_simple_bool("net.ifup_detect_usb", &net_ifup_detect_usb);
> > > 
> > >  	return 0;
> > >  }
> > > @@ -310,6 +316,8 @@ late_initcall(ifup_all_init);
> > > 
> > >  BAREBOX_MAGICVAR(global.net.ifup_force_detect,
> > >                   "net: force detection of devices on ifup -a");
> > > +BAREBOX_MAGICVAR(global.net.ifup_detect_usb,
> > > +                 "net: scan usb without forcing detection of all devices on ifup -a");
> > > 
> > >  #if IS_ENABLED(CONFIG_NET_CMD_IFUP)
> > > 
> > > @@ -319,11 +327,14 @@ static int do_ifup(int argc, char *argv[])
> > >  	unsigned flags = 0;
> > >  	int all = 0;
> > > 
> > > -	while ((opt = getopt(argc, argv, "af")) > 0) {
> > > +	while ((opt = getopt(argc, argv, "afu")) > 0) {
> > >  		switch (opt) {
> > >  		case 'f':
> > >  			flags |= IFUP_FLAG_FORCE;
> > >  			break;
> > > +		case 'u':
> > > +			flags |= IFUP_FLAG_USB;
> > > +			break;
> > >  		case 'a':
> > >  			all = 1;
> > >  			break;
> > > @@ -348,12 +359,13 @@ BAREBOX_CMD_HELP_TEXT("")
> > >  BAREBOX_CMD_HELP_TEXT("Options:")
> > >  BAREBOX_CMD_HELP_OPT ("-a",  "bring up all interfaces")
> > >  BAREBOX_CMD_HELP_OPT ("-f",  "Force. Configure even if ip already set")
> > > +BAREBOX_CMD_HELP_OPT ("-u",  "Probe USB ")
> > >  BAREBOX_CMD_HELP_END
> > > 
> > >  BAREBOX_CMD_START(ifup)
> > >  	.cmd		= do_ifup,
> > >  	BAREBOX_CMD_DESC("bring a network interface up")
> > > -	BAREBOX_CMD_OPTS("[-af] [INTF]")
> > > +	BAREBOX_CMD_OPTS("[-afu] [INTF]")
> > >  	BAREBOX_CMD_GROUP(CMD_GRP_NET)
> > >  	BAREBOX_CMD_COMPLETE(eth_complete)
> > >  	BAREBOX_CMD_HELP(cmd_ifup_help)
> > 
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> > 
> 
> 
> --
> Regards,
> Oleksij



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2021-09-09 10:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 7/8] ARM: boards: skov-imx6: set net.ifup_force_detect if no switch is detected Oleksij Rempel
2021-09-09  9:13 ` [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters Oleksij Rempel
2021-09-09  9:28   ` Lucas Stach
2021-09-09 10:24     ` Oleksij Rempel
2021-09-09 10:36       ` Lucas Stach [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d2d9969fef304fd82f5f3b894f5bbbf6a1d6bc7.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=linux@rempel-privat.de \
    --cc=o.rempel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox