wifi: ath12k: implement TX flow control
v8 cover wifi: ath12k: implement TX flow control
This series implements a custom wake_tx_queue operation for the ath12k driver to prevent hardware ring overflow issues under heavy traffic.
Without proper flow control, the driver can hang and experiences -ENOMEM errors ("failed to transmit frame -12") when the hardware TCL ring fills up. These issues are more commonly observed in VMs with PCIe passthrough but also occur on bare metal systems.
The implementation follows the pattern used in the iwlwifi driver, adapted for ath12k hardware ring architecture, checking hardware ring space before dequeuing packets from mac80211.
Testing shows stable operation with eliminated -ENOMEM errors, no hangs, and improved throughput under heavy traffic conditions.
Jose Ignacio Tornos Martinez (2):
wifi: ath12k: remove skb parameter from get_ring_selector
wifi: ath12k: implement custom wake_tx_queue with flow control
v8: Split ath11k and ath12k into separate series to avoid conflict
with Julius's airtime queue limits series (ath11k only) and help to unblock both
No code changes from v7
v7: https://lore.kernel.org/all/[email protected]/
--
2.54.0
PATCH v8 1/2 wifi: ath12k: remove skb parameter from get_ring_selector
Change the get_ring_selector hw_ops callback signature from get_ring_selector(struct sk_buff *skb) to get_ring_selector(u8 ac), removing the dependency on the skb.
All ath12k get_ring_selector implementations fall into two categories:
- smp_processor_id(): ignores the skb entirely
- skb_get_queue_mapping(): only reads the AC value from the skb
Since the AC is the only information extracted from the skb, pass it directly as a u8 parameter instead. Callers in the dp_tx path now pass skb_get_queue_mapping(skb), which preserves the exact same behavior.
This change enables a subsequent patch to call get_ring_selector() from wake_tx_queue using txq->ac, without needing access to the skb. mac80211 guarantees that skb_get_queue_mapping(skb) == txq->ac for any skb dequeued from a given txq, since both values are derived from the same skb->priority through the same AC mapping.
No functional change.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
---
v8: Split ath11k and ath12k into separate series to avoid conflict
with Julius's airtime queue limits series (ath11k only) and help to unblock both
No code changes from v7
v7: https://lore.kernel.org/all/[email protected]/
drivers/net/wireless/ath/ath12k/hw.h | 2 +- drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c | 2 +- drivers/net/wireless/ath/ath12k/wifi7/hw.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath12k/hw.h +1 -1
@@ -243,7 +243,7 @@ struct ath12k_hw_ops {int (*mac_id_to_pdev_id)(const struct ath12k_hw_params *hw,int mac_id);int (*mac_id_to_srng_id)(const struct ath12k_hw_params *hw,int mac_id);int (*rxdma_ring_sel_config)(struct ath12k_base *ab); -u8 (*get_ring_selector)(struct sk_buff *skb); +u8 (*get_ring_selector)(u8 ac);bool (*dp_srng_is_tx_comp_ring)(int ring_num);bool (*is_frame_link_agnostic)(struct ath12k_link_vif *arvif,struct ieee80211_mgmt *mgmt);
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c +1 -1
@@ -111,7 +111,7 @@ int ath12k_wifi7_dp_tx(struct ath12k_pdev_dp *dp_pdev, struct ath12k_link_vif *a* If all rings are full, we drop the packet. * TODO: Add throttling logic when all rings are full */ - ring_selector = dp->hw_params->hw_ops->get_ring_selector (skb); + ring_selector = dp->hw_params->hw_ops->get_ring_selector (skb_get_queue_mapping (skb)); tcl_ring_sel: tcl_ring_retry = false;
drivers/net/wireless/ath/ath12k/wifi7/hw.c +3 -3
@@ -49,7 +49,7 @@ ath12k_wifi7_hw_mac_id_to_srng_id_qcn9274(const struct ath12k_hw_params *hw,return 0 ; } -static u8 ath12k_wifi7_hw_get_ring_selector_qcn9274 (struct sk_buff *skb) +static u8 ath12k_wifi7_hw_get_ring_selector_qcn9274 (u8 ac) {return smp_processor_id (); }
@@ -83,9 +83,9 @@ ath12k_wifi7_hw_mac_id_to_srng_id_wcn7850(const struct ath12k_hw_params *hw,return mac_id; } -static u8 ath12k_wifi7_hw_get_ring_selector_wcn7850 (struct sk_buff *skb) +static u8 ath12k_wifi7_hw_get_ring_selector_wcn7850 (u8 ac) { -return skb_get_queue_mapping (skb); +return ac; }static bool ath12k_wifi7_dp_srng_is_comp_ring_wcn7850 (int ring_num)
--
2.54.0
PATCH v8 2/2 wifi: ath12k: implement custom wake_tx_queue with flow control
In reply to Jose Ignacio Tornos MartinezUnder heavy traffic, ath12k can hang and experiences -ENOMEM errors ("failed to transmit frame -12") when the hardware TCL ring fills up. This issue is more commonly observed in VMs with PCIe passthrough but also occurs on bare metal systems.
Implement a custom wake_tx_queue operation that:
1. Checks hardware ring space before dequeuing packets from mac80211
2. Uses per-ring locking (wake_tx_lock with spin_lock_bh) to serialize concurrent wake_tx_queue calls targeting the same ring and to ensure bottom halves are disabled as required by ieee80211_tx_dequeue()
3. Syncs with hardware state to get accurate free slot count
4. Resolves the target TCL ring once using get_ring_selector(txq->ac), which selects the ring based on the access category
5. Returns early during firmware crash in the same way as other tx paths
This approach follows the pattern used in the iwlwifi driver, adapted for ath12k's hardware ring architecture.
This prevents hangs, eliminates -ENOMEM errors, and improves throughput by optimizing resource usage and preventing unnecessary packet drops.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
---
v8: Split ath11k and ath12k into separate series to avoid conflict
with Julius's airtime queue limits series (ath11k only) and help to unblock both
No code changes from v7
v7: https://lore.kernel.org/all/[email protected]/
drivers/net/wireless/ath/ath12k/dp.c | 1 + drivers/net/wireless/ath/ath12k/dp.h | 2 + drivers/net/wireless/ath/ath12k/hal.c | 1 + drivers/net/wireless/ath/ath12k/wifi7/hw.c | 69 +++++++++++++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/dp.c +1 -0
@@ -1537,6 +1537,7 @@ static int ath12k_dp_setup(struct ath12k_base *ab) }for (i =0 ; i < ab->hw_params->max_tx_ring; i++) { +spin_lock_init (&dp->tx_ring[i].wake_tx_lock); dp->tx_ring[i].tcl_data_ring_id = i; dp->tx_ring[i].tx_status_head =0 ;
drivers/net/wireless/ath/ath12k/dp.h +2 -0
@@ -58,6 +58,8 @@ struct dp_tx_ring {u8 tcl_data_ring_id;struct dp_srng tcl_data_ring;struct dp_srng tcl_comp_ring; +/* Serializes wake_tx_queue operations for this ring */ +spinlock_t wake_tx_lock;struct hal_wbm_completion_ring_tx *tx_status;int tx_status_head;int tx_status_tail;
drivers/net/wireless/ath/ath12k/hal.c +1 -0
@@ -390,6 +390,7 @@ int ath12k_hal_srng_src_num_free(struct ath12k_base *ab, struct hal_srng *srng,else return ((srng->ring_size - hp + tp) / srng->entry_size) -1 ; } +EXPORT_SYMBOL (ath12k_hal_srng_src_num_free);void *ath12k_hal_srng_src_next_peek (struct ath12k_base *ab,struct hal_srng *srng)
drivers/net/wireless/ath/ath12k/wifi7/hw.c +68 -1
77 lines not on this page · raw message
--
2.54.0