Skip to contentSkip to conversation

Ethernet MAC address question

DISCUSSION Don Fry 4 participants 6 messages Jun 14, 2004 – Jun 15, 2004

Subsystems (2)
lore
Share & tools
lore

Don Fry

author
#0 lore raw

When and/or why would an ethernet driver not use the MAC address from the PROM associated with the adapter?

Since the MAC address can be specified via "ifconfig ethN ether ...." why not use the PROM value, and override it later if needed?

I have received several complaints that the pcnet32 adapter is using the 'wrong' MAC address. By looking back through older kernels, the pcnet32 code was changed between November 2001 and February 2002 to read the MAC address from PROM, but to use whatever value was read from some volatile chip registers, which early chip versions do not even initialize.

It seems to me the driver should always use the PROM address, assuming it has one. What am I missing?

Signature · 2 lines
Don Fry
[email protected]
#1 lore raw
Quoted 13 lines · Don Fry

When and/or why would an ethernet driver not use the MAC address from the PROM associated with the adapter?

Since the MAC address can be specified via "ifconfig ethN ether ...." why not use the PROM value, and override it later if needed?

I have received several complaints that the pcnet32 adapter is using the 'wrong' MAC address. By looking back through older kernels, the pcnet32 code was changed between November 2001 and February 2002 to read the MAC address from PROM, but to use whatever value was read from some volatile chip registers, which early chip versions do not even initialize.

Quoted 2 lines

It seems to me the driver should always use the PROM address, assuming it has one. What am I missing?

In general, you are correct.

However there are a few cases where some magic platform means loads the MAC address into the (volatile) MAC address registers, and that's the only source of an accurate MAC address for those people.

Jeff

#2 lore raw
Quoted 17 lines · Jeff Garzik
Quoted 13 lines · Don Fry

When and/or why would an ethernet driver not use the MAC address from the PROM associated with the adapter?

Since the MAC address can be specified via "ifconfig ethN ether ...." why not use the PROM value, and override it later if needed?

I have received several complaints that the pcnet32 adapter is using the 'wrong' MAC address. By looking back through older kernels, the pcnet32 code was changed between November 2001 and February 2002 to read the MAC address from PROM, but to use whatever value was read from some volatile chip registers, which early chip versions do not even initialize.

Quoted 2 lines

It seems to me the driver should always use the PROM address, assuming it has one. What am I missing?

Quoted 7 lines

In general, you are correct.

However there are a few cases where some magic platform means loads the MAC address into the (volatile) MAC address registers, and that's the only source of an accurate MAC address for those people.

Jeff

In Prism54's case, since we need to first load a firmware to first obtain the MAC address, there's a time period where the default mac address is set to a
temporary: 00:30:B4:00:00:00. This value was chosen by Jean (from HP). He sent in a patch to do this and added the following comment:

/* Temporary dummy MAC address to use until firmware is loaded.
* The idea there is that some tools (such as nameif) may query
* the MAC address before the netdev is 'open'. By using a valid
* OUI prefix, they can process the netdev properly.
* Of course, this is not the final/real MAC address. It doesn't
* matter, as you are suppose to be able to change it anytime via
* ndev->set_mac_address. Jean II */

The real mac address will be populated currently if you modprobe prism54, the firmware is loaded as a result and then there is a netdev open (ifconfig eth0 up). There after the mac address is saved unless you rmmod the driver.

PS. A bit off topic but I'll soon send in a patch for review about loading the firmware @ device probe Vs only at netdevice open time. This will allow the mac address to always be correctly populated if the firmware is present with the downside that you'll see a kernel message complaining it didn't find the firmware if it was not found (to try to reload the firmware all you would have to do is just try to bring the device up, so this is not an issue for a built-in). I'll also shut the radio off at probe though to not waste precious energy when on battery-powered laptops.

Luis

Signature · 1 line
GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84  A34A 6ADD 4937 E20A 525E
#3 lore raw
In reply to Jeff Garzik
Quoted 3 lines · Jeff Garzik

However there are a few cases where some magic platform means loads the MAC address into the (volatile) MAC address registers, and that's the only source of an accurate MAC address for those people.

This is reasonably common on embedded systems - often there won't be SEPROMs for individual devices and the MAC address will be stored in flash or similar and read by the bootloader.

Signature · 1 line
"You grabbed my hand and we fell into it, like a daydream - or a fever."
author
#4 lore raw

So how does the driver distinguish between a valid, but incorrect MAC address, and the 'correct' MAC address? The incorrect one that is the value that just happened to be in the uninitialized volatile registers, and the correct address which some magic platform means loaded into the same, but this time initialized, volatile registers.

Quoted 8 lines
Quoted 3 lines

However there are a few cases where some magic platform means loads the MAC address into the (volatile) MAC address registers, and that's the only source of an accurate MAC address for those people.

This is reasonably common on embedded systems - often there won't be SEPROMs for individual devices and the MAC address will be stored in flash or similar and read by the bootloader.

Signature · 2 lines
Don Fry
[email protected]
#5 lore raw
Quoted 5 lines · Don Fry

So how does the driver distinguish between a valid, but incorrect MAC address, and the 'correct' MAC address? The incorrect one that is the value that just happened to be in the uninitialized volatile registers, and the correct address which some magic platform means loaded into the same, but this time initialized, volatile registers.

You have to notice that certain platform-specific attributes are present, that tells your code to search in <this magic place> rather than the standard place for MAC address.

For example, some Compaqs have a magic MAC address location (this might even be pcnet32), and one solution proposed was looking for the platform's DMI table identifiers. Another solution -- working -- was to load the MAC address registers when the driver loads, and just hope it is a correct address.

Jeff