From bc46dfac2f21756642e549b05689e03db538639f Mon Sep 17 00:00:00 2001 From: Jayachandran Chandrasekharan Nair Date: Tue, 10 Jul 2012 11:48:54 +0530 Subject: net: tftp: fix type of block arg to store_block The block argument for store_block can be -1 when the tftp sequence number rolls over (i.e TftpBlock == 0), so the first argument to store_block has to be of type 'int' instead of 'unsigned'. In our environment (gcc 4.4.5 mips toolchain), this causes incorrect 'offset' to be generated for storing the block, and the tftp block with number 0 will be written elsewhere, resulting in a bad block in the downloaded file and a memory corruption. Signed-off-by: Jayachandran Chandrasekharan Nair --- net/tftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/tftp.c b/net/tftp.c index b2e08b4bf..59a8ebb3c 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -156,7 +156,7 @@ mcast_cleanup(void) #endif /* CONFIG_MCAST_TFTP */ static inline void -store_block(unsigned block, uchar *src, unsigned len) +store_block(int block, uchar *src, unsigned len) { ulong offset = block * TftpBlkSize + TftpBlockWrapOffset; ulong newsize = offset + len; -- cgit v1.2.3-70-g09d2 From c88ef3c12dcf8596433d52a2631982d9d3a478dd Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Sat, 14 Apr 2012 18:06:49 +0000 Subject: net: allow setting env enetaddr from net device setting If the net driver has setup a valid ethernet address and an ethernet address is not set in the environment already, then set the environment variables from the net driver setting. This enables pxe booting on boards which don't set ethaddr env variable. Signed-off-by: Rob Herring --- doc/README.enetaddr | 6 +++++- net/eth.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/doc/README.enetaddr b/doc/README.enetaddr index 2d8e24f5c..1eaeaf941 100644 --- a/doc/README.enetaddr +++ b/doc/README.enetaddr @@ -32,7 +32,11 @@ Correct flow of setting up the MAC address (summarized): 1. Read from hardware in initialize() function 2. Read from environment in net/eth.c after initialize() -3. Give priority to the value in the environment if a conflict +3. The environment variable will be compared to the driver initialized + struct eth_device->enetaddr. If they differ, a warning is printed, and the + environment variable will be used unchanged. + If the environment variable is not set, it will be initialized from + eth_device->enetaddr, and a warning will be printed. 4. Program the address into hardware if the following conditions are met: a) The relevant driver has a 'write_addr' function b) The user hasn't set an 'ethmacskip' environment variable diff --git a/net/eth.c b/net/eth.c index d526264fa..6290b332f 100644 --- a/net/eth.c +++ b/net/eth.c @@ -62,6 +62,15 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index, return eth_getenv_enetaddr(enetvar, enetaddr); } +int eth_setenv_enetaddr_by_index(const char *base_name, int index, + uchar *enetaddr) +{ + char enetvar[32]; + sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); + return eth_setenv_enetaddr(enetvar, enetaddr); +} + + static int eth_mac_skip(int index) { char enetvar[15]; @@ -205,6 +214,11 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, } memcpy(dev->enetaddr, env_enetaddr, 6); + } else if (is_valid_ether_addr(dev->enetaddr)) { + eth_setenv_enetaddr_by_index(base_name, eth_number, + dev->enetaddr); + printf("\nWarning: %s using MAC address from net device\n", + dev->name); } if (dev->write_hwaddr && -- cgit v1.2.3-70-g09d2 From 154177e14a141468374f438ed3096ab097b79976 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Tue, 10 Jul 2012 16:23:22 -0500 Subject: net: Inline the new eth_setenv_enetaddr_by_index function This function is currently only used in one case. Inline for now. Signed-off-by: Joe Hershberger --- net/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net') diff --git a/net/eth.c b/net/eth.c index 6290b332f..1a11ce102 100644 --- a/net/eth.c +++ b/net/eth.c @@ -62,7 +62,7 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index, return eth_getenv_enetaddr(enetvar, enetaddr); } -int eth_setenv_enetaddr_by_index(const char *base_name, int index, +static inline int eth_setenv_enetaddr_by_index(const char *base_name, int index, uchar *enetaddr) { char enetvar[32]; -- cgit v1.2.3-70-g09d2 From 48a3e999c86e7e6033133152b07a308def559d46 Mon Sep 17 00:00:00 2001 From: Tetsuyuki Kobayashi Date: Tue, 3 Jul 2012 22:25:21 +0000 Subject: net: nfs: make NFS_TIMEOUT configurable NFS_TIMEOUT is constant value defined in net/nfs.c. But sometimes it needs to adjust. This patch enables to override NFS_TIMEOUT by defining CONFIG_NFS_TIMEOUT in a board specific config file. Signed-off-by: Tetsuyuki Kobayashi --- README | 7 +++++++ net/nfs.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/README b/README index dac46f35b..fb9d904a2 100644 --- a/README +++ b/README @@ -2149,6 +2149,13 @@ The following options need to be configured: Timeout waiting for an ARP reply in milliseconds. + CONFIG_NFS_TIMEOUT + + Timeout in milliseconds used in NFS protocol. + If you encounter "ERROR: Cannot umount" in nfs command, + try longer timeout such as + #define CONFIG_NFS_TIMEOUT 10000UL + - Command Interpreter: CONFIG_AUTO_COMPLETE diff --git a/net/nfs.c b/net/nfs.c index 5b9976354..7f2393f60 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -31,7 +31,11 @@ #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */ #define NFS_RETRY_COUNT 30 -#define NFS_TIMEOUT 2000UL +#ifndef CONFIG_NFS_TIMEOUT +# define NFS_TIMEOUT 2000UL +#else +# define NFS_TIMEOUT CONFIG_NFS_TIMEOUT +#endif static int fs_mounted; static unsigned long rpc_id; -- cgit v1.2.3-70-g09d2