mac80211: add rate control rewrite and enhance the performance of the minstrel algori...
[openwrt.git] / package / mac80211 / patches / 410-mac80211-cleanups.patch
1 Subject: mac80211: minor code cleanups
2
3 Nothing very interesting, some checkpatch inspired stuff,
4 some other things.
5
6 Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
7 ---
8 net/mac80211/debugfs_sta.c | 6 +++---
9 net/mac80211/main.c | 2 +-
10 net/mac80211/mesh.c | 2 +-
11 net/mac80211/rc80211_pid.h | 2 +-
12 net/mac80211/rx.c | 24 +++++++++++++-----------
13 net/mac80211/sta_info.c | 4 ++--
14 net/mac80211/wep.c | 26 +++++++++++++-------------
15 net/mac80211/wep.h | 2 +-
16 net/mac80211/wpa.c | 29 ++++++++++-------------------
17 9 files changed, 45 insertions(+), 52 deletions(-)
18
19 --- everything.orig/net/mac80211/wep.c 2008-10-07 20:05:49.000000000 +0200
20 +++ everything/net/mac80211/wep.c 2008-10-07 20:06:41.000000000 +0200
21 @@ -49,17 +49,19 @@ void ieee80211_wep_free(struct ieee80211
22 crypto_free_blkcipher(local->wep_rx_tfm);
23 }
24
25 -static inline int ieee80211_wep_weak_iv(u32 iv, int keylen)
26 +static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen)
27 {
28 - /* Fluhrer, Mantin, and Shamir have reported weaknesses in the
29 + /*
30 + * Fluhrer, Mantin, and Shamir have reported weaknesses in the
31 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3,
32 - * 0xff, N) can be used to speedup attacks, so avoid using them. */
33 + * 0xff, N) can be used to speedup attacks, so avoid using them.
34 + */
35 if ((iv & 0xff00) == 0xff00) {
36 u8 B = (iv >> 16) & 0xff;
37 if (B >= 3 && B < 3 + keylen)
38 - return 1;
39 + return true;
40 }
41 - return 0;
42 + return false;
43 }
44
45
46 @@ -268,7 +270,7 @@ int ieee80211_wep_decrypt(struct ieee802
47 }
48
49
50 -u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
51 +bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
52 {
53 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
54 unsigned int hdrlen;
55 @@ -276,16 +278,13 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_
56 u32 iv;
57
58 if (!ieee80211_has_protected(hdr->frame_control))
59 - return NULL;
60 + return false;
61
62 hdrlen = ieee80211_hdrlen(hdr->frame_control);
63 ivpos = skb->data + hdrlen;
64 iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
65
66 - if (ieee80211_wep_weak_iv(iv, key->conf.keylen))
67 - return ivpos;
68 -
69 - return NULL;
70 + return ieee80211_wep_weak_iv(iv, key->conf.keylen);
71 }
72
73 ieee80211_rx_result
74 @@ -329,6 +328,8 @@ static int wep_encrypt_skb(struct ieee80
75 ieee80211_tx_result
76 ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx)
77 {
78 + int i;
79 +
80 ieee80211_tx_set_protected(tx);
81
82 if (wep_encrypt_skb(tx, tx->skb) < 0) {
83 @@ -337,9 +338,8 @@ ieee80211_crypto_wep_encrypt(struct ieee
84 }
85
86 if (tx->extra_frag) {
87 - int i;
88 for (i = 0; i < tx->num_extra_frag; i++) {
89 - if (wep_encrypt_skb(tx, tx->extra_frag[i]) < 0) {
90 + if (wep_encrypt_skb(tx, tx->extra_frag[i])) {
91 I802_DEBUG_INC(tx->local->
92 tx_handlers_drop_wep);
93 return TX_DROP;
94 --- everything.orig/net/mac80211/wep.h 2008-10-07 20:05:28.000000000 +0200
95 +++ everything/net/mac80211/wep.h 2008-10-07 20:06:41.000000000 +0200
96 @@ -26,7 +26,7 @@ int ieee80211_wep_encrypt(struct ieee802
97 struct ieee80211_key *key);
98 int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
99 struct ieee80211_key *key);
100 -u8 *ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
101 +bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
102
103 ieee80211_rx_result
104 ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx);
105 --- everything.orig/net/mac80211/wpa.c 2008-10-07 20:05:49.000000000 +0200
106 +++ everything/net/mac80211/wpa.c 2008-10-07 20:06:41.000000000 +0200
107 @@ -49,8 +49,7 @@ ieee80211_tx_h_michael_mic_add(struct ie
108 !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
109 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
110 !wpa_test) {
111 - /* hwaccel - with no need for preallocated room for Michael MIC
112 - */
113 + /* hwaccel - with no need for preallocated room for MMIC */
114 return TX_CONTINUE;
115 }
116
117 @@ -67,8 +66,6 @@ ieee80211_tx_h_michael_mic_add(struct ie
118 #else
119 authenticator = 1;
120 #endif
121 - /* At this point we know we're using ALG_TKIP. To get the MIC key
122 - * we now will rely on the offset from the ieee80211_key_conf::key */
123 key_offset = authenticator ?
124 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY :
125 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
126 @@ -92,9 +89,7 @@ ieee80211_rx_h_michael_mic_verify(struct
127 int authenticator = 1, wpa_test = 0;
128 DECLARE_MAC_BUF(mac);
129
130 - /*
131 - * No way to verify the MIC if the hardware stripped it
132 - */
133 + /* No way to verify the MIC if the hardware stripped it */
134 if (rx->status->flag & RX_FLAG_MMIC_STRIPPED)
135 return RX_CONTINUE;
136
137 @@ -116,8 +111,6 @@ ieee80211_rx_h_michael_mic_verify(struct
138 #else
139 authenticator = 1;
140 #endif
141 - /* At this point we know we're using ALG_TKIP. To get the MIC key
142 - * we now will rely on the offset from the ieee80211_key_conf::key */
143 key_offset = authenticator ?
144 NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY :
145 NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
146 @@ -202,6 +195,7 @@ ieee80211_tx_result
147 ieee80211_crypto_tkip_encrypt(struct ieee80211_tx_data *tx)
148 {
149 struct sk_buff *skb = tx->skb;
150 + int i;
151
152 ieee80211_tx_set_protected(tx);
153
154 @@ -209,9 +203,8 @@ ieee80211_crypto_tkip_encrypt(struct iee
155 return TX_DROP;
156
157 if (tx->extra_frag) {
158 - int i;
159 for (i = 0; i < tx->num_extra_frag; i++) {
160 - if (tkip_encrypt_skb(tx, tx->extra_frag[i]) < 0)
161 + if (tkip_encrypt_skb(tx, tx->extra_frag[i]))
162 return TX_DROP;
163 }
164 }
165 @@ -350,7 +343,7 @@ static inline void ccmp_pn2hdr(u8 *hdr,
166 }
167
168
169 -static inline int ccmp_hdr2pn(u8 *pn, u8 *hdr)
170 +static inline void ccmp_hdr2pn(u8 *pn, u8 *hdr)
171 {
172 pn[0] = hdr[7];
173 pn[1] = hdr[6];
174 @@ -358,7 +351,6 @@ static inline int ccmp_hdr2pn(u8 *pn, u8
175 pn[3] = hdr[4];
176 pn[4] = hdr[1];
177 pn[5] = hdr[0];
178 - return (hdr[3] >> 6) & 0x03;
179 }
180
181
182 @@ -373,7 +365,7 @@ static int ccmp_encrypt_skb(struct ieee8
183
184 if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
185 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
186 - /* hwaccel - with no need for preallocated room for CCMP "
187 + /* hwaccel - with no need for preallocated room for CCMP
188 * header or MIC fields */
189 info->control.hw_key = &tx->key->conf;
190 return 0;
191 @@ -426,6 +418,7 @@ ieee80211_tx_result
192 ieee80211_crypto_ccmp_encrypt(struct ieee80211_tx_data *tx)
193 {
194 struct sk_buff *skb = tx->skb;
195 + int i;
196
197 ieee80211_tx_set_protected(tx);
198
199 @@ -433,9 +426,8 @@ ieee80211_crypto_ccmp_encrypt(struct iee
200 return TX_DROP;
201
202 if (tx->extra_frag) {
203 - int i;
204 for (i = 0; i < tx->num_extra_frag; i++) {
205 - if (ccmp_encrypt_skb(tx, tx->extra_frag[i]) < 0)
206 + if (ccmp_encrypt_skb(tx, tx->extra_frag[i]))
207 return TX_DROP;
208 }
209 }
210 @@ -468,7 +460,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
211 (rx->status->flag & RX_FLAG_IV_STRIPPED))
212 return RX_CONTINUE;
213
214 - (void) ccmp_hdr2pn(pn, skb->data + hdrlen);
215 + ccmp_hdr2pn(pn, skb->data + hdrlen);
216
217 if (memcmp(pn, key->u.ccmp.rx_pn[rx->queue], CCMP_PN_LEN) <= 0) {
218 key->u.ccmp.replays++;
219 @@ -483,9 +475,8 @@ ieee80211_crypto_ccmp_decrypt(struct iee
220 key->u.ccmp.tfm, key->u.ccmp.rx_crypto_buf,
221 skb->data + hdrlen + CCMP_HDR_LEN, data_len,
222 skb->data + skb->len - CCMP_MIC_LEN,
223 - skb->data + hdrlen + CCMP_HDR_LEN)) {
224 + skb->data + hdrlen + CCMP_HDR_LEN))
225 return RX_DROP_UNUSABLE;
226 - }
227 }
228
229 memcpy(key->u.ccmp.rx_pn[rx->queue], pn, CCMP_PN_LEN);
230 --- everything.orig/net/mac80211/debugfs_sta.c 2008-10-07 20:06:40.000000000 +0200
231 +++ everything/net/mac80211/debugfs_sta.c 2008-10-07 20:06:41.000000000 +0200
232 @@ -137,7 +137,7 @@ static ssize_t sta_agg_status_read(struc
233 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
234 for (i = 0; i < STA_TID_NUM; i++)
235 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
236 - sta->ampdu_mlme.tid_state_rx[i]?
237 + sta->ampdu_mlme.tid_state_rx[i] ?
238 sta->ampdu_mlme.tid_rx[i]->dialog_token : 0);
239
240 p += scnprintf(p, sizeof(buf)+buf-p, "\n TX :");
241 @@ -148,13 +148,13 @@ static ssize_t sta_agg_status_read(struc
242 p += scnprintf(p, sizeof(buf)+buf-p, "\n DTKN:");
243 for (i = 0; i < STA_TID_NUM; i++)
244 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
245 - sta->ampdu_mlme.tid_state_tx[i]?
246 + sta->ampdu_mlme.tid_state_tx[i] ?
247 sta->ampdu_mlme.tid_tx[i]->dialog_token : 0);
248
249 p += scnprintf(p, sizeof(buf)+buf-p, "\n SSN :");
250 for (i = 0; i < STA_TID_NUM; i++)
251 p += scnprintf(p, sizeof(buf)+buf-p, "%5d",
252 - sta->ampdu_mlme.tid_state_tx[i]?
253 + sta->ampdu_mlme.tid_state_tx[i] ?
254 sta->ampdu_mlme.tid_tx[i]->ssn : 0);
255
256 p += scnprintf(p, sizeof(buf)+buf-p, "\n");
257 --- everything.orig/net/mac80211/main.c 2008-10-07 20:05:49.000000000 +0200
258 +++ everything/net/mac80211/main.c 2008-10-07 20:06:41.000000000 +0200
259 @@ -1013,7 +1013,7 @@ static int __init ieee80211_init(void)
260
261 BUILD_BUG_ON(sizeof(struct ieee80211_tx_info) > sizeof(skb->cb));
262 BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, driver_data) +
263 - IEEE80211_TX_INFO_DRIVER_DATA_SIZE > sizeof(skb->cb));
264 + IEEE80211_TX_INFO_DRIVER_DATA_SIZE > sizeof(skb->cb));
265
266 ret = rc80211_minstrel_init();
267 if (ret)
268 --- everything.orig/net/mac80211/mesh.c 2008-10-07 20:05:28.000000000 +0200
269 +++ everything/net/mac80211/mesh.c 2008-10-07 20:06:41.000000000 +0200
270 @@ -473,7 +473,7 @@ static void ieee80211_mesh_rx_bcn_presp(
271 size_t len,
272 struct ieee80211_rx_status *rx_status)
273 {
274 - struct ieee80211_local *local= sdata->local;
275 + struct ieee80211_local *local = sdata->local;
276 struct ieee802_11_elems elems;
277 struct ieee80211_channel *channel;
278 u64 supp_rates = 0;
279 --- everything.orig/net/mac80211/rc80211_pid.h 2008-10-07 20:05:28.000000000 +0200
280 +++ everything/net/mac80211/rc80211_pid.h 2008-10-07 20:06:41.000000000 +0200
281 @@ -49,7 +49,7 @@
282
283 /* Arithmetic right shift for positive and negative values for ISO C. */
284 #define RC_PID_DO_ARITH_RIGHT_SHIFT(x, y) \
285 - (x) < 0 ? -((-(x)) >> (y)) : (x) >> (y)
286 + ((x) < 0 ? -((-(x)) >> (y)) : (x) >> (y))
287
288 enum rc_pid_event_type {
289 RC_PID_EVENT_TYPE_TX_STATUS,
290 --- everything.orig/net/mac80211/rx.c 2008-10-07 20:06:38.000000000 +0200
291 +++ everything/net/mac80211/rx.c 2008-10-07 20:06:41.000000000 +0200
292 @@ -26,10 +26,11 @@
293 #include "tkip.h"
294 #include "wme.h"
295
296 -u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
297 - struct tid_ampdu_rx *tid_agg_rx,
298 - struct sk_buff *skb, u16 mpdu_seq_num,
299 - int bar_req);
300 +static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
301 + struct tid_ampdu_rx *tid_agg_rx,
302 + struct sk_buff *skb,
303 + u16 mpdu_seq_num,
304 + int bar_req);
305 /*
306 * monitor mode reception
307 *
308 @@ -2000,17 +2001,17 @@ static void __ieee80211_rx_handle_packet
309
310 static inline int seq_less(u16 sq1, u16 sq2)
311 {
312 - return (((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1));
313 + return ((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1);
314 }
315
316 static inline u16 seq_inc(u16 sq)
317 {
318 - return ((sq + 1) & SEQ_MASK);
319 + return (sq + 1) & SEQ_MASK;
320 }
321
322 static inline u16 seq_sub(u16 sq1, u16 sq2)
323 {
324 - return ((sq1 - sq2) & SEQ_MASK);
325 + return (sq1 - sq2) & SEQ_MASK;
326 }
327
328
329 @@ -2018,10 +2019,11 @@ static inline u16 seq_sub(u16 sq1, u16 s
330 * As it function blongs to Rx path it must be called with
331 * the proper rcu_read_lock protection for its flow.
332 */
333 -u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
334 - struct tid_ampdu_rx *tid_agg_rx,
335 - struct sk_buff *skb, u16 mpdu_seq_num,
336 - int bar_req)
337 +static u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
338 + struct tid_ampdu_rx *tid_agg_rx,
339 + struct sk_buff *skb,
340 + u16 mpdu_seq_num,
341 + int bar_req)
342 {
343 struct ieee80211_local *local = hw_to_local(hw);
344 struct ieee80211_rx_status status;
345 --- everything.orig/net/mac80211/sta_info.c 2008-10-07 20:06:39.000000000 +0200
346 +++ everything/net/mac80211/sta_info.c 2008-10-07 20:06:41.000000000 +0200
347 @@ -294,7 +294,7 @@ int sta_info_insert(struct sta_info *sta
348 }
349
350 if (WARN_ON(compare_ether_addr(sta->sta.addr, sdata->dev->dev_addr) == 0 ||
351 - is_multicast_ether_addr(sta->sta.addr))) {
352 + is_multicast_ether_addr(sta->sta.addr))) {
353 err = -EINVAL;
354 goto out_free;
355 }
356 @@ -830,7 +830,7 @@ void ieee80211_sta_expire(struct ieee802
357 }
358
359 struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw,
360 - const u8 *addr)
361 + const u8 *addr)
362 {
363 struct sta_info *sta = sta_info_get(hw_to_local(hw), addr);
364
This page took 0.065037 seconds and 5 git commands to generate.