Re: [PATCH] r8169: read MAC address from EEPROM on init (2nd attempt)

Previous thread: ip_nonlocal_bind and sendto (fwd) by david on Friday, February 27, 2009 - 2:20 am. (4 messages)

Next thread: Connection reset by peer - need a patch by Pascal GREGIS on Friday, February 27, 2009 - 8:07 am. (4 messages)
From: Ivan Vecera
Date: Friday, February 27, 2009 - 5:13 am

This is 2nd attempt to implement the initialization/reading of MAC address
from EEPROM. The first used PCI's VPD and there were some problems, some
devices are not able to read EEPROM content by VPD. The 2nd one uses direct
access to EEPROM through bit-banging interface and my testing results seem
to be much better.

I tested 5 systems each with different Realtek NICs and I didn't find any
problem. AFAIK Francois's NICs also works fine.

Original description:
This fixes the problem when MAC address is set by ifconfig or by
ip link commands and this address is stored in the device after
reboot. The power-off is needed to get right MAC address.
This is problem when Xen daemon is running because it renames the device
name from ethX to pethX and sets its MAC address to FE:FF:FF:FF:FF:FF.
After reboot the device is still using FE:FF:FF:FF:FF:FF.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/r8169.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 112 insertions(+), 2 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 0771eb6..b347340 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -81,9 +81,9 @@ static const int multicast_filter_limit = 32;
 #define RTL8169_TX_TIMEOUT	(6*HZ)
 #define RTL8169_PHY_TIMEOUT	(10*HZ)
 
-#define RTL_EEPROM_SIG		cpu_to_le32(0x8129)
-#define RTL_EEPROM_SIG_MASK	cpu_to_le32(0xffff)
+#define RTL_EEPROM_SIG		0x8129
 #define RTL_EEPROM_SIG_ADDR	0x0000
+#define RTL_EEPROM_MAC_ADDR	0x0007
 
 /* write/read MMIO register */
 #define RTL_W8(reg, val8)	writeb ((val8), ioaddr + (reg))
@@ -293,6 +293,11 @@ enum rtl_register_content {
 	/* Cfg9346Bits */
 	Cfg9346_Lock	= 0x00,
 	Cfg9346_Unlock	= 0xc0,
+	Cfg9346_Program	= 0x80,		/* Programming mode */
+	Cfg9346_EECS	= 0x08,		/* Chip select */
+	Cfg9346_EESK	= 0x04,		/* Serial data clock */
+	Cfg9346_EEDI	= 0x02,		/* Data input */
+	Cfg9346_EEDO	= 0x01,		/* Data output */
 
 	/* rx_mode_bits */
 	AcceptErr	= 0x20,
@@ ...
From: Francois Romieu
Date: Sunday, March 1, 2009 - 3:34 pm

Ivan Vecera <ivecera@redhat.com> :

Yes.


I would not had mind a loop here but it's otherwise fine.

Please apply.

-- 
Ueimor
--

From: David Miller
Date: Sunday, March 1, 2009 - 9:35 pm

From: Francois Romieu <romieu@fr.zoreil.com>

Done, thanks everyone.
--

Previous thread: ip_nonlocal_bind and sendto (fwd) by david on Friday, February 27, 2009 - 2:20 am. (4 messages)

Next thread: Connection reset by peer - need a patch by Pascal GREGIS on Friday, February 27, 2009 - 8:07 am. (4 messages)