Calculate the estimated airtime pending in the txqs and apply AQL to
prevent excessive amounts of packets being queued in the firmware queue.

Change-Id: I4047ce0938f7b97440fb040b16b74f2e49aa3433
Signed-off-by: Kan Yan <k...@google.com>
---
 drivers/net/wireless/ath/ath10k/mac.c  |  7 +++++--
 drivers/net/wireless/ath/ath10k/txrx.c | 12 +++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 0606416dc971..37eb56c19f19 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3983,6 +3983,9 @@ static bool ath10k_mac_tx_can_push(struct ieee80211_hw 
*hw,
        struct ath10k_txq *artxq = (void *)txq->drv_priv;
 
        /* No need to get locks */
+       if (!ieee80211_txq_airtime_check(hw, txq))
+               return false;
+
        if (ar->htt.tx_q_state.mode == HTT_TX_MODE_SWITCH_PUSH)
                return true;
 
@@ -4014,8 +4017,6 @@ static u16 ath10k_mac_update_airtime(struct ath10k *ar,
        if (!txq || !txq->sta)
                return airtime;
 
-       if (test_bit(WMI_SERVICE_REPORT_AIRTIME, ar->wmi.svc_map))
-               return airtime;
 
        spin_lock_bh(&ar->data_lock);
        arsta = (struct ath10k_sta *)txq->sta->drv_priv;
@@ -4038,6 +4039,8 @@ static u16 ath10k_mac_update_airtime(struct ath10k *ar,
        }
        spin_unlock_bh(&ar->data_lock);
 
+       ieee80211_sta_register_pending_airtime(txq->sta, txq->tid, airtime,
+                                              false);
        return airtime;
 }
 
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c 
b/drivers/net/wireless/ath/ath10k/txrx.c
index 4102df016931..9266d3dd6adb 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -84,9 +84,15 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
                wake_up(&htt->empty_tx_wq);
        spin_unlock_bh(&htt->tx_lock);
 
-       if (txq && txq->sta && skb_cb->airtime_est)
-               ieee80211_sta_register_airtime(txq->sta, txq->tid,
-                                              skb_cb->airtime_est, 0);
+       if (txq && txq->sta && skb_cb->airtime_est) {
+               if (!test_bit(WMI_SERVICE_REPORT_AIRTIME, ar->wmi.svc_map))
+                       ieee80211_sta_register_airtime(txq->sta, txq->tid,
+                                                      skb_cb->airtime_est, 0);
+
+               ieee80211_sta_register_pending_airtime(txq->sta, txq->tid,
+                                                      skb_cb->airtime_est,
+                                                      true);
+       }
 
        if (ar->bus_param.dev_type != ATH10K_DEV_TYPE_HL)
                dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
-- 
2.23.0.581.g78d2f28ef7-goog

Reply via email to