]>
Commit | Line | Data |
---|---|---|
e2ebc74d JB |
1 | /* |
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | |
3 | * Copyright 2005-2006, Devicescape Software, Inc. | |
4 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | |
5 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * | |
12 | * Transmit and frame generation functions. | |
13 | */ | |
14 | ||
15 | #include <linux/kernel.h> | |
16 | #include <linux/slab.h> | |
17 | #include <linux/skbuff.h> | |
18 | #include <linux/etherdevice.h> | |
19 | #include <linux/bitmap.h> | |
d4e46a3d | 20 | #include <linux/rcupdate.h> |
881d966b | 21 | #include <net/net_namespace.h> |
e2ebc74d JB |
22 | #include <net/ieee80211_radiotap.h> |
23 | #include <net/cfg80211.h> | |
24 | #include <net/mac80211.h> | |
25 | #include <asm/unaligned.h> | |
26 | ||
27 | #include "ieee80211_i.h" | |
28 | #include "ieee80211_led.h" | |
29 | #include "wep.h" | |
30 | #include "wpa.h" | |
31 | #include "wme.h" | |
32 | #include "ieee80211_rate.h" | |
33 | ||
34 | #define IEEE80211_TX_OK 0 | |
35 | #define IEEE80211_TX_AGAIN 1 | |
36 | #define IEEE80211_TX_FRAG_AGAIN 2 | |
37 | ||
38 | /* misc utils */ | |
39 | ||
40 | static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdata, | |
41 | struct ieee80211_hdr *hdr) | |
42 | { | |
43 | /* Set the sequence number for this frame. */ | |
44 | hdr->seq_ctrl = cpu_to_le16(sdata->sequence); | |
45 | ||
46 | /* Increase the sequence number. */ | |
47 | sdata->sequence = (sdata->sequence + 0x10) & IEEE80211_SCTL_SEQ; | |
48 | } | |
49 | ||
50 | #ifdef CONFIG_MAC80211_LOWTX_FRAME_DUMP | |
51 | static void ieee80211_dump_frame(const char *ifname, const char *title, | |
52 | const struct sk_buff *skb) | |
53 | { | |
54 | const struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
55 | u16 fc; | |
56 | int hdrlen; | |
0795af57 | 57 | DECLARE_MAC_BUF(mac); |
e2ebc74d JB |
58 | |
59 | printk(KERN_DEBUG "%s: %s (len=%d)", ifname, title, skb->len); | |
60 | if (skb->len < 4) { | |
61 | printk("\n"); | |
62 | return; | |
63 | } | |
64 | ||
65 | fc = le16_to_cpu(hdr->frame_control); | |
66 | hdrlen = ieee80211_get_hdrlen(fc); | |
67 | if (hdrlen > skb->len) | |
68 | hdrlen = skb->len; | |
69 | if (hdrlen >= 4) | |
70 | printk(" FC=0x%04x DUR=0x%04x", | |
71 | fc, le16_to_cpu(hdr->duration_id)); | |
72 | if (hdrlen >= 10) | |
0795af57 | 73 | printk(" A1=%s", print_mac(mac, hdr->addr1)); |
e2ebc74d | 74 | if (hdrlen >= 16) |
0795af57 | 75 | printk(" A2=%s", print_mac(mac, hdr->addr2)); |
e2ebc74d | 76 | if (hdrlen >= 24) |
0795af57 | 77 | printk(" A3=%s", print_mac(mac, hdr->addr3)); |
e2ebc74d | 78 | if (hdrlen >= 30) |
0795af57 | 79 | printk(" A4=%s", print_mac(mac, hdr->addr4)); |
e2ebc74d JB |
80 | printk("\n"); |
81 | } | |
82 | #else /* CONFIG_MAC80211_LOWTX_FRAME_DUMP */ | |
83 | static inline void ieee80211_dump_frame(const char *ifname, const char *title, | |
84 | struct sk_buff *skb) | |
85 | { | |
86 | } | |
87 | #endif /* CONFIG_MAC80211_LOWTX_FRAME_DUMP */ | |
88 | ||
89 | static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr, | |
90 | int next_frag_len) | |
91 | { | |
92 | int rate, mrate, erp, dur, i; | |
93 | struct ieee80211_rate *txrate = tx->u.tx.rate; | |
94 | struct ieee80211_local *local = tx->local; | |
95 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | |
96 | ||
97 | erp = txrate->flags & IEEE80211_RATE_ERP; | |
98 | ||
99 | /* | |
100 | * data and mgmt (except PS Poll): | |
101 | * - during CFP: 32768 | |
102 | * - during contention period: | |
103 | * if addr1 is group address: 0 | |
104 | * if more fragments = 0 and addr1 is individual address: time to | |
105 | * transmit one ACK plus SIFS | |
106 | * if more fragments = 1 and addr1 is individual address: time to | |
107 | * transmit next fragment plus 2 x ACK plus 3 x SIFS | |
108 | * | |
109 | * IEEE 802.11, 9.6: | |
110 | * - control response frame (CTS or ACK) shall be transmitted using the | |
111 | * same rate as the immediately previous frame in the frame exchange | |
112 | * sequence, if this rate belongs to the PHY mandatory rates, or else | |
113 | * at the highest possible rate belonging to the PHY rates in the | |
114 | * BSSBasicRateSet | |
115 | */ | |
116 | ||
117 | if ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) { | |
118 | /* TODO: These control frames are not currently sent by | |
119 | * 80211.o, but should they be implemented, this function | |
120 | * needs to be updated to support duration field calculation. | |
121 | * | |
122 | * RTS: time needed to transmit pending data/mgmt frame plus | |
123 | * one CTS frame plus one ACK frame plus 3 x SIFS | |
124 | * CTS: duration of immediately previous RTS minus time | |
125 | * required to transmit CTS and its SIFS | |
126 | * ACK: 0 if immediately previous directed data/mgmt had | |
127 | * more=0, with more=1 duration in ACK frame is duration | |
128 | * from previous frame minus time needed to transmit ACK | |
129 | * and its SIFS | |
130 | * PS Poll: BIT(15) | BIT(14) | aid | |
131 | */ | |
132 | return 0; | |
133 | } | |
134 | ||
135 | /* data/mgmt */ | |
136 | if (0 /* FIX: data/mgmt during CFP */) | |
137 | return 32768; | |
138 | ||
139 | if (group_addr) /* Group address as the destination - no ACK */ | |
140 | return 0; | |
141 | ||
142 | /* Individual destination address: | |
143 | * IEEE 802.11, Ch. 9.6 (after IEEE 802.11g changes) | |
144 | * CTS and ACK frames shall be transmitted using the highest rate in | |
145 | * basic rate set that is less than or equal to the rate of the | |
146 | * immediately previous frame and that is using the same modulation | |
147 | * (CCK or OFDM). If no basic rate set matches with these requirements, | |
148 | * the highest mandatory rate of the PHY that is less than or equal to | |
149 | * the rate of the previous frame is used. | |
150 | * Mandatory rates for IEEE 802.11g PHY: 1, 2, 5.5, 11, 6, 12, 24 Mbps | |
151 | */ | |
152 | rate = -1; | |
153 | mrate = 10; /* use 1 Mbps if everything fails */ | |
154 | for (i = 0; i < mode->num_rates; i++) { | |
155 | struct ieee80211_rate *r = &mode->rates[i]; | |
156 | if (r->rate > txrate->rate) | |
157 | break; | |
158 | ||
159 | if (IEEE80211_RATE_MODULATION(txrate->flags) != | |
160 | IEEE80211_RATE_MODULATION(r->flags)) | |
161 | continue; | |
162 | ||
163 | if (r->flags & IEEE80211_RATE_BASIC) | |
164 | rate = r->rate; | |
165 | else if (r->flags & IEEE80211_RATE_MANDATORY) | |
166 | mrate = r->rate; | |
167 | } | |
168 | if (rate == -1) { | |
169 | /* No matching basic rate found; use highest suitable mandatory | |
170 | * PHY rate */ | |
171 | rate = mrate; | |
172 | } | |
173 | ||
174 | /* Time needed to transmit ACK | |
175 | * (10 bytes + 4-byte FCS = 112 bits) plus SIFS; rounded up | |
176 | * to closest integer */ | |
177 | ||
178 | dur = ieee80211_frame_duration(local, 10, rate, erp, | |
13262ffd | 179 | tx->sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE); |
e2ebc74d JB |
180 | |
181 | if (next_frag_len) { | |
182 | /* Frame is fragmented: duration increases with time needed to | |
183 | * transmit next fragment plus ACK and 2 x SIFS. */ | |
184 | dur *= 2; /* ACK + SIFS */ | |
185 | /* next fragment */ | |
186 | dur += ieee80211_frame_duration(local, next_frag_len, | |
13262ffd JS |
187 | txrate->rate, erp, |
188 | tx->sdata->flags & | |
189 | IEEE80211_SDATA_SHORT_PREAMBLE); | |
e2ebc74d JB |
190 | } |
191 | ||
192 | return dur; | |
193 | } | |
194 | ||
195 | static inline int __ieee80211_queue_stopped(const struct ieee80211_local *local, | |
196 | int queue) | |
197 | { | |
198 | return test_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]); | |
199 | } | |
200 | ||
201 | static inline int __ieee80211_queue_pending(const struct ieee80211_local *local, | |
202 | int queue) | |
203 | { | |
204 | return test_bit(IEEE80211_LINK_STATE_PENDING, &local->state[queue]); | |
205 | } | |
206 | ||
207 | static int inline is_ieee80211_device(struct net_device *dev, | |
208 | struct net_device *master) | |
209 | { | |
210 | return (wdev_priv(dev->ieee80211_ptr) == | |
211 | wdev_priv(master->ieee80211_ptr)); | |
212 | } | |
213 | ||
214 | /* tx handlers */ | |
215 | ||
216 | static ieee80211_txrx_result | |
217 | ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx) | |
218 | { | |
219 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
220 | struct sk_buff *skb = tx->skb; | |
221 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
222 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | |
223 | u32 sta_flags; | |
224 | ||
58d4185e JB |
225 | if (unlikely(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) |
226 | return TXRX_CONTINUE; | |
227 | ||
ece8eddd | 228 | if (unlikely(tx->local->sta_sw_scanning) && |
e2ebc74d JB |
229 | ((tx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT || |
230 | (tx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PROBE_REQ)) | |
231 | return TXRX_DROP; | |
232 | ||
badffb72 | 233 | if (tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED) |
e2ebc74d JB |
234 | return TXRX_CONTINUE; |
235 | ||
236 | sta_flags = tx->sta ? tx->sta->flags : 0; | |
237 | ||
badffb72 | 238 | if (likely(tx->flags & IEEE80211_TXRXD_TXUNICAST)) { |
e2ebc74d JB |
239 | if (unlikely(!(sta_flags & WLAN_STA_ASSOC) && |
240 | tx->sdata->type != IEEE80211_IF_TYPE_IBSS && | |
241 | (tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) { | |
242 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
0795af57 | 243 | DECLARE_MAC_BUF(mac); |
e2ebc74d | 244 | printk(KERN_DEBUG "%s: dropped data frame to not " |
0795af57 JP |
245 | "associated station %s\n", |
246 | tx->dev->name, print_mac(mac, hdr->addr1)); | |
e2ebc74d JB |
247 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
248 | I802_DEBUG_INC(tx->local->tx_handlers_drop_not_assoc); | |
249 | return TXRX_DROP; | |
250 | } | |
251 | } else { | |
252 | if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA && | |
253 | tx->local->num_sta == 0 && | |
e2ebc74d JB |
254 | tx->sdata->type != IEEE80211_IF_TYPE_IBSS)) { |
255 | /* | |
256 | * No associated STAs - no need to send multicast | |
257 | * frames. | |
258 | */ | |
259 | return TXRX_DROP; | |
260 | } | |
261 | return TXRX_CONTINUE; | |
262 | } | |
263 | ||
e2ebc74d JB |
264 | return TXRX_CONTINUE; |
265 | } | |
266 | ||
267 | static ieee80211_txrx_result | |
268 | ieee80211_tx_h_sequence(struct ieee80211_txrx_data *tx) | |
269 | { | |
270 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | |
271 | ||
272 | if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24) | |
273 | ieee80211_include_sequence(tx->sdata, hdr); | |
274 | ||
275 | return TXRX_CONTINUE; | |
276 | } | |
277 | ||
278 | /* This function is called whenever the AP is about to exceed the maximum limit | |
279 | * of buffered frames for power saving STAs. This situation should not really | |
280 | * happen often during normal operation, so dropping the oldest buffered packet | |
281 | * from each queue should be OK to make some room for new frames. */ | |
282 | static void purge_old_ps_buffers(struct ieee80211_local *local) | |
283 | { | |
284 | int total = 0, purged = 0; | |
285 | struct sk_buff *skb; | |
286 | struct ieee80211_sub_if_data *sdata; | |
287 | struct sta_info *sta; | |
288 | ||
79010420 JB |
289 | /* |
290 | * virtual interfaces are protected by RCU | |
291 | */ | |
292 | rcu_read_lock(); | |
293 | ||
294 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | |
e2ebc74d JB |
295 | struct ieee80211_if_ap *ap; |
296 | if (sdata->dev == local->mdev || | |
297 | sdata->type != IEEE80211_IF_TYPE_AP) | |
298 | continue; | |
299 | ap = &sdata->u.ap; | |
300 | skb = skb_dequeue(&ap->ps_bc_buf); | |
301 | if (skb) { | |
302 | purged++; | |
303 | dev_kfree_skb(skb); | |
304 | } | |
305 | total += skb_queue_len(&ap->ps_bc_buf); | |
306 | } | |
79010420 | 307 | rcu_read_unlock(); |
e2ebc74d | 308 | |
be8755e1 | 309 | read_lock_bh(&local->sta_lock); |
e2ebc74d JB |
310 | list_for_each_entry(sta, &local->sta_list, list) { |
311 | skb = skb_dequeue(&sta->ps_tx_buf); | |
312 | if (skb) { | |
313 | purged++; | |
314 | dev_kfree_skb(skb); | |
315 | } | |
316 | total += skb_queue_len(&sta->ps_tx_buf); | |
317 | } | |
be8755e1 | 318 | read_unlock_bh(&local->sta_lock); |
e2ebc74d JB |
319 | |
320 | local->total_ps_buffered = total; | |
321 | printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n", | |
dd1cd4c6 | 322 | wiphy_name(local->hw.wiphy), purged); |
e2ebc74d JB |
323 | } |
324 | ||
7d54d0dd | 325 | static ieee80211_txrx_result |
e2ebc74d JB |
326 | ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx) |
327 | { | |
7d54d0dd JB |
328 | /* |
329 | * broadcast/multicast frame | |
330 | * | |
331 | * If any of the associated stations is in power save mode, | |
332 | * the frame is buffered to be sent after DTIM beacon frame. | |
333 | * This is done either by the hardware or us. | |
334 | */ | |
335 | ||
336 | /* not AP/IBSS or ordered frame */ | |
337 | if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER)) | |
338 | return TXRX_CONTINUE; | |
339 | ||
340 | /* no stations in PS mode */ | |
341 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) | |
342 | return TXRX_CONTINUE; | |
343 | ||
344 | /* buffered in mac80211 */ | |
345 | if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) { | |
e2ebc74d JB |
346 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
347 | purge_old_ps_buffers(tx->local); | |
348 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= | |
349 | AP_MAX_BC_BUFFER) { | |
350 | if (net_ratelimit()) { | |
351 | printk(KERN_DEBUG "%s: BC TX buffer full - " | |
352 | "dropping the oldest frame\n", | |
353 | tx->dev->name); | |
354 | } | |
355 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); | |
356 | } else | |
357 | tx->local->total_ps_buffered++; | |
358 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); | |
359 | return TXRX_QUEUED; | |
360 | } | |
361 | ||
7d54d0dd JB |
362 | /* buffered in hardware */ |
363 | tx->u.tx.control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM; | |
364 | ||
e2ebc74d JB |
365 | return TXRX_CONTINUE; |
366 | } | |
367 | ||
7d54d0dd | 368 | static ieee80211_txrx_result |
e2ebc74d JB |
369 | ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx) |
370 | { | |
371 | struct sta_info *sta = tx->sta; | |
0795af57 | 372 | DECLARE_MAC_BUF(mac); |
e2ebc74d JB |
373 | |
374 | if (unlikely(!sta || | |
375 | ((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && | |
376 | (tx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP))) | |
377 | return TXRX_CONTINUE; | |
378 | ||
379 | if (unlikely((sta->flags & WLAN_STA_PS) && !sta->pspoll)) { | |
380 | struct ieee80211_tx_packet_data *pkt_data; | |
381 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | |
0795af57 | 382 | printk(KERN_DEBUG "STA %s aid %d: PS buffer (entries " |
e2ebc74d | 383 | "before %d)\n", |
0795af57 | 384 | print_mac(mac, sta->addr), sta->aid, |
e2ebc74d JB |
385 | skb_queue_len(&sta->ps_tx_buf)); |
386 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | |
387 | sta->flags |= WLAN_STA_TIM; | |
388 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | |
389 | purge_old_ps_buffers(tx->local); | |
390 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { | |
391 | struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); | |
392 | if (net_ratelimit()) { | |
0795af57 | 393 | printk(KERN_DEBUG "%s: STA %s TX " |
e2ebc74d | 394 | "buffer full - dropping oldest frame\n", |
0795af57 | 395 | tx->dev->name, print_mac(mac, sta->addr)); |
e2ebc74d JB |
396 | } |
397 | dev_kfree_skb(old); | |
398 | } else | |
399 | tx->local->total_ps_buffered++; | |
400 | /* Queue frame to be sent after STA sends an PS Poll frame */ | |
401 | if (skb_queue_empty(&sta->ps_tx_buf)) { | |
402 | if (tx->local->ops->set_tim) | |
403 | tx->local->ops->set_tim(local_to_hw(tx->local), | |
404 | sta->aid, 1); | |
405 | if (tx->sdata->bss) | |
406 | bss_tim_set(tx->local, tx->sdata->bss, sta->aid); | |
407 | } | |
408 | pkt_data = (struct ieee80211_tx_packet_data *)tx->skb->cb; | |
409 | pkt_data->jiffies = jiffies; | |
410 | skb_queue_tail(&sta->ps_tx_buf, tx->skb); | |
411 | return TXRX_QUEUED; | |
412 | } | |
413 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG | |
414 | else if (unlikely(sta->flags & WLAN_STA_PS)) { | |
0795af57 | 415 | printk(KERN_DEBUG "%s: STA %s in PS mode, but pspoll " |
e2ebc74d | 416 | "set -> send frame\n", tx->dev->name, |
0795af57 | 417 | print_mac(mac, sta->addr)); |
e2ebc74d JB |
418 | } |
419 | #endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ | |
420 | sta->pspoll = 0; | |
421 | ||
422 | return TXRX_CONTINUE; | |
423 | } | |
424 | ||
e2ebc74d JB |
425 | static ieee80211_txrx_result |
426 | ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx) | |
427 | { | |
badffb72 | 428 | if (unlikely(tx->flags & IEEE80211_TXRXD_TXPS_BUFFERED)) |
e2ebc74d JB |
429 | return TXRX_CONTINUE; |
430 | ||
badffb72 | 431 | if (tx->flags & IEEE80211_TXRXD_TXUNICAST) |
e2ebc74d JB |
432 | return ieee80211_tx_h_unicast_ps_buf(tx); |
433 | else | |
434 | return ieee80211_tx_h_multicast_ps_buf(tx); | |
435 | } | |
436 | ||
e2ebc74d JB |
437 | static ieee80211_txrx_result |
438 | ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) | |
439 | { | |
d4e46a3d | 440 | struct ieee80211_key *key; |
176e4f84 | 441 | u16 fc = tx->fc; |
d4e46a3d | 442 | |
e2ebc74d JB |
443 | if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) |
444 | tx->key = NULL; | |
d4e46a3d JB |
445 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) |
446 | tx->key = key; | |
447 | else if ((key = rcu_dereference(tx->sdata->default_key))) | |
448 | tx->key = key; | |
e2ebc74d | 449 | else if (tx->sdata->drop_unencrypted && |
678f5f71 JB |
450 | !(tx->u.tx.control->flags & IEEE80211_TXCTL_EAPOL_FRAME) && |
451 | !(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) { | |
e2ebc74d JB |
452 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); |
453 | return TXRX_DROP; | |
176e4f84 | 454 | } else |
e2ebc74d JB |
455 | tx->key = NULL; |
456 | ||
457 | if (tx->key) { | |
176e4f84 JB |
458 | u16 ftype, stype; |
459 | ||
e2ebc74d | 460 | tx->key->tx_rx_count++; |
011bfcc4 | 461 | /* TODO: add threshold stuff again */ |
176e4f84 JB |
462 | |
463 | switch (tx->key->conf.alg) { | |
464 | case ALG_WEP: | |
465 | ftype = fc & IEEE80211_FCTL_FTYPE; | |
466 | stype = fc & IEEE80211_FCTL_STYPE; | |
467 | ||
468 | if (ftype == IEEE80211_FTYPE_MGMT && | |
469 | stype == IEEE80211_STYPE_AUTH) | |
470 | break; | |
471 | case ALG_TKIP: | |
472 | case ALG_CCMP: | |
473 | if (!WLAN_FC_DATA_PRESENT(fc)) | |
474 | tx->key = NULL; | |
475 | break; | |
476 | } | |
e2ebc74d JB |
477 | } |
478 | ||
176e4f84 JB |
479 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
480 | tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; | |
481 | ||
e2ebc74d JB |
482 | return TXRX_CONTINUE; |
483 | } | |
484 | ||
485 | static ieee80211_txrx_result | |
486 | ieee80211_tx_h_fragment(struct ieee80211_txrx_data *tx) | |
487 | { | |
488 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | |
489 | size_t hdrlen, per_fragm, num_fragm, payload_len, left; | |
490 | struct sk_buff **frags, *first, *frag; | |
491 | int i; | |
492 | u16 seq; | |
493 | u8 *pos; | |
494 | int frag_threshold = tx->local->fragmentation_threshold; | |
495 | ||
badffb72 | 496 | if (!(tx->flags & IEEE80211_TXRXD_FRAGMENTED)) |
e2ebc74d JB |
497 | return TXRX_CONTINUE; |
498 | ||
499 | first = tx->skb; | |
500 | ||
501 | hdrlen = ieee80211_get_hdrlen(tx->fc); | |
502 | payload_len = first->len - hdrlen; | |
503 | per_fragm = frag_threshold - hdrlen - FCS_LEN; | |
172589cc | 504 | num_fragm = DIV_ROUND_UP(payload_len, per_fragm); |
e2ebc74d JB |
505 | |
506 | frags = kzalloc(num_fragm * sizeof(struct sk_buff *), GFP_ATOMIC); | |
507 | if (!frags) | |
508 | goto fail; | |
509 | ||
510 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); | |
511 | seq = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ; | |
512 | pos = first->data + hdrlen + per_fragm; | |
513 | left = payload_len - per_fragm; | |
514 | for (i = 0; i < num_fragm - 1; i++) { | |
515 | struct ieee80211_hdr *fhdr; | |
516 | size_t copylen; | |
517 | ||
518 | if (left <= 0) | |
519 | goto fail; | |
520 | ||
521 | /* reserve enough extra head and tail room for possible | |
522 | * encryption */ | |
523 | frag = frags[i] = | |
524 | dev_alloc_skb(tx->local->tx_headroom + | |
525 | frag_threshold + | |
526 | IEEE80211_ENCRYPT_HEADROOM + | |
527 | IEEE80211_ENCRYPT_TAILROOM); | |
528 | if (!frag) | |
529 | goto fail; | |
530 | /* Make sure that all fragments use the same priority so | |
531 | * that they end up using the same TX queue */ | |
532 | frag->priority = first->priority; | |
533 | skb_reserve(frag, tx->local->tx_headroom + | |
534 | IEEE80211_ENCRYPT_HEADROOM); | |
535 | fhdr = (struct ieee80211_hdr *) skb_put(frag, hdrlen); | |
536 | memcpy(fhdr, first->data, hdrlen); | |
537 | if (i == num_fragm - 2) | |
538 | fhdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREFRAGS); | |
539 | fhdr->seq_ctrl = cpu_to_le16(seq | ((i + 1) & IEEE80211_SCTL_FRAG)); | |
540 | copylen = left > per_fragm ? per_fragm : left; | |
541 | memcpy(skb_put(frag, copylen), pos, copylen); | |
542 | ||
543 | pos += copylen; | |
544 | left -= copylen; | |
545 | } | |
546 | skb_trim(first, hdrlen + per_fragm); | |
547 | ||
548 | tx->u.tx.num_extra_frag = num_fragm - 1; | |
549 | tx->u.tx.extra_frag = frags; | |
550 | ||
551 | return TXRX_CONTINUE; | |
552 | ||
553 | fail: | |
554 | printk(KERN_DEBUG "%s: failed to fragment frame\n", tx->dev->name); | |
555 | if (frags) { | |
556 | for (i = 0; i < num_fragm - 1; i++) | |
557 | if (frags[i]) | |
558 | dev_kfree_skb(frags[i]); | |
559 | kfree(frags); | |
560 | } | |
561 | I802_DEBUG_INC(tx->local->tx_handlers_drop_fragment); | |
562 | return TXRX_DROP; | |
563 | } | |
564 | ||
e2ebc74d | 565 | static ieee80211_txrx_result |
6a22a59d | 566 | ieee80211_tx_h_encrypt(struct ieee80211_txrx_data *tx) |
e2ebc74d | 567 | { |
6a22a59d | 568 | if (!tx->key) |
e2ebc74d JB |
569 | return TXRX_CONTINUE; |
570 | ||
6a22a59d JB |
571 | switch (tx->key->conf.alg) { |
572 | case ALG_WEP: | |
573 | return ieee80211_crypto_wep_encrypt(tx); | |
574 | case ALG_TKIP: | |
575 | return ieee80211_crypto_tkip_encrypt(tx); | |
576 | case ALG_CCMP: | |
577 | return ieee80211_crypto_ccmp_encrypt(tx); | |
e2ebc74d JB |
578 | } |
579 | ||
6a22a59d JB |
580 | /* not reached */ |
581 | WARN_ON(1); | |
582 | return TXRX_DROP; | |
e2ebc74d JB |
583 | } |
584 | ||
585 | static ieee80211_txrx_result | |
586 | ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) | |
587 | { | |
1abbe498 | 588 | struct rate_selection rsel; |
e2ebc74d | 589 | |
58d4185e | 590 | if (likely(!tx->u.tx.rate)) { |
1abbe498 MN |
591 | rate_control_get_rate(tx->dev, tx->u.tx.mode, tx->skb, &rsel); |
592 | tx->u.tx.rate = rsel.rate; | |
593 | if (unlikely(rsel.probe != NULL)) { | |
58d4185e JB |
594 | tx->u.tx.control->flags |= |
595 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | |
596 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; | |
597 | tx->u.tx.control->alt_retry_rate = tx->u.tx.rate->val; | |
1abbe498 | 598 | tx->u.tx.rate = rsel.probe; |
58d4185e JB |
599 | } else |
600 | tx->u.tx.control->alt_retry_rate = -1; | |
601 | ||
602 | if (!tx->u.tx.rate) | |
603 | return TXRX_DROP; | |
604 | } else | |
e2ebc74d | 605 | tx->u.tx.control->alt_retry_rate = -1; |
58d4185e | 606 | |
e2ebc74d | 607 | if (tx->u.tx.mode->mode == MODE_IEEE80211G && |
13262ffd | 608 | (tx->sdata->flags & IEEE80211_SDATA_USE_PROTECTION) && |
1abbe498 | 609 | (tx->flags & IEEE80211_TXRXD_FRAGMENTED) && rsel.nonerp) { |
e2ebc74d | 610 | tx->u.tx.last_frag_rate = tx->u.tx.rate; |
1abbe498 | 611 | if (rsel.probe) |
badffb72 JS |
612 | tx->flags &= ~IEEE80211_TXRXD_TXPROBE_LAST_FRAG; |
613 | else | |
614 | tx->flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; | |
1abbe498 MN |
615 | tx->u.tx.rate = rsel.nonerp; |
616 | tx->u.tx.control->rate = rsel.nonerp; | |
e2ebc74d JB |
617 | tx->u.tx.control->flags &= ~IEEE80211_TXCTL_RATE_CTRL_PROBE; |
618 | } else { | |
619 | tx->u.tx.last_frag_rate = tx->u.tx.rate; | |
620 | tx->u.tx.control->rate = tx->u.tx.rate; | |
621 | } | |
622 | tx->u.tx.control->tx_rate = tx->u.tx.rate->val; | |
e2ebc74d JB |
623 | |
624 | return TXRX_CONTINUE; | |
625 | } | |
626 | ||
627 | static ieee80211_txrx_result | |
628 | ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) | |
629 | { | |
630 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | |
7e9ed188 | 631 | u16 fc = le16_to_cpu(hdr->frame_control); |
e2ebc74d JB |
632 | u16 dur; |
633 | struct ieee80211_tx_control *control = tx->u.tx.control; | |
634 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | |
635 | ||
58d4185e JB |
636 | if (!control->retry_limit) { |
637 | if (!is_multicast_ether_addr(hdr->addr1)) { | |
638 | if (tx->skb->len + FCS_LEN > tx->local->rts_threshold | |
639 | && tx->local->rts_threshold < | |
640 | IEEE80211_MAX_RTS_THRESHOLD) { | |
641 | control->flags |= | |
642 | IEEE80211_TXCTL_USE_RTS_CTS; | |
643 | control->flags |= | |
644 | IEEE80211_TXCTL_LONG_RETRY_LIMIT; | |
645 | control->retry_limit = | |
646 | tx->local->long_retry_limit; | |
647 | } else { | |
648 | control->retry_limit = | |
649 | tx->local->short_retry_limit; | |
650 | } | |
e2ebc74d | 651 | } else { |
58d4185e | 652 | control->retry_limit = 1; |
e2ebc74d | 653 | } |
e2ebc74d JB |
654 | } |
655 | ||
badffb72 | 656 | if (tx->flags & IEEE80211_TXRXD_FRAGMENTED) { |
e2ebc74d JB |
657 | /* Do not use multiple retry rates when sending fragmented |
658 | * frames. | |
659 | * TODO: The last fragment could still use multiple retry | |
660 | * rates. */ | |
661 | control->alt_retry_rate = -1; | |
662 | } | |
663 | ||
664 | /* Use CTS protection for unicast frames sent using extended rates if | |
665 | * there are associated non-ERP stations and RTS/CTS is not configured | |
666 | * for the frame. */ | |
667 | if (mode->mode == MODE_IEEE80211G && | |
668 | (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) && | |
badffb72 | 669 | (tx->flags & IEEE80211_TXRXD_TXUNICAST) && |
13262ffd | 670 | (tx->sdata->flags & IEEE80211_SDATA_USE_PROTECTION) && |
e2ebc74d JB |
671 | !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) |
672 | control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT; | |
673 | ||
7e9ed188 DD |
674 | /* Transmit data frames using short preambles if the driver supports |
675 | * short preambles at the selected rate and short preambles are | |
676 | * available on the network at the current point in time. */ | |
677 | if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) && | |
678 | (tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) && | |
13262ffd | 679 | (tx->sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE) && |
7e9ed188 DD |
680 | (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) { |
681 | tx->u.tx.control->tx_rate = tx->u.tx.rate->val2; | |
682 | } | |
683 | ||
e2ebc74d JB |
684 | /* Setup duration field for the first fragment of the frame. Duration |
685 | * for remaining fragments will be updated when they are being sent | |
686 | * to low-level driver in ieee80211_tx(). */ | |
687 | dur = ieee80211_duration(tx, is_multicast_ether_addr(hdr->addr1), | |
badffb72 JS |
688 | (tx->flags & IEEE80211_TXRXD_FRAGMENTED) ? |
689 | tx->u.tx.extra_frag[0]->len : 0); | |
e2ebc74d JB |
690 | hdr->duration_id = cpu_to_le16(dur); |
691 | ||
692 | if ((control->flags & IEEE80211_TXCTL_USE_RTS_CTS) || | |
693 | (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { | |
694 | struct ieee80211_rate *rate; | |
695 | ||
696 | /* Do not use multiple retry rates when using RTS/CTS */ | |
697 | control->alt_retry_rate = -1; | |
698 | ||
699 | /* Use min(data rate, max base rate) as CTS/RTS rate */ | |
700 | rate = tx->u.tx.rate; | |
701 | while (rate > mode->rates && | |
702 | !(rate->flags & IEEE80211_RATE_BASIC)) | |
703 | rate--; | |
704 | ||
705 | control->rts_cts_rate = rate->val; | |
706 | control->rts_rate = rate; | |
707 | } | |
708 | ||
709 | if (tx->sta) { | |
710 | tx->sta->tx_packets++; | |
711 | tx->sta->tx_fragments++; | |
712 | tx->sta->tx_bytes += tx->skb->len; | |
713 | if (tx->u.tx.extra_frag) { | |
714 | int i; | |
715 | tx->sta->tx_fragments += tx->u.tx.num_extra_frag; | |
716 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | |
717 | tx->sta->tx_bytes += | |
718 | tx->u.tx.extra_frag[i]->len; | |
719 | } | |
720 | } | |
721 | } | |
722 | ||
723 | return TXRX_CONTINUE; | |
724 | } | |
725 | ||
726 | static ieee80211_txrx_result | |
727 | ieee80211_tx_h_load_stats(struct ieee80211_txrx_data *tx) | |
728 | { | |
729 | struct ieee80211_local *local = tx->local; | |
730 | struct ieee80211_hw_mode *mode = tx->u.tx.mode; | |
731 | struct sk_buff *skb = tx->skb; | |
732 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
733 | u32 load = 0, hdrtime; | |
734 | ||
735 | /* TODO: this could be part of tx_status handling, so that the number | |
736 | * of retries would be known; TX rate should in that case be stored | |
737 | * somewhere with the packet */ | |
738 | ||
739 | /* Estimate total channel use caused by this frame */ | |
740 | ||
741 | /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values, | |
742 | * 1 usec = 1/8 * (1080 / 10) = 13.5 */ | |
743 | ||
744 | if (mode->mode == MODE_IEEE80211A || | |
e2ebc74d JB |
745 | (mode->mode == MODE_IEEE80211G && |
746 | tx->u.tx.rate->flags & IEEE80211_RATE_ERP)) | |
747 | hdrtime = CHAN_UTIL_HDR_SHORT; | |
748 | else | |
749 | hdrtime = CHAN_UTIL_HDR_LONG; | |
750 | ||
751 | load = hdrtime; | |
752 | if (!is_multicast_ether_addr(hdr->addr1)) | |
753 | load += hdrtime; | |
754 | ||
755 | if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_RTS_CTS) | |
756 | load += 2 * hdrtime; | |
757 | else if (tx->u.tx.control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) | |
758 | load += hdrtime; | |
759 | ||
760 | load += skb->len * tx->u.tx.rate->rate_inv; | |
761 | ||
762 | if (tx->u.tx.extra_frag) { | |
763 | int i; | |
764 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | |
765 | load += 2 * hdrtime; | |
766 | load += tx->u.tx.extra_frag[i]->len * | |
767 | tx->u.tx.rate->rate; | |
768 | } | |
769 | } | |
770 | ||
771 | /* Divide channel_use by 8 to avoid wrapping around the counter */ | |
772 | load >>= CHAN_UTIL_SHIFT; | |
773 | local->channel_use_raw += load; | |
774 | if (tx->sta) | |
775 | tx->sta->channel_use_raw += load; | |
776 | tx->sdata->channel_use_raw += load; | |
777 | ||
778 | return TXRX_CONTINUE; | |
779 | } | |
780 | ||
781 | /* TODO: implement register/unregister functions for adding TX/RX handlers | |
782 | * into ordered list */ | |
783 | ||
784 | ieee80211_tx_handler ieee80211_tx_handlers[] = | |
785 | { | |
786 | ieee80211_tx_h_check_assoc, | |
787 | ieee80211_tx_h_sequence, | |
788 | ieee80211_tx_h_ps_buf, | |
789 | ieee80211_tx_h_select_key, | |
790 | ieee80211_tx_h_michael_mic_add, | |
791 | ieee80211_tx_h_fragment, | |
6a22a59d | 792 | ieee80211_tx_h_encrypt, |
e2ebc74d JB |
793 | ieee80211_tx_h_rate_ctrl, |
794 | ieee80211_tx_h_misc, | |
795 | ieee80211_tx_h_load_stats, | |
796 | NULL | |
797 | }; | |
798 | ||
799 | /* actual transmit path */ | |
800 | ||
801 | /* | |
802 | * deal with packet injection down monitor interface | |
803 | * with Radiotap Header -- only called for monitor mode interface | |
804 | */ | |
805 | static ieee80211_txrx_result | |
58d4185e JB |
806 | __ieee80211_parse_tx_radiotap(struct ieee80211_txrx_data *tx, |
807 | struct sk_buff *skb) | |
e2ebc74d JB |
808 | { |
809 | /* | |
810 | * this is the moment to interpret and discard the radiotap header that | |
811 | * must be at the start of the packet injected in Monitor mode | |
812 | * | |
813 | * Need to take some care with endian-ness since radiotap | |
814 | * args are little-endian | |
815 | */ | |
816 | ||
817 | struct ieee80211_radiotap_iterator iterator; | |
818 | struct ieee80211_radiotap_header *rthdr = | |
819 | (struct ieee80211_radiotap_header *) skb->data; | |
820 | struct ieee80211_hw_mode *mode = tx->local->hw.conf.mode; | |
821 | int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len); | |
58d4185e | 822 | struct ieee80211_tx_control *control = tx->u.tx.control; |
e2ebc74d | 823 | |
58d4185e JB |
824 | control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; |
825 | tx->flags |= IEEE80211_TXRXD_TX_INJECTED; | |
826 | tx->flags &= ~IEEE80211_TXRXD_FRAGMENTED; | |
e2ebc74d JB |
827 | |
828 | /* | |
829 | * for every radiotap entry that is present | |
830 | * (ieee80211_radiotap_iterator_next returns -ENOENT when no more | |
831 | * entries present, or -EINVAL on error) | |
832 | */ | |
833 | ||
834 | while (!ret) { | |
835 | int i, target_rate; | |
836 | ||
837 | ret = ieee80211_radiotap_iterator_next(&iterator); | |
838 | ||
839 | if (ret) | |
840 | continue; | |
841 | ||
842 | /* see if this argument is something we can use */ | |
843 | switch (iterator.this_arg_index) { | |
844 | /* | |
845 | * You must take care when dereferencing iterator.this_arg | |
846 | * for multibyte types... the pointer is not aligned. Use | |
847 | * get_unaligned((type *)iterator.this_arg) to dereference | |
848 | * iterator.this_arg for type "type" safely on all arches. | |
849 | */ | |
850 | case IEEE80211_RADIOTAP_RATE: | |
851 | /* | |
852 | * radiotap rate u8 is in 500kbps units eg, 0x02=1Mbps | |
853 | * ieee80211 rate int is in 100kbps units eg, 0x0a=1Mbps | |
854 | */ | |
855 | target_rate = (*iterator.this_arg) * 5; | |
856 | for (i = 0; i < mode->num_rates; i++) { | |
857 | struct ieee80211_rate *r = &mode->rates[i]; | |
858 | ||
58d4185e JB |
859 | if (r->rate == target_rate) { |
860 | tx->u.tx.rate = r; | |
861 | break; | |
862 | } | |
e2ebc74d JB |
863 | } |
864 | break; | |
865 | ||
866 | case IEEE80211_RADIOTAP_ANTENNA: | |
867 | /* | |
868 | * radiotap uses 0 for 1st ant, mac80211 is 1 for | |
869 | * 1st ant | |
870 | */ | |
871 | control->antenna_sel_tx = (*iterator.this_arg) + 1; | |
872 | break; | |
873 | ||
874 | case IEEE80211_RADIOTAP_DBM_TX_POWER: | |
875 | control->power_level = *iterator.this_arg; | |
876 | break; | |
877 | ||
878 | case IEEE80211_RADIOTAP_FLAGS: | |
879 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { | |
880 | /* | |
881 | * this indicates that the skb we have been | |
882 | * handed has the 32-bit FCS CRC at the end... | |
883 | * we should react to that by snipping it off | |
884 | * because it will be recomputed and added | |
885 | * on transmission | |
886 | */ | |
887 | if (skb->len < (iterator.max_length + FCS_LEN)) | |
888 | return TXRX_DROP; | |
889 | ||
890 | skb_trim(skb, skb->len - FCS_LEN); | |
891 | } | |
58d4185e JB |
892 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) |
893 | control->flags &= | |
894 | ~IEEE80211_TXCTL_DO_NOT_ENCRYPT; | |
895 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | |
896 | tx->flags |= IEEE80211_TXRXD_FRAGMENTED; | |
e2ebc74d JB |
897 | break; |
898 | ||
58d4185e JB |
899 | /* |
900 | * Please update the file | |
901 | * Documentation/networking/mac80211-injection.txt | |
902 | * when parsing new fields here. | |
903 | */ | |
904 | ||
e2ebc74d JB |
905 | default: |
906 | break; | |
907 | } | |
908 | } | |
909 | ||
910 | if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */ | |
911 | return TXRX_DROP; | |
912 | ||
913 | /* | |
914 | * remove the radiotap header | |
915 | * iterator->max_length was sanity-checked against | |
916 | * skb->len by iterator init | |
917 | */ | |
918 | skb_pull(skb, iterator.max_length); | |
919 | ||
920 | return TXRX_CONTINUE; | |
921 | } | |
922 | ||
58d4185e JB |
923 | /* |
924 | * initialises @tx | |
925 | */ | |
926 | static ieee80211_txrx_result | |
e2ebc74d JB |
927 | __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, |
928 | struct sk_buff *skb, | |
929 | struct net_device *dev, | |
930 | struct ieee80211_tx_control *control) | |
931 | { | |
932 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
58d4185e | 933 | struct ieee80211_hdr *hdr; |
e2ebc74d | 934 | struct ieee80211_sub_if_data *sdata; |
e2ebc74d JB |
935 | |
936 | int hdrlen; | |
937 | ||
938 | memset(tx, 0, sizeof(*tx)); | |
939 | tx->skb = skb; | |
940 | tx->dev = dev; /* use original interface */ | |
941 | tx->local = local; | |
942 | tx->sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
58d4185e | 943 | tx->u.tx.control = control; |
e2ebc74d | 944 | /* |
58d4185e JB |
945 | * Set this flag (used below to indicate "automatic fragmentation"), |
946 | * it will be cleared/left by radiotap as desired. | |
e2ebc74d | 947 | */ |
58d4185e | 948 | tx->flags |= IEEE80211_TXRXD_FRAGMENTED; |
e2ebc74d JB |
949 | |
950 | /* process and remove the injection radiotap header */ | |
951 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
952 | if (unlikely(sdata->type == IEEE80211_IF_TYPE_MNTR)) { | |
58d4185e | 953 | if (__ieee80211_parse_tx_radiotap(tx, skb) == TXRX_DROP) |
e2ebc74d | 954 | return TXRX_DROP; |
58d4185e | 955 | |
e2ebc74d | 956 | /* |
58d4185e JB |
957 | * __ieee80211_parse_tx_radiotap has now removed |
958 | * the radiotap header that was present and pre-filled | |
959 | * 'tx' with tx control information. | |
e2ebc74d | 960 | */ |
e2ebc74d JB |
961 | } |
962 | ||
58d4185e JB |
963 | hdr = (struct ieee80211_hdr *) skb->data; |
964 | ||
24338793 | 965 | tx->sta = sta_info_get(local, hdr->addr1); |
966 | tx->fc = le16_to_cpu(hdr->frame_control); | |
58d4185e | 967 | |
badffb72 JS |
968 | if (is_multicast_ether_addr(hdr->addr1)) { |
969 | tx->flags &= ~IEEE80211_TXRXD_TXUNICAST; | |
e2ebc74d | 970 | control->flags |= IEEE80211_TXCTL_NO_ACK; |
badffb72 JS |
971 | } else { |
972 | tx->flags |= IEEE80211_TXRXD_TXUNICAST; | |
e2ebc74d | 973 | control->flags &= ~IEEE80211_TXCTL_NO_ACK; |
badffb72 | 974 | } |
58d4185e JB |
975 | |
976 | if (tx->flags & IEEE80211_TXRXD_FRAGMENTED) { | |
977 | if ((tx->flags & IEEE80211_TXRXD_TXUNICAST) && | |
978 | skb->len + FCS_LEN > local->fragmentation_threshold && | |
979 | !local->ops->set_frag_threshold) | |
980 | tx->flags |= IEEE80211_TXRXD_FRAGMENTED; | |
981 | else | |
982 | tx->flags &= ~IEEE80211_TXRXD_FRAGMENTED; | |
983 | } | |
984 | ||
e2ebc74d JB |
985 | if (!tx->sta) |
986 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | |
987 | else if (tx->sta->clear_dst_mask) { | |
988 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | |
989 | tx->sta->clear_dst_mask = 0; | |
990 | } | |
58d4185e | 991 | |
e2ebc74d JB |
992 | hdrlen = ieee80211_get_hdrlen(tx->fc); |
993 | if (skb->len > hdrlen + sizeof(rfc1042_header) + 2) { | |
994 | u8 *pos = &skb->data[hdrlen + sizeof(rfc1042_header)]; | |
995 | tx->ethertype = (pos[0] << 8) | pos[1]; | |
996 | } | |
997 | control->flags |= IEEE80211_TXCTL_FIRST_FRAGMENT; | |
998 | ||
6d65f5db | 999 | return TXRX_CONTINUE; |
e2ebc74d JB |
1000 | } |
1001 | ||
1002 | /* Device in tx->dev has a reference added; use dev_put(tx->dev) when | |
58d4185e JB |
1003 | * finished with it. |
1004 | * | |
1005 | * NB: @tx is uninitialised when passed in here | |
1006 | */ | |
1007 | static int ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |
1008 | struct sk_buff *skb, | |
1009 | struct net_device *mdev, | |
1010 | struct ieee80211_tx_control *control) | |
e2ebc74d JB |
1011 | { |
1012 | struct ieee80211_tx_packet_data *pkt_data; | |
1013 | struct net_device *dev; | |
1014 | ||
1015 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | |
881d966b | 1016 | dev = dev_get_by_index(&init_net, pkt_data->ifindex); |
e2ebc74d JB |
1017 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { |
1018 | dev_put(dev); | |
1019 | dev = NULL; | |
1020 | } | |
1021 | if (unlikely(!dev)) | |
1022 | return -ENODEV; | |
58d4185e | 1023 | /* initialises tx with control */ |
e2ebc74d JB |
1024 | __ieee80211_tx_prepare(tx, skb, dev, control); |
1025 | return 0; | |
1026 | } | |
1027 | ||
1028 | static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | |
1029 | struct ieee80211_txrx_data *tx) | |
1030 | { | |
1031 | struct ieee80211_tx_control *control = tx->u.tx.control; | |
1032 | int ret, i; | |
1033 | ||
1034 | if (!ieee80211_qdisc_installed(local->mdev) && | |
1035 | __ieee80211_queue_stopped(local, 0)) { | |
1036 | netif_stop_queue(local->mdev); | |
1037 | return IEEE80211_TX_AGAIN; | |
1038 | } | |
1039 | if (skb) { | |
dd1cd4c6 JB |
1040 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), |
1041 | "TX to low-level driver", skb); | |
e2ebc74d JB |
1042 | ret = local->ops->tx(local_to_hw(local), skb, control); |
1043 | if (ret) | |
1044 | return IEEE80211_TX_AGAIN; | |
1045 | local->mdev->trans_start = jiffies; | |
1046 | ieee80211_led_tx(local, 1); | |
1047 | } | |
1048 | if (tx->u.tx.extra_frag) { | |
1049 | control->flags &= ~(IEEE80211_TXCTL_USE_RTS_CTS | | |
1050 | IEEE80211_TXCTL_USE_CTS_PROTECT | | |
1051 | IEEE80211_TXCTL_CLEAR_DST_MASK | | |
1052 | IEEE80211_TXCTL_FIRST_FRAGMENT); | |
1053 | for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | |
1054 | if (!tx->u.tx.extra_frag[i]) | |
1055 | continue; | |
1056 | if (__ieee80211_queue_stopped(local, control->queue)) | |
1057 | return IEEE80211_TX_FRAG_AGAIN; | |
1058 | if (i == tx->u.tx.num_extra_frag) { | |
1059 | control->tx_rate = tx->u.tx.last_frag_hwrate; | |
1060 | control->rate = tx->u.tx.last_frag_rate; | |
badffb72 | 1061 | if (tx->flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG) |
e2ebc74d JB |
1062 | control->flags |= |
1063 | IEEE80211_TXCTL_RATE_CTRL_PROBE; | |
1064 | else | |
1065 | control->flags &= | |
1066 | ~IEEE80211_TXCTL_RATE_CTRL_PROBE; | |
1067 | } | |
1068 | ||
dd1cd4c6 | 1069 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), |
e2ebc74d JB |
1070 | "TX to low-level driver", |
1071 | tx->u.tx.extra_frag[i]); | |
1072 | ret = local->ops->tx(local_to_hw(local), | |
1073 | tx->u.tx.extra_frag[i], | |
1074 | control); | |
1075 | if (ret) | |
1076 | return IEEE80211_TX_FRAG_AGAIN; | |
1077 | local->mdev->trans_start = jiffies; | |
1078 | ieee80211_led_tx(local, 1); | |
1079 | tx->u.tx.extra_frag[i] = NULL; | |
1080 | } | |
1081 | kfree(tx->u.tx.extra_frag); | |
1082 | tx->u.tx.extra_frag = NULL; | |
1083 | } | |
1084 | return IEEE80211_TX_OK; | |
1085 | } | |
1086 | ||
1087 | static int ieee80211_tx(struct net_device *dev, struct sk_buff *skb, | |
f9d540ee | 1088 | struct ieee80211_tx_control *control) |
e2ebc74d JB |
1089 | { |
1090 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
1091 | struct sta_info *sta; | |
1092 | ieee80211_tx_handler *handler; | |
1093 | struct ieee80211_txrx_data tx; | |
1094 | ieee80211_txrx_result res = TXRX_DROP, res_prepare; | |
1095 | int ret, i; | |
1096 | ||
1097 | WARN_ON(__ieee80211_queue_pending(local, control->queue)); | |
1098 | ||
1099 | if (unlikely(skb->len < 10)) { | |
1100 | dev_kfree_skb(skb); | |
1101 | return 0; | |
1102 | } | |
1103 | ||
58d4185e | 1104 | /* initialises tx */ |
e2ebc74d JB |
1105 | res_prepare = __ieee80211_tx_prepare(&tx, skb, dev, control); |
1106 | ||
1107 | if (res_prepare == TXRX_DROP) { | |
1108 | dev_kfree_skb(skb); | |
1109 | return 0; | |
1110 | } | |
1111 | ||
d4e46a3d JB |
1112 | /* |
1113 | * key references are protected using RCU and this requires that | |
1114 | * we are in a read-site RCU section during receive processing | |
1115 | */ | |
1116 | rcu_read_lock(); | |
1117 | ||
e2ebc74d | 1118 | sta = tx.sta; |
e2ebc74d JB |
1119 | tx.u.tx.mode = local->hw.conf.mode; |
1120 | ||
58d4185e JB |
1121 | for (handler = local->tx_handlers; *handler != NULL; |
1122 | handler++) { | |
1123 | res = (*handler)(&tx); | |
1124 | if (res != TXRX_CONTINUE) | |
1125 | break; | |
e2ebc74d JB |
1126 | } |
1127 | ||
1128 | skb = tx.skb; /* handlers are allowed to change skb */ | |
1129 | ||
1130 | if (sta) | |
1131 | sta_info_put(sta); | |
1132 | ||
1133 | if (unlikely(res == TXRX_DROP)) { | |
1134 | I802_DEBUG_INC(local->tx_handlers_drop); | |
1135 | goto drop; | |
1136 | } | |
1137 | ||
1138 | if (unlikely(res == TXRX_QUEUED)) { | |
1139 | I802_DEBUG_INC(local->tx_handlers_queued); | |
d4e46a3d | 1140 | rcu_read_unlock(); |
e2ebc74d JB |
1141 | return 0; |
1142 | } | |
1143 | ||
1144 | if (tx.u.tx.extra_frag) { | |
1145 | for (i = 0; i < tx.u.tx.num_extra_frag; i++) { | |
1146 | int next_len, dur; | |
1147 | struct ieee80211_hdr *hdr = | |
1148 | (struct ieee80211_hdr *) | |
1149 | tx.u.tx.extra_frag[i]->data; | |
1150 | ||
1151 | if (i + 1 < tx.u.tx.num_extra_frag) { | |
1152 | next_len = tx.u.tx.extra_frag[i + 1]->len; | |
1153 | } else { | |
1154 | next_len = 0; | |
1155 | tx.u.tx.rate = tx.u.tx.last_frag_rate; | |
1156 | tx.u.tx.last_frag_hwrate = tx.u.tx.rate->val; | |
1157 | } | |
1158 | dur = ieee80211_duration(&tx, 0, next_len); | |
1159 | hdr->duration_id = cpu_to_le16(dur); | |
1160 | } | |
1161 | } | |
1162 | ||
1163 | retry: | |
1164 | ret = __ieee80211_tx(local, skb, &tx); | |
1165 | if (ret) { | |
1166 | struct ieee80211_tx_stored_packet *store = | |
1167 | &local->pending_packet[control->queue]; | |
1168 | ||
1169 | if (ret == IEEE80211_TX_FRAG_AGAIN) | |
1170 | skb = NULL; | |
1171 | set_bit(IEEE80211_LINK_STATE_PENDING, | |
1172 | &local->state[control->queue]); | |
1173 | smp_mb(); | |
1174 | /* When the driver gets out of buffers during sending of | |
1175 | * fragments and calls ieee80211_stop_queue, there is | |
1176 | * a small window between IEEE80211_LINK_STATE_XOFF and | |
1177 | * IEEE80211_LINK_STATE_PENDING flags are set. If a buffer | |
1178 | * gets available in that window (i.e. driver calls | |
1179 | * ieee80211_wake_queue), we would end up with ieee80211_tx | |
1180 | * called with IEEE80211_LINK_STATE_PENDING. Prevent this by | |
1181 | * continuing transmitting here when that situation is | |
1182 | * possible to have happened. */ | |
1183 | if (!__ieee80211_queue_stopped(local, control->queue)) { | |
1184 | clear_bit(IEEE80211_LINK_STATE_PENDING, | |
1185 | &local->state[control->queue]); | |
1186 | goto retry; | |
1187 | } | |
1188 | memcpy(&store->control, control, | |
1189 | sizeof(struct ieee80211_tx_control)); | |
1190 | store->skb = skb; | |
1191 | store->extra_frag = tx.u.tx.extra_frag; | |
1192 | store->num_extra_frag = tx.u.tx.num_extra_frag; | |
1193 | store->last_frag_hwrate = tx.u.tx.last_frag_hwrate; | |
1194 | store->last_frag_rate = tx.u.tx.last_frag_rate; | |
badffb72 JS |
1195 | store->last_frag_rate_ctrl_probe = |
1196 | !!(tx.flags & IEEE80211_TXRXD_TXPROBE_LAST_FRAG); | |
e2ebc74d | 1197 | } |
d4e46a3d | 1198 | rcu_read_unlock(); |
e2ebc74d JB |
1199 | return 0; |
1200 | ||
1201 | drop: | |
1202 | if (skb) | |
1203 | dev_kfree_skb(skb); | |
1204 | for (i = 0; i < tx.u.tx.num_extra_frag; i++) | |
1205 | if (tx.u.tx.extra_frag[i]) | |
1206 | dev_kfree_skb(tx.u.tx.extra_frag[i]); | |
1207 | kfree(tx.u.tx.extra_frag); | |
d4e46a3d | 1208 | rcu_read_unlock(); |
e2ebc74d JB |
1209 | return 0; |
1210 | } | |
1211 | ||
1212 | /* device xmit handlers */ | |
1213 | ||
1214 | int ieee80211_master_start_xmit(struct sk_buff *skb, | |
1215 | struct net_device *dev) | |
1216 | { | |
1217 | struct ieee80211_tx_control control; | |
1218 | struct ieee80211_tx_packet_data *pkt_data; | |
1219 | struct net_device *odev = NULL; | |
1220 | struct ieee80211_sub_if_data *osdata; | |
1221 | int headroom; | |
1222 | int ret; | |
1223 | ||
1224 | /* | |
1225 | * copy control out of the skb so other people can use skb->cb | |
1226 | */ | |
1227 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | |
1228 | memset(&control, 0, sizeof(struct ieee80211_tx_control)); | |
1229 | ||
1230 | if (pkt_data->ifindex) | |
881d966b | 1231 | odev = dev_get_by_index(&init_net, pkt_data->ifindex); |
e2ebc74d JB |
1232 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { |
1233 | dev_put(odev); | |
1234 | odev = NULL; | |
1235 | } | |
1236 | if (unlikely(!odev)) { | |
1237 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
1238 | printk(KERN_DEBUG "%s: Discarded packet with nonexistent " | |
1239 | "originating device\n", dev->name); | |
1240 | #endif | |
1241 | dev_kfree_skb(skb); | |
1242 | return 0; | |
1243 | } | |
1244 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); | |
1245 | ||
1246 | headroom = osdata->local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM; | |
1247 | if (skb_headroom(skb) < headroom) { | |
1248 | if (pskb_expand_head(skb, headroom, 0, GFP_ATOMIC)) { | |
1249 | dev_kfree_skb(skb); | |
1250 | dev_put(odev); | |
1251 | return 0; | |
1252 | } | |
1253 | } | |
1254 | ||
1255 | control.ifindex = odev->ifindex; | |
1256 | control.type = osdata->type; | |
e8bf9649 | 1257 | if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS) |
e2ebc74d | 1258 | control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS; |
e8bf9649 | 1259 | if (pkt_data->flags & IEEE80211_TXPD_DO_NOT_ENCRYPT) |
e2ebc74d | 1260 | control.flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT; |
e8bf9649 | 1261 | if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) |
e2ebc74d | 1262 | control.flags |= IEEE80211_TXCTL_REQUEUE; |
678f5f71 JB |
1263 | if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME) |
1264 | control.flags |= IEEE80211_TXCTL_EAPOL_FRAME; | |
e2ebc74d JB |
1265 | control.queue = pkt_data->queue; |
1266 | ||
f9d540ee | 1267 | ret = ieee80211_tx(odev, skb, &control); |
e2ebc74d JB |
1268 | dev_put(odev); |
1269 | ||
1270 | return ret; | |
1271 | } | |
1272 | ||
1273 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |
1274 | struct net_device *dev) | |
1275 | { | |
1276 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
1277 | struct ieee80211_tx_packet_data *pkt_data; | |
1278 | struct ieee80211_radiotap_header *prthdr = | |
1279 | (struct ieee80211_radiotap_header *)skb->data; | |
9b8a74e3 | 1280 | u16 len_rthdr; |
e2ebc74d | 1281 | |
9b8a74e3 AG |
1282 | /* check for not even having the fixed radiotap header part */ |
1283 | if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) | |
1284 | goto fail; /* too short to be possibly valid */ | |
1285 | ||
1286 | /* is it a header version we can trust to find length from? */ | |
1287 | if (unlikely(prthdr->it_version)) | |
1288 | goto fail; /* only version 0 is supported */ | |
1289 | ||
1290 | /* then there must be a radiotap header with a length we can use */ | |
1291 | len_rthdr = ieee80211_get_radiotap_len(skb->data); | |
1292 | ||
1293 | /* does the skb contain enough to deliver on the alleged length? */ | |
1294 | if (unlikely(skb->len < len_rthdr)) | |
1295 | goto fail; /* skb too short for claimed rt header extent */ | |
e2ebc74d JB |
1296 | |
1297 | skb->dev = local->mdev; | |
1298 | ||
1299 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | |
1300 | memset(pkt_data, 0, sizeof(*pkt_data)); | |
9b8a74e3 | 1301 | /* needed because we set skb device to master */ |
e2ebc74d | 1302 | pkt_data->ifindex = dev->ifindex; |
9b8a74e3 | 1303 | |
e8bf9649 | 1304 | pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; |
e2ebc74d | 1305 | |
e2ebc74d JB |
1306 | /* |
1307 | * fix up the pointers accounting for the radiotap | |
1308 | * header still being in there. We are being given | |
1309 | * a precooked IEEE80211 header so no need for | |
1310 | * normal processing | |
1311 | */ | |
9b8a74e3 | 1312 | skb_set_mac_header(skb, len_rthdr); |
e2ebc74d | 1313 | /* |
9b8a74e3 AG |
1314 | * these are just fixed to the end of the rt area since we |
1315 | * don't have any better information and at this point, nobody cares | |
e2ebc74d | 1316 | */ |
9b8a74e3 AG |
1317 | skb_set_network_header(skb, len_rthdr); |
1318 | skb_set_transport_header(skb, len_rthdr); | |
e2ebc74d | 1319 | |
9b8a74e3 AG |
1320 | /* pass the radiotap header up to the next stage intact */ |
1321 | dev_queue_xmit(skb); | |
e2ebc74d | 1322 | return NETDEV_TX_OK; |
9b8a74e3 AG |
1323 | |
1324 | fail: | |
1325 | dev_kfree_skb(skb); | |
1326 | return NETDEV_TX_OK; /* meaning, we dealt with the skb */ | |
e2ebc74d JB |
1327 | } |
1328 | ||
1329 | /** | |
1330 | * ieee80211_subif_start_xmit - netif start_xmit function for Ethernet-type | |
1331 | * subinterfaces (wlan#, WDS, and VLAN interfaces) | |
1332 | * @skb: packet to be sent | |
1333 | * @dev: incoming interface | |
1334 | * | |
1335 | * Returns: 0 on success (and frees skb in this case) or 1 on failure (skb will | |
1336 | * not be freed, and caller is responsible for either retrying later or freeing | |
1337 | * skb). | |
1338 | * | |
1339 | * This function takes in an Ethernet header and encapsulates it with suitable | |
1340 | * IEEE 802.11 header based on which interface the packet is coming in. The | |
1341 | * encapsulated packet will then be passed to master interface, wlan#.11, for | |
1342 | * transmission (through low-level driver). | |
1343 | */ | |
1344 | int ieee80211_subif_start_xmit(struct sk_buff *skb, | |
1345 | struct net_device *dev) | |
1346 | { | |
1347 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
1348 | struct ieee80211_tx_packet_data *pkt_data; | |
1349 | struct ieee80211_sub_if_data *sdata; | |
1350 | int ret = 1, head_need; | |
1351 | u16 ethertype, hdrlen, fc; | |
1352 | struct ieee80211_hdr hdr; | |
1353 | const u8 *encaps_data; | |
1354 | int encaps_len, skip_header_bytes; | |
e8bf9649 | 1355 | int nh_pos, h_pos; |
e2ebc74d | 1356 | struct sta_info *sta; |
ce3edf6d | 1357 | u32 sta_flags = 0; |
e2ebc74d JB |
1358 | |
1359 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1360 | if (unlikely(skb->len < ETH_HLEN)) { | |
1361 | printk(KERN_DEBUG "%s: short skb (len=%d)\n", | |
1362 | dev->name, skb->len); | |
1363 | ret = 0; | |
1364 | goto fail; | |
1365 | } | |
1366 | ||
1367 | nh_pos = skb_network_header(skb) - skb->data; | |
1368 | h_pos = skb_transport_header(skb) - skb->data; | |
1369 | ||
1370 | /* convert Ethernet header to proper 802.11 header (based on | |
1371 | * operation mode) */ | |
1372 | ethertype = (skb->data[12] << 8) | skb->data[13]; | |
e2ebc74d JB |
1373 | fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA; |
1374 | ||
cf966838 JB |
1375 | switch (sdata->type) { |
1376 | case IEEE80211_IF_TYPE_AP: | |
1377 | case IEEE80211_IF_TYPE_VLAN: | |
e2ebc74d JB |
1378 | fc |= IEEE80211_FCTL_FROMDS; |
1379 | /* DA BSSID SA */ | |
1380 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | |
1381 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | |
1382 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); | |
1383 | hdrlen = 24; | |
cf966838 JB |
1384 | break; |
1385 | case IEEE80211_IF_TYPE_WDS: | |
e2ebc74d JB |
1386 | fc |= IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS; |
1387 | /* RA TA DA SA */ | |
1388 | memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN); | |
1389 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | |
1390 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | |
1391 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | |
1392 | hdrlen = 30; | |
cf966838 JB |
1393 | break; |
1394 | case IEEE80211_IF_TYPE_STA: | |
e2ebc74d JB |
1395 | fc |= IEEE80211_FCTL_TODS; |
1396 | /* BSSID SA DA */ | |
1397 | memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN); | |
1398 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | |
1399 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | |
1400 | hdrlen = 24; | |
cf966838 JB |
1401 | break; |
1402 | case IEEE80211_IF_TYPE_IBSS: | |
e2ebc74d JB |
1403 | /* DA SA BSSID */ |
1404 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | |
1405 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | |
1406 | memcpy(hdr.addr3, sdata->u.sta.bssid, ETH_ALEN); | |
1407 | hdrlen = 24; | |
cf966838 JB |
1408 | break; |
1409 | default: | |
e2ebc74d JB |
1410 | ret = 0; |
1411 | goto fail; | |
1412 | } | |
1413 | ||
e2ebc74d JB |
1414 | sta = sta_info_get(local, hdr.addr1); |
1415 | if (sta) { | |
ce3edf6d | 1416 | sta_flags = sta->flags; |
e2ebc74d JB |
1417 | sta_info_put(sta); |
1418 | } | |
1419 | ||
ce3edf6d JB |
1420 | /* receiver is QoS enabled, use a QoS type frame */ |
1421 | if (sta_flags & WLAN_STA_WME) { | |
1422 | fc |= IEEE80211_STYPE_QOS_DATA; | |
1423 | hdrlen += 2; | |
1424 | } | |
1425 | ||
1426 | /* | |
1427 | * If port access control is enabled, drop frames to unauthorised | |
1428 | * stations unless they are EAPOL frames from the local station. | |
1429 | */ | |
1430 | if (unlikely(sdata->ieee802_1x_pac && | |
1431 | !(sta_flags & WLAN_STA_AUTHORIZED) && | |
1432 | !(ethertype == ETH_P_PAE && | |
1433 | compare_ether_addr(dev->dev_addr, | |
1434 | skb->data + ETH_ALEN) == 0))) { | |
1435 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
1436 | DECLARE_MAC_BUF(mac); | |
1437 | ||
1438 | if (net_ratelimit()) | |
1439 | printk(KERN_DEBUG "%s: dropped frame to %s" | |
1440 | " (unauthorized port)\n", dev->name, | |
1441 | print_mac(mac, hdr.addr1)); | |
1442 | #endif | |
1443 | ||
1444 | I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); | |
1445 | ||
1446 | ret = 0; | |
1447 | goto fail; | |
1448 | } | |
1449 | ||
e2ebc74d JB |
1450 | hdr.frame_control = cpu_to_le16(fc); |
1451 | hdr.duration_id = 0; | |
1452 | hdr.seq_ctrl = 0; | |
1453 | ||
1454 | skip_header_bytes = ETH_HLEN; | |
1455 | if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) { | |
1456 | encaps_data = bridge_tunnel_header; | |
1457 | encaps_len = sizeof(bridge_tunnel_header); | |
1458 | skip_header_bytes -= 2; | |
1459 | } else if (ethertype >= 0x600) { | |
1460 | encaps_data = rfc1042_header; | |
1461 | encaps_len = sizeof(rfc1042_header); | |
1462 | skip_header_bytes -= 2; | |
1463 | } else { | |
1464 | encaps_data = NULL; | |
1465 | encaps_len = 0; | |
1466 | } | |
1467 | ||
1468 | skb_pull(skb, skip_header_bytes); | |
1469 | nh_pos -= skip_header_bytes; | |
1470 | h_pos -= skip_header_bytes; | |
1471 | ||
1472 | /* TODO: implement support for fragments so that there is no need to | |
1473 | * reallocate and copy payload; it might be enough to support one | |
1474 | * extra fragment that would be copied in the beginning of the frame | |
1475 | * data.. anyway, it would be nice to include this into skb structure | |
1476 | * somehow | |
1477 | * | |
1478 | * There are few options for this: | |
1479 | * use skb->cb as an extra space for 802.11 header | |
1480 | * allocate new buffer if not enough headroom | |
1481 | * make sure that there is enough headroom in every skb by increasing | |
1482 | * build in headroom in __dev_alloc_skb() (linux/skbuff.h) and | |
1483 | * alloc_skb() (net/core/skbuff.c) | |
1484 | */ | |
1485 | head_need = hdrlen + encaps_len + local->tx_headroom; | |
1486 | head_need -= skb_headroom(skb); | |
1487 | ||
1488 | /* We are going to modify skb data, so make a copy of it if happens to | |
1489 | * be cloned. This could happen, e.g., with Linux bridge code passing | |
1490 | * us broadcast frames. */ | |
1491 | ||
1492 | if (head_need > 0 || skb_cloned(skb)) { | |
1493 | #if 0 | |
1494 | printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " | |
1495 | "of headroom\n", dev->name, head_need); | |
1496 | #endif | |
1497 | ||
1498 | if (skb_cloned(skb)) | |
1499 | I802_DEBUG_INC(local->tx_expand_skb_head_cloned); | |
1500 | else | |
1501 | I802_DEBUG_INC(local->tx_expand_skb_head); | |
1502 | /* Since we have to reallocate the buffer, make sure that there | |
1503 | * is enough room for possible WEP IV/ICV and TKIP (8 bytes | |
1504 | * before payload and 12 after). */ | |
1505 | if (pskb_expand_head(skb, (head_need > 0 ? head_need + 8 : 8), | |
1506 | 12, GFP_ATOMIC)) { | |
1507 | printk(KERN_DEBUG "%s: failed to reallocate TX buffer" | |
1508 | "\n", dev->name); | |
1509 | goto fail; | |
1510 | } | |
1511 | } | |
1512 | ||
1513 | if (encaps_data) { | |
1514 | memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len); | |
1515 | nh_pos += encaps_len; | |
1516 | h_pos += encaps_len; | |
1517 | } | |
c29b9b9b JB |
1518 | |
1519 | if (fc & IEEE80211_STYPE_QOS_DATA) { | |
1520 | __le16 *qos_control; | |
1521 | ||
1522 | qos_control = (__le16*) skb_push(skb, 2); | |
1523 | memcpy(skb_push(skb, hdrlen - 2), &hdr, hdrlen - 2); | |
1524 | /* | |
1525 | * Maybe we could actually set some fields here, for now just | |
1526 | * initialise to zero to indicate no special operation. | |
1527 | */ | |
1528 | *qos_control = 0; | |
1529 | } else | |
1530 | memcpy(skb_push(skb, hdrlen), &hdr, hdrlen); | |
1531 | ||
e2ebc74d JB |
1532 | nh_pos += hdrlen; |
1533 | h_pos += hdrlen; | |
1534 | ||
1535 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | |
1536 | memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data)); | |
1537 | pkt_data->ifindex = dev->ifindex; | |
678f5f71 JB |
1538 | if (ethertype == ETH_P_PAE) |
1539 | pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME; | |
e2ebc74d JB |
1540 | |
1541 | skb->dev = local->mdev; | |
68aae116 SH |
1542 | dev->stats.tx_packets++; |
1543 | dev->stats.tx_bytes += skb->len; | |
e2ebc74d JB |
1544 | |
1545 | /* Update skb pointers to various headers since this modified frame | |
1546 | * is going to go through Linux networking code that may potentially | |
1547 | * need things like pointer to IP header. */ | |
1548 | skb_set_mac_header(skb, 0); | |
1549 | skb_set_network_header(skb, nh_pos); | |
1550 | skb_set_transport_header(skb, h_pos); | |
1551 | ||
1552 | dev->trans_start = jiffies; | |
1553 | dev_queue_xmit(skb); | |
1554 | ||
1555 | return 0; | |
1556 | ||
1557 | fail: | |
1558 | if (!ret) | |
1559 | dev_kfree_skb(skb); | |
1560 | ||
1561 | return ret; | |
1562 | } | |
1563 | ||
e2ebc74d JB |
1564 | /* helper functions for pending packets for when queues are stopped */ |
1565 | ||
1566 | void ieee80211_clear_tx_pending(struct ieee80211_local *local) | |
1567 | { | |
1568 | int i, j; | |
1569 | struct ieee80211_tx_stored_packet *store; | |
1570 | ||
1571 | for (i = 0; i < local->hw.queues; i++) { | |
1572 | if (!__ieee80211_queue_pending(local, i)) | |
1573 | continue; | |
1574 | store = &local->pending_packet[i]; | |
1575 | kfree_skb(store->skb); | |
1576 | for (j = 0; j < store->num_extra_frag; j++) | |
1577 | kfree_skb(store->extra_frag[j]); | |
1578 | kfree(store->extra_frag); | |
1579 | clear_bit(IEEE80211_LINK_STATE_PENDING, &local->state[i]); | |
1580 | } | |
1581 | } | |
1582 | ||
1583 | void ieee80211_tx_pending(unsigned long data) | |
1584 | { | |
1585 | struct ieee80211_local *local = (struct ieee80211_local *)data; | |
1586 | struct net_device *dev = local->mdev; | |
1587 | struct ieee80211_tx_stored_packet *store; | |
1588 | struct ieee80211_txrx_data tx; | |
1589 | int i, ret, reschedule = 0; | |
1590 | ||
1591 | netif_tx_lock_bh(dev); | |
1592 | for (i = 0; i < local->hw.queues; i++) { | |
1593 | if (__ieee80211_queue_stopped(local, i)) | |
1594 | continue; | |
1595 | if (!__ieee80211_queue_pending(local, i)) { | |
1596 | reschedule = 1; | |
1597 | continue; | |
1598 | } | |
1599 | store = &local->pending_packet[i]; | |
1600 | tx.u.tx.control = &store->control; | |
1601 | tx.u.tx.extra_frag = store->extra_frag; | |
1602 | tx.u.tx.num_extra_frag = store->num_extra_frag; | |
1603 | tx.u.tx.last_frag_hwrate = store->last_frag_hwrate; | |
1604 | tx.u.tx.last_frag_rate = store->last_frag_rate; | |
badffb72 JS |
1605 | tx.flags = 0; |
1606 | if (store->last_frag_rate_ctrl_probe) | |
1607 | tx.flags |= IEEE80211_TXRXD_TXPROBE_LAST_FRAG; | |
e2ebc74d JB |
1608 | ret = __ieee80211_tx(local, store->skb, &tx); |
1609 | if (ret) { | |
1610 | if (ret == IEEE80211_TX_FRAG_AGAIN) | |
1611 | store->skb = NULL; | |
1612 | } else { | |
1613 | clear_bit(IEEE80211_LINK_STATE_PENDING, | |
1614 | &local->state[i]); | |
1615 | reschedule = 1; | |
1616 | } | |
1617 | } | |
1618 | netif_tx_unlock_bh(dev); | |
1619 | if (reschedule) { | |
1620 | if (!ieee80211_qdisc_installed(dev)) { | |
1621 | if (!__ieee80211_queue_stopped(local, 0)) | |
1622 | netif_wake_queue(dev); | |
1623 | } else | |
1624 | netif_schedule(dev); | |
1625 | } | |
1626 | } | |
1627 | ||
1628 | /* functions for drivers to get certain frames */ | |
1629 | ||
1630 | static void ieee80211_beacon_add_tim(struct ieee80211_local *local, | |
1631 | struct ieee80211_if_ap *bss, | |
1632 | struct sk_buff *skb) | |
1633 | { | |
1634 | u8 *pos, *tim; | |
1635 | int aid0 = 0; | |
1636 | int i, have_bits = 0, n1, n2; | |
1637 | ||
1638 | /* Generate bitmap for TIM only if there are any STAs in power save | |
1639 | * mode. */ | |
be8755e1 | 1640 | read_lock_bh(&local->sta_lock); |
e2ebc74d JB |
1641 | if (atomic_read(&bss->num_sta_ps) > 0) |
1642 | /* in the hope that this is faster than | |
1643 | * checking byte-for-byte */ | |
1644 | have_bits = !bitmap_empty((unsigned long*)bss->tim, | |
1645 | IEEE80211_MAX_AID+1); | |
1646 | ||
1647 | if (bss->dtim_count == 0) | |
1648 | bss->dtim_count = bss->dtim_period - 1; | |
1649 | else | |
1650 | bss->dtim_count--; | |
1651 | ||
1652 | tim = pos = (u8 *) skb_put(skb, 6); | |
1653 | *pos++ = WLAN_EID_TIM; | |
1654 | *pos++ = 4; | |
1655 | *pos++ = bss->dtim_count; | |
1656 | *pos++ = bss->dtim_period; | |
1657 | ||
1658 | if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf)) | |
1659 | aid0 = 1; | |
1660 | ||
1661 | if (have_bits) { | |
1662 | /* Find largest even number N1 so that bits numbered 1 through | |
1663 | * (N1 x 8) - 1 in the bitmap are 0 and number N2 so that bits | |
1664 | * (N2 + 1) x 8 through 2007 are 0. */ | |
1665 | n1 = 0; | |
1666 | for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) { | |
1667 | if (bss->tim[i]) { | |
1668 | n1 = i & 0xfe; | |
1669 | break; | |
1670 | } | |
1671 | } | |
1672 | n2 = n1; | |
1673 | for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { | |
1674 | if (bss->tim[i]) { | |
1675 | n2 = i; | |
1676 | break; | |
1677 | } | |
1678 | } | |
1679 | ||
1680 | /* Bitmap control */ | |
1681 | *pos++ = n1 | aid0; | |
1682 | /* Part Virt Bitmap */ | |
1683 | memcpy(pos, bss->tim + n1, n2 - n1 + 1); | |
1684 | ||
1685 | tim[1] = n2 - n1 + 4; | |
1686 | skb_put(skb, n2 - n1); | |
1687 | } else { | |
1688 | *pos++ = aid0; /* Bitmap control */ | |
1689 | *pos++ = 0; /* Part Virt Bitmap */ | |
1690 | } | |
be8755e1 | 1691 | read_unlock_bh(&local->sta_lock); |
e2ebc74d JB |
1692 | } |
1693 | ||
1694 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, | |
1695 | struct ieee80211_tx_control *control) | |
1696 | { | |
1697 | struct ieee80211_local *local = hw_to_local(hw); | |
1698 | struct sk_buff *skb; | |
1699 | struct net_device *bdev; | |
1700 | struct ieee80211_sub_if_data *sdata = NULL; | |
1701 | struct ieee80211_if_ap *ap = NULL; | |
1abbe498 | 1702 | struct rate_selection rsel; |
e2ebc74d JB |
1703 | u8 *b_head, *b_tail; |
1704 | int bh_len, bt_len; | |
1705 | ||
881d966b | 1706 | bdev = dev_get_by_index(&init_net, if_id); |
e2ebc74d JB |
1707 | if (bdev) { |
1708 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | |
1709 | ap = &sdata->u.ap; | |
1710 | dev_put(bdev); | |
1711 | } | |
1712 | ||
1713 | if (!ap || sdata->type != IEEE80211_IF_TYPE_AP || | |
1714 | !ap->beacon_head) { | |
1715 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
1716 | if (net_ratelimit()) | |
1717 | printk(KERN_DEBUG "no beacon data avail for idx=%d " | |
1718 | "(%s)\n", if_id, bdev ? bdev->name : "N/A"); | |
1719 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | |
1720 | return NULL; | |
1721 | } | |
1722 | ||
1723 | /* Assume we are generating the normal beacon locally */ | |
1724 | b_head = ap->beacon_head; | |
1725 | b_tail = ap->beacon_tail; | |
1726 | bh_len = ap->beacon_head_len; | |
1727 | bt_len = ap->beacon_tail_len; | |
1728 | ||
1729 | skb = dev_alloc_skb(local->tx_headroom + | |
1730 | bh_len + bt_len + 256 /* maximum TIM len */); | |
1731 | if (!skb) | |
1732 | return NULL; | |
1733 | ||
1734 | skb_reserve(skb, local->tx_headroom); | |
1735 | memcpy(skb_put(skb, bh_len), b_head, bh_len); | |
1736 | ||
1737 | ieee80211_include_sequence(sdata, (struct ieee80211_hdr *)skb->data); | |
1738 | ||
1739 | ieee80211_beacon_add_tim(local, ap, skb); | |
1740 | ||
1741 | if (b_tail) { | |
1742 | memcpy(skb_put(skb, bt_len), b_tail, bt_len); | |
1743 | } | |
1744 | ||
1745 | if (control) { | |
1abbe498 MN |
1746 | rate_control_get_rate(local->mdev, local->oper_hw_mode, skb, |
1747 | &rsel); | |
1748 | if (!rsel.rate) { | |
e2ebc74d | 1749 | if (net_ratelimit()) { |
1abbe498 MN |
1750 | printk(KERN_DEBUG "%s: ieee80211_beacon_get: " |
1751 | "no rate found\n", | |
1752 | wiphy_name(local->hw.wiphy)); | |
e2ebc74d JB |
1753 | } |
1754 | dev_kfree_skb(skb); | |
1755 | return NULL; | |
1756 | } | |
1757 | ||
13262ffd JS |
1758 | control->tx_rate = |
1759 | ((sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE) && | |
1abbe498 MN |
1760 | (rsel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ? |
1761 | rsel.rate->val2 : rsel.rate->val; | |
e2ebc74d JB |
1762 | control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; |
1763 | control->power_level = local->hw.conf.power_level; | |
1764 | control->flags |= IEEE80211_TXCTL_NO_ACK; | |
1765 | control->retry_limit = 1; | |
1766 | control->flags |= IEEE80211_TXCTL_CLEAR_DST_MASK; | |
1767 | } | |
1768 | ||
1769 | ap->num_beacons++; | |
1770 | return skb; | |
1771 | } | |
1772 | EXPORT_SYMBOL(ieee80211_beacon_get); | |
1773 | ||
7e9ed188 | 1774 | void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, |
e2ebc74d JB |
1775 | const void *frame, size_t frame_len, |
1776 | const struct ieee80211_tx_control *frame_txctl, | |
1777 | struct ieee80211_rts *rts) | |
1778 | { | |
1779 | const struct ieee80211_hdr *hdr = frame; | |
1780 | u16 fctl; | |
1781 | ||
1782 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS; | |
1783 | rts->frame_control = cpu_to_le16(fctl); | |
7e9ed188 | 1784 | rts->duration = ieee80211_rts_duration(hw, if_id, frame_len, frame_txctl); |
e2ebc74d JB |
1785 | memcpy(rts->ra, hdr->addr1, sizeof(rts->ra)); |
1786 | memcpy(rts->ta, hdr->addr2, sizeof(rts->ta)); | |
1787 | } | |
1788 | EXPORT_SYMBOL(ieee80211_rts_get); | |
1789 | ||
7e9ed188 | 1790 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, |
e2ebc74d JB |
1791 | const void *frame, size_t frame_len, |
1792 | const struct ieee80211_tx_control *frame_txctl, | |
1793 | struct ieee80211_cts *cts) | |
1794 | { | |
1795 | const struct ieee80211_hdr *hdr = frame; | |
1796 | u16 fctl; | |
1797 | ||
1798 | fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS; | |
1799 | cts->frame_control = cpu_to_le16(fctl); | |
7e9ed188 | 1800 | cts->duration = ieee80211_ctstoself_duration(hw, if_id, frame_len, frame_txctl); |
e2ebc74d JB |
1801 | memcpy(cts->ra, hdr->addr1, sizeof(cts->ra)); |
1802 | } | |
1803 | EXPORT_SYMBOL(ieee80211_ctstoself_get); | |
1804 | ||
1805 | struct sk_buff * | |
1806 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | |
1807 | struct ieee80211_tx_control *control) | |
1808 | { | |
1809 | struct ieee80211_local *local = hw_to_local(hw); | |
1810 | struct sk_buff *skb; | |
1811 | struct sta_info *sta; | |
1812 | ieee80211_tx_handler *handler; | |
1813 | struct ieee80211_txrx_data tx; | |
1814 | ieee80211_txrx_result res = TXRX_DROP; | |
1815 | struct net_device *bdev; | |
1816 | struct ieee80211_sub_if_data *sdata; | |
1817 | struct ieee80211_if_ap *bss = NULL; | |
1818 | ||
881d966b | 1819 | bdev = dev_get_by_index(&init_net, if_id); |
e2ebc74d JB |
1820 | if (bdev) { |
1821 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | |
1822 | bss = &sdata->u.ap; | |
1823 | dev_put(bdev); | |
1824 | } | |
1825 | if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head) | |
1826 | return NULL; | |
1827 | ||
1828 | if (bss->dtim_count != 0) | |
1829 | return NULL; /* send buffered bc/mc only after DTIM beacon */ | |
1830 | memset(control, 0, sizeof(*control)); | |
1831 | while (1) { | |
1832 | skb = skb_dequeue(&bss->ps_bc_buf); | |
1833 | if (!skb) | |
1834 | return NULL; | |
1835 | local->total_ps_buffered--; | |
1836 | ||
1837 | if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) { | |
1838 | struct ieee80211_hdr *hdr = | |
1839 | (struct ieee80211_hdr *) skb->data; | |
1840 | /* more buffered multicast/broadcast frames ==> set | |
1841 | * MoreData flag in IEEE 802.11 header to inform PS | |
1842 | * STAs */ | |
1843 | hdr->frame_control |= | |
1844 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); | |
1845 | } | |
1846 | ||
58d4185e | 1847 | if (!ieee80211_tx_prepare(&tx, skb, local->mdev, control)) |
e2ebc74d JB |
1848 | break; |
1849 | dev_kfree_skb_any(skb); | |
1850 | } | |
1851 | sta = tx.sta; | |
badffb72 | 1852 | tx.flags |= IEEE80211_TXRXD_TXPS_BUFFERED; |
475fa49c | 1853 | tx.u.tx.mode = local->hw.conf.mode; |
e2ebc74d JB |
1854 | |
1855 | for (handler = local->tx_handlers; *handler != NULL; handler++) { | |
1856 | res = (*handler)(&tx); | |
1857 | if (res == TXRX_DROP || res == TXRX_QUEUED) | |
1858 | break; | |
1859 | } | |
1860 | dev_put(tx.dev); | |
1861 | skb = tx.skb; /* handlers are allowed to change skb */ | |
1862 | ||
1863 | if (res == TXRX_DROP) { | |
1864 | I802_DEBUG_INC(local->tx_handlers_drop); | |
1865 | dev_kfree_skb(skb); | |
1866 | skb = NULL; | |
1867 | } else if (res == TXRX_QUEUED) { | |
1868 | I802_DEBUG_INC(local->tx_handlers_queued); | |
1869 | skb = NULL; | |
1870 | } | |
1871 | ||
1872 | if (sta) | |
1873 | sta_info_put(sta); | |
1874 | ||
1875 | return skb; | |
1876 | } | |
1877 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); |