xtknight / mt7610u-linksys-ae6000-wifi-fixes

Trying to fix the MT7610U chipset driver by MediaTek so it's usable on modern Linux kernels and with nl80211/NetworkManager (and not completely breaking on old ones, maybe...)
187 stars 71 forks source link

Does only establish a 54MBit connection #2

Closed mkreisl closed 8 years ago

mkreisl commented 8 years ago

At least in a 2.4G network this driver only establishes a 54MBit (11g) connection.

If the AP is configured for 11n only, no connection is possible. Tested a ftp download, speed is up to 2,9MByte/s, so its really only 54MBit. The entries in RT2870STA.dat file seems to be completely ignored, but the file must exist (already checked).

(tested on a i5 noteook with kernel 4.1.13 and Raspberry Pi 2 with kernel 4.4.3)

Used stick: TP-Link Archer T2U AC600

xtknight commented 8 years ago

EDIT: I see. I misread your post. So you mean when you set your AP to 11n only, you cannot connect to it at all with this adapter? Even if you put the adapter right next to the router?

That is interesting. I readily connect to 2.4G routers at >54 MBps speeds (sometimes 100). However, that is only the bitrate shown in iwconfig. Right now I normally test with Comcast xfinitywifi hotspots, and as a more-or-less public network of course speeds are quite limited in reality.

Have you tried transferring files over LAN to eliminate potential WAN bottlenecks? I will test my adapter over LAN transferring files from my wireless to a wired computer and see what I get. At any rate, it probably isn't an issue with the mode-setting but there might be something else holding back the speed. (Note, the configuration file bitrate and mode parameters don't do a whole lot. I have already experienced this. I tried to force the 802.11 a/b/g and it insisted on connecting at N speeds. Kind of the opposite of your problem. I really want to fix this too, because G could offer better range.)

Also, what kind of TX bitrate do you see if you use the 'iw' and 'iwconfig' utilities? (Note this particular example is not using this adapter.)

$ sudo iw wlan4 link Connected to xx (on wlan4) SSID: dd-wrt freq: 2437 RX: 5619519 bytes (22032 packets) TX: 601679 bytes (4562 packets) signal: -56 dBm tx bitrate: 72.2 MBit/s MCS 7 short GI

As you can see, 72.2 MBit/s can mean either 802.11n or 802.11ac, although in this case it's N because I don't have an AC router. But it also means that 802.11n can even go down to 7.2 MBit/s in some cases, at least according this page. I don't know if that happens in reality, but it's worth considering that even though you might be operating in 802.11N mode, you aren't necessarily going to get N bitrates. It's worth some further research perhaps.

https://en.wikipedia.org/wiki/IEEE_802.11#Protocol

xtknight commented 8 years ago

With LInksys AE6000 and WirelessMode=5(a/b/g/n) or 6(n only), I get an 802.11n connection. My router has DD-WRT and was forced to 802.11n during testing. It seems fixed at 65 MBit. (Not sure why it's not 108, but anyway, even the router says only 65.) Note after changing config it might be necessary to reload the module.

vi /etc/Wireless/... conf file ifconfig ra0 down rmmod mt7610u_sta modprobe mt7610u_sta

I pasted my dd-wrt configuration on the terminal.

80211n-mt7610u

mkreisl commented 8 years ago

Done from my notebook

Connected to xx:xx:xx:xx:xx:xx (on ra0)
        SSID: BigBellN
        freq: 2472
        signal: -70 dBm
        tx bitrate: 54.0 MBit/s

Don't have any bottleneck

Did this from my RPi2 with a 8192cu driven device:

ftp> get D.N.1969.Das.Superhirn.avi /dev/null
local: /dev/null remote: D.N.1969.Das.Superhirn.avi
200 EPRT command successful. Consider using EPSV.
150 Opening BINARY mode data connection for D.N.1969.Das.Superhirn.avi (1337602458 bytes).
226 Transfer complete.
1337602458 bytes received in 130.10 secs (9.8047 MB/s)
mkreisl commented 8 years ago

And tha'ts mine

enp1s0f0  no wireless extensions.

vmnet1    no wireless extensions.

vmnet8    no wireless extensions.

wlp2s0    IEEE 802.11bgn  ESSID:"BigBellN"  
          Mode:Managed  Frequency:2.472 GHz  Access Point: xx:xx:xx:xx:xx   
          Bit Rate=1 Mb/s   Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=64/70  Signal level=-46 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:138   Missed beacon:0

ra0       Ralink STA  ESSID:"BigBellN"  Nickname:"MT7610U_STA"
          Mode:Managed  Frequency=2.472 GHz  Access Point: xx:xx:xx:xx:xx:xx   
          Bit Rate=54 Mb/s   
          RTS thr:off   Fragment thr:off
          Encryption key:xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx   Security mode:open
          Link Quality=100/100  Signal level:-44 dBm  Noise level:-79 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

lo        no wireless extensions.

And this is my 8192cu driven on RPi2:

wlan0     IEEE 802.11bgn  ESSID:"BigBellN"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.472 GHz  Access Point: xx:xx:xx:xx:xx:xx
          Bit Rate:144.4 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level=84/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

sit0      no wireless extensions.

lo        no wireless extensions.

eth0      no wireless extensions.
xtknight commented 8 years ago

Yeah, even at signal quality 100/100, it connects at 54 MBit. I don't know what to say. I wonder if it's an incompatibility between your router and the chipset. Of course, more likely a bug in the driver but I would have no idea how to fix it especially because I can't reproduce the problem. What model and brand of router do you have? Have you had a chance to try any other routers? It would be good to limit the problem to a specific router-adapter combination or maybe just that adapter itself.

mkreisl commented 8 years ago

Sure, it's very hard for you figuring out what's going on, but I appreciate your help vey much

Just changed my AP, now using a hostapd driven AP with this WLAN dongle http://www.amazon.de/TP-Link-TL-WN822N-High-Gain-Antenne-USB-Verl%C3%A4ngerungskabel-unterst%C3%BCtzt/dp/B00416Q5KI

Still having only a 54MBit connection (8192CU driven now has 300MBit)

xtknight commented 8 years ago

I notice you're connected at 2472 MHz which is only available in Europe and Japan. I wonder if this adapter is working properly for that. I am in the US with frequency 2437 MHz. The adapter does have settings for the region in the configuration file, but I don't know if they change anything.

Have you thoroughly tried the country and region settings here? http://hprath.com/2014/06/cisco-linksys-ae6000-ac580-media-tek-mt7610u-mt7630u-mt7650u-linux-x64-driver-patch/

Some of these I'm not even sure what the proper settings would be.

CountryRegion CountryRegionABand CountryCode ChannelGeography

I would also be curious to see if changing the channel on the AP to something available in both the US and Europe range has any effect.

mkreisl commented 8 years ago

I also tried different channels yesterday - no difference

Usually I'm using this AP (gotten from my cable provider) http://www.hitrontech.com/en/cable_detail.php?id=13

Edit: my hostapd is using channel 6

mkreisl commented 8 years ago

Just tried the speed with 8192cu driven device and hostapd AP:

ftp> get D.N.1969.Das.Superhirn.avi /dev/null
local: /dev/null remote: D.N.1969.Das.Superhirn.avi
200 EPRT command successful. Consider using EPSV.
150 Opening BINARY mode data connection for D.N.1969.Das.Superhirn.avi (1337602458 bytes).
226 Transfer complete.
1337602458 bytes received in 83.60 secs (15.2595 MB/s)

Really fast :smile:

xtknight commented 8 years ago

Actually I have a TP-LINK TL-WN722N (the 150 MBit version) hooked up to a custom SMA antenna, although not as my AP.

But importantly, the 300 MBit version you showed me is probably using dual-band, right? I was going to mention that perhaps MT7610U chipset does not work with dual-band 802.11n (MIMO). I don't know for sure. So that means you might have to set the AP to 20 MHz instead of 40 MHz (MIMO). I'm assuming it should be backwards compatible, but perhaps it's not.

mkreisl commented 8 years ago

No, no dualband. only 2 antennas and 2x2 mimo streams

And yes, with my router I'm only using 20MHz, hostapd uses 40MHz

But again, everything makes no difference for T2U: always only 54MBit

Btw, the 8192cu device is this one: http://www.tp-link.com/en/products/details/cat-11_TL-WN823N.html

xtknight commented 8 years ago

Oh, yes, it seems like I've confused the terms. I've never even used a MIMO or dual-band router, so I'm not sure. But I wonder if changing either the MT7610U to use 40 MHz somehow or changing the AP to be non-MIMO mode would help, even perhaps reveal a bug. Maybe the AP advertises a certain mode when it sends a beacon and perhaps the MT7610U thinks it can't support it, even if it can (which would be a bug). Anyway, I guess trying to limit the bug to a certain configuration or combination of devices would be the best thing you could do at this point.

mkreisl commented 8 years ago

Any changes to come closer to the issue are welcome :+1:

mkreisl commented 8 years ago

It's really confusing me why 11n does not work, maybe this is an issue of the TP-Link dongle

(with the hostapd I don't see an opportunity to use 11n only, but IMO dd-wrt also uses hostapd, so it should work, somehow)

xtknight commented 8 years ago

Well, guess what.. I can reproduce a similar issue. Somehow I set my dd-wrt to 40 MHz and 144 MBit/s (never tried before.) But indeed the MT7610U insists on using a lower speed, even though it's right next to the router. This is comparing with my ASUS rtl8187 adapter. I'll see what I can do to fix this.

# iwconfig 
ra0       Ralink STA  ESSID:"dd-wrt"  Nickname:"MT7610U_STA"
          Mode:Managed  Frequency=2.462 GHz  Access Point: xx
          Bit Rate=65 Mb/s   
          RTS thr:off   Fragment thr:off
          Encryption key:xx [2]   Security mode:open
          Link Quality=100/100  Signal level:-40 dBm  Noise level:-40 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan4     IEEE 802.11bgn  ESSID:"dd-wrt"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.462 GHz  Access Point: xx   
          Bit Rate:144.4 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level=100/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
mkreisl commented 8 years ago

Seems the difference to me is: your connection is fixed to 65, mine to 54 mbit :smile:

Hopefully you'll found a solution

xtknight commented 8 years ago

Apparently several factors can lead to falling back to 802.11g. Check that WMM is on (there's a flag in the config, but hard to tell if it's really on) and that Authentication is WPA2 AES ONLY (not TKIP). Mine is set to AES and WMM is enabled on the router. I know WMM definitely makes a difference. It's often strictly enforced.

https://www.dd-wrt.com/wiki/index.php/Wireless-N_Configuration#Basic_Configuration

I'm continuing to look at the code and also trying to force it to 40MHz, but not much success yet. I'm not clear that the 40MHz issue is the problem you're experiencing or not, but I just want to get this adapter to 144 MBit if possible.

xtknight commented 8 years ago

I changed the channel of my router and then my hacked mt7610u driver forced 40MHz and managed to connect. Ultimately the mt7610u managed to beat my ASUS rtl8187 adapter.

mt7610u(40MHz/~122Mbit mode): 9.75Mbyte/sec rtl8187(40MHz/~144Mbit mode): 8.27Mbyte/sec mt7610u(20MHz/~65Mbit mode): ~4.00Mbyte/sec (or less: really slow, didn't even finish it)

Even though the rtl8187 claimed up to 300MBits support.

But the code is a complete hack. I'm going to post it on a branch so you can try it. Maybe if it fixes anything I'll put it on the main branch.

xtknight commented 8 years ago

Try to pull the branch 40mhzhack https://github.com/xtknight/mt7610u-linksys-ae6000-wifi-fixes/tree/40mhzhack

But, it's unreliable. It seems like half of the time the adapter gets the fast speed, and half the time it gets the slow speed. It has added logging and you can check dmesg. The most important one is probably this one: [153421.630398] AdjustChannelRelatedValue(): BW_40 below. If it says BW_40 after this it should be in 40MHz mode.

[153421.630384] RTMPCheckHt:: HtCapInfo.ChannelWidth=1, RecomWidth=1, DesiredHtPhy.ChannelWidth=1, BW40MAvailForA/G=0/0, PhyMode=31 
[153421.630387] PeerBeaconAtJoinAction(): HT-CtrlChannel=8, CentralChannel=>6
[153421.630389] PeerBeaconAtJoinAction(): Set CentralChannel=6
[153421.630391] PeerBeaconAtJoinAction(): - after JOIN, SupRateLen=8, ExtRateLen=4
[153421.630393] PeerBeaconAtJoinAction(): pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth=BW_40
[153421.630396] AdjustChannelRelatedValue():CentralChannel=6, Channel=8, ChannelWidth=1
[153421.630398] AdjustChannelRelatedValue(): BW_40 below
[153421.630400] AdjustChannelRelatedValue(): Input BW=1, rf_channel=6, vht_bw=1, Channel=8, vht_cent_ch=0!
[153421.647938] AdjustChannelRelatedValue():BW_40, RF-Ch=6, CtrlCh=8, HT-CentralCh=6

See if this branch does anything for you. Seems to be no need to change the default configuration file. However, this only works when I put my router on lower channels. It didn't work with channels 11/13. Only 7/9, 6/8.

However it does go to 40MHz when it can, even while connected. When it's working well it looks like this. But otherwise you get stuck at 65Mbit or 54Mbit, etc...

$ sudo iwconfig
ra0       Ralink STA  ESSID:"dd-wrt"  Nickname:"MT7610U_STA"
          Mode:Managed  Frequency=2.447 GHz  Access Point: x   
          Bit Rate=135 Mb/s   
          RTS thr:off   Fragment thr:off
          Encryption key:xxx [2]   Security mode:open
          Link Quality=100/100  Signal level:-52 dBm  Noise level:-100 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
mkreisl commented 8 years ago

Nothing changed - still 54MBit. And before you're asking: yes, I unloaded module :smile:

Using channel 6 now

Got some strange error messages, here is my logfile (only kernel messages included) http://paste.ubuntu.com/15299357/

Do you also have this error message(s)?

mkreisl commented 8 years ago

Check that WMM is on (there's a flag in the config, but hard to tell if it's really on) and that Authentication is WPA2 AES ONLY (not TKIP). Mine is set to AES and WMM is enabled on the router. I know WMM definitely makes a difference. It's often strictly enforced.

WMM is enabled and only AES is used (TKIP is disabled)

mkreisl commented 8 years ago

Does you get the RT2870STA.dat read error?

I found this snipped of code https://www.howtoforge.com/reading-files-from-the-linux-kernel-space-module-driver-fedora-14, but it also does not read the file, it crashes the system, because the fd_op->read does not exist. So, this config file seems to be useless

When I run iw list, I see only one band for this device (2.4G) the second Band for 5G will never be listed

Edit: this works http://paste.ubuntu.com/15302683/ using vfs_read()

xtknight commented 8 years ago

I don't think I get a read error on RT2870STA.dat. My permissions are as follows. As long as root can read it should probably be fine from kernel mode, I guess? Is that code snippet in the kernel module somewhere?

$ ls -al /etc/Wireless/RT2870STA/ -rw-r--r-- 1 root root 1270 Mar 6 13:57 RT2870STA.dat

I updated the 40mhzhacks branch. Now there should be more logging. Can you give it a try and post the log (since starting a connection to AP to 30 seconds after association finished?)

It will be a long log because it logs every PeerBeacon information packet.

In my case, I can associate with my AP in 40 MHz mode right after changing AP settings but after 5 minutes or so, AP suddenly changes me back to 20 MHz mode and I'm stuck at slow speed. I haven't figured out why the AP is doing this. Even after forcing 40 MHz mode on the adapter, it refuses to connect to the AP: the AP is definitely in 20 MHz mode. Also, during scan when the adapter switches to 20 MHz mode, the connection suddenly starts working, but stops working after forced 40 MHz mode.

There are a few factors I'm looking for in the logs (but I would like to see the whole log anyway):

Also, I realized that if non 802.11-n clients (a/b/g) connect to the AP, every client's speed can be affected. I want to see what happens if you connect only the MT7610U to your AP.

-- Also, it seems to me that the RT2870STA.dat could possibly be overwritten if it exists during make install. I'm not sure. I'll have to investigate that.

mkreisl commented 8 years ago

I don't think I get a read error on RT2870STA.dat. My permissions are as follows. As long as root can read it should probably be fine from kernel mode, I guess? Is that code snippet in the kernel module somewhere?

Yes, this part of code reads the .DAT file. And this fails because the fd_op->read does not exist

What is your file system at your root partition? mine is BTRFS and I assume that this read method is not supported by this fs (unfortunately don't have an ext4 system for testing)

Will try it ASAP

xtknight commented 8 years ago

Okay, it seems like on new kernels that may happen. I'll check out the code that reads the config file and try to fix it.

mkreisl commented 8 years ago

This is my log file with new module compiled http://paste.ubuntu.com/15311980/

Thats what I get:

Mar  6 20:22:23 kmnote5 kernel: [ 2762.988794] no file read method
Mar  6 20:22:23 kmnote5 kernel: [ 2762.988795] Read file "/etc/Wireless/RT2870STA/RT2870STA.dat" failed(errCode=-1)!

no file read method means file can be opened but not read

Would be interesting if you could put a 0 bytes RT2870STA.dat.in the /etc/Wireless folder and see what happens ...

xtknight commented 8 years ago

Ohhh. Mine is ext4. Yes, I believe the file systems implement some of those read functions (like AIO read etc) on their own. Maybe it's not implemented for btrfs. The function used in the module is clearly still in the latest kernel and I haven't seen the errors on my brand new kernel machine with ext4, either. Also, the new MT7612U still uses this function, which is a good indication it still works. http://lxr.free-electrons.com/source/fs/open.c#L984

I wonder why they killed it... http://lkml.iu.edu/hypermail/linux/kernel/0801.2/0210.html

I'll try to change the functions to use an alternative method or look and see what the current modules do (maybe the vfs one).

I opened a separate bug for that. I'll investigate more after we figure out what's going on with your 802.11n.

xtknight commented 8 years ago

So from looking at the new log, it seems like your AP is recommending to run at 40 MHz, but the adapter is stuck at 20 MHz for some reason. And, it doesn't even seem like WMM is getting enabled or that 802.11n is even enabled. That part is even stranger. Can you type this?

$ sudo iwpriv ra0 get_site_survey

Mine shows like this (though the router is set to "N-Only mode"): 6 dd-wrt xx:xx:xx:xx:xx:xx WPA2PSK/AES 100 11b/g/n NONE In

mkreisl commented 8 years ago

That's the main issue: driver does not recognize 11n

ra0       get_site_survey:
Ch  SSID                             BSSID               Security               Siganl(%)W-Mode  ExtCH  NT
1   FRITZ!Box 6360 Cable             c0:25:06:42:8e:21   WPA1PSKWPA2PSK/TKIPAES 55       11b/g/n ABOVE  In
1   WLAN-0024FE947921                00:24:fe:94:79:21   WPA1PSKWPA2PSK/TKIPAES 15       11b/g/n ABOVE  In
1   Telekom_FON                      b8:bc:1b:62:c1:f2   NONE                   20       11b/g/n NONE   In
5   CPoint                           34:08:04:25:fc:14   WPA1PSKWPA2PSK/TKIPAES 26       11b/g/n NONE   In
6   BigBellN                         64:70:02:23:80:78   WPA2PSK/AES            68       11b/g/n ABOVE  In
7                                    34:81:c4:ee:ff:c7   WPA2PSK/AES            60       11b/g/n NONE   In
9   WLAN_57438954                    00:09:4f:6f:40:99   WPA1PSKWPA2PSK/TKIPAES 13       11b/g/n NONE   In
11  FRITZ!Box 7362 SL                c8:0e:14:7e:5f:dd   WPA2PSK/AES            26       11b/g/n NONE   In
10  Dj Hap                           9c:c7:a6:9c:e9:34   WPA2PSK/AES            15       11b/g/n NONE   In
xtknight commented 8 years ago

Try this: it will read what's in the internal config. $ sudo iwpriv ra0 show WirelessMode

mkreisl commented 8 years ago

ra0 show: 11B/G

xtknight commented 8 years ago

Try to force to 11n: $ sudo iwpriv ra0 set WirelessMode=6

Does anything happen differently in the logs? After running this command it should automatically re-associate.

xtknight commented 8 years ago

Reason is, your config file can't be read and everything is 0 by default. Option 0 is b/g only. So I'll work on fixing the config file. I wonder what else is also screwed up when the config file can't be read at all.

mkreisl commented 8 years ago

$ sudo iwpriv ra0 set WirelessMode=6

Does completely NOTHING

Reason is, your config file can't be read and everything is 0 by default. Option 0 is b/g only. So I'll work on fixing the config file. I wonder what else is also screwed up when the config file can't be read at all.

Agree (that's why I was asking what happens on your system if you put a 0-byte length .DAT file in your Wireless folder)

xtknight commented 8 years ago

I made a 0 byte file, and it gets stuck and refuses to connect. Basically nothing works. I think many other settings are necessary. So, I will work on fixing the config file reading and maybe that will fix all the issues you're having. Also I'll try to eliminate the necessity for this config file in the first place. I don't know why it's necessary. I'll allow it but also allow it to be 0 byte and still operate fine.

mkreisl commented 8 years ago

Also I'll try to eliminate the necessity for this config file in the first place. I don't know why it's necessary. I'll allow it but also allow it to be 0 byte and still operate fine.

That's what I want to ask next: Why not get rid of this .DAT file and making the highest possible mode as default and adding some module options

xtknight commented 8 years ago

Sure, can you try the latest 40mhzhacks branch. I forced vfs_read for myself even though I have f_op->read and it worked. If it works for you I will push to main, and then the next project is getting rid of the config file.

mkreisl commented 8 years ago

Tataaaaaaahhhh :smile:

ra0       Ralink STA  ESSID:"BigBellN"  Nickname:"MT7610U_STA"
          Mode:Managed  Frequency=2.437 GHz  Access Point: 64:70:02:23:80:78   
          Bit Rate=135 Mb/s   
          RTS thr:off   Fragment thr:off
          Encryption XXXXX   Security mode:open
          Link Quality=88/100  Signal level:-58 dBm  Noise level:-99 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
xtknight commented 8 years ago

Oh, even better you get full speed 135 Mb/s even more than 802.11n. I guess two problems might have been fixed. Don't know if the 40 MHz hacks even did anything though. I'll push the config file fix to main. Thanks for your help in figuring this out! I just couldn't imagine it was because of btrfs. ;) I'll close this particular issue and we can communicate in other Issues.

xtknight commented 8 years ago

If you don't want all the weird logging you can use the main branch now. It should at least go to 802.11n speeds and I'll investigate if there are any issues using 40 MHz as well.

mkreisl commented 8 years ago

40mhz hack is not needed.

Returned to master branch and still having 135MBit

mkreisl commented 8 years ago

Thanks for fixing this issue :+1: