On Tue, May 11, 2021 at 11:44:17AM +0200, Stefan Sperling wrote:
> Can you please run with this and let me know if it changes anything?

I have finally managed to reproduce the problem locally by playing around
with forced background scans and roaming. This patch is a superset of the
previous patch. It should fix the 'add sta' problem and also fixes a couple
of small bugs I found along the way.

diff refs/heads/master refs/heads/iwm-txaggfixes
blob - f3380617f2f5a80854e72b5a44cceff28d42aafc
blob + f430116aaabda132d2b9bf9acd7eca260b25373a
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -3312,9 +3312,9 @@ iwm_sta_tx_agg(struct iwm_softc *sc, struct ieee80211_
        if (start) {
                /* Enable Tx aggregation for this queue. */
                in->tid_disable_ampdu &= ~(1 << tid);
-               in->tfd_queue_msk |= htole32(1 << qid);
+               in->tfd_queue_msk |= (1 << qid);
        } else {
-               in->tid_disable_ampdu |= ~(1 << tid);
+               in->tid_disable_ampdu |= (1 << tid);
                /* Queue remains enabled in the TFD queue mask. */
                err = iwm_flush_sta(sc, in);
                if (err)
@@ -6677,7 +6677,7 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
                        qid = IWM_DQA_INJECT_MONITOR_QUEUE;
                else
                        qid = IWM_AUX_QUEUE;
-               in->tfd_queue_msk |= htole32(1 << qid);
+               in->tfd_queue_msk |= (1 << qid);
        } else {
                int ac;
                for (ac = 0; ac < EDCA_NUM_AC; ac++) {
@@ -6685,7 +6685,7 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
                        if (isset(sc->sc_enabled_capa,
                            IWM_UCODE_TLV_CAPA_DQA_SUPPORT))
                                qid += IWM_DQA_MIN_MGMT_QUEUE;
-                       in->tfd_queue_msk |= htole32(1 << qid);
+                       in->tfd_queue_msk |= (1 << qid);
                }
        }
        if (!update) {
@@ -8015,7 +8015,6 @@ iwm_auth(struct iwm_softc *sc)
        sc->sc_flags |= IWM_FLAG_BINDING_ACTIVE;
 
        in->tid_disable_ampdu = 0xffff;
-       in->tfd_queue_msk = 0;
        err = iwm_add_sta_cmd(sc, in, 0);
        if (err) {
                printf("%s: could not add sta (error %d)\n",
@@ -8074,11 +8073,11 @@ iwm_deauth(struct iwm_softc *sc)
                        return err;
                }
                in->tid_disable_ampdu = 0xffff;
-               in->tfd_queue_msk = 0;
                sc->sc_flags &= ~IWM_FLAG_STA_ACTIVE;
                sc->sc_rx_ba_sessions = 0;
                sc->ba_rx.start_tidmask = 0;
                sc->ba_rx.stop_tidmask = 0;
+               sc->tx_ba_queue_mask = 0;
                sc->ba_tx.start_tidmask = 0;
                sc->ba_tx.stop_tidmask = 0;
        }
@@ -8116,10 +8115,8 @@ iwm_assoc(struct iwm_softc *sc)
 
        splassert(IPL_NET);
 
-       if (!update_sta) {
+       if (!update_sta)
                in->tid_disable_ampdu = 0xffff;
-               in->tfd_queue_msk = 0;
-       }
        err = iwm_add_sta_cmd(sc, in, update_sta);
        if (err) {
                printf("%s: could not %s STA (error %d)\n",
@@ -8150,11 +8147,11 @@ iwm_disassoc(struct iwm_softc *sc)
                        return err;
                }
                in->tid_disable_ampdu = 0xffff;
-               in->tfd_queue_msk = 0;
                sc->sc_flags &= ~IWM_FLAG_STA_ACTIVE;
                sc->sc_rx_ba_sessions = 0;
                sc->ba_rx.start_tidmask = 0;
                sc->ba_rx.stop_tidmask = 0;
+               sc->tx_ba_queue_mask = 0;
                sc->ba_tx.start_tidmask = 0;
                sc->ba_tx.stop_tidmask = 0;
        }
@@ -9520,6 +9517,8 @@ iwm_stop(struct ifnet *ifp)
        ifq_clr_oactive(&ifp->if_snd);
 
        in->in_phyctxt = NULL;
+       in->tid_disable_ampdu = 0xffff;
+       in->tfd_queue_msk = 0;
 
        sc->sc_flags &= ~(IWM_FLAG_SCANNING | IWM_FLAG_BGSCAN);
        sc->sc_flags &= ~IWM_FLAG_MAC_ACTIVE;

Reply via email to