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