rt73usb on at91sam9260 WPA issue

Live forum: http://rt2x00.serialmonkey.com/viewtopic.php?t=5638

RushPL

19-09-2009 05:40:48

Dear rt2x00 gurus,

I'm trying to set up a rt73 based usb dongle on my ARM board. I have been successful to the point of connecting via ad-hoc and ordinary WEP for which I am grateful to the project developers, it's very cool but unfortunately far from 100% usable.
I have been unable to use WPA1 for which I get the following wpa_supplicant errors

[quote1k587e3k]
Trying to associate with 001cf069c28e (SSID='unimatrix' freq=2417 MHz)
Associated with 001cf069c28e
WPA Failed to set PTK to the driver.[/color1k587e3k]
Authentication with 001cf069c28e timed out.
CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
[/quote1k587e3k]
And as for WPA2 it gets somewhat farther, it associates
[quote1k587e3k]
root@robo> wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf &
CTRL-EVENT-SCAN-RESULTS
Trying to associate with 001cf069c28e (SSID='unimatrix' freq=2417 MHz)
Associated with 001cf069c28e
WPA Failed to set PTK to the driver.[/color1k587e3k] [i1k587e3k]- Maybe this is a problem, but no idea where it comes from.[/i1k587e3k]
WPA Key negotiation completed with 001cf069c28e [PTK=CCMP GTK=TKIP]
CTRL-EVENT-CONNECTED - Connection to 001cf069c28e completed (auth) [id=3 id_str=]
[/quote1k587e3k]

[quote1k587e3k]
root@robo> ssh 192.168.0.1
ssh connect to host 192.168.0.1 port 22 No route to host
[/quote1k587e3k]
but even though it shows to properly associate, I can't seem to connect anywhere, though ifconfig reports some data getting through, but I don't really know how to debug it.
[quote1k587e3k]
root@robo> ifconfig
wlan0 Link encapEthernet HWaddr 001F1F08E947
inet addr192.168.0.102 Bcast192.168.0.255 Mask255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU1500 Metric1
RX packets109 errors0 dropped0 overruns0 frame0
TX packets114 errors0 dropped0 overruns0 carrier0
collisions0 txqueuelen1000
RX bytes15155 (14.7 Kb) TX bytes15446 (15.0 Kb)
[/quote1k587e3k]

There are no unusual kernel warning/errors.

My kernel version is 2.6.30.5 from kernel.org with at91 patchset applied (which is not messing with the wireless stack).
I tried using rt2x00 from git but unfortunately the at91 patch does not yet apply cleanly on 2.6.31 tree, which makes me stuck with 2.6.30 until someone ports them.

I compile my system totally from scratch so it's not unreasonable that I might have missed something. I tried to use latest possible stable packages.

I would be grateful for some pointers on where to look and how to debug this issue.
I'm sorry if this proves to not be a bug in the driver.

Best Regards,
Damian Kaczmarek

RushPL

20-09-2009 21:51:09

I have further tracked the "Failed to set PTK to the driver"

in wext mode wpa_supplicant reports
[quoteundn3etx]
WPA Installing PTK to the driver.
wpa_driver_wext_set_key alg=3 key_idx=0 set_tx=1 seq_len=6 key_len=16
ioctl[SIOCSIWENCODEEXT] Cannot allocate memory
Driver did not support SIOCSIWENCODEEXT
WPA Failed to set PTK to the driver
[/quoteundn3etx]
and in nl80211
[quoteundn3etx]
WPA Installing PTK to the driver.
wpa_driver_nl80211_set_key alg=3 addr=0x6431c key_idx=0 set_tx=1 seq_len=6 key_len=16
addr=001cf069c28e
nl80211 set_key failed; err=-12
WPA Failed to set PTK to the driver.
[/quoteundn3etx]
Both of which report memory allocation erros, since err=-12 is -ENOMEM. It's weird because there's plenty of memory, including swap. I'll try to find out some more.

RushPL

21-09-2009 19:41:38

I boiled down the problem this morning. The following piece of code from aes_ccm.c was failing at me, namely aes allocation.
[code35nq76b6]
struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[])
{
struct crypto_cipher *tfm;

tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
return NULL;
}
[/code35nq76b6]
It made me check my kernel config but AES was there as a module. "modprobe aes" didn't help but later I checked that "lsmod" wasn't showing it (although modprobe didn't report any error)... it appeared that the module in question was named "aes_generic". Modprobing it solved the problem!! Hurray. I'm still pretty convinced that there's something wrong with the error reporting code, why would ENOMEM propagate? It's completely unfriendly, if "aes_generic" was put somewhere in the error message or maybe set a dependency for the driver I wouldn't have to dive into the kernel code. I would be happy to write a patch that properly reports the error, is something like this ok?
[code35nq76b6]
tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
printk("ieee80211: AES cipher allocation failed.");
return NULL;
}
[/code35nq76b6]