mac80211: update to wireless-testing 2011-09-14
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 560-minstrel_ht_optimize.patch
1 --- a/net/mac80211/rc80211_minstrel_ht.h
2 +++ b/net/mac80211/rc80211_minstrel_ht.h
3 @@ -70,6 +70,8 @@ struct minstrel_mcs_group_data {
4 };
5
6 struct minstrel_ht_sta {
7 + struct ieee80211_tx_rate tx_rates[3];
8 +
9 /* ampdu length (average, per sampling interval) */
10 unsigned int ampdu_len;
11 unsigned int ampdu_packets;
12 --- a/net/mac80211/rc80211_minstrel_ht.c
13 +++ b/net/mac80211/rc80211_minstrel_ht.c
14 @@ -87,6 +87,10 @@ const struct mcs_group minstrel_mcs_grou
15
16 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
17
18 +static void
19 +minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
20 + struct ieee80211_tx_rate *rate, int index,
21 + bool sample, bool rtscts);
22 /*
23 * Perform EWMA (Exponentially Weighted Moving Average) calculation
24 */
25 @@ -174,6 +178,17 @@ minstrel_ht_calc_tp(struct minstrel_priv
26 mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
27 }
28
29 +static void
30 +minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
31 +{
32 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[0], mi->max_tp_rate,
33 + false, false);
34 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[1], mi->max_tp_rate2,
35 + false, true);
36 + minstrel_ht_set_rate(mp, mi, &mi->tx_rates[2], mi->max_prob_rate,
37 + false, true);
38 +}
39 +
40 /*
41 * Update rate statistics and select new primary rates
42 *
43 @@ -292,6 +307,7 @@ minstrel_ht_update_stats(struct minstrel
44 }
45 }
46
47 + minstrel_ht_update_rates(mp, mi);
48 mi->stats_update = jiffies;
49 }
50
51 @@ -330,8 +346,8 @@ minstrel_next_sample_idx(struct minstrel
52 }
53
54 static void
55 -minstrel_downgrade_rate(struct minstrel_ht_sta *mi, unsigned int *idx,
56 - bool primary)
57 +minstrel_downgrade_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
58 + unsigned int *idx, bool primary)
59 {
60 int group, orig_group;
61
62 @@ -350,6 +366,7 @@ minstrel_downgrade_rate(struct minstrel_
63 *idx = mi->groups[group].max_tp_rate;
64 else
65 *idx = mi->groups[group].max_tp_rate2;
66 + minstrel_ht_update_rates(mp, mi);
67 break;
68 }
69 }
70 @@ -450,13 +467,13 @@ minstrel_ht_tx_status(void *priv, struct
71 if (rate->attempts > 30 &&
72 MINSTREL_FRAC(rate->success, rate->attempts) <
73 MINSTREL_FRAC(20, 100))
74 - minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
75 + minstrel_downgrade_rate(mp, mi, &mi->max_tp_rate, true);
76
77 rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
78 if (rate2->attempts > 30 &&
79 MINSTREL_FRAC(rate2->success, rate2->attempts) <
80 MINSTREL_FRAC(20, 100))
81 - minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
82 + minstrel_downgrade_rate(mp, mi, &mi->max_tp_rate2, false);
83
84 if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
85 minstrel_ht_update_stats(mp, mi);
86 @@ -521,7 +538,6 @@ minstrel_calc_retransmit(struct minstrel
87 static void
88 minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
89 struct ieee80211_tx_rate *rate, int index,
90 - struct ieee80211_tx_rate_control *txrc,
91 bool sample, bool rtscts)
92 {
93 const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
94 @@ -609,6 +625,7 @@ minstrel_ht_get_rate(void *priv, struct
95 struct minstrel_priv *mp = priv;
96 int sample_idx;
97 bool sample = false;
98 + int last = 0;
99
100 if (rate_control_send_low(sta, priv_sta, txrc))
101 return;
102 @@ -634,11 +651,10 @@ minstrel_ht_get_rate(void *priv, struct
103 if (sample_idx >= 0) {
104 sample = true;
105 minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
106 - txrc, true, false);
107 + true, false);
108 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
109 } else {
110 - minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
111 - txrc, false, false);
112 + ar[0] = mi->tx_rates[0];
113 }
114
115 if (mp->hw->max_rates >= 3) {
116 @@ -648,33 +664,27 @@ minstrel_ht_get_rate(void *priv, struct
117 * max_tp_rate -> max_tp_rate2 -> max_prob_rate by default.
118 */
119 if (sample_idx >= 0)
120 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
121 - txrc, false, false);
122 + ar[1] = mi->tx_rates[0];
123 else
124 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
125 - txrc, false, true);
126 -
127 - minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate,
128 - txrc, false, !sample);
129 + ar[1] = mi->tx_rates[1];
130
131 - ar[3].count = 0;
132 - ar[3].idx = -1;
133 + ar[2] = mi->tx_rates[2];
134 + last = 3;
135 } else if (mp->hw->max_rates == 2) {
136 /*
137 * Only 2 tx rates supported, use
138 * sample_rate -> max_prob_rate for sampling and
139 * max_tp_rate -> max_prob_rate by default.
140 */
141 - minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_prob_rate,
142 - txrc, false, !sample);
143 -
144 - ar[2].count = 0;
145 - ar[2].idx = -1;
146 + ar[1] = mi->tx_rates[2];
147 + last = 2;
148 } else {
149 /* Not using MRR, only use the first rate */
150 - ar[1].count = 0;
151 - ar[1].idx = -1;
152 + last = 1;
153 +
154 }
155 + ar[last].count = 0;
156 + ar[last].idx = -1;
157
158 mi->total_packets++;
159
160 @@ -766,6 +776,7 @@ minstrel_ht_update_caps(void *priv, stru
161 if (!n_supported)
162 goto use_legacy;
163
164 + minstrel_ht_update_rates(mp, mi);
165 return;
166
167 use_legacy: