301-ath9k-limit-retries-for-powersave-response-frames.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From: Felix Fietkau <nbd@openwrt.org>
  2. Date: Thu, 2 Jul 2015 15:20:56 +0200
  3. Subject: [PATCH] ath9k: limit retries for powersave response frames
  4. In some cases, the channel might be busy enough that an ath9k AP's
  5. response to PS-Poll frames might be too slow and the station has already
  6. gone to sleep. To avoid wasting too much airtime on this, limit the
  7. number of retries on such frames and ensure that no sample rate gets
  8. used.
  9. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  10. ---
  11. --- a/drivers/net/wireless/ath/ath9k/xmit.c
  12. +++ b/drivers/net/wireless/ath/ath9k/xmit.c
  13. @@ -136,10 +136,25 @@ static void ath_send_bar(struct ath_atx_
  14. }
  15. static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  16. - struct ath_buf *bf)
  17. + struct ath_buf *bf, bool ps)
  18. {
  19. + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu);
  20. +
  21. + if (ps) {
  22. + /* Clear the first rate to avoid using a sample rate for PS frames */
  23. + info->control.rates[0].idx = -1;
  24. + info->control.rates[0].count = 0;
  25. + }
  26. +
  27. ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
  28. ARRAY_SIZE(bf->rates));
  29. + if (!ps)
  30. + return;
  31. +
  32. + if (bf->rates[0].count > 2)
  33. + bf->rates[0].count = 2;
  34. +
  35. + bf->rates[1].idx = -1;
  36. }
  37. static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
  38. @@ -1419,7 +1434,7 @@ ath_tx_form_burst(struct ath_softc *sc,
  39. if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
  40. break;
  41. - ath_set_rates(tid->an->vif, tid->an->sta, bf);
  42. + ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
  43. } while (1);
  44. }
  45. @@ -1450,7 +1465,7 @@ static bool ath_tx_sched_aggr(struct ath
  46. return false;
  47. }
  48. - ath_set_rates(tid->an->vif, tid->an->sta, bf);
  49. + ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
  50. if (aggr)
  51. last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
  52. tid_q, &aggr_len);
  53. @@ -1647,7 +1662,7 @@ void ath9k_release_buffered_frames(struc
  54. __skb_unlink(bf->bf_mpdu, tid_q);
  55. list_add_tail(&bf->list, &bf_q);
  56. - ath_set_rates(tid->an->vif, tid->an->sta, bf);
  57. + ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
  58. if (bf_isampdu(bf)) {
  59. ath_tx_addto_baw(sc, tid, bf);
  60. bf->bf_state.bf_type &= ~BUF_AGGR;
  61. @@ -2293,7 +2308,7 @@ int ath_tx_start(struct ieee80211_hw *hw
  62. struct ath_txq *txq = txctl->txq;
  63. struct ath_atx_tid *tid = NULL;
  64. struct ath_buf *bf;
  65. - bool queue, skip_uapsd = false, ps_resp;
  66. + bool queue, ps_resp;
  67. int q, ret;
  68. if (vif)
  69. @@ -2346,13 +2361,13 @@ int ath_tx_start(struct ieee80211_hw *hw
  70. if (!txctl->an)
  71. txctl->an = &avp->mcast_node;
  72. queue = true;
  73. - skip_uapsd = true;
  74. + ps_resp = false;
  75. }
  76. if (txctl->an && queue)
  77. tid = ath_get_skb_tid(sc, txctl->an, skb);
  78. - if (!skip_uapsd && ps_resp) {
  79. + if (ps_resp) {
  80. ath_txq_unlock(sc, txq);
  81. txq = sc->tx.uapsdq;
  82. ath_txq_lock(sc, txq);
  83. @@ -2390,7 +2405,7 @@ int ath_tx_start(struct ieee80211_hw *hw
  84. if (txctl->paprd)
  85. bf->bf_state.bfs_paprd_timestamp = jiffies;
  86. - ath_set_rates(vif, sta, bf);
  87. + ath_set_rates(vif, sta, bf, ps_resp);
  88. ath_tx_send_normal(sc, txq, tid, skb);
  89. out:
  90. @@ -2429,7 +2444,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
  91. break;
  92. bf->bf_lastbf = bf;
  93. - ath_set_rates(vif, NULL, bf);
  94. + ath_set_rates(vif, NULL, bf, false);
  95. ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
  96. duration += info.rates[0].PktDuration;
  97. if (bf_tail)
  98. @@ -2932,7 +2947,7 @@ int ath9k_tx99_send(struct ath_softc *sc
  99. return -EINVAL;
  100. }
  101. - ath_set_rates(sc->tx99_vif, NULL, bf);
  102. + ath_set_rates(sc->tx99_vif, NULL, bf, false);
  103. ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
  104. ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);