2
0

320-ath9k-clean-up-and-fix-ath_tx_count_airtime.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Sun, 12 Feb 2017 13:13:05 +0100
  3. Subject: [PATCH] ath9k: clean up and fix ath_tx_count_airtime
  4. ath_tx_count_airtime is doing a lot of unnecessary work:
  5. - Redundant station lookup
  6. - Redundant rcu_read_lock/unlock
  7. - Useless memcpy of bf->rates
  8. - Useless NULL check of bf->bf_mpdu
  9. - Redundant lookup of the skb tid
  10. Additionally, it tries to look up the mac80211 queue index from the txq,
  11. which fails if the frame was delivered via the power save queue.
  12. This patch fixes all of these issues by passing down the right set of
  13. pointers instead of doing extra work
  14. Cc: stable@vger.kernel.org
  15. Fixes: 63fefa050477 ("ath9k: Introduce airtime fairness scheduling between stations")
  16. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  17. ---
  18. --- a/drivers/net/wireless/ath/ath9k/xmit.c
  19. +++ b/drivers/net/wireless/ath/ath9k/xmit.c
  20. @@ -723,51 +723,31 @@ static bool bf_is_ampdu_not_probing(stru
  21. return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE);
  22. }
  23. -static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_txq *txq,
  24. - struct ath_buf *bf, struct ath_tx_status *ts)
  25. +static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an,
  26. + struct ath_atx_tid *tid, struct ath_buf *bf,
  27. + struct ath_tx_status *ts)
  28. {
  29. - struct ath_node *an;
  30. - struct ath_acq *acq = &sc->cur_chan->acq[txq->mac80211_qnum];
  31. - struct sk_buff *skb;
  32. - struct ieee80211_hdr *hdr;
  33. - struct ieee80211_hw *hw = sc->hw;
  34. - struct ieee80211_tx_rate rates[4];
  35. - struct ieee80211_sta *sta;
  36. - int i;
  37. + struct ath_txq *txq = tid->txq;
  38. u32 airtime = 0;
  39. -
  40. - skb = bf->bf_mpdu;
  41. - if(!skb)
  42. - return;
  43. -
  44. - hdr = (struct ieee80211_hdr *)skb->data;
  45. - memcpy(rates, bf->rates, sizeof(rates));
  46. -
  47. - rcu_read_lock();
  48. -
  49. - sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
  50. - if(!sta)
  51. - goto exit;
  52. -
  53. -
  54. - an = (struct ath_node *) sta->drv_priv;
  55. + int i;
  56. airtime += ts->duration * (ts->ts_longretry + 1);
  57. + for(i = 0; i < ts->ts_rateindex; i++) {
  58. + int rate_dur = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i);
  59. + airtime += rate_dur * bf->rates[i].count;
  60. + }
  61. - for(i=0; i < ts->ts_rateindex; i++)
  62. - airtime += ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i) * rates[i].count;
  63. + if (sc->airtime_flags & AIRTIME_USE_TX) {
  64. + int q = txq->mac80211_qnum;
  65. + struct ath_acq *acq = &sc->cur_chan->acq[q];
  66. - if (!!(sc->airtime_flags & AIRTIME_USE_TX)) {
  67. spin_lock_bh(&acq->lock);
  68. - an->airtime_deficit[txq->mac80211_qnum] -= airtime;
  69. - if (an->airtime_deficit[txq->mac80211_qnum] <= 0)
  70. - __ath_tx_queue_tid(sc, ath_get_skb_tid(sc, an, skb));
  71. + an->airtime_deficit[q] -= airtime;
  72. + if (an->airtime_deficit[q] <= 0)
  73. + __ath_tx_queue_tid(sc, tid);
  74. spin_unlock_bh(&acq->lock);
  75. }
  76. ath_debug_airtime(sc, an, 0, airtime);
  77. -
  78. -exit:
  79. - rcu_read_unlock();
  80. }
  81. static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
  82. @@ -791,13 +771,13 @@ static void ath_tx_process_buffer(struct
  83. ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc,
  84. ts->ts_rateindex);
  85. - ath_tx_count_airtime(sc, txq, bf, ts);
  86. hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
  87. sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
  88. if (sta) {
  89. struct ath_node *an = (struct ath_node *)sta->drv_priv;
  90. tid = ath_get_skb_tid(sc, an, bf->bf_mpdu);
  91. + ath_tx_count_airtime(sc, an, tid, bf, ts);
  92. if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY))
  93. tid->clear_ps_filter = true;
  94. }