For a long time I have observed that iwn takes much longer when connecting
to a 5GHz AP compared to a 2GHz AP. I think I have finally figured out why.

After enabling debug printfs in the driver I've observed that the Tx-done
interrupt usually reports an error the first time an auth request is sent
to the AP on 5GHz: iwn_tx_done: status=0x90

The scan loop will restart because no auth response is received from the AP.
It starts working the second or third time through and then we can associate.

After looking up this Tx status code in Linux I found out that the firmware
wants to see a beacon before allowing transmissions on a 5GHz channel.
This enforces regulatory domain requirements (protecting radars etc. from
interference).

So I tried adding some delay before the initial AUTH request is sent.
Waiting for just one beacon interval doesn't seem to cut it, two still
fails sometimes, but at 3 it's pretty solid. Association on 5GHz is now
just as fast as it is on 2GHz.

ok?

Index: if_iwn.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.191
diff -u -p -r1.191 if_iwn.c
--- if_iwn.c    13 Aug 2017 15:04:47 -0000      1.191
+++ if_iwn.c    3 Sep 2017 18:06:16 -0000
@@ -4930,6 +4930,15 @@ iwn_auth(struct iwn_softc *sc)
                    sc->sc_dev.dv_xname);
                return error;
        }
+
+       /* 
+        * On a 5GHz channel, make sure the firmware gets to see a beacon
+        * before we send the auth request. Otherwise the Tx attempt can
+        * fail due to the firmware's built-in regulatory domain enforcement.
+        */
+       if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan))
+               DELAY(ni->ni_intval * 3 * IEEE80211_DUR_TU);
+
        return 0;
 }
 

Reply via email to