# Slow/unstable Wi-Fi

## BaltazarGabka

Hi,

I have a problem with slow/unstable Wi-Fi on Gentoo. Usually speed is about 1 - 2 Mbps, sometimes it gets higher, sometimes it drops to 0, but it doesn't disconnect. I've checked if it's a problem with my computer, or with router. Every other device I've checked works fine. My computer gets normal Wi-Fi speeds under Windows 8.1, I also tried some other Linux distros (Pop!_OS, EndeavourOS and Fedora - all LiveDVDs) and it works fine as well.

My Wi-Fi adapter is Atheros AR9485, I use NetworkManager, my kernel is 5.10.78-gentoo-dist (however this problem occurred some kernels ago...).

```
ifconfig wlp3s0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.50.106  netmask 255.255.255.0  broadcast 192.168.50.255

        inet6 fe80::6c22:59e1:8fa8:8eb1  prefixlen 64  scopeid 0x20<link>

        ether 24:0a:64:91:9f:79  txqueuelen 1000  (Ethernet)

        RX packets 1119426  bytes 1563764542 (1.4 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 499039  bytes 71181851 (67.8 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

```
iwconfig wlp3s0

wlp3s0    IEEE 802.11  ESSID:"***** ***"  

          Mode:Managed  Frequency:2.442 GHz  Access Point: ***** ***   

          Bit Rate=57.8 Mb/s   Tx-Power=15 dBm   

          Retry short limit:7   RTS thr:off   Fragment thr:off

          Power Management:off

          Link Quality=58/70  Signal level=-52 dBm  

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:23104   Missed beacon:0
```

```
lsmod | grep ath

ath9k                 139264  0

ath9k_common           24576  1 ath9k

ath3k                  24576  0

ath9k_hw              466944  2 ath9k_common,ath9k

bluetooth             581632  46 btrtl,btintel,btbcm,bnep,ath3k,btusb,rfcomm

mac80211              925696  1 ath9k

ath                    32768  3 ath9k_common,ath9k,ath9k_hw

cfg80211              774144  4 ath9k_common,ath9k,ath,mac80211
```

The only difference I see between Gentoo and Pop!_OS, EndeavourOS and Fedora is the number of "Invalid misc" (iwconfig) - in Gentoo it's much higher. I tried some solutions found on this forum and somewhere else, and they didn't work (like nohwcrypt=1). I also tried to connect to Wi-Fi using wpa_supplicant and there was no difference (doesn't NetworkManager use wpa_supplicant?). Now I don't know what to look for, and where might be the problem. Maybe there are some options missing in the kernel, but i thought that gentoo-dist kernel uses Fedora's config, so if there's something wrong, Fedora should behave the same, but it's fine.

I'd appreciate any help.

----------

## alamahant

Do you have

linux-firmware

emerged?

----------

## BaltazarGabka

 *alamahant wrote:*   

> Do you have
> 
> linux-firmware
> 
> emerged?

 

Yes, I have it emerged. I assume, that I wouldn't be able to load ath9k module without this package.

```
emerge --search linux-firmware

*  sys-kernel/linux-firmware

      Latest version available: 20211027

      Latest version installed: 20211027

      Size of files: 179 045 KiB

      Homepage:      https://git.kernel.org/?p=linux/kernel/git/firmware/linux-firmware.git

```

----------

## Jaglover

What driver wpa_supplicant is using?

----------

## alamahant

Plz Disable wpa_supplicant and/or iwd and any net.<wifi> service and just let NM handle wifi.

----------

## BaltazarGabka

 *Jaglover wrote:*   

> What driver wpa_supplicant is using?

 

wpa_supplicant uses nl80211, wext didn't work at all.

 *alamahant wrote:*   

> Plz Disable wpa_supplicant and/or iwd and any net.<wifi> service and just let NM handle wifi.

 

Actually the only enabled service responsible for managing networks is NetworkManager. Anything else is disabled.

----------

## Jaglover

Anything in kernel log?

----------

## BaltazarGabka

 *Jaglover wrote:*   

> Anything in kernel log?

 

Do you mean something specific?

This part is the same on all four LInux distributions I tried (Gentoo, Pop!_OS, EndeavourOS, Fedora):

```
dmesg | grep ath

[    5.973787] usbcore: registered new interface driver ath3k

[    5.991480] ath: phy0: Disable PLL PowerSave

[    5.999197] ath: phy0: ASPM enabled: 0x42

[    5.999202] ath: EEPROM regdomain: 0x60

[    5.999203] ath: EEPROM indicates we should expect a direct regpair map

[    5.999206] ath: Country alpha2 being used: 00

[    5.999208] ath: Regpair used: 0x60

[    6.025356] ath9k 0000:03:00.0 wlp3s0: renamed from wlan0

[   30.484924] ath: EEPROM regdomain: 0x80fa

[   30.484925] ath: EEPROM indicates we should expect a country code

[   30.484926] ath: doing EEPROM country->regdmn map search

[   30.484927] ath: country maps to regdmn code: 0x37

[   30.484929] ath: Country alpha2 being used: FR

[   30.484929] ath: Regpair used: 0x37

[   30.484931] ath: regdomain 0x80fa dynamically updated by country element
```

```
dmesg | grep wlp3s0

[    6.025356] ath9k 0000:03:00.0 wlp3s0: renamed from wlan0

[   30.454136] wlp3s0: authenticate with ***** ***

[   30.473412] wlp3s0: send auth to ***** *** (try 1/3)

[   30.475316] wlp3s0: authenticated

[   30.478134] wlp3s0: associate with ***** *** (try 1/3)

[   30.484642] wlp3s0: RX AssocResp from ***** *** (capab=0xc11 status=0 aid=1)

[   30.484819] wlp3s0: associated

[   30.600893] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready
```

For me nothing out of ordinary...

----------

## NeddySeagoon

BaltazarGabka,

```
[   30.484929] ath: Country alpha2 being used: FR
```

This is used to determine which WiFi operating parameters are permitted in your region.

Did the crda database load?

Check dmesg, there will be an error if it failed.

Are you using the correct country code for your region?

You may be restricting your Transmit power and permitted channels if not.

WiFi will often work but badly if that setup is not correct.

----------

## BaltazarGabka

 *NeddySeagoon wrote:*   

> BaltazarGabka,
> 
> ```
> [   30.484929] ath: Country alpha2 being used: FR
> ```
> ...

 

I checked dmesg, and there aren't any errors. Other Linux distros I've tested used the same regulatory domain and Wi-Fi worked fine. I tried to change it, bu it didn't help.

When I installed Gentoo Wi-Fi also worked fine, but it changed probably after some update. Unfortunately I don't remember when it happened, so now it's more difficult to find where might be the problem. I thought that some interferences from other networks may cause my Wi-Fi to work so slowly and unstable, but after making some tests I found out, that there must be a problem in my Gentoo system...

----------

## BaltazarGabka

I haven't found a solution yet, but I've found some strange behavior: when I suspend my computer, and then I resume it, Wi-Fi works fine, it gets normal speeds. I don't see any difference in dmesg, only iwconfig shows lower "Invalid misc". Can anybody tell me where can I look for a reason of that behavior?

----------

