Commit c88ef3c12dcf8596433d52a2631982d9d3a478dd
Committed by
Joe Hershberger
1 parent
66f119e50c
Exists in
master
and in
54 other branches
net: allow setting env enetaddr from net device setting
If the net driver has setup a valid ethernet address and an ethernet address is not set in the environment already, then set the environment variables from the net driver setting. This enables pxe booting on boards which don't set ethaddr env variable. Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Showing 2 changed files with 19 additions and 1 deletions Side-by-side Diff
doc/README.enetaddr
... | ... | @@ -32,7 +32,11 @@ |
32 | 32 | |
33 | 33 | 1. Read from hardware in initialize() function |
34 | 34 | 2. Read from environment in net/eth.c after initialize() |
35 | -3. Give priority to the value in the environment if a conflict | |
35 | +3. The environment variable will be compared to the driver initialized | |
36 | + struct eth_device->enetaddr. If they differ, a warning is printed, and the | |
37 | + environment variable will be used unchanged. | |
38 | + If the environment variable is not set, it will be initialized from | |
39 | + eth_device->enetaddr, and a warning will be printed. | |
36 | 40 | 4. Program the address into hardware if the following conditions are met: |
37 | 41 | a) The relevant driver has a 'write_addr' function |
38 | 42 | b) The user hasn't set an 'ethmacskip' environment variable |
net/eth.c
... | ... | @@ -62,6 +62,15 @@ |
62 | 62 | return eth_getenv_enetaddr(enetvar, enetaddr); |
63 | 63 | } |
64 | 64 | |
65 | +int eth_setenv_enetaddr_by_index(const char *base_name, int index, | |
66 | + uchar *enetaddr) | |
67 | +{ | |
68 | + char enetvar[32]; | |
69 | + sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); | |
70 | + return eth_setenv_enetaddr(enetvar, enetaddr); | |
71 | +} | |
72 | + | |
73 | + | |
65 | 74 | static int eth_mac_skip(int index) |
66 | 75 | { |
67 | 76 | char enetvar[15]; |
... | ... | @@ -205,6 +214,11 @@ |
205 | 214 | } |
206 | 215 | |
207 | 216 | memcpy(dev->enetaddr, env_enetaddr, 6); |
217 | + } else if (is_valid_ether_addr(dev->enetaddr)) { | |
218 | + eth_setenv_enetaddr_by_index(base_name, eth_number, | |
219 | + dev->enetaddr); | |
220 | + printf("\nWarning: %s using MAC address from net device\n", | |
221 | + dev->name); | |
208 | 222 | } |
209 | 223 | |
210 | 224 | if (dev->write_hwaddr && |