Fresh pull from upstream
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 338-mac80211-minstrel-remove-cur_prob-from-debugfs.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 14 Dec 2016 20:13:58 +0100
3 Subject: [PATCH] mac80211: minstrel: remove cur_prob from debugfs
4
5 This field is redundant, because it is simply last success divided by
6 last attempt count. Removing it from the rate stats struct saves about
7 1.2 KiB per HT station.
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/net/mac80211/rc80211_minstrel.c
13 +++ b/net/mac80211/rc80211_minstrel.c
14 @@ -159,21 +159,23 @@ minstrel_update_rates(struct minstrel_pr
15  void
16  minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
17  {
18 +       unsigned int cur_prob;
19 +
20         if (unlikely(mrs->attempts > 0)) {
21                 mrs->sample_skipped = 0;
22 -               mrs->cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
23 +               cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
24                 if (unlikely(!mrs->att_hist)) {
25 -                       mrs->prob_ewma = mrs->cur_prob;
26 +                       mrs->prob_ewma = cur_prob;
27                 } else {
28                         /* update exponential weighted moving variance */
29                         mrs->prob_ewmsd = minstrel_ewmsd(mrs->prob_ewmsd,
30 -                                                        mrs->cur_prob,
31 +                                                        cur_prob,
32                                                          mrs->prob_ewma,
33                                                          EWMA_LEVEL);
34  
35                         /*update exponential weighted moving avarage */
36                         mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
37 -                                                      mrs->cur_prob,
38 +                                                      cur_prob,
39                                                        EWMA_LEVEL);
40                 }
41                 mrs->att_hist += mrs->attempts;
42 --- a/net/mac80211/rc80211_minstrel.h
43 +++ b/net/mac80211/rc80211_minstrel.h
44 @@ -62,10 +62,8 @@ struct minstrel_rate_stats {
45         u32 att_hist, succ_hist;
46  
47         /* statistis of packet delivery probability
48 -        *  cur_prob  - current prob within last update intervall
49          *  prob_ewma - exponential weighted moving average of prob
50          *  prob_ewmsd - exp. weighted moving standard deviation of prob */
51 -       unsigned int cur_prob;
52         unsigned int prob_ewma;
53         u16 prob_ewmsd;
54  
55 --- a/net/mac80211/rc80211_minstrel_debugfs.c
56 +++ b/net/mac80211/rc80211_minstrel_debugfs.c
57 @@ -75,7 +75,7 @@ minstrel_stats_open(struct inode *inode,
58  {
59         struct minstrel_sta_info *mi = inode->i_private;
60         struct minstrel_debugfs_info *ms;
61 -       unsigned int i, tp_max, tp_avg, prob, eprob;
62 +       unsigned int i, tp_max, tp_avg, eprob;
63         char *p;
64  
65         ms = kmalloc(2048, GFP_KERNEL);
66 @@ -86,9 +86,9 @@ minstrel_stats_open(struct inode *inode,
67         p = ms->buf;
68         p += sprintf(p, "\n");
69         p += sprintf(p,
70 -                    "best   __________rate_________    ________statistics________    ________last_______    ______sum-of________\n");
71 +                    "best   __________rate_________    ________statistics________    ____last_____    ______sum-of________\n");
72         p += sprintf(p,
73 -                    "rate  [name idx airtime max_tp]  [avg(tp) avg(prob) sd(prob)]  [prob.|retry|suc|att]  [#success | #attempts]\n");
74 +                    "rate  [name idx airtime max_tp]  [avg(tp) avg(prob) sd(prob)]  [retry|suc|att]  [#success | #attempts]\n");
75  
76         for (i = 0; i < mi->n_rates; i++) {
77                 struct minstrel_rate *mr = &mi->r[i];
78 @@ -107,17 +107,15 @@ minstrel_stats_open(struct inode *inode,
79  
80                 tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
81                 tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
82 -               prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
83                 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
84  
85                 p += sprintf(p, "%4u.%1u    %4u.%1u     %3u.%1u    %3u.%1u"
86 -                               "     %3u.%1u %3u   %3u %-3u   "
87 +                               "     %3u   %3u %-3u   "
88                                 "%9llu   %-9llu\n",
89                                 tp_max / 10, tp_max % 10,
90                                 tp_avg / 10, tp_avg % 10,
91                                 eprob / 10, eprob % 10,
92                                 mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
93 -                               prob / 10, prob % 10,
94                                 mrs->retry_count,
95                                 mrs->last_success,
96                                 mrs->last_attempts,
97 @@ -148,7 +146,7 @@ minstrel_stats_csv_open(struct inode *in
98  {
99         struct minstrel_sta_info *mi = inode->i_private;
100         struct minstrel_debugfs_info *ms;
101 -       unsigned int i, tp_max, tp_avg, prob, eprob;
102 +       unsigned int i, tp_max, tp_avg, eprob;
103         char *p;
104  
105         ms = kmalloc(2048, GFP_KERNEL);
106 @@ -175,16 +173,14 @@ minstrel_stats_csv_open(struct inode *in
107  
108                 tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
109                 tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
110 -               prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
111                 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
112  
113 -               p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
114 +               p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
115                                 "%llu,%llu,%d,%d\n",
116                                 tp_max / 10, tp_max % 10,
117                                 tp_avg / 10, tp_avg % 10,
118                                 eprob / 10, eprob % 10,
119                                 mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
120 -                               prob / 10, prob % 10,
121                                 mrs->retry_count,
122                                 mrs->last_success,
123                                 mrs->last_attempts,
124 --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
125 +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
126 @@ -19,7 +19,7 @@ static char *
127  minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
128  {
129         const struct mcs_group *mg;
130 -       unsigned int j, tp_max, tp_avg, prob, eprob, tx_time;
131 +       unsigned int j, tp_max, tp_avg, eprob, tx_time;
132         char htmode = '2';
133         char gimode = 'L';
134         u32 gflags;
135 @@ -83,17 +83,15 @@ minstrel_ht_stats_dump(struct minstrel_h
136  
137                 tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
138                 tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
139 -               prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
140                 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
141  
142                 p += sprintf(p, "%4u.%1u    %4u.%1u     %3u.%1u    %3u.%1u"
143 -                               "     %3u.%1u %3u   %3u %-3u   "
144 +                               "     %3u   %3u %-3u   "
145                                 "%9llu   %-9llu\n",
146                                 tp_max / 10, tp_max % 10,
147                                 tp_avg / 10, tp_avg % 10,
148                                 eprob / 10, eprob % 10,
149                                 mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
150 -                               prob / 10, prob % 10,
151                                 mrs->retry_count,
152                                 mrs->last_success,
153                                 mrs->last_attempts,
154 @@ -130,9 +128,9 @@ minstrel_ht_stats_open(struct inode *ino
155  
156         p += sprintf(p, "\n");
157         p += sprintf(p,
158 -                    "              best   ____________rate__________    ________statistics________    ________last_______    ______sum-of________\n");
159 +                    "              best   ____________rate__________    ________statistics________    _____last____    ______sum-of________\n");
160         p += sprintf(p,
161 -                    "mode guard #  rate  [name   idx airtime  max_tp]  [avg(tp) avg(prob) sd(prob)]  [prob.|retry|suc|att]  [#success | #attempts]\n");
162 +                    "mode guard #  rate  [name   idx airtime  max_tp]  [avg(tp) avg(prob) sd(prob)]  [retry|suc|att]  [#success | #attempts]\n");
163  
164         p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p);
165         for (i = 0; i < MINSTREL_CCK_GROUP; i++)
166 @@ -165,7 +163,7 @@ static char *
167  minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
168  {
169         const struct mcs_group *mg;
170 -       unsigned int j, tp_max, tp_avg, prob, eprob, tx_time;
171 +       unsigned int j, tp_max, tp_avg, eprob, tx_time;
172         char htmode = '2';
173         char gimode = 'L';
174         u32 gflags;
175 @@ -226,16 +224,14 @@ minstrel_ht_stats_csv_dump(struct minstr
176  
177                 tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
178                 tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
179 -               prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
180                 eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
181  
182 -               p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
183 +               p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
184                                 "%u,%llu,%llu,",
185                                 tp_max / 10, tp_max % 10,
186                                 tp_avg / 10, tp_avg % 10,
187                                 eprob / 10, eprob % 10,
188                                 mrs->prob_ewmsd / 10, mrs->prob_ewmsd % 10,
189 -                               prob / 10, prob % 10,
190                                 mrs->retry_count,
191                                 mrs->last_success,
192                                 mrs->last_attempts,