556-ath9k-dynack-make-ewma-estimation-faster.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. From: Lorenzo Bianconi <[email protected]>
  2. Date: Fri, 2 Nov 2018 21:49:58 +0100
  3. Subject: [PATCH] ath9k: dynack: make ewma estimation faster
  4. In order to make propagation time estimation faster,
  5. use current sample as ewma output value during 'late ack'
  6. tracking
  7. Tested-by: Koen Vandeputte <[email protected]>
  8. Signed-off-by: Lorenzo Bianconi <[email protected]>
  9. ---
  10. --- a/drivers/net/wireless/ath/ath9k/ath9k.h
  11. +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
  12. @@ -274,7 +274,7 @@ struct ath_node {
  13. #endif
  14. u8 key_idx[4];
  15. - u32 ackto;
  16. + int ackto;
  17. struct list_head list;
  18. };
  19. --- a/drivers/net/wireless/ath/ath9k/dynack.c
  20. +++ b/drivers/net/wireless/ath/ath9k/dynack.c
  21. @@ -29,9 +29,13 @@
  22. * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation
  23. *
  24. */
  25. -static inline u32 ath_dynack_ewma(u32 old, u32 new)
  26. +static inline int ath_dynack_ewma(int old, int new)
  27. {
  28. - return (new * (EWMA_DIV - EWMA_LEVEL) + old * EWMA_LEVEL) / EWMA_DIV;
  29. + if (old > 0)
  30. + return (new * (EWMA_DIV - EWMA_LEVEL) +
  31. + old * EWMA_LEVEL) / EWMA_DIV;
  32. + else
  33. + return new;
  34. }
  35. /**
  36. @@ -82,10 +86,10 @@ static inline bool ath_dynack_bssidmask(
  37. */
  38. static void ath_dynack_compute_ackto(struct ath_hw *ah)
  39. {
  40. - struct ath_node *an;
  41. - u32 to = 0;
  42. - struct ath_dynack *da = &ah->dynack;
  43. struct ath_common *common = ath9k_hw_common(ah);
  44. + struct ath_dynack *da = &ah->dynack;
  45. + struct ath_node *an;
  46. + int to = 0;
  47. list_for_each_entry(an, &da->nodes, list)
  48. if (an->ackto > to)
  49. @@ -144,7 +148,8 @@ static void ath_dynack_compute_to(struct
  50. an->ackto = ath_dynack_ewma(an->ackto,
  51. ackto);
  52. ath_dbg(ath9k_hw_common(ah), DYNACK,
  53. - "%pM to %u\n", dst, an->ackto);
  54. + "%pM to %d [%u]\n", dst,
  55. + an->ackto, ackto);
  56. if (time_is_before_jiffies(da->lto)) {
  57. ath_dynack_compute_ackto(ah);
  58. da->lto = jiffies + COMPUTE_TO;
  59. @@ -166,10 +171,12 @@ static void ath_dynack_compute_to(struct
  60. * @ah: ath hw
  61. * @skb: socket buffer
  62. * @ts: tx status info
  63. + * @sta: station pointer
  64. *
  65. */
  66. void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
  67. - struct ath_tx_status *ts)
  68. + struct ath_tx_status *ts,
  69. + struct ieee80211_sta *sta)
  70. {
  71. struct ieee80211_hdr *hdr;
  72. struct ath_dynack *da = &ah->dynack;
  73. @@ -191,9 +198,16 @@ void ath_dynack_sample_tx_ts(struct ath_
  74. ieee80211_is_assoc_resp(hdr->frame_control) ||
  75. ieee80211_is_auth(hdr->frame_control)) {
  76. ath_dbg(common, DYNACK, "late ack\n");
  77. +
  78. ath9k_hw_setslottime(ah, (LATEACK_TO - 3) / 2);
  79. ath9k_hw_set_ack_timeout(ah, LATEACK_TO);
  80. ath9k_hw_set_cts_timeout(ah, LATEACK_TO);
  81. + if (sta) {
  82. + struct ath_node *an;
  83. +
  84. + an = (struct ath_node *)sta->drv_priv;
  85. + an->ackto = -1;
  86. + }
  87. da->lto = jiffies + LATEACK_DELAY;
  88. }
  89. --- a/drivers/net/wireless/ath/ath9k/dynack.h
  90. +++ b/drivers/net/wireless/ath/ath9k/dynack.h
  91. @@ -86,7 +86,8 @@ void ath_dynack_node_deinit(struct ath_h
  92. void ath_dynack_init(struct ath_hw *ah);
  93. void ath_dynack_sample_ack_ts(struct ath_hw *ah, struct sk_buff *skb, u32 ts);
  94. void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
  95. - struct ath_tx_status *ts);
  96. + struct ath_tx_status *ts,
  97. + struct ieee80211_sta *sta);
  98. #else
  99. static inline void ath_dynack_init(struct ath_hw *ah) {}
  100. static inline void ath_dynack_node_init(struct ath_hw *ah,
  101. @@ -97,7 +98,8 @@ static inline void ath_dynack_sample_ack
  102. struct sk_buff *skb, u32 ts) {}
  103. static inline void ath_dynack_sample_tx_ts(struct ath_hw *ah,
  104. struct sk_buff *skb,
  105. - struct ath_tx_status *ts) {}
  106. + struct ath_tx_status *ts,
  107. + struct ieee80211_sta *sta) {}
  108. #endif
  109. #endif /* DYNACK_H */
  110. --- a/drivers/net/wireless/ath/ath9k/xmit.c
  111. +++ b/drivers/net/wireless/ath/ath9k/xmit.c
  112. @@ -629,7 +629,7 @@ static void ath_tx_complete_aggr(struct
  113. if (bf == bf->bf_lastbf)
  114. ath_dynack_sample_tx_ts(sc->sc_ah,
  115. bf->bf_mpdu,
  116. - ts);
  117. + ts, sta);
  118. }
  119. ath_tx_complete_buf(sc, bf, txq, &bf_head, sta, ts,
  120. @@ -773,7 +773,8 @@ static void ath_tx_process_buffer(struct
  121. memcpy(info->control.rates, bf->rates,
  122. sizeof(info->control.rates));
  123. ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok);
  124. - ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts);
  125. + ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts,
  126. + sta);
  127. }
  128. ath_tx_complete_buf(sc, bf, txq, bf_head, sta, ts, txok);
  129. } else