Bug 247528 - RTL8192EU usb wifi dongle can't connect to AP
Summary: RTL8192EU usb wifi dongle can't connect to AP
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-24 22:51 UTC by Mc James
Modified: 2020-09-13 12:47 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mc James 2020-06-24 22:51:07 UTC
Hi:
I have a very complex problem.
a dongle with this chipset won't work with FreeBSD SJD 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64.
furthermore this usb dongle gets disconnected after a couple of tries of wpa_supplicant (from pkg not the base system as the wpa_supplicant from the base system would crash at the first try)

dmesg outpout is strange .... while wpa_supplicant is running ....
usb_alloc_device: set address 2 failed (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=2, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 2 failed, USB_ERR_IOERROR
ugen5.2: <Unknown > at usbus5 (disconnected)
uhub_reattach_port: could not allocate new device
ugen7.2: <Realtek 802.11n NIC> at usbus7
rtwn0 on uhub0
rtwn0: <802.11n NIC > on usbus7
rtwn0: MAC/BB RTL8192EU, RF 6052 2T2R
wlan0: Ethernet address: d4:6e:0e:7f:51:67
wlan0: ieee80211_new_state_locked: pending SCAN -> AUTH transition lost





Please continue reading !!! the full context is here : 
https://forums.freebsd.org/threads/tp-link-tl-wn823n-v2-device-not-showing-up.75923/
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2020-06-25 01:59:55 UTC
^Triage: assign to usb@ but Cc: wireless@ in case someone there has a quick insight.
Comment 2 Kris 2020-06-29 01:44:04 UTC
i have almost same problem.

https://www.mail-archive.com/freebsd-usb@freebsd.org/msg14466.html
Comment 3 Danilo Egea Gondolfo freebsd_committer 2020-07-25 20:22:25 UTC
Exactly same problem here. I have a tplink wn823n (RTL8192EU).

The issue is easily reproducible. The device will get UP and things like scanning and adhoc mode will work fine. But if you "ifconfig down" the interface and "ifconfig up" it again it will stuck and the device will get disconnected from the USB bus.

This will make wpa_supplicant try to connect using WPA but it will fail:

ifconfig wlan0 create wlandev rtwn0
wpa_supplicant -i wlan0 -c...

Note that the interface is still down before running wpa_supplicant. wpa_supplicant will put the interface UP and try to connect although it will fail with authentication timeout.

If you put the interface UP yourself and then run wpa_supplicant it will fail and the device will be kicked out from the USB bus when it sends a second ioctl(... IFF_UP) to the interface.

So, the problem is reproducible with:

ifconfig wlan0 create wlandev rtwn0 up
ifconfig wlan0 down
ifconfig wlan0 up

The last command will stuck here:

17899 101638 ifconfig            -                   mi_switch+0xc1 _sleep+0x1cb taskqueue_drain+0xeb ieee80211_waitfor_parent+0x28 ieee80211_ioctl+0x44b ifhwioctl+0xbb2 ifioctl+0x419 kern_ioctl+0x25e sys_ioctl+0xfa amd64_syscall+0x119 fast_syscall_common+0x101 


And this is what happens:

ugen0.4: <Realtek 802.11n NIC> at usbus0
rtwn0 on uhub0
rtwn0: <802.11n NIC > on usbus0
rtwn0: MAC/BB RTL8192EU, RF 6052 2T2R
wlan1: Ethernet address: d0:37:45:0a:a3:81
ugen0.4: <Realtek 802.11n NIC> at usbus0 (disconnected)
rtwn0: at uhub0, port 1, addr 13 (disconnected)
rtwn0: r92e_power_off: failed to block Tx queues
rtwn0: detached
usb_alloc_device: set address 4 failed (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 4 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=4, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 4 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=4, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 4 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=4, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 4 failed, USB_ERR_IOERROR
usbd_req_re_enumerate: addr=4, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 4 failed, USB_ERR_IOERROR
ugen0.4: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
Comment 4 Danilo Egea Gondolfo freebsd_committer 2020-09-12 15:05:47 UTC
Regarding the ifconfig up and down issue, it seems that the function r92e_power_off() is breaking the firmware state machine.

According to the driver provided by the vendor [1], transitioning the device from Active to Low Power State consists of this sequence of steps [2]. The driver in fact does that (plus a few more actions) when you ifconfig down it.

In fact, interrupting the code after it moves the state machine to LPS (inserting a return; right here [3] for example) fixes the device-being-disconnected-from-the-bus issue, what is probably due to a crash in the firmware.

Hopefully it will provide some insight to whoever looks into this issue in the future.

It's still not working when used with wpa_supplicant. 

[1] - https://static.tp-link.com/TL-WN823N(EU)_V2_160315_Linux_1479970241132h.zip
[2] - https://gitlab.cosmoproducts.de/cosmocard/rtl8192eu-linux-driver/-/blob/c50f3f80b97a5ab2d2582021ae93e0a5f07118b7/include/Hal8192EPwrSeq.h#L106
[3] - https://github.com/freebsd/freebsd/blob/master/sys/dev/rtwn/rtl8192e/r92e_init.c#L327
Comment 5 Danilo Egea Gondolfo freebsd_committer 2020-09-13 12:47:30 UTC
I'm using it on hostap mode right now and it works perfectly. I'm accessing the internet in my smartphone through it.

wlan1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether d0:37:45:0a:a3:81
        inet6 fe80::d237:45ff:fe0a:a381%wlan1 prefixlen 64 scopeid 0x4
        inet 172.17.0.1 netmask 0xffffff00 broadcast 172.17.0.255
        groups: wlan
        ssid capetinha channel 10 (2457 MHz 11g ht/20) bssid d0:37:45:0a:a3:81
        regdomain NONE country UA authmode WPA2/802.11i privacy MIXED
        deftxkey 2 AES-CCM 2:128-bit txpower 30 scanvalid 60 protmode CTS ht20
        ampdulimit 64k ampdudensity 16 shortgi -stbc -ldpc -uapsd wme
        dtimperiod 1 -dfs
        parent interface: rtwn0
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11ng <hostap>
        status: running
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>