public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot]  [PATCH] NetLoop initialization bug
@ 2009-03-22 17:35 Michael Zaidman
  2009-03-27  7:59 ` Michael Zaidman
  0 siblings, 1 reply; 21+ messages in thread
From: Michael Zaidman @ 2009-03-22 17:35 UTC (permalink / raw)
  To: u-boot

[U-Boot] [PATCH] NetLoop initialization bug



Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP command. It happens in the recently added mechanism of
the NetLoop initialization where initialization of global network parameters is
separated in the NetInitLoop routine which is called per env_id change.
Thus, ping request will initialize the network parameters necessary for ping
operation only, afterwards the env_changed_id will be set to the env_id
that will prevent all following initialization requests from other protocols.
The problem is that the initialized by ping subset of network parameters is not
sufficient for other protocols and particularly for TFTP
which requires the NetServerIp also.

Signed-off-by: michael.zaidman at kodak.com

diff --git a/net/net.c b/net/net.c
index a89f6a0..dc98d0f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -288,64 +288,13 @@ NetInitLoop(proto_t protocol)
 	if (env_changed_id == env_id)
 		return 0;

-	switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-	case NFS:
-#endif
-#if defined(CONFIG_CMD_PING)
-	case PING:
-#endif
-#if defined(CONFIG_CMD_SNTP)
-	case SNTP:
-#endif
-	case NETCONS:
-	case TFTP:
-		NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
-		NetOurGatewayIP = getenv_IPaddr ("gatewayip");
-		NetOurSubnetMask= getenv_IPaddr ("netmask");
-		NetOurVLAN = getenv_VLAN("vlan");
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
+	NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
+	NetOurGatewayIP = getenv_IPaddr ("gatewayip");
+	NetOurSubnetMask= getenv_IPaddr ("netmask");
+	NetServerIP = getenv_IPaddr ("serverip");
+	NetOurNativeVLAN = getenv_VLAN("nvlan");
+	NetOurVLAN = getenv_VLAN("vlan");

-		switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-		case NFS:
-#endif
-		case NETCONS:
-		case TFTP:
-			NetServerIP = getenv_IPaddr ("serverip");
-			break;
-#if defined(CONFIG_CMD_PING)
-		case PING:
-			/* nothing */
-			break;
-#endif
-#if defined(CONFIG_CMD_SNTP)
-		case SNTP:
-			/* nothing */
-			break;
-#endif
-		default:
-			break;
-		}
-
-		break;
-	case BOOTP:
-	case RARP:
-		/*
-		 * initialize our IP addr to 0 in order to accept ANY
-		 * IP addr assigned to us by the BOOTP / RARP server
-		 */
-		NetOurIP = 0;
-		NetServerIP = getenv_IPaddr ("serverip");
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-	case CDP:
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-		break;
-	default:
-		break;
-	}
 	env_changed_id = env_id;
 	return 0;
 }
@@ -443,18 +392,19 @@ restart:
 			/* Start with a clean slate... */
 			BootpTry = 0;
 			NetOurIP = 0;
-			NetServerIP = getenv_IPaddr ("serverip");
 			DhcpRequest();		/* Basically same as BOOTP */
 			break;
 #endif

 		case BOOTP:
 			BootpTry = 0;
+			NetOurIP = 0;
 			BootpRequest ();
 			break;

 		case RARP:
 			RarpTry = 0;
+			NetOurIP = 0;
 			RarpRequest ();
 			break;
 #if defined(CONFIG_CMD_PING)


Regards,
Michael Zaidman,
michael.zaidman at kodak.com

^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [U-Boot] [PATCH] NetLoop initialization bug
@ 2009-04-02 15:25 Michael Zaidman
  0 siblings, 0 replies; 21+ messages in thread
From: Michael Zaidman @ 2009-04-02 15:25 UTC (permalink / raw)
  To: u-boot

The patch fixes the bug of partial initialization of global network
parameters.

Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP transfers. It happens in the recently added mechanism of
NetLoop initialization where initialization of global network parameters is
separated in the NetInitLoop routine which is called per env_id change.
Thus, ping request will initialize the network parameters necessary
for ping operation only, afterwards the env_changed_id will be set
to the env_id that will prevent all following initialization requests
from other protocols.
The problem is that the initialized by ping subset of network parameters
is not sufficient for other protocols and particularly for TFTP
which requires the NetServerIp also.

Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
---
 net/net.c |   62 ++-------------------------------------------------------=
---
 1 files changed, 3 insertions(+), 59 deletions(-)

diff --git a/net/net.c b/net/net.c
index a89f6a0..edb4477 100644
--- a/net/net.c
+++ b/net/net.c
@@ -285,68 +285,15 @@ NetInitLoop(proto_t protocol)
 	int env_id =3D get_env_id ();

 	/* update only when the environment has changed */
-	if (env_changed_id =3D=3D env_id)
-		return 0;
-
-	switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-	case NFS:
-#endif
-#if defined(CONFIG_CMD_PING)
-	case PING:
-#endif
-#if defined(CONFIG_CMD_SNTP)
-	case SNTP:
-#endif
-	case NETCONS:
-	case TFTP:
+	if (env_changed_id !=3D env_id) {
 		NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
 		NetOurGatewayIP =3D getenv_IPaddr ("gatewayip");
 		NetOurSubnetMask=3D getenv_IPaddr ("netmask");
-		NetOurVLAN =3D getenv_VLAN("vlan");
-		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
-
-		switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-		case NFS:
-#endif
-		case NETCONS:
-		case TFTP:
-			NetServerIP =3D getenv_IPaddr ("serverip");
-			break;
-#if defined(CONFIG_CMD_PING)
-		case PING:
-			/* nothing */
-			break;
-#endif
-#if defined(CONFIG_CMD_SNTP)
-		case SNTP:
-			/* nothing */
-			break;
-#endif
-		default:
-			break;
-		}
-
-		break;
-	case BOOTP:
-	case RARP:
-		/*
-		 * initialize our IP addr to 0 in order to accept ANY
-		 * IP addr assigned to us by the BOOTP / RARP server
-		 */
-		NetOurIP =3D 0;
 		NetServerIP =3D getenv_IPaddr ("serverip");
-		NetOurVLAN =3D getenv_VLAN("vlan");	/* VLANs must be read */
 		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
-	case CDP:
-		NetOurVLAN =3D getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN =3D getenv_VLAN("nvlan");
-		break;
-	default:
-		break;
+		NetOurVLAN =3D getenv_VLAN("vlan");
+		env_changed_id =3D env_id;
 	}
-	env_changed_id =3D env_id;
 	return 0;
 }

@@ -440,10 +387,7 @@ restart:

 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
-			/* Start with a clean slate... */
 			BootpTry =3D 0;
-			NetOurIP =3D 0;
-			NetServerIP =3D getenv_IPaddr ("serverip");
 			DhcpRequest();		/* Basically same as BOOTP */
 			break;
 #endif
--=20
1.5.6.3

^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [U-Boot] [PATCH] NetLoop initialization bug
@ 2009-04-03 20:16 Michael Zaidman
  0 siblings, 0 replies; 21+ messages in thread
From: Michael Zaidman @ 2009-04-03 20:16 UTC (permalink / raw)
  To: u-boot

The patch fixes the bug of partial initialization of global network
parameters.

Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP command. It happens in the recently added mechanism of
the NetLoop initialization where initialization of global network
parameters is separated in the NetInitLoop routine which is called per
env_id change. Thus, ping request will initialize the network parameters
necessary for ping operation only, afterwards the env_changed_id will be
set to the env_id that will prevent all following initialization requests
from other protocols.
The problem is that the initialized by ping subset of network parameters
is not sufficient for other protocols and particularly for TFTP which
requires the NetServerIp also.

Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
---
 net/net.c |   61 +++----------------------------------------------------------
 1 files changed, 3 insertions(+), 58 deletions(-)

diff --git a/net/net.c b/net/net.c
index a89f6a0..97883df 100644
--- a/net/net.c
+++ b/net/net.c
@@ -285,67 +285,15 @@ NetInitLoop(proto_t protocol)
 	int env_id = get_env_id ();
 
 	/* update only when the environment has changed */
-	if (env_changed_id == env_id)
-		return 0;
-
-	switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-	case NFS:
-#endif
-#if defined(CONFIG_CMD_PING)
-	case PING:
-#endif
-#if defined(CONFIG_CMD_SNTP)
-	case SNTP:
-#endif
-	case NETCONS:
-	case TFTP:
+	if (env_changed_id != env_id) {
 		NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
 		NetOurGatewayIP = getenv_IPaddr ("gatewayip");
 		NetOurSubnetMask= getenv_IPaddr ("netmask");
-		NetOurVLAN = getenv_VLAN("vlan");
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-
-		switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-		case NFS:
-#endif
-		case NETCONS:
-		case TFTP:
-			NetServerIP = getenv_IPaddr ("serverip");
-			break;
-#if defined(CONFIG_CMD_PING)
-		case PING:
-			/* nothing */
-			break;
-#endif
-#if defined(CONFIG_CMD_SNTP)
-		case SNTP:
-			/* nothing */
-			break;
-#endif
-		default:
-			break;
-		}
-
-		break;
-	case BOOTP:
-	case RARP:
-		/*
-		 * initialize our IP addr to 0 in order to accept ANY
-		 * IP addr assigned to us by the BOOTP / RARP server
-		 */
-		NetOurIP = 0;
 		NetServerIP = getenv_IPaddr ("serverip");
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-	case CDP:
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
 		NetOurNativeVLAN = getenv_VLAN("nvlan");
-		break;
-	default:
-		break;
+		NetOurVLAN = getenv_VLAN("vlan");
 	}
+
 	env_changed_id = env_id;
 	return 0;
 }
@@ -440,10 +388,7 @@ restart:
 
 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
-			/* Start with a clean slate... */
 			BootpTry = 0;
-			NetOurIP = 0;
-			NetServerIP = getenv_IPaddr ("serverip");
 			DhcpRequest();		/* Basically same as BOOTP */
 			break;
 #endif
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [U-Boot] [PATCH] NetLoop initialization bug
@ 2009-04-03 22:43 Michael Zaidman
  0 siblings, 0 replies; 21+ messages in thread
From: Michael Zaidman @ 2009-04-03 22:43 UTC (permalink / raw)
  To: u-boot

The patch fixes the bug of partial initialization of global network
parameters.

Upon u-boot's start up the first ping command causes a failure of the
consequent TFTP command. It happens in the recently added mechanism of
the NetLoop initialization where initialization of global network
parameters is separated in the NetInitLoop routine which is called per
env_id change. Thus, ping request will initialize the network parameters
necessary for ping operation only, afterwards the env_changed_id will be
set to the env_id that will prevent all following initialization requests
from other protocols.
The problem is that the initialized by ping subset of network parameters
is not sufficient for other protocols and particularly for TFTP which
requires the NetServerIp also.

Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
---
 net/net.c |   63 +++---------------------------------------------------------
 1 files changed, 4 insertions(+), 59 deletions(-)

diff --git a/net/net.c b/net/net.c
index a89f6a0..b8648bd 100644
--- a/net/net.c
+++ b/net/net.c
@@ -285,68 +285,16 @@ NetInitLoop(proto_t protocol)
 	int env_id = get_env_id ();
 
 	/* update only when the environment has changed */
-	if (env_changed_id == env_id)
-		return 0;
-
-	switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-	case NFS:
-#endif
-#if defined(CONFIG_CMD_PING)
-	case PING:
-#endif
-#if defined(CONFIG_CMD_SNTP)
-	case SNTP:
-#endif
-	case NETCONS:
-	case TFTP:
+	if (env_changed_id != env_id) {
 		NetCopyIP(&NetOurIP, &bd->bi_ip_addr);
 		NetOurGatewayIP = getenv_IPaddr ("gatewayip");
 		NetOurSubnetMask= getenv_IPaddr ("netmask");
-		NetOurVLAN = getenv_VLAN("vlan");
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-
-		switch (protocol) {
-#if defined(CONFIG_CMD_NFS)
-		case NFS:
-#endif
-		case NETCONS:
-		case TFTP:
-			NetServerIP = getenv_IPaddr ("serverip");
-			break;
-#if defined(CONFIG_CMD_PING)
-		case PING:
-			/* nothing */
-			break;
-#endif
-#if defined(CONFIG_CMD_SNTP)
-		case SNTP:
-			/* nothing */
-			break;
-#endif
-		default:
-			break;
-		}
-
-		break;
-	case BOOTP:
-	case RARP:
-		/*
-		 * initialize our IP addr to 0 in order to accept ANY
-		 * IP addr assigned to us by the BOOTP / RARP server
-		 */
-		NetOurIP = 0;
 		NetServerIP = getenv_IPaddr ("serverip");
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
-		NetOurNativeVLAN = getenv_VLAN("nvlan");
-	case CDP:
-		NetOurVLAN = getenv_VLAN("vlan");	/* VLANs must be read */
 		NetOurNativeVLAN = getenv_VLAN("nvlan");
-		break;
-	default:
-		break;
+		NetOurVLAN = getenv_VLAN("vlan");
+		env_changed_id = env_id;
 	}
-	env_changed_id = env_id;
+
 	return 0;
 }
 
@@ -440,10 +388,7 @@ restart:
 
 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
-			/* Start with a clean slate... */
 			BootpTry = 0;
-			NetOurIP = 0;
-			NetServerIP = getenv_IPaddr ("serverip");
 			DhcpRequest();		/* Basically same as BOOTP */
 			break;
 #endif
-- 
1.5.6.3

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

end of thread, other threads:[~2009-04-03 22:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-22 17:35 [U-Boot] [PATCH] NetLoop initialization bug Michael Zaidman
2009-03-27  7:59 ` Michael Zaidman
2009-03-30  5:12   ` Heiko Schocher
2009-03-30  7:45     ` Wolfgang Denk
2009-03-30 13:07     ` Michael Zaidman
2009-03-31  6:36       ` Heiko Schocher
2009-03-31  9:30       ` Detlev Zundel
2009-03-31 10:47         ` Michael Zaidman
2009-03-31 16:26         ` Michael Zaidman
2009-04-02 12:47           ` Detlev Zundel
2009-04-02 15:47             ` Michael Zaidman
2009-04-02 21:52               ` Ben Warren
2009-04-03 20:05                 ` Wolfgang Denk
2009-04-03 20:20                 ` Michael Zaidman
2009-04-03 20:28                   ` Wolfgang Denk
2009-04-03 20:41                     ` Ben Warren
2009-04-03 20:39                   ` Ben Warren
2009-04-03 21:02                     ` Michael Zaidman
  -- strict thread matches above, loose matches on Subject: below --
2009-04-02 15:25 Michael Zaidman
2009-04-03 20:16 Michael Zaidman
2009-04-03 22:43 Michael Zaidman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox