mac80211: document TX aggregation (and small cleanup)
[deliverable/linux.git] / net / mac80211 / agg-tx.c
CommitLineData
b8695a8f
JB
1/*
2 * HT handling
3 *
4 * Copyright 2003, Jouni Malinen <jkmaline@cc.hut.fi>
5 * Copyright 2002-2005, Instant802 Networks, Inc.
6 * Copyright 2005-2006, Devicescape Software, Inc.
7 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
9 * Copyright 2007-2009, Intel Corporation
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/ieee80211.h>
17#include <net/mac80211.h>
18#include "ieee80211_i.h"
19#include "wme.h"
20
86ab6c5a
JB
21/**
22 * DOC: TX aggregation
23 *
24 * Aggregation on the TX side requires setting the hardware flag
25 * %IEEE80211_HW_AMPDU_AGGREGATION as well as, if present, the @ampdu_queues
26 * hardware parameter to the number of hardware AMPDU queues. If there are no
27 * hardware queues then the driver will (currently) have to do all frame
28 * buffering.
29 *
30 * When TX aggregation is started by some subsystem (usually the rate control
31 * algorithm would be appropriate) by calling the
32 * ieee80211_start_tx_ba_session() function, the driver will be notified via
33 * its @ampdu_action function, with the %IEEE80211_AMPDU_TX_START action.
34 *
35 * In response to that, the driver is later required to call the
36 * ieee80211_start_tx_ba_cb() (or ieee80211_start_tx_ba_cb_irqsafe())
37 * function, which will start the aggregation session.
38 *
39 * Similarly, when the aggregation session is stopped by
40 * ieee80211_stop_tx_ba_session(), the driver's @ampdu_action function will
41 * be called with the action %IEEE80211_AMPDU_TX_STOP. In this case, the
42 * call must not fail, and the driver must later call ieee80211_stop_tx_ba_cb()
43 * (or ieee80211_stop_tx_ba_cb_irqsafe()).
44 */
45
b8695a8f
JB
46static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
47 const u8 *da, u16 tid,
48 u8 dialog_token, u16 start_seq_num,
49 u16 agg_size, u16 timeout)
50{
51 struct ieee80211_local *local = sdata->local;
52 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
53 struct sk_buff *skb;
54 struct ieee80211_mgmt *mgmt;
55 u16 capab;
56
57 skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
58
59 if (!skb) {
60 printk(KERN_ERR "%s: failed to allocate buffer "
61 "for addba request frame\n", sdata->dev->name);
62 return;
63 }
64 skb_reserve(skb, local->hw.extra_tx_headroom);
65 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
66 memset(mgmt, 0, 24);
67 memcpy(mgmt->da, da, ETH_ALEN);
68 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
8abd3f9b
JB
69 if (sdata->vif.type == NL80211_IFTYPE_AP ||
70 sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
b8695a8f
JB
71 memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
72 else
73 memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
74
75 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
76 IEEE80211_STYPE_ACTION);
77
78 skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req));
79
80 mgmt->u.action.category = WLAN_CATEGORY_BACK;
81 mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ;
82
83 mgmt->u.action.u.addba_req.dialog_token = dialog_token;
84 capab = (u16)(1 << 1); /* bit 1 aggregation policy */
85 capab |= (u16)(tid << 2); /* bit 5:2 TID number */
86 capab |= (u16)(agg_size << 6); /* bit 15:6 max size of aggergation */
87
88 mgmt->u.action.u.addba_req.capab = cpu_to_le16(capab);
89
90 mgmt->u.action.u.addba_req.timeout = cpu_to_le16(timeout);
91 mgmt->u.action.u.addba_req.start_seq_num =
92 cpu_to_le16(start_seq_num << 4);
93
94 ieee80211_tx_skb(sdata, skb, 1);
95}
96
97void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn)
98{
99 struct ieee80211_local *local = sdata->local;
100 struct sk_buff *skb;
101 struct ieee80211_bar *bar;
102 u16 bar_control = 0;
103
104 skb = dev_alloc_skb(sizeof(*bar) + local->hw.extra_tx_headroom);
105 if (!skb) {
106 printk(KERN_ERR "%s: failed to allocate buffer for "
107 "bar frame\n", sdata->dev->name);
108 return;
109 }
110 skb_reserve(skb, local->hw.extra_tx_headroom);
111 bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar));
112 memset(bar, 0, sizeof(*bar));
113 bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
114 IEEE80211_STYPE_BACK_REQ);
115 memcpy(bar->ra, ra, ETH_ALEN);
116 memcpy(bar->ta, sdata->dev->dev_addr, ETH_ALEN);
117 bar_control |= (u16)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL;
118 bar_control |= (u16)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA;
119 bar_control |= (u16)(tid << 12);
120 bar->control = cpu_to_le16(bar_control);
121 bar->start_seq_num = cpu_to_le16(ssn);
122
123 ieee80211_tx_skb(sdata, skb, 0);
124}
125
126/*
127 * After sending add Block Ack request we activated a timer until
128 * add Block Ack response will arrive from the recipient.
129 * If this timer expires sta_addba_resp_timer_expired will be executed.
130 */
131static void sta_addba_resp_timer_expired(unsigned long data)
132{
133 /* not an elegant detour, but there is no choice as the timer passes
134 * only one argument, and both sta_info and TID are needed, so init
135 * flow in sta_info_create gives the TID as data, while the timer_to_id
136 * array gives the sta through container_of */
137 u16 tid = *(u8 *)data;
138 struct sta_info *temp_sta = container_of((void *)data,
139 struct sta_info, timer_to_tid[tid]);
140
141 struct ieee80211_local *local = temp_sta->local;
142 struct ieee80211_hw *hw = &local->hw;
143 struct sta_info *sta;
144 u8 *state;
145
146 rcu_read_lock();
147
148 sta = sta_info_get(local, temp_sta->sta.addr);
149 if (!sta) {
150 rcu_read_unlock();
151 return;
152 }
153
154 state = &sta->ampdu_mlme.tid_state_tx[tid];
155 /* check if the TID waits for addBA response */
156 spin_lock_bh(&sta->lock);
157 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
158 spin_unlock_bh(&sta->lock);
159 *state = HT_AGG_STATE_IDLE;
160#ifdef CONFIG_MAC80211_HT_DEBUG
161 printk(KERN_DEBUG "timer expired on tid %d but we are not "
162 "expecting addBA response there", tid);
163#endif
164 goto timer_expired_exit;
165 }
166
167#ifdef CONFIG_MAC80211_HT_DEBUG
168 printk(KERN_DEBUG "addBA response timer expired on tid %d\n", tid);
169#endif
170
171 /* go through the state check in stop_BA_session */
172 *state = HT_AGG_STATE_OPERATIONAL;
173 spin_unlock_bh(&sta->lock);
174 ieee80211_stop_tx_ba_session(hw, temp_sta->sta.addr, tid,
175 WLAN_BACK_INITIATOR);
176
177timer_expired_exit:
178 rcu_read_unlock();
179}
180
181int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
182{
183 struct ieee80211_local *local = hw_to_local(hw);
184 struct sta_info *sta;
185 struct ieee80211_sub_if_data *sdata;
186 u16 start_seq_num;
187 u8 *state;
188 int ret = 0;
189
190 if ((tid >= STA_TID_NUM) || !(hw->flags & IEEE80211_HW_AMPDU_AGGREGATION))
191 return -EINVAL;
192
193#ifdef CONFIG_MAC80211_HT_DEBUG
194 printk(KERN_DEBUG "Open BA session requested for %pM tid %u\n",
195 ra, tid);
196#endif /* CONFIG_MAC80211_HT_DEBUG */
197
198 rcu_read_lock();
199
200 sta = sta_info_get(local, ra);
201 if (!sta) {
202#ifdef CONFIG_MAC80211_HT_DEBUG
203 printk(KERN_DEBUG "Could not find the station\n");
204#endif
205 ret = -ENOENT;
206 goto exit;
207 }
208
8abd3f9b
JB
209 /*
210 * The aggregation code is not prepared to handle
211 * anything but STA/AP due to the BSSID handling.
212 * IBSS could work in the code but isn't supported
213 * by drivers or the standard.
214 */
215 if (sta->sdata->vif.type != NL80211_IFTYPE_STATION &&
216 sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
217 sta->sdata->vif.type != NL80211_IFTYPE_AP) {
218 ret = -EINVAL;
219 goto exit;
220 }
221
b8695a8f
JB
222 spin_lock_bh(&sta->lock);
223
224 /* we have tried too many times, receiver does not want A-MPDU */
225 if (sta->ampdu_mlme.addba_req_num[tid] > HT_AGG_MAX_RETRIES) {
226 ret = -EBUSY;
227 goto err_unlock_sta;
228 }
229
230 state = &sta->ampdu_mlme.tid_state_tx[tid];
231 /* check if the TID is not in aggregation flow already */
232 if (*state != HT_AGG_STATE_IDLE) {
233#ifdef CONFIG_MAC80211_HT_DEBUG
234 printk(KERN_DEBUG "BA request denied - session is not "
235 "idle on tid %u\n", tid);
236#endif /* CONFIG_MAC80211_HT_DEBUG */
237 ret = -EAGAIN;
238 goto err_unlock_sta;
239 }
240
241 /* prepare A-MPDU MLME for Tx aggregation */
242 sta->ampdu_mlme.tid_tx[tid] =
243 kmalloc(sizeof(struct tid_ampdu_tx), GFP_ATOMIC);
244 if (!sta->ampdu_mlme.tid_tx[tid]) {
245#ifdef CONFIG_MAC80211_HT_DEBUG
246 if (net_ratelimit())
247 printk(KERN_ERR "allocate tx mlme to tid %d failed\n",
248 tid);
249#endif
250 ret = -ENOMEM;
251 goto err_unlock_sta;
252 }
253 /* Tx timer */
254 sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.function =
255 sta_addba_resp_timer_expired;
256 sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.data =
257 (unsigned long)&sta->timer_to_tid[tid];
258 init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
259
260 if (hw->ampdu_queues) {
261 /* create a new queue for this aggregation */
262 ret = ieee80211_ht_agg_queue_add(local, sta, tid);
263
264 /* case no queue is available to aggregation
265 * don't switch to aggregation */
266 if (ret) {
267#ifdef CONFIG_MAC80211_HT_DEBUG
268 printk(KERN_DEBUG "BA request denied - "
269 "queue unavailable for tid %d\n", tid);
270#endif /* CONFIG_MAC80211_HT_DEBUG */
271 goto err_unlock_queue;
272 }
273 }
274 sdata = sta->sdata;
275
276 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
277 * call back right away, it must see that the flow has begun */
278 *state |= HT_ADDBA_REQUESTED_MSK;
279
280 /* This is slightly racy because the queue isn't stopped */
281 start_seq_num = sta->tid_seq[tid];
282
283 if (local->ops->ampdu_action)
284 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
285 &sta->sta, tid, &start_seq_num);
286
287 if (ret) {
288 /* No need to requeue the packets in the agg queue, since we
289 * held the tx lock: no packet could be enqueued to the newly
290 * allocated queue */
291 if (hw->ampdu_queues)
292 ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
293#ifdef CONFIG_MAC80211_HT_DEBUG
294 printk(KERN_DEBUG "BA request denied - HW unavailable for"
295 " tid %d\n", tid);
296#endif /* CONFIG_MAC80211_HT_DEBUG */
297 *state = HT_AGG_STATE_IDLE;
298 goto err_unlock_queue;
299 }
300
301 /* Will put all the packets in the new SW queue */
302 if (hw->ampdu_queues)
303 ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
304 spin_unlock_bh(&sta->lock);
305
306 /* send an addBA request */
307 sta->ampdu_mlme.dialog_token_allocator++;
308 sta->ampdu_mlme.tid_tx[tid]->dialog_token =
309 sta->ampdu_mlme.dialog_token_allocator;
310 sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num;
311
312
313 ieee80211_send_addba_request(sta->sdata, ra, tid,
314 sta->ampdu_mlme.tid_tx[tid]->dialog_token,
315 sta->ampdu_mlme.tid_tx[tid]->ssn,
316 0x40, 5000);
317 /* activate the timer for the recipient's addBA response */
318 sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.expires =
319 jiffies + ADDBA_RESP_INTERVAL;
320 add_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
321#ifdef CONFIG_MAC80211_HT_DEBUG
322 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
323#endif
324 goto exit;
325
326err_unlock_queue:
327 kfree(sta->ampdu_mlme.tid_tx[tid]);
328 sta->ampdu_mlme.tid_tx[tid] = NULL;
329 ret = -EBUSY;
330err_unlock_sta:
331 spin_unlock_bh(&sta->lock);
332exit:
333 rcu_read_unlock();
334 return ret;
335}
336EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
337
338void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
339{
340 struct ieee80211_local *local = hw_to_local(hw);
341 struct sta_info *sta;
342 u8 *state;
343
344 if (tid >= STA_TID_NUM) {
345#ifdef CONFIG_MAC80211_HT_DEBUG
346 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
347 tid, STA_TID_NUM);
348#endif
349 return;
350 }
351
352 rcu_read_lock();
353 sta = sta_info_get(local, ra);
354 if (!sta) {
355 rcu_read_unlock();
356#ifdef CONFIG_MAC80211_HT_DEBUG
357 printk(KERN_DEBUG "Could not find station: %pM\n", ra);
358#endif
359 return;
360 }
361
362 state = &sta->ampdu_mlme.tid_state_tx[tid];
363 spin_lock_bh(&sta->lock);
364
365 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
366#ifdef CONFIG_MAC80211_HT_DEBUG
367 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
368 *state);
369#endif
370 spin_unlock_bh(&sta->lock);
371 rcu_read_unlock();
372 return;
373 }
374
375 WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
376
377 *state |= HT_ADDBA_DRV_READY_MSK;
378
379 if (*state == HT_AGG_STATE_OPERATIONAL) {
380#ifdef CONFIG_MAC80211_HT_DEBUG
381 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
382#endif
383 if (hw->ampdu_queues)
384 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
385 }
386 spin_unlock_bh(&sta->lock);
387 rcu_read_unlock();
388}
389EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
390
86ab6c5a
JB
391void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
392 const u8 *ra, u16 tid)
393{
394 struct ieee80211_local *local = hw_to_local(hw);
395 struct ieee80211_ra_tid *ra_tid;
396 struct sk_buff *skb = dev_alloc_skb(0);
397
398 if (unlikely(!skb)) {
399#ifdef CONFIG_MAC80211_HT_DEBUG
400 if (net_ratelimit())
401 printk(KERN_WARNING "%s: Not enough memory, "
402 "dropping start BA session", skb->dev->name);
403#endif
404 return;
405 }
406 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
407 memcpy(&ra_tid->ra, ra, ETH_ALEN);
408 ra_tid->tid = tid;
409
410 skb->pkt_type = IEEE80211_ADDBA_MSG;
411 skb_queue_tail(&local->skb_queue, skb);
412 tasklet_schedule(&local->tasklet);
413}
414EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
415
b8695a8f
JB
416
417int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
418 u8 *ra, u16 tid,
419 enum ieee80211_back_parties initiator)
420{
421 struct ieee80211_local *local = hw_to_local(hw);
422 struct sta_info *sta;
423 u8 *state;
424 int ret = 0;
425
426 if (tid >= STA_TID_NUM)
427 return -EINVAL;
428
429 rcu_read_lock();
430 sta = sta_info_get(local, ra);
431 if (!sta) {
432 rcu_read_unlock();
433 return -ENOENT;
434 }
435
436 /* check if the TID is in aggregation */
437 state = &sta->ampdu_mlme.tid_state_tx[tid];
438 spin_lock_bh(&sta->lock);
439
440 if (*state != HT_AGG_STATE_OPERATIONAL) {
441 ret = -ENOENT;
442 goto stop_BA_exit;
443 }
444
445#ifdef CONFIG_MAC80211_HT_DEBUG
446 printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n",
447 ra, tid);
448#endif /* CONFIG_MAC80211_HT_DEBUG */
449
450 if (hw->ampdu_queues)
451 ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
452
453 *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
454 (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
455
456 if (local->ops->ampdu_action)
457 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
458 &sta->sta, tid, NULL);
459
955d3fe3
JB
460 /* HW shall not deny going back to legacy */
461 if (WARN_ON(ret)) {
b8695a8f
JB
462 *state = HT_AGG_STATE_OPERATIONAL;
463 if (hw->ampdu_queues)
464 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
465 goto stop_BA_exit;
466 }
467
468stop_BA_exit:
469 spin_unlock_bh(&sta->lock);
470 rcu_read_unlock();
471 return ret;
472}
473EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
474
475void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
476{
477 struct ieee80211_local *local = hw_to_local(hw);
478 struct sta_info *sta;
479 u8 *state;
480 int agg_queue;
481
482 if (tid >= STA_TID_NUM) {
483#ifdef CONFIG_MAC80211_HT_DEBUG
484 printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
485 tid, STA_TID_NUM);
486#endif
487 return;
488 }
489
490#ifdef CONFIG_MAC80211_HT_DEBUG
491 printk(KERN_DEBUG "Stopping Tx BA session for %pM tid %d\n",
492 ra, tid);
493#endif /* CONFIG_MAC80211_HT_DEBUG */
494
495 rcu_read_lock();
496 sta = sta_info_get(local, ra);
497 if (!sta) {
498#ifdef CONFIG_MAC80211_HT_DEBUG
499 printk(KERN_DEBUG "Could not find station: %pM\n", ra);
500#endif
501 rcu_read_unlock();
502 return;
503 }
504 state = &sta->ampdu_mlme.tid_state_tx[tid];
505
506 /* NOTE: no need to use sta->lock in this state check, as
507 * ieee80211_stop_tx_ba_session will let only one stop call to
508 * pass through per sta/tid
509 */
510 if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
511#ifdef CONFIG_MAC80211_HT_DEBUG
512 printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
513#endif
514 rcu_read_unlock();
515 return;
516 }
517
518 if (*state & HT_AGG_STATE_INITIATOR_MSK)
519 ieee80211_send_delba(sta->sdata, ra, tid,
520 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
521
522 if (hw->ampdu_queues) {
523 agg_queue = sta->tid_to_tx_q[tid];
524 ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
525
526 /* We just requeued the all the frames that were in the
527 * removed queue, and since we might miss a softirq we do
528 * netif_schedule_queue. ieee80211_wake_queue is not used
529 * here as this queue is not necessarily stopped
530 */
531 netif_schedule_queue(netdev_get_tx_queue(local->mdev,
532 agg_queue));
533 }
534 spin_lock_bh(&sta->lock);
535 *state = HT_AGG_STATE_IDLE;
536 sta->ampdu_mlme.addba_req_num[tid] = 0;
537 kfree(sta->ampdu_mlme.tid_tx[tid]);
538 sta->ampdu_mlme.tid_tx[tid] = NULL;
539 spin_unlock_bh(&sta->lock);
540
541 rcu_read_unlock();
542}
543EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
544
b8695a8f
JB
545void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
546 const u8 *ra, u16 tid)
547{
548 struct ieee80211_local *local = hw_to_local(hw);
549 struct ieee80211_ra_tid *ra_tid;
550 struct sk_buff *skb = dev_alloc_skb(0);
551
552 if (unlikely(!skb)) {
553#ifdef CONFIG_MAC80211_HT_DEBUG
554 if (net_ratelimit())
555 printk(KERN_WARNING "%s: Not enough memory, "
556 "dropping stop BA session", skb->dev->name);
557#endif
558 return;
559 }
560 ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
561 memcpy(&ra_tid->ra, ra, ETH_ALEN);
562 ra_tid->tid = tid;
563
564 skb->pkt_type = IEEE80211_DELBA_MSG;
565 skb_queue_tail(&local->skb_queue, skb);
566 tasklet_schedule(&local->tasklet);
567}
568EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
569
86ab6c5a 570
b8695a8f
JB
571void ieee80211_process_addba_resp(struct ieee80211_local *local,
572 struct sta_info *sta,
573 struct ieee80211_mgmt *mgmt,
574 size_t len)
575{
576 struct ieee80211_hw *hw = &local->hw;
577 u16 capab;
578 u16 tid, start_seq_num;
579 u8 *state;
580
581 capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
582 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
583
584 state = &sta->ampdu_mlme.tid_state_tx[tid];
585
586 spin_lock_bh(&sta->lock);
587
588 if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
589 spin_unlock_bh(&sta->lock);
590 return;
591 }
592
593 if (mgmt->u.action.u.addba_resp.dialog_token !=
594 sta->ampdu_mlme.tid_tx[tid]->dialog_token) {
595 spin_unlock_bh(&sta->lock);
596#ifdef CONFIG_MAC80211_HT_DEBUG
597 printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid);
598#endif /* CONFIG_MAC80211_HT_DEBUG */
599 return;
600 }
601
602 del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer);
603#ifdef CONFIG_MAC80211_HT_DEBUG
604 printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid);
605#endif /* CONFIG_MAC80211_HT_DEBUG */
606 if (le16_to_cpu(mgmt->u.action.u.addba_resp.status)
607 == WLAN_STATUS_SUCCESS) {
608 *state |= HT_ADDBA_RECEIVED_MSK;
609 sta->ampdu_mlme.addba_req_num[tid] = 0;
610
611 if (*state == HT_AGG_STATE_OPERATIONAL &&
612 local->hw.ampdu_queues)
613 ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
614
615 if (local->ops->ampdu_action) {
616 (void)local->ops->ampdu_action(hw,
617 IEEE80211_AMPDU_TX_RESUME,
618 &sta->sta, tid, &start_seq_num);
619 }
620#ifdef CONFIG_MAC80211_HT_DEBUG
621 printk(KERN_DEBUG "Resuming TX aggregation for tid %d\n", tid);
622#endif /* CONFIG_MAC80211_HT_DEBUG */
623 spin_unlock_bh(&sta->lock);
624 } else {
625 sta->ampdu_mlme.addba_req_num[tid]++;
626 /* this will allow the state check in stop_BA_session */
627 *state = HT_AGG_STATE_OPERATIONAL;
628 spin_unlock_bh(&sta->lock);
629 ieee80211_stop_tx_ba_session(hw, sta->sta.addr, tid,
630 WLAN_BACK_INITIATOR);
631 }
632}
This page took 0.04665 seconds and 5 git commands to generate.