All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tg3: fix big endian MAC address collection failure
@ 2009-04-13 15:29 James Bottomley
  2009-04-13 21:32 ` David Miller
  0 siblings, 1 reply; 32+ messages in thread
From: James Bottomley @ 2009-04-13 15:29 UTC (permalink / raw)
  To: netdev; +Cc: Parisc List, Matt Carlson, Michael Chan

[sorry for repost; wrong netdev address first time around]

We noticed on parisc that our broadcoms all swapped MAC addresses going
from 2.6.29 to 2.6.30-rc1:

Apr 11 07:48:24 ion kernel: eth0: Tigon3 [partno(BCM95700A6) rev 0105] (PCI:66MHz:64-bit) MAC address 00:30:6e:4b:15:59
Apr 13 07:34:34 ion kernel: eth0: Tigon3 [partno(BCM95700A6) rev 0105] (PCI:66MHz:64-bit) MAC address 00:00:59:15:4b:6e

The problem patch is:

commit 6d348f2c1e0bb1cf7a494b51fc921095ead3f6ae
Author: Matt Carlson <mcarlson@broadcom.com>
Date:   Wed Feb 25 14:25:52 2009 +0000

    tg3: Eliminate tg3_nvram_read_swab()

With the root cause being the use of memcpy to set the mac address:

   memcpy(&dev->dev_addr[0], ((char *)&hi) + 2, 2);
   memcpy(&dev->dev_addr[2], (char *)&lo, sizeof(lo));

This might work on little endian machines, but it can't on big endian
ones.  You have to use the original setting mechanism to be correct on
all architectures.

The attached patch fixes parisc.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

---

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6a736dd..7a837c4 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12443,8 +12443,13 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
 		/* Next, try NVRAM. */
 		if (!tg3_nvram_read_be32(tp, mac_offset + 0, &hi) &&
 		    !tg3_nvram_read_be32(tp, mac_offset + 4, &lo)) {
-			memcpy(&dev->dev_addr[0], ((char *)&hi) + 2, 2);
-			memcpy(&dev->dev_addr[2], (char *)&lo, sizeof(lo));
+			dev->dev_addr[0] = ((hi >> 16) & 0xff);
+			dev->dev_addr[1] = ((hi >> 24) & 0xff);
+			dev->dev_addr[2] = ((lo >>  0) & 0xff);
+			dev->dev_addr[3] = ((lo >>  8) & 0xff);
+			dev->dev_addr[4] = ((lo >> 16) & 0xff);
+			dev->dev_addr[5] = ((lo >> 24) & 0xff);
+
 		}
 		/* Finally just fetch it out of the MAC control regs. */
 		else {




^ permalink raw reply related	[flat|nested] 32+ messages in thread
* [PATCH] tg3: fix big endian MAC address collection failure
@ 2009-04-13 15:21 James Bottomley
  2009-04-13 18:00 ` Matt Carlson
  0 siblings, 1 reply; 32+ messages in thread
From: James Bottomley @ 2009-04-13 15:21 UTC (permalink / raw)
  To: linux-netdev; +Cc: Parisc List, Matt Carlson, Michael Chan

We noticed on parisc that our broadcoms all swapped MAC addresses going
from 2.6.29 to 2.6.30-rc1:

Apr 11 07:48:24 ion kernel: eth0: Tigon3 [partno(BCM95700A6) rev 0105] (PCI:66MHz:64-bit) MAC address 00:30:6e:4b:15:59
Apr 13 07:34:34 ion kernel: eth0: Tigon3 [partno(BCM95700A6) rev 0105] (PCI:66MHz:64-bit) MAC address 00:00:59:15:4b:6e

The problem patch is:

commit 6d348f2c1e0bb1cf7a494b51fc921095ead3f6ae
Author: Matt Carlson <mcarlson@broadcom.com>
Date:   Wed Feb 25 14:25:52 2009 +0000

    tg3: Eliminate tg3_nvram_read_swab()

With the root cause being the use of memcpy to set the mac address:

   memcpy(&dev->dev_addr[0], ((char *)&hi) + 2, 2);
   memcpy(&dev->dev_addr[2], (char *)&lo, sizeof(lo));

This might work on little endian machines, but it can't on big endian
ones.  You have to use the original setting mechanism to be correct on
all architectures.

The attached patch fixes parisc.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

---

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6a736dd..7a837c4 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12443,8 +12443,13 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
 		/* Next, try NVRAM. */
 		if (!tg3_nvram_read_be32(tp, mac_offset + 0, &hi) &&
 		    !tg3_nvram_read_be32(tp, mac_offset + 4, &lo)) {
-			memcpy(&dev->dev_addr[0], ((char *)&hi) + 2, 2);
-			memcpy(&dev->dev_addr[2], (char *)&lo, sizeof(lo));
+			dev->dev_addr[0] = ((hi >> 16) & 0xff);
+			dev->dev_addr[1] = ((hi >> 24) & 0xff);
+			dev->dev_addr[2] = ((lo >>  0) & 0xff);
+			dev->dev_addr[3] = ((lo >>  8) & 0xff);
+			dev->dev_addr[4] = ((lo >> 16) & 0xff);
+			dev->dev_addr[5] = ((lo >> 24) & 0xff);
+
 		}
 		/* Finally just fetch it out of the MAC control regs. */
 		else {




^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2009-04-20 20:46 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-13 15:29 [PATCH] tg3: fix big endian MAC address collection failure James Bottomley
2009-04-13 21:32 ` David Miller
2009-04-13 21:42   ` James Bottomley
2009-04-13 21:44     ` David Miller
2009-04-13 22:17     ` Michael Chan
2009-04-13 22:32       ` James Bottomley
2009-04-14  1:25         ` Matt Carlson
2009-04-14  1:40           ` David Miller
2009-04-14  2:00             ` Matt Carlson
2009-04-14  2:19               ` Kyle McMartin
2009-04-14  2:51               ` David Miller
2009-04-14  3:56                 ` Michael Chan
2009-04-14  3:51           ` James Bottomley
2009-04-14  4:11             ` Michael Chan
2009-04-14 15:26               ` James Bottomley
2009-04-14 15:31               ` Robin Holt
  -- strict thread matches above, loose matches on Subject: below --
2009-04-13 15:21 James Bottomley
2009-04-13 18:00 ` Matt Carlson
2009-04-13 18:04   ` Kyle McMartin
2009-04-13 18:13     ` Matt Carlson
2009-04-13 18:18       ` James Bottomley
2009-04-13 18:24         ` Matt Carlson
2009-04-13 18:15   ` James Bottomley
2009-04-13 18:37     ` Matt Carlson
2009-04-13 20:48       ` James Bottomley
2009-04-14  1:17         ` Matt Carlson
2009-04-14 15:39           ` Grant Grundler
2009-04-14 19:02             ` Matt Carlson
2009-04-18 23:00               ` Grant Grundler
2009-04-19  7:30                 ` Michael Chan
2009-04-19 22:32                   ` Grant Grundler
2009-04-20 20:46                     ` Matt Carlson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.