305-ath9k-limit-retries-for-powersave-response-frames.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. @@ -188,10 +188,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. @@ -1522,7 +1537,7 @@ ath_tx_form_burst(struct ath_softc *sc,
  39. break;
  40. }
  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. @@ -1552,7 +1567,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. aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
  52. else
  53. @@ -1710,7 +1725,7 @@ void ath9k_release_buffered_frames(struc
  54. break;
  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. @@ -2410,7 +2425,7 @@ int ath_tx_start(struct ieee80211_hw *hw
  62. if (txctl->paprd)
  63. bf->bf_state.bfs_paprd_timestamp = jiffies;
  64. - ath_set_rates(vif, sta, bf);
  65. + ath_set_rates(vif, sta, bf, ps_resp);
  66. ath_tx_send_normal(sc, txq, tid, skb);
  67. out:
  68. @@ -2449,7 +2464,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
  69. break;
  70. bf->bf_lastbf = bf;
  71. - ath_set_rates(vif, NULL, bf);
  72. + ath_set_rates(vif, NULL, bf, false);
  73. ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
  74. duration += info.rates[0].PktDuration;
  75. if (bf_tail)
  76. @@ -2968,7 +2983,7 @@ int ath9k_tx99_send(struct ath_softc *sc
  77. return -EINVAL;
  78. }
  79. - ath_set_rates(sc->tx99_vif, NULL, bf);
  80. + ath_set_rates(sc->tx99_vif, NULL, bf, false);
  81. ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
  82. ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);