tg3: replace placeholder MAC address with device property
Subsystems (3)
PATCH v3 1/1 tg3: replace placeholder MAC address with device property
From: Paul SAGE <[email protected]>
On some systems (e.g. iMac 20,1 with BCM57766), the tg3 driver reads a default placeholder mac address (00:10:18:00:00:00) from the mailbox. The correct value on those systems are stored in the 'local-mac-address' property.
This patch, detect the default value and tries to retrieve the correct address from the device_get_mac_address function instead.
The patch has been tested on two different systems:
- iMac 20,1 (BCM57766) model which use the local-mac-address property
- iMac 13,2 (BCM57766) model which can use the mailbox, NVRAM or MAC control registers
---
v3:
- Used ether_addr_equal
v2:
- Wrapped commit message to 70 characters
- Removed BROADCOM_OUI constant
---
--- drivers/net/ethernet/broadcom/tg3.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +11 -0
@@ -17030,6 +17030,13 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent)return err; } +static int tg3_is_default_mac_address (u8 *addr) +{ +const u8 default_mac_address[ETH_ALEN ] = {0x00 ,0x10 ,0x18 ,0x00 ,0x00 ,0x00 }; + +return ether_addr_equal (default_mac_address, addr); +} +static int tg3_get_device_address (struct tg3 *tp,u8 *addr) {u32 hi, lo, mac_offset;
@@ -17103,6 +17110,10 @@ static int tg3_get_device_address(struct tg3 *tp, u8 *addr)if (!is_valid_ether_addr (addr))return -EINVAL ; + +if (tg3_is_default_mac_address (addr)) +device_get_mac_address (&tp->pdev->dev, addr); +return 0 ; }
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerdrivers/net/ethernet/broadcom/tg3.c static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent) · line 17035
Quoted 3 lines · On Fri, 13 Mar 2026 11:38:09 +0530 Atharva Tiwari wrote:
drivers/net/ethernet/broadcom/tg3.c +3
-0+static int tg3_is_default_mac_address (u8 *addr) +{ +const u8 default_mac_address[ETH_ALEN ] = {0x00 ,0x10 ,0x18 ,0x00 ,0x00 ,0x00 };
Please add static as well. I think it should result in slightly smaller object code.
drivers/net/ethernet/broadcom/tg3.c static int tg3_get_device_address(struct tg3 *tp, u8 *addr) · line 17115
Quoted 13 lines
drivers/net/ethernet/broadcom/tg3.c +6
-0+return ether_addr_equal (default_mac_address, addr); +} +static int tg3_get_device_address (struct tg3 *tp,u8 *addr) {u32 hi, lo, mac_offset;@@ -17103,6 +17110,10 @@ static int tg3_get_device_address(struct tg3 *tp, u8 *addr)if (!is_valid_ether_addr (addr))return -EINVAL ; + +if (tg3_is_default_mac_address (addr)) +device_get_mac_address (&tp->pdev->dev, addr);
Shouldn't we return device_get_mac_address(); IOW return an error if device_get.. failed?
Signature · 1 line
pw-bot: cr