standardize mac address handling in u-boot
cover standardize mac address handling in u-boot
this set of patches aims to standardize the mac address handling in all of u-boot by doing the following:
- add helper funcs for working with mac addresses (binary & string)
- convert all duplicated code to use aforementioned helper funcs
- convert all places to get the mac address from the environment
- drop the global data instances of bi_enet*addr
- document the whole damned thing
ive taken pains to make sure the patchset doesnt break along the way (in terms of doing bisection and such). but in general, the interdependency looks something like:
- add util funcs
- convert net/boards/drivers/cpu/commands from global data to env
- convert arch/board.c init to not touch global data
- remove global data from all arch headers
the ppc steps with load_sernum_ethaddr() are a little hairy due to the spread of code and trying to make sure things don't break bisection. but the other option is to squash all these commits (the common ppc board code as well as each individual board) into one change. doesn't matter to me either way.
currently this patch series is maintained in my tree:
git://www.denx.de/git/u-boot-blackfin.git macaddr
Mike Frysinger (27):
net: new utility functions for working with enetaddr's doc/README.enetaddr: document proper MAC usage
Blackfin: bfin_mac: force boards to setup the MAC themselves
net: get mac address from environment and use eth util funcs
bdinfo: get mac address from environment
bootvx: get mac address from environment
lynxkdi: get mac address from environment
nvedit: do not update global bi_enetaddr and do not call
eth_set_enetaddr()
AmigaOneG3SE/enet: get mac address from environment
boards: get mac address from environment
drivers/net/: get mac address from environment
bcm570x: get mac address from environment
cs8900: get mac address from environment
sh_eth: get mac address from environment lan91c96/smc91111/smc911x: get mac address from environment cpu/: get mac address from environment
npe: get mac address from environment
lib_*/board.c: do not initialize bi_enet*addr in global data
nx823: get mac address from environment
arm: get mac address from environment
cmc_pu2: get mac address from environment
pcs440ep: get mac address from environment and move
load_sernum_ethaddr() to board init
kup4k/kup4x: rename load_sernum_ethaddr() to
kup_load_sernum_ethaddr()
tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
ppc: do not initialize bi_enet*addr in global data drop now unused load_sernum_ethaddr() function
remove bi_enet*addr from global data for all arches
board/MAI/AmigaOneG3SE/enet.c | 42 ++-------- board/cmc_pu2/load_sernum_ethaddr.c | 18 +---- board/etin/debris/debris.c | 6 +- board/keymile/mgcoge/mgcoge.c | 4 +- board/keymile/mgsuvd/mgsuvd.c | 4 +- board/kup/common/load_sernum_ethaddr.c | 2 +- board/kup/kup4k/kup4k.c | 3 + board/kup/kup4x/kup4x.c | 4 +- board/m501sk/m501sk.c | 5 - board/mpl/vcma9/cmd_vcma9.c | 11 +-- board/muas3001/muas3001.c | 4 +- board/netstal/common/nm_bsp.c | 40 +++------- board/nx823/flash.c | 5 +- board/nx823/nx823.c | 41 ++++------ board/pcs440ep/pcs440ep.c | 31 +++---- board/pn62/pn62.c | 24 ++---- board/sixnet/sixnet.c | 11 +-- board/tqc/tqm8xx/load_sernum_ethaddr.c | 2 +- board/tqc/tqm8xx/tqm8xx.c | 3 + board/xilinx/xilinx_enet/emac_adapter.c | 8 ++- common/cmd_bdinfo.c | 136 +++++++++---------------------- common/cmd_elf.c | 6 +- common/cmd_nvedit.c | 24 +----- common/lynxkdi.c | 2 +- cpu/arm920t/at91rm9200/ether.c | 8 +- cpu/ixp/npe/npe.c | 36 +++------ cpu/mpc512x/cpu.c | 6 +- cpu/mpc5xxx/cpu.c | 6 +- cpu/mpc8260/ether_fcc.c | 4 +- cpu/mpc8260/ether_scc.c | 4 +- cpu/ppc4xx/cpu_init.c | 14 ++-- doc/README.enetaddr | 96 ++++++++++++++++++++++ drivers/net/3c589.c | 7 +- drivers/net/4xx_enet.c | 13 +-- drivers/net/bcm570x.c | 4 +- drivers/net/bcm570x_lm.h | 2 +- drivers/net/bfin_mac.c | 16 ++-- drivers/net/bfin_mac.h | 2 +- drivers/net/cs8900.c | 58 ++++--------- drivers/net/dc2114x.c | 9 ++- drivers/net/dm9000x.c | 27 ++----- drivers/net/enc28j60.c | 4 +- drivers/net/fsl_mcdmafec.c | 11 ++- drivers/net/ks8695eth.c | 9 +-- drivers/net/lan91c96.c | 79 ++++--------------- drivers/net/mcffec.c | 10 +- drivers/net/rtl8019.c | 14 ++-- drivers/net/rtl8169.c | 2 +- drivers/net/s3c4510b_eth.c | 2 +- drivers/net/s3c4510b_eth.h | 2 +- drivers/net/sh_eth.c | 28 ++----- drivers/net/smc91111.c | 76 ++++-------------- drivers/net/smc911x.c | 15 ++-- drivers/net/tigon3.c | 7 +- drivers/net/xilinx_emac.c | 12 ++- drivers/net/xilinx_emaclite.c | 11 ++- include/asm-arm/u-boot.h | 5 - include/asm-avr32/u-boot.h | 1 - include/asm-blackfin/u-boot.h | 1 - include/asm-i386/u-boot.h | 1 - include/asm-m68k/u-boot.h | 13 --- include/asm-microblaze/u-boot.h | 1 - include/asm-mips/u-boot.h | 1 - include/asm-nios/u-boot.h | 1 - include/asm-nios2/u-boot.h | 1 - include/asm-ppc/u-boot.h | 19 ----- include/asm-sh/u-boot.h | 1 - include/asm-sparc/u-boot.h | 12 --- include/common.h | 2 - include/configs/cmc_pu2.h | 1 + include/net.h | 4 + lib_arm/board.c | 47 +++-------- lib_blackfin/board.c | 48 +----------- lib_i386/board.c | 17 ---- lib_m68k/board.c | 38 --------- lib_microblaze/board.c | 8 -- lib_mips/board.c | 8 -- lib_nios/board.c | 5 - lib_nios2/board.c | 5 - lib_ppc/board.c | 96 ---------------------- lib_sh/board.c | 10 --- lib_sparc/board.c | 19 ----- net/bootp.c | 13 +--- net/eth.c | 79 +++++++++++------- net/net.c | 20 ++--- post/cpu/mpc8xx/ether.c | 4 +- 86 files changed, 497 insertions(+), 1014 deletions(-) create mode 100644 doc/README.enetaddr
PATCH 1/27 net: new utility functions for working with enetaddr's
Declare new utility functions for converting between the environment variables (eth*addr) and the binary MAC address representation. This way we can unify all the random places that already do this kind of thing.
The functions in question:
eth_parse_enetaddr - "..." -> {...}
eth_getenv_enetaddr - env -> {...}
eth_setenv_enetaddr - {...} -> env
str_enetaddr - {...} -> "..."--- include/net.h | 4 +++ net/eth.c | 79 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 31 deletions(-)
include/net.h +4 -0
@@ -119,6 +119,10 @@ extern struct eth_device *eth_get_dev(void); /* get the current device MAC */extern struct eth_device *eth_get_dev_by_name (char *devname);/* get device */ extern int eth_get_dev_index (void );/* get the device index */ extern void eth_set_enetaddr (int num,char * a);/* Set new MAC address */ +extern void eth_parse_enetaddr (const char *addr,uchar *enetaddr); +extern int eth_getenv_enetaddr (char *name,uchar *enetaddr); +extern int eth_setenv_enetaddr (char *name,const uchar *enetaddr); +extern char *str_enetaddr (char *buf,const uchar *enetaddr);extern int eth_init (bd_t *bis);/* Initialize the device */ extern int eth_send (volatile void *packet,int length);/* Send a packet */
net/eth.c +48 -31
122 lines not on this page · raw message
Signature · 1 line
1.6.1.3
PATCH 1/27 net: new utility functions for working with enetaddr's
Dear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
Declare new utility functions for converting between the environment variables (eth*addr) and the binary MAC address representation. This way we can unify all the random places that already do this kind of thing.
...
net/eth.c line 41
Quoted 13 lines
net/eth.c +13
-0+#ifdef CONFIG_CMD_NET +char *str_enetaddr (char *buf,const uchar *enetaddr) +{ +sprintf (buf,"%02X:%02X:%02X:%02X:%02X:%02X" , + enetaddr[0 ], enetaddr[1 ], enetaddr[2 ], + enetaddr[3 ], enetaddr[4 ], enetaddr[5 ]); +return buf; +} + +void eth_parse_enetaddr (const char *addr,uchar *enetaddr) +{ +char *end; +int i;
Empty line here...
net/eth.c line 52
Quoted 11 lines
net/eth.c +11
-0+for (i =0 ; i <6 ; ++i) { + enetaddr[i] = addr ?simple_strtoul (addr, &end,16 ) :0 ; +if (addr) + addr = (*end) ? end +1 : end; + } +} + +int eth_getenv_enetaddr (char *name,uchar *enetaddr) +{ +int ret =0 ; +char *addr =getenv (name);
Empty line here...
net/eth.c line 61
Quoted 9 lines
net/eth.c +9
-0+if (!addr) + ret =-1 ; +eth_parse_enetaddr (addr, enetaddr); +return ret; +} + +int eth_setenv_enetaddr (char *name,const uchar *enetaddr) +{ +char buf[20 ];
Empty line here...
and so on...
Quoted 1 line
net/eth.c +1
-0+return setenv (name,str_enetaddr (buf, enetaddr));
...
net/eth.c int eth_initialize(bd_t *bis) · line 222
Quoted 4 lines
net/eth.c +4
-0+printf ("Address in SROM is %s\n" , +str_enetaddr (enetvar, dev->enetaddr)); +printf ("Address in environment is %s\n" , +str_enetaddr (enetvar, env_enetaddr));
Hm... Linux has a printk() format specifier for MAC addresses. Sounds like a clever idea to me. Maybe we should borrow that code?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de You can do this in a number of ways. IBM chose to do all of them. Why do you find that funny? -- D. Taylor, Computer Science 350
PATCH 1/27 net: new utility functions for working with enetaddr's
Quoted 8 lines · On Monday 16 February 2009 17:28:24 Wolfgang Denk wrote:
net/eth.c int eth_initialize(bd_t *bis) · line 222
Quoted 4 lines · In message Mike Frysinger
net/eth.c +4
-0+printf ("Address in SROM is %s\n" , +str_enetaddr (enetvar, dev->enetaddr)); +printf ("Address in environment is %s\n" , +str_enetaddr (enetvar, env_enetaddr));Hm... Linux has a
printk()format specifier for MAC addresses. Sounds like a clever idea to me. Maybe we should borrow that code?
it does eh ? that certainly sounds a lot better than str_enetaddr() as every place i changed to use it was in a printf() string. where in the kernel is that code ? i looked in lib/vsprintf.c but couldnt find it.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/684ef220/attachment.pgp
PATCH 1/27 net: new utility functions for working with enetaddr's
Dear Mike,
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Hm... Linux has a
printk()format specifier for MAC addresses. Sounds like a clever idea to me. Maybe we should borrow that code?it does eh ? that certainly sounds a lot better than
str_enetaddr()as every place i changed to use it was in aprintf()string. where in the kernel is that code ? i looked inlib/vsprintf.cbut couldnt find it.
But it is in lib/vsprintf.c:
...
644 /*
645 * Show a '%p' thing. A kernel extension is that the '%p' is followed 646 * by an extra set of alphanumeric characters that are extended format 647 * specifiers. 648 * 649 * Right now we handle: 650 * 651 * - 'F' For symbolic function descriptor pointers 652 * - 'S' For symbolic direct pointers 653 * - 'R' For a struct resource pointer, it prints the range of 654 * addresses (not the name nor the flags) 655 * - 'M' For a 6-byte MAC address, it prints the address in the 656 * usual colon-separated hex notation 657 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way (dot-separated 658 * decimal for v4 and colon separated network-order 16 bit hex for v6) 659 * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is 660 * currently the same
...
So it's actually printk("%pM", ...);
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de To be sure of hitting the target, shoot first and, whatever you hit, call it the target.
PATCH 1/27 net: new utility functions for working with enetaddr's
Quoted 11 lines · On Monday 16 February 2009 19:13:31 Wolfgang Denk wrote:
Dear Mike,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Hm... Linux has a
printk()format specifier for MAC addresses. Sounds like a clever idea to me. Maybe we should borrow that code?it does eh ? that certainly sounds a lot better than
str_enetaddr()as every place i changed to use it was in aprintf()string. where in the kernel is that code ? i looked inlib/vsprintf.cbut couldnt find it.But it is in
lib/vsprintf.c:
apparently it's new to 2.6.29 ... i'm actively working/looking at 2.6.28.x which doesnt have 'M'.
Quoted 15 lines
...
644 /*645 * Show a '%p' thing. A kernel extension is that the '%p' is followed 646 * by an extra set of alphanumeric characters that are extended format 647 * specifiers. 648 * 649 * Right now we handle: 650 * 651 * - 'F' For symbolic function descriptor pointers 652 * - 'S' For symbolic direct pointers 653 * - 'R' For a struct resource pointer, it prints the range of 654 * addresses (not the name nor the flags) 655 * - 'M' For a 6-byte MAC address, it prints the address in the 656 * usual colon-separated hex notation 657 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way
Quoted 6 lines
(dot-separated 658 * decimal for v4 and colon separated
network-order 16 bit hex for v6) 659 * - 'i' [46] for 'raw' IPv4/IPv6
addresses, IPv6 omits the colons, IPv4 is 660 * currently the same
...So it's actually
printk("%pM", ...);
so do you want to go the %pM route (to make u-boot/linux code sharing easier) or move over only %M ?
-mike
PATCH 1/27 net: new utility functions for working with enetaddr's
Quoted 2 lines · Mike Frysinger
so do you want to go the %pM route (to make u-boot/linux code sharing easier) or move over only %M ?
The latter would require turning off GCC's format checking.
-Scott
PATCH 1/27 net: new utility functions for working with enetaddr's
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
apparently it's new to 2.6.29 ... i'm actively working/looking at 2.6.28.x which doesnt have 'M'.
Eventually that was triggered from our discussion here :-)
Quoted 4 lines
Quoted 1 line
So it's actually
printk("%pM", ...);so do you want to go the %pM route (to make u-boot/linux code sharing easier) or move over only %M ?
I don't really care, but for the sake of code compatibility we probably should use Linux style.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de If it happens once, it's a bug. If it happens twice, it's a feature. If it happens more than twice, it's a design philosophy.
PATCH 1/27 net: new utility functions for working with enetaddr's
Quoted 6 lines · On Monday 16 February 2009 19:29:22 Wolfgang Denk wrote:
Quoted 2 lines · In message Mike Frysinger you
apparently it's new to 2.6.29 ... i'm actively working/looking at 2.6.28.x which doesnt have 'M'.
Eventually that was triggered from our discussion here :-)
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So it's actually
printk("%pM", ...);so do you want to go the %pM route (to make u-boot/linux code sharing easier) or move over only %M ?
I don't really care, but for the sake of code compatibility we probably should use Linux style.
ok ... it'll take me a bit to familiarize myself with the u-boot stdio code. then i'll send out the updated patch series (assuming all goes well). -mike
PATCH 1/27 net: new utility functions for working with enetaddr's
Dear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
ok ... it'll take me a bit to familiarize myself with the u-boot stdio code. then i'll send out the updated patch series (assuming all goes well).
Excellent. I really appreaciate all the work you're doing here.
U-Boot's printf implementation was taken directly from Linux kernel code (but a long, long time ago), so that should be a straightforward task).
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de How many QA engineers does it take to screw in a lightbulb? 3: 1 to screw it in and 2 to say "I told you so" when it doesn't work.
PATCH 2/27 doc/README.enetaddr: document proper MAC usage
In reply to Mike Frysinger--- doc/README.enetaddr | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 doc/README.enetaddr
doc/README.enetaddr new file +96 -0
@@ -0,0 +1,96 @@ +--------------------------------- + Ethernet Address (MAC) Handling +--------------------------------- + +There are a variety of places in U-Boot where the MAC address is used, parsed, +and stored. This document covers proper usage of each location and the moving +of data between them. + +----------- + Locations +----------- + +Here are the places where MAC addresses might be stored: + + - board-specific location (eeprom, dedicated flash, ...) + Note: only used when mandatory due to hardware design etc... + + - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR) + Note: this is the preferred way to permanently store MAC addresses + + - ethernet data (struct eth_device -> enetaddr) + Note: these are temporary copies of the MAC address which exist only + after the respective init steps have run and only to make usage + in other places easier (to avoid constant env lookup/parsing) + +------- + Usage +------- + +If the hardware design mandates that the MAC address is stored in some special +place (like EEPROM etc...), then the board specific init code (such as the +board-specific misc_init_r() function) is responsible for locating the MAC +address(es) and initializing the respective environment variable(s) from it. +Note that this shall be done if, and only if, the environment does not already +contain these environment variables, i.e. existing variable definitions must +not be overwritten. + +During runtime, the ethernet layer will use the environment variables to sync +the MAC addresses to the ethernet structures. All ethernet driver code should +then only use the enetaddr member of the eth_device structure. This is done +on every network command, so the ethernet copies will stay in sync. + +The common environment code will take care of passing environment changes to +the global data. This happens automatically whenever setenv() updates the +relevant ethaddr variables. + +Any other common code that wishes to access the MAC address should then query +the global data directly. No one should be looking in the environment for any +addresses. + +--------- + Helpers +--------- + +To assist in the management of these layers, a few helper functions exist. You +should use these rather than attempt to do any kind of parsing/manipulation +yourself as many common errors have arisen in the past. + + * void eth_parse_enetaddr(const char *addr, uchar *enetaddr); + +Convert a string representation of a MAC address to the binary version. +char *addr = "00:11:22:33:44:55"; +uchar enetaddr[6]; +eth_parse_enetaddr(addr, enetaddr); +/* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */ + + * int eth_getenv_enetaddr(char *name, uchar *enetaddr); + +Look up an environment variable and convert the stored address. If the env var +is not set, then the function returns -1. Otherwise, the conversion occurs and +returns 0. +uchar enetaddr[6]; +if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { + /* "ethaddr" is not set in the environment */ + ... try and setup "ethaddr" in the env ... +} +/* enetaddr is now set to the value stored in the ethaddr env var */ + + * int eth_setenv_enetaddr(char *name, const uchar *enetaddr); + +Store the MAC address into the named environment variable. The return value is +the same as the setenv() function. +uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; +eth_setenv_enetaddr("ethaddr", enetaddr); +/* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */ + + * char *str_enetaddr(char *buf, const uchar *enetaddr); + +Print the MAC address into the specified storage. Caller should make sure the +storage is sufficient (20 bytes is fine). The pointer used for storage is +returned. +char buf[20]; +uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; +str_enetaddr(buf, enetaddr); +printf("The MAC is %s\n", buf); +/* the buf variable is now set to "00:11:22:33:44:55" */
Signature · 1 line
1.6.1.3
PATCH 2/27 doc/README.enetaddr: document proper MAC usage
Dear Mike Frysinger,
Quoted 6 lines · In message <[email protected]> you wrote:
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- doc/README.enetaddr | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) create mode 100644 doc/README.enetaddr
...
doc/README.enetaddr line 24
Quoted 12 lines
doc/README.enetaddr new file +12
-0+Here are the places where MAC addresses might be stored: + + - board-specific location (eeprom, dedicated flash, ...) + Note: only used when mandatory due to hardware design etc... + + - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR) + Note: this is the preferred way to permanently store MAC addresses + + - ethernet data (struct eth_device -> enetaddr) + Note: these are temporary copies of the MAC address which exist only + after the respective init steps have run and only to make usage + in other places easier (to avoid constant env lookup/parsing)
- struct bd_info and/or device tree
Note: these are temporary copies of the MAC address only foir the purpose to pass this information to an OS kernel we are about to boot
doc/README.enetaddr line 45
Quoted 3 lines
doc/README.enetaddr new file +3
-0+The common environment code will take care of passing environment changes to +the global data. This happens automatically whenever setenv() updates the +relevant ethaddr variables.
Didn't we just remove the MAC address information from the global data?
doc/README.enetaddr line 49
Quoted 3 lines
doc/README.enetaddr new file +3
-0+Any other common code that wishes to access the MAC address should then query +the global data directly. No one should be looking in the environment for any +addresses.
Is this still valid?
doc/README.enetaddr line 96
Quoted 8 lines
doc/README.enetaddr new file +8
-0+Print the MAC address into the specified storage. Caller should make sure the +storage is sufficient (20 bytes is fine). The pointer used for storage is +returned. +char buf[20]; +uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; +str_enetaddr(buf, enetaddr); +printf("The MAC is %s\n", buf); +/* the buf variable is now set to "00:11:22:33:44:55" */
I think we should instead borrow the 'M' (and probably also the 'I', but that's a different story) format specifiers from the Linux "lib/vsprintf.c" implementation ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Real Programmers always confuse Christmas and Halloween because OCT 31 == DEC 25 ! - Andrew Rutherford (andrewr at ucs.adelaide.edu.au)
PATCH 2/27 doc/README.enetaddr: document proper MAC usage
Quoted 23 lines · On Monday 16 February 2009 17:38:54 Wolfgang Denk wrote:
doc/README.enetaddr line 24
Quoted 12 lines · In message Mike Frysinger
doc/README.enetaddr new file +12
-0+Here are the places where MAC addresses might be stored: + + - board-specific location (eeprom, dedicated flash, ...) + Note: only used when mandatory due to hardware design etc... + + - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR) + Note: this is the preferred way to permanently store MAC addresses + + - ethernet data (struct eth_device -> enetaddr) + Note: these are temporary copies of the MAC address which exist only + after the respective init steps have run and only to make usage + in other places easier (to avoid constant env lookup/parsing)- struct
bd_infoand/or device tree
Note: these are temporary copies of the MAC address only foir the purpose to pass this information to an OS kernel we are about to bootQuoted 3 lines
+The common environment code will take care of passing environment changes to +the global data. This happens automatically whenever
setenv()updates the +relevant ethaddr variables.
Quoted 8 lines
Didn't we just remove the MAC address information from the global data?
Quoted 3 lines
+Any other common code that wishes to access the MAC address should then query +the global data directly. No one should be looking in the environment for any +addresses.
Is this still valid?
erm, i updated the file in places i remembered, but didnt give it a complete top-to-bottom look over after the last discussion. ive fixed up the things you pointed out, thanks.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/d7a34961/attachment-0001.pgp
PATCH 3/27 Blackfin: bfin_mac: force boards to setup the MAC themselves
In reply to Mike FrysingerSince the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this driver to setup the board data with a proper MAC.
--- drivers/net/bfin_mac.c | 16 ++++++++-------- drivers/net/bfin_mac.h | 2 +- lib_blackfin/board.c | 48 ++---------------------------------------------- 3 files changed, 11 insertions(+), 55 deletions(-)
drivers/net/bfin_mac.c +8 -8
@@ -315,7 +315,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)return -1 ;/* Initialize EMAC address */ -bfin_EMAC_setup_addr (bd); +bfin_EMAC_setup_addr (dev->enetaddr);/* Initialize TX and RX buffer */ for (i =0 ; i <PKTBUFSRX ; i++) {
@@ -373,16 +373,16 @@ static void bfin_EMAC_halt(struct eth_device *dev) } -void bfin_EMAC_setup_addr (bd_t *bd) +void bfin_EMAC_setup_addr (uchar *enetaddr) { *pEMAC_ADDRLO = - bd->bi_enetaddr[0 ] | - bd->bi_enetaddr[1 ] <<8 | - bd->bi_enetaddr[2 ] <<16 | - bd->bi_enetaddr[3 ] <<24 ; + enetaddr[0 ] | + enetaddr[1 ] <<8 | + enetaddr[2 ] <<16 | + enetaddr[3 ] <<24 ; *pEMAC_ADDRHI = - bd->bi_enetaddr[4 ] | - bd->bi_enetaddr[5 ] <<8 ; + enetaddr[4 ] | + enetaddr[5 ] <<8 ; }ADI_ETHER_BUFFER *SetupRxBuffer (int no)
drivers/net/bfin_mac.h +1 -1
@@ -61,6 +61,6 @@ static void bfin_EMAC_halt(struct eth_device *dev);static int bfin_EMAC_send (struct eth_device *dev,volatile void *packet,int length);static int bfin_EMAC_recv (struct eth_device *dev); -static void bfin_EMAC_setup_addr (bd_t *bd); +void bfin_EMAC_setup_addr (uchar *enetaddr);#endif
lib_blackfin/board.c +2 -46
68 lines not on this page · raw message
Signature · 1 line
1.6.1.3
PATCH 4/27 net: get mac address from environment and use eth util funcs
In reply to Mike Frysinger--- net/bootp.c | 13 ++----------- net/net.c | 20 ++++++++------------ 2 files changed, 10 insertions(+), 23 deletions(-)
net/bootp.c +1 -10
@@ -579,21 +579,12 @@ BootpRequest (void)#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */ unsigned char bi_enetaddr[6 ];int reg; -char *e,*s; -char tmp[64 ];ulong tst1, tst2, sum, m_mask, m_value =0 ;if (BootpTry ==0 ) {/* get our mac */ - reg =getenv_r ("ethaddr" , tmp,sizeof (tmp)); - s = (reg >0 ) ? tmp :NULL ; +eth_getenv_enetaddr ("ethaddr" , bi_enetaddr); -for (reg=0 ; reg<6 ; ++reg) { - bi_enetaddr[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) { - s = (*e) ? e+1 : e; - } - }#ifdef DEBUG puts ("BootpRequest => Our Mac: " );for (reg=0 ; reg<6 ; reg++) {
net/net.c +8 -12
@@ -330,7 +330,7 @@ restart:#ifdef CONFIG_NET_MULTI memcpy (NetOurEther,eth_get_dev ()->enetaddr,6 );#else -memcpy (NetOurEther, bd->bi_enetaddr,6 ); +eth_getenv_enetaddr ("ethaddr" , NetOurEther);#endif NetState =NETLOOP_CONTINUE ;
@@ -658,6 +658,9 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len) {uchar *pkt; +#ifdef ET_DEBUG +char buf[20 ]; +#endif /* convert to new style broadcast */ if (dest ==0 )
@@ -693,8 +696,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len) }#ifdef ET_DEBUG -printf ("sending UDP to %08lx/%02x:%02x:%02x:%02x:%02x:%02x\n" , - dest, ether[0 ], ether[1 ], ether[2 ], ether[3 ], ether[4 ], ether[5 ]); +printf ("sending UDP to %08lx/%s\n" , dest,str_enetaddr (buf, ether));#endif pkt = (uchar *)NetTxPacket;
@@ -915,11 +917,7 @@ int CDPSendTrigger(void)#ifdef CONFIG_CDP_DEVICE_ID *s++ =htons (CDP_DEVICE_ID_TLV ); *s++ =htons (CONFIG_CDP_DEVICE_ID ); -memset (buf,0 ,sizeof (buf)); -sprintf (buf,CONFIG_CDP_DEVICE_ID_PREFIX "%02X%02X%02X%02X%02X%02X" , - NetOurEther[0 ] &0xff , NetOurEther[1 ] &0xff , - NetOurEther[2 ] &0xff , NetOurEther[3 ] &0xff , - NetOurEther[4 ] &0xff , NetOurEther[5 ] &0xff ); +str_enetaddr (buf, NetOurEther);memcpy ((uchar *)s, buf,16 ); s +=16 /2 ;#endif
@@ -1319,10 +1317,8 @@ NetReceive(volatile uchar * inpkt, int len)if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC)break ;#ifdef ET_DEBUG -printf ("Got ARP REPLY, set server/gtwy eth addr (%02x:%02x:%02x:%02x:%02x:%02x)\n" , - arp->ar_data[0 ], arp->ar_data[1 ], - arp->ar_data[2 ], arp->ar_data[3 ], - arp->ar_data[4 ], arp->ar_data[5 ]); +printf ("Got ARP REPLY, set server/gtwy eth addr (%s)\n" , +str_enetaddr (arp->ar_data));#endif tmp =NetReadIP (&arp->ar_data[6 ]);
Signature · 1 line
1.6.1.3
PATCH 5/27 bdinfo: get mac address from environment
In reply to Mike FrysingerAdd a new print_eth() function to automate the eth*addr env var acquisition and display. Affects all arches.
--- common/cmd_bdinfo.c | 136 +++++++++++++++------------------------------------ 1 files changed, 40 insertions(+), 96 deletions(-)
common/cmd_bdinfo.c +40 -96
@@ -32,6 +32,8 @@ DECLARE_GLOBAL_DATA_PTR;static void print_num (const char *,ulong ); +static void print_eth (int idx); +#ifndef CONFIG_ARM /* PowerPC and other */ static void print_lnum (const char *,u64 );
@@ -40,7 +42,6 @@ static void print_str(const char *, const char *);int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;char buf[32 ];
@@ -91,44 +92,21 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_str ("pevfreq" ,strmhz (buf, bd->bi_pevfreq));#endif -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } - +print_eth (0 );#if defined(CONFIG_HAS_ETH1 ) -puts ("\neth1addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet1addr[i]); - } +print_eth (1 );#endif -#if defined(CONFIG_HAS_ETH2 ) -puts ("\neth2addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet2addr[i]); - } +print_eth (2 );#endif -#if defined(CONFIG_HAS_ETH3 ) -puts ("\neth3addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet3addr[i]); - } +print_eth (3 );#endif -#if defined(CONFIG_HAS_ETH4 ) -puts ("\neth4addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet4addr[i]); - } +print_eth (4 );#endif -#if defined(CONFIG_HAS_ETH5 ) -puts ("\neth5addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet5addr[i]); - } +print_eth (5 );#endif #ifdef CONFIG_HERMES
@@ -143,7 +121,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;print_num ("memstart" , (ulong )bd->bi_memstart);
@@ -152,11 +129,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_num ("flashsize" , (ulong )bd->bi_flashsize);print_num ("flashoffset" , (ulong )bd->bi_flashoffset); -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\nip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);printf ("\nbaudrate = %ld bps\n" , bd->bi_baudrate);
@@ -167,9 +141,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -#if defined(CONFIG_CMD_NET ) -int i; -#endif bd_t *bd = gd->bd;print_num ("mem start" , (ulong )bd->bi_memstart);
@@ -184,11 +155,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#endif #if defined(CONFIG_CMD_NET ) -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\nip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);#endif
@@ -200,7 +168,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;print_num ("mem start " , (ulong )bd->bi_memstart);print_lnum ("mem size " , (u64 )bd->bi_memsize);
@@ -212,11 +179,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_num ("sram size " , (ulong )bd->bi_sramsize);#endif #if defined(CONFIG_CMD_NET ) -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\nip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);#endif printf ("\nbaudrate = %ld bps\n" , (ulong )bd->bi_baudrate);
@@ -227,9 +191,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_bdinfo (cmd_tbl_t * cmdtp,int flag,int argc,char *argv[]) {bd_t *bd = gd->bd; -#if defined(CONFIG_CMD_NET ) -int i; -#endif #ifdef DEBUG print_num ("bd address " , (ulong ) bd);
@@ -251,11 +212,8 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) CONFIG_SYS_GBL_DATA_SIZE);#if defined(CONFIG_CMD_NET ) -puts ("ethaddr =" ); -for (i =0 ; i <6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\nIP addr = " ); +print_eth (0 ); +puts ("IP addr = " );print_IPaddr (bd->bi_ip_addr);#endif printf ("\nbaudrate = %6ld bps\n" , bd->bi_baudrate);
@@ -267,7 +225,6 @@ static void print_str(const char *, const char *);int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;char buf[32 ];
@@ -294,33 +251,18 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_str ("vcofreq" ,strmhz (buf, bd->bi_vcofreq));#endif #if defined(CONFIG_CMD_NET ) -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } - +print_eth (0 );#if defined(CONFIG_HAS_ETH1 ) -puts ("\neth1addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet1addr[i]); - } +print_eth (1 );#endif -#if defined(CONFIG_HAS_ETH2 ) -puts ("\neth2addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet2addr[i]); - } +print_eth (2 );#endif -#if defined(CONFIG_HAS_ETH3 ) -puts ("\neth3addr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enet3addr[i]); - } +print_eth (3 );#endif -puts ("\nip_addr = " ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);#endif printf ("\nbaudrate = %ld bps\n" , bd->bi_baudrate);
@@ -333,7 +275,6 @@ static void print_str(const char *, const char *);int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;char buf[32 ];
@@ -351,10 +292,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_num ("flashsize" , (ulong )bd->bi_flashsize);print_num ("flashoffset" , (ulong )bd->bi_flashoffset); -puts ("ethaddr =" ); -for (i =0 ; i <6 ; ++i) -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); -puts ("\nip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);printf ("\nbaudrate = %d bps\n" , bd->bi_baudrate);
@@ -365,7 +304,6 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_bdinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -int i;bd_t *bd = gd->bd;print_num ("boot_params" , (ulong )bd->bi_boot_params);
@@ -375,11 +313,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])print_num ("flashsize" , (ulong )bd->bi_flashsize);print_num ("flashoffset" , (ulong )bd->bi_flashoffset); -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\nip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);printf ("\nbaudrate = %d bps\n" , bd->bi_baudrate);
@@ -405,12 +340,8 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }#if defined(CONFIG_CMD_NET ) -puts ("ethaddr =" ); -for (i=0 ; i<6 ; ++i) { -printf ("%c%02X" , i ?':' :' ' , bd->bi_enetaddr[i]); - } -puts ("\n" -"ip_addr = " ); +print_eth (0 ); +puts ("ip_addr = " );print_IPaddr (bd->bi_ip_addr);#endif printf ("\n"
@@ -426,6 +357,19 @@ static void print_num(const char *name, ulong value)printf ("%-12s= 0x%08lX\n" , name, value); } +static void print_eth (int idx) +{ +char name[10 ], *val; +if (idx) +sprintf (name,"eth%iaddr" , idx); +else +strcpy (name,"ethaddr" ); + val =getenv (name); +if (!val) + val ="(not set)" ; +printf ("%-12s= %s\n" , name, val); +} +#ifndef CONFIG_ARM static void print_lnum (const char *name,u64 value) {
Signature · 1 line
1.6.1.3
PATCH 6/27 bootvx: get mac address from environment
In reply to Mike Frysinger--- common/cmd_elf.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
common/cmd_elf.c +4 -2
@@ -131,10 +131,12 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])#if defined(CONFIG_WALNUT ) tmp = (char *)CONFIG_SYS_NVRAM_BASE_ADDR +0x500 ; -memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[3 ],3 ); +eth_getenv_enetaddr ("ethaddr" , build_buf); +memcpy (tmp, &build_buf[3 ],3 );#elif defined(CONFIG_SYS_VXWORKS_MAC_PTR ) tmp = (char *)CONFIG_SYS_VXWORKS_MAC_PTR ; -memcpy ((char *) tmp, (char *) &gd->bd->bi_enetaddr[0 ],6 ); +eth_getenv_enetaddr ("ethaddr" , build_buf); +memcpy (tmp, build_buf,6 );#else puts ("## Ethernet MAC address not copied to NV RAM\n" );#endif
Signature · 1 line
1.6.1.3
PATCH 7/27 lynxkdi: get mac address from environment
In reply to Mike Frysinger--- common/lynxkdi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
common/lynxkdi.c +1 -1
@@ -33,7 +33,7 @@ void lynxkdi_boot (image_header_t *hdr) kbd = gd->bd; parms->clock_ref = kbd->bi_busfreq; parms->dramsz = kbd->bi_memsize; -memcpy (parms->ethaddr, kbd->bi_enetaddr,6 ); +eth_getenv_enetaddr ("ethaddr" , parms->ethaddr);mtspr (SPRN_SPRG2 ,0x0020 );/* Do a simple check for Bluecat so we can pass the
Signature · 1 line
1.6.1.3
PATCH 8/27 nvedit: do not update global bi_enetaddr and do not call eth_set_enetaddr()
In reply to Mike FrysingerSince the ethernet layer handles updating of device addresses itself from the environment, there is no point in calling eth_set_enetaddr().
--- common/cmd_nvedit.c | 24 +----------------------- 1 files changed, 1 insertions(+), 23 deletions(-)
common/cmd_nvedit.c +1 -23
@@ -277,18 +277,6 @@ int _do_setenv (int flag, int argc, char *argv[]) *++env ='\0' ; } -#ifdef CONFIG_NET_MULTI -if (strncmp (name,"eth" ,3 ) ==0 ) { -char *end; -int num =simple_strtoul (name+3 , &end,10 ); - -if (strcmp (end,"addr" ) ==0 ) { -eth_set_enetaddr (num, argv[2 ]); - } - } -#endif - -/* Delete only ? */ if ((argc <3 ) || argv[2 ] ==NULL ) {env_crc_update ();
@@ -336,18 +324,8 @@ int _do_setenv (int flag, int argc, char *argv[])* entry in the enviornment is changed */ -if (strcmp (argv[1 ],"ethaddr" ) ==0 ) { -char *s = argv[2 ];/* always use only one arg */ -char *e; -for (i=0 ; i<6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) s = (*e) ? e+1 : e; - } -#ifdef CONFIG_NET_MULTI -eth_set_enetaddr (0 , argv[2 ]); -#endif +if (strcmp (argv[1 ],"ethaddr" ) ==0 )return 0 ; - }if (strcmp (argv[1 ],"ipaddr" ) ==0 ) {char *s = argv[2 ];/* always use only one arg */
Signature · 1 line
1.6.1.3
PATCH 9/27 AmigaOneG3SE/enet: get mac address from environment
In reply to Mike FrysingerAlways use the MAC address that is stored in the environment first before falling back to the ROM. This also cuts out any comparison steps: if the mac in the env is sane, the ROM is never consulted.
--- board/MAI/AmigaOneG3SE/enet.c | 42 +++++++--------------------------------- 1 files changed, 8 insertions(+), 34 deletions(-)
board/MAI/AmigaOneG3SE/enet.c +8 -34
@@ -600,7 +600,7 @@ static int eth_3com_init (struct eth_device *dev, bd_t * bis) ias_cmd = (struct descriptor *) &tx_ring[tx_cur]; ias_cmd->status =cpu_to_le32 (1 <<31 );/* set DnIndicate bit. */ ias_cmd->next =0 ; - ias_cmd->addr =cpu_to_le32 ((u32) & bis->bi_enetaddr[0 ]); + ias_cmd->addr =cpu_to_le32 ((u32 ) dev->enetaddr); ias_cmd->length =cpu_to_le32 (6 |LAST_FRAG );/* Tell the adapter where the TX ring is located */
@@ -787,6 +787,10 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)unsigned int checksum =0 ;int i, j, timer; +/* First, try the env ... if that works, we're all done! */ +if (eth_getenv_enetaddr ("ethaddr" , hw_addr)) + goto Done; +/* Read the station address from the EEPROM. */ EL3WINDOW (dev,0 );
@@ -827,40 +831,10 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) hw_addr[j +1 ] = (u8) ((ETH_INW (dev, j) >>8 ) &0xff ); } -for (i =0 ; i <ETH_ALEN ; i++) { -if (hw_addr[i] != bis->bi_enetaddr[i]) { -/* printf("Warning: HW address don't match:\n"); */ -/* printf("Address in 3Com Window 2 is " */ -/* "%02X:%02X:%02X:%02X:%02X:%02X\n", */ -/* hw_addr[0], hw_addr[1], hw_addr[2], */ -/* hw_addr[3], hw_addr[4], hw_addr[5]); */ -/* printf("Address used by U-Boot is " */ -/* "%02X:%02X:%02X:%02X:%02X:%02X\n", */ -/* bis->bi_enetaddr[0], bis->bi_enetaddr[1], */ -/* bis->bi_enetaddr[2], bis->bi_enetaddr[3], */ -/* bis->bi_enetaddr[4], bis->bi_enetaddr[5]); */ -/* goto Done; */ -char buffer[256 ]; - -if (bis->bi_enetaddr[0 ] ==0 - && bis->bi_enetaddr[1 ] ==0 - && bis->bi_enetaddr[2 ] ==0 - && bis->bi_enetaddr[3 ] ==0 - && bis->bi_enetaddr[4 ] ==0 - && bis->bi_enetaddr[5 ] ==0 ) { - -sprintf (buffer, -"%02X:%02X:%02X:%02X:%02X:%02X" , - hw_addr[0 ], hw_addr[1 ], hw_addr[2 ], - hw_addr[3 ], hw_addr[4 ], hw_addr[5 ]); -setenv ("ethaddr" , buffer); - } - } - } - -for (i =0 ; i <ETH_ALEN ; i++) - dev->enetaddr[i] = hw_addr[i]; +/* Save the result in the environment */ +eth_setenv_enetaddr ("ethaddr" , hw_addr); Done: +memcpy (dev->enetaddr, hw_addr,6 );return ; }
Signature · 1 line
1.6.1.3
PATCH 10/27 boards: get mac address from environment
In reply to Mike FrysingerThe boards that get converted here to use the environment for the mac address rather than global data:
debris mgcoge mgsuvd muas3001 netstal pn62 sixnet vcma9 xilinx (the ones that use xilinx_enet)
--- board/etin/debris/debris.c | 6 +++- board/keymile/mgcoge/mgcoge.c | 4 ++- board/keymile/mgsuvd/mgsuvd.c | 4 ++- board/mpl/vcma9/cmd_vcma9.c | 11 +++----- board/muas3001/muas3001.c | 4 ++- board/netstal/common/nm_bsp.c | 40 +++++++----------------------- board/pn62/pn62.c | 24 ++++++------------ board/sixnet/sixnet.c | 11 +++----- board/xilinx/xilinx_enet/emac_adapter.c | 8 ++++- 9 files changed, 45 insertions(+), 67 deletions(-)
board/etin/debris/debris.c +4 -2
@@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t count)int misc_init_r (void ) {/* Write ethernet addr in NVRAM for VxWorks */ -nvram_write (CONFIG_ENV_ADDR +CONFIG_SYS_NVRAM_VXWORKS_OFFS , - (char *)&gd->bd->bi_enetaddr[0 ],6 ); +uchar ethaddr[6 ]; +if (eth_getenv_enetaddr ("ethaddr" , ethaddr)) +nvram_write (CONFIG_ENV_ADDR +CONFIG_SYS_NVRAM_VXWORKS_OFFS , + ethaddr,6 );return 0 ; }
board/keymile/mgcoge/mgcoge.c +3 -1
@@ -325,6 +325,7 @@ void ft_blob_update (void *blob, bd_t *bd) {ulong memory_data[2 ] = {0 };ulong flash_data[8 ] = {0 }; +uchar enetaddr[6 ]; memory_data[0 ] =cpu_to_be32 (bd->bi_memstart); memory_data[1 ] =cpu_to_be32 (bd->bi_memsize);
@@ -341,8 +342,9 @@ void ft_blob_update (void *blob, bd_t *bd)fdt_set_node_and_value (blob,"/localbus" ,"ranges" , flash_data,sizeof (flash_data));/* MAC addr */ +eth_getenv_enetaddr ("ethaddr" , enetaddr);fdt_set_node_and_value (blob,"/soc/cpm/ethernet" ,"mac-address" , - bd->bi_enetaddr,sizeof (u8) *6 ); + enetaddr,sizeof (u8) *6 ); }void ft_board_setup (void *blob,bd_t *bd)
board/keymile/mgsuvd/mgsuvd.c +3 -1
@@ -168,6 +168,7 @@ void ft_blob_update (void *blob, bd_t *bd)ulong brg_data[1 ] = {0 };ulong memory_data[2 ] = {0 };ulong flash_data[4 ] = {0 }; +uchar enetaddr[6 ]; memory_data[0 ] =cpu_to_be32 (bd->bi_memstart); memory_data[1 ] =cpu_to_be32 (bd->bi_memsize);
@@ -185,8 +186,9 @@ void ft_blob_update (void *blob, bd_t *bd) sizeof (brg_data));/* MAC adr */ +eth_getenv_enetaddr ("ethaddr" , enetaddr);fdt_set_node_and_value (blob,"/soc/cpm/ethernet" ,"mac-address" , - bd->bi_enetaddr,sizeof (u8) *6 ); + enetaddr,sizeof (u8) *6 ); }void ft_board_setup (void *blob,bd_t *bd)
board/mpl/vcma9/cmd_vcma9.c +4 -7
@@ -76,21 +76,18 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])cs8900_e2prom_write (addr, data); }else if (strcmp (argv[2 ],"setaddr" ) ==0 ) {uchar addr, i, csum;ushort data; +uchar ethaddr[6 ];/* check for valid ethaddr */ -for (i =0 ; i <6 ; i++) -if (gd->bd->bi_enetaddr[i] !=0 ) -break ; - -if (i <6 ) { +if (eth_getenv_enetaddr ("ethaddr" , ethaddr)) { addr =1 ; data =0x2158 ;cs8900_e2prom_write (addr, data); csum =cs8900_chksum (data); addr++;for (i =0 ; i <6 ; i+=2 ) { - data = gd->bd->bi_enetaddr[i+1 ] <<8 | - gd->bd->bi_enetaddr[i]; + data = enetaddr[i+1 ] <<8 | + enetaddr[i];cs8900_e2prom_write (addr, data); csum +=cs8900_chksum (data); addr++;
board/muas3001/muas3001.c +3 -1
@@ -346,7 +346,9 @@ void ft_blob_update (void *blob, bd_t *bd)/* MAC Adresse */ nodeoffset =fdt_path_offset (blob,"/soc/cpm/ethernet" );if (nodeoffset >=0 ) { - ret =fdt_setprop (blob, nodeoffset,"mac-address" , bd->bi_enetaddr, +uchar ethaddr[6 ]; +eth_getenv_enetaddr ("ethaddr" , ethaddr); + ret =fdt_setprop (blob, nodeoffset,"mac-address" , ethaddr,sizeof (uchar) *6 );if (ret <0 ) printf ("ft_blob_update): cannot set /soc/cpm/ethernet/mac-address "
board/netstal/common/nm_bsp.c +10 -30
@@ -83,40 +83,20 @@ void set_params_for_sw_install(int install_requested, char *board_name )void common_misc_init_r (void ) { -char *s =getenv (DEFAULT_ETH_ADDR ); -char *e; -int i; -u32 serial =get_serial_number ();IPaddr_t ipaddr;char *ipstring; +uchar ethaddr[6 ]; -for (i =0 ; i <6 ; ++i) { - gd->bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } - -if (gd->bd->bi_enetaddr[3 ] ==0 && - gd->bd->bi_enetaddr[4 ] ==0 && - gd->bd->bi_enetaddr[5 ] ==0 ) { -char ethaddr[22 ]; - +if (!eth_getenv_enetaddr (DEFAULT_ETH_ADDR , ethaddr)) {/* Must be in sync with CONFIG_ETHADDR */ - gd->bd->bi_enetaddr[0 ] =0x00 ; - gd->bd->bi_enetaddr[1 ] =0x60 ; - gd->bd->bi_enetaddr[2 ] =0x13 ; - gd->bd->bi_enetaddr[3 ] = (serial >>16 ) &0xff ; - gd->bd->bi_enetaddr[4 ] = (serial >>8 ) &0xff ; - gd->bd->bi_enetaddr[5 ] =hcu_get_slot (); -sprintf (ethaddr,"%02X:%02X:%02X:%02X:%02X:%02X%c" , - gd->bd->bi_enetaddr[0 ], gd->bd->bi_enetaddr[1 ], - gd->bd->bi_enetaddr[2 ], gd->bd->bi_enetaddr[3 ], - gd->bd->bi_enetaddr[4 ], - gd->bd->bi_enetaddr[5 ], -0 ) ; -printf ("%s: Setting eth %s serial 0x%x\n" , __FUNCTION__, - ethaddr, serial); -setenv (DEFAULT_ETH_ADDR , ethaddr); +u32 serial =get_serial_number (); + ethaddr[0 ] =0x00 ; + ethaddr[1 ] =0x60 ; + ethaddr[2 ] =0x13 ; + ethaddr[3 ] = (serial >>16 ) &0xff ; + ethaddr[4 ] = (serial >>8 ) &0xff ; + ethaddr[5 ] =hcu_get_slot (); +eth_setenv_enetaddr (DEFAULT_ETH_ADDR , ethaddr); }/* IP-Adress update */
board/pn62/pn62.c +8 -16
@@ -30,7 +30,7 @@DECLARE_GLOBAL_DATA_PTR ;static int get_serial_number (char *string,int size); -static int get_mac_address (int id,u8 * mac,char *string,int size); +static int get_mac_address (int id,u8 *mac);#ifdef CONFIG_SHOW_BOOT_PROGRESS void show_boot_progress (int phase)
@@ -138,18 +138,16 @@ int misc_init_r (void) }show_startup_phase (9 ); -if (getenv ("ethaddr" ) ==NULL && -get_mac_address (0 , mac, str,sizeof (str)) >0 ) { -setenv ("ethaddr" , str); -memcpy (gd->bd->bi_enetaddr, mac,6 ); +if (!eth_getenv_enetaddr ("ethaddr" , mac)) { +get_mac_address (0 , mac); +eth_setenv_enetaddr ("ethaddr" , mac); }show_startup_phase (10 );#ifdef CONFIG_HAS_ETH1 -if (getenv ("eth1addr" ) ==NULL && -get_mac_address (1 , mac, str,sizeof (str)) >0 ) { -setenv ("eth1addr" , str); -memcpy (gd->bd->bi_enet1addr, mac,6 ); +if (!eth_getenv_enetaddr ("eth1addr" , mac)) { +get_mac_address (1 , mac); +eth_setenv_enetaddr ("eth1addr" , mac); }#endif /* CONFIG_HAS_ETH1 */ show_startup_phase (11 );
@@ -177,15 +175,9 @@ static int get_serial_number (char *string, int size)return i; } -static int get_mac_address (int id,u8 * mac,char *string,int size) +static int get_mac_address (int id,u8 *mac) { -if (size <6 *3 ) -return -1 ; -i2155x_read_vpd (I2155X_VPD_MAC0_START +6 * id,6 , mac); -return sprintf (string,"%02x:%02x:%02x:%02x:%02x:%02x" , - mac[0 ], mac[1 ], mac[2 ], - mac[3 ], mac[4 ], mac[5 ]); }int board_eth_init (bd_t *bis)
board/sixnet/sixnet.c +4 -7
@@ -264,6 +264,7 @@ int misc_init_r (void)char * e;int reg;bd_t *bd = gd->bd; +uchar enetaddr[6 ]; memctl->memc_or2 =NVRAM_OR_PRELIM ; memctl->memc_br2 =NVRAM_BR_VALUE ;
@@ -315,13 +316,9 @@ int misc_init_r (void)* is present it gets a unique address, otherwise it * shares the FEC address. */ - s =getenv ("eth1addr" ); -if (s ==NULL ) - s =getenv ("ethaddr" ); -for (reg=0 ; reg<6 ; ++reg) { - bd->bi_enet1addr[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e+1 : e; +if (!eth_getenv_enetaddr ("eth1addr" , enetaddr)) { +eth_getenv_enetaddr ("ethaddr" , enetaddr); +eth_setenv_enetaddr ("eth1addr" , enetaddr); }return (0 );
board/xilinx/xilinx_enet/emac_adapter.c +6 -2
@@ -74,6 +74,7 @@ eth_init(bd_t * bis) {u32 Options;XStatus Result; +uchar enetaddr[6 ];#ifdef DEBUG printf ("EMAC Initialization Started\n\r" );
@@ -87,11 +88,14 @@ eth_init(bd_t * bis)/* make sure the Emac is stopped before it is started */ (void )XEmac_Stop (&Emac); +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) {#ifdef CONFIG_ENV_IS_NOWHERE -memcpy (bis->bi_enetaddr, EMACAddr,6 ); +memcpy (enetaddr, EMACAddr,6 ); +eth_setenv_enetaddr ("ethaddr" , enetaddr);#endif + } - Result =XEmac_SetMacAddress (&Emac, bis->bi_enetaddr); + Result =XEmac_SetMacAddress (&Emac, enetaddr);if (Result !=XST_SUCCESS ) {return 0 ; }
Signature · 1 line
1.6.1.3
PATCH 10/27 boards: get mac address from environment
Dear Mike Frysinger,
Quoted 2 lines · In message <[email protected]> you wrote:
The boards that get converted here to use the environment for the mac address rather than global data:
Hmm... is this commit message correct? Makes little sense to me....
board/etin/debris/debris.c void nvram_write(long dest, const void *src, size_t count) · line 178
Quoted 12 lines
board/etin/debris/debris.c +2
-2@@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t count)int misc_init_r (void ) {/* Write ethernet addr in NVRAM for VxWorks */ -nvram_write (CONFIG_ENV_ADDR +CONFIG_SYS_NVRAM_VXWORKS_OFFS , - (char *)&gd->bd->bi_enetaddr[0 ],6 ); +uchar ethaddr[6 ]; +if (eth_getenv_enetaddr ("ethaddr" , ethaddr))
Please move declaration above comment (and add an empty line).
...
board/etin/debris/debris.c void nvram_write(long dest, const void *src, size_t count)
Quoted 11 lines
board/etin/debris/debris.c +1
-7-static int get_mac_address (int id,u8 * mac,char *string,int size) +static int get_mac_address (int id,u8 *mac) { -if (size <6 *3 ) -return -1 ; -i2155x_read_vpd (I2155X_VPD_MAC0_START +6 * id,6 , mac); -return sprintf (string,"%02x:%02x:%02x:%02x:%02x:%02x" , - mac[0 ], mac[1 ], mac[2 ], - mac[3 ], mac[4 ], mac[5 ]); }
This one looks broken to me. At least it returns random data.
Best regards,
Wolfgang Denk
Signature · 9 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ADVISORY: There is an Extremely Small but Nonzero Chance That, Through a Process Know as "Tunneling," This Product May Spontaneously Disappear from Its Present Location and Reappear at Any Random Place in the Universe, Including Your Neighbor's Domicile. The Manufacturer Will Not Be Responsible for Any Damages or Inconvenience That May Result.
PATCH 10/27 boards: get mac address from environment
Quoted 5 lines · On Monday 16 February 2009 17:46:24 Wolfgang Denk wrote:
Quoted 2 lines · In message Mike Frysinger
The boards that get converted here to use the environment for the mac address rather than global data:
Hmm... is this commit message correct? Makes little sense to me....
looks correct to me ... the boards are moved from using the global data to using the environment
Quoted 6 lines
Quoted 6 lines
board/etin/debris/debris.c +0
-0@@ -174,8 +174,10 @@ void nvram_write(long dest, const void *src, size_t count) int misc_init_r(void)
Quoted 8 lines
board/etin/debris/debris.c void nvram_write(long dest, const void *src, size_t count) · line 178
Quoted 6 lines
board/etin/debris/debris.c +2
-2{/* Write ethernet addr in NVRAM for VxWorks */ -nvram_write (CONFIG_ENV_ADDR +CONFIG_SYS_NVRAM_VXWORKS_OFFS , - (char *)&gd->bd->bi_enetaddr[0 ],6 ); +uchar ethaddr[6 ]; +if (eth_getenv_enetaddr ("ethaddr" , ethaddr))Please move declaration above comment (and add an empty line).
ok
Quoted 5 lines
Quoted 5 lines
board/etin/debris/debris.c +1
-3-static int get_mac_address (int id,u8 * mac,char *string,int size) +static int get_mac_address (int id,u8 *mac) { -if (size <6 *3 ) -return -1 ;
Quoted 8 lines
board/etin/debris/debris.c
Quoted 6 lines
board/etin/debris/debris.c +0
-4-i2155x_read_vpd (I2155X_VPD_MAC0_START +6 * id,6 , mac); -return sprintf (string,"%02x:%02x:%02x:%02x:%02x:%02x" , - mac[0 ], mac[1 ], mac[2 ], - mac[3 ], mac[4 ], mac[5 ]); }This one looks broken to me. At least it returns random data.
yes, i broke the return value. not that it would make a difference at runtime as nowhere was the return value actually checked/used. fixed though, thanks. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/25976e62/attachment.pgp
PATCH 11/27 drivers/net/: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
The drivers that get converted here:
3c589 4xx_enet dc2114x dm9000x enc28j60 fsl_mcdmafec ks8695eth mcffec rtl8019 rtl8169 s3c4510b_eth xilinx_emac xilinx_emaclite
--- drivers/net/3c589.c | 7 +++++-- drivers/net/4xx_enet.c | 13 +++++-------- drivers/net/dc2114x.c | 9 ++++++--- drivers/net/dm9000x.c | 27 ++++++++------------------- drivers/net/enc28j60.c | 4 +++- drivers/net/fsl_mcdmafec.c | 11 ++++++----- drivers/net/ks8695eth.c | 9 ++------- drivers/net/mcffec.c | 10 +++++----- drivers/net/rtl8019.c | 14 ++++++++------ drivers/net/rtl8169.c | 2 +- drivers/net/s3c4510b_eth.c | 2 +- drivers/net/s3c4510b_eth.h | 2 +- drivers/net/xilinx_emac.c | 12 +++++++----- drivers/net/xilinx_emaclite.c | 11 +++++++---- 14 files changed, 65 insertions(+), 68 deletions(-)
drivers/net/3c589.c +5 -2
@@ -259,10 +259,13 @@ static void el_reset(bd_t *bd)/* set mac addr */ { -unsigned char *mac_addr = bd->bi_enetaddr; +uchar mac_addr[6 ];int i; -el_get_mac_addr ( mac_addr ); +if (!eth_getenv_enetaddr ("ethaddr" , mac_addr)) { +el_get_mac_addr (mac_addr); +eth_setenv_enetaddr ("ethaddr" , mac_addr); + }GO_WINDOW (2 );VX_BUSY_WAIT ;
drivers/net/4xx_enet.c +5 -8
@@ -1927,24 +1927,22 @@ int ppc_4xx_eth_initialize (bd_t * bis)memcpy (ethaddr[eth_num],"\0\0\0\0\0\0" ,6 );for (eth_num =0 ; eth_num <LAST_EMAC_NUM ; eth_num++) { +int ethaddr_idx = eth_num +CONFIG_EMAC_NR_START ;switch (eth_num) {default :/* fall through */ case 0 : -memcpy (ethaddr[eth_num +CONFIG_EMAC_NR_START ], - bis->bi_enetaddr,6 ); +eth_getenv_enetaddr ("ethaddr" , ethaddr[ethaddr_idx]); hw_addr[eth_num] =0x0 ;break ;#ifdef CONFIG_HAS_ETH1 case 1 : -memcpy (ethaddr[eth_num +CONFIG_EMAC_NR_START ], - bis->bi_enet1addr,6 ); +eth_getenv_enetaddr ("eth1addr" , ethaddr[ethaddr_idx]); hw_addr[eth_num] =0x100 ;break ;#endif #ifdef CONFIG_HAS_ETH2 case 2 : -memcpy (ethaddr[eth_num +CONFIG_EMAC_NR_START ], - bis->bi_enet2addr,6 ); +eth_getenv_enetaddr ("eth2addr" , ethaddr[ethaddr_idx]);#if defined(CONFIG_460GT ) hw_addr[eth_num] =0x300 ;#else
@@ -1954,8 +1952,7 @@ int ppc_4xx_eth_initialize (bd_t * bis)#endif #ifdef CONFIG_HAS_ETH3 case 3 : -memcpy (ethaddr[eth_num +CONFIG_EMAC_NR_START ], - bis->bi_enet3addr,6 ); +eth_getenv_enetaddr ("eth3addr" , ethaddr[ethaddr_idx]);#if defined(CONFIG_460GT ) hw_addr[eth_num] =0x400 ;#else
drivers/net/dc2114x.c +6 -3
@@ -752,11 +752,14 @@ static void update_srom(struct eth_device *dev, bd_t *bis)0x0000 ,0x0000 ,0x0000 ,0x0000 ,/* 38 */ 0x0000, 0x0000, 0x0000, 0x4e07, /* 3c */ }; +uchar enetaddr[6 ];/* Ethernet Addr... */ - eeprom[0x0a ] = ((bis->bi_enetaddr[1 ] &0xff ) <<8 ) | (bis->bi_enetaddr[0 ] &0xff ); - eeprom[0x0b ] = ((bis->bi_enetaddr[3 ] &0xff ) <<8 ) | (bis->bi_enetaddr[2 ] &0xff ); - eeprom[0x0c ] = ((bis->bi_enetaddr[5 ] &0xff ) <<8 ) | (bis->bi_enetaddr[4 ] &0xff ); +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) +return ; + eeprom[0x0a ] = (enetaddr[1 ] <<8 ) | enetaddr[0 ]; + eeprom[0x0b ] = (enetaddr[3 ] <<8 ) | enetaddr[2 ]; + eeprom[0x0c ] = (enetaddr[5 ] <<8 ) | enetaddr[4 ];for (i=0 ; i<0x40 ; i++) {write_srom (dev,DE4X5_APROM , i, eeprom[i]);
drivers/net/dm9000x.c +8 -19
@@ -287,6 +287,8 @@ eth_init(bd_t * bd)int i, oft, lnk;u8 io_mode;struct board_info *db = &dm9000_info; +uchar enetaddr[6 ]; +char buf[20 ];DM9000_DBG ("eth_init()\n" );
@@ -345,32 +347,19 @@ eth_init(bd_t * bd)DM9000_iow (DM9000_ISR ,ISR_ROOS |ISR_ROS |ISR_PTS |ISR_PRS );/* Set Node address */ +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) {#if !defined(CONFIG_AT91SAM9261EK ) -for (i =0 ; i <6 ; i++) - ((u16 *) bd->bi_enetaddr)[i] =read_srom_word (i); +for (i =0 ; i <6 ; i++) + enetaddr[i] =read_srom_word (i); +eth_setenv_enetaddr ("ethaddr" , enetaddr);#endif - -if (is_zero_ether_addr (bd->bi_enetaddr) || -is_multicast_ether_addr (bd->bi_enetaddr)) { -/* try reading from environment */ -u8 i; -char *s, *e; - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ? -simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } } -printf ("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n" , bd->bi_enetaddr[0 ], - bd->bi_enetaddr[1 ], bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); +printf ("MAC: %s\n" ,str_enetaddr (buf, enetaddr));/* fill device MAC address registers */ for (i =0 , oft =DM9000_PAR ; i <6 ; i++, oft++) -DM9000_iow (oft, bd->bi_enetaddr[i]); +DM9000_iow (oft, enetaddr[i]);for (i =0 , oft =0x16 ; i <8 ; i++, oft++)DM9000_iow (oft,0xff );
drivers/net/enc28j60.c +3 -1
@@ -330,6 +330,7 @@ static int rxResetCounter = 0;int eth_init (bd_t * bis) {unsigned char estatVal; +uchar enetaddr[6 ];/* configure GPIO */ (*((volatile unsigned long *)IO1DIR )) |=ENC_SPI_SLAVE_CS ;
@@ -351,7 +352,8 @@ int eth_init (bd_t * bis)/* initialize controller */ encReset (); -encInit (bis->bi_enetaddr); +eth_getenv_enetaddr ("ethaddr" , enetaddr); +encInit (enetaddr);m_nic_bfs (CTL_REG_ECON1 ,ENC_ECON1_RXEN );/* enable receive */
drivers/net/fsl_mcdmafec.c +6 -5
@@ -369,6 +369,7 @@ static int fec_init(struct eth_device *dev, bd_t * bd)struct fec_info_dma *info = dev->priv;volatile fecdma_t *fecp = (fecdma_t *) (info->iobase);int i; +uchar enetaddr[6 ];#ifdef ET_DEBUG printf ("fec_init: iobase 0x%08x ...\n" , info->iobase);
@@ -397,11 +398,11 @@ static int fec_init(struct eth_device *dev, bd_t * bd) fecp->eir =0xffffffff ;/* Set station address */ -if ((u32 ) fecp ==CONFIG_SYS_FEC0_IOBASE ) { -fec_set_hwaddr (fecp, bd->bi_enetaddr); - }else { -fec_set_hwaddr (fecp, bd->bi_enet1addr); - } +if ((u32 ) fecp ==CONFIG_SYS_FEC0_IOBASE ) +eth_getenv_enetaddr ("ethaddr" , enetaddr); +else +eth_getenv_enetaddr ("eth1addr" , enetaddr); +fec_set_hwaddr (fecp, enetaddr);/* Set Opcode/Pause Duration Register */ fecp->opd =0x00010020 ;
drivers/net/ks8695eth.c +2 -7
@@ -102,6 +102,7 @@ void ks8695_getmac(void)void eth_reset (bd_t *bd) {int i; +char addr[20 ];debug ("%s(%d): eth_reset()\n" , __FILE__, __LINE__);
@@ -150,13 +151,7 @@ void eth_reset(bd_t *bd)ks8695_write (KS8695_LAN_DMA_RX ,0x71 );ks8695_write (KS8695_LAN_DMA_RX_START ,0x1 ); -printf ("KS8695 ETHERNET: " ); -for (i =0 ; (i <5 ); i++) { - bd->bi_enetaddr[i] = eth_mac[i]; -printf ("%02x:" , eth_mac[i]); - } - bd->bi_enetaddr[i] = eth_mac[i]; -printf ("%02x\n" , eth_mac[i]); +printf ("KS8695 ETHERNET: %s\n" ,str_enetaddr (addr, eth_mac)); }/****************************************************************************/
drivers/net/mcffec.c +5 -5
@@ -416,7 +416,7 @@ int fec_init(struct eth_device *dev, bd_t * bd)struct fec_info_s *info = dev->priv;volatile fec_t *fecp = (fec_t *) (info->iobase);int i; -u8 *ea =NULL ; +uchar ea[6 ];fecpin_setclear (dev,1 );
@@ -444,25 +444,25 @@ int fec_init(struct eth_device *dev, bd_t * bd)if ((u32 ) fecp ==CONFIG_SYS_FEC0_IOBASE ) {#ifdef CONFIG_SYS_FEC1_IOBASE volatile fec_t *fecp1 = (fec_t *) (CONFIG_SYS_FEC1_IOBASE ); - ea = &bd->bi_enet1addr[0 ]; +eth_getenv_enetaddr ("eth1addr" , ea); fecp1->palr = (ea[0 ] <<24 ) | (ea[1 ] <<16 ) | (ea[2 ] <<8 ) | (ea[3 ]); fecp1->paur = (ea[4 ] <<24 ) | (ea[5 ] <<16 );#endif - ea = &bd->bi_enetaddr[0 ]; +eth_getenv_enetaddr ("ethaddr" , ea); fecp->palr = (ea[0 ] <<24 ) | (ea[1 ] <<16 ) | (ea[2 ] <<8 ) | (ea[3 ]); fecp->paur = (ea[4 ] <<24 ) | (ea[5 ] <<16 ); }else {#ifdef CONFIG_SYS_FEC0_IOBASE volatile fec_t *fecp0 = (fec_t *) (CONFIG_SYS_FEC0_IOBASE ); - ea = &bd->bi_enetaddr[0 ]; +eth_getenv_enetaddr ("ethaddr" , ea); fecp0->palr = (ea[0 ] <<24 ) | (ea[1 ] <<16 ) | (ea[2 ] <<8 ) | (ea[3 ]); fecp0->paur = (ea[4 ] <<24 ) | (ea[5 ] <<16 );#endif #ifdef CONFIG_SYS_FEC1_IOBASE - ea = &bd->bi_enet1addr[0 ]; +eth_getenv_enetaddr ("eth1addr" , ea); fecp->palr = (ea[0 ] <<24 ) | (ea[1 ] <<16 ) | (ea[2 ] <<8 ) | (ea[3 ]); fecp->paur = (ea[4 ] <<24 ) | (ea[5 ] <<16 );
drivers/net/rtl8019.c +8 -6
@@ -91,6 +91,7 @@ void eth_halt (void)int eth_init (bd_t * bd) { +uchar enetaddr[6 ];eth_reset ();put_reg (RTL8019_COMMAND ,RTL8019_PAGE0STOP );put_reg (RTL8019_DATACONFIGURATION ,0x48 );
@@ -105,12 +106,13 @@ int eth_init (bd_t * bd)put_reg (RTL8019_INTERRUPTSTATUS ,0xff );put_reg (RTL8019_INTERRUPTMASK ,0x11 );/*b; */ put_reg (RTL8019_COMMAND ,RTL8019_PAGE1STOP ); -put_reg (RTL8019_PHYSICALADDRESS0 , bd->bi_enetaddr[0 ]); -put_reg (RTL8019_PHYSICALADDRESS1 , bd->bi_enetaddr[1 ]); -put_reg (RTL8019_PHYSICALADDRESS2 , bd->bi_enetaddr[2 ]); -put_reg (RTL8019_PHYSICALADDRESS3 , bd->bi_enetaddr[3 ]); -put_reg (RTL8019_PHYSICALADDRESS4 , bd->bi_enetaddr[4 ]); -put_reg (RTL8019_PHYSICALADDRESS5 , bd->bi_enetaddr[5 ]); +eth_getenv_enetaddr ("ethaddr" , enetaddr); +put_reg (RTL8019_PHYSICALADDRESS0 , enetaddr[0 ]); +put_reg (RTL8019_PHYSICALADDRESS1 , enetaddr[1 ]); +put_reg (RTL8019_PHYSICALADDRESS2 , enetaddr[2 ]); +put_reg (RTL8019_PHYSICALADDRESS3 , enetaddr[3 ]); +put_reg (RTL8019_PHYSICALADDRESS4 , enetaddr[4 ]); +put_reg (RTL8019_PHYSICALADDRESS5 , enetaddr[5 ]);put_reg (RTL8019_MULTIADDRESS0 ,0x00 );put_reg (RTL8019_MULTIADDRESS1 ,0x00 );put_reg (RTL8019_MULTIADDRESS2 ,0x00 );
drivers/net/rtl8169.c +1 -1
@@ -750,7 +750,7 @@ static int rtl_init(struct eth_device *dev, bd_t *bis)/* Get MAC address. FIXME: read EEPROM */ for (i =0 ; i <MAC_ADDR_LEN ; i++) - bis->bi_enetaddr[i] = dev->enetaddr[i] =RTL_R8 (MAC0 + i); + dev->enetaddr[i] =RTL_R8 (MAC0 + i);#ifdef DEBUG_RTL8169 printf ("chipset = %d\n" , tpc->chipset);
drivers/net/s3c4510b_eth.c +1 -1
@@ -100,7 +100,7 @@ int eth_init(bd_t *bis)ETH *eth = &m_eth;/* store our MAC address */ - eth->m_mac = bis->bi_enetaddr; +eth_getenv_enetaddr ("ethaddr" , eth->m_mac);/* setup DBMA and MAC */ PUT_REG (REG_BDMARXCON , ETH_BRxRS);/* reset BDMA RX machine */
drivers/net/s3c4510b_eth.h +1 -1
@@ -296,7 +296,7 @@ typedef struct __ETH {TX_FrameDescriptor *m_baseTX_FD;/* pointer to base TX frame descriptor */ RX_FrameDescriptor *m_curRX_FD;/* pointer to current RX frame descriptor */ RX_FrameDescriptor *m_baseRX_FD;/* pointer to base RX frame descriptor */ - u8 *m_mac; /* pointer to our MAC address */ + u8 m_mac[6]; /* pointer to our MAC address */ }ETH ;#endif
drivers/net/xilinx_emac.c +7 -5
@@ -166,6 +166,7 @@ void eth_halt(void)int eth_init (bd_t * bis) { +uchar enetaddr[6 ];u32 helpreg;debug ("EMAC Initialization Started\n\r" );
@@ -200,15 +201,16 @@ int eth_init(bd_t * bis) helpreg &= ~(XEM_ECR_XMIT_ENABLE_MASK |XEM_ECR_RECV_ENABLE_MASK );out_be32 (emac.baseaddress +XEM_ECR_OFFSET , helpreg); -if (!getenv ("ethaddr" )) { -memcpy (bis->bi_enetaddr, emacaddr,ENET_ADDR_LENGTH ); +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) { +memcpy (enetaddr, emacaddr,ENET_ADDR_LENGTH ); +eth_setenv_enetaddr ("ethaddr" , enetaddr); }/* Set the device station address high and low registers */ - helpreg = (bis->bi_enetaddr[0 ] <<8 ) | bis->bi_enetaddr[1 ]; + helpreg = (enetaddr[0 ] <<8 ) | enetaddr[1 ];out_be32 (emac.baseaddress +XEM_SAH_OFFSET , helpreg); - helpreg = (bis->bi_enetaddr[2 ] <<24 ) | (bis->bi_enetaddr[3 ] <<16 ) | - (bis->bi_enetaddr[4 ] <<8 ) | bis->bi_enetaddr[5 ]; + helpreg = (enetaddr[2 ] <<24 ) | (enetaddr[3 ] <<16 ) | + (enetaddr[4 ] <<8 ) | enetaddr[5 ];out_be32 (emac.baseaddress +XEM_SAL_OFFSET , helpreg); helpreg = XEM_ECR_UNICAST_ENABLE_MASK | XEM_ECR_BROAD_ENABLE_MASK |
drivers/net/xilinx_emaclite.c +7 -4
@@ -140,12 +140,15 @@ void eth_halt (void)int eth_init (bd_t * bis) { +uchar enetaddr[6 ]; +debug ("EmacLite Initialization Started\n" );memset (&emaclite,0 ,sizeof (xemaclite)); emaclite.baseaddress =XILINX_EMACLITE_BASEADDR ; -if (!getenv ("ethaddr" )) { -memcpy (bis->bi_enetaddr, emacaddr,ENET_ADDR_LENGTH ); +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) { +memcpy (enetaddr, emacaddr,ENET_ADDR_LENGTH ); +eth_setenv_enetaddr ("ethaddr" , enetaddr); }/*
@@ -154,7 +157,7 @@ int eth_init (bd_t * bis)/* Restart PING TX */ out_be32 (emaclite.baseaddress +XEL_TSR_OFFSET ,0 );/* Copy MAC address */ -xemaclite_alignedwrite (bis->bi_enetaddr, +xemaclite_alignedwrite (enetaddr, emaclite.baseaddress,ENET_ADDR_LENGTH );/* Set the length */ out_be32 (emaclite.baseaddress +XEL_TPLR_OFFSET ,ENET_ADDR_LENGTH );
@@ -167,7 +170,7 @@ int eth_init (bd_t * bis)#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG /* The same operation with PONG TX */ out_be32 (emaclite.baseaddress +XEL_TSR_OFFSET +XEL_BUFFER_OFFSET ,0 ); -xemaclite_alignedwrite (bis->bi_enetaddr, emaclite.baseaddress + +xemaclite_alignedwrite (enetaddr, emaclite.baseaddress +XEL_BUFFER_OFFSET ,ENET_ADDR_LENGTH );out_be32 (emaclite.baseaddress +XEL_TPLR_OFFSET ,ENET_ADDR_LENGTH ); out_be32 (emaclite.baseaddress + XEL_TSR_OFFSET + XEL_BUFFER_OFFSET,
Signature · 1 line
1.6.1.3
PATCH 12/27 bcm570x: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Since the address is in the PLM_DEVICE_BLOCK structure already, there is no need to pass the NodeAddress as a second parameter. So drop the second argument to the LM_SetMacAddress() function (and update the tigon3 driver accordingly).
--- drivers/net/bcm570x.c | 4 ++-- drivers/net/bcm570x_lm.h | 2 +- drivers/net/tigon3.c | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/bcm570x.c +2 -2
@@ -450,8 +450,8 @@ int eth_init (bd_t * bis) + 1);strcpy (pUmDevice->name, board_info[bcm570xDevices[i].board_id].name); -memcpy (pDevice->NodeAddress, bis->bi_enetaddr,6 ); -LM_SetMacAddress (pDevice, bis->bi_enetaddr); +eth_getenv_enetaddr ("ethaddr" , pDevice->NodeAddress); +LM_SetMacAddress (pDevice);/* Init queues .. */ QQ_InitQueue (&pUmDevice->rx_out_of_buf_q.Container,MAX_RX_PACKET_DESC_COUNT );
drivers/net/bcm570x_lm.h +1 -1
@@ -371,7 +371,7 @@ LM_STATUS LM_Abort (PLM_DEVICE_BLOCK pDevice);LM_STATUS LM_MulticastAdd (PLM_DEVICE_BLOCK pDevice,PLM_UINT8 pMcAddress);LM_STATUS LM_MulticastDel (PLM_DEVICE_BLOCK pDevice,PLM_UINT8 pMcAddress);LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice); -LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice,PLM_UINT8 pMacAddress); +LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice);LM_STATUS LM_LoopbackAddress (PLM_DEVICE_BLOCK pDevice,PLM_UINT8 pAddress);LM_UINT32 LM_GetCrcCounter (PLM_DEVICE_BLOCK pDevice);
drivers/net/tigon3.c +4 -3
@@ -2463,7 +2463,7 @@ LM_STATUS LM_ResetAdapter (PLM_DEVICE_BLOCK pDevice)#endif /* T3_JUMBO_RCV_ENTRY_COUNT */ /* Configure the MAC address. */ -LM_SetMacAddress (pDevice, pDevice->NodeAddress); +LM_SetMacAddress (pDevice);/* Initialize the transmit random backoff seed. */ Value32 = (pDevice->NodeAddress[0] + pDevice->NodeAddress[1] +
@@ -3428,7 +3428,7 @@ LM_STATUS LM_Halt (PLM_DEVICE_BLOCK pDevice) (pDevice->SubsystemId << 16) | pDevice->SubsystemVendorId);/* Reprogram the MAC address. */ -LM_SetMacAddress (pDevice, pDevice->NodeAddress); +LM_SetMacAddress (pDevice);return LM_STATUS_SUCCESS ; }/* LM_Halt */
@@ -3833,9 +3833,10 @@ LM_STATUS LM_MulticastClear (PLM_DEVICE_BLOCK pDevice)/* */ /* Return: */ /******************************************************************************/ -LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice,PLM_UINT8 pMacAddress) +LM_STATUS LM_SetMacAddress (PLM_DEVICE_BLOCK pDevice) {LM_UINT32 j; +PLM_UINT8 pMacAddress = pDevice->NodeAddress;for (j =0 ; j <4 ; j++) { REG_WR (pDevice, MacCtrl.MacAddr[j].High,
Signature · 1 line
1.6.1.3
PATCH 13/27 cs8900: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
The cs8900 driver also changes slightly in that the hardware is not consulted if the mac address in the env is sane.
--- drivers/net/cs8900.c | 58 +++++++++++++++---------------------------------- 1 files changed, 18 insertions(+), 40 deletions(-)
drivers/net/cs8900.c +18 -40
@@ -110,18 +110,15 @@ static void eth_reginit (void)put_reg (PP_LineCTL, PP_LineCTL_Rx | PP_LineCTL_Tx); } -void cs8900_get_enetaddr (uchar * addr) +void cs8900_get_enetaddr (void ) {int i; -unsigned char env_enetaddr[6 ]; -char *tmp =getenv ("ethaddr" ); -char *end; - -for (i=0 ; i<6 ; i++) { - env_enetaddr[i] = tmp ?simple_strtoul (tmp, &end,16 ) :0 ; -if (tmp) - tmp = (*end) ? end+1 : end; - } +uchar enetaddr[6 ]; +char buf[20 ]; + +/* if the env is setup, then bail */ +if (eth_getenv_enetaddr ("ethaddr" , enetaddr)) +return ;/* verify chip id */ if (get_reg_init_bus (PP_ChipID) !=0x630e )
@@ -135,35 +132,13 @@ void cs8900_get_enetaddr (uchar * addr)unsigned int Addr; Addr =get_reg (PP_IA + i *2 ); - addr[i *2 ] = Addr &0xFF ; - addr[i *2 +1 ] = Addr >>8 ; + enetaddr[i *2 ] = Addr &0xFF ; + enetaddr[i *2 +1 ] = Addr >>8 ; } -if (memcmp (env_enetaddr,"\0\0\0\0\0\0" ,6 ) !=0 && -memcmp (env_enetaddr, addr,6 ) !=0 ) { -printf ("\nWarning: MAC addresses don't match:\n" ); -printf ("\tHW MAC address: " -"%02X:%02X:%02X:%02X:%02X:%02X\n" , - addr[0 ], addr[1 ], - addr[2 ], addr[3 ], - addr[4 ], addr[5 ] ); -printf ("\t\"ethaddr\" value: " -"%02X:%02X:%02X:%02X:%02X:%02X\n" , - env_enetaddr[0 ], env_enetaddr[1 ], - env_enetaddr[2 ], env_enetaddr[3 ], - env_enetaddr[4 ], env_enetaddr[5 ]) ; -debug ("### Set MAC addr from environment\n" ); -memcpy (addr, env_enetaddr,6 ); - } -if (!tmp) { -char ethaddr[20 ]; -sprintf (ethaddr,"%02X:%02X:%02X:%02X:%02X:%02X" , - addr[0 ], addr[1 ], - addr[2 ], addr[3 ], - addr[4 ], addr[5 ]) ; -debug ("### Set environment from HW MAC addr = \"%s\"\n" , ethaddr); -setenv ("ethaddr" , ethaddr); - } +eth_setenv_enetaddr ("ethaddr" , enetaddr); +str_enetaddr (buf, enetaddr); +debug ("### Set environment from HW MAC addr = \"%s\"\n" , buf); } }
@@ -178,6 +153,8 @@ void eth_halt (void)int eth_init (bd_t * bd) { +uchar *enetaddr[6 ]; +/* verify chip id */ if (get_reg_init_bus (PP_ChipID) !=0x630e ) {printf ("CS8900 Ethernet chip not found?!\n" );
@@ -186,9 +163,10 @@ int eth_init (bd_t * bd)eth_reset ();/* set the ethernet address */ -put_reg (PP_IA +0 , bd->bi_enetaddr[0 ] | (bd->bi_enetaddr[1 ] <<8 )); -put_reg (PP_IA +2 , bd->bi_enetaddr[2 ] | (bd->bi_enetaddr[3 ] <<8 )); -put_reg (PP_IA +4 , bd->bi_enetaddr[4 ] | (bd->bi_enetaddr[5 ] <<8 )); +eth_getenv_enetaddr ("ethaddr" , enetaddr); +put_reg (PP_IA +0 , enetaddr[0 ] | (enetaddr[1 ] <<8 )); +put_reg (PP_IA +2 , enetaddr[2 ] | (enetaddr[3 ] <<8 )); +put_reg (PP_IA +4 , enetaddr[4 ] | (enetaddr[5 ] <<8 ));eth_reginit ();return 0 ;
Signature · 1 line
1.6.1.3
PATCH 14/27 sh_eth: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
The sh_eth driver can also be simplified a bit by using enetaddr member of the eth_device structure.
--- drivers/net/sh_eth.c | 28 ++++++---------------------- 1 files changed, 6 insertions(+), 22 deletions(-)
drivers/net/sh_eth.c +6 -22
@@ -514,6 +514,7 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)int port = eth->port, ret =0 ;u32 val, phy_status;struct sh_eth_info *port_info = ð->port_info[port]; +struct eth_device *dev = port_info->dev;/* Configure e-dmac registers */ outl ((inl (EDMR (port)) & ~EMDR_DESC_R ) |EDMR_EL ,EDMR (port));
@@ -529,11 +530,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd)outl (0 ,ECSIPR (port));/* Set Mac address */ - val = bd->bi_enetaddr[0 ] <<24 | bd->bi_enetaddr[1 ] <<16 | - bd->bi_enetaddr[2 ] <<8 | bd->bi_enetaddr[3 ]; + val = dev->enetaddr[0 ] <<24 | dev->enetaddr[1 ] <<16 | + dev->enetaddr[2 ] <<8 | dev->enetaddr[3 ];outl (val,MAHR (port)); - val = bd->bi_enetaddr[4 ] <<8 | bd->bi_enetaddr[5 ]; + val = dev->enetaddr[4 ] <<8 | dev->enetaddr[5 ];outl (val,MALR (port));outl (RFLR_RFL_MIN ,RFLR (port));
@@ -589,24 +590,6 @@ static void sh_eth_stop(struct sh_eth_dev *eth)outl (~EDRRR_R ,EDRRR (eth->port)); } -static int sh_eth_get_mac (bd_t *bd) -{ -char *s, *e; - - s =getenv ("ethaddr" ); -if (s !=NULL ) { -int i; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } - }else { -puts ("Please set MAC address\n" ); - } -return 0 ; -} -int sh_eth_init (struct eth_device *dev,bd_t *bd) {int ret =0 ;
@@ -682,7 +665,8 @@ int sh_eth_initialize(bd_t *bd)/* Register Device to EtherNet subsystem */ eth_register (dev); -sh_eth_get_mac (bd); +if (!eth_getenv_enetaddr ("ethaddr" , dev->enetaddr)) +puts ("Please set MAC address\n" );return ret;
Signature · 1 line
1.6.1.3
PATCH 15/27 lan91c96/smc91111/smc911x: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Also, do not bother checking the EEPROM if the env is setup. This simplifies the code greatly.
--- drivers/net/lan91c96.c | 79 +++++++++-------------------------------------- drivers/net/smc91111.c | 76 +++++++++------------------------------------- drivers/net/smc911x.c | 15 ++++----- 3 files changed, 36 insertions(+), 134 deletions(-)
drivers/net/lan91c96.c +15 -64
@@ -606,10 +606,8 @@ static int smc_open (bd_t *bd)SMC_SELECT_BANK (1 ); err =smc_get_ethaddr (bd);/* set smc_mac_addr, and sync it with u-boot globals */ -if (err <0 ) { -memset (bd->bi_enetaddr,0 ,6 );/* hack to make error stick! upper code will abort if not set */ -return (-1 );/* upper code ignores this, but NOT bi_enetaddr */ - } +if (err <0 ) +return -1 ;#ifdef USE_32_BIT for (i =0 ; i <6 ; i +=2 ) {word address;
@@ -869,69 +867,22 @@ static int smc_hw_init ()int smc_get_ethaddr (bd_t * bd) { -int env_size =0 ; -int rom_valid =0 ; -int env_present =0 ; -int reg =0 ; -char *s =NULL ; -char *e =NULL ; -char *v_mac, es[] ="11:22:33:44:55:66" ; -char s_env_mac[64 ]; -uchar v_env_mac[6 ]; -uchar v_rom_mac[6 ]; - - env_size =getenv_r ("ethaddr" , s_env_mac,sizeof (s_env_mac)); -if (env_size !=sizeof (es)) {/* Ignore if env is bad or not set */ -printf ("\n*** Warning: ethaddr is not set properly, ignoring!!\n" ); - }else { - env_present =1 ; - s = s_env_mac; - -for (reg =0 ; reg <6 ; ++reg) {/* turn string into mac value */ - v_env_mac[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; +uchar v_mac[6 ]; +char buf[20 ]; + +if (!eth_getenv_enetaddr ("ethaddr" , v_mac)) { +/* get ROM mac value if any */ +if (!get_rom_mac (v_mac)) { +printf ("\n*** ERROR: ethaddr is NOT set !!\n" ); +return -1 ; } +eth_setenv_enetaddr ("ethaddr" , v_mac); } - rom_valid =get_rom_mac (v_rom_mac);/* get ROM mac value if any */ - -if (!env_present) {/* if NO env */ -if (rom_valid) {/* but ROM is valid */ - v_mac = (char *)v_rom_mac; -sprintf (s_env_mac,"%02X:%02X:%02X:%02X:%02X:%02X" , - v_mac[0 ], v_mac[1 ], v_mac[2 ], v_mac[3 ], - v_mac[4 ], v_mac[5 ]); -setenv ("ethaddr" , s_env_mac); - }else {/* no env, bad ROM */ -printf ("\n*** ERROR: ethaddr is NOT set !!\n" ); -return (-1 ); - } - }else {/* good env, don't care ROM */ - v_mac = (char *)v_env_mac;/* always use a good env over a ROM */ - } - -if (env_present && rom_valid) {/* if both env and ROM are good */ -if (memcmp (v_env_mac, v_rom_mac,6 ) !=0 ) { -printf ("\nWarning: MAC addresses don't match:\n" ); -printf ("\tHW MAC address: " -"%02X:%02X:%02X:%02X:%02X:%02X\n" , - v_rom_mac[0 ], v_rom_mac[1 ], - v_rom_mac[2 ], v_rom_mac[3 ], - v_rom_mac[4 ], v_rom_mac[5 ] ); -printf ("\t\"ethaddr\" value: " -"%02X:%02X:%02X:%02X:%02X:%02X\n" , - v_env_mac[0 ], v_env_mac[1 ], - v_env_mac[2 ], v_env_mac[3 ], - v_env_mac[4 ], v_env_mac[5 ]) ; -debug ("### Set MAC addr from environment\n" ); - } - } -memcpy (bd->bi_enetaddr, v_mac,6 );/* update global address to match env (allows env changing) */ -smc_set_mac_addr ((unsigned char *)v_mac);/* use old function to update smc default */ -PRINTK ("Using MAC Address %02X:%02X:%02X:%02X:%02X:%02X\n" , v_mac[0 ], v_mac[1 ], - v_mac[2 ], v_mac[3 ], v_mac[4 ], v_mac[5 ]); -return (0 ); +smc_set_mac_addr (v_mac);/* use old function to update smc default */ +str_enetaddr (buf, v_mac); +PRINTK ("Using MAC Address %s\n" , buf); +return 0 ; }/*
drivers/net/smc91111.c +15 -61
91 lines not on this page · raw message
drivers/net/smc911x.c +6 -9
@@ -434,15 +434,11 @@ void smc911x_set_mac_csr(u8 reg, u32 data)static int smx911x_handle_mac_address (bd_t *bd) {unsigned long addrh, addrl; -unsigned char *m = bd->bi_enetaddr; +uchar m[6 ]; +char buf[20 ];/* if the environment has a valid mac address then use it */ -if ((m[0 ] | m[1 ] | m[2 ] | m[3 ] | m[4 ] | m[5 ])) { - addrl = m[0 ] | m[1 ] <<8 | m[2 ] <<16 | m[3 ] <<24 ; - addrh = m[4 ] | m[5 ] <<8 ; -smc911x_set_mac_csr (ADDRH , addrh); -smc911x_set_mac_csr (ADDRL , addrl); - }else { +if (!eth_getenv_enetaddr ("ethaddr" , m))/* if not, try to get one from the eeprom */ addrh =smc911x_get_mac_csr (ADDRH ); addrl =smc911x_get_mac_csr (ADDRL );
@@ -460,10 +456,11 @@ static int smx911x_handle_mac_address(bd_t *bd) "and no eeprom found\n");return -1 ; } + +eth_setenv_enetaddr ("ethaddr" , m); } -printf (DRIVERNAME ": MAC %02x:%02x:%02x:%02x:%02x:%02x\n" , - m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ]); +printf (DRIVERNAME ": MAC %s\n" ,str_enetaddr (buf, m));return 0 ; }
Signature · 1 line
1.6.1.3
PATCH 16/27 cpu/: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
The cpus that get converted here:
at91rm9200 mpc512x mpc5xxx mpc8260 mpc8xx ppc4xx
--- cpu/arm920t/at91rm9200/ether.c | 8 +++++--- cpu/mpc512x/cpu.c | 6 ++++-- cpu/mpc5xxx/cpu.c | 6 ++++-- cpu/mpc8260/ether_fcc.c | 4 ++-- cpu/mpc8260/ether_scc.c | 4 ++-- cpu/ppc4xx/cpu_init.c | 14 ++++++++------ post/cpu/mpc8xx/ether.c | 4 ++-- 7 files changed, 27 insertions(+), 19 deletions(-)
cpu/arm920t/at91rm9200/ether.c +5 -3
@@ -155,6 +155,7 @@ int eth_init (bd_t * bd) {int ret;int i; +uchar enetaddr[6 ]; p_mac =AT91C_BASE_EMAC ;
@@ -190,9 +191,10 @@ int eth_init (bd_t * bd) rbfdt[RBF_FRAMEMAX -1 ].addr |=RBF_WRAP ; rbfp = &rbfdt[0 ]; - p_mac->EMAC_SA2L = (bd->bi_enetaddr[3 ] <<24 ) | (bd->bi_enetaddr[2 ] <<16 ) - | (bd->bi_enetaddr[1 ] <<8 ) | (bd->bi_enetaddr[0 ]); - p_mac->EMAC_SA2H = (bd->bi_enetaddr[5 ] <<8 ) | (bd->bi_enetaddr[4 ]); +eth_getenv_enetaddr ("ethaddr" , enetaddr); + p_mac->EMAC_SA2L = (enetaddr[3 ] <<24 ) | (enetaddr[2 ] <<16 ) + | (enetaddr[1 ] <<8 ) | (enetaddr[0 ]); + p_mac->EMAC_SA2H = (enetaddr[5 ] <<8 ) | (enetaddr[4 ]); p_mac->EMAC_RBQP = (long ) (&rbfdt[0 ]); p_mac->EMAC_RSR &= ~(AT91C_EMAC_RSR_OVR |AT91C_EMAC_REC |AT91C_EMAC_BNA );
cpu/mpc512x/cpu.c +4 -2
@@ -148,15 +148,17 @@ static void old_ft_cpu_setup(void *blob, bd_t *bd)* avoid fixing up by path because that * produces scary error messages */ +uchar enetaddr[6 ];/* * old device trees have ethernet nodes with * device_type = "network" */ +eth_getenv_enetaddr ("ethaddr" , enetaddr);do_fixup_by_prop (blob,"device_type" ,"network" ,8 , -"local-mac-address" , bd->bi_enetaddr,6 ,0 ); +"local-mac-address" , enetaddr,6 ,0 );do_fixup_by_prop (blob,"device_type" ,"network" ,8 , -"address" , bd->bi_enetaddr,6 ,0 ); +"address" , enetaddr,6 ,0 );/* * old device trees have soc nodes with * device_type = "soc"
cpu/mpc5xxx/cpu.c +4 -2
@@ -121,6 +121,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)int div =in_8 ((void *)CONFIG_SYS_MBAR +0x204 ) &0x0020 ?8 :4 ;char * cpu_path ="/cpus/" OF_CPU ;#ifdef CONFIG_MPC5xxx_FEC +uchar *enetaddr[6 ];char * eth_path ="/" OF_SOC "/ethernet at 3000" ;#endif
@@ -131,8 +132,9 @@ void ft_cpu_setup(void *blob, bd_t *bd)do_fixup_by_path_u32 (blob,"/" OF_SOC ,"system-frequency" , bd->bi_busfreq*div,1 );#ifdef CONFIG_MPC5xxx_FEC -do_fixup_by_path (blob, eth_path,"mac-address" , bd->bi_enetaddr,6 ,0 ); -do_fixup_by_path (blob, eth_path,"local-mac-address" , bd->bi_enetaddr,6 ,0 ); +eth_getenv_enetaddr ("ethaddr" , enetaddr); +do_fixup_by_path (blob, eth_path,"mac-address" , enetaddr,6 ,0 ); +do_fixup_by_path (blob, eth_path,"local-mac-address" , enetaddr,6 ,0 ); #endif }#endif
cpu/mpc8260/ether_fcc.c +2 -2
@@ -654,7 +654,7 @@ eth_loopback_test (void)puts ("FCC Ethernet External loopback test\n" ); -memcpy (NetOurEther, gd->bd->bi_enetaddr,6 ); +eth_getenv_enetaddr ("ethaddr" , NetOurEther);/* * global initialisations for all FCC channels
@@ -841,7 +841,7 @@ eth_loopback_test (void)* So, far we have only been given one Ethernet address. We use * the same address for all channels */ -#define ea gd->bd->bi_enetaddr +#define ea NetOurEther fpp->fen_paddrh = (ea[5 ] <<8 ) + ea[4 ]; fpp->fen_paddrm = (ea[3 ] <<8 ) + ea[2 ]; fpp->fen_paddrl = (ea[1 ] <<8 ) + ea[0 ];
cpu/mpc8260/ether_scc.c +2 -2
@@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis)volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR ;scc_enet_t *pram_ptr;uint dpaddr; +uchar ea[6 ]; rxIdx =0 ; txIdx =0 ;
@@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis) pram_ptr->sen_gaddr3 =0x0 ;/* Group Address Filter 3 (unused) */ pram_ptr->sen_gaddr4 =0x0 ;/* Group Address Filter 4 (unused) */ -# define ea bis->bi_enetaddr +eth_getenv_enetaddr ("ethaddr" , ea); pram_ptr->sen_paddrh = (ea[5 ] <<8 ) + ea[4 ]; pram_ptr->sen_paddrm = (ea[3 ] <<8 ) + ea[2 ]; pram_ptr->sen_paddrl = (ea[1 ] <<8 ) + ea[0 ]; -# undef ea pram_ptr->sen_pper =0x0 ;/* Persistence (unused) */
cpu/ppc4xx/cpu_init.c +8 -6
@@ -324,6 +324,7 @@ int cpu_init_r (void)#if defined(CONFIG_405GP ) || defined(CONFIG_405EP )bd_t *bd = gd->bd;unsigned long reg; +uchar enetaddr[6 ];#if defined(CONFIG_405GP )uint pvr =get_pvr ();#endif
@@ -332,19 +333,20 @@ int cpu_init_r (void)* Write Ethernetaddress into on-chip register */ reg =0x00000000 ; - reg |= bd->bi_enetaddr[0 ];/* set high address */ +eth_getenv_enetaddr ("ethaddr" , enetaddr); + reg |= enetaddr[0 ];/* set high address */ reg = reg <<8 ; - reg |= bd->bi_enetaddr[1 ]; + reg |= enetaddr[1 ];out32 (EMAC_IAH , reg); reg =0x00000000 ; - reg |= bd->bi_enetaddr[2 ];/* set low address */ + reg |= enetaddr[2 ];/* set low address */ reg = reg <<8 ; - reg |= bd->bi_enetaddr[3 ]; + reg |= enetaddr[3 ]; reg = reg <<8 ; - reg |= bd->bi_enetaddr[4 ]; + reg |= enetaddr[4 ]; reg = reg <<8 ; - reg |= bd->bi_enetaddr[5 ]; + reg |= enetaddr[5 ];out32 (EMAC_IAL , reg);#if defined(CONFIG_405GP )
post/cpu/mpc8xx/ether.c +2 -2
@@ -110,6 +110,7 @@ static RTXBD *rtx;static void scc_init (int scc_index) {bd_t *bd = gd->bd; +uchar ea[6 ];static int proff[] = {PROFF_SCC1 ,PROFF_SCC2 ,PROFF_SCC3 ,PROFF_SCC4 };
@@ -296,11 +297,10 @@ CPM_CR_CH_SCC4 }; pram_ptr->sen_gaddr3 =0x0 ;/* Group Address Filter 3 (unused) */ pram_ptr->sen_gaddr4 =0x0 ;/* Group Address Filter 4 (unused) */ -#define ea bd->bi_enetaddr +eth_getenv_enetaddr ("ethaddr" , ea); pram_ptr->sen_paddrh = (ea[5 ] <<8 ) + ea[4 ]; pram_ptr->sen_paddrm = (ea[3 ] <<8 ) + ea[2 ]; pram_ptr->sen_paddrl = (ea[1 ] <<8 ) + ea[0 ]; -#undef ea pram_ptr->sen_pper =0x0 ;/* Persistence (unused) */ pram_ptr->sen_iaddr1 =0x0 ;/* Individual Address Filter 1 (unused) */
Signature · 1 line
1.6.1.3
PATCH 16/27 cpu/: get mac address from environment
Dear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
...
Quoted 11 lines
cpu/mpc8260/ether_scc.c +1
-0@@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis)volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR ;scc_enet_t *pram_ptr;uint dpaddr; +uchar ea[6 ]; rxIdx =0 ; txIdx =0 ;
cpu/mpc8260/ether_scc.c static int sec_init(struct eth_device *dev, bd_t *bis) · line 268
Quoted 9 lines
cpu/mpc8260/ether_scc.c +1
-2@@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis) pram_ptr->sen_gaddr3 =0x0 ;/* Group Address Filter 3 (unused) */ pram_ptr->sen_gaddr4 =0x0 ;/* Group Address Filter 4 (unused) */ -# define ea bis->bi_enetaddr +eth_getenv_enetaddr ("ethaddr" , ea); pram_ptr->sen_paddrh = (ea[5 ] <<8 ) + ea[4 ]; pram_ptr->sen_paddrm = (ea[3 ] <<8 ) + ea[2 ]; pram_ptr->sen_paddrl = (ea[1 ] <<8 ) + ea[0 ]; -# undef ea
I see that we have bad indentations here, but please either provide a separate patch to fix the cosing style, or stich with your new code to the existing one.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There's an old proverb that says just about whatever you want it to.
PATCH 16/27 cpu/: get mac address from environment
Quoted 15 lines · On Monday 16 February 2009 17:52:55 Wolfgang Denk wrote:
Quoted 14 lines · In message Mike Frysinger
cpu/mpc8260/ether_scc.c +1
-0@@ -199,6 +199,7 @@ static int sec_init(struct eth_device *dev, bd_t *bis) volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;scc_enet_t *pram_ptr;uint dpaddr; +uchar ea[6 ]; rxIdx =0 ; txIdx =0 ;@@ -261,11 +262,10 @@ static int sec_init(struct eth_device *dev, bd_t *bis) pram_ptr->sen_gaddr3 = 0x0; /* Group Address Filter 3 (unused) */
pram_ptr->sen_gaddr4=0x0; /* Group Address Filter 4 (unused) */
Quoted 10 lines
cpu/mpc8260/ether_scc.c static int sec_init(struct eth_device *dev, bd_t *bis) · line 268
Quoted 6 lines
cpu/mpc8260/ether_scc.c +1
-2-# define ea bis->bi_enetaddr +eth_getenv_enetaddr ("ethaddr" , ea); pram_ptr->sen_paddrh = (ea[5 ] <<8 ) + ea[4 ]; pram_ptr->sen_paddrm = (ea[3 ] <<8 ) + ea[2 ]; pram_ptr->sen_paddrl = (ea[1 ] <<8 ) + ea[0 ]; -# undef eaI see that we have bad indentations here, but please either provide a separate patch to fix the cosing style, or stich with your new code to the existing one.
oh, looks like this file uses sucky GNU style. i didnt notice as i use 4- spaced tabs. i'll just change my tabs to match existing style as the cleanup would pretty much rewrite the whole file.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/58b8c8e2/attachment.pgp
PATCH 17/27 npe: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
The resulting code can also be simplified even further.
--- cpu/ixp/npe/npe.c | 36 +++++++++++------------------------- 1 files changed, 11 insertions(+), 25 deletions(-)
cpu/ixp/npe/npe.c +11 -25
@@ -565,25 +565,19 @@ int npe_initialize(bd_t * bis)struct eth_device *dev;int eth_num =0 ;struct npe *p_npe =NULL ; +uchar enetaddr[6 ];for (eth_num =0 ; eth_num <CONFIG_SYS_NPE_NUMS ; eth_num++) {/* See if we can actually bring up the interface, otherwise, skip it */ -switch (eth_num) { -default :/* fall through */ -case 0 : -if (memcmp (bis->bi_enetaddr,"\0\0\0\0\0\0" ,6 ) ==0 ) { -continue ; - } -break ;#ifdef CONFIG_HAS_ETH1 -case 1 : -if (memcmp (bis->bi_enet1addr,"\0\0\0\0\0\0" ,6 ) ==0 ) { +if (eth_num ==1 ) { +if (!eth_getenv_enetaddr ("eth1addr" , enetaddr))continue ; - } -break ; + } else#endif - } +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) +continue ;/* Allocate device structure */ dev = (struct eth_device *)malloc (sizeof (*dev));
@@ -603,22 +597,14 @@ int npe_initialize(bd_t * bis) }memset (p_npe,0 ,sizeof (struct npe )); -switch (eth_num) { -default :/* fall through */ -case 0 : -memcpy (dev->enetaddr, bis->bi_enetaddr,6 ); - p_npe->eth_id =0 ; - p_npe->phy_no =CONFIG_PHY_ADDR ; -break ; - + p_npe->eth_id = eth_num; +memcpy (dev->enetaddr, enetaddr,6 );#ifdef CONFIG_HAS_ETH1 -case 1 : -memcpy (dev->enetaddr, bis->bi_enet1addr,6 ); - p_npe->eth_id =1 ; +if (eth_num ==1 ) p_npe->phy_no =CONFIG_PHY1_ADDR ; -break ; + else#endif - } + p_npe->phy_no =CONFIG_PHY_ADDR ;sprintf (dev->name,"NPE%d" , eth_num); dev->priv = (void *)p_npe;
Signature · 1 line
1.6.1.3
PATCH 18/27 lib_*/board.c: do not initialize bi_enet*addr in global data
In reply to Mike FrysingerSince everyone is using the environment for mac address storage, there is no point in seeding the global data.
The arches that are converted here:
i386 m68k microblaze mips nios nios2 sh sparc
--- lib_i386/board.c | 17 ----------------- lib_m68k/board.c | 38 -------------------------------------- lib_microblaze/board.c | 8 -------- lib_mips/board.c | 8 -------- lib_nios/board.c | 5 ----- lib_nios2/board.c | 5 ----- lib_sh/board.c | 10 ---------- lib_sparc/board.c | 19 ------------------- 8 files changed, 0 insertions(+), 110 deletions(-)
lib_i386/board.c +0 -17
@@ -262,23 +262,6 @@ void start_i386boot (void)/* IP Address */ bd_data.bi_ip_addr =getenv_IPaddr ("ipaddr" ); -/* MAC Address */ - { -int i; -ulong reg; -char *s, *e; -char tmp[64 ]; - - i =getenv_r ("ethaddr" , tmp,sizeof (tmp)); - s = (i >0 ) ? tmp :NULL ; - -for (reg =0 ; reg <6 ; ++reg) { - bd_data.bi_enetaddr[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } - } -#if defined(CONFIG_PCI )/* * Do pci configuration
lib_m68k/board.c +0 -38
@@ -584,44 +584,6 @@ void board_init_r (gd_t *id, ulong dest_addr)* where had to use getenv_r(), which can be pretty slow when * the environment is in EEPROM. */ - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#ifdef CONFIG_HAS_ETH1 -/* handle the 2nd ethernet address */ - - s =getenv ("eth1addr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enet1addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif -#ifdef CONFIG_HAS_ETH2 -/* handle the 3rd ethernet address */ - - s =getenv ("eth2addr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enet2addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -#ifdef CONFIG_HAS_ETH3 -/* handle 4th ethernet address */ - s =getenv ("eth3addr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enet3addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -/* IP Address */ bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );WATCHDOG_RESET ();
lib_microblaze/board.c +0 -8
@@ -173,14 +173,6 @@ void board_init (void)#endif #if defined(CONFIG_CMD_NET ) -/* board MAC address */ - s =getenv ("ethaddr" ); -printf ("MAC:%s\n" ,s); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - }/* IP Address */ bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );eth_init (bd);
lib_mips/board.c +0 -8
@@ -401,14 +401,6 @@ void board_init_r (gd_t *id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -/* board MAC address */ - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -/* IP Address */ bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );
lib_nios/board.c +0 -5
@@ -151,11 +151,6 @@ void board_init (void)env_relocate (); bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) s = (*e) ? e +1 : e; - }WATCHDOG_RESET ();devices_init ();
lib_nios2/board.c +0 -5
@@ -157,11 +157,6 @@ void board_init (void)env_relocate (); bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) s = (*e) ? e +1 : e; - }WATCHDOG_RESET ();devices_init ();
lib_sh/board.c +0 -10
@@ -125,17 +125,7 @@ static int sh_mem_env_init(void)static int sh_net_init (void ) {DECLARE_GLOBAL_DATA_PTR ; -char *s, *e; -int i; - gd->bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - gd->bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -return 0 ; }#endif
lib_sparc/board.c +0 -19
@@ -390,25 +390,6 @@ void board_init_f(ulong bootflag)board_late_init ();#endif - s =getenv ("ethaddr" ); -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } - -#ifdef CONFIG_HAS_ETH1 -/* handle the 2nd ethernet address */ - - s =getenv ("eth1addr" ); - -for (i =0 ; i <6 ; ++i) { - bd->bi_enet1addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif -#ifdef CONFIG_ID_EEPROM mac_read_from_eeprom ();#endif
Signature · 1 line
1.6.1.3
PATCH 19/27 nx823: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
For the nx823, the serial number is moved out of load_sernum_ethaddr() and into misc_init_r() as is the env setup. This lets us kill off the former function in the process.
--- board/nx823/flash.c | 5 +++-- board/nx823/nx823.c | 41 ++++++++++++++++------------------------- lib_ppc/board.c | 4 ---- 3 files changed, 19 insertions(+), 31 deletions(-)
board/nx823/flash.c +3 -2
@@ -27,8 +27,9 @@#include <common.h> #include <mpc8xx.h> +DECLARE_GLOBAL_DATA_PTR ; +flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS ];/* info for FLASH chips */ -extern u_long *my_sernum;/* from nx823.c */ /*----------------------------------------------------------------------- * Protection Flags:
@@ -346,7 +347,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)if (addr >=CONFIG_SYS_FLASH_SN_SECTOR && addr <CONFIG_SYS_FLASH_SN_BASE ) {u_long dest =CONFIG_SYS_FLASH_SN_BASE ; -u_short *sn = (u_short *)my_sernum; +u_short *sn = (u_short *)gd->bd->bi_sernum;printf ("(saving sernum)" );for (i=0 ; i<4 ; i++)
board/nx823/nx823.c +16 -25
55 lines not on this page · raw message
lib_ppc/board.c +0 -4
@@ -900,10 +900,6 @@ void board_init_r (gd_t *id, ulong dest_addr) bd->bi_ethspeed =0xFFFF ;#endif -#ifdef CONFIG_NX823 -load_sernum_ethaddr (); -#endif -#ifdef CONFIG_HAS_ETH1 /* handle the 2nd ethernet address */
Signature · 1 line
1.6.1.3
PATCH 20/27 arm: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Some warts are remaining and should be killed off (by moving the func to the appropriate board init code):
- davinci_eth_set_mac_addr
- cs8900_get_enetaddr
- smc_set_mac_addr
--- lib_arm/board.c | 43 +++++++++++-------------------------------- 1 files changed, 11 insertions(+), 32 deletions(-)
lib_arm/board.c +11 -32
@@ -73,7 +73,7 @@ const char version_string[] =U_BOOT_VERSION " (" U_BOOT_DATE " - " U_BOOT_TIME ")" CONFIG_IDENT_STRING ;#ifdef CONFIG_DRIVER_CS8900 -extern void cs8900_get_enetaddr (uchar * addr); +extern void cs8900_get_enetaddr (void );#endif #ifdef CONFIG_DRIVER_RTL8019
@@ -380,34 +380,6 @@ void start_armboot (void)/* IP Address */ gd->bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -/* MAC Address */ - { -int i; -ulong reg; -char *s, *e; -char tmp[64 ]; - - i =getenv_r ("ethaddr" , tmp,sizeof (tmp)); - s = (i >0 ) ? tmp :NULL ; - -for (reg =0 ; reg <6 ; ++reg) { - gd->bd->bi_enetaddr[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } - -#ifdef CONFIG_HAS_ETH1 - i =getenv_r ("eth1addr" , tmp,sizeof (tmp)); - s = (i >0 ) ? tmp :NULL ; - -for (reg =0 ; reg <6 ; ++reg) { - gd->bd->bi_enet1addr[reg] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - } -devices_init ();/* get the devices list going. */ #ifdef CONFIG_CMC_PU2
@@ -428,19 +400,26 @@ void start_armboot (void)/* Perform network card initialisation if necessary */ #ifdef CONFIG_DRIVER_TI_EMAC +/* XXX: this needs to be moved to board init */ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);if (getenv ("ethaddr" )) { -davinci_eth_set_mac_addr (gd->bd->bi_enetaddr); +uchar enetaddr[6 ]; +eth_getenv_enetaddr ("ethaddr" , enetaddr); +davinci_eth_set_mac_addr (enetaddr); }#endif #ifdef CONFIG_DRIVER_CS8900 -cs8900_get_enetaddr (gd->bd->bi_enetaddr); +/* XXX: this needs to be moved to board init */ +cs8900_get_enetaddr ();#endif #if defined(CONFIG_DRIVER_SMC91111 ) || defined (CONFIG_DRIVER_LAN91C96 ) +/* XXX: this needs to be moved to board init */ if (getenv ("ethaddr" )) { -smc_set_mac_addr (gd->bd->bi_enetaddr); +uchar enetaddr[6 ]; +eth_getenv_enetaddr ("ethaddr" , enetaddr); +smc_set_mac_addr (enetaddr); }#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
Signature · 1 line
1.6.1.3
PATCH 21/27 cmc_pu2: get mac address from environment
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Also rename load_sernum_ethaddr() to misc_init_r() so we don't need to handle this board specially in common ARM code.
--- board/cmc_pu2/load_sernum_ethaddr.c | 18 +++--------------- include/configs/cmc_pu2.h | 1 + lib_arm/board.c | 4 ---- 3 files changed, 4 insertions(+), 19 deletions(-)
board/cmc_pu2/load_sernum_ethaddr.c +3 -15
@@ -66,14 +66,13 @@ int i2c_read (unsigned char chip, unsigned int addr, int alen,* Internal structure: see struct definition */ -void load_sernum_ethaddr (void ) +void misc_init_r (void ) {struct manufacturer_data data; -char ethaddr[18 ];char serial [9 ];unsigned short chksum;unsigned char *p; -unsigned short i, is, id; +unsigned short i;#if !defined(CONFIG_HARD_I2C ) && !defined(CONFIG_SOFT_I2C )#error you must define some I2C support (CONFIG_HARD_I2C or CONFIG_SOFT_I2C)
@@ -97,17 +96,6 @@ void load_sernum_ethaddr (void)return ; } -/* copy MAC address */ - is =0 ; - id =0 ; -for (i =0 ; i <6 ; i++) { -sprintf (ðaddr[id],"%02x" , data.macadr[is++]); - id +=2 ; -if (is <6 ) - ethaddr[id++] =':' ; - } - ethaddr[id] ='\0' ;/* just to be sure */ -/* copy serial number */ sprintf (serial,"%d" , data.serial_number);
@@ -117,6 +105,6 @@ void load_sernum_ethaddr (void) }if (getenv ("ethaddr" ) ==NULL ) { -setenv ("ethaddr" , ethaddr); +eth_setenv_enetaddr ("ethaddr" , data.macadr); } }
include/configs/cmc_pu2.h +1 -0
@@ -143,6 +143,7 @@#endif +#define CONFIG_MISC_INIT_R #define CONFIG_SYS_LONGHELP #define AT91_SMART_MEDIA_ALE (1 << 22)/* our ALE is AD22 */
lib_arm/board.c +0 -4
@@ -382,10 +382,6 @@ void start_armboot (void)devices_init ();/* get the devices list going. */ -#ifdef CONFIG_CMC_PU2 -load_sernum_ethaddr (); -#endif /* CONFIG_CMC_PU2 */ -jumptable_init ();console_init_r ();/* fully init console as a device */
Signature · 1 line
1.6.1.3
PATCH 21/27 cmc_pu2: get mac address from environment
Dear Mike Frysinger,
Quoted 6 lines · In message <[email protected]> you wrote:
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Also rename
load_sernum_ethaddr()tomisc_init_r()so we don't need to handle this board specially in common ARM code.
...
lib_arm/board.c void start_armboot (void) · line 388
Quoted 4 lines
lib_arm/board.c +0
-4-#ifdef CONFIG_CMC_PU2 -load_sernum_ethaddr (); -#endif /* CONFIG_CMC_PU2 */ -
If we bisect here, we have broken boards because load_sernum_ethaddr() is no longer called but the new init code is not installed yet.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de This is an unauthorized cybernetic announcement.
PATCH 21/27 cmc_pu2: get mac address from environment
Quoted 10 lines · On Monday 16 February 2009 17:56:17 Wolfgang Denk wrote:
Quoted 6 lines · In message Mike Frysinger
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Also rename
load_sernum_ethaddr()tomisc_init_r()so we don't need to handle this board specially in common ARM code....
Quoted 7 lines
lib_arm/board.c void start_armboot (void) · line 388
Quoted 4 lines
lib_arm/board.c +0
-4-#ifdef CONFIG_CMC_PU2 -load_sernum_ethaddr (); -#endif /* CONFIG_CMC_PU2 */ -If we bisect here, we have broken boards because
load_sernum_ethaddr()is no longer called but the new init code is not installed yet.
umm, are you sure ? the arm port is nicer than the ppc port because there is only one board that uses load_sernum_ethaddr(). so in 1 change, i dropped the call to load_sernum_ethaddr() and had the board move to misc_init_r(). i see no breakage in this change.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/174fa655/attachment.pgp
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Move all the work of load_sernum_ethaddr() into a local load_ethaddr() func and call that from misc_init_r(). We leave load_sernum_ethaddr() as a stub so that it can be removed from all places in a later commit.
--- board/pcs440ep/pcs440ep.c | 35 ++++++++++++++++++----------------- 1 files changed, 18 insertions(+), 17 deletions(-)
board/pcs440ep/pcs440ep.c +18 -17
@@ -182,14 +182,21 @@ int board_early_init_f(void) }#define EEPROM_LEN 256 -void load_sernum_ethaddr (void ) +static void load_ethaddr (void ) { +int ok_ethaddr, ok_eth1addr;int ret;char buf[EEPROM_LEN ];char mac[32 ];char *use_eeprom;u16 checksumcrc16 =0 ; +/* If the env is sane, then nothing for us to do */ + ok_ethaddr =eth_getenv_enetaddr ("ethaddr" , buf); + ok_eth1addr =eth_getenv_enetaddr ("eth1addr" , buf); +if (ok_ethaddr && ok_eth1addr) +return ; +/* read the MACs from EEprom */ status_led_set (0 ,STATUS_LED_ON );status_led_set (1 ,STATUS_LED_ON );
@@ -207,22 +214,10 @@ void load_sernum_ethaddr (void)printf ("%s: EEPROM Checksum not OK\n" , __FUNCTION__); }else {/* get the MACs */ -sprintf (mac,"%02x:%02x:%02x:%02x:%02x:%02x" , - buf[3 ], - buf[4 ], - buf[5 ], - buf[6 ], - buf[7 ], - buf[8 ]); -setenv ("ethaddr" , (char *) mac); -sprintf (mac,"%02x:%02x:%02x:%02x:%02x:%02x" , - buf[9 ], - buf[10 ], - buf[11 ], - buf[12 ], - buf[13 ], - buf[14 ]); -setenv ("eth1addr" , (char *) mac); +if (!ok_ethaddr) +eth_setenv_enetaddr ("ethaddr" , &buf[3 ]); +if (!ok_eth1addr) +eth_setenv_enetaddr ("eth1addr" , &buf[9 ]);return ; } }
@@ -249,6 +244,10 @@ void load_sernum_ethaddr (void)return ; } +void load_sernum_ethaddr (void ) +{ +} +#ifdef CONFIG_PREBOOT static uchar kbd_magic_prefix[] ="key_magic" ;
@@ -446,6 +445,8 @@ int misc_init_r (void)uint pbcr;int size_val =0 ; +load_ethaddr (); +/* Re-do sizing to get full correct info */ mtdcr (ebccfga, pb0cr); pbcr =mfdcr (ebccfgd);
Signature · 1 line
1.6.1.3
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike Frysinger,
Quoted 11 lines · In message <[email protected]> you wrote:
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Move all the work of
load_sernum_ethaddr()into a localload_ethaddr()func and call that frommisc_init_r(). We leaveload_sernum_ethaddr()as a stub so that it can be removed from all places in a later commit.Signed-off-by Mike Frysinger <[email protected]>CC Stefan Roese <[email protected]>CC Ben Warren <[email protected]>
...
board/pcs440ep/pcs440ep.c void load_sernum_ethaddr (void) · line 250
Quoted 4 lines
board/pcs440ep/pcs440ep.c +4
-0+void load_sernum_ethaddr (void ) +{ +} +
See previous comments - please do not add dead code just to remove it later.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I think it's a new feature. Don't tell anyone it was an accident. :-) -- Larry Wall on s/foo/bar/eieio in <[email protected]>
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 15 lines · On Monday 16 February 2009 17:57:22 Wolfgang Denk wrote:
Quoted 11 lines · In message Mike Frysinger
The environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Move all the work of
load_sernum_ethaddr()into a localload_ethaddr()func and call that frommisc_init_r(). We leaveload_sernum_ethaddr()as a stub so that it can be removed from all places in a later commit.Signed-off-by Mike Frysinger <[email protected]>CC Stefan Roese <[email protected]>CC Ben Warren <[email protected]>...
Quoted 7 lines
board/pcs440ep/pcs440ep.c void load_sernum_ethaddr (void) · line 250
Quoted 4 lines
board/pcs440ep/pcs440ep.c +4
-0+void load_sernum_ethaddr (void ) +{ +} +See previous comments - please do not add dead code just to remove it later.
your previous comment doesnt apply to these later ones. the first change is for arm-only. the later changes are for ppc. it isnt dead code because the function is still called by common ppc code. just like i outlined in the summary for this patchset.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/5321d2a4/attachment.pgp
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike,
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
board/pcs440ep/pcs440ep.c void load_sernum_ethaddr (void) · line 250
Quoted 5 lines
board/pcs440ep/pcs440ep.c +4
-0+void load_sernum_ethaddr (void ) +{ +} +See previous comments - please do not add dead code just to remove it later.
Quoted 4 lines
your previous comment doesnt apply to these later ones. the first change is for arm-only. the later changes are for ppc. it isnt dead code because the function is still called by common ppc code. just like i outlined in the summary for this patchset.
Well, there is a very small number of boards. Why cannot we have this change in one step, in one commit? Adding empty functions just to remove them later seems sub-optimal to me.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race has one really effective weapon, and that is laughter.
- Mark TwainPATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 9 lines · On Monday 16 February 2009 19:16:13 Wolfgang Denk wrote:
Quoted 8 lines · In message Mike
Quoted 7 lines
board/pcs440ep/pcs440ep.c void load_sernum_ethaddr (void) · line 250
Quoted 4 lines
board/pcs440ep/pcs440ep.c +4
-0+void load_sernum_ethaddr (void ) +{ +} +See previous comments - please do not add dead code just to remove it later.
Quoted 8 lines
Quoted 4 lines
your previous comment doesnt apply to these later ones. the first change is for arm-only. the later changes are for ppc. it isnt dead code because the function is still called by common ppc code. just like i outlined in the summary for this patchset.
Well, there is a very small number of boards. Why cannot we have this change in one step, in one commit? Adding empty functions just to remove them later seems sub-optimal to me.
in my mind, what i did is more logical. i'll do whatever way you want though. so just explicitly state "squash those changes into one even though they touch a bunch of different places" and i'll happily do it.
-mike
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike Frysinger,
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Well, there is a very small number of boards. Why cannot we have this change in one step, in one commit? Adding empty functions just to remove them later seems sub-optimal to me.
in my mind, what i did is more logical. i'll do whatever way you want though. so just explicitly state "squash those changes into one even though they touch a bunch of different places" and i'll happily do it.
Hm... maybe somebody else comments?
Stefan, Ben?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Sometimes a feeling is all we humans have to go on. -- Kirk, "A Taste of Armageddon", stardate 3193.9
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 11 lines · Wolfgang Denk
Quoted 7 lines
Quoted 3 lines
Well, there is a very small number of boards. Why cannot we have this change in one step, in one commit? Adding empty functions just to remove them later seems sub-optimal to me.
in my mind, what i did is more logical. i'll do whatever way you want though. so just explicitly state "squash those changes into one even though they touch a bunch of different places" and i'll happily do it.
Hm... maybe somebody else comments?
Stefan, Ben?
Personally I would prefer this "squashed" patch version as well. If possible in a "git-bisectable" version.
Thanks for all your effort here. Really appreciated.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 9 lines · On Tuesday 17 February 2009 08:42:01 Stefan Roese wrote:
Quoted 8 lines · Wolfgang Denk
Quoted 7 lines
Quoted 3 lines
Well, there is a very small number of boards. Why cannot we have this change in one step, in one commit? Adding empty functions just to remove them later seems sub-optimal to me.
in my mind, what i did is more logical. i'll do whatever way you want though. so just explicitly state "squash those changes into one even though they touch a bunch of different places" and i'll happily do it.
Quoted 6 lines
Quoted 3 lines
Hm... maybe somebody else comments?
Stefan, Ben?
Personally I would prefer this "squashed" patch version as well. If possible in a "git-bisectable" version.
it would be bisectable because then there would be only one change:
- every board would move load_sernum_ethaddr() to board init (as well as any
side effects that the change requires)
- the common ppc code would stop calling load_sernum_ethaddr()
i think this is the only outstanding issue for the patchset before Ben merges it into whatever testing tree he has ...
-mike
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike, dear Ben,
Quoted 3 lines · in message <[email protected]> you wrote:
i think this is the only outstanding issue for the patchset before Ben merges it into whatever testing tree he has ...
I agree that this is the last issue at the moment.
This is a pretty big change that affects much more than networking code (even though the cause of the changes is network support related). So I tend to pull this into mainline quickly.
Ben:
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Mike, I guess this is OK with you, too?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de In general, if you think something isn't in Perl, try it out, because it usually is :-) - Larry Wall in <[email protected]>
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 14 lines · Wolfgang Denk
Dear Mike, dear Ben,
Quoted 3 lines · in message <[email protected]> you wrote:
i think this is the only outstanding issue for the patchset before Ben merges it into whatever testing tree he has ...
I agree that this is the last issue at the moment.
This is a pretty big change that affects much more than networking code (even though the cause of the changes is network support related). So I tend to pull this into mainline quickly.
Quoted 7 lines
Ben:
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Yes, this is good. Your 'next' will get much more exposure than mine.
Quoted 7 lines
Mike, I guess this is OK with you, too?
Best regards,
Wolfgang Denk
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
In reply to Wolfgang DenkQuoted 5 lines · On Wednesday 18 February 2009 17:36:04 Wolfgang Denk wrote:
Quoted 2 lines · in message Mike
i think this is the only outstanding issue for the patchset before Ben merges it into whatever testing tree he has ...
I agree that this is the last issue at the moment.
btw, i'm waiting for an explicit "go squash them" from you ;)
Quoted 11 lines
This is a pretty big change that affects much more than networking code (even though the cause of the changes is network support related). So I tend to pull this into mainline quickly.
Ben:
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Mike, I guess this is OK with you, too?
yeah, that's fine with me
-mike
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike Frysinger,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines
I agree that this is the last issue at the moment.
btw, i'm waiting for an explicit "go squash them" from you ;)
I see: go squash them, please!
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Let the programmers be many and the managers few -- then all will be productive. -- Geoffrey James, "The Tao of Programming"
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 6 lines
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Mike, I guess this is OK with you, too?
yeah, that's fine with me
"next" branch is ready and waiting :-)
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de We're all sorry for the other guy when he loses his job to a machine. But when it comes to your job -- that's different. And it always will be different. -- McCoy, "The Ultimate Computer", stardate 4729.4
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 10 lines · On Wednesday 18 February 2009 19:06:04 Wolfgang Denk wrote:
Quoted 7 lines · In message Mike Frysinger
Quoted 5 lines
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Mike, I guess this is OK with you, too?
yeah, that's fine with me
"next" branch is ready and waiting :-)
ive pushed up to my macaddr branch. the changes are:
- rebased against latest master mainline master
- expanded vprintf() changelog a bit
- squashed the ppc load_sernum_ethaddr() changes into 1 commit
- fixed the return value in eth_getenv_enetaddr()
- fixed bugs in the net cdp code pointed out in 2nd patch series
-mike
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Dear Mike Frysinger,
Quoted 7 lines · In message <[email protected]> you wrote:
ive pushed up to my macaddr branch. the changes are:
- rebased against latest master mainline master
- expandedvprintf()changelog a bit
- squashed the ppcload_sernum_ethaddr()changes into 1 commit
- fixed the return value ineth_getenv_enetaddr()
- fixed bugs in the net cdp code pointed out in 2nd patch series
Thanks. Unfortunately the first patch in the series (the printf extension) breaks some board - I just did a small test and got this:
Configuring for TQM860L board... /home/wd/git/u-boot/next/board/tqc/tqm8xx/u-boot.lds:145 cannot move location counter backwards (from 40008088 to 40008000)
make: *** [u-boot] Error 1
ppc_8xx-size: './u-boot': No such file
Mike - do you want to fix the loader script, or do you want the board maintainer to do that (i. e. me) ?
I think we should do these changes BEFORE appplying your patch series (to avoid bisect issues), what do you think?
Note (especially to Jean-Christophe who asked):
I measured the size impact of the printf changes; a short scan on seven PowerPC boards showed an average size increase of 1.6 kB:
Board Diff old new
TQM8260 1168 : 189520 190688
TQM5200 1152 : 690468 691620
ads5121 1168 : 264816 265984
ocotea 1256 : 313444 314700
sequoia 1256 : 703404 704660
MPC8572DS 1236 : 487457 488693
MPC8641HPCN 4064 : 463916 467980
AVRG: 1614
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de 1st Old Man: Gee, its windy today. 2nd Old Man: No it's not... it's Thursday. 3rd Old Man: Yeh, me too. Let's go for a beer.
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
Quoted 14 lines
Note (especially to Jean-Christophe who asked):
I measured the size impact of the printf changes; a short scan on seven PowerPC boards showed an average size increase of 1.6 kB:
Board Diff old new
TQM8260 1168 : 189520 190688
TQM5200 1152 : 690468 691620
ads5121 1168 : 264816 265984
ocotea 1256 : 313444 314700
sequoia 1256 : 703404 704660
MPC8572DS 1236 : 487457 488693
MPC8641HPCN 4064 : 463916 467980
Quoted 2 lines
AVRG: 1614
Tks,
IMHO improve the printf is important but may need to plan to clean up or improve other part of U-Boot to allow peolple to reduce its size. Especially the NOR driver that does not allow to enable/disable vendor support as the kernel
Best Regards,
J.
PATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
In reply to Wolfgang DenkDear Mile,
Quoted 11 lines · In message <[email protected]> I wrote:
Thanks. Unfortunately the first patch in the series (the printf extension) breaks some board - I just did a small test and got this:
Configuring for TQM860L board...
/home/wd/git/u-boot/next/board/tqc/tqm8xx/u-boot.lds:145cannot move location counter backwards (from 40008088 to 40008000)
make: *** [u-boot] Error 1
ppc_8xx-size: './u-boot': No such file
Quoted 2 lines
Mike - do you want to fix the loader script, or do you want the board maintainer to do that (i. e. me) ?
Don't bother. Patch following.
Best regards,
Wolfgang Denk
Signature · 8 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The net result is a system that is not only binary compatible with 4.3 BSD, but is even bug for bug compatible in almost all features." - Avadit Tevanian, Jr., "Architecture-Independent Virtual Memory Management for Parallel and Distributed Environments: The Mach Approach"
Wolfgang Denk
AppliedPATCH 22/27 pcs440ep: get mac address from environment and move load_sernum_ethaddr() to board init
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 9 lines · On Wednesday 18 February 2009 19:06:04 Wolfgang Denk wrote:
Quoted 7 lines · In message Mike Frysinger
Quoted 5 lines
if you agree, please just ACK the patches, and I will pull them into the next branch (which I will create as soon as 2009-03-rc1 is out or the new patch series gets posted, whatever comes earlier).
Mike, I guess this is OK with you, too?
yeah, that's fine with me
Quoted 8 lines
Quoted 1 line
"next" branch is ready and waiting :-)
ive pushed up to my macaddr branch. the changes are:
- rebased against latest master mainline master
- expandedvprintf()changelog a bit
- squashed the ppcload_sernum_ethaddr()changes into 1 commit
- fixed the return value ineth_getenv_enetaddr()
- fixed bugs in the net cdp code pointed out in 2nd patch series
Applied to "next" branch. Thanks for all the work, and for your patience.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Randal said it would be tough to do in sed. He didn't say he didn't understand sed. Randal understands sed quite well. Which is why he uses Perl. :-) - Larry Wall in <[email protected]>
PATCH 23/27 kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr()
In reply to Mike FrysingerRename load_sernum_ethaddr() to kup_load_sernum_ethaddr() and have board init code call it rather than the common ppc board code.
--- board/kup/common/load_sernum_ethaddr.c | 6 +++++- board/kup/kup4k/kup4k.c | 3 +++ board/kup/kup4x/kup4x.c | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-)
board/kup/common/load_sernum_ethaddr.c +5 -1
@@ -51,7 +51,7 @@#define ETHADDR_TOKEN "ethaddr="#define LCD_TOKEN "lcd=" -void load_sernum_ethaddr (void ) +void kup_load_sernum_ethaddr (void ) {unsigned char *hwi;char *var;
@@ -92,3 +92,7 @@ void load_sernum_ethaddr (void) } } } + +void load_sernum_ethaddr (void ) +{ +}
board/kup/kup4k/kup4k.c +3 -0
@@ -233,6 +233,8 @@ phys_size_t initdram (int board_type)/* ------------------------------------------------------------------------- */ +extern void kup_load_sernum_ethaddr (void ); +int misc_init_r (void ) {#ifdef CONFIG_STATUS_LED
@@ -250,6 +252,7 @@ int misc_init_r (void) immap->im_ioport.iop_papar &= ~0x80 ; immap->im_ioport.iop_padat |=0x80 ;/* turn it off */ #endif +kup_load_sernum_ethaddr ();setenv ("hw" ,"4k" );poweron_key ();return (0 );
board/kup/kup4x/kup4x.c +3 -1
@@ -292,10 +292,11 @@ static long int dram_size (long int mamr_value, long int *base, }#endif +extern void kup_load_sernum_ethaddr (void ); +int misc_init_r (void ) {volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ; -#ifdef CONFIG_IDE_LED /* Configure PA8 as output port */ immap->im_ioport.iop_padir |=0x80 ;
@@ -306,6 +307,7 @@ int misc_init_r (void)#ifdef KUP4X_USB usb_init_kup4x ();#endif +kup_load_sernum_ethaddr ();setenv ("hw" ,"4x" );poweron_key ();return (0 );
Signature · 1 line
1.6.1.3
PATCH 23/27 kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr()
Dear Mike Frysinger,
Quoted 71 lines · In message <[email protected]> you wrote:
Rename
load_sernum_ethaddr()tokup_load_sernum_ethaddr()and have board init code call it rather than the common ppc board code.Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- board/kup/common/load_sernum_ethaddr.c | 6 +++++- board/kup/kup4k/kup4k.c | 3 +++ board/kup/kup4x/kup4x.c | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-)board/kup/common/load_sernum_ethaddr.c +5
-1@@ -51,7 +51,7 @@#define ETHADDR_TOKEN "ethaddr="#define LCD_TOKEN "lcd=" -void load_sernum_ethaddr (void ) +void kup_load_sernum_ethaddr (void ) {unsigned char *hwi;char *var;@@ -92,3 +92,7 @@ void load_sernum_ethaddr (void) } } } + +void load_sernum_ethaddr (void ) +{ +}board/kup/kup4k/kup4k.c +3
-0@@ -233,6 +233,8 @@ phys_size_t initdram (int board_type)/* ------------------------------------------------------------------------- */ +extern void kup_load_sernum_ethaddr (void ); +int misc_init_r (void ) {#ifdef CONFIG_STATUS_LED @@ -250,6 +252,7 @@ int misc_init_r (void) immap->im_ioport.iop_papar &= ~0x80 ; immap->im_ioport.iop_padat |=0x80 ;/* turn it off */ #endif +kup_load_sernum_ethaddr ();setenv ("hw" ,"4k" );poweron_key ();return (0 );board/kup/kup4x/kup4x.c +2
-1@@ -292,10 +292,11 @@ static long int dram_size (long int mamr_value, long int *base, }#endif +extern void kup_load_sernum_ethaddr (void ); +int misc_init_r (void ) {volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ; -#ifdef CONFIG_IDE_LED /* Configure PA8 as output port */ immap->im_ioport.iop_padir |=0x80 ;
board/kup/kup4x/kup4x.c int misc_init_r (void) · line 313
Quoted 7 lines
board/kup/kup4x/kup4x.c +1
-0@@ -306,6 +307,7 @@ int misc_init_r (void)#ifdef KUP4X_USB usb_init_kup4x ();#endif +kup_load_sernum_ethaddr ();setenv ("hw" ,"4x" );poweron_key ();return (0 );
See previous review comments - NAK.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is a biblical analogy I'd like to draw here. Casts are to C++ Programmers what the apple was to Eve. - Scott Douglas Meyers
PATCH 24/27 tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
In reply to Mike FrysingerRename load_sernum_ethaddr() to tqc_load_sernum_ethaddr() and have board init code call it rather than the common ppc board code.
--- board/tqc/tqm8xx/load_sernum_ethaddr.c | 6 +++++- board/tqc/tqm8xx/tqm8xx.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletions(-)
board/tqc/tqm8xx/load_sernum_ethaddr.c +5 -1
@@ -49,7 +49,7 @@* 4) Number of additional MAC addresses */ -void load_sernum_ethaddr (void ) +void tqc_load_sernum_ethaddr (void ) {unsigned char *hwi;unsigned char serial [CONFIG_SYS_HWINFO_SIZE ];
@@ -103,3 +103,7 @@ void load_sernum_ethaddr (void)setenv ((char *)"ethaddr" , (char *)ethaddr); } } + +void load_sernum_ethaddr (void ) +{ +}
board/tqc/tqm8xx/tqm8xx.c +3 -0
@@ -449,11 +449,14 @@ int board_early_init_r (void)#ifdef CONFIG_MISC_INIT_R +extern void tqc_load_sernum_ethaddr (void );int misc_init_r (void ) {volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ;volatile memctl8xx_t *memctl = &immap->im_memctl; +tqc_load_sernum_ethaddr (); +#ifdef CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ int scy, trlx, flash_or_timing, clk_diff;
Signature · 1 line
1.6.1.3
PATCH 24/27 tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
Dear Mike Frysinger,
Quoted 39 lines · In message <[email protected]> you wrote:
Rename
load_sernum_ethaddr()totqc_load_sernum_ethaddr()and have board init code call it rather than the common ppc board code.Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- board/tqc/tqm8xx/load_sernum_ethaddr.c | 6 +++++- board/tqc/tqm8xx/tqm8xx.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletions(-)board/tqc/tqm8xx/load_sernum_ethaddr.c +5
-1@@ -49,7 +49,7 @@* 4) Number of additional MAC addresses */ -void load_sernum_ethaddr (void ) +void tqc_load_sernum_ethaddr (void ) {unsigned char *hwi;unsigned char serial [CONFIG_SYS_HWINFO_SIZE ];@@ -103,3 +103,7 @@ void load_sernum_ethaddr (void)setenv ((char *)"ethaddr" , (char *)ethaddr); } } + +void load_sernum_ethaddr (void ) +{ +}board/tqc/tqm8xx/tqm8xx.c +0
-0@@ -449,11 +449,14 @@ int board_early_init_r (void)#ifdef CONFIG_MISC_INIT_R
board/tqc/tqm8xx/tqm8xx.c int board_early_init_r (void) · line 461
Quoted 10 lines
board/tqc/tqm8xx/tqm8xx.c +3
-0+extern void tqc_load_sernum_ethaddr (void );int misc_init_r (void ) {volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ;volatile memctl8xx_t *memctl = &immap->im_memctl; +tqc_load_sernum_ethaddr (); +#ifdef CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ int scy, trlx, flash_or_timing, clk_diff;
See previous review comments - NAK.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de FORTRAN? The syntactically incorrect statement "DO 10 I = 1.10" will parse and generate code creating a variable, DO10I, as follows: "DO10I = 1.10" If that doesn't terrify you, it should.
PATCH 25/27 ppc: do not initialize bi_enet*addr in global data
In reply to Mike FrysingerThe environment is the canonical storage location of the mac address, so we're killing off the global data location and moving everything to querying the env directly.
Also stop calling load_sernum_ethaddr() since all boards now implement this as a stub.
--- lib_ppc/board.c | 92 ------------------------------------------------------- 1 files changed, 0 insertions(+), 92 deletions(-)
lib_ppc/board.c +0 -92
@@ -879,20 +879,6 @@ void board_init_r (gd_t *id, ulong dest_addr)mac_read_from_eeprom ();#endif - s =getenv ("ethaddr" ); -#if defined (CONFIG_MBX ) || \ - defined (CONFIG_RPXCLASSIC ) || \ - defined(CONFIG_IAD210 ) || \ - defined(CONFIG_V38B ) -if (s ==NULL ) -board_get_enetaddr (bd->bi_enetaddr); - else -#endif -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - }#ifdef CONFIG_HERMES if ((gd->board_type >>16 ) ==2 ) bd->bi_ethspeed = gd->board_type &0xFFFF ;
@@ -900,84 +886,6 @@ void board_init_r (gd_t *id, ulong dest_addr) bd->bi_ethspeed =0xFFFF ;#endif -#ifdef CONFIG_HAS_ETH1 -/* handle the 2nd ethernet address */ - - s =getenv ("eth1addr" ); - -for (i =0 ; i <6 ; ++i) { - bd->bi_enet1addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif -#ifdef CONFIG_HAS_ETH2 -/* handle the 3rd ethernet address */ - - s =getenv ("eth2addr" ); -#if defined(CONFIG_XPEDITE1K ) || defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) -if (s ==NULL ) -board_get_enetaddr (bd->bi_enet2addr); - else -#endif -for (i =0 ; i <6 ; ++i) { - bd->bi_enet2addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -#ifdef CONFIG_HAS_ETH3 -/* handle 4th ethernet address */ - s =getenv ("eth3addr" ); -#if defined(CONFIG_XPEDITE1K ) || defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) -if (s ==NULL ) -board_get_enetaddr (bd->bi_enet3addr); - else -#endif -for (i =0 ; i <6 ; ++i) { - bd->bi_enet3addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -#ifdef CONFIG_HAS_ETH4 -/* handle 5th ethernet address */ - s =getenv ("eth4addr" ); -#if defined(CONFIG_XPEDITE1K ) || defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) -if (s ==NULL ) -board_get_enetaddr (bd->bi_enet4addr); - else -#endif -for (i =0 ; i <6 ; ++i) { - bd->bi_enet4addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -#ifdef CONFIG_HAS_ETH5 -/* handle 6th ethernet address */ - s =getenv ("eth5addr" ); -#if defined(CONFIG_XPEDITE1K ) || defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) -if (s ==NULL ) -board_get_enetaddr (bd->bi_enet5addr); - else -#endif -for (i =0 ; i <6 ; ++i) { - bd->bi_enet5addr[i] = s ?simple_strtoul (s, &e,16 ) :0 ; -if (s) - s = (*e) ? e +1 : e; - } -#endif - -#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260 ) || \ - defined(CONFIG_TQM8272 ) || \ - defined(CONFIG_CCM ) || defined(CONFIG_KUP4K ) || \ - defined(CONFIG_KUP4X ) || defined(CONFIG_PCS440EP ) -load_sernum_ethaddr (); -#endif /* IP Address */ bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );
Signature · 1 line
1.6.1.3
PATCH 26/27 drop now unused load_sernum_ethaddr() function
In reply to Mike Frysinger--- board/kup/common/load_sernum_ethaddr.c | 4 ---- board/m501sk/m501sk.c | 5 ----- board/pcs440ep/pcs440ep.c | 4 ---- board/tqc/tqm8xx/load_sernum_ethaddr.c | 4 ---- include/common.h | 2 -- 5 files changed, 0 insertions(+), 19 deletions(-)
board/kup/common/load_sernum_ethaddr.c +0 -4
@@ -92,7 +92,3 @@ void kup_load_sernum_ethaddr (void) } } } - -void load_sernum_ethaddr (void ) -{ -}
board/m501sk/m501sk.c +0 -5
@@ -105,11 +105,6 @@ uchar m501sk_gpio_clear(M501SK_PIO io)return status; } -void load_sernum_ethaddr (void ) -{ -return ; -} -/* * Miscelaneous platform dependent initialisations */
board/pcs440ep/pcs440ep.c +0 -4
@@ -244,10 +244,6 @@ static void load_ethaddr(void)return ; } -void load_sernum_ethaddr (void ) -{ -} -#ifdef CONFIG_PREBOOT static uchar kbd_magic_prefix[] ="key_magic" ;
board/tqc/tqm8xx/load_sernum_ethaddr.c +0 -4
@@ -103,7 +103,3 @@ void tqc_load_sernum_ethaddr (void)setenv ((char *)"ethaddr" , (char *)ethaddr); } } - -void load_sernum_ethaddr (void ) -{ -}
include/common.h +0 -2
@@ -370,8 +370,6 @@ void display_mem_map(void);void perform_soft_reset (void );#endif -void load_sernum_ethaddr (void ); -/* $(BOARD)/$(BOARD).c */ int board_early_init_f (void );int board_late_init (void );
Signature · 1 line
1.6.1.3
PATCH 26/27 drop now unused load_sernum_ethaddr() function
Quoted 10 lines · Mike Frysinger
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- board/kup/common/load_sernum_ethaddr.c | 4 ---- board/m501sk/m501sk.c | 5 ----- board/pcs440ep/pcs440ep.c | 4 ---- board/tqc/tqm8xx/load_sernum_ethaddr.c | 4 ---- include/common.h | 2 -- 5 files changed, 0 insertions(+), 19 deletions(-)
do not drop from the common nslu2 patch use it
I'll send an update version within the few days
Best Regards,
J.
PATCH 26/27 drop now unused load_sernum_ethaddr() function
Quoted 11 lines · On Saturday 14 February 2009 04:22:44 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 9 lines · Mike Frysinger
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- board/kup/common/load_sernum_ethaddr.c | 4 ---- board/m501sk/m501sk.c | 5 ----- board/pcs440ep/pcs440ep.c | 4 ---- board/tqc/tqm8xx/load_sernum_ethaddr.c | 4 ---- include/common.h | 2 -- 5 files changed, 0 insertions(+), 19 deletions(-)
Quoted 2 lines
do not drop from the common nslu2 patch use it
I'll send an update version within the few days
i dont know what "common nslu2 patch" is. there is no nslu2 code in mainline. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090214/f130a245/attachment.pgp
PATCH 26/27 drop now unused load_sernum_ethaddr() function
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 9 lines · In message <[email protected]> you wrote:
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- board/kup/common/load_sernum_ethaddr.c | 4 ---- board/m501sk/m501sk.c | 5 ----- board/pcs440ep/pcs440ep.c | 4 ---- board/tqc/tqm8xx/load_sernum_ethaddr.c | 4 ---- include/common.h | 2 -- 5 files changed, 0 insertions(+), 19 deletions(-)
See previous review comments - NAK.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de He'd been wrong, there _was_ a light at the end of the tunnel, and it was a flamethrower. - Terry Pratchett, _Mort_
PATCH 27/27 remove bi_enet*addr from global data for all arches
In reply to Mike Frysinger--- include/asm-arm/u-boot.h | 5 ----- include/asm-avr32/u-boot.h | 1 - include/asm-blackfin/u-boot.h | 1 - include/asm-i386/u-boot.h | 1 - include/asm-m68k/u-boot.h | 13 ------------- include/asm-microblaze/u-boot.h | 1 - include/asm-mips/u-boot.h | 1 - include/asm-nios/u-boot.h | 1 - include/asm-nios2/u-boot.h | 1 - include/asm-ppc/u-boot.h | 19 ------------------- include/asm-sh/u-boot.h | 1 - include/asm-sparc/u-boot.h | 12 ------------ 12 files changed, 0 insertions(+), 57 deletions(-)
include/asm-arm/u-boot.h +0 -5
@@ -39,7 +39,6 @@ typedef struct bd_info { int bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ - unsigned char bi_enetaddr[6]; /* Ethernet adress */ struct environment_s *bi_env; ulong bi_arch_number; /* unique id for this board */ ulong bi_boot_params; /* where this board expects params */
@@ -48,10 +47,6 @@ typedef struct bd_info {ulong start;ulong size; } bi_dram[CONFIG_NR_DRAM_BANKS ]; -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif } bd_t;#define bi_env_data bi_env->data
include/asm-avr32/u-boot.h +0 -1
@@ -25,7 +25,6 @@ typedef struct bd_info { unsigned long bi_baudrate; unsigned long bi_ip_addr; - unsigned char bi_enetaddr[6]; unsigned char bi_phy_id[4]; struct environment_s *bi_env; unsigned long bi_board_number;
include/asm-blackfin/u-boot.h +0 -1
@@ -31,7 +31,6 @@ typedef struct bd_info { int bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ - unsigned char bi_enetaddr[6]; /* Ethernet adress */ unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_memstart; /* start of DRAM memory */ phys_size_t bi_memsize; /* size of DRAM memory in bytes */
include/asm-i386/u-boot.h +0 -1
@@ -46,7 +46,6 @@ typedef struct bd_info {unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_bootflags;/* boot / reboot flag (for LynxOS) */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */
include/asm-m68k/u-boot.h +0 -13
@@ -48,7 +48,6 @@ typedef struct bd_info {unsigned long bi_bootflags;/* boot / reboot flag (for LynxOS) */ unsigned long bi_boot_params;/* where this board expects params */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */
@@ -61,18 +60,6 @@ typedef struct bd_info {unsigned long bi_flbfreq;/* Flexbus Freq in MHz */ #endif unsigned long bi_baudrate; /* Console Baudrate */ - -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif } bd_t;#endif /* __ASSEMBLY__ */
include/asm-microblaze/u-boot.h +0 -1
@@ -41,7 +41,6 @@ typedef struct bd_info {unsigned long bi_sramstart;/* start of SRAM memory */ unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned long bi_baudrate;/* Console Baudrate */ } bd_t;
include/asm-mips/u-boot.h +0 -1
@@ -34,7 +34,6 @@ typedef struct bd_info { int bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ - unsigned char bi_enetaddr[6]; /* Ethernet adress */ unsigned long bi_arch_number; /* unique id for this board */ unsigned long bi_boot_params; /* where this board expects params */ unsigned long bi_memstart; /* start of DRAM memory */
include/asm-nios/u-boot.h +0 -1
@@ -41,7 +41,6 @@ typedef struct bd_info {unsigned long bi_sramstart;/* start of SRAM memory */ unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned long bi_baudrate;/* Console Baudrate */ } bd_t;
include/asm-nios2/u-boot.h +0 -1
@@ -40,7 +40,6 @@ typedef struct bd_info {unsigned long bi_sramstart;/* start of SRAM memory */ unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned long bi_baudrate;/* Console Baudrate */ } bd_t;
include/asm-ppc/u-boot.h +0 -19
@@ -64,7 +64,6 @@ typedef struct bd_info {#endif unsigned long bi_bootflags;/* boot / reboot flag (for LynxOS) */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */
@@ -100,24 +99,6 @@ typedef struct bd_info {hymod_conf_t bi_hymod_conf;/* hymod configuration information */ #endif -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH4 -unsigned char bi_enet4addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH5 -unsigned char bi_enet5addr[6 ]; -#endif - #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \ defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
include/asm-sh/u-boot.h +0 -1
@@ -34,7 +34,6 @@ typedef struct bd_info {unsigned long bi_sramstart;/* start of SRAM memory */ unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned long bi_baudrate;/* Console Baudrate */ unsigned long bi_boot_params;/* where this board expects params */ } bd_t;
include/asm-sparc/u-boot.h +0 -12
@@ -52,22 +52,10 @@ typedef struct bd_info {unsigned long bi_sramsize;/* size of SRAM memory */ unsigned long bi_bootflags;/* boot / reboot flag (for LynxOS) */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */ unsigned long bi_baudrate; /* Console Baudrate */ -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif } bd_t;#endif /* __ASSEMBLY__ */
Signature · 1 line
1.6.1.3
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 27 lines · Mike Frysinger
include/asm-ppc/u-boot.h +0
-12@@ -64,7 +64,6 @@ typedef struct bd_info {#endif unsigned long bi_bootflags;/* boot / reboot flag (for LynxOS) */ unsigned long bi_ip_addr;/* IP Address */ -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ unsigned short bi_ethspeed;/* Ethernet speed in Mbps */ unsigned long bi_intfreq;/* Internal Freq, in MHz */ unsigned long bi_busfreq;/* Bus Freq, in MHz */ @@ -100,24 +99,6 @@ typedef struct bd_info {hymod_conf_t bi_hymod_conf;/* hymod configuration information */ #endif -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif
include/asm-ppc/u-boot.h typedef struct bd_info { · line 104
Quoted 10 lines
include/asm-ppc/u-boot.h +0
-7-#ifdef CONFIG_HAS_ETH4 -unsigned char bi_enet4addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH5 -unsigned char bi_enet5addr[6 ]; -#endif - #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \ defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \ defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
This will break compatibility with pre-device-tree kernels.
bd_t is a public interface, albeit a deprecated one.
-Scott
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 27 lines · On Monday 16 February 2009 13:16:38 Scott Wood wrote:
Quoted 13 lines · Mike Frysinger
include/asm-ppc/u-boot.h +0
-8@@ -64,7 +64,6 @@ typedef struct bd_info { -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ];include/asm-ppc/u-boot.h typedef struct bd_info { · line 119
Quoted 10 lines
include/asm-ppc/u-boot.h +0
-10-#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH4 -unsigned char bi_enet4addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH5 -unsigned char bi_enet5addr[6 ]; -#endif This will break compatibility with pre-device-tree kernels.
Quoted 1 line
bd_tis a public interface, albeit a deprecated one.
the fact that the size can change based on board configs makes it already a pretty unreliable ABI ...
at any rate, is there a define that can be keyed off of ? CONFIG_HAS_FDT or some such junk ? then the behavior can be changed to like:
#ifndef CONFIG_HAS_FDT /* ABI compat junk */ uchar bi_padding_was_enetaddr[6];
#endif
-mike
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 7 lines · Mike Frysinger
Quoted 3 lines · On Monday 16 February 2009 13:16:38 Scott Wood wrote:
This will break compatibility with pre-device-tree kernels.
bd_tis a public interface, albeit a deprecated one.the fact that the size can change based on board configs makes it already a pretty unreliable ABI ...
Sure, that's why it's deprecated. :-)
Quoted 6 lines
at any rate, is there a define that can be keyed off of ?
CONFIG_HAS_FDTor some such junk ? then the behavior can be changed to like:#ifndef CONFIG_HAS_FDT /* ABI compat junk */ uchar bi_padding_was_enetaddr[6];#endif
Why not just leave the bd_t alone, until such a time as we can get rid of it altogether?
Note that just because we support booting with device trees doesn't mean we don't also support booting legacy kernels.
-Scott
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 8 lines · On Monday 16 February 2009 14:00:59 Scott Wood wrote:
Quoted 6 lines · Mike Frysinger
at any rate, is there a define that can be keyed off of ?
CONFIG_HAS_FDTor some such junk ? then the behavior can be changed to like:#ifndef CONFIG_HAS_FDT /* ABI compat junk */ uchar bi_padding_was_enetaddr[6];#endif
Quoted 5 lines
Why not just leave the
bd_talone, until such a time as we can get rid of it altogether?Note that just because we support booting with device trees doesn't mean we don't also support booting legacy kernels.
the name has to go. u-boot no longer uses that field and leaving it in will simply lead to code misusing it creeping it back into the tree. whether you choose to force the warts on everyone is up to you ... i'm not a ppc consumer so i could care less.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/ffcbb7a6/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
Dear Mike,
Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 11 lines
Quoted 7 lines
at any rate, is there a define that can be keyed off of ?
CONFIG_HAS_FDTor some such junk ? then the behavior can be changed to like:#ifndef CONFIG_HAS_FDT /* ABI compat junk */ uchar bi_padding_was_enetaddr[6];#endif
Why not just leave the
bd_talone, until such a time as we can get rid of it altogether?
Quoted 7 lines
Quoted 2 lines
Note that just because we support booting with device trees doesn't mean we don't also support booting legacy kernels.
the name has to go. u-boot no longer uses that field and leaving it in will simply lead to code misusing it creeping it back into the tree. whether you choose to force the warts on everyone is up to you ... i'm not a ppc consumer so i could care less.
You are not permitted to change this interface. It must remain stable. There are systems out there running really old kernel versions, and every now and then they may even need to update U-Boot to adapt it for recent hardware changes, while they cannot change the kernel. It is mandatory that even old 2.4 kernel versions must be bootable with recent versions of U-Boot.
As mentioned before, bd_info is a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Research is what I'm doing when I don't know what I'm doing.
-- Wernher von BraunPATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 26 lines · On Monday 16 February 2009 14:47:52 Wolfgang Denk wrote:
Quoted 10 lines · In message <[email protected]> you wrote:
Quoted 10 lines
Quoted 6 lines
at any rate, is there a define that can be keyed off of ?
CONFIG_HAS_FDTor some such junk ? then the behavior can be changed to like: #ifndefCONFIG_HAS_FDT/* ABI compat junk */ uchar bi_padding_was_enetaddr[6];#endif
Why not just leave the
bd_talone, until such a time as we can get rid of it altogether?Quoted 7 lines
Quoted 2 lines
Note that just because we support booting with device trees doesn't mean we don't also support booting legacy kernels.
the name has to go. u-boot no longer uses that field and leaving it in will simply lead to code misusing it creeping it back into the tree. whether you choose to force the warts on everyone is up to you ... i'm not a ppc consumer so i could care less.
You are not permitted to change this interface. It must remain stable. There are systems out there running really old kernel versions, and every now and then they may even need to update U-Boot to adapt it for recent hardware changes, while they cannot change the kernel. It is mandatory that even old 2.4 kernel versions must be bootable with recent versions of U-Boot.
Quoted 2 lines
As mentioned before,
bd_infois a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.
i'm not talking about changing the binary aspect of it. i'm talking about changing the API. two completely different things.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/4e7e55cb/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
Dear Mike Frysinger,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 3 lines
As mentioned before,
bd_infois a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.i'm not talking about changing the binary aspect of it. i'm talking about changing the API. two completely different things.
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the bd_info structure.
Such a modification is not permitted, the bd_info structure must be kept constant and unchanged *and* the respective fields must be correctly initialized before booting the Linux kernel.
This is mandatory.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Even if you aren't in doubt, consider the mental welfare of the per- son who has to maintain the code after you, and who will probably put parens in the wrong place. - Larry Wall in the perl man page
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 10 lines · On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
Quoted 5 lines · In message Mike Frysinger
Quoted 2 lines
As mentioned before,
bd_infois a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.i'm not talking about changing the binary aspect of it. i'm talking about changing the API. two completely different things.
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the
bd_infostructure.
the discussion has moved on. the original patch removed the fields, but in the follow ups it was proposed simply renaming them. please review the context of each reply.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/215c8324/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 6 lines · Mike Frysinger
Quoted 5 lines · On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
Quoted 4 lines · In message Mike Frysinger
Quoted 2 lines
As mentioned before,
bd_infois a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.i'm not talking about changing the binary aspect of it. i'm talking about changing the API. two completely different things.
Quoted 7 lines
Quoted 3 lines
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the
bd_infostructure.the discussion has moved on. the original patch removed the fields, but in the follow ups it was proposed simply renaming them. please review the context of each reply.
What do we gain from renaming them? We still need to fill in the MAC addresses for compatibility. If you want to discourage new internal users, use a comment (preferably a giant do-not-touch sign over the entire bd_t).
-Scott
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 13 lines · On Monday 16 February 2009 15:54:06 Scott Wood wrote:
Quoted 12 lines · Mike Frysinger
Quoted 10 lines · On Monday 16 February 2009 15:14:32 Wolfgang Denk wrote:
Quoted 5 lines · In message Mike Frysinger
Quoted 2 lines
As mentioned before,
bd_infois a binary interfwace between U-Boot and the Linux kernel, and it must not be changed.i'm not talking about changing the binary aspect of it. i'm talking about changing the API. two completely different things.
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the
bd_infostructure.
Quoted 8 lines
Quoted 3 lines
the discussion has moved on. the original patch removed the fields, but in the follow ups it was proposed simply renaming them. please review the context of each reply.
What do we gain from renaming them? We still need to fill in the MAC addresses for compatibility. If you want to discourage new internal users, use a comment (preferably a giant do-not-touch sign over the entire
bd_t).
people dont read comments. that method of deprecation is pure wishful thinking. people forward porting old code (boards/drivers/whatever) or even writing new code will build it up and if it seems to work, submit it. and no amount of review is 100% all the time. if, instead, they got a build error straight up front, they'd sure as hell figure out why and get it fixed. this is where a comment in the struct that says "this is legacy, do not touch, go read README.macaddr" would actually be read and be useful.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/a9c48be3/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the
bd_infostructure.the discussion has moved on. the original patch removed the fields, but in the follow ups it was proposed simply renaming them. please review the context of each reply.
You just mentioned in one message a (IMHO silly) name bi_padding_was_enetaddr[] which did not look to me as if you intended to keep the funtionality.
And even renaming is BAD as it breaks compatibility with the Linux kernel. It's bad enough that we have a binary data structure as a critical interface, but suing different variable names for the same fields would make it definitely worse.
Please leave that structure untouched.
This is my final statement on this issue.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The biggest difference between time and space is that you can't reuse time. - Merrick Furst
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 5 lines · On Monday 16 February 2009 16:03:36 Wolfgang Denk wrote:
Quoted 4 lines · In message Mike Frysinger
Quoted 3 lines
Then I don't understand what you are talking about or what your patch is doing. To me it looks as if you were removing the bi_enetaddr[] resp. bi_enet?addr[] from the
bd_infostructure.
Quoted 7 lines
Quoted 3 lines
the discussion has moved on. the original patch removed the fields, but in the follow ups it was proposed simply renaming them. please review the context of each reply.
You just mentioned in one message a (IMHO silly) name bi_padding_was_enetaddr[] which did not look to me as if you intended to keep the funtionality.
padding/deprecated/whatever. it's the same thing: it becomes internal/legacy only and no new code touches it.
Quoted 4 lines
And even renaming is BAD as it breaks compatibility with the Linux kernel. It's bad enough that we have a binary data structure as a critical interface, but suing different variable names for the same fields would make it definitely worse.
that doesnt make any sense at all. the kernel isnt passed the structure as seen in the C language, it gets passed a binary blob. how the kernel chooses to interpret it is up to the kernel.
Quoted 3 lines
Please leave that structure untouched.
This is my final statement on this issue.
you'd think the maintainer would be more open to talking about issues instead of closing their mind and ignoring improvements
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/dcdad27c/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
Dear Mike Frysinger,
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 5 lines
And even renaming is BAD as it breaks compatibility with the Linux kernel. It's bad enough that we have a binary data structure as a critical interface, but suing different variable names for the same fields would make it definitely worse.
that doesnt make any sense at all. the kernel isnt passed the structure as seen in the C language, it gets passed a binary blob. how the kernel chooses to interpret it is up to the kernel.
And how do you check for problems? At least initially by comparing the source code. Why making this more difficult than necessary?
Quoted 6 lines
Quoted 3 lines
Please leave that structure untouched.
This is my final statement on this issue.
you'd think the maintainer would be more open to talking about issues instead of closing their mind and ignoring improvements
We have discussed this here for some time now, and I considered the pros and cons and made up my mind. YMMV.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de God is real, unless declared integer.
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 6 lines · On Monday 16 February 2009 18:13:25 Wolfgang Denk wrote:
Quoted 5 lines · In message Mike Frysinger
Quoted 4 lines
And even renaming is BAD as it breaks compatibility with the Linux kernel. It's bad enough that we have a binary data structure as a critical interface, but suing different variable names for the same fields would make it definitely worse.
Quoted 6 lines
Quoted 3 lines
that doesnt make any sense at all. the kernel isnt passed the structure as seen in the C language, it gets passed a binary blob. how the kernel chooses to interpret it is up to the kernel.
And how do you check for problems? At least initially by comparing the source code. Why making this more difficult than necessary?
yes, comparing the linux source and the u-boot source would be marginally more difficult. but as you've highlighted many times, no new code should be using these fields, so the likely hood of people having to do that is pretty low imo. the flip side of what i wrote to Scott is that people are actively porting code from older u-boot versions (how often do we see people saying that using u-boot-<some old version> isnt working) and if the field isnt renamed, things will appear to "just work". so there is no way for them to know that they need to fix their code which means they wont. otherwise, people hitting a build failure will know immediately that they need to update something.
again, generally i could care less because this is ppc code, but considering how many abusers we've had in common network drivers, people testing drivers on ppc will not notice this issue and instead, it'll make every other arch maintainers' life annoying.
perhaps if u-boot looked at importing and extending the check patch script from the kernel, then i would worry a lot less as we could make usage of this field a failure.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090216/d70cf74c/attachment.pgp
PATCH 27/27 remove bi_enet*addr from global data for all arches
Dear Mike Frysinger,
Quoted 4 lines · In message <[email protected]> you wrote:
perhaps if u-boot looked at importing and extending the check patch script from the kernel, then i would worry a lot less as we could make usage of this field a failure.
Well, maybe your words fall on some fertile ground, and some voluteer enters the scene? He would be definitely welcome...
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Computers are not intelligent. They only think they are.
PATCH 27/27 remove bi_enet*addr from global data for all arches
In reply to Mike FrysingerQuoted 4 lines · On Mon, 16 Feb 2009 19:18:19 -0500 Mike Frysinger <[email protected]> wrote:
renamed, things will appear to "just work". so there is no way for them to know that they need to fix their code which means they wont. otherwise, people hitting a build failure will know immediately that they need to update something.
there's also #warning for this type of situation, but I agree with adding glaring comments in the code.
Kim
PATCH 27/27 remove bi_enet*addr from global data for all arches
Quoted 8 lines · On Monday 16 February 2009 20:49:00 Kim Phillips wrote:
Quoted 4 lines · Mike Frysinger
renamed, things will appear to "just work". so there is no way for them to know that they need to fix their code which means they wont. otherwise, people hitting a build failure will know immediately that they need to update something.
there's also #warning for this type of situation, but I agree with adding glaring comments in the code.
#warning's wont help as there's no way to take it onto a member of a struct (unless there's something i'm not aware of), plus the common ppc code explicitly set it all the time and we dont want to have that trigger a warning -mike
PATCH 27/27 remove bi_enet*addr from global data for all arches
In reply to Mike FrysingerDear Mike,
Quoted 27 lines · In message <[email protected]> you wrote:
Quoted 27 lines
Quoted 14 lines
include/asm-ppc/u-boot.h +0
-8@@ -64,7 +64,6 @@ typedef struct bd_info { -unsigned char bi_enetaddr[6 ];/* Ethernet adress */ -#ifdef CONFIG_HAS_ETH1 -/* second onboard ethernet port */ -unsigned char bi_enet1addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH2 -/* third onboard ethernet port */ -unsigned char bi_enet2addr[6 ];include/asm-ppc/u-boot.h typedef struct bd_info { · line 119
Quoted 10 lines
include/asm-ppc/u-boot.h +0
-10-#endif -#ifdef CONFIG_HAS_ETH3 -unsigned char bi_enet3addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH4 -unsigned char bi_enet4addr[6 ]; -#endif -#ifdef CONFIG_HAS_ETH5 -unsigned char bi_enet5addr[6 ]; -#endif This will break compatibility with pre-device-tree kernels.
Quoted 1 line
Quoted 1 line
bd_tis a public interface, albeit a deprecated one.
Crect - and one that must be kept untouched.
Quoted 6 lines
at any rate, is there a define that can be keyed off of ?
CONFIG_HAS_FDTor some such junk ? then the behavior can be changed to like:#ifndef CONFIG_HAS_FDT /* ABI compat junk */ uchar bi_padding_was_enetaddr[6];#endif
No. This interface must be kept as is.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Motto of the Electrical Engineer: Working computer hardware is a lot like an erect penis: it stays up as long as you don't fuck with it.