[U-Boot-Users] [PATCH] net: add 'ethtoggle' environment variable

This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Signed-off-by: Matthias Fuchs matthias.fuchs@esd-electronics.com --- README | 4 ++++ net/net.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/README b/README index 9a8b3b9..9eac840 100644 --- a/README +++ b/README @@ -2687,6 +2687,10 @@ Some configuration options can be set using Environment Variables: => setenv ethact SCC ETHERNET => ping 10.0.0.1 # traffic sent on SCC ETHERNET
+ ethtoggle - When set to "no" U-Boot does not go through all + available network interfaces. + It just stays at the default interface. + netretry - When set to "no" each network operation will either succeed or fail without retrying. When set to "once" the network operation will diff --git a/net/net.c b/net/net.c index 44feee2..48ccd96 100644 --- a/net/net.c +++ b/net/net.c @@ -581,6 +581,7 @@ void NetStartAgain (void) { char *nretry; int noretry = 0, once = 0; + char *ethtoggle;
if ((nretry = getenv ("netretry")) != NULL) { noretry = (strcmp (nretry, "no") == 0); @@ -596,9 +597,15 @@ void NetStartAgain (void) NetSetHandler (startAgainHandler); #else /* !CONFIG_NET_MULTI*/ eth_halt (); -#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) - eth_try_another (!NetRestarted); -#endif + + /* + * Do not toggle between network interfaces when + * 'ethtoggle' variable is set to 'no'. + */ + if (((ethtoggle = getenv ("ethtoggle")) == NULL) || + (strcmp(ethtoggle, "no") != 0)) + eth_try_another (!NetRestarted); + eth_init (gd->bd); if (NetRestartWrap) { NetRestartWrap = 0;

Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
cheers, Ben

Hi Ben,
'ethtoggle' is the result of a discussion on irc some hours ago. Arguments have been: no 'eth' prefix and underscore (because 'ethprime' and 'ethact'). It was clear that the name of the variable would be most difficult site of its implementation.
If you suggest a better name, I am willing to rename it:-)
Matthias
On Wednesday 09 January 2008 18:45, Ben Warren wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
cheers, Ben

In message 47850837.6020608@gmail.com you wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
We discussed this on IRC this afternoon. The name was agreed between Matthias Fuchs, Stefan Roese, Jean-Christophe Plagniol-Villard, and me...
Best regards,
Wolfgang Denk

Wolfgang Denk wrote:
In message 47850837.6020608@gmail.com you wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
We discussed this on IRC this afternoon. The name was agreed between Matthias Fuchs, Stefan Roese, Jean-Christophe Plagniol-Villard, and me...
Best regards,
Wolfgang Denk
Fair enough. Lacking any creativity today, I'll shake my head and pull it in...
regards, Ben

On Wed, 09 Jan 2008 22:58:21 +0100 Wolfgang Denk wd@denx.de wrote:
In message 47850837.6020608@gmail.com you wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
We discussed this on IRC this afternoon. The name was agreed between Matthias Fuchs, Stefan Roese, Jean-Christophe Plagniol-Villard, and me...
toggle to me implies a binary sense, e.g. toggling a switch on/off, whereas this code doesn't turn eth on/off, it enables/disables the round-robin polling of eth devices. 'ethpoll' isn't quite precise enough either; what about 'ethcycle' ?
Kim

Kim Phillips wrote:
On Wed, 09 Jan 2008 22:58:21 +0100 Wolfgang Denk wd@denx.de wrote:
In message 47850837.6020608@gmail.com you wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
We discussed this on IRC this afternoon. The name was agreed between Matthias Fuchs, Stefan Roese, Jean-Christophe Plagniol-Villard, and me...
toggle to me implies a binary sense, e.g. toggling a switch on/off, whereas this code doesn't turn eth on/off, it enables/disables the round-robin polling of eth devices. 'ethpoll' isn't quite precise enough either; what about 'ethcycle' ?
Kim
Getting better...

In message 47854759.7020803@gmail.com you wrote:
toggle to me implies a binary sense, e.g. toggling a switch on/off, whereas this code doesn't turn eth on/off, it enables/disables the round-robin polling of eth devices. 'ethpoll' isn't quite precise enough either; what about 'ethcycle' ?
...
Getting better...
Well, the function that get's called is "eth_try_another()", so maybe "ethtryanother" ;-)
Best regards,
Wolfgang Denk

What about 'ethrotate' or 'ethshift' ?
Matthias
On Wednesday 09 January 2008 23:14, Ben Warren wrote:
Kim Phillips wrote:
On Wed, 09 Jan 2008 22:58:21 +0100 Wolfgang Denk wd@denx.de wrote:
In message 47850837.6020608@gmail.com you wrote:
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Good idea, but surely you can come up with a better word than 'ethtoggle'... It sounds like something Elmo would show to Big Bird and doesn't have anything to do with automatically advancing devices. Of course, I don't have any useful suggestions, but will think about it.
We discussed this on IRC this afternoon. The name was agreed between Matthias Fuchs, Stefan Roese, Jean-Christophe Plagniol-Villard, and me...
toggle to me implies a binary sense, e.g. toggling a switch on/off, whereas this code doesn't turn eth on/off, it enables/disables the round-robin polling of eth devices. 'ethpoll' isn't quite precise enough either; what about 'ethcycle' ?
Kim
Getting better...
Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

Dear Ben,
in message 200801091756.48890.matthias.fuchs@esd-electronics.com Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethtoggle' runtime configuration veriable. See README.
Signed-off-by: Matthias Fuchs matthias.fuchs@esd-electronics.com
Ack-by: Wolfgang Denk wd@denx.de
But please edit the doc:
diff --git a/README b/README index 9a8b3b9..9eac840 100644 --- a/README +++ b/README @@ -2687,6 +2687,10 @@ Some configuration options can be set using Environment Variables: => setenv ethact SCC ETHERNET => ping 10.0.0.1 # traffic sent on SCC ETHERNET
- ethtoggle - When set to "no" U-Boot does not go through all
available network interfaces.
It just stays at the default interface.
... It just stays at the currently selected interface.
Best regards,
Wolfgang Denk

This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethrotate' runtime configuration variable. See README.
Signed-off-by: Matthias Fuchs matthias.fuchs@esd-electronics.com --- README | 4 ++++ net/net.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/README b/README index 9a8b3b9..9ca512d 100644 --- a/README +++ b/README @@ -2687,6 +2687,10 @@ Some configuration options can be set using Environment Variables: => setenv ethact SCC ETHERNET => ping 10.0.0.1 # traffic sent on SCC ETHERNET
+ ethrotate - When set to "no" U-Boot does not go through all + available network interfaces. + It just stays at the currently selected interface. + netretry - When set to "no" each network operation will either succeed or fail without retrying. When set to "once" the network operation will diff --git a/net/net.c b/net/net.c index 44feee2..e1b71a9 100644 --- a/net/net.c +++ b/net/net.c @@ -581,6 +581,7 @@ void NetStartAgain (void) { char *nretry; int noretry = 0, once = 0; + char *ethrotate;
if ((nretry = getenv ("netretry")) != NULL) { noretry = (strcmp (nretry, "no") == 0); @@ -596,9 +597,15 @@ void NetStartAgain (void) NetSetHandler (startAgainHandler); #else /* !CONFIG_NET_MULTI*/ eth_halt (); -#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER) - eth_try_another (!NetRestarted); -#endif + + /* + * Do not rotate between network interfaces when + * 'ethrotate' variable is set to 'no'. + */ + if (((ethrotate = getenv ("ethrotate")) == NULL) || + (strcmp(ethrotate, "no") != 0)) + eth_try_another (!NetRestarted); + eth_init (gd->bd); if (NetRestartWrap) { NetRestartWrap = 0;

Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethrotate' runtime configuration variable. See README.
Signed-off-by: Matthias Fuchs matthias.fuchs@esd-electronics.com
README | 4 ++++ net/net.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/README b/README index 9a8b3b9..9ca512d 100644 --- a/README +++ b/README @@ -2687,6 +2687,10 @@ Some configuration options can be set using Environment Variables: => setenv ethact SCC ETHERNET => ping 10.0.0.1 # traffic sent on SCC ETHERNET
- ethrotate - When set to "no" U-Boot does not go through all
available network interfaces.
It just stays at the currently selected interface.
- netretry - When set to "no" each network operation will either succeed or fail without retrying. When set to "once" the network operation will
diff --git a/net/net.c b/net/net.c index 44feee2..e1b71a9 100644 --- a/net/net.c +++ b/net/net.c @@ -581,6 +581,7 @@ void NetStartAgain (void) { char *nretry; int noretry = 0, once = 0;
char *ethrotate;
if ((nretry = getenv ("netretry")) != NULL) { noretry = (strcmp (nretry, "no") == 0);
@@ -596,9 +597,15 @@ void NetStartAgain (void) NetSetHandler (startAgainHandler); #else /* !CONFIG_NET_MULTI*/ eth_halt (); -#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
- eth_try_another (!NetRestarted);
-#endif
- /*
* Do not rotate between network interfaces when
* 'ethrotate' variable is set to 'no'.
*/
- if (((ethrotate = getenv ("ethrotate")) == NULL) ||
(strcmp(ethrotate, "no") != 0))
eth_try_another (!NetRestarted);
- eth_init (gd->bd); if (NetRestartWrap) { NetRestartWrap = 0;
Thanks - applied.
regards, Ben

Hi Matthias,
Matthias Fuchs wrote:
This patch replaces the buildtime configuration option CONFIG_NET_DO_NOT_TRY_ANOTHER through the 'ethrotate' runtime configuration variable. See README.
Signed-off-by: Matthias Fuchs matthias.fuchs@esd-electronics.com
README | 4 ++++ net/net.c | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/README b/README index 9a8b3b9..9ca512d 100644 --- a/README +++ b/README @@ -2687,6 +2687,10 @@ Some configuration options can be set using Environment Variables: => setenv ethact SCC ETHERNET => ping 10.0.0.1 # traffic sent on SCC ETHERNET
- ethrotate - When set to "no" U-Boot does not go through all
available network interfaces.
It just stays at the currently selected interface.
- netretry - When set to "no" each network operation will either succeed or fail without retrying. When set to "once" the network operation will
diff --git a/net/net.c b/net/net.c index 44feee2..e1b71a9 100644 --- a/net/net.c +++ b/net/net.c @@ -581,6 +581,7 @@ void NetStartAgain (void) { char *nretry; int noretry = 0, once = 0;
char *ethrotate;
if ((nretry = getenv ("netretry")) != NULL) { noretry = (strcmp (nretry, "no") == 0);
@@ -596,9 +597,15 @@ void NetStartAgain (void) NetSetHandler (startAgainHandler); #else /* !CONFIG_NET_MULTI*/ eth_halt (); -#if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
- eth_try_another (!NetRestarted);
-#endif
- /*
* Do not rotate between network interfaces when
* 'ethrotate' variable is set to 'no'.
*/
- if (((ethrotate = getenv ("ethrotate")) == NULL) ||
(strcmp(ethrotate, "no") != 0))
eth_try_another (!NetRestarted);
- eth_init (gd->bd); if (NetRestartWrap) { NetRestartWrap = 0;
I'm a little curious about what it is you're trying to do. If you want to prevent Ethernet devices from ever rotating, this doesn't work. For example, if you set 'ethact' to an interface that isn't connected, eth_init() will rotate the interfaces until it reaches a valid link or the end of the chain, never reaching your change. If you really want to prevent rotation, I'd move your logic into the 'eth_try_another()' function itself, returning quickly if "ethrotate=no".
regards, Ben

Hi Ben,
On Saturday 12 January 2008 03:49, Ben Warren wrote:
I'm a little curious about what it is you're trying to do. If you want to prevent Ethernet devices from ever rotating, this doesn't work. For example, if you set 'ethact' to an interface that isn't connected, eth_init() will rotate the interfaces until it reaches a valid link or the end of the chain, never reaching your change. If you really want to prevent rotation, I'd move your logic into the 'eth_try_another()' function itself, returning quickly if "ethrotate=no".
regards, Ben
I will post a fixing patch in a minute.
Matthias
participants (4)
-
Ben Warren
-
Kim Phillips
-
Matthias Fuchs
-
Wolfgang Denk