mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes
@ 2021-09-09  9:13 Oleksij Rempel
  2021-09-09  9:13 ` [PATCH v1 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node Oleksij Rempel
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

We need USB working to make use of USB ethernet adapters.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/dts/imx6qdl-skov-imx6.dtsi | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/dts/imx6qdl-skov-imx6.dtsi b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
index 03f3cb02fc..371a931e53 100644
--- a/arch/arm/dts/imx6qdl-skov-imx6.dtsi
+++ b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
@@ -273,6 +273,26 @@
 	remote-endpoint = <&display0_in>;
 };
 
+&usbh1 {
+	disable-over-current;
+	status = "okay";
+};
+
+/* no usbh2 */
+&usbphynop1 {
+	status = "disabled";
+};
+
+/* no usbh3 */
+&usbphynop2 {
+	status = "disabled";
+};
+
+&usbotg {
+	disable-over-current;
+	status = "okay";
+};
+
 &iomuxc {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_hog>;
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 2/8] ARM: boards: skov-imx6: fixup_machine_compatible() add optional root node
  2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
@ 2021-09-09  9:13 ` Oleksij Rempel
  2021-09-09  9:13 ` [PATCH v1 3/8] ARM: boards: skov-imx6: add switch detection Oleksij Rempel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

This will be needed by the next patch

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index a58172b2b1..030ac62c52 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -432,16 +432,18 @@ static void skov_init_board(const struct board_description *variant)
 	}
 }
 
-static void fixup_machine_compatible(const char *compat)
+static void fixup_machine_compatible(const char *compat,
+				     struct device_node *root)
 {
 	const char *curcompat;
-	struct device_node *root;
 	int cclen = 0, clen = strlen(compat) + 1;
 	void *buf;
 
-	root = of_get_root_node();
-	if (!root)
-		return;
+	if (!root) {
+		root = of_get_root_node();
+		if (!root)
+			return;
+	}
 
 	curcompat = of_get_property(root, "compatible", &cclen);
 
@@ -487,7 +489,7 @@ static int skov_imx6_probe(struct device_d *dev)
 	globalvar_add_simple("board.dts", variant->dts_compatible);
 	globalvar_add_simple("board.display", variant->display ?: NULL);
 
-	fixup_machine_compatible(variant->dts_compatible);
+	fixup_machine_compatible(variant->dts_compatible, NULL);
 
 	skov_init_board(variant);
 
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 3/8] ARM: boards: skov-imx6: add switch detection
  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 ` 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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

There are board variants with same board ID but not switch. Detect this
variants.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 159 +++++++++++++++++++++++++-----
 1 file changed, 135 insertions(+), 24 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 030ac62c52..2bd21adaeb 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <of_gpio.h>
 #include <gpio.h>
+#include <linux/micrel_phy.h>
 
 #include "version.h"
 
@@ -130,6 +131,9 @@ copy_mac_from_eth0:
 	return eth_of_fixup_node_from_eth_device(root, node_path, ethname);
 }
 
+#define SKOV_GPIO_MDIO_BUS	0
+#define SKOV_LAN1_PHY_ADDR	1
+
 #define MAX_V_GPIO 8
 
 struct board_description {
@@ -303,20 +307,121 @@ static const struct board_description imx6_variants[] = {
 };
 
 static int skov_board_no = -1;
+static bool skov_no_switch = false;
+static const char *no_switch_suffix = "-noswitch";
 
-static int skov_imx6_fixup(struct device_node *root, void *unused)
+static void fixup_machine_compatible(const char *compat,
+				     struct device_node *root)
 {
+	int cclen = 0, clen = strlen(compat) + 1;
+	const char *curcompat;
+	void *buf;
+
+	if (!root) {
+		root = of_get_root_node();
+		if (!root)
+			return;
+	}
+
+	curcompat = of_get_property(root, "compatible", &cclen);
+
+	buf = xzalloc(cclen + clen);
+
+	memcpy(buf, compat, clen);
+	memcpy(buf + clen, curcompat, cclen);
+
+	/*
+	 * Prepend the compatible from board entry to the machine compatible.
+	 * Used to match bootspec entries against it.
+	 */
+	of_set_property(root, "compatible", buf, cclen + clen, true);
+
+	free(buf);
+}
+
+static void fixup_noswitch_machine_compatible(struct device_node *root)
+{
+	const char *compat = imx6_variants[skov_board_no].dts_compatible;
+	const char *generic = "skov,imx6";
+	size_t size, size_generic;
+	char *buf;
 	int ret;
-	const char *val;
-	uint32_t brightness;
+
+	size = strlen(compat) + strlen(no_switch_suffix) + 1;
+	size_generic = strlen(generic) + strlen(no_switch_suffix) + 1;
+	size = max(size, size_generic);
+	buf = xzalloc(size);
+	if (!buf) {
+		pr_warn("Can't allocate buffer\n");
+		return;
+	}
+
+	/* add generic compatible, so systemd&co can make right decisions */
+	ret = snprintf(buf, size, "%s%s", generic, no_switch_suffix);
+	if (ret >= 0)
+		fixup_machine_compatible(buf, root);
+	else
+		pr_warn("Can't prepare generic compatible string\n");
+
+	/* add specific compatible as fallback, in case this board has new
+	 * challenges.
+	 */
+	ret = snprintf(buf, size, "%s%s", compat, no_switch_suffix);
+	if (ret >= 0)
+		fixup_machine_compatible(buf, root);
+	else
+		pr_warn("Can't prepare specific compatible string\n");
+
+	free(buf);
+}
+
+static void skov_imx6_no_switch(struct device_node *root)
+{
 	struct device_node *node;
-	struct device_node *chosen = of_create_node(root, "/chosen");
+	int ret;
+
+	fixup_noswitch_machine_compatible(root);
 
+	node = of_find_node_by_path_from(root, "/soc/bus@2100000/ethernet@2188000");
+	if (!node) {
+		pr_warn("Did not find node to disable it\n");
+	} else {
+		ret = of_device_disable(node);
+		if (ret)
+			pr_warn("Can't disable ethernet node\n");
+	}
+
+	node = of_find_node_by_alias(root, "mdio-gpio0");
+	if (node) {
+		ret = of_device_disable(node);
+		if (ret)
+			pr_warn("Can't disable mdio-gpio0 node\n");
+	} else {
+		pr_warn("Can't find mdio-gpio0 node\n");
+	}
+}
+
+static void skov_imx6_switch(struct device_node *root)
+{
 	eth_of_fixup_node_from_eth_device(root,
 			"/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
 	eth2_of_fixup_node_individually(root,
 		"/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
 		"state.ethaddr.eth2", "/state/ethaddr/eth2");
+}
+
+static int skov_imx6_fixup(struct device_node *root, void *unused)
+{
+	struct device_node *chosen = of_create_node(root, "/chosen");
+	struct device_node *node;
+	uint32_t brightness;
+	const char *val;
+	int ret;
+
+	if (skov_no_switch)
+		skov_imx6_no_switch(root);
+	else
+		skov_imx6_switch(root);
 
 	switch (bootsource_get()) {
 	case BOOTSOURCE_MMC:
@@ -432,34 +537,40 @@ static void skov_init_board(const struct board_description *variant)
 	}
 }
 
-static void fixup_machine_compatible(const char *compat,
-				     struct device_node *root)
+static int skov_switch_test(void)
 {
-	const char *curcompat;
-	int cclen = 0, clen = strlen(compat) + 1;
-	void *buf;
+	struct phy_device *phydev;
+	struct mii_bus *mii;
+	int ret;
 
-	if (!root) {
-		root = of_get_root_node();
-		if (!root)
-			return;
-	}
+	if (skov_board_no < 0)
+		return 0;
 
-	curcompat = of_get_property(root, "compatible", &cclen);
+	/* On this boards, we have only one MDIO bus. So, it is enough to take
+	 * the first one.
+	 */
+	mii = mdiobus_get_bus(SKOV_GPIO_MDIO_BUS);
+	/* We can't read the switch ID, but we get get ID of the first PHY,
+	 * which is enough to test if the switch is attached.
+	 */
+	phydev = get_phy_device(mii, SKOV_LAN1_PHY_ADDR);
+	if (IS_ERR(phydev))
+		goto no_switch;
 
-	buf = xzalloc(cclen + clen);
+	if (phydev->phy_id != PHY_ID_KSZ886X)
+		goto no_switch;
 
-	memcpy(buf, compat, clen);
-	memcpy(buf + clen, curcompat, cclen);
+	return 0;
 
-	/*
-	 * Prepend the compatible from board entry to the machine compatible.
-	 * Used to match bootspec entries against it.
-	 */
-	of_set_property(root, "compatible", buf, cclen + clen, true);
+no_switch:
+	skov_no_switch = true;
+	fixup_noswitch_machine_compatible(NULL);
 
-	free(buf);
+	pr_notice("No-switch variant is detected\n");
+
+	return 0;
 }
+late_initcall(skov_switch_test);
 
 static int skov_imx6_probe(struct device_d *dev)
 {
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 4/8] ARM: boards: skov-imx6: disable eth0 for barebox if no switch is detected
  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 ` Oleksij Rempel
  2021-09-09  9:13 ` [PATCH v1 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 2bd21adaeb..c4665c2b45 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -540,6 +540,7 @@ static void skov_init_board(const struct board_description *variant)
 static int skov_switch_test(void)
 {
 	struct phy_device *phydev;
+	struct device_d *eth0;
 	struct mii_bus *mii;
 	int ret;
 
@@ -568,6 +569,15 @@ no_switch:
 
 	pr_notice("No-switch variant is detected\n");
 
+	eth0 = get_device_by_name("eth0");
+	if (eth0) {
+		ret = dev_set_param(eth0, "mode", "disabled");
+		if (ret)
+			pr_warn("Can't set eth0 mode\n");
+	} else {
+		pr_warn("Can't disable eth0\n");
+	}
+
 	return 0;
 }
 late_initcall(skov_switch_test);
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 5/8] ARM: boards: skov-imx6: fixup different DTS variants
  2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
                   ` (2 preceding siblings ...)
  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 ` Oleksij Rempel
  2021-09-09  9:13 ` [PATCH v1 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 47 +++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index c4665c2b45..8961c8dd53 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -401,13 +401,50 @@ static void skov_imx6_no_switch(struct device_node *root)
 	}
 }
 
+static int skov_imx6_switch_port(struct device_node *root, const char *path)
+{
+	size_t size;
+	char *buf;
+	int ret;
+
+	size = strlen(path) + 1;
+	buf = xzalloc(size);
+	if (!buf)
+		return -ENOMEM;
+
+	ret = snprintf(buf, size, "%s0", path);
+	if (ret < 0)
+		return ret;
+
+	ret = eth_of_fixup_node_from_eth_device(root, buf, "eth0");
+	if (ret)
+		return ret;
+
+	ret = snprintf(buf, size, "%s1", path);
+	if (ret < 0)
+		return ret;
+
+	ret = eth2_of_fixup_node_individually(root, buf, "eth0",
+					      "state.ethaddr.eth2",
+					      "/state/ethaddr/eth2");
+	return ret;
+}
+
 static void skov_imx6_switch(struct device_node *root)
 {
-	eth_of_fixup_node_from_eth_device(root,
-			"/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
-	eth2_of_fixup_node_individually(root,
-		"/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
-		"state.ethaddr.eth2", "/state/ethaddr/eth2");
+	const char *old = "/mdio-gpio/ksz8873@3/ports/ports@";
+	const char *new = "/mdio/switch@0/ports/ports@";
+	int ret;
+
+	/* Old DTS variants (pre kernel mainline) use different path. Try first
+	 * the new variant the fall back for the old one
+	 */
+	ret = skov_imx6_switch_port(root, new);
+	if (ret) {
+		ret = skov_imx6_switch_port(root, old);
+		if (ret)
+			pr_err("Filed to set mac address\n");
+	}
 }
 
 static int skov_imx6_fixup(struct device_node *root, void *unused)
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 6/8] ARM: boards: skov-imx6: start using deep-probe
  2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
                   ` (3 preceding siblings ...)
  2021-09-09  9:13 ` [PATCH v1 5/8] ARM: boards: skov-imx6: fixup different DTS variants Oleksij Rempel
@ 2021-09-09  9:13 ` 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
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

Port Skov boards to the deep-propbe and reduce boot time by 100msec.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 8961c8dd53..618c6eb6b4 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -2,16 +2,17 @@
 
 #define pr_fmt(fmt) "skov-imx6: " fmt
 
+#include <bootsource.h>
 #include <common.h>
-#include <init.h>
-#include <mach/bbu.h>
+#include <deep-probe.h>
 #include <environment.h>
-#include <bootsource.h>
 #include <globalvar.h>
-#include <net.h>
-#include <of_gpio.h>
 #include <gpio.h>
+#include <init.h>
 #include <linux/micrel_phy.h>
+#include <mach/bbu.h>
+#include <net.h>
+#include <of_gpio.h>
 
 #include "version.h"
 
@@ -499,10 +500,20 @@ static int skov_imx6_fixup(struct device_node *root, void *unused)
  */
 static void skov_init_board(const struct board_description *variant)
 {
+	struct device_node *gpio_np = NULL;
 	struct device_node *np;
 	char *environment_path, *envdev;
 	int ret;
 
+	gpio_np = of_find_node_by_name(NULL, "gpio@20b4000");
+	if (gpio_np) {
+		ret = of_device_ensure_probed(gpio_np);
+		if (ret)
+			pr_warn("Can't probe GPIO node\n");
+	} else {
+		pr_warn("Can't get GPIO node\n");
+	}
+
 	imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox",
 		BBU_HANDLER_FLAG_DEFAULT);
 
@@ -661,6 +672,7 @@ static __maybe_unused struct of_device_id skov_version_ids[] = {
 		/* sentinel */
 	}
 };
+BAREBOX_DEEP_PROBE_ENABLE(skov_version_ids);
 
 static struct driver_d skov_version_driver = {
 	.name = "skov-imx6",
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 7/8] ARM: boards: skov-imx6: set net.ifup_force_detect if no switch is detected
  2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
                   ` (4 preceding siblings ...)
  2021-09-09  9:13 ` [PATCH v1 6/8] ARM: boards: skov-imx6: start using deep-probe Oleksij Rempel
@ 2021-09-09  9:13 ` Oleksij Rempel
  2021-09-09  9:13 ` [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters Oleksij Rempel
  6 siblings, 0 replies; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

In case of the no-switch board, we can only do the net boot over an USB
ethernet adapter. Since USB probing is slow, we do not probe it for
normal boot. So, set net.ifup_force_detect to probe everything possible
in case the net boot is chosen.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/skov-imx6/board.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
index 618c6eb6b4..9a32e68f21 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -626,6 +626,8 @@ no_switch:
 		pr_warn("Can't disable eth0\n");
 	}
 
+	globalvar_set("net.ifup_force_detect", "true");
+
 	return 0;
 }
 late_initcall(skov_switch_test);
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters
  2021-09-09  9:13 [PATCH v1 1/8] ARM: dts: skov-imx6: add USB nodes Oleksij Rempel
                   ` (5 preceding siblings ...)
  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 ` Oleksij Rempel
  2021-09-09  9:28   ` Lucas Stach
  6 siblings, 1 reply; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09  9:13 UTC (permalink / raw)
  To: barebox; +Cc: 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.

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)
-- 
2.30.2


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Lucas Stach @ 2021-09-09  9:28 UTC (permalink / raw)
  To: Oleksij Rempel, barebox

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?

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters
  2021-09-09  9:28   ` Lucas Stach
@ 2021-09-09 10:24     ` Oleksij Rempel
  2021-09-09 10:36       ` Lucas Stach
  0 siblings, 1 reply; 11+ messages in thread
From: Oleksij Rempel @ 2021-09-09 10:24 UTC (permalink / raw)
  To: Lucas Stach, Oleksij Rempel, barebox

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?

> 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 8/8] ifup: optimize net boot time for USB ethernet adapters
  2021-09-09 10:24     ` Oleksij Rempel
@ 2021-09-09 10:36       ` Lucas Stach
  0 siblings, 0 replies; 11+ messages in thread
From: Lucas Stach @ 2021-09-09 10:36 UTC (permalink / raw)
  To: Oleksij Rempel, Oleksij Rempel, barebox

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-09 10:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox