mac-address vs. local-mac-address
Hi everyone,
What is the current consensus on using mac-address vs. local-mac-address in the device tree? The 1275 spec says this:
"local-mac-address" Standard property name to specify preassigned network address. "mac-address" Standard property name to specify network address last used.
I think we need to agree on some interpretation of these statements, and all the code should be updated to implement that interpretation.
My interpretation is that mac-address is supposed to the contain these MAC addresses under these circumstances:
1) If the Ethernet interface is up, it's the MAC address that is currently in use.
2) If the Ethernet interface is not up, it's the MAC address that was in use the last time the Ethernet interface was shut down.
In Linux, the ifconfig command is used to change the MAC address. This command calls the driver's set_mac_address function, so it is the driver that sets the MAC address in the hardware.
In order to properly support the mac-address property, the driver must also update the device tree with the new MAC address. That's the only way that mac-address can contain the "specify network address last used".
Linux doesn't support that. In some cases, the actual device tree is located on a TFTP server, and it's only copied temporarily into RAM by U-Boot. There's no way that a Linux driver can update that.
On a full-blown OF machine, the firmware does provide APIs for updating the device tree, and so we could support mac-address on these machines. But U-Boot disappears once the kernel loads, so there is no firmware to call to update the device tree.
Therefore, I propose that on systems where the driver cannot update the device tree, the mac-address property should be absent from the device tree. U-Boot should not add one, and the Linux device drivers should not reference it.
Comments?
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 10 lines · Timur Tabi
Hi everyone,
What is the current consensus on using mac-address vs. local-mac-address in the device tree? The 1275 spec says this:
"local-mac-address" Standard property name to specify preassigned network address. "mac-address" Standard property name to specify network address last used.
I think we need to agree on some interpretation of these statements, and all the code should be updated to implement that interpretation.
It's fairly clear:
local-mac-address is what is statically set by the firwmare (comes from EEPROM, whatever).
mac-address is really only meaningful if your firmware is "dynamic" (real OF, uboot maybe) and was, for some reason, instructed by the user to use a different mac address for that boot (if that feature exist).
It's basically the mac-address that was actually used on that interface to netboot the kernel I'd say.
Quoted 3 lines
Linux doesn't support that. In some cases, the actual device tree is located on a TFTP server, and it's only copied temporarily into RAM by U-Boot. There's no way that a Linux driver can update that.
I don't understand what you mean here :-) The linux driver can perfectly well update the in-memory copy of the device-tree, which would make it useful in the case of a kexec to a newer kernel.
Quoted 4 lines
On a full-blown OF machine, the firmware does provide APIs for updating the device tree, and so we could support mac-address on these machines. But U-Boot disappears once the kernel loads, so there is no firmware to call to update the device tree.
I don't understand what the firmware device-tree has to do with that...
If uboot is instructed to use a different mac-address than the "built-in" one, it can perfectly well create that property before getting to the kernel.
Quoted 3 lines
Therefore, I propose that on systems where the driver cannot update the device tree, the mac-address property should be absent from the device tree. U-Boot should not add one, and the Linux device drivers should not reference it.
"cannot update the device tree" is what makes little sense to me.
Ben.
Quoted 17 lines · Benjamin Herrenschmidt
Quoted 10 lines · Timur Tabi
Hi everyone,
What is the current consensus on using mac-address vs. local-mac-address in the device tree? The 1275 spec says this:
"local-mac-address" Standard property name to specify preassigned network address. "mac-address" Standard property name to specify network address last used.
I think we need to agree on some interpretation of these statements, and all the code should be updated to implement that interpretation.
It's fairly clear:
local-mac-address is what is statically set by the firwmare (comes from EEPROM, whatever).
Quoted 7 lines
mac-address is really only meaningful if your firmware is "dynamic" (real OF, uboot maybe) and was, for some reason, instructed by the user to use a different mac address for that boot (if that feature exist).
It's basically the mac-address that was actually used on that interface to netboot the kernel I'd say.
Which means the code in fsl_soc.c is wrong in how it handles the precedence of gianfar:
mac_addr = get_property(np, "local-mac-address", NULL);
if (mac_addr == NULL)
mac_addr = get_property(np, "mac-address",
NULL);
if (mac_addr == NULL) {
/* Obsolete */
mac_addr = get_property(np, "address", NULL);
}should really be:
mac_addr = get_property(np, "mac-address", NULL);
if (mac_addr == NULL)
mac_addr = get_property(np, "local-mac-
address", NULL);
if (mac_addr == NULL) {
/* Obsolete */
mac_addr = get_property(np, "address", NULL);
}- k
Quoted 1 line · Kumar Gala
Which means the code in
fsl_soc.cis wrong in how it handles the precedence of gianfar:
I agree, and this is the type of thing that we're trying to clear up.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 20 lines · Benjamin Herrenschmidt
Quoted 8 lines · Timur Tabi
Hi everyone,
What is the current consensus on using mac-address vs. local-mac-address in the device tree? The 1275 spec says this:
"local-mac-address" Standard property name to specify preassigned network address. "mac-address" Standard property name to specify network address last used.
I think we need to agree on some interpretation of these statements, and all the code should be updated to implement that interpretation.
It's fairly clear:
local-mac-address is what is statically set by the firwmare (comes from EEPROM, whatever).
mac-address is really only meaningful if your firmware is "dynamic" (real OF, uboot maybe) and was, for some reason, instructed by the user to use a different mac address for that boot (if that feature exist).
Quoted 8 lines
It's basically the mac-address that was actually used on that interface to netboot the kernel I'd say.
Quoted 1 line
Linux doesn't support that. In some cases, the actual device tree is located on a TFTP server, and it's only copied temporarily into RAM by U-Boot. There's no way that a Linux driver can update that.
I don't understand what you mean here :-) The linux driver can perfectly well update the in-memory copy of the device-tree, which would make it useful in the case of a kexec to a newer kernel.
That makes sense. I don't know anything about kexec, so I didn't think there was any point in updating the in-memory copy. But in this case, the driver should update it.
Quoted 3 lines
Quoted 1 line
On a full-blown OF machine, the firmware does provide APIs for updating the device tree, and so we could support mac-address on these machines. But U-Boot disappears once the kernel loads, so there is no firmware to call to update the device tree.
I don't understand what the firmware device-tree has to do with that...
Without a firmware device tree, there's no way to update the device tree and have that new tree retained over a reboot.
Quoted 3 lines
If uboot is instructed to use a different mac-address than the "built-in" one, it can perfectly well create that property before getting to the kernel.
And it does, depending on which version of U-Boot. There is debate (inside Freescale, at least) whether U-Boot should update mac-address or local-mac-address. It sounds to me like it should update local-mac-address, and the DTS file shouldn't even include an entry for mac-address.
Quoted 3 lines
Quoted 1 line
Therefore, I propose that on systems where the driver cannot update the device tree, the mac-address property should be absent from the device tree. U-Boot should not add one, and the Linux device drivers should not reference it.
"cannot update the device tree" is what makes little sense to me.
If I keep my device tree on a TFTP server, which U-Boot fetches every time it boots the kernel, there's no way for Linux to update *that* device tree, which would be the only one that's important. You mentioned kexec earlier, and that's fine, so the driver should update the in-memory copy. But in my opinion, the in-memory copy of the device tree isn't the *real* device tree, it's just a temporary copy of one.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 48 lines · Timur Tabi
Quoted 25 lines · Benjamin Herrenschmidt
Quoted 10 lines · Timur Tabi
Hi everyone,
What is the current consensus on using mac-address vs. local-mac-address in the device tree? The 1275 spec says this:
"local-mac-address" Standard property name to specify preassigned network address. "mac-address" Standard property name to specify network address last used.
I think we need to agree on some interpretation of these statements, and all the code should be updated to implement that interpretation.
It's fairly clear:
local-mac-address is what is statically set by the firwmare (comes from EEPROM, whatever).
mac-address is really only meaningful if your firmware is "dynamic" (real OF, uboot maybe) and was, for some reason, instructed by the user to use a different mac address for that boot (if that feature exist).
It's basically the mac-address that was actually used on that interface to netboot the kernel I'd say.
Quoted 7 lines
Quoted 3 lines
Linux doesn't support that. In some cases, the actual device tree is located on a TFTP server, and it's only copied temporarily into RAM by U-Boot. There's no way that a Linux driver can update that.
I don't understand what you mean here :-) The linux driver can perfectly well update the in-memory copy of the device-tree, which would make it useful in the case of a kexec to a newer kernel.
That makes sense. I don't know anything about kexec, so I didn't think there was any point in updating the in-memory copy. But in this case, the driver should update it.
Quoted 6 lines
Quoted 4 lines
On a full-blown OF machine, the firmware does provide APIs for updating the device tree, and so we could support mac-address on these machines. But U-Boot disappears once the kernel loads, so there is no firmware to call to update the device tree.
I don't understand what the firmware device-tree has to do with that...
Without a firmware device tree, there's no way to update the device tree and have that new tree retained over a reboot.
Quoted 8 lines
Quoted 3 lines
If uboot is instructed to use a different mac-address than the "built-in" one, it can perfectly well create that property before getting to the kernel.
And it does, depending on which version of U-Boot. There is debate (inside Freescale, at least) whether U-Boot should update mac-address or local-mac-address. It sounds to me like it should update local-mac-address, and the DTS file shouldn't even include an entry for mac-address.
The problem with u-boot is that the correct way would be to use local-mac-address for what's compiled into u-boot and mac-address if someone does a 'setenv' to modify the mac address. The question is anyone really going to care that much.
- k
Quoted 1 line · Kumar Gala
The problem with u-boot is that the correct way would be to use local-mac-address for what's compiled into u-boot and mac-address if someone does a 'setenv' to modify the mac address. The question is anyone really going to care that much.
I don't think the compiled-in MAC address should be used at all.
For most boards, the compiled-in option is just some random MAC address. When the board is shipped, the manufacturer creates his own set of environment variables and overrides what's stored on flash.
I actually think that storing a MAC address in a board configuration for or a DTS is a bad idea, because MAC addresses are supposed to be unique for each Ethernet device, and storing a fixed value in a source file breaks that. However, that's a separate issue. I was just trying to stress that the compiled-in MAC address is of no value.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 7 lines · Timur Tabi
Quoted 1 line · Kumar Gala
The problem with u-boot is that the correct way would be to use local-mac-address for what's compiled into u-boot and mac-address if someone does a 'setenv' to modify the mac address. The question is anyone really going to care that much.
I don't think the compiled-in MAC address should be used at all.
For most boards, the compiled-in option is just some random MAC address. When the board is shipped, the manufacturer creates his own set of environment variables and overrides what's stored on flash.
And where does the mfg store these?
Quoted 1 line
I actually think that storing a MAC address in a board configuration for or a DTS is a bad idea, because MAC addresses are supposed to be unique for each Ethernet device, and storing a fixed value in a source file breaks that. However, that's a separate issue. I was just trying to stress that the compiled-in MAC address is of no value.
Ok, so 'compiled-in' wasn't the best choice. What I meant is 'local-mac-address' is the MAC address u-boot decides to use when it boots before any user interaction. (this may be the compiled-in one, or one from flash env settings, or whatever other source the board code decides).
- k
Quoted 3 lines · Kumar Gala
Quoted 1 line
For most boards, the compiled-in option is just some random MAC address. When the board is shipped, the manufacturer creates his own set of environment variables and overrides what's stored on flash.
And where does the mfg store these?
Ideally, on the Ethernet adapters's internal EEPROM. On non-OF systems, the driver is supposed to read the MAC address from the hardware.
Quoted 1 line
Ok, so 'compiled-in' wasn't the best choice. What I meant is 'local-mac-address' is the MAC address u-boot decides to use when it boots before any user interaction.
I agree with that.
Quoted 1 line
(this may be the compiled-in one, or one from flash env settings, or whatever other source the board code decides).
Well, I think you mean that it should be only the environment variable. The compiled-in version is just a default value for the environment, so that should be ignored. On a few U-Boot Ethernet drivers, the driver queries the hardware and fetches the MAC address from it. The driver then updates the environment variable.
So in all case, when U-Boot boots the kernel, it should use the environment variable to update local-mac-address, and leave mac-address alone. I'm trying to get a consensus on this proposition.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 3 lines
Without a firmware device tree, there's no way to update the device tree and have that new tree retained over a reboot.
I don't think it was ever question to update it over reboot... mac-address is a runtime property that is lost at reboot, at least that's my understanding of the OF behaviour. That's where your confusion is.
Ben.
Quoted 3 lines · Benjamin Herrenschmidt
Quoted 1 line
Without a firmware device tree, there's no way to update the device tree and have that new tree retained over a reboot.
I don't think it was ever question to update it over reboot...
Well, it is a good idea to use the same MAC address at every boot. The question becomes: when you change the MAC address in Linux, is it possible to retain that value over reboot? If the driver were able to update the *real* OF tree, then we could provide that functionality (on OF-enabled systems).
My main point was to define when mac-address should be used, and when local-mac-address should be used.
Quoted 3 lines
mac-address is a runtime property that is lost at reboot, at least that's my understanding of the OF behaviour. That's where your confusion is.
Linux already stores the current MAC address somewhere outside of the OF tree. When I reboot the system, does Linux store the current MAC address somewhere?
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale