* [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler
@ 2026-11-28 23:40 Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 01/10] wifi: ath11k: free tx skbs through ieee80211_free_txskb() Julius Bairaktaris
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
ath11k sets neither NL80211_EXT_FEATURE_AQL nor
NL80211_EXT_FEATURE_AIRTIME_FAIRNESS, so a saturated download queues
every frame in the hardware TX rings, where there is no AQM. This series
sets both, registers tx and rx airtime, and runs the TXQ scheduler from
the driver and from tx completion.
IPQ8074 AP, TCP download from a wired host to one 1x1 VHT80 station,
default limits, 20 s, three interleaved runs per arm, measured on v5:
Mbit/s sender RTT mean ms
auto rate without 92.9, 94.4, 94.3 111, 232, 231
with 93.7, 88.0, 93.6 124, 51, 167
VHT MCS 0 without 21.4, 22.3, 22.6 587, 550, 526
with 22.9, 22.2, 22.3 44, 42, 43
The v6 changes to 5/10 (the share of a multi-user PPDU) and 9/10 (ending
a round on a full MSDU idr) do not act with one single-user station
below the idr limit, so the table stands. On v6, a routed TCP download
to one HE160 station at 883 to 923 Mbit/s logged no "failed to transmit
frame", six runs with aql_enable set to 0 in debugfs and six with it set
to 1 (IPQ8074 hw2.0, WLAN.HK.2.9.0.1-02146).
On v5, airtime weights are accepted but leave a 2x2 HE160 station at 45
to 49% of the airtime against a 1x1 VHT80 station at 1:1, 4:1 and 1:4,
because the firmware serves every station with frames queued in turn.
Ending the round at 256 MSDUs in flight, as Toke suggested, gives the
HE160 station 65 to 80% at 4:1, but at 1:1 its aggregates shrink from
258 to 100 MSDUs (one run) and the two-station throughput drops by a
third, so the series leaves it out.
2/10 is new. With the AQL flag set by 3/10, mac80211 charges each frame's
airtime to its station; ath11k freed a dropped encap offloaded frame
with ieee80211_free_txskb(), which finds the station only from an
802.11 header, so the charge stayed with the station. v6 carried a
mac80211 patch for this [2]; Felix asked for the driver to pass the
station instead [3], and 2/10 does that. A station hits this when
ath11k_dp_tx() refuses its frames ("failed to transmit frame"), as on a
full MSDU idr or while a firmware crash is flushed: once the leaked
charge reaches the 12000 us high limit, its queue gets no frame until
it reassociates. Mainline is not affected, since only this series sets
the AQL flag. Found by an LLM review of the tx status paths.
The series is based on "wifi: ath11k/ath12k: implement TX flow control"
v8 [1], patches 1-3, which is not in ath-next yet; it applies after them.
I used Claude (Anthropic) to help write these patches.
Changes in v7:
- new patch 2: return a dropped encap frame to mac80211 with its
station through ieee80211_tx_status_ext(), replacing the mac80211
patch [2], as Felix Fietkau asked [3]
- patch 1: commit message names patch 2 for the charge of an encap
frame
- rebased onto ath-next 18d0bedbb5f0
- v6: https://lore.kernel.org/all/20261122181145.1015729-1-julius@bairaktaris.de/
Changes in v6 (v6 patch numbers):
- patch 1: return the frames in flight to mac80211 on firmware recovery
- patch 2: report the tx completion rate on single pdev chips, which
stayed at the 4 us airtime floor
- patch 4: charge each user of a downlink OFDMA or MU-MIMO PPDU its
share of the PPDU duration, the duration divided by num_users, not
the whole duration; reported by Christopher Griffin
- patch 7: register rx airtime under ab->base_lock; mac80211 frees the
station without a grace period after the peer drops it
- patch 8: end a round also when the ring's MSDU idr is full, so no
frame is dequeued only to be dropped; reported by Christopher Griffin
- patch 8: end a round only while a frame is pending, and mark the
access category before reading the pending counts, so a completion
cannot miss the mark
- patch 8: drop the management queue from the commit message; ath11k
has no management TXQ
- rebased onto ath-next 1983b40acfcb
- v5: https://lore.kernel.org/all/20261018174904.1757161-1-julius@bairaktaris.de/
[1] https://lore.kernel.org/all/20261021060725.242681-1-jtornosm@redhat.com/
[2] https://lore.kernel.org/all/20261122150541.3117507-1-julius@bairaktaris.de/
[3] https://lore.kernel.org/all/8d674f7c-68db-474f-8cb1-5645542db0ac@nbd.name/
Julius Bairaktaris (10):
wifi: ath11k: free tx skbs through ieee80211_free_txskb()
wifi: ath11k: report a dropped frame with its station
wifi: ath11k: enable airtime queue limits
wifi: ath11k: report the pending tx MSDU count in soc_dp_stats
wifi: ath11k: report tx airtime and enable airtime fairness
wifi: ath11k: schedule TXQs from the driver
wifi: ath11k: run the TXQ scheduler on tx completion
wifi: ath11k: charge received airtime to the station deficit
wifi: ath11k: stop a scheduling round when the hardware is full
wifi: ath11k: budget the tx completion handler
drivers/net/wireless/ath/ath11k/core.c | 1 +
drivers/net/wireless/ath/ath11k/core.h | 9 +
drivers/net/wireless/ath/ath11k/debugfs.c | 10 +
drivers/net/wireless/ath/ath11k/dp.c | 11 +-
drivers/net/wireless/ath/ath11k/dp.h | 6 +-
drivers/net/wireless/ath/ath11k/dp_rx.c | 34 +++-
drivers/net/wireless/ath/ath11k/dp_tx.c | 229 ++++++++++++++++++++--
drivers/net/wireless/ath/ath11k/dp_tx.h | 7 +-
drivers/net/wireless/ath/ath11k/mac.c | 112 +++++++++--
drivers/net/wireless/ath/ath11k/mac.h | 1 +
10 files changed, 383 insertions(+), 37 deletions(-)
base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
prerequisite-message-id: <20261021060725.242681-1-jtornosm@redhat.com>
prerequisite-patch-id: ff44eb6f1d673e75bc013e3ffc870d7d30252c17
prerequisite-patch-id: 2cde5e2a788f79e4b8c858a60ec11cd120b1b97e
prerequisite-patch-id: c86d3c9047c851f45b5d46398850c9d810d82258
--
2.53.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 01/10] wifi: ath11k: free tx skbs through ieee80211_free_txskb()
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 02/10] wifi: ath11k: report a dropped frame with its station Julius Bairaktaris
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
ath11k_dp_tx_free_txbuf(), reached for the HTT REINJ and INSPECT
statuses, frees the frame with dev_kfree_skb_any(), unlike every other
tx completion path in dp_tx.c, and so does ath11k_dp_free() for the
frames in flight when firmware recovery tears the rings down. This leaks
the tx status clone and idr entry mac80211 keeps for a frame whose
socket asked for status, as commit 29d15589f084 ("wifi: ath11k: Cleanup
mac80211 references on failure during tx_complete") fixed on three
sibling paths. With NL80211_EXT_FEATURE_AQL, set later in this series,
it also keeps the frame's airtime charge, which ieee80211_restart_hw()
does not reset, and a station whose charge reaches its limit is no
longer dequeued in that access category. ieee80211_free_txskb() returns
the charge of an 802.11 frame to the station it finds from the header;
the next patch passes the station of an encap offloaded frame.
Free the REINJ and INSPECT frame with ieee80211_free_txskb(), and return
the frames in flight to mac80211 in ath11k_core_reconfigure_on_crash()
before ath11k_dp_free(), which also runs at teardown after the radios
are freed. Neither HTT status occurred on the hardware below, and the
recovery path was not exercised; both changes are by inspection.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: commit message: the next patch returns the charge of an encap frame
v6: return the frames in flight to mac80211 on firmware recovery
drivers/net/wireless/ath/ath11k/core.c | 1 +
drivers/net/wireless/ath/ath11k/dp_tx.c | 39 ++++++++++++++++++++++++-
drivers/net/wireless/ath/ath11k/dp_tx.h | 1 +
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index 766ae27306f43..34cfdedea6adb 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -2341,6 +2341,7 @@ static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab)
ath11k_dp_pdev_reo_cleanup(ab);
mutex_unlock(&ab->core_lock);
+ ath11k_dp_tx_free_pending(ab);
ath11k_dp_free(ab);
ath11k_hal_srng_clear(ab);
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index 083aca8ff355b..0e3b4e836001f 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -305,13 +305,50 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
skb_cb = ATH11K_SKB_CB(msdu);
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
- dev_kfree_skb_any(msdu);
ar = ab->pdevs[mac_id].ar;
+ ieee80211_free_txskb(ar->hw, msdu);
+
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
}
+/**
+ * ath11k_dp_tx_free_pending() - return the frames a crashed firmware holds
+ * @ab: device being recovered
+ *
+ * The radios outlive the firmware restart, and mac80211 keeps the tx status
+ * and the airtime charge of each frame until the driver returns it.
+ */
+void ath11k_dp_tx_free_pending(struct ath11k_base *ab)
+{
+ struct ath11k_skb_cb *skb_cb;
+ struct sk_buff_head pending;
+ struct dp_tx_ring *tx_ring;
+ struct sk_buff *msdu;
+ int i, msdu_id;
+
+ __skb_queue_head_init(&pending);
+
+ for (i = 0; i < ab->hw_params.hal_params->num_tx_rings; i++) {
+ tx_ring = &ab->dp.tx_ring[i];
+
+ spin_lock_bh(&tx_ring->tx_idr_lock);
+ idr_for_each_entry(&tx_ring->txbuf_idr, msdu, msdu_id) {
+ idr_remove(&tx_ring->txbuf_idr, msdu_id);
+ __skb_queue_tail(&pending, msdu);
+ }
+ spin_unlock_bh(&tx_ring->tx_idr_lock);
+ }
+
+ while ((msdu = __skb_dequeue(&pending))) {
+ skb_cb = ATH11K_SKB_CB(msdu);
+ dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len,
+ DMA_TO_DEVICE);
+ ieee80211_free_txskb(skb_cb->ar->hw, msdu);
+ }
+}
+
static void
ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
struct dp_tx_ring *tx_ring,
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless/ath/ath11k/dp_tx.h
index 9303b5ba6e012..9a26de411e83a 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
@@ -22,6 +22,7 @@ int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab);
int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
struct ath11k_sta *arsta, struct sk_buff *skb);
void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id);
+void ath11k_dp_tx_free_pending(struct ath11k_base *ab);
int ath11k_dp_tx_send_reo_cmd(struct ath11k_base *ab, struct dp_rx_tid *rx_tid,
enum hal_reo_cmd_type type,
struct ath11k_hal_reo_cmd *cmd,
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 02/10] wifi: ath11k: report a dropped frame with its station
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 01/10] wifi: ath11k: free tx skbs through ieee80211_free_txskb() Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 03/10] wifi: ath11k: enable airtime queue limits Julius Bairaktaris
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
mac80211 charges a frame's airtime to its station when
ieee80211_tx_dequeue() hands the frame over. It returns the charge on tx
status to the station the driver passes, and in ieee80211_free_txskb()
to the station it finds from the 802.11 header. An encap offloaded
frame starts with its 802.3 header, so each ath11k path that frees one
leaves the charge with its station: the HTT REINJ and INSPECT statuses,
the frames in flight at firmware recovery, a completion whose peer is
not found or that carries no peer id, a completion for a radio that is
no longer active, and a frame ath11k_dp_tx() refuses. Once a station's
leaked charge in an access category reaches its high limit,
ieee80211_txq_airtime_check() stops that queue until the station
reassociates.
Keep the address of the frame's station in the skb control block, and
hand such an encap frame back with ieee80211_tx_status_ext() with its
station and without status info, so mac80211 returns the charge without
updating station statistics, then free it as dropped, as
ieee80211_free_txskb() does. A frame ath11k_dp_tx() refuses goes back
with the station mac80211 passed. Other dropped frames find their
station by its address with ieee80211_find_sta(), which does not depend
on the firmware peer table; the reset recovery frees the peers before
the frames in flight are returned. A socket that asked for an encap
frame's status now gets one, with the ack state ath11k set, where it got
none. An 802.11 frame is still freed with ieee80211_free_txskb().
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.12-01460-QCAHKSWPL_SILICONZ-1
Link: https://lore.kernel.org/all/8d674f7c-68db-474f-8cb1-5645542db0ac@nbd.name/
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: new; replaces the mac80211 patch
https://lore.kernel.org/all/20261122150541.3117507-1-julius@bairaktaris.de/
which Felix Fietkau asked to be solved in the driver:
https://lore.kernel.org/all/8d674f7c-68db-474f-8cb1-5645542db0ac@nbd.name/
drivers/net/wireless/ath/ath11k/core.h | 2 +
drivers/net/wireless/ath/ath11k/dp_tx.c | 93 +++++++++++++++++++++++--
drivers/net/wireless/ath/ath11k/dp_tx.h | 2 +
drivers/net/wireless/ath/ath11k/mac.c | 7 +-
4 files changed, 96 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index a0d725923ef24..7fa93df81a41d 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -113,6 +113,7 @@ static inline enum wme_ac ath11k_tid_to_ac(u32 tid)
enum ath11k_skb_flags {
ATH11K_SKB_HW_80211_ENCAP = BIT(0),
ATH11K_SKB_CIPHER_SET = BIT(1),
+ ATH11K_SKB_STA = BIT(2),
};
struct ath11k_skb_cb {
@@ -122,6 +123,7 @@ struct ath11k_skb_cb {
u32 cipher;
struct ath11k *ar;
struct ieee80211_vif *vif;
+ u8 sta_addr[ETH_ALEN];
} __packed;
struct ath11k_skb_rxcb {
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index 0e3b4e836001f..25a91681a2192 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -284,6 +284,66 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
return ret;
}
+/**
+ * ath11k_dp_tx_drop() - return a frame without status info
+ * @ar: radio the frame was queued on
+ * @sta: station mac80211 queued the frame to, or NULL
+ * @msdu: the frame, already unmapped
+ *
+ * For a frame that was not transmitted, a completion whose peer is not
+ * found, or one for a radio that is no longer active. mac80211 charged the
+ * frame's airtime to its station when it handed the frame over. It finds
+ * the station of a dropped 802.11 frame from the header; an encap offloaded
+ * frame starts with its 802.3 header, so it goes back with the station.
+ * Without status info, mac80211 updates no station statistics for it and
+ * reports the ack state in the frame's flags to a socket that asked for its
+ * status. The frame is freed as dropped.
+ */
+void ath11k_dp_tx_drop(struct ath11k *ar, struct ieee80211_sta *sta,
+ struct sk_buff *msdu)
+{
+ LIST_HEAD(free_list);
+ struct ieee80211_tx_status status = {
+ .sta = sta,
+ .skb = msdu,
+ .free_list = &free_list,
+ };
+
+ if (!(IEEE80211_SKB_CB(msdu)->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) {
+ ieee80211_free_txskb(ar->hw, msdu);
+ return;
+ }
+
+ ieee80211_tx_status_ext(ar->hw, &status);
+ skb_list_del_init(msdu);
+ dev_kfree_skb_any(msdu);
+}
+
+/*
+ * Find the station mac80211 queued a frame to by the address
+ * ath11k_mac_tx() kept; a station removed since is not found. The caller
+ * has had BH disabled or held the RCU read lock since before the frame left
+ * the idr, so the vif is still valid or ath11k_mac_vif_unref() cleared it,
+ * and a station found stays valid until the frame is reported.
+ */
+static struct ieee80211_sta *ath11k_dp_tx_find_sta(struct ieee80211_vif *vif,
+ u8 flags, const u8 *addr)
+{
+ if (!vif || !(flags & ATH11K_SKB_STA))
+ return NULL;
+
+ return ieee80211_find_sta(vif, addr);
+}
+
+static void ath11k_dp_tx_drop_queued(struct ath11k *ar, struct sk_buff *msdu)
+{
+ struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(msdu);
+
+ ath11k_dp_tx_drop(ar, ath11k_dp_tx_find_sta(skb_cb->vif, skb_cb->flags,
+ skb_cb->sta_addr),
+ msdu);
+}
+
static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
int msdu_id,
struct dp_tx_ring *tx_ring)
@@ -307,7 +367,7 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
ar = ab->pdevs[mac_id].ar;
- ieee80211_free_txskb(ar->hw, msdu);
+ ath11k_dp_tx_drop_queued(ar, msdu);
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
@@ -330,6 +390,8 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab)
__skb_queue_head_init(&pending);
+ rcu_read_lock();
+
for (i = 0; i < ab->hw_params.hal_params->num_tx_rings; i++) {
tx_ring = &ab->dp.tx_ring[i];
@@ -345,8 +407,10 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab)
skb_cb = ATH11K_SKB_CB(msdu);
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len,
DMA_TO_DEVICE);
- ieee80211_free_txskb(skb_cb->ar->hw, msdu);
+ ath11k_dp_tx_drop_queued(skb_cb->ar, msdu);
}
+
+ rcu_read_unlock();
}
static void
@@ -360,6 +424,9 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
struct ath11k_skb_cb *skb_cb;
struct ath11k *ar;
struct ath11k_peer *peer;
+ struct ieee80211_vif *vif;
+ u8 sta_addr[ETH_ALEN];
+ u8 flags;
spin_lock(&tx_ring->tx_idr_lock);
msdu = idr_remove(&tx_ring->txbuf_idr, ts->msdu_id);
@@ -375,13 +442,17 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
info = IEEE80211_SKB_CB(msdu);
ar = skb_cb->ar;
+ /* info->status below overwrites skb_cb */
+ vif = skb_cb->vif;
+ flags = skb_cb->flags;
+ memcpy(sta_addr, skb_cb->sta_addr, ETH_ALEN);
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
- if (!skb_cb->vif) {
+ if (!vif) {
ieee80211_free_txskb(ar->hw, msdu);
return;
}
@@ -411,7 +482,8 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
"dp_tx: failed to find the peer with peer_id %d\n",
ts->peer_id);
spin_unlock_bh(&ab->base_lock);
- ieee80211_free_txskb(ar->hw, msdu);
+ ath11k_dp_tx_drop(ar, ath11k_dp_tx_find_sta(vif, flags, sta_addr),
+ msdu);
return;
}
spin_unlock_bh(&ab->base_lock);
@@ -597,6 +669,9 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
struct ath11k_peer *peer;
struct ath11k_sta *arsta;
struct rate_info rate;
+ struct ieee80211_vif *vif;
+ u8 sta_addr[ETH_ALEN];
+ u8 flags;
if (WARN_ON_ONCE(ts->buf_rel_source != HAL_WBM_REL_SRC_MODULE_TQM)) {
/* Must not happen */
@@ -608,7 +683,7 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
if (unlikely(!rcu_access_pointer(ab->pdevs_active[ar->pdev_idx]))) {
- ieee80211_free_txskb(ar->hw, msdu);
+ ath11k_dp_tx_drop_queued(ar, msdu);
return;
}
@@ -617,6 +692,11 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
return;
}
+ /* info->status below overwrites skb_cb */
+ vif = skb_cb->vif;
+ flags = skb_cb->flags;
+ memcpy(sta_addr, skb_cb->sta_addr, ETH_ALEN);
+
info = IEEE80211_SKB_CB(msdu);
memset(&info->status, 0, sizeof(info->status));
@@ -670,7 +750,8 @@ static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
"dp_tx: failed to find the peer with peer_id %d\n",
ts->peer_id);
spin_unlock_bh(&ab->base_lock);
- ieee80211_free_txskb(ar->hw, msdu);
+ ath11k_dp_tx_drop(ar, ath11k_dp_tx_find_sta(vif, flags, sta_addr),
+ msdu);
return;
}
arsta = ath11k_sta_to_arsta(peer->sta);
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless/ath/ath11k/dp_tx.h
index 9a26de411e83a..977cb48de7c0a 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
@@ -23,6 +23,8 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
struct ath11k_sta *arsta, struct sk_buff *skb);
void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id);
void ath11k_dp_tx_free_pending(struct ath11k_base *ab);
+void ath11k_dp_tx_drop(struct ath11k *ar, struct ieee80211_sta *sta,
+ struct sk_buff *msdu);
int ath11k_dp_tx_send_reo_cmd(struct ath11k_base *ab, struct dp_rx_tid *rx_tid,
enum hal_reo_cmd_type type,
struct ath11k_hal_reo_cmd *cmd,
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index d6e07b98b65aa..ec92c825f809c 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -6555,13 +6555,16 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
return;
}
- if (control->sta)
+ if (control->sta) {
arsta = ath11k_sta_to_arsta(control->sta);
+ memcpy(skb_cb->sta_addr, control->sta->addr, ETH_ALEN);
+ skb_cb->flags |= ATH11K_SKB_STA;
+ }
ret = ath11k_dp_tx(ar, arvif, arsta, skb);
if (unlikely(ret)) {
ath11k_warn(ar->ab, "failed to transmit frame %d\n", ret);
- ieee80211_free_txskb(ar->hw, skb);
+ ath11k_dp_tx_drop(ar, control->sta, skb);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 03/10] wifi: ath11k: enable airtime queue limits
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 01/10] wifi: ath11k: free tx skbs through ieee80211_free_txskb() Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 02/10] wifi: ath11k: report a dropped frame with its station Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 04/10] wifi: ath11k: report the pending tx MSDU count in soc_dp_stats Julius Bairaktaris
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
Without NL80211_EXT_FEATURE_AQL, mac80211 applies no airtime queue limit,
and a saturated download moves every queued frame into the hardware TX
rings. Set the bit. mac80211 estimates each frame's airtime from the
rate ath11k reports through ieee80211_tx_status_ext(), and charges its
4 us floor while that rate is unset. Only the PPDU stats set it, so
single pdev chips, which take the rate from the tx completion instead,
would stay at the floor; set it there as well.
With the series and the AP pinned to VHT MCS 0, a TCP download to one
1x1 VHT80 station keeps 22 Mbit/s while the sender's mean RTT falls from
526-587 ms to 42-44 ms (three interleaved runs per arm, default limits).
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
v6: report the tx completion rate on single pdev chips, which stayed at
the 4 us airtime floor
drivers/net/wireless/ath/ath11k/dp_tx.c | 6 ++++++
drivers/net/wireless/ath/ath11k/mac.c | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index 25a91681a2192..d4c98a2459ff0 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -650,6 +650,12 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts)
ath11k_mac_he_ru_tones_to_nl80211_he_ru_alloc(ru_tones);
}
+ /* Single pdev chips have no other source for the rate reported to
+ * mac80211, which estimates airtime from it.
+ */
+ if (ab->hw_params.single_pdev_only)
+ arsta->last_txrate = arsta->txrate;
+
if (ath11k_debugfs_is_extd_tx_stats_enabled(ar))
ath11k_debugfs_sta_add_tx_stats(arsta, peer_stats, rate_idx);
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index ec92c825f809c..bf39005fb0ae4 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -10655,6 +10655,7 @@ static int __ath11k_mac_register(struct ath11k *ar)
ar->hw->sta_data_size = sizeof(struct ath11k_sta);
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
+ wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_AQL);
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
if (test_bit(WMI_TLV_SERVICE_BSS_COLOR_OFFLOAD,
ar->ab->wmi_ab.svc_map)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 04/10] wifi: ath11k: report the pending tx MSDU count in soc_dp_stats
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (2 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 03/10] wifi: ath11k: enable airtime queue limits Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 05/10] wifi: ath11k: report tx airtime and enable airtime fairness Julius Bairaktaris
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
Nothing shows ar->dp.num_tx_pending, the MSDUs the hardware has not
completed. Print it per radio in soc_dp_stats. Divided into the pending
airtime in a station's aql file, it gives the airtime AQL charges per
MSDU.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
drivers/net/wireless/ath/ath11k/debugfs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index 70922612d3fb9..ffe1f466aefb6 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -714,6 +714,16 @@ static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file,
"\nMisc Transmit Failures: %d\n",
atomic_read(&soc_stats->tx_err.misc_fail));
+ /* Descriptors the hardware has not completed. */
+ len += scnprintf(buf + len, size - len, "\nPending Tx MSDUs:\n");
+ for (i = 0; i < ab->num_radios; i++) {
+ struct ath11k *ar = ab->pdevs[i].ar;
+
+ if (ar)
+ len += scnprintf(buf + len, size - len, "radio%d: %d\n",
+ i, atomic_read(&ar->dp.num_tx_pending));
+ }
+
len += ath11k_debugfs_dump_soc_ring_bp_stats(ab, buf + len, size - len);
if (len > size)
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 05/10] wifi: ath11k: report tx airtime and enable airtime fairness
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (3 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 04/10] wifi: ath11k: report the pending tx MSDU count in soc_dp_stats Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 06/10] wifi: ath11k: schedule TXQs from the driver Julius Bairaktaris
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
mac80211 charges the airtime deficit only through
ieee80211_sta_register_airtime(), which ath11k never calls, so with
NL80211_EXT_FEATURE_AIRTIME_FAIRNESS alone every station stays in
credit. Register fes_duration_us from the PPDU stats, which ath11k
already adds to arsta->tx_duration, and set the bit. The TID comes from
the ack/BA status TLV, sent only for a PPDU that drew a response, then
from the completion or rate TLV, then BE. fes_duration_us is the
duration of the whole PPDU, from the common TLV that all its users
share, so each user of a downlink OFDMA or MU-MIMO PPDU is charged the
duration divided by num_users, in arsta->tx_duration as well. mac80211
takes only local->active_txq_lock[ac] inside the call, which runs under
ar->data_lock and ab->base_lock.
'iw station set <mac> airtime_weight' fails with -EOPNOTSUPP before this
patch and succeeds after it.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
v6: charge each user of a downlink OFDMA or MU-MIMO PPDU the PPDU
duration divided by num_users; reported by Christopher Griffin
drivers/net/wireless/ath/ath11k/dp_rx.c | 23 ++++++++++++++++++++++-
drivers/net/wireless/ath/ath11k/mac.c | 2 ++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 6d95f7b343a55..777c56e416aed 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -1382,6 +1382,7 @@ ath11k_update_per_peer_tx_stats(struct ath11k *ar,
u16 rate = 0, succ_pkts = 0;
u32 tx_duration = 0;
u8 tid = HTT_PPDU_STATS_NON_QOS_TID;
+ u8 airtime_tid;
bool is_ampdu = false;
if (!(usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_RATE)))
@@ -1400,8 +1401,12 @@ ath11k_update_per_peer_tx_stats(struct ath11k *ar,
usr_stats->ack_ba.info);
}
+ /* fes_duration_us is in the common TLV, one value for the whole PPDU
+ * that every user's stats repeat; a user holds its share of it.
+ */
if (common->fes_duration_us)
- tx_duration = common->fes_duration_us;
+ tx_duration = common->fes_duration_us /
+ max_t(u8, common->num_users, 1);
user_rate = &usr_stats->rate;
flags = HTT_USR_RATE_PREAMBLE(user_rate->rate_flags);
@@ -1490,6 +1495,22 @@ ath11k_update_per_peer_tx_stats(struct ath11k *ar,
arsta->txrate.bw = ath11k_mac_bw_to_mac80211_bw(bw);
arsta->tx_duration += tx_duration;
+
+ /* The ack/BA status TLV names the TID only for a PPDU that drew a
+ * response; fall back to the completion and rate TLVs, then to BE.
+ */
+ airtime_tid = tid;
+ if (airtime_tid >= IEEE80211_NUM_TIDS &&
+ usr_stats->tlv_flags & BIT(HTT_PPDU_STATS_TAG_USR_COMPLTN_COMMON))
+ airtime_tid = usr_stats->cmpltn_cmn.tid_num;
+ if (airtime_tid >= IEEE80211_NUM_TIDS)
+ airtime_tid = user_rate->tid_num;
+ if (airtime_tid >= IEEE80211_NUM_TIDS)
+ airtime_tid = 0;
+
+ if (tx_duration)
+ ieee80211_sta_register_airtime(sta, airtime_tid, tx_duration, 0);
+
memcpy(&arsta->last_txrate, &arsta->txrate, sizeof(struct rate_info));
/* PPDU stats reported for mgmt packet doesn't have valid tx bytes.
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index bf39005fb0ae4..244e2a5b27b1d 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -10656,6 +10656,8 @@ static int __ath11k_mac_register(struct ath11k *ar)
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_AQL);
+ wiphy_ext_feature_set(ar->hw->wiphy,
+ NL80211_EXT_FEATURE_AIRTIME_FAIRNESS);
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
if (test_bit(WMI_TLV_SERVICE_BSS_COLOR_OFFLOAD,
ar->ab->wmi_ab.svc_map)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 06/10] wifi: ath11k: schedule TXQs from the driver
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (4 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 05/10] wifi: ath11k: report tx airtime and enable airtime fairness Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 07/10] wifi: ath11k: run the TXQ scheduler on tx completion Julius Bairaktaris
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
The wake_tx_queue handler serves only the txq mac80211 passes it, so
there is no deficit round robin between stations. Run the round in the
driver: walk the access category's active txqs with
ieee80211_next_txq() and drain each through the TCL ring check until the
airtime queue limit binds or the queue empties. A full ring ends the
round, since all txqs of a round share it. Each round holds a
per-category lock, as in ath10k, because mac80211 forbids concurrent
rounds on one category and the next patch also starts rounds from tx
completion. The design was proposed for ath11k in [1].
Link: https://lore.kernel.org/all/20230501130725.7171-1-quic_tamizhr@quicinc.com/ [1]
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
drivers/net/wireless/ath/ath11k/core.h | 5 +++
drivers/net/wireless/ath/ath11k/mac.c | 44 +++++++++++++++++++++++---
2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 7fa93df81a41d..9e81709b98099 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -711,6 +711,11 @@ struct ath11k {
*/
spinlock_t data_lock;
+ /* serialises one scheduling round per access category against the
+ * other contexts that drive it
+ */
+ spinlock_t txq_lock[IEEE80211_NUM_ACS];
+
struct list_head arvifs;
/* should never be NULL; needed for regular htt rx */
struct ieee80211_channel *rx_channel;
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 244e2a5b27b1d..0744d02b8dc84 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -10081,13 +10081,12 @@ static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw,
return ret;
}
-static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
- struct ieee80211_txq *txq)
+static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
{
struct ieee80211_tx_control control = {
.sta = txq->sta,
};
- struct ath11k *ar = hw->priv;
+ struct ieee80211_hw *hw = ar->hw;
struct dp_tx_ring *tx_ring;
struct hal_srng *tcl_ring;
struct sk_buff *skb;
@@ -10100,6 +10099,10 @@ static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
tx_ring = &ar->ab->dp.tx_ring[ring_id];
tcl_ring = &ar->ab->hal.srng_list[tx_ring->tcl_data_ring.ring_id];
+ /* ieee80211_tx_dequeue() applies the airtime queue limit, so a
+ * selection ends where that limit binds or the queue empties. A full
+ * TCL ring ends the whole round.
+ */
while (1) {
if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH,
&ar->ab->dev_flags)))
@@ -10113,7 +10116,7 @@ static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
if (num_free == 0) {
spin_unlock_bh(&tx_ring->wake_tx_lock);
- break;
+ return -ENOSPC;
}
skb = ieee80211_tx_dequeue(hw, txq);
@@ -10126,6 +10129,34 @@ static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
spin_unlock_bh(&tx_ring->wake_tx_lock);
}
+
+ return 0;
+}
+
+static void ath11k_mac_schedule_txq(struct ath11k *ar, u8 ac)
+{
+ struct ieee80211_hw *hw = ar->hw;
+ struct ieee80211_txq *txq;
+
+ spin_lock_bh(&ar->txq_lock[ac]);
+
+ ieee80211_txq_schedule_start(hw, ac);
+ while ((txq = ieee80211_next_txq(hw, ac))) {
+ int ret = ath11k_mac_tx_push_txq(ar, txq);
+
+ ieee80211_return_txq(hw, txq, false);
+ if (unlikely(ret))
+ break;
+ }
+ ieee80211_txq_schedule_end(hw, ac);
+
+ spin_unlock_bh(&ar->txq_lock[ac]);
+}
+
+static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
+ struct ieee80211_txq *txq)
+{
+ ath11k_mac_schedule_txq(hw->priv, txq->ac);
}
static const struct ieee80211_ops ath11k_ops = {
@@ -10820,7 +10851,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
struct ath11k *ar;
struct ath11k_pdev *pdev;
int ret;
- int i;
+ int i, j;
if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
@@ -10854,6 +10885,9 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
pdev->ar = ar;
spin_lock_init(&ar->data_lock);
+
+ for (j = 0; j < IEEE80211_NUM_ACS; j++)
+ spin_lock_init(&ar->txq_lock[j]);
INIT_LIST_HEAD(&ar->arvifs);
INIT_LIST_HEAD(&ar->ppdu_stats_info);
mutex_init(&ar->conf_mutex);
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 07/10] wifi: ath11k: run the TXQ scheduler on tx completion
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (5 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 06/10] wifi: ath11k: schedule TXQs from the driver Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 08/10] wifi: ath11k: charge received airtime to the station deficit Julius Bairaktaris
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
A station at its airtime queue limit gets airtime back only when the
hardware completes its frames, but ath11k starts a round only from
wake_tx_queue, so the backlog waits for the next frame from the stack.
Start a round for each access category, taken from the frame's queue
mapping, that a reaped completion belonged to, whether the hardware or
the firmware released the frame.
TCP download from a wired host to one 1x1 VHT80 station, BE
aql_txq_limit 500/1000 us, 20 s, three interleaved runs per arm, sender
RTT:
Mbit/s RTT mean ms RTT max ms
with this patch 94.5, 94.4, 94.6 68, 62, 67 126, 135, 121
without 74.0, 78.5, 72.4 28, 27, 27 55, 40, 40
Without it the link idles between arrivals, which also lowers its RTT.
At the default limits both arms reach 88 to 95 Mbit/s.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change; rebased over patch 2
drivers/net/wireless/ath/ath11k/dp_tx.c | 33 +++++++++++++++++++------
drivers/net/wireless/ath/ath11k/mac.c | 7 ++++++
drivers/net/wireless/ath/ath11k/mac.h | 1 +
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index d4c98a2459ff0..d4c6367f6d79e 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -346,7 +346,8 @@ static void ath11k_dp_tx_drop_queued(struct ath11k *ar, struct sk_buff *msdu)
static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
int msdu_id,
- struct dp_tx_ring *tx_ring)
+ struct dp_tx_ring *tx_ring,
+ unsigned long *push)
{
struct ath11k *ar;
struct sk_buff *msdu;
@@ -367,6 +368,8 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
ar = ab->pdevs[mac_id].ar;
+ __set_bit(mac_id * IEEE80211_NUM_ACS + skb_get_queue_mapping(msdu),
+ push);
ath11k_dp_tx_drop_queued(ar, msdu);
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
@@ -416,7 +419,8 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab)
static void
ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
struct dp_tx_ring *tx_ring,
- struct ath11k_dp_htt_wbm_tx_status *ts)
+ struct ath11k_dp_htt_wbm_tx_status *ts,
+ unsigned long *push)
{
struct ieee80211_tx_status status = {};
struct sk_buff *msdu;
@@ -446,6 +450,8 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
vif = skb_cb->vif;
flags = skb_cb->flags;
memcpy(sta_addr, skb_cb->sta_addr, ETH_ALEN);
+ __set_bit(ar->pdev_idx * IEEE80211_NUM_ACS +
+ skb_get_queue_mapping(msdu), push);
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
@@ -498,7 +504,8 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
static void
ath11k_dp_tx_process_htt_tx_complete(struct ath11k_base *ab,
void *desc, u8 mac_id,
- u32 msdu_id, struct dp_tx_ring *tx_ring)
+ u32 msdu_id, struct dp_tx_ring *tx_ring,
+ unsigned long *push)
{
struct htt_tx_wbm_completion *status_desc;
struct ath11k_dp_htt_wbm_tx_status ts = {};
@@ -523,12 +530,12 @@ ath11k_dp_tx_process_htt_tx_complete(struct ath11k_base *ab,
else
ts.peer_id = HTT_INVALID_PEER_ID;
- ath11k_dp_tx_htt_tx_complete_buf(ab, tx_ring, &ts);
+ ath11k_dp_tx_htt_tx_complete_buf(ab, tx_ring, &ts, push);
break;
case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ:
case HAL_WBM_REL_HTT_TX_COMP_STATUS_INSPECT:
- ath11k_dp_tx_free_txbuf(ab, mac_id, msdu_id, tx_ring);
+ ath11k_dp_tx_free_txbuf(ab, mac_id, msdu_id, tx_ring, push);
break;
case HAL_WBM_REL_HTT_TX_COMP_STATUS_MEC_NOTIFY:
/* This event is to be handled only when the driver decides to
@@ -817,9 +824,10 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
struct sk_buff *msdu;
struct hal_tx_status ts = {};
struct dp_tx_ring *tx_ring = &dp->tx_ring[ring_id];
+ unsigned long push = 0;
u32 *desc;
u32 msdu_id;
- u8 mac_id;
+ u8 mac_id, i;
spin_lock_bh(&status_ring->lock);
@@ -863,7 +871,7 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
ath11k_dp_tx_process_htt_tx_complete(ab,
(void *)tx_status,
mac_id, msdu_id,
- tx_ring);
+ tx_ring, &push);
continue;
}
@@ -879,12 +887,23 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
spin_unlock(&tx_ring->tx_idr_lock);
ar = ab->pdevs[mac_id].ar;
+ __set_bit(mac_id * IEEE80211_NUM_ACS + skb_get_queue_mapping(msdu),
+ &push);
if (atomic_dec_and_test(&ar->dp.num_tx_pending))
wake_up(&ar->dp.tx_empty_waitq);
ath11k_dp_tx_complete_msdu(ar, msdu, &ts);
}
+
+ /* A completion returns the airtime the frame was charged, which is
+ * what an airtime-limited station in that access category is waiting
+ * on. The arrivals that would otherwise start a round are themselves
+ * queued behind that limit.
+ */
+ for_each_set_bit(i, &push, ab->num_radios * IEEE80211_NUM_ACS)
+ ath11k_mac_tx_push_pending(ab->pdevs[i / IEEE80211_NUM_ACS].ar,
+ i % IEEE80211_NUM_ACS);
}
int ath11k_dp_tx_send_reo_cmd(struct ath11k_base *ab, struct dp_rx_tid *rx_tid,
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 0744d02b8dc84..5312f0d8faf34 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -10159,6 +10159,13 @@ static void ath11k_mac_op_wake_tx_queue(struct ieee80211_hw *hw,
ath11k_mac_schedule_txq(hw->priv, txq->ac);
}
+void ath11k_mac_tx_push_pending(struct ath11k *ar, u8 ac)
+{
+ rcu_read_lock();
+ ath11k_mac_schedule_txq(ar, ac);
+ rcu_read_unlock();
+}
+
static const struct ieee80211_ops ath11k_ops = {
.tx = ath11k_mac_op_tx,
.wake_tx_queue = ath11k_mac_op_wake_tx_queue,
diff --git a/drivers/net/wireless/ath/ath11k/mac.h b/drivers/net/wireless/ath/ath11k/mac.h
index 127cb476b44b7..b78a357b5472e 100644
--- a/drivers/net/wireless/ath/ath11k/mac.h
+++ b/drivers/net/wireless/ath/ath11k/mac.h
@@ -161,6 +161,7 @@ struct ath11k *ath11k_mac_get_ar_by_vdev_id(struct ath11k_base *ab, u32 vdev_id)
struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id);
void ath11k_mac_drain_tx(struct ath11k *ar);
+void ath11k_mac_tx_push_pending(struct ath11k *ar, u8 ac);
void ath11k_mac_peer_cleanup_all(struct ath11k *ar);
void ath11k_mac_tx_mgmt_pending_free(struct ath11k *ar);
u8 ath11k_mac_bw_to_mac80211_bw(u8 bw);
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 08/10] wifi: ath11k: charge received airtime to the station deficit
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (6 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 07/10] wifi: ath11k: run the TXQ scheduler on tx completion Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 09/10] wifi: ath11k: stop a scheduling round when the hardware is full Julius Bairaktaris
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
mac80211 charges received airtime to the same deficit, as AIRTIME_USE_RX
is set by default, but ath11k reports none. Register each received
PPDU's duration, which ath11k already adds to rx_duration, once against
the PPDU's first TID, or BE when it names none. The TID comes from the
PPDU end user stats TLV, which is added to the default monitor status
filter. The call runs under ab->base_lock, as on the transmit side:
ath11k_mac_op_sta_state() drops the station from its peer under that
lock, and mac80211 frees it after that without an RCU grace period.
A station uploading with DSCP CS5 moved its VI deficit in 3 of 3 runs;
uploads marked BE left it unchanged in 3 of 3.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
v6: register rx airtime under ab->base_lock
drivers/net/wireless/ath/ath11k/dp_rx.c | 11 +++++++++++
drivers/net/wireless/ath/ath11k/mac.c | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 777c56e416aed..1e4080caaa80d 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -5280,6 +5280,7 @@ int ath11k_dp_rx_process_mon_status(struct ath11k_base *ab, int mac_id,
struct ath11k_peer *peer;
struct ath11k_sta *arsta;
int num_buffs_reaped = 0;
+ u8 tid;
u32 rx_buf_sz;
u16 log_type;
struct ath11k_mon_data *pmon = (struct ath11k_mon_data *)&ar->dp.mon_data;
@@ -5347,6 +5348,16 @@ int ath11k_dp_rx_process_mon_status(struct ath11k_base *ab, int mac_id,
arsta = ath11k_sta_to_arsta(peer->sta);
ath11k_dp_rx_update_peer_stats(arsta, ppdu_info);
+ /* Charged once per PPDU with the measured duration, as on
+ * the transmit side, to the first TID of the PPDU; BE when
+ * it names none. mac80211 frees the station without a grace
+ * period after the peer drops it under base_lock.
+ */
+ tid = ppdu_info->tid < IEEE80211_NUM_TIDS ? ppdu_info->tid : 0;
+ if (ppdu_info->rx_duration)
+ ieee80211_sta_register_airtime(peer->sta, tid, 0,
+ ppdu_info->rx_duration);
+
if (ath11k_debugfs_is_pktlog_peer_valid(ar, peer->addr))
trace_ath11k_htt_rxdesc(ar, skb->data, log_type, rx_buf_sz);
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 5312f0d8faf34..461f06336bea7 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -229,6 +229,7 @@ ath11k_phymodes[NUM_NL80211_BANDS][ATH11K_CHAN_WIDTH_NUM] = {
const struct htt_rx_ring_tlv_filter ath11k_mac_mon_status_filter_default = {
.rx_filter = HTT_RX_FILTER_TLV_FLAGS_MPDU_START |
HTT_RX_FILTER_TLV_FLAGS_PPDU_END |
+ HTT_RX_FILTER_TLV_FLAGS_PPDU_END_USER_STATS |
HTT_RX_FILTER_TLV_FLAGS_PPDU_END_STATUS_DONE,
.pkt_filter_flags0 = HTT_RX_FP_MGMT_FILTER_FLAGS0,
.pkt_filter_flags1 = HTT_RX_FP_MGMT_FILTER_FLAGS1,
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 09/10] wifi: ath11k: stop a scheduling round when the hardware is full
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (7 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 08/10] wifi: ath11k: charge received airtime to the station deficit Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 10/10] wifi: ath11k: budget the tx completion handler Julius Bairaktaris
2026-11-29 22:43 ` [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Giuseppe Piscitelli
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
A round dequeues a frame from mac80211 before ath11k_dp_tx() can refuse
it, and ath11k_mac_tx() then frees it. ath11k_dp_tx() returns -ENOSPC
when the ring's MSDU idr, DP_TX_IDR_SIZE - 1 ids, is full and -ENOMEM
when no TCL descriptor is free or a DMA mapping fails. Without airtime
queue limits, as with aql_enable off, nothing keeps the frames in flight
below that.
Count the ids in use per ring and end the round before a dequeue when
the idr or the TCL ring has no room, so a frame leaves the queue only
when it can be sent. A frame refused anyway, because one sent outside a
round took the last slot, still ends the round and leaves the frames
behind it queued; other errors concern only the frame. A category whose
round ended this way may have nothing of its own in flight, so mark it
and start its round from the next tx completion on the device.
Such a completion is due only while a frame is pending, so the round
ends only then. It marks the category before it reads the pending
counts, and tx completion reads the marks after the fully ordered
decrement of its frame's count, so either the round sees no frame
pending and goes on, or a completion sees the mark. With no frame
pending, a refused frame is dropped and the round goes on, as before.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
v6: end a round also when the ring's MSDU idr is full (reported by
Christopher Griffin); end a round only while a frame is pending and mark
the access category before reading the pending counts; drop the
management queue from the commit message
drivers/net/wireless/ath/ath11k/core.h | 2 +
drivers/net/wireless/ath/ath11k/dp.c | 1 +
drivers/net/wireless/ath/ath11k/dp.h | 6 ++-
drivers/net/wireless/ath/ath11k/dp_tx.c | 55 +++++++++++++++++++++----
drivers/net/wireless/ath/ath11k/dp_tx.h | 1 +
drivers/net/wireless/ath/ath11k/mac.c | 54 ++++++++++++++++++++----
6 files changed, 103 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 9e81709b98099..d28e0c043f5ed 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -715,6 +715,8 @@ struct ath11k {
* other contexts that drive it
*/
spinlock_t txq_lock[IEEE80211_NUM_ACS];
+ /* access categories whose round ended for lack of room */
+ unsigned long txq_starved;
struct list_head arvifs;
/* should never be NULL; needed for regular htt rx */
diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c
index 3e0a6bdfa0505..615384a4bb75e 100644
--- a/drivers/net/wireless/ath/ath11k/dp.c
+++ b/drivers/net/wireless/ath/ath11k/dp.c
@@ -1088,6 +1088,7 @@ int ath11k_dp_alloc(struct ath11k_base *ab)
for (i = 0; i < ab->hw_params.hal_params->num_tx_rings; i++) {
idr_init(&dp->tx_ring[i].txbuf_idr);
+ atomic_set(&dp->tx_ring[i].num_txbuf, 0);
spin_lock_init(&dp->tx_ring[i].tx_idr_lock);
spin_lock_init(&dp->tx_ring[i].wake_tx_lock);
dp->tx_ring[i].tcl_data_ring_id = i;
diff --git a/drivers/net/wireless/ath/ath11k/dp.h b/drivers/net/wireless/ath/ath11k/dp.h
index 6d99501aa269c..bf7439e8b37d0 100644
--- a/drivers/net/wireless/ath/ath11k/dp.h
+++ b/drivers/net/wireless/ath/ath11k/dp.h
@@ -85,8 +85,12 @@ struct dp_tx_ring {
struct dp_srng tcl_data_ring;
struct dp_srng tcl_comp_ring;
struct idr txbuf_idr;
- /* Protects txbuf_idr and num_pending */
+ /* Protects txbuf_idr; num_txbuf changes with it and is read without */
spinlock_t tx_idr_lock;
+ /* MSDU ids in use, one per frame between ath11k_dp_tx() and its
+ * completion
+ */
+ atomic_t num_txbuf;
/* Serializes wake_tx_queue operations for this ring */
spinlock_t wake_tx_lock;
struct hal_wbm_release_ring *tx_status;
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index d4c6367f6d79e..e193aea6cf6f1 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -79,6 +79,35 @@ enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32 cipher)
}
}
+/* The caller holds tx_ring->tx_idr_lock. */
+static struct sk_buff *ath11k_dp_tx_idr_remove(struct dp_tx_ring *tx_ring,
+ int msdu_id)
+{
+ struct sk_buff *msdu;
+
+ msdu = idr_remove(&tx_ring->txbuf_idr, msdu_id);
+ if (msdu)
+ atomic_dec(&tx_ring->num_txbuf);
+
+ return msdu;
+}
+
+/**
+ * ath11k_dp_tx_idr_has_room() - tell whether ath11k_dp_tx() can take a frame
+ * @tx_ring: the ring the frame would go to first
+ *
+ * ath11k_dp_tx() allocates the frame's MSDU id from the ring's idr, which
+ * holds DP_TX_IDR_SIZE - 1 ids and frees one when the frame completes. A
+ * caller that takes a frame from mac80211 only to have it refused for a full
+ * idr loses the frame, so it checks first.
+ *
+ * Return: true if the idr has an id free.
+ */
+bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring)
+{
+ return atomic_read(&tx_ring->num_txbuf) < DP_TX_IDR_SIZE - 1;
+}
+
int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
struct ath11k_sta *arsta, struct sk_buff *skb)
{
@@ -123,6 +152,8 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
spin_lock_bh(&tx_ring->tx_idr_lock);
ret = idr_alloc(&tx_ring->txbuf_idr, skb, 0,
DP_TX_IDR_SIZE - 1, GFP_ATOMIC);
+ if (likely(ret >= 0))
+ atomic_inc(&tx_ring->num_txbuf);
spin_unlock_bh(&tx_ring->tx_idr_lock);
if (unlikely(ret < 0)) {
@@ -274,8 +305,8 @@ int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
fail_remove_idr:
spin_lock_bh(&tx_ring->tx_idr_lock);
- idr_remove(&tx_ring->txbuf_idr,
- FIELD_GET(DP_TX_DESC_ID_MSDU_ID, ti.desc_id));
+ ath11k_dp_tx_idr_remove(tx_ring,
+ FIELD_GET(DP_TX_DESC_ID_MSDU_ID, ti.desc_id));
spin_unlock_bh(&tx_ring->tx_idr_lock);
if (tcl_ring_retry)
@@ -354,7 +385,7 @@ static void ath11k_dp_tx_free_txbuf(struct ath11k_base *ab, u8 mac_id,
struct ath11k_skb_cb *skb_cb;
spin_lock(&tx_ring->tx_idr_lock);
- msdu = idr_remove(&tx_ring->txbuf_idr, msdu_id);
+ msdu = ath11k_dp_tx_idr_remove(tx_ring, msdu_id);
spin_unlock(&tx_ring->tx_idr_lock);
if (unlikely(!msdu)) {
@@ -400,7 +431,7 @@ void ath11k_dp_tx_free_pending(struct ath11k_base *ab)
spin_lock_bh(&tx_ring->tx_idr_lock);
idr_for_each_entry(&tx_ring->txbuf_idr, msdu, msdu_id) {
- idr_remove(&tx_ring->txbuf_idr, msdu_id);
+ ath11k_dp_tx_idr_remove(tx_ring, msdu_id);
__skb_queue_tail(&pending, msdu);
}
spin_unlock_bh(&tx_ring->tx_idr_lock);
@@ -433,7 +464,7 @@ ath11k_dp_tx_htt_tx_complete_buf(struct ath11k_base *ab,
u8 flags;
spin_lock(&tx_ring->tx_idr_lock);
- msdu = idr_remove(&tx_ring->txbuf_idr, ts->msdu_id);
+ msdu = ath11k_dp_tx_idr_remove(tx_ring, ts->msdu_id);
spin_unlock(&tx_ring->tx_idr_lock);
if (unlikely(!msdu)) {
@@ -876,7 +907,7 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
}
spin_lock(&tx_ring->tx_idr_lock);
- msdu = idr_remove(&tx_ring->txbuf_idr, msdu_id);
+ msdu = ath11k_dp_tx_idr_remove(tx_ring, msdu_id);
if (unlikely(!msdu)) {
ath11k_warn(ab, "tx completion for unknown msdu_id %d\n",
msdu_id);
@@ -899,8 +930,18 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
/* A completion returns the airtime the frame was charged, which is
* what an airtime-limited station in that access category is waiting
* on. The arrivals that would otherwise start a round are themselves
- * queued behind that limit.
+ * queued behind that limit. It also frees the ring space and MSDU ids
+ * that a round ended early on any radio is waiting on. The fully
+ * ordered decrement of num_tx_pending orders the read of the mark
+ * after the frame is counted done.
*/
+ for (i = 0; i < ab->num_radios; i++) {
+ ar = ab->pdevs[i].ar;
+ if (unlikely(READ_ONCE(ar->txq_starved)))
+ push |= xchg(&ar->txq_starved, 0) <<
+ (i * IEEE80211_NUM_ACS);
+ }
+
for_each_set_bit(i, &push, ab->num_radios * IEEE80211_NUM_ACS)
ath11k_mac_tx_push_pending(ab->pdevs[i / IEEE80211_NUM_ACS].ar,
i % IEEE80211_NUM_ACS);
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless/ath/ath11k/dp_tx.h
index 977cb48de7c0a..54c6f7363dcec 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
@@ -21,6 +21,7 @@ void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts);
int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab);
int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
struct ath11k_sta *arsta, struct sk_buff *skb);
+bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring);
void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id);
void ath11k_dp_tx_free_pending(struct ath11k_base *ab);
void ath11k_dp_tx_drop(struct ath11k *ar, struct ieee80211_sta *sta,
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 461f06336bea7..e82efca9ac8d7 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -6519,9 +6519,9 @@ static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb,
return 0;
}
-static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
- struct ieee80211_tx_control *control,
- struct sk_buff *skb)
+static int ath11k_mac_tx(struct ieee80211_hw *hw,
+ struct ieee80211_tx_control *control,
+ struct sk_buff *skb)
{
struct ath11k_skb_cb *skb_cb = ATH11K_SKB_CB(skb);
struct ath11k *ar = hw->priv;
@@ -6553,7 +6553,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
ret);
ieee80211_free_txskb(ar->hw, skb);
}
- return;
+ return ret;
}
if (control->sta) {
@@ -6567,6 +6567,15 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
ath11k_warn(ar->ab, "failed to transmit frame %d\n", ret);
ath11k_dp_tx_drop(ar, control->sta, skb);
}
+
+ return ret;
+}
+
+static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
+ struct ieee80211_tx_control *control,
+ struct sk_buff *skb)
+{
+ ath11k_mac_tx(hw, control, skb);
}
void ath11k_mac_drain_tx(struct ath11k *ar)
@@ -10082,6 +10091,26 @@ static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw,
return ret;
}
+/* A round that stops for lack of room is restarted by the next tx completion
+ * on the device, which reads the mark after counting its frame done. Mark
+ * first, then check that a frame is still pending, or no completion is due.
+ */
+static bool ath11k_mac_mark_txq_starved(struct ath11k *ar, u8 ac)
+{
+ struct ath11k_base *ab = ar->ab;
+ int i;
+
+ set_bit(ac, &ar->txq_starved);
+ /* pairs with the decrement of num_tx_pending in tx completion */
+ smp_mb__after_atomic();
+
+ for (i = 0; i < ab->num_radios; i++)
+ if (atomic_read(&ab->pdevs[i].ar->dp.num_tx_pending))
+ return true;
+
+ return false;
+}
+
static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
{
struct ieee80211_tx_control control = {
@@ -10093,6 +10122,7 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
struct sk_buff *skb;
u32 ring_selector;
int num_free;
+ int ret;
u8 ring_id;
ring_selector = ar->ab->hw_params.hw_ops->get_ring_selector(txq->ac);
@@ -10102,7 +10132,9 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
/* ieee80211_tx_dequeue() applies the airtime queue limit, so a
* selection ends where that limit binds or the queue empties. A full
- * TCL ring ends the whole round.
+ * TCL ring or MSDU idr ends the whole round before a frame is taken
+ * from the queue, and so does a frame the hardware refuses anyway,
+ * as long as a frame in flight will restart it.
*/
while (1) {
if (unlikely(test_bit(ATH11K_FLAG_CRASH_FLUSH,
@@ -10115,9 +10147,11 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
num_free = ath11k_hal_srng_src_num_free(ar->ab, tcl_ring, true);
spin_unlock_bh(&tcl_ring->lock);
- if (num_free == 0) {
+ if (num_free == 0 || !ath11k_dp_tx_idr_has_room(tx_ring)) {
spin_unlock_bh(&tx_ring->wake_tx_lock);
- return -ENOSPC;
+ if (ath11k_mac_mark_txq_starved(ar, txq->ac))
+ return -ENOSPC;
+ continue;
}
skb = ieee80211_tx_dequeue(hw, txq);
@@ -10126,9 +10160,13 @@ static int ath11k_mac_tx_push_txq(struct ath11k *ar, struct ieee80211_txq *txq)
break;
}
- ath11k_mac_op_tx(hw, &control, skb);
+ ret = ath11k_mac_tx(hw, &control, skb);
spin_unlock_bh(&tx_ring->wake_tx_lock);
+
+ if (unlikely(ret == -ENOSPC || ret == -ENOMEM) &&
+ ath11k_mac_mark_txq_starved(ar, txq->ac))
+ return ret;
}
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH ath-next v7 10/10] wifi: ath11k: budget the tx completion handler
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (8 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 09/10] wifi: ath11k: stop a scheduling round when the hardware is full Julius Bairaktaris
@ 2026-11-28 23:40 ` Julius Bairaktaris
2026-11-29 22:43 ` [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Giuseppe Piscitelli
10 siblings, 0 replies; 12+ messages in thread
From: Julius Bairaktaris @ 2026-11-28 23:40 UTC (permalink / raw)
To: Jeff Johnson
Cc: linux-wireless, ath11k, linux-kernel, Felix Fietkau, tamizh.raja,
jtornosm, baochen.qiang, rameshkumar.sundaram,
vasanthakumar.thiagarajan, sriram.ramachandran, yaojiale02,
quic_pradeepc, quic_msinada, quic_vnaralas, slakkavalli, kvalo,
sven, john, toke, Christopher Griffin
ath11k_dp_tx_completion_handler() reaps the whole release ring, and
ath11k_dp_service_srng() charges none of it against the NAPI budget,
unlike the receive handlers. Since the handler now ends in a scheduling
round, a full ring gets one round for all of it. Reap at most the budget
per poll and return the count, so a round runs once per budget of
completions; NAPI polls again at once for the rest.
BE aql_txq_limit 500/1000 us, three interleaved runs per arm: both arms
reach 94.4 to 94.8 Mbit/s, and the sender retransmits 4, 6 and 8
segments with this patch against 8, 644 and 296 without.
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v7: no change
drivers/net/wireless/ath/ath11k/dp.c | 10 ++++++++--
drivers/net/wireless/ath/ath11k/dp_tx.c | 11 +++++++++--
drivers/net/wireless/ath/ath11k/dp_tx.h | 3 ++-
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c
index 615384a4bb75e..833feb981cfc0 100644
--- a/drivers/net/wireless/ath/ath11k/dp.c
+++ b/drivers/net/wireless/ath/ath11k/dp.c
@@ -783,8 +783,14 @@ int ath11k_dp_service_srng(struct ath11k_base *ab,
for (i = 0; i < ab->hw_params.hal_params->num_tx_rings; i++) {
if (BIT(ab->hw_params.hal_params->tcl2wbm_rbm_map[i].wbm_ring_num) &
- ab->hw_params.ring_mask->tx[grp_id])
- ath11k_dp_tx_completion_handler(ab, i);
+ ab->hw_params.ring_mask->tx[grp_id]) {
+ work_done =
+ ath11k_dp_tx_completion_handler(ab, i, budget);
+ budget -= work_done;
+ tot_work_done += work_done;
+ if (budget <= 0)
+ goto done;
+ }
}
if (ab->hw_params.ring_mask->rx_err[grp_id]) {
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.c b/drivers/net/wireless/ath/ath11k/dp_tx.c
index e193aea6cf6f1..fc3e3cb8f8b29 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -846,7 +846,8 @@ static inline void ath11k_dp_tx_status_parse(struct ath11k_base *ab,
ts->rate_stats = 0;
}
-void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
+int ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id,
+ int budget)
{
struct ath11k *ar;
struct ath11k_dp *dp = &ab->dp;
@@ -856,6 +857,7 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
struct hal_tx_status ts = {};
struct dp_tx_ring *tx_ring = &dp->tx_ring[ring_id];
unsigned long push = 0;
+ int done = 0;
u32 *desc;
u32 msdu_id;
u8 mac_id, i;
@@ -884,10 +886,13 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
spin_unlock_bh(&status_ring->lock);
- while (ATH11K_TX_COMPL_NEXT(tx_ring->tx_status_tail) != tx_ring->tx_status_head) {
+ while (done < budget &&
+ ATH11K_TX_COMPL_NEXT(tx_ring->tx_status_tail) !=
+ tx_ring->tx_status_head) {
struct hal_wbm_release_ring *tx_status;
u32 desc_id;
+ done++;
tx_ring->tx_status_tail =
ATH11K_TX_COMPL_NEXT(tx_ring->tx_status_tail);
tx_status = &tx_ring->tx_status[tx_ring->tx_status_tail];
@@ -945,6 +950,8 @@ void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id)
for_each_set_bit(i, &push, ab->num_radios * IEEE80211_NUM_ACS)
ath11k_mac_tx_push_pending(ab->pdevs[i / IEEE80211_NUM_ACS].ar,
i % IEEE80211_NUM_ACS);
+
+ return done;
}
int ath11k_dp_tx_send_reo_cmd(struct ath11k_base *ab, struct dp_rx_tid *rx_tid,
diff --git a/drivers/net/wireless/ath/ath11k/dp_tx.h b/drivers/net/wireless/ath/ath11k/dp_tx.h
index 54c6f7363dcec..9d2cb2a2a1e16 100644
--- a/drivers/net/wireless/ath/ath11k/dp_tx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.h
@@ -22,7 +22,8 @@ int ath11k_dp_tx_htt_h2t_ver_req_msg(struct ath11k_base *ab);
int ath11k_dp_tx(struct ath11k *ar, struct ath11k_vif *arvif,
struct ath11k_sta *arsta, struct sk_buff *skb);
bool ath11k_dp_tx_idr_has_room(struct dp_tx_ring *tx_ring);
-void ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id);
+int ath11k_dp_tx_completion_handler(struct ath11k_base *ab, int ring_id,
+ int budget);
void ath11k_dp_tx_free_pending(struct ath11k_base *ab);
void ath11k_dp_tx_drop(struct ath11k *ar, struct ieee80211_sta *sta,
struct sk_buff *msdu);
--
2.53.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
` (9 preceding siblings ...)
2026-11-28 23:40 ` [PATCH ath-next v7 10/10] wifi: ath11k: budget the tx completion handler Julius Bairaktaris
@ 2026-11-29 22:43 ` Giuseppe Piscitelli
10 siblings, 0 replies; 12+ messages in thread
From: Giuseppe Piscitelli @ 2026-11-29 22:43 UTC (permalink / raw)
To: Julius Bairaktaris; +Cc: Jeff Johnson, ath11k, linux-wireless
Hi Julius,
I tested an OpenWrt backport of v7, the three TX flow-control
prerequisites, and local adaptation and review fixes on four Linksys
MX5300s (IPQ8074 hw2.0 AHB, non-CT firmware
WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1). The base was OpenWrt r33416,
kernel 6.12.118 and wireless backports 6.18.55-r2. Both AHB radios on
each node exposed AQL and airtime fairness. All four restored stock
after the test.
I ran two reverse TCP streams for 25 s directly from one AP to a Linux
client on the same 5 GHz HE40 BSSID, with RSSI between -48 and -49 dBm.
ICMP sampled that hop at 5 Hz for 21 s during the load. These are p95s
of received echoes and receiver TCP goodput, one run per condition.
The candidate ran first.
With a 180 Mbit/s target
stock 169.8 Mbit/s 598.10 ms 103/105 echoes
candidate 180.0 Mbit/s 13.94 ms 105/105 echoes
Uncapped TCP
stock 348.7 Mbit/s 543.85 ms 102/105 echoes
candidate 380.7 Mbit/s 102.40 ms 105/105 echoes
The stock uncapped run started at one RX spatial stream and ended at
two, so it does not establish a throughput difference under identical
PHY conditions. The paced runs showed two RX spatial streams in both
snapshots. These results cover the combined backport, not the separate
effect of each patch.
A repeat after installing an official-ImageBuilder image with the same
driver gave 25.02 ms p95 at 180.0 Mbit/s and 61.38 ms at 307.3 Mbit/s
uncapped. Both returned 105/105 echoes. The installed firmware also
contained newer LuCI and PPP packages from the feed.
Codex helped prepare the backport and test harness.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-11-29 22:44 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 23:40 [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 01/10] wifi: ath11k: free tx skbs through ieee80211_free_txskb() Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 02/10] wifi: ath11k: report a dropped frame with its station Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 03/10] wifi: ath11k: enable airtime queue limits Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 04/10] wifi: ath11k: report the pending tx MSDU count in soc_dp_stats Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 05/10] wifi: ath11k: report tx airtime and enable airtime fairness Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 06/10] wifi: ath11k: schedule TXQs from the driver Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 07/10] wifi: ath11k: run the TXQ scheduler on tx completion Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 08/10] wifi: ath11k: charge received airtime to the station deficit Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 09/10] wifi: ath11k: stop a scheduling round when the hardware is full Julius Bairaktaris
2026-11-28 23:40 ` [PATCH ath-next v7 10/10] wifi: ath11k: budget the tx completion handler Julius Bairaktaris
2026-11-29 22:43 ` [PATCH ath-next v7 00/10] wifi: ath11k: airtime queue limits, airtime fairness and a driver TXQ scheduler Giuseppe Piscitelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox