The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=259efa730c3d5c52d6ef0faa1d57d66eea5afa8e
commit 259efa730c3d5c52d6ef0faa1d57d66eea5afa8e Author: Bjoern A. Zeeb <[email protected]> AuthorDate: 2026-04-27 00:48:06 +0000 Commit: Bjoern A. Zeeb <[email protected]> CommitDate: 2026-06-05 12:09:23 +0000 LinuxKPI: 802.11: make *addba* work better Fill in more details for lkpi_ic_addba_request(), lkpi_ic_addba_response(), and lkpi_ic_addba_response_timeout(). Migrate the ltxq flags seen_dequeue and stopped to a bitfield and add %b support to log messages. This seemed the better approach after needing an additional stop field for BA while we have to hold packets from being transmitted. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 79 ++++++++++++++++++++++------ sys/compat/linuxkpi/common/src/linux_80211.h | 12 ++++- 2 files changed, 74 insertions(+), 17 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 774bcc531ad3..11c37f9529de 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -891,8 +891,7 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], } else { ltxq->txq.ac = ieee80211e_up_to_ac[tid & 7]; } - ltxq->seen_dequeue = false; - ltxq->stopped = false; + ltxq->flags = 0; ltxq->txq.vif = vif; ltxq->txq.tid = tid; ltxq->txq.sta = sta; @@ -2179,7 +2178,7 @@ lkpi_wake_tx_queues(struct ieee80211_hw *hw, struct ieee80211_sta *sta, continue; ltxq = TXQ_TO_LTXQ(sta->txq[tid]); - if (dequeue_seen && !ltxq->seen_dequeue) + if (dequeue_seen && (ltxq->flags & LKPI_TXQ_SEEN_DEQUEUE) == 0) continue; LKPI_80211_LTXQ_LOCK(ltxq); @@ -5793,8 +5792,8 @@ lkpi_80211_txq_tx_one(struct lkpi_sta *lsta, struct mbuf *m) if (sta->txq[tid] == NULL) continue; ltxq = TXQ_TO_LTXQ(sta->txq[tid]); - ic_printf(ic, " tid %d ltxq %p seen_dequeue %d stopped %d skb_queue_len %u\n", - tid, ltxq, ltxq->seen_dequeue, ltxq->stopped, skb_queue_len(<xq->skbq)); + ic_printf(ic, " tid %d ltxq %p flags %b skb_queue_len %u\n", + tid, ltxq, ltxq->flags, LKPI_TXQ_FLAGS_BITS, skb_queue_len(<xq->skbq)); } } ieee80211_free_node(ni); @@ -6091,17 +6090,29 @@ lkpi_ic_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, params.tid = tap->txa_tid; params.amsdu = false; - IEEE80211_UNLOCK(ic); + /* We get called from if_transmit all the way up unlocked in net80211. */ + IEEE80211_UNLOCK_ASSERT(ic); wiphy_lock(hw->wiphy); error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); wiphy_unlock(hw->wiphy); - IEEE80211_LOCK(ic); - if (error != 0) { + if (error == IEEE80211_AMPDU_TX_START_IMMEDIATE) { + ic_printf(ic, "%s: mo_ampdu_action returned AMPDU_TX_START_IMMEDIATE. " + "ni %p tap %p\n", __func__, ni, tap); + } else if (error != 0) { ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p tap %p\n", __func__, error, ni, tap); return (0); } + if (sta->txq[tap->txa_tid] != NULL) { + struct lkpi_txq *ltxq; + + ltxq = TXQ_TO_LTXQ(sta->txq[tap->txa_tid]); + TRACEOK("ADDBA REQ ltxq tid %u flags %b qlen %d", tap->txa_tid, + ltxq->flags, LKPI_TXQ_FLAGS_BITS, skb_queue_len(<xq->skbq)); + ltxq->flags |= LKPI_TXQ_STOPPED_BA; + } + return (lhw->ic_addba_request(ni, tap, dialogtoken, baparamset, batimeout)); } @@ -6171,17 +6182,27 @@ lkpi_ic_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap params.amsdu = false; } - IEEE80211_UNLOCK(ic); + /* We are called all they way up from ieee80211_input* without lock. */ wiphy_lock(hw->wiphy); error = lkpi_80211_mo_ampdu_action(hw, vif, ¶ms); wiphy_unlock(hw->wiphy); - IEEE80211_LOCK(ic); if (error != 0) { ic_printf(ic, "%s: mo_ampdu_action returned %d. ni %p tap %p\n", __func__, error, ni, tap); return (0); } + if (sta->txq[tap->txa_tid] != NULL) { + struct lkpi_txq *ltxq; + + ltxq = TXQ_TO_LTXQ(sta->txq[tap->txa_tid]); + TRACEOK("ADDBA RESP ltxq tid %u flags %b qlen %d", tap->txa_tid, + ltxq->flags, LKPI_TXQ_FLAGS_BITS, skb_queue_len(<xq->skbq)); + ltxq->flags &= ~LKPI_TXQ_STOPPED_BA; + + lkpi_80211_mo_wake_tx_queue(hw, sta->txq[tap->txa_tid], true); + } + IMPROVE_HT("who unleashes the TXQ? and when?, do we need to ni->ni_txseqs[tid] = tap->txa_start & 0xfff;"); return (lhw->ic_addba_response(ni, tap, status, baparamset, batimeout)); @@ -6252,14 +6273,40 @@ lkpi_ic_addba_response_timeout(struct ieee80211_node *ni, struct ieee80211_tx_am { struct ieee80211com *ic; struct lkpi_hw *lhw; + struct lkpi_sta *lsta; + struct ieee80211_sta *sta; ic = ni->ni_ic; lhw = ic->ic_softc; + lsta = ni->ni_drv_data; + sta = LSTA_TO_STA(lsta); TRACEOK("ADDBA RESP TIMEO tid %u", tap->txa_tid); IMPROVE_HT(); + if (!lsta->added_to_drv) { + ic_printf(ic, "%s: lsta %p ni %p, sta %p not added to firmware\n", + __func__, lsta, ni, sta); + goto n80211; + } + + /* We need to re-enable the txq and get packets out. */ + if (sta->txq[tap->txa_tid] != NULL) { + struct lkpi_txq *ltxq; + struct ieee80211_hw *hw; + + ltxq = TXQ_TO_LTXQ(sta->txq[tap->txa_tid]); + TRACEOK("ADDBA RESP TIMEO ltxq tid %u flags %b qlen %d", + tap->txa_tid, ltxq->flags, LKPI_TXQ_FLAGS_BITS, + skb_queue_len(<xq->skbq)); + ltxq->flags &= ~LKPI_TXQ_STOPPED_BA; + + hw = LHW_TO_HW(lhw); + lkpi_80211_mo_wake_tx_queue(hw, sta->txq[tap->txa_tid], true); + } + +n80211: lhw->ic_addba_response_timeout(ni, tap); } @@ -8592,14 +8639,14 @@ linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *hw, IMPROVE("wiphy_lock? or assert?"); skb = NULL; ltxq = TXQ_TO_LTXQ(txq); - ltxq->seen_dequeue = true; + ltxq->flags |= LKPI_TXQ_SEEN_DEQUEUE; - if (ltxq->stopped) + if ((ltxq->flags & (LKPI_TXQ_STOPPED|LKPI_TXQ_STOPPED_BA)) != 0) goto stopped; lvif = VIF_TO_LVIF(ltxq->txq.vif); if (lvif->hw_queue_stopped[ltxq->txq.ac]) { - ltxq->stopped = true; + ltxq->flags |= LKPI_TXQ_STOPPED; goto stopped; } @@ -9102,10 +9149,10 @@ lkpi_ieee80211_wake_queues(struct ieee80211_hw *hw, int hwq) continue; ltxq = TXQ_TO_LTXQ(sta->txq[tid]); - if (!ltxq->stopped) + if ((ltxq->flags & LKPI_TXQ_STOPPED) == 0) continue; - ltxq->stopped = false; + ltxq->flags &= ~LKPI_TXQ_STOPPED; if (!skb_queue_empty(<xq->skbq)) lkpi_80211_mo_wake_tx_queue(hw, sta->txq[tid], false); @@ -9245,6 +9292,8 @@ linuxkpi_ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac) goto out; if (ltxq->txq_generation == lhw->txq_generation[ac]) goto out; + if ((ltxq->flags & (LKPI_TXQ_STOPPED|LKPI_TXQ_STOPPED_BA)) != 0) + goto out; IMPROVE("check AIRTIME_FAIRNESS"); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index f33075b354d2..063be4251ccc 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -150,12 +150,20 @@ struct lkpi_radiotap_rx_hdr { struct lkpi_hw; +enum lkpi_txq_flags { + LKPI_TXQ_SEEN_DEQUEUE = 0x01, + LKPI_TXQ_STOPPED = 0x02, + LKPI_TXQ_STOPPED_BA = 0x04, +}; +#define LKPI_TXQ_FLAGS_BITS \ + "\010\1SEEN_DEQUEUE\2STOPPED\3STOPPED_BA" + struct lkpi_txq { TAILQ_ENTRY(lkpi_txq) txq_entry; struct mtx ltxq_mtx; - bool seen_dequeue; - bool stopped; + enum lkpi_txq_flags flags; + uint32_t txq_generation; struct sk_buff_head skbq; uint64_t frms_enqueued;
