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
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.
16 #include <linux/ieee80211.h>
17 #include <net/mac80211.h>
18 #include "ieee80211_i.h"
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
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.
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.
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()).
46 static 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
)
51 struct ieee80211_local
*local
= sdata
->local
;
53 struct ieee80211_mgmt
*mgmt
;
56 skb
= dev_alloc_skb(sizeof(*mgmt
) + local
->hw
.extra_tx_headroom
);
59 printk(KERN_ERR
"%s: failed to allocate buffer "
60 "for addba request frame\n", sdata
->dev
->name
);
63 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
64 mgmt
= (struct ieee80211_mgmt
*) skb_put(skb
, 24);
66 memcpy(mgmt
->da
, da
, ETH_ALEN
);
67 memcpy(mgmt
->sa
, sdata
->dev
->dev_addr
, ETH_ALEN
);
68 if (sdata
->vif
.type
== NL80211_IFTYPE_AP
||
69 sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
)
70 memcpy(mgmt
->bssid
, sdata
->dev
->dev_addr
, ETH_ALEN
);
71 else if (sdata
->vif
.type
== NL80211_IFTYPE_STATION
)
72 memcpy(mgmt
->bssid
, sdata
->u
.mgd
.bssid
, ETH_ALEN
);
74 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
75 IEEE80211_STYPE_ACTION
);
77 skb_put(skb
, 1 + sizeof(mgmt
->u
.action
.u
.addba_req
));
79 mgmt
->u
.action
.category
= WLAN_CATEGORY_BACK
;
80 mgmt
->u
.action
.u
.addba_req
.action_code
= WLAN_ACTION_ADDBA_REQ
;
82 mgmt
->u
.action
.u
.addba_req
.dialog_token
= dialog_token
;
83 capab
= (u16
)(1 << 1); /* bit 1 aggregation policy */
84 capab
|= (u16
)(tid
<< 2); /* bit 5:2 TID number */
85 capab
|= (u16
)(agg_size
<< 6); /* bit 15:6 max size of aggergation */
87 mgmt
->u
.action
.u
.addba_req
.capab
= cpu_to_le16(capab
);
89 mgmt
->u
.action
.u
.addba_req
.timeout
= cpu_to_le16(timeout
);
90 mgmt
->u
.action
.u
.addba_req
.start_seq_num
=
91 cpu_to_le16(start_seq_num
<< 4);
93 ieee80211_tx_skb(sdata
, skb
, 1);
96 void ieee80211_send_bar(struct ieee80211_sub_if_data
*sdata
, u8
*ra
, u16 tid
, u16 ssn
)
98 struct ieee80211_local
*local
= sdata
->local
;
100 struct ieee80211_bar
*bar
;
103 skb
= dev_alloc_skb(sizeof(*bar
) + local
->hw
.extra_tx_headroom
);
105 printk(KERN_ERR
"%s: failed to allocate buffer for "
106 "bar frame\n", sdata
->dev
->name
);
109 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
110 bar
= (struct ieee80211_bar
*)skb_put(skb
, sizeof(*bar
));
111 memset(bar
, 0, sizeof(*bar
));
112 bar
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_CTL
|
113 IEEE80211_STYPE_BACK_REQ
);
114 memcpy(bar
->ra
, ra
, ETH_ALEN
);
115 memcpy(bar
->ta
, sdata
->dev
->dev_addr
, ETH_ALEN
);
116 bar_control
|= (u16
)IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL
;
117 bar_control
|= (u16
)IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA
;
118 bar_control
|= (u16
)(tid
<< 12);
119 bar
->control
= cpu_to_le16(bar_control
);
120 bar
->start_seq_num
= cpu_to_le16(ssn
);
122 ieee80211_tx_skb(sdata
, skb
, 0);
125 static int ___ieee80211_stop_tx_ba_session(struct sta_info
*sta
, u16 tid
,
126 enum ieee80211_back_parties initiator
)
128 struct ieee80211_local
*local
= sta
->local
;
132 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
134 *state
= HT_AGG_STATE_REQ_STOP_BA_MSK
|
135 (initiator
<< HT_AGG_STATE_INITIATOR_SHIFT
);
137 ret
= local
->ops
->ampdu_action(&local
->hw
, IEEE80211_AMPDU_TX_STOP
,
138 &sta
->sta
, tid
, NULL
);
140 /* HW shall not deny going back to legacy */
142 *state
= HT_AGG_STATE_OPERATIONAL
;
144 * We may have pending packets get stuck in this case...
145 * Not bothering with a workaround for now.
153 * After sending add Block Ack request we activated a timer until
154 * add Block Ack response will arrive from the recipient.
155 * If this timer expires sta_addba_resp_timer_expired will be executed.
157 static void sta_addba_resp_timer_expired(unsigned long data
)
159 /* not an elegant detour, but there is no choice as the timer passes
160 * only one argument, and both sta_info and TID are needed, so init
161 * flow in sta_info_create gives the TID as data, while the timer_to_id
162 * array gives the sta through container_of */
163 u16 tid
= *(u8
*)data
;
164 struct sta_info
*sta
= container_of((void *)data
,
165 struct sta_info
, timer_to_tid
[tid
]);
168 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
170 /* check if the TID waits for addBA response */
171 spin_lock_bh(&sta
->lock
);
172 if (!(*state
& HT_ADDBA_REQUESTED_MSK
)) {
173 spin_unlock_bh(&sta
->lock
);
174 *state
= HT_AGG_STATE_IDLE
;
175 #ifdef CONFIG_MAC80211_HT_DEBUG
176 printk(KERN_DEBUG
"timer expired on tid %d but we are not "
177 "expecting addBA response there", tid
);
182 #ifdef CONFIG_MAC80211_HT_DEBUG
183 printk(KERN_DEBUG
"addBA response timer expired on tid %d\n", tid
);
186 ___ieee80211_stop_tx_ba_session(sta
, tid
, WLAN_BACK_INITIATOR
);
187 spin_unlock_bh(&sta
->lock
);
190 static inline int ieee80211_ac_from_tid(int tid
)
192 return ieee802_1d_to_ac
[tid
& 7];
195 int ieee80211_start_tx_ba_session(struct ieee80211_hw
*hw
, u8
*ra
, u16 tid
)
197 struct ieee80211_local
*local
= hw_to_local(hw
);
198 struct sta_info
*sta
;
199 struct ieee80211_sub_if_data
*sdata
;
204 if (WARN_ON(!local
->ops
->ampdu_action
))
207 if ((tid
>= STA_TID_NUM
) || !(hw
->flags
& IEEE80211_HW_AMPDU_AGGREGATION
))
210 #ifdef CONFIG_MAC80211_HT_DEBUG
211 printk(KERN_DEBUG
"Open BA session requested for %pM tid %u\n",
213 #endif /* CONFIG_MAC80211_HT_DEBUG */
217 sta
= sta_info_get(local
, ra
);
219 #ifdef CONFIG_MAC80211_HT_DEBUG
220 printk(KERN_DEBUG
"Could not find the station\n");
227 * The aggregation code is not prepared to handle
228 * anything but STA/AP due to the BSSID handling.
229 * IBSS could work in the code but isn't supported
230 * by drivers or the standard.
232 if (sta
->sdata
->vif
.type
!= NL80211_IFTYPE_STATION
&&
233 sta
->sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
234 sta
->sdata
->vif
.type
!= NL80211_IFTYPE_AP
) {
239 if (test_sta_flags(sta
, WLAN_STA_SUSPEND
)) {
240 #ifdef CONFIG_MAC80211_HT_DEBUG
241 printk(KERN_DEBUG
"Suspend in progress. "
242 "Denying BA session request\n");
248 spin_lock_bh(&sta
->lock
);
249 spin_lock(&local
->ampdu_lock
);
253 /* we have tried too many times, receiver does not want A-MPDU */
254 if (sta
->ampdu_mlme
.addba_req_num
[tid
] > HT_AGG_MAX_RETRIES
) {
259 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
260 /* check if the TID is not in aggregation flow already */
261 if (*state
!= HT_AGG_STATE_IDLE
) {
262 #ifdef CONFIG_MAC80211_HT_DEBUG
263 printk(KERN_DEBUG
"BA request denied - session is not "
264 "idle on tid %u\n", tid
);
265 #endif /* CONFIG_MAC80211_HT_DEBUG */
271 * While we're asking the driver about the aggregation,
272 * stop the AC queue so that we don't have to worry
273 * about frames that came in while we were doing that,
274 * which would require us to put them to the AC pending
275 * afterwards which just makes the code more complex.
277 ieee80211_stop_queue_by_reason(
278 &local
->hw
, ieee80211_ac_from_tid(tid
),
279 IEEE80211_QUEUE_STOP_REASON_AGGREGATION
);
281 /* prepare A-MPDU MLME for Tx aggregation */
282 sta
->ampdu_mlme
.tid_tx
[tid
] =
283 kmalloc(sizeof(struct tid_ampdu_tx
), GFP_ATOMIC
);
284 if (!sta
->ampdu_mlme
.tid_tx
[tid
]) {
285 #ifdef CONFIG_MAC80211_HT_DEBUG
287 printk(KERN_ERR
"allocate tx mlme to tid %d failed\n",
294 skb_queue_head_init(&sta
->ampdu_mlme
.tid_tx
[tid
]->pending
);
297 sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
.function
=
298 sta_addba_resp_timer_expired
;
299 sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
.data
=
300 (unsigned long)&sta
->timer_to_tid
[tid
];
301 init_timer(&sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
);
303 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
304 * call back right away, it must see that the flow has begun */
305 *state
|= HT_ADDBA_REQUESTED_MSK
;
307 start_seq_num
= sta
->tid_seq
[tid
];
309 ret
= local
->ops
->ampdu_action(hw
, IEEE80211_AMPDU_TX_START
,
310 &sta
->sta
, tid
, &start_seq_num
);
313 #ifdef CONFIG_MAC80211_HT_DEBUG
314 printk(KERN_DEBUG
"BA request denied - HW unavailable for"
316 #endif /* CONFIG_MAC80211_HT_DEBUG */
317 *state
= HT_AGG_STATE_IDLE
;
321 /* Driver vetoed or OKed, but we can take packets again now */
322 ieee80211_wake_queue_by_reason(
323 &local
->hw
, ieee80211_ac_from_tid(tid
),
324 IEEE80211_QUEUE_STOP_REASON_AGGREGATION
);
326 spin_unlock(&local
->ampdu_lock
);
327 spin_unlock_bh(&sta
->lock
);
329 /* send an addBA request */
330 sta
->ampdu_mlme
.dialog_token_allocator
++;
331 sta
->ampdu_mlme
.tid_tx
[tid
]->dialog_token
=
332 sta
->ampdu_mlme
.dialog_token_allocator
;
333 sta
->ampdu_mlme
.tid_tx
[tid
]->ssn
= start_seq_num
;
335 ieee80211_send_addba_request(sta
->sdata
, ra
, tid
,
336 sta
->ampdu_mlme
.tid_tx
[tid
]->dialog_token
,
337 sta
->ampdu_mlme
.tid_tx
[tid
]->ssn
,
339 /* activate the timer for the recipient's addBA response */
340 sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
.expires
=
341 jiffies
+ ADDBA_RESP_INTERVAL
;
342 add_timer(&sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
);
343 #ifdef CONFIG_MAC80211_HT_DEBUG
344 printk(KERN_DEBUG
"activated addBA response timer on tid %d\n", tid
);
349 kfree(sta
->ampdu_mlme
.tid_tx
[tid
]);
350 sta
->ampdu_mlme
.tid_tx
[tid
] = NULL
;
352 ieee80211_wake_queue_by_reason(
353 &local
->hw
, ieee80211_ac_from_tid(tid
),
354 IEEE80211_QUEUE_STOP_REASON_AGGREGATION
);
356 spin_unlock(&local
->ampdu_lock
);
357 spin_unlock_bh(&sta
->lock
);
362 EXPORT_SYMBOL(ieee80211_start_tx_ba_session
);
365 * splice packets from the STA's pending to the local pending,
366 * requires a call to ieee80211_agg_splice_finish and holding
367 * local->ampdu_lock across both calls.
369 static void ieee80211_agg_splice_packets(struct ieee80211_local
*local
,
370 struct sta_info
*sta
, u16 tid
)
373 u16 queue
= ieee80211_ac_from_tid(tid
);
375 ieee80211_stop_queue_by_reason(
377 IEEE80211_QUEUE_STOP_REASON_AGGREGATION
);
379 if (!skb_queue_empty(&sta
->ampdu_mlme
.tid_tx
[tid
]->pending
)) {
380 spin_lock_irqsave(&local
->queue_stop_reason_lock
, flags
);
381 /* mark queue as pending, it is stopped already */
382 __set_bit(IEEE80211_QUEUE_STOP_REASON_PENDING
,
383 &local
->queue_stop_reasons
[queue
]);
384 /* copy over remaining packets */
385 skb_queue_splice_tail_init(
386 &sta
->ampdu_mlme
.tid_tx
[tid
]->pending
,
387 &local
->pending
[queue
]);
388 spin_unlock_irqrestore(&local
->queue_stop_reason_lock
, flags
);
392 static void ieee80211_agg_splice_finish(struct ieee80211_local
*local
,
393 struct sta_info
*sta
, u16 tid
)
395 u16 queue
= ieee80211_ac_from_tid(tid
);
397 ieee80211_wake_queue_by_reason(
399 IEEE80211_QUEUE_STOP_REASON_AGGREGATION
);
402 /* caller must hold sta->lock */
403 static void ieee80211_agg_tx_operational(struct ieee80211_local
*local
,
404 struct sta_info
*sta
, u16 tid
)
406 #ifdef CONFIG_MAC80211_HT_DEBUG
407 printk(KERN_DEBUG
"Aggregation is on for tid %d \n", tid
);
410 spin_lock(&local
->ampdu_lock
);
411 ieee80211_agg_splice_packets(local
, sta
, tid
);
413 * NB: we rely on sta->lock being taken in the TX
414 * processing here when adding to the pending queue,
415 * otherwise we could only change the state of the
416 * session to OPERATIONAL _here_.
418 ieee80211_agg_splice_finish(local
, sta
, tid
);
419 spin_unlock(&local
->ampdu_lock
);
421 local
->ops
->ampdu_action(&local
->hw
, IEEE80211_AMPDU_TX_OPERATIONAL
,
422 &sta
->sta
, tid
, NULL
);
425 void ieee80211_start_tx_ba_cb(struct ieee80211_hw
*hw
, u8
*ra
, u16 tid
)
427 struct ieee80211_local
*local
= hw_to_local(hw
);
428 struct sta_info
*sta
;
431 if (tid
>= STA_TID_NUM
) {
432 #ifdef CONFIG_MAC80211_HT_DEBUG
433 printk(KERN_DEBUG
"Bad TID value: tid = %d (>= %d)\n",
440 sta
= sta_info_get(local
, ra
);
443 #ifdef CONFIG_MAC80211_HT_DEBUG
444 printk(KERN_DEBUG
"Could not find station: %pM\n", ra
);
449 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
450 spin_lock_bh(&sta
->lock
);
452 if (WARN_ON(!(*state
& HT_ADDBA_REQUESTED_MSK
))) {
453 #ifdef CONFIG_MAC80211_HT_DEBUG
454 printk(KERN_DEBUG
"addBA was not requested yet, state is %d\n",
457 spin_unlock_bh(&sta
->lock
);
462 if (WARN_ON(*state
& HT_ADDBA_DRV_READY_MSK
))
465 *state
|= HT_ADDBA_DRV_READY_MSK
;
467 if (*state
== HT_AGG_STATE_OPERATIONAL
)
468 ieee80211_agg_tx_operational(local
, sta
, tid
);
471 spin_unlock_bh(&sta
->lock
);
474 EXPORT_SYMBOL(ieee80211_start_tx_ba_cb
);
476 void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw
*hw
,
477 const u8
*ra
, u16 tid
)
479 struct ieee80211_local
*local
= hw_to_local(hw
);
480 struct ieee80211_ra_tid
*ra_tid
;
481 struct sk_buff
*skb
= dev_alloc_skb(0);
483 if (unlikely(!skb
)) {
484 #ifdef CONFIG_MAC80211_HT_DEBUG
486 printk(KERN_WARNING
"%s: Not enough memory, "
487 "dropping start BA session", skb
->dev
->name
);
491 ra_tid
= (struct ieee80211_ra_tid
*) &skb
->cb
;
492 memcpy(&ra_tid
->ra
, ra
, ETH_ALEN
);
495 skb
->pkt_type
= IEEE80211_ADDBA_MSG
;
496 skb_queue_tail(&local
->skb_queue
, skb
);
497 tasklet_schedule(&local
->tasklet
);
499 EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe
);
501 int __ieee80211_stop_tx_ba_session(struct sta_info
*sta
, u16 tid
,
502 enum ieee80211_back_parties initiator
)
507 /* check if the TID is in aggregation */
508 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
509 spin_lock_bh(&sta
->lock
);
511 if (*state
!= HT_AGG_STATE_OPERATIONAL
) {
516 #ifdef CONFIG_MAC80211_HT_DEBUG
517 printk(KERN_DEBUG
"Tx BA session stop requested for %pM tid %u\n",
519 #endif /* CONFIG_MAC80211_HT_DEBUG */
521 ret
= ___ieee80211_stop_tx_ba_session(sta
, tid
, initiator
);
524 spin_unlock_bh(&sta
->lock
);
528 int ieee80211_stop_tx_ba_session(struct ieee80211_hw
*hw
,
530 enum ieee80211_back_parties initiator
)
532 struct ieee80211_local
*local
= hw_to_local(hw
);
533 struct sta_info
*sta
;
536 if (WARN_ON(!local
->ops
->ampdu_action
))
539 if (tid
>= STA_TID_NUM
)
543 sta
= sta_info_get(local
, ra
);
549 ret
= __ieee80211_stop_tx_ba_session(sta
, tid
, initiator
);
553 EXPORT_SYMBOL(ieee80211_stop_tx_ba_session
);
555 void ieee80211_stop_tx_ba_cb(struct ieee80211_hw
*hw
, u8
*ra
, u8 tid
)
557 struct ieee80211_local
*local
= hw_to_local(hw
);
558 struct sta_info
*sta
;
561 if (tid
>= STA_TID_NUM
) {
562 #ifdef CONFIG_MAC80211_HT_DEBUG
563 printk(KERN_DEBUG
"Bad TID value: tid = %d (>= %d)\n",
569 #ifdef CONFIG_MAC80211_HT_DEBUG
570 printk(KERN_DEBUG
"Stopping Tx BA session for %pM tid %d\n",
572 #endif /* CONFIG_MAC80211_HT_DEBUG */
575 sta
= sta_info_get(local
, ra
);
577 #ifdef CONFIG_MAC80211_HT_DEBUG
578 printk(KERN_DEBUG
"Could not find station: %pM\n", ra
);
583 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
585 /* NOTE: no need to use sta->lock in this state check, as
586 * ieee80211_stop_tx_ba_session will let only one stop call to
587 * pass through per sta/tid
589 if ((*state
& HT_AGG_STATE_REQ_STOP_BA_MSK
) == 0) {
590 #ifdef CONFIG_MAC80211_HT_DEBUG
591 printk(KERN_DEBUG
"unexpected callback to A-MPDU stop\n");
597 if (*state
& HT_AGG_STATE_INITIATOR_MSK
)
598 ieee80211_send_delba(sta
->sdata
, ra
, tid
,
599 WLAN_BACK_INITIATOR
, WLAN_REASON_QSTA_NOT_USE
);
601 spin_lock_bh(&sta
->lock
);
602 spin_lock(&local
->ampdu_lock
);
604 ieee80211_agg_splice_packets(local
, sta
, tid
);
606 *state
= HT_AGG_STATE_IDLE
;
607 /* from now on packets are no longer put onto sta->pending */
608 sta
->ampdu_mlme
.addba_req_num
[tid
] = 0;
609 kfree(sta
->ampdu_mlme
.tid_tx
[tid
]);
610 sta
->ampdu_mlme
.tid_tx
[tid
] = NULL
;
612 ieee80211_agg_splice_finish(local
, sta
, tid
);
614 spin_unlock(&local
->ampdu_lock
);
615 spin_unlock_bh(&sta
->lock
);
619 EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb
);
621 void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw
*hw
,
622 const u8
*ra
, u16 tid
)
624 struct ieee80211_local
*local
= hw_to_local(hw
);
625 struct ieee80211_ra_tid
*ra_tid
;
626 struct sk_buff
*skb
= dev_alloc_skb(0);
628 if (unlikely(!skb
)) {
629 #ifdef CONFIG_MAC80211_HT_DEBUG
631 printk(KERN_WARNING
"%s: Not enough memory, "
632 "dropping stop BA session", skb
->dev
->name
);
636 ra_tid
= (struct ieee80211_ra_tid
*) &skb
->cb
;
637 memcpy(&ra_tid
->ra
, ra
, ETH_ALEN
);
640 skb
->pkt_type
= IEEE80211_DELBA_MSG
;
641 skb_queue_tail(&local
->skb_queue
, skb
);
642 tasklet_schedule(&local
->tasklet
);
644 EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe
);
647 void ieee80211_process_addba_resp(struct ieee80211_local
*local
,
648 struct sta_info
*sta
,
649 struct ieee80211_mgmt
*mgmt
,
655 capab
= le16_to_cpu(mgmt
->u
.action
.u
.addba_resp
.capab
);
656 tid
= (capab
& IEEE80211_ADDBA_PARAM_TID_MASK
) >> 2;
658 state
= &sta
->ampdu_mlme
.tid_state_tx
[tid
];
660 spin_lock_bh(&sta
->lock
);
662 if (!(*state
& HT_ADDBA_REQUESTED_MSK
)) {
663 spin_unlock_bh(&sta
->lock
);
667 if (mgmt
->u
.action
.u
.addba_resp
.dialog_token
!=
668 sta
->ampdu_mlme
.tid_tx
[tid
]->dialog_token
) {
669 spin_unlock_bh(&sta
->lock
);
670 #ifdef CONFIG_MAC80211_HT_DEBUG
671 printk(KERN_DEBUG
"wrong addBA response token, tid %d\n", tid
);
672 #endif /* CONFIG_MAC80211_HT_DEBUG */
676 del_timer_sync(&sta
->ampdu_mlme
.tid_tx
[tid
]->addba_resp_timer
);
677 #ifdef CONFIG_MAC80211_HT_DEBUG
678 printk(KERN_DEBUG
"switched off addBA timer for tid %d \n", tid
);
679 #endif /* CONFIG_MAC80211_HT_DEBUG */
680 if (le16_to_cpu(mgmt
->u
.action
.u
.addba_resp
.status
)
681 == WLAN_STATUS_SUCCESS
) {
682 u8 curstate
= *state
;
684 *state
|= HT_ADDBA_RECEIVED_MSK
;
686 if (*state
!= curstate
&& *state
== HT_AGG_STATE_OPERATIONAL
)
687 ieee80211_agg_tx_operational(local
, sta
, tid
);
689 sta
->ampdu_mlme
.addba_req_num
[tid
] = 0;
691 sta
->ampdu_mlme
.addba_req_num
[tid
]++;
692 ___ieee80211_stop_tx_ba_session(sta
, tid
, WLAN_BACK_INITIATOR
);
694 spin_unlock_bh(&sta
->lock
);