Skip to contentSkip to conversation

rtl8102e: commit 7bf6bf480 zeroized MAC address

PATCH [email protected] 3 participants 4 messages Oct 15, 2008 – Oct 21, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 8 lines

From: Ivan Vecera<[email protected]>

Quoted 5 lines · [email protected] wrote:

Tested on top of linus tree and back ported 2.6.27.

Please cc me, thanks
Martin Capitanio

I think this one is more common.

What about to mix both?
If the address is not stored here than it must be somewhere else -- or the read algorithm is broken ;-)

May be we are reading just by luck zeros and not a random perfectly sane address. Personally I would prefer in this fine driver, just not doing what is not absolutely needed. It would be great to figure out if all of the rtl8102e, etc. doesn't have this location.

You can hardly desolder those chips from notebooks and I am really happy if this _just works_ with as much realtek blessing as possible.

Martin

P.S. Apologize, I'm forced to use this * webmailer.

Quoted 28 lines

Ivan

=====
Subject: [PATCH] [r8169] initialize MAC address found in EEPROM only if is it valid

---
 drivers/net/r8169.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/r8169.c +3 -2
index c821da2..587a96c 100644
@@ -1975,8 +1975,9 @@ static void rtl_init_mac_address(struct
 rtl8169_private *tp,
 
 	dprintk("MAC address found in EEPROM: %s\n", print_mac(buf, mac));
 
-	/* Write MAC address */
-	rtl_rar_set(tp, mac);
+	/* Write MAC address if is it valid */
+	if (is_valid_ether_addr(mac))
+		rtl_rar_set(tp, mac);
 }
 
Quoted 4 lines

static int __devinit

Signature · 1 line
1.5.6.3

--- original message end ----

#1 lore raw

[email protected] <[email protected]> :

Quoted 2 lines

May be we are reading just by luck zeros and not a random perfectly sane address.

I would use the attached patches. The former one is mostly Ivan's one with some rework of the debug messages. The later checks the eeprom for its signature.

With these patches the driver notices that it can not get an address for my 8168b but it works ok with my 8169 after both an hot and a cold boot. Interestingly enough, the VPD is not enabled on the 8169 during the first boot.

Ivan, can you test them (and fix them afterwards :o) ) ?

Signature · 1 line
Ueimor
drivers/net/r8169.c +14 -6
index c821da2..e80ca26 100644
@@ -1947,11 +1947,11 @@ static void rtl_init_mac_address(struct rtl8169_private *tp,
 	u8 cfg1;
 	int vpd_cap;
 	u8 mac[8];
-	DECLARE_MAC_BUF(buf);
 
 	cfg1 = RTL_R8(Config1);
 	if (!(cfg1  & VPD)) {
-		dprintk("VPD access not enabled, enabling\n");
+		if (netif_msg_probe(tp))
+			dev_info(&pdev->dev, "VPD access disabled, enabling\n");
 		RTL_W8(Cfg9346, Cfg9346_Unlock);
 		RTL_W8(Config1, cfg1 | VPD);
 		RTL_W8(Cfg9346, Cfg9346_Lock);
@@ -1969,14 +1969,22 @@ static void rtl_init_mac_address(struct rtl8169_private *tp,
 	 */
 	if (rtl_eeprom_read(pdev, vpd_cap, 0x000e, (__le32*)&mac[0]) < 0 ||
 	    rtl_eeprom_read(pdev, vpd_cap, 0x0012, (__le32*)&mac[4]) < 0) {
-		dprintk("Reading MAC address from EEPROM failed\n");
+		if (netif_msg_probe(tp)) {
+			dev_warn(&pdev->dev,
+				 "reading MAC address from EEPROM failed\n");
+		}
 		return;
 	}
 
-	dprintk("MAC address found in EEPROM: %s\n", print_mac(buf, mac));
+	if (netif_msg_probe(tp)) {
+		DECLARE_MAC_BUF(buf);
+
+		dev_info(&pdev->dev, "MAC address found in EEPROM: %s\n",
+			 print_mac(buf, mac));
+	}
 
-	/* Write MAC address */
-	rtl_rar_set(tp, mac);
+	if (is_valid_ether_addr(mac))
+		rtl_rar_set(tp, mac);
 }
 
 static int __devinit
drivers/net/r8169.c +30 -11

67 lines not on this page · raw message

#2 lore raw

Am Donnerstag, den 16.10.2008, 00:50 +0200 schrieb Francois Romieu:

Quoted 7 lines

[email protected] <[email protected]> :

Quoted 2 lines

May be we are reading just by luck zeros and not a random perfectly sane address.

I would use the attached patches. The former one is mostly Ivan's one with some rework of the debug messages. The later checks the eeprom for its signature.

[ 8087.008071] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[ 8087.008108] r8169 0000:02:00.0: PCI INT A -> GSI 16 (level, low) ->
IRQ 16
[ 8087.008120] r8169 0000:02:00.0: enabling Mem-Wr-Inval
[ 8087.008139] r8169 0000:02:00.0: enabling bus mastering
[ 8087.008149] r8169 0000:02:00.0: setting latency timer to 64
[ 8087.008284] r8169 0000:02:00.0: VPD access advertised.
[ 8087.008620] r8169 0000:02:00.0: Missing EEPROM signature: 0000
[ 8087.009390] eth0: RTL8102e at 0xffffc20000042000,, XID 34a00000 IRQ
316
[ 8091.040800] r8169: eth0: link up

Thanks,
Martin

Quoted 8 lines

With these patches the driver notices that it can not get an address for my 8168b but it works ok with my 8169 after both an hot and a cold boot. Interestingly enough, the VPD is not enabled on the 8169 during the first boot.

Ivan, can you test them (and fix them afterwards :o) ) ?

#3 lore raw
In reply to Francois Romieu
Quoted 8 lines · Francois Romieu

[email protected] <[email protected]> :

Quoted 2 lines

May be we are reading just by luck zeros and not a random perfectly sane address.

I would use the attached patches. The former one is mostly Ivan's one with some rework of the debug messages. The later checks the eeprom for its signature.

Quoted 6 lines

With these patches the driver notices that it can not get an address for my 8168b but it works ok with my 8169 after both an hot and a cold boot. Interestingly enough, the VPD is not enabled on the 8169 during the first boot.

Ivan, can you test them (and fix them afterwards :o) ) ?

No problem found. Both 8168c (GIGA_MAC_VER_20) and 8102el (GIGA_MAC_VER_09) successfully loads MAC address from EEPROM (from power-off state and also after reboot).

Ivan