Skip to contentSkip to conversation

tg3: replace placeholder MAC address with device property

PATCH Superseded Atharva Tiwari 2 participants 2 messages Mar 6 – Mar 10

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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

---
v2:
- Wrapped commit message to 70 characters
- Removed BROADCOM_OUI constant
---

---
 drivers/net/ethernet/broadcom/tg3.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +12 -0
index 75f66587983d..b9950651b20c 100644
@@ -17030,6 +17030,14 @@ 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)
+{
+	u32 addr_high = (addr[0] << 16) | (addr[1] << 8) | addr[2];
+	u32 addr_low = (addr[3] << 16) | (addr[4] << 8) | addr[5];
+
+	return addr_high == 0x00001018 && addr_low == 0;
+}
+
 static int tg3_get_device_address(struct tg3 *tp, u8 *addr)
 {
 	u32 hi, lo, mac_offset;
@@ -17103,6 +17111,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
reviewer
#1 lore raw

On Fri, Mar 06, 2026 at 10:36:55PM +0530, Atharva Tiwari wrote:

...

Quoted 5 lines
drivers/net/ethernet/broadcom/tg3.c +0 -0
index 75f66587983d..b9950651b20c 100644

drivers/net/ethernet/broadcom/tg3.c static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent) · line 17038

Quoted 9 lines
drivers/net/ethernet/broadcom/tg3.c +6 -0
@@ -17030,6 +17030,14 @@ 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)
+{
+	u32 addr_high = (addr[0] << 16) | (addr[1] << 8) | addr[2];
+	u32 addr_low = (addr[3] << 16) | (addr[4] << 8) | addr[5];
+
+	return addr_high == 0x00001018 && addr_low == 0;

Hi Paul and Atharva,

I think you can use ether_addr_equal(), or some variant of it, here.

Quoted 1 line
drivers/net/ethernet/broadcom/tg3.c +1 -0
+}

...