From ecee9324d73555e744593f3e0d387bec4c566f55 Mon Sep 17 00:00:00 2001 From: Ben Warren Date: Mon, 26 Apr 2010 11:11:46 -0700 Subject: Program net device MAC addresses after initializing Add a new function to the eth_device struct for programming a network controller's hardware address. After all network devices have been initialized and the proper MAC address for each has been determined, make a device driver call to program the address into the device. Only device instances with valid unicast addresses will be programmed. Signed-off-by: Ben Warren Acked-by: Detlev Zundel Tested-by: Prafulla Wadaskar Tested-by: Heiko Schocher Tested-by: Thomas Chou --- doc/README.drivers.eth | 7 ++++++- doc/README.enetaddr | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/README.drivers.eth b/doc/README.drivers.eth index d0c3571165..eb83038b5d 100644 --- a/doc/README.drivers.eth +++ b/doc/README.drivers.eth @@ -70,6 +70,7 @@ int ape_register(bd_t *bis, int iobase) dev->halt = ape_halt; dev->send = ape_send; dev->recv = ape_recv; + dev->write_hwaddr = ape_write_hwaddr; eth_register(dev); @@ -102,11 +103,12 @@ not checking its state or doing random probing. ----------- Now that we've registered with the ethernet layer, we can start getting some -real work done. You will need four functions: +real work done. You will need five functions: int ape_init(struct eth_device *dev, bd_t *bis); int ape_send(struct eth_device *dev, volatile void *packet, int length); int ape_recv(struct eth_device *dev); int ape_halt(struct eth_device *dev); + int ape_write_hwaddr(struct eth_device *dev); The init function checks the hardware (probing/identifying) and gets it ready for send/recv operations. You often do things here such as resetting the MAC @@ -150,6 +152,9 @@ The halt function should turn off / disable the hardware and place it back in its reset state. It can be called at any time (before any call to the related init function), so make sure it can handle this sort of thing. +The write_hwaddr function should program the MAC address stored in dev->enetaddr +into the Ethernet controller. + So the call graph at this stage would look something like: some net operation (ping / tftp / whatever...) eth_init() diff --git a/doc/README.enetaddr b/doc/README.enetaddr index 94d800a02a..2d8e24f5cb 100644 --- a/doc/README.enetaddr +++ b/doc/README.enetaddr @@ -33,11 +33,13 @@ Correct flow of setting up the MAC address (summarized): 1. Read from hardware in initialize() function 2. Read from environment in net/eth.c after initialize() 3. Give priority to the value in the environment if a conflict -4. Program hardware in the device's init() function. +4. Program the address into hardware if the following conditions are met: + a) The relevant driver has a 'write_addr' function + b) The user hasn't set an 'ethmacskip' environment variable + c) The address is valid (unicast, not all-zeros) -If somebody wants to subvert the design philosophy, this can be done -in the board-specific board_eth_init() function by calling eth_init() -after all the NICs have been registered. +Previous behavior had the MAC address always being programmed into hardware +in the device's init() function. ------- Usage -- cgit