17 #include <linux/slab.h>
18 #include <linux/export.h>
72 skb = dev_alloc_skb(
sizeof(*mgmt) + local->
hw.extra_tx_headroom);
77 skb_reserve(skb, local->
hw.extra_tx_headroom);
94 skb_put(skb, 1 +
sizeof(mgmt->
u.action.u.addba_req));
100 capab = (
u16)(1 << 1);
101 capab |= (
u16)(tid << 2);
102 capab |= (
u16)(agg_size << 6);
106 mgmt->
u.action.u.addba_req.timeout =
cpu_to_le16(timeout);
107 mgmt->
u.action.u.addba_req.start_seq_num =
121 skb = dev_alloc_skb(
sizeof(*bar) + local->
hw.extra_tx_headroom);
125 skb_reserve(skb, local->
hw.extra_tx_headroom);
127 memset(bar, 0,
sizeof(*bar));
162 spin_lock_bh(&sta->
lock);
164 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
166 spin_unlock_bh(&sta->
lock);
172 spin_unlock_bh(&sta->
lock);
179 spin_unlock_bh(&sta->
lock);
186 spin_unlock_bh(&sta->
lock);
188 ht_dbg(sta->
sdata,
"Tx BA session stop requested for %pM tid %u\n",
218 ret = drv_ampdu_action(local, sta->
sdata,
238 static void sta_addba_resp_timer_expired(
unsigned long data)
244 u16 tid = *(
u8 *)data;
256 "timer expired on tid %d but we are not (or no longer) expecting addBA response there\n",
261 ht_dbg(sta->
sdata,
"addBA response timer expired on tid %d\n", tid);
267 static inline int ieee80211_ac_from_tid(
int tid)
286 int queue = sdata->vif.hw_queue[ieee80211_ac_from_tid(tid)];
290 &sdata->local->hw, queue,
298 int queue = sdata->vif.hw_queue[ieee80211_ac_from_tid(tid)];
302 &sdata->local->hw, queue,
316 int queue = sdata->vif.hw_queue[ieee80211_ac_from_tid(tid)];
319 ieee80211_stop_queue_agg(sdata, tid);
322 "TID %d gone but expected when splicing aggregates from the pending queue\n",
326 if (!skb_queue_empty(&tid_tx->pending)) {
329 skb_queue_splice_tail_init(&tid_tx->pending,
338 ieee80211_wake_queue_agg(sdata, tid);
349 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
366 start_seq_num = sta->
tid_seq[tid] >> 4;
369 &sta->
sta, tid, &start_seq_num, 0);
372 "BA request denied - HW unavailable for tid %d\n", tid);
373 spin_lock_bh(&sta->
lock);
374 ieee80211_agg_splice_packets(sdata, tid_tx, tid);
376 ieee80211_agg_splice_finish(sdata, tid);
377 spin_unlock_bh(&sta->
lock);
385 ht_dbg(sdata,
"activated addBA response timer on tid %d\n", tid);
387 spin_lock_bh(&sta->
lock);
390 spin_unlock_bh(&sta->
lock);
393 ieee80211_send_addba_request(sdata, sta->
sta.addr, tid,
395 local->
hw.max_tx_aggregation_subframes,
403 static void sta_tx_agg_session_timer_expired(
unsigned long data)
409 u8 *ptid = (
u8 *)data;
410 u8 *timer_to_id = ptid - *ptid;
432 ht_dbg(sta->
sdata,
"tx session timer expired on tid %d\n", (
u16)*ptid);
446 trace_api_start_tx_ba_session(pubsta, tid);
456 ht_dbg(sdata,
"Open BA session requested for %pM tid %u\n",
468 "BA sessions blocked - Denying BA session request\n");
485 !sta->
sta.ht_cap.ht_supported) {
487 "BA request denied - IBSS STA %pM does not advertise HT support\n",
492 spin_lock_bh(&sta->
lock);
509 "BA request denied - waiting a grace period after %d failed requests on tid %u\n",
515 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
517 if (tid_tx || sta->
ampdu_mlme.tid_start_tx[tid]) {
519 "BA request denied - session is not idle on tid %u\n",
532 skb_queue_head_init(&tid_tx->
pending);
543 tid_tx->
session_timer.function = sta_tx_agg_session_timer_expired;
561 spin_unlock_bh(&sta->
lock);
566 static void ieee80211_agg_tx_operational(
struct ieee80211_local *local,
573 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
575 ht_dbg(sta->
sdata,
"Aggregation is on for tid %d\n", tid);
577 drv_ampdu_action(local, sta->
sdata,
585 spin_lock_bh(&sta->
lock);
587 ieee80211_agg_splice_packets(sta->
sdata, tid_tx, tid);
594 ieee80211_agg_splice_finish(sta->
sdata, tid);
596 spin_unlock_bh(&sta->
lock);
606 trace_api_start_tx_ba_cb(sdata, ra, tid);
609 ht_dbg(sdata,
"Bad TID value: tid = %d (>= %d)\n",
618 ht_dbg(sdata,
"Could not find station: %pM\n", ra);
623 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
626 ht_dbg(sdata,
"addBA was not requested!\n");
634 ieee80211_agg_tx_operational(local, sta, tid);
647 struct sk_buff *skb = dev_alloc_skb(0);
685 trace_api_stop_tx_ba_session(pubsta, tid);
687 if (!local->
ops->ampdu_action)
693 spin_lock_bh(&sta->
lock);
694 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
711 spin_unlock_bh(&sta->
lock);
723 trace_api_stop_tx_ba_cb(sdata, ra, tid);
726 ht_dbg(sdata,
"Bad TID value: tid = %d (>= %d)\n",
731 ht_dbg(sdata,
"Stopping Tx BA session for %pM tid %d\n", ra, tid);
737 ht_dbg(sdata,
"Could not find station: %pM\n", ra);
742 spin_lock_bh(&sta->
lock);
743 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
746 ht_dbg(sdata,
"unexpected callback to A-MPDU stop\n");
764 ieee80211_agg_splice_packets(sta->
sdata, tid_tx, tid);
769 ieee80211_agg_splice_finish(sta->
sdata, tid);
774 spin_unlock_bh(&sta->
lock);
786 struct sk_buff *skb = dev_alloc_skb(0);
817 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
821 if (mgmt->
u.action.u.addba_resp.dialog_token != tid_tx->
dialog_token) {
822 ht_dbg(sta->
sdata,
"wrong addBA response token, tid %d\n", tid);
828 ht_dbg(sta->
sdata,
"switched off addBA timer for tid %d\n", tid);
838 "got addBA resp for tid %d but we already gave up\n",
860 ieee80211_agg_tx_operational(local, sta, tid);