All of lore.kernel.org
 help / color / mirror / Atom feed
* mac80211 driver for RT3070 wifi card does not work on big-endian platform
@ 2011-09-08  5:34 Semigod King
  2011-09-08 15:12 ` Larry Finger
  2011-09-08 19:04 ` Larry Finger
  0 siblings, 2 replies; 7+ messages in thread
From: Semigod King @ 2011-09-08  5:34 UTC (permalink / raw)
  To: linux-wireless

Greetings,

I would like to report a bug to you. The same problem was reported to
OpenWRT developers. But, they suggest me report it to linux wireless.

Problem:
The wireless card can not be recognized. But, an iface with wrong MAC
is created.

wlan1 Link encap:Ethernet HWaddr 00:06:4E:E8:00:00 <== Wrong MAC, the
correct MAC is E8:4E:06:00:74:61. Looks like byte-swapped.
UP BROADCAST MULTICAST MTU:1500 Metric:1 <=== Not running
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

After making changes according to
https://forum.openwrt.org/viewtopic.php?id=30132,
the card can now be recognized with correct MAC and can be operated.
But, it does not work yet.
No RX in AP mode. No TX & RX in STA mode. I guess the TX in AP mode is
meaningless.


Wifi Card: Unknown brand, RT3070 chipset, USB
Platform: Openwrt (MIPS, BCM6358, big-endian)
Kernel:
root@OpenWrt:~# uname -a
Linux OpenWrt 2.6.39.4 #1 Mon Aug 22 04:57:19 MST 2011 mips GNU/Linux
driver: mac80211 compat-wireless driver.
kmod-rt2800-lib - 2.6.39.4+2011-08-10-2
kmod-rt2800-usb - 2.6.39.4+2011-08-10-2
kmod-rt2x00-lib - 2.6.39.4+2011-08-10-2
kmod-rt2x00-usb - 2.6.39.4+2011-08-10-2



Regards,
Lucas Wang

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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
  2011-09-08  5:34 mac80211 driver for RT3070 wifi card does not work on big-endian platform Semigod King
@ 2011-09-08 15:12 ` Larry Finger
  2011-09-08 19:04 ` Larry Finger
  1 sibling, 0 replies; 7+ messages in thread
From: Larry Finger @ 2011-09-08 15:12 UTC (permalink / raw)
  To: Semigod King; +Cc: linux-wireless

On 09/08/2011 12:34 AM, Semigod King wrote:
> Greetings,
>
> I would like to report a bug to you. The same problem was reported to
> OpenWRT developers. But, they suggest me report it to linux wireless.
>
> Problem:
> The wireless card can not be recognized. But, an iface with wrong MAC
> is created.
>
> wlan1 Link encap:Ethernet HWaddr 00:06:4E:E8:00:00<== Wrong MAC, the
> correct MAC is E8:4E:06:00:74:61. Looks like byte-swapped.
> UP BROADCAST MULTICAST MTU:1500 Metric:1<=== Not running
> RX packets:0 errors:0 dropped:0 overruns:0 frame:0
> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
>
> After making changes according to
> https://forum.openwrt.org/viewtopic.php?id=30132,
> the card can now be recognized with correct MAC and can be operated.
> But, it does not work yet.
> No RX in AP mode. No TX&  RX in STA mode. I guess the TX in AP mode is
> meaningless.
>
>
> Wifi Card: Unknown brand, RT3070 chipset, USB
> Platform: Openwrt (MIPS, BCM6358, big-endian)
> Kernel:
> root@OpenWrt:~# uname -a
> Linux OpenWrt 2.6.39.4 #1 Mon Aug 22 04:57:19 MST 2011 mips GNU/Linux
> driver: mac80211 compat-wireless driver.
> kmod-rt2800-lib - 2.6.39.4+2011-08-10-2
> kmod-rt2800-usb - 2.6.39.4+2011-08-10-2
> kmod-rt2x00-lib - 2.6.39.4+2011-08-10-2
> kmod-rt2x00-usb - 2.6.39.4+2011-08-10-2

Obviously, that driver fails to work on a big-endian platform. For tracking 
purposes, please open a bug report at bugzilla.kernel.org. That will also be a 
location for exchanging trial patches.

I have an RT3090 USB device and a MacBook G4 that uses the PPC processor, thus I 
have a test bed for investigating this problem.

Larry

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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
  2011-09-08  5:34 mac80211 driver for RT3070 wifi card does not work on big-endian platform Semigod King
  2011-09-08 15:12 ` Larry Finger
@ 2011-09-08 19:04 ` Larry Finger
       [not found]   ` <CA+TXxM0EOBs2x+6jh=0uwDTMTUD+9ZXQ8W-ZR+=TjSARV3kAeQ@mail.gmail.com>
  1 sibling, 1 reply; 7+ messages in thread
From: Larry Finger @ 2011-09-08 19:04 UTC (permalink / raw)
  To: Semigod King; +Cc: linux-wireless

On 09/08/2011 12:34 AM, Semigod King wrote:
> Greetings,
>
> I would like to report a bug to you. The same problem was reported to
> OpenWRT developers. But, they suggest me report it to linux wireless.

I do see a problem. Looking at one piece of your patch, we see

-    rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3,
-                    (u32 *)&rt2x00dev->eeprom[i]);
+    rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, &reg);
+    *(u32 *)&rt2x00dev->eeprom[i] = le32_to_cpu(reg);

The last statement of rt2800_register_read_lock() does an le32_to_cpu() 
conversion of the output value (3rd argument), but rt2x00dev->eeprom is le16, 
which is why a double conversion le32 => be32 => le32 is needed. Your second 
line should be

*(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg);

That does the same thing, but makes it clearer what is happening.

I am having to rebuild the Ubuntu system on my Mac, which will take a while. 
When that is done, I will be able to test.

Larry

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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
       [not found]   ` <CA+TXxM0EOBs2x+6jh=0uwDTMTUD+9ZXQ8W-ZR+=TjSARV3kAeQ@mail.gmail.com>
@ 2011-09-09 13:55     ` Larry Finger
  2011-09-09 17:30       ` Semigod King
  0 siblings, 1 reply; 7+ messages in thread
From: Larry Finger @ 2011-09-09 13:55 UTC (permalink / raw)
  To: Semigod King; +Cc: wireless

On 09/09/2011 07:05 AM, Semigod King wrote:
> Larry,
> Thank you for looking at this issue. I will try your code change tonight and let
> you know test results. I have an openwrt cross build system ready on my freebsd
> at home.

That will not change a thing. Other than trip some sparse warnings, 
le32_to_cpu() and cpu_to_le32() do the same thing. On little-endian boxes, they 
are a no-op, and on big-endian platforms, they both reverse the byte order. 
Switching the call only makes it clearer what is happening.

I am having trouble getting Ubuntu 11.04 running on my Macbook. The OS is 
installed, but no X at the moment.

BTW, please do not drop the Cc to wireless. I want to keep the ML in the loop.

Larry


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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
  2011-09-09 13:55     ` Larry Finger
@ 2011-09-09 17:30       ` Semigod King
  2011-09-14 21:22         ` Larry Finger
  0 siblings, 1 reply; 7+ messages in thread
From: Semigod King @ 2011-09-09 17:30 UTC (permalink / raw)
  To: Larry Finger; +Cc: wireless

I noticed two lines of code:
                static const u32 wcid[2] = { 0xffffffff, 0x00ffffff };
                rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
                                              wcid, sizeof(wcid));

Do you think the first line should be changed as below to eliminate
platform difference?
                static const u32 wcid[2] = { 0xffffffff,
cpu_to_le32(0x00ffffff) };


On Fri, Sep 9, 2011 at 9:55 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> On 09/09/2011 07:05 AM, Semigod King wrote:
>>
>> Larry,
>> Thank you for looking at this issue. I will try your code change tonight
>> and let
>> you know test results. I have an openwrt cross build system ready on my
>> freebsd
>> at home.
>
> That will not change a thing. Other than trip some sparse warnings,
> le32_to_cpu() and cpu_to_le32() do the same thing. On little-endian boxes,
> they are a no-op, and on big-endian platforms, they both reverse the byte
> order. Switching the call only makes it clearer what is happening.
>
> I am having trouble getting Ubuntu 11.04 running on my Macbook. The OS is
> installed, but no X at the moment.
>
> BTW, please do not drop the Cc to wireless. I want to keep the ML in the
> loop.
>
> Larry
>
>

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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
  2011-09-09 17:30       ` Semigod King
@ 2011-09-14 21:22         ` Larry Finger
  2011-09-16  7:12           ` Semigod King
  0 siblings, 1 reply; 7+ messages in thread
From: Larry Finger @ 2011-09-14 21:22 UTC (permalink / raw)
  To: Semigod King; +Cc: wireless

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

On 09/09/2011 12:30 PM, Semigod King wrote:
> I noticed two lines of code:
>                  static const u32 wcid[2] = { 0xffffffff, 0x00ffffff };
>                  rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
>                                                wcid, sizeof(wcid));
>
> Do you think the first line should be changed as below to eliminate
> platform difference?
>                  static const u32 wcid[2] = { 0xffffffff,
> cpu_to_le32(0x00ffffff) };

No, that kind of thing should not be done. Internal data that are not 
specifically set to be little- or big-endian should be in cpu order. The 
conversions need to be done when writing to or reading from the device when the 
order differs from that of the cpu.

The changes were minimal. Most of the time it took me were in getting Linux 
running on my Powerbook G4 and getting the code to compile - I had to work 
around a bug in gcc version 4.4.5 on the PowerMac platform. The patch I needed 
is attached. The performance of rt2800usb is not great. With netperf, I'm 
getting about 5 Mbps for the netperf MAERTS, STREAM, and SENDFILE tests.

Larry



[-- Attachment #2: rt2x00_big_endian --]
[-- Type: text/plain, Size: 2331 bytes --]

Index: wireless-testing-new/drivers/net/wireless/rt2x00/rt2800lib.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rt2x00/rt2800lib.c	2011-09-14 15:25:01.595735348 -0500
+++ wireless-testing-new/drivers/net/wireless/rt2x00/rt2800lib.c	2011-09-14 15:25:09.291644646 -0500
@@ -3697,14 +3697,15 @@
 	rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
 
 	/* Apparently the data is read from end to start */
-	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3,
-					(u32 *)&rt2x00dev->eeprom[i]);
-	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2,
-					(u32 *)&rt2x00dev->eeprom[i + 2]);
-	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1,
-					(u32 *)&rt2x00dev->eeprom[i + 4]);
-	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0,
-					(u32 *)&rt2x00dev->eeprom[i + 6]);
+	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, &reg);
+	/* The returned value is in CPU order, but eeprom is le */
+	rt2x00dev->eeprom[i] = cpu_to_le32(reg);
+	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2, &reg);
+	*(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg);
+	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1, &reg);
+	*(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg);
+	rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0, &reg);
+	*(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg);
 
 	mutex_unlock(&rt2x00dev->csr_mutex);
 }
@@ -3870,19 +3872,23 @@
 		return -ENODEV;
 	}
 
-	if (!rt2x00_rf(rt2x00dev, RF2820) &&
-	    !rt2x00_rf(rt2x00dev, RF2850) &&
-	    !rt2x00_rf(rt2x00dev, RF2720) &&
-	    !rt2x00_rf(rt2x00dev, RF2750) &&
-	    !rt2x00_rf(rt2x00dev, RF3020) &&
-	    !rt2x00_rf(rt2x00dev, RF2020) &&
-	    !rt2x00_rf(rt2x00dev, RF3021) &&
-	    !rt2x00_rf(rt2x00dev, RF3022) &&
-	    !rt2x00_rf(rt2x00dev, RF3052) &&
-	    !rt2x00_rf(rt2x00dev, RF3320) &&
-	    !rt2x00_rf(rt2x00dev, RF5370) &&
-	    !rt2x00_rf(rt2x00dev, RF5390)) {
-		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
+	switch (rt2x00dev->chip.rf) {
+	case RF2820:
+	case RF2850:
+	case RF2720:
+	case RF2750:
+	case RF3020:
+	case RF2020:
+	case RF3021:
+	case RF3022:
+	case RF3052:
+	case RF3320:
+	case RF5370:
+	case RF5390:
+		break;
+	default:
+		ERROR(rt2x00dev, "Invalid RF chipset 0x%x detected.\n",
+		      rt2x00dev->chip.rf);
 		return -ENODEV;
 	}
 

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

* Re: mac80211 driver for RT3070 wifi card does not work on big-endian platform
  2011-09-14 21:22         ` Larry Finger
@ 2011-09-16  7:12           ` Semigod King
  0 siblings, 0 replies; 7+ messages in thread
From: Semigod King @ 2011-09-16  7:12 UTC (permalink / raw)
  To: Larry Finger; +Cc: wireless

Larry,
Thanks for your work. It seems the driver works with your dongle &
platform. In your patch, the code changes are just refactor besides
efuse reading part. I tried your patch, no luck. Any r/w operation to
the card causes segment fault.
For changing
  static const u32 wcid[2] = { 0xffffffff, 0x00ffffff };
to
  static const u32 wcid[2] = { 0xffffffff, cpu_to_le32(0x00ffffff) };
, my understanding is that rt2800_register_multiwrite always write
data with assumption that the data is little-endian.

I have no other big-endian platform to test the driver on with regular
linux. So, i have to stick to Brcm6358 based wireless router and
openwrt.



On Thu, Sep 15, 2011 at 5:22 AM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> On 09/09/2011 12:30 PM, Semigod King wrote:
>>
>> I noticed two lines of code:
>>                 static const u32 wcid[2] = { 0xffffffff, 0x00ffffff };
>>                 rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
>>                                               wcid, sizeof(wcid));
>>
>> Do you think the first line should be changed as below to eliminate
>> platform difference?
>>                 static const u32 wcid[2] = { 0xffffffff,
>> cpu_to_le32(0x00ffffff) };
>
> No, that kind of thing should not be done. Internal data that are not
> specifically set to be little- or big-endian should be in cpu order. The
> conversions need to be done when writing to or reading from the device when
> the order differs from that of the cpu.
>
> The changes were minimal. Most of the time it took me were in getting Linux
> running on my Powerbook G4 and getting the code to compile - I had to work
> around a bug in gcc version 4.4.5 on the PowerMac platform. The patch I
> needed is attached. The performance of rt2800usb is not great. With netperf,
> I'm getting about 5 Mbps for the netperf MAERTS, STREAM, and SENDFILE tests.
>
> Larry
>
>
>

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

end of thread, other threads:[~2011-09-16  7:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08  5:34 mac80211 driver for RT3070 wifi card does not work on big-endian platform Semigod King
2011-09-08 15:12 ` Larry Finger
2011-09-08 19:04 ` Larry Finger
     [not found]   ` <CA+TXxM0EOBs2x+6jh=0uwDTMTUD+9ZXQ8W-ZR+=TjSARV3kAeQ@mail.gmail.com>
2011-09-09 13:55     ` Larry Finger
2011-09-09 17:30       ` Semigod King
2011-09-14 21:22         ` Larry Finger
2011-09-16  7:12           ` Semigod King

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.