Skip to contentSkip to conversation

net/eth.c call dev->write_hwaddr in eth_init

PATCH New John Rigby 2 participants 6 messages Sep 7, 2010 – Sep 8, 2010 Networking

lore
Share & tools
lore

John Rigby

author
#0 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

When eth_init updates dev->enetaddr it does not call dev->write_hwaddr. Fix that so when ethaddr is set after eth_initialize the change will propagate to the hw.

---
 net/eth.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
net/eth.c +7 -1
index 993306f..5216c2b 100644
@@ -341,8 +341,14 @@ int eth_init(bd_t *bis)
 	do {
 		uchar env_enetaddr[6];
 
-		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr))
+		if (eth_getenv_enetaddr_by_index(eth_number, env_enetaddr)) {
 			memcpy(dev->enetaddr, env_enetaddr, 6);
+			if (dev->write_hwaddr &&
+				!eth_mac_skip(eth_number) &&
+				is_valid_ether_addr(dev->enetaddr)) {
+				dev->write_hwaddr(dev);
+			}
+		}
 
 		++eth_number;
 		dev = dev->next;
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

Quoted 4 lines · On Tuesday, September 07, 2010 18:50:26 John Rigby wrote:

When eth_init updates dev->enetaddr it does not call dev->write_hwaddr. Fix that so when ethaddr is set after eth_initialize the change will propagate to the hw.

current policy is that the driver init() is supposed to be taking care of this. if you're going to change that, you'll have to update the documentation and actual drivers.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100908/18884116/attachment.pgp

author
#2 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

The case I am personally dealing with is one where there is no persistent storage
for ethaddr. Booting from and SD card and a script is run that sets the ethaddr.

Currently eth_init updates dev->enetaddr for each device but does not call dev-write_hwaddr. This seems like a bug not a policy change.

Quoted 11 lines · Mike Frysinger
Quoted 4 lines · On Tuesday, September 07, 2010 18:50:26 John Rigby wrote:

When eth_init updates dev->enetaddr it does not call dev->write_hwaddr. ?Fix that so when ethaddr is set after eth_initialize the change will propagate to the hw.

current policy is that the driver init() is supposed to be taking care of this. ?if you're going to change that, you'll have to update the documentation and actual drivers.
-mike

#3 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

On Wednesday, September 08, 2010 11:06:54 John Rigby wrote:

please do not top post

Quoted 7 lines

The case I am personally dealing with is one where there is no persistent storage
for ethaddr. Booting from and SD card and a script is run that sets the ethaddr.

Currently eth_init updates dev->enetaddr for each device but does not call dev-write_hwaddr. This seems like a bug not a policy change.

and if you read the doumentation, you'll see that you're mistaken. whatever device you're dealing with (today) is missing a call to its own write_hwaaddr function inside of its own init function.

if you want to fix your immediate issue, then fix that driver as implied by the policy. if you want to improve the policy, then you need to update all the drivers and the common code.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100908/f1e94a46/attachment.pgp

author
#4 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

Quoted 10 lines · Mike Frysinger

and if you read the doumentation, you'll see that you're mistaken. ?whatever device you're dealing with (today) is missing a call to its own write_hwaaddr function inside of its own init function.

if you want to fix your immediate issue, then fix that driver as implied by the policy. ?if you want to improve the policy, then you need to update all the drivers and the common code.
-mike

Apologies, I get it now. I will send a new patch that fixes the driver's init routine.

One more question however, why does eth_initialize call dev->write_hwaddr?

Thanks
John

#5 lore raw

PATCH 1/1 net/eth.c call dev->write_hwaddr in eth_init

Quoted 1 line · On Wednesday, September 08, 2010 13:11:14 John Rigby wrote:

One more question however, why does eth_initialize call dev->write_hwaddr?

as part of the debate "program the MAC without actually using the network" -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100908/814ae97f/attachment.pgp