# 11n support for Ralink



## marslars (Jan 22, 2012)

Hi,

I'm fooling around with my lovely BSD-9.0-release server, and I have a D-link DWA-140 USB adapter, that's is using the RT3070 driver. I would like to play a bit with 11n-support, so I was just wondering how the development is going in this area? I found some drivers, but it seems that they are all older than the ones in CURRENT.


Thanks in advance guys,
best regards Lars


----------



## PseudoCylon (Jan 22, 2012)

All I have to do is fix high RX buffer overflow and CRC error rates. Due to lack of documentation, it may take a while. At least, I'm still working on it.

Check back in this repository https://gitorious.org/run/run/trees/11n_rc3


----------



## marslars (Jan 22, 2012)

*Very nice*

Hey,

Thanks for your answer 

Keep up the good work


----------



## huanghwh (Oct 6, 2012)

PseudoCylon said:
			
		

> All I have to do is fix high RX buffer overflow and CRC error rates. Due to lack of documentation, it may take a while. At least, I'm still working on it.
> 
> Check back in this repository https://gitorious.org/run/run/trees/11n_rc3


Hi,
I tried your 802.11n driver:

```
run0: <1.0> on usbus1
run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 1T1R), address 4c:e6:76:d4:c9:5e
run0: firmware RT2870 ver. 0.236 loaded
wlan0: Ethernet address: 4c:e6:76:d4:c9:5e
wlan0: link state changed to UP

root@mbp:/tmp/run-run/modules/usb/run # ifconfig run0
run0: flags=8a43<UP,BROADCAST,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> metric 0 mtu 2290
	ether 4c:e6:76:d4:c9:5e
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11ng
	status: associated
root@mbp:/tmp/run-run/modules/usb/run # ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 4c:e6:76:d4:c9:5e
	inet 10.0.1.5 netmask 0xff000000 broadcast 255.255.255.255
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
	status: associated
	ssid LHT channel 1 (2412 MHz 11g ht/20) bssid 7c:d1:c3:cf:f2:de
	country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
	AES-CCM 3:128-bit txpower 0 bmiss 7 scanvalid 60 protmode CTS
	ampdulimit 64k ampdudensity 8 shortgi wme roaming MANUAL
```
could not get ip from dhcp, and I set ip manually, but still could not ping wireless-router, any ideas?

--hwh


----------



## PseudoCylon (Oct 7, 2012)

Can you post your
wpa_supplicant.conf,
output of
`% uname -a` and wpa_supplicant(9) debug info (run with -d option)
`# wpa_supplicant [b]-d[/b] -i wlan0 -c /path/to/wpa_supplicant.conf`


----------



## huanghwh (Oct 7, 2012)

PseudoCylon said:
			
		

> Can you post your
> wpa_supplicant.conf,
> output of
> `% uname -a` and wpa_supplicant(9) debug info (run with -d option)
> `# wpa_supplicant [b]-d[/b] -i wlan0 -c /path/to/wpa_supplicant.conf`




```
# uname -a
FreeBSD mbp.gddsn.org.cn 9.1-RC2 FreeBSD 9.1-RC2 #8: Sun Oct  7 14:17:46 CST 2012     [email]root@mbp.gddsn.org.cn[/email]:/usr/obj/usr/src/sys/MACBOOK  amd64
# cat /etc/wpa_supplicant.conf
network={
        ssid="HWH"
	priority=10
        psk="87686302"
}

network={
	ssid="LHT"
	psk="87680280"
}
# ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 4c:e6:76:d4:c9:5e
	inet 10.0.1.5 netmask 0xffffff00 broadcast 10.0.1.255
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
	status: associated
	ssid HWH channel 11 (2462 MHz 11g ht/20) bssid 7c:d1:c3:d0:4e:c2
	country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
	AES-CCM 2:128-bit txpower 0 bmiss 7 scanvalid 60 protmode CTS
	ampdulimit 64k ampdudensity 8 shortgi wme roaming MANUAL

# wpa_supplicant -d -i wlan0 -c /etc/wpa_supplicant.conf
Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
Priority group 10
   id=0 ssid='HWH'
Priority group 0
   id=1 ssid='LHT'
Own MAC address: 4c:e6:76:d4:c9:5e
wpa_driver_bsd_del_key: keyidx=0
wpa_driver_bsd_del_key: keyidx=1
wpa_driver_bsd_del_key: keyidx=2
wpa_driver_bsd_del_key: keyidx=3
wpa_driver_bsd_set_countermeasures: enabled=0
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
Added interface wlan0
State: DISCONNECTED -> SCANNING
Starting AP scan for wildcard SSID
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
Received 1796 bytes of scan results (6 BSSes)
BSS: Start scan result update 1
BSS: Add new id 0 BSSID 7c:d1:c3:d0:4e:c2 SSID 'HWH'
BSS: Add new id 1 BSSID 84:c9:b2:06:87:b6 SSID ''
BSS: Add new id 2 BSSID 8c:21:0a:c9:30:98 SSID 'Cybertech'
BSS: Add new id 3 BSSID 8c:21:0a:b2:c5:ea SSID 'Zhuzhujia'
BSS: Add new id 4 BSSID b4:b3:62:09:48:d1 SSID 'ChinaNet-kpmz'
BSS: Add new id 5 BSSID f4:ec:38:21:7a:84 SSID 'TP-LINK_yuzhiwen'
New scan results available
Selecting BSS from priority group 10
Try to find WPA-enabled AP
0: 7c:d1:c3:d0:4e:c2 ssid='HWH' wpa_ie_len=0 rsn_ie_len=20 caps=0x31
   selected based on RSN IE
   selected WPA AP 7c:d1:c3:d0:4e:c2 ssid='HWH'
Trying to associate with 7c:d1:c3:d0:4e:c2 (SSID='HWH' freq=2462 MHz)
Cancelling scan request
WPA: clearing own WPA/RSN IE
Automatic auth_alg selection: 0x1
RSN: using IEEE 802.11i/D9.0
WPA: Selected cipher suites: group 16 pairwise 16 key_mgmt 2 proto 2
WPA: clearing AP WPA IE
WPA: set AP RSN IE - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: using GTK CCMP
WPA: using PTK CCMP
WPA: using KEY_MGMT WPA-PSK
WPA: Set own WPA IE default - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
No keys have been configured - skip key clearing
State: SCANNING -> ASSOCIATING
wpa_driver_bsd_associate: ssid 'HWH' wpa ie len 22 pairwise 3 group 3 key mgmt 1
wpa_driver_bsd_set_drop_unencrypted: enabled=1
wpa_driver_bsd_set_auth_alg alg 0x1 authmode 1
wpa_driver_bsd_associate: set PRIVACY 1
Setting authentication timeout: 10 sec 0 usec
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP fail=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portControl=Auto
EAPOL: Supplicant port status: Unauthorized
RX EAPOL from 7c:d1:c3:d0:4e:c2
Not associated - Delay processing of received EAPOL frame
State: ASSOCIATING -> ASSOCIATED
Associated to a new BSS: BSSID=7c:d1:c3:d0:4e:c2
No keys have been configured - skip key clearing
Associated with 7c:d1:c3:d0:4e:c2
WPA: Association event - clear replay counter
WPA: Clear old PTK
EAPOL: External notification - portEnabled=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portValid=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portEnabled=1
EAPOL: SUPP_PAE entering state CONNECTING
EAPOL: enable timer tick
EAPOL: SUPP_BE entering state IDLE
Setting authentication timeout: 10 sec 0 usec
Cancelling scan request
Process pending EAPOL frame that was received just before association notification
RX EAPOL from 7c:d1:c3:d0:4e:c2
Setting authentication timeout: 10 sec 0 usec
IEEE 802.1X RX: version=2 type=3 length=95
  EAPOL-Key type=2
  key_info 0x8a (ver=2 keyidx=0 rsvd=0 Pairwise Ack)
  key_length=16 key_data_length=0
  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 02
  key_nonce - hexdump(len=32): 93 6e 94 ee 7e 28 92 a3 e0 2b 9d fb e5 64 1b b1 18 1b ad 28 8f 47 11 8a 70 81 e9 af 29 43 a3 40
  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  key_rsc - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_mic - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
State: ASSOCIATED -> 4WAY_HANDSHAKE
WPA: RX message 1 of 4-Way Handshake from 7c:d1:c3:d0:4e:c2 (ver=2)
RSN: msg 1/4 key data - hexdump(len=0):
WPA: Renewed SNonce - hexdump(len=32): 80 ea be d5 a5 2e 7c 4d eb af 13 9f eb 53 03 ce 0c 9e 05 f1 32 75 ee f4 c1 da 42 94 bf 13 5a 7a
WPA: PTK derivation - A1=4c:e6:76:d4:c9:5e A2=7c:d1:c3:d0:4e:c2
WPA: PMK - hexdump(len=32): [REMOVED]
WPA: PTK - hexdump(len=48): [REMOVED]
WPA: WPA IE for msg 2/4 - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: Sending EAPOL-Key 2/4
RX EAPOL from 7c:d1:c3:d0:4e:c2
IEEE 802.1X RX: version=2 type=3 length=151
  EAPOL-Key type=2
  key_info 0x13ca (ver=2 keyidx=0 rsvd=0 Pairwise Install Ack MIC Secure Encr)
  key_length=16 key_data_length=56
  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 03
  key_nonce - hexdump(len=32): 93 6e 94 ee 7e 28 92 a3 e0 2b 9d fb e5 64 1b b1 18 1b ad 28 8f 47 11 8a 70 81 e9 af 29 43 a3 40
  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  key_rsc - hexdump(len=8): 64 00 00 00 00 00 00 00
  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_mic - hexdump(len=16): c6 28 d2 c1 16 f9 2c b6 44 df fb a3 15 73 99 9f
RSN: encrypted key data - hexdump(len=56): d5 84 f2 b9 dc 38 0c 47 ce ba 94 70 30 f1 8f 4c 1b 68 72 b9 3a 5d 22 74 dd 1c d2 c4 2c ad ff 0f eb dd 03 9d 59 01 e6 1f fe 39 7f 93 ea 4f 6c 9e 08 f6 ed e9 6e 3e 2b 05
WPA: decrypted EAPOL-Key key data - hexdump(len=48): [REMOVED]
State: 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE
WPA: RX message 3 of 4-Way Handshake from 7c:d1:c3:d0:4e:c2 (ver=2)
WPA: IE KeyData - hexdump(len=48): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 dd 16 00 0f ac 01 01 00 69 4c 35 9e 06 22 92 c9 47 be b8 dd 8c 15 45 45 dd 00
WPA: RSN IE in EAPOL-Key - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: GTK in EAPOL-Key - hexdump(len=24): [REMOVED]
WPA: Sending EAPOL-Key 4/4
WPA: Installing PTK to the driver.
wpa_driver_bsd_set_key: alg=CCMP addr=7c:d1:c3:d0:4e:c2 key_idx=0 set_tx=1 seq_len=6 key_len=16
EAPOL: External notification - portValid=1
State: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
RSN: received GTK in pairwise handshake - hexdump(len=18): [REMOVED]
WPA: Group Key - hexdump(len=16): [REMOVED]
WPA: Installing GTK to the driver (keyidx=1 tx=0 len=16).
WPA: RSC - hexdump(len=6): 64 00 00 00 00 00
wpa_driver_bsd_set_key: alg=CCMP addr=ff:ff:ff:ff:ff:ff key_idx=1 set_tx=0 seq_len=6 key_len=16
WPA: Key negotiation completed with 7c:d1:c3:d0:4e:c2 [PTK=CCMP GTK=CCMP]
Cancelling authentication timeout
State: GROUP_HANDSHAKE -> COMPLETED
CTRL-EVENT-CONNECTED - Connection to 7c:d1:c3:d0:4e:c2 completed (auth) [id=0 id_str=]
EAPOL: External notification - portValid=1
EAPOL: External notification - EAP success=1
EAPOL: SUPP_PAE entering state AUTHENTICATING
EAPOL: SUPP_BE entering state SUCCESS
EAP: EAP entering state DISABLED
EAPOL: SUPP_PAE entering state AUTHENTICATED
EAPOL: Supplicant port status: Authorized
EAPOL: SUPP_BE entering state IDLE
EAPOL authentication completed successfully
EAPOL: startWhen --> 0
EAPOL: disable timer tick
```

My AP is AirPort Express and WLAN is Buffalo WLI-UC-GN.

--hwh


----------



## PseudoCylon (Oct 8, 2012)

Try this patch.

```
diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
index a373e33..1b11508 100644
--- a/dev/usb/wlan/if_run.c
+++ b/dev/usb/wlan/if_run.c
[color="Blue"]@@ -3423,8 +3423,6 @@[/color] run_set_tx_desc(struct run_softc *sc, struct mbuf *m,
                *(uint16_t *)wh->i_dur = htole16(dur);
        }
 
[color="Red"]-       txwi->xflags |= tid == IEEE80211_NONQOS_TID ? RT2860_TX_NSEQ : 0;
-[/color]
        DPRINTFN(6, "wcid=%u ridx=%u phy=%x qid=%u txop=%x %s %s %s %s %s %s\n",
            txwi->wcid, ridx, txwi->phy >> 14, qid, txwi->txop,
            isdata ? "data" : "mgmt", txwi->phy & (1 << 7) ? "40Mhz" : "20Mhz",
```


----------



## huanghwh (Oct 9, 2012)

PseudoCylon said:
			
		

> Try this patch.
> 
> ```
> diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
> ...



I got the same result: could not ping wireless-router.

```
#dmesg
ugen1.3: <Ralink> at usbus1
run0: <1.0> on usbus1
run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 1T1R), address 4c:e6:76:d4:c9:5e
run0: firmware RT2870 ver. 0.17 loaded
wlan0: Ethernet address: 4c:e6:76:d4:c9:5e


# wpa_supplicant -d -i wlan0 -c /etc/wpa_supplicant.conf
Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
Priority group 10
   id=0 ssid='HWH'
Priority group 1
   id=2 ssid='QQQ'
Priority group 0
   id=1 ssid='LHT'
   id=3 ssid='gddsn'
   id=4 ssid='conghua'
   id=5 ssid='hwh___iphone'
   id=6 ssid='xinhuitai'
   id=7 ssid='igp602'
   id=8 ssid='Tenda_06E960'
   id=9 ssid='LM'
   id=10 ssid='sjr'
Own MAC address: 4c:e6:76:d4:c9:5e
wpa_driver_bsd_del_key: keyidx=0
wpa_driver_bsd_del_key: keyidx=1
wpa_driver_bsd_del_key: keyidx=2
wpa_driver_bsd_del_key: keyidx=3
wpa_driver_bsd_set_countermeasures: enabled=0
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state NO_KEY_RECEIVE
EAPOL: SUPP_BE entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
Added interface wlan0
State: DISCONNECTED -> SCANNING
Starting AP scan for wildcard SSID
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
Received 1204 bytes of scan results (6 BSSes)
BSS: Start scan result update 1
BSS: Add new id 0 BSSID 7c:d1:c3:d0:4e:c2 SSID 'HWH'
BSS: Add new id 1 BSSID c0:3f:0e:82:80:5f SSID 'QQQ'
BSS: Add new id 2 BSSID 00:1e:58:12:95:f2 SSID 'crj'
BSS: Add new id 3 BSSID 5c:63:bf:de:d8:80 SSID 'Tan'
BSS: Add new id 4 BSSID 00:15:6d:9a:44:da SSID 'gdyj2'
BSS: Add new id 5 BSSID 00:0f:b3:4b:ea:db SSID 'EDUP'
New scan results available
Selecting BSS from priority group 10
Try to find WPA-enabled AP
0: 7c:d1:c3:d0:4e:c2 ssid='HWH' wpa_ie_len=0 rsn_ie_len=20 caps=0x31
   selected based on RSN IE
   selected WPA AP 7c:d1:c3:d0:4e:c2 ssid='HWH'
Trying to associate with 7c:d1:c3:d0:4e:c2 (SSID='HWH' freq=2462 MHz)
Cancelling scan request
WPA: clearing own WPA/RSN IE
Automatic auth_alg selection: 0x1
RSN: using IEEE 802.11i/D9.0
WPA: Selected cipher suites: group 16 pairwise 16 key_mgmt 2 proto 2
WPA: clearing AP WPA IE
WPA: set AP RSN IE - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: using GTK CCMP
WPA: using PTK CCMP
WPA: using KEY_MGMT WPA-PSK
WPA: Set own WPA IE default - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
No keys have been configured - skip key clearing
State: SCANNING -> ASSOCIATING
wpa_driver_bsd_associate: ssid 'HWH' wpa ie len 22 pairwise 3 group 3 key mgmt 1
wpa_driver_bsd_set_drop_unencrypted: enabled=1
wpa_driver_bsd_set_auth_alg alg 0x1 authmode 1
wpa_driver_bsd_associate: set PRIVACY 1
Setting authentication timeout: 10 sec 0 usec
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP fail=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portControl=Auto
EAPOL: Supplicant port status: Unauthorized
RX EAPOL from 7c:d1:c3:d0:4e:c2
Not associated - Delay processing of received EAPOL frame
State: ASSOCIATING -> ASSOCIATED
Associated to a new BSS: BSSID=7c:d1:c3:d0:4e:c2
No keys have been configured - skip key clearing
Associated with 7c:d1:c3:d0:4e:c2
WPA: Association event - clear replay counter
WPA: Clear old PTK
EAPOL: External notification - portEnabled=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portValid=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - EAP success=0
EAPOL: Supplicant port status: Unauthorized
EAPOL: External notification - portEnabled=1
EAPOL: SUPP_PAE entering state CONNECTING
EAPOL: enable timer tick
EAPOL: SUPP_BE entering state IDLE
Setting authentication timeout: 10 sec 0 usec
Cancelling scan request
Process pending EAPOL frame that was received just before association notification
RX EAPOL from 7c:d1:c3:d0:4e:c2
Setting authentication timeout: 10 sec 0 usec
IEEE 802.1X RX: version=2 type=3 length=95
  EAPOL-Key type=2
  key_info 0x8a (ver=2 keyidx=0 rsvd=0 Pairwise Ack)
  key_length=16 key_data_length=0
  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 06
  key_nonce - hexdump(len=32): 26 52 42 73 ac 69 6d e4 29 62 b4 3f d1 17 36 40 b9 f5 7a 57 e9 ea 61 96 54 7c 28 80 cf a5 49 29
  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  key_rsc - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_mic - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
State: ASSOCIATED -> 4WAY_HANDSHAKE
WPA: RX message 1 of 4-Way Handshake from 7c:d1:c3:d0:4e:c2 (ver=2)
RSN: msg 1/4 key data - hexdump(len=0):
WPA: Renewed SNonce - hexdump(len=32): 4a 19 63 b8 05 97 b7 e3 f6 be ef 0e b5 ca 6a 56 3b 47 cf 9a 6a 2c f2 04 e1 86 da a6 b9 5c 7a 4e
WPA: PTK derivation - A1=4c:e6:76:d4:c9:5e A2=7c:d1:c3:d0:4e:c2
WPA: PMK - hexdump(len=32): [REMOVED]
WPA: PTK - hexdump(len=48): [REMOVED]
WPA: WPA IE for msg 2/4 - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: Sending EAPOL-Key 2/4
RX EAPOL from 7c:d1:c3:d0:4e:c2
IEEE 802.1X RX: version=2 type=3 length=151
  EAPOL-Key type=2
  key_info 0x13ca (ver=2 keyidx=0 rsvd=0 Pairwise Install Ack MIC Secure Encr)
  key_length=16 key_data_length=56
  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 07
  key_nonce - hexdump(len=32): 26 52 42 73 ac 69 6d e4 29 62 b4 3f d1 17 36 40 b9 f5 7a 57 e9 ea 61 96 54 7c 28 80 cf a5 49 29
  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  key_rsc - hexdump(len=8): cc 08 00 00 00 00 00 00
  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_mic - hexdump(len=16): c1 04 f4 9a af 70 09 33 11 93 b2 1e 41 30 26 07
RSN: encrypted key data - hexdump(len=56): 01 76 10 ec aa d2 a5 6f 43 ac 5a c6 ed 6c eb d6 02 73 b7 58 91 78 8b ed b3 45 81 bd d2 a1 2d 32 10 9d 74 45 ba 64 e0 00 d5 db fa 24 47 39 a5 ed 23 02 ed 66 fa 54 8b 0d
WPA: decrypted EAPOL-Key key data - hexdump(len=48): [REMOVED]
State: 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE
WPA: RX message 3 of 4-Way Handshake from 7c:d1:c3:d0:4e:c2 (ver=2)
WPA: IE KeyData - hexdump(len=48): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00 dd 16 00 0f ac 01 02 00 e7 81 f7 83 11 da c3 01 68 5f a9 f8 8a fd cc 92 dd 00
WPA: RSN IE in EAPOL-Key - hexdump(len=22): 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 00 00
WPA: GTK in EAPOL-Key - hexdump(len=24): [REMOVED]
WPA: Sending EAPOL-Key 4/4
WPA: Installing PTK to the driver.
wpa_driver_bsd_set_key: alg=CCMP addr=7c:d1:c3:d0:4e:c2 key_idx=0 set_tx=1 seq_len=6 key_len=16
EAPOL: External notification - portValid=1
State: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
RSN: received GTK in pairwise handshake - hexdump(len=18): [REMOVED]
WPA: Group Key - hexdump(len=16): [REMOVED]
WPA: Installing GTK to the driver (keyidx=2 tx=0 len=16).
WPA: RSC - hexdump(len=6): cc 08 00 00 00 00
wpa_driver_bsd_set_key: alg=CCMP addr=ff:ff:ff:ff:ff:ff key_idx=2 set_tx=0 seq_len=6 key_len=16
WPA: Key negotiation completed with 7c:d1:c3:d0:4e:c2 [PTK=CCMP GTK=CCMP]
Cancelling authentication timeout
State: GROUP_HANDSHAKE -> COMPLETED
CTRL-EVENT-CONNECTED - Connection to 7c:d1:c3:d0:4e:c2 completed (auth) [id=0 id_str=]
EAPOL: External notification - portValid=1
EAPOL: External notification - EAP success=1
EAPOL: SUPP_PAE entering state AUTHENTICATING
EAPOL: SUPP_BE entering state SUCCESS
EAP: EAP entering state DISABLED
EAPOL: SUPP_PAE entering state AUTHENTICATED
EAPOL: Supplicant port status: Authorized
EAPOL: SUPP_BE entering state IDLE
EAPOL authentication completed successfully
EAPOL: startWhen --> 0
EAPOL: disable timer tick
```


----------



## SirDice (Oct 9, 2012)

Please use pastebin or something similar for large outputs.


----------



## PseudoCylon (Oct 10, 2012)

more patch
[NB] The previous patch is still required.
	
	



```
diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
index 1b11508..86cea94 100644
--- a/dev/usb/wlan/if_run.c
+++ b/dev/usb/wlan/if_run.c
[color="Blue"]@@ -1978,9 +1978,22 @@[/color] run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
        sc->ratectl_run = RUN_RATECTL_OFF;
        usb_callout_stop(&sc->ratectl_ch);
 
[color="Red"]-       if (ostate == IEEE80211_S_RUN) {[/color]
[color="Green"]+       switch (ostate) {
+       case IEEE80211_S_RUN:[/color]
                /* turn link LED off */
                run_set_leds(sc, RT2860_LED_RADIO);
[color="Green"]+               break;
+       case IEEE80211_S_INIT:
+               if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
+                   vap->iv_opmode == IEEE80211_M_MBSS)
+                       break;
+
+               /* clear encryption key table */
+               run_set_region_4(sc, RT2860_SKEY(0, 0), 0, 1024);
+               run_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4);
+               break;
+       default:
+               break;[/color]
        }
 
        switch (nstate) {
@@ -2006,7 +2019,7 @@ run_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
                 * Clear key table only when the device is being brought down.
                 * Hostapd might have set the key.
                 */
[color="Red"]-               run_set_region_4(sc, RT2860_SKEY(0, 0), 0, 128);[/color]
[color="Green"]+               run_set_region_4(sc, RT2860_SKEY(0, 0), 0, 1024);[/color]
                run_set_region_4(sc, RT2860_SKEY_MODE_0_7, 0, 4);
 
                break;
```


----------



## huanghwh (Oct 11, 2012)

PseudoCylon said:
			
		

> more patch
> [NB] The previous patch is still required.
> 
> 
> ...


Still does not work, same result, any test I can do?
--hwh


----------



## PseudoCylon (Oct 12, 2012)

Try following in order, and let me know what the debug messages say.

`# ifconfig wlan create wlandev run0`
`# sysctl hw.usb.run.debug=1`
`# wpa_supplicant -B -i wlan0 -c /wherever/wpa_supplicant.conf`
`# dhclient wlan0`

Does AirPort produce any log regarding to DHCP?


----------



## huanghwh (Oct 13, 2012)

http://pastebin.com/yVBLNg4P

Note, still not get ip from dhcp.
From AirPort utility, I can only see my MAC address "4c:e6:76:d4:c9:5e" connected, no ip.
But link rate is 65Mb/s, mode still 802.11b/g, I see the link rate of other 8012.11n is about 300Mb/s.
--hwh


----------



## PseudoCylon (Oct 13, 2012)

What do you mean by not getting ip? The log says dhclient has received it.

```
Oct 13 09:16:55 mbp dhclient: New IP Address (wlan0): 10.0.1.5
Oct 13 09:16:55 mbp dhclient: New Subnet Mask (wlan0): 255.255.255.0
Oct 13 09:16:55 mbp dhclient: New Broadcast Address (wlan0): 10.0.1.255
Oct 13 09:16:55 mbp dhclient: New Routers (wlan0): 10.0.1.1
Oct 13 09:16:56 mbp dhclient: New Routers (wlan0): 10.0.1.1
```



			
				huanghwh said:
			
		

> But link rate is 65Mb/s, mode still 802.11b/g,


These statments are conflicting each other. The max Tx rate for G mode is 54mbps. 65 > 54, so it is running in N mode.




			
				huanghwh said:
			
		

> I see the link rate of other 8012.11n is about 300Mb/s.


The AMRR will change the Tx rate based on Tx success/failure rate. Once more Tx is generated, it will go up. But, because your device has 1T1R radio chip, the max rate is 150mbps. This is a hardware limitation.


----------



## huanghwh (Oct 14, 2012)

PseudoCylon said:
			
		

> What do you mean by not getting ip? The log says dhclient has received it.
> 
> ```
> Oct 13 09:16:55 mbp dhclient: New IP Address (wlan0): 10.0.1.5
> ...



Thank you for your explanation.
About dhcp, I also noticed these log messages, but really no ip with ifconfig checking.

There are some dhcp cache files /var/db/dhclient.leases.* in my system.
I test your driver again, the dhcp messages are gone after I deleted the files /var/db/dhclient.leases, ifconfig command give me ip 0.0.0.0.

--hwh


----------



## PseudoCylon (Oct 15, 2012)

Does /dev/bpf0 present?

Can you try without encryption and see if it works?


----------



## huanghwh (Oct 16, 2012)

PseudoCylon said:
			
		

> Does /dev/bpf0 present?
> 
> Can you try without encryption and see if it works?


Yes, I am using GENERIC kernel config file.

In case of without encryption:
For WLI-UC-G300N(MIMO 2T2R), same result as before.
For WLI-UC-GNM(MIMO 1T2R), wlan0 status is "no carrier".

Of cause, both of them work with the version in the 9.1.

Thanks, 
--hwh


----------



## PseudoCylon (Oct 17, 2012)

You cannot throw random info in. First, you said,





			
				huanghwh said:
			
		

> My AP is AirPort Express and WLAN is Buffalo *WLI-UC-GN*.


Now,





			
				huanghwh said:
			
		

> For *WLI-UC-G300N*(MIMO 2T2R), same result as before.
> For *WLI-UC-GNM*(MIMO 1T2R), wlan0 status is "no carrier".


Some recapping would be nice. While you are writing, keep in mind that I don't know anything what is going on at you place.

In the mean time, I just go for _same result as before_, so that encryption is working. Try capture bootp packets with`# tcpdump -v wlan0 port bootpc or port bootps`after association but before dhclient.

And,`# ifconfig -v wlan0 list scan | grep [i]SSID of AirPort[/i]`would be helpful. (Do this after ifconfig wlan0 up or wpa_supplicant and wait for about 10 sec.)


----------



## huanghwh (Oct 18, 2012)

PseudoCylon said:
			
		

> You cannot throw random info in. First, you said,Now,Some recapping would be nice. While you are writing, keep in mind that I don't know anything what is going on at you place.
> 
> In the mean time, I just go for _same result as before_, so that encryption is working. Try capture bootp packets with`# tcpdump -v wlan0 port bootpc or port bootps`after association but before dhclient.
> 
> And,`# ifconfig -v wlan0 list scan | grep [i]SSID of AirPort[/i]`would be helpful. (Do this after ifconfig wlan0 up or wpa_supplicant and wait for about 10 sec.)


I am very sorry, my bad, "Buffalo WLI-UC-GN" should be Buffalo WLI-UC-GNM:

```
# dmesg|grep run0
run0: <1.0> on usbus1
run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 1T1R), address 4c:e6:76:d4:c9:5e
run0: firmware RT2870 ver. 0.17 loaded
```

Now I am using WLI-UC-GNM, try this command `# tcpdump -v -i wlan0 port bootpc or port bootps` after association but before dhclient, but capture nothing.
If after dhclient, I can capture some bootpc packets.



```
# ifconfig -v wlan0 list scan|grep HWH
HWH                              7c:d1:c3:d0:4e:c2   11   54M -77:-92  100 EPS  SSID<HWH> RATES<B2,B4,B11,B22,12,18,24,36> DSPARMS<11> TIM<050400030000> COUNTRY<CN  1-11,30> ERP<0x2> XRATES<48,72,96,108> RSN<v1 mc:TKIP uc:AES-CCMP+TKIP km:8021X-PSK> HTCAP<cap 0x51ad param 0x1b mcsset[0-15] extcap 0x0 txbf 0x0 antenna 0x0> HTINFO<ctl 11, 0,17,0,0 basicmcs[]> WPA<v1 mc:TKIP uc:TKIP km:8021X-PSK> WME<qosinfo 0x1 BE[aifsn 3 cwmin 4 cwmax 10 txop 0] BK[aifsn 7 cwmin 4 cwmax 10 txop 0] VO[aifsn 2 cwmin 3 cwmax 4 txop 94] VI[aifsn 2 cwmin 2 cwmax 3 txop 47]> VEN<dd0700039301730320> VEN<dd0e0017f207000101067cd1c3d04ec2> VEN<dd0b0017f20100010100000007>
```


----------

