mac80211: Speedup ieee80211_remove_interfaces()
[safe/jmp/linux-2.6] / net / mac80211 / agg-rx.c
index 62b9feb..7ed5fe6 100644 (file)
 #include <linux/ieee80211.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
+#include "driver-ops.h"
 
-void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid,
-                                       u16 initiator, u16 reason)
+void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
+                                   u16 initiator, u16 reason)
 {
-       struct ieee80211_local *local = sdata->local;
-       struct ieee80211_hw *hw = &local->hw;
-       struct sta_info *sta;
-       int ret, i;
-
-       rcu_read_lock();
-
-       sta = sta_info_get(local, ra);
-       if (!sta) {
-               rcu_read_unlock();
-               return;
-       }
+       struct ieee80211_local *local = sta->local;
+       int i;
 
        /* check if TID is in operational state */
        spin_lock_bh(&sta->lock);
-       if (sta->ampdu_mlme.tid_state_rx[tid]
-                               != HT_AGG_STATE_OPERATIONAL) {
+       if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_OPERATIONAL) {
                spin_unlock_bh(&sta->lock);
-               rcu_read_unlock();
                return;
        }
+
        sta->ampdu_mlme.tid_state_rx[tid] =
                HT_AGG_STATE_REQ_STOP_BA_MSK |
                (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
        spin_unlock_bh(&sta->lock);
 
-       /* stop HW Rx aggregation. ampdu_action existence
-        * already verified in session init so we add the BUG_ON */
-       BUG_ON(!local->ops->ampdu_action);
-
 #ifdef CONFIG_MAC80211_HT_DEBUG
        printk(KERN_DEBUG "Rx BA session stop requested for %pM tid %u\n",
-              ra, tid);
+              sta->sta.addr, tid);
 #endif /* CONFIG_MAC80211_HT_DEBUG */
 
-       ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_STOP,
-                                      &sta->sta, tid, NULL);
-       if (ret)
+       if (drv_ampdu_action(local, &sta->sdata->vif,
+                            IEEE80211_AMPDU_RX_STOP,
+                            &sta->sta, tid, NULL))
                printk(KERN_DEBUG "HW problem - can not stop rx "
                                "aggregation for tid %d\n", tid);
 
@@ -67,7 +53,8 @@ void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *r
 
        /* check if this is a self generated aggregation halt */
        if (initiator == WLAN_BACK_RECIPIENT || initiator == WLAN_BACK_TIMER)
-               ieee80211_send_delba(sdata, ra, tid, 0, reason);
+               ieee80211_send_delba(sta->sdata, sta->sta.addr,
+                                    tid, 0, reason);
 
        /* free the reordering buffer */
        for (i = 0; i < sta->ampdu_mlme.tid_rx[tid]->buf_size; i++) {
@@ -78,11 +65,40 @@ void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *r
                        sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i] = NULL;
                }
        }
+
+       spin_lock_bh(&sta->lock);
        /* free resources */
        kfree(sta->ampdu_mlme.tid_rx[tid]->reorder_buf);
-       kfree(sta->ampdu_mlme.tid_rx[tid]);
-       sta->ampdu_mlme.tid_rx[tid] = NULL;
+       kfree(sta->ampdu_mlme.tid_rx[tid]->reorder_time);
+
+       if (!sta->ampdu_mlme.tid_rx[tid]->shutdown) {
+               kfree(sta->ampdu_mlme.tid_rx[tid]);
+               sta->ampdu_mlme.tid_rx[tid] = NULL;
+       }
+
        sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_IDLE;
+       spin_unlock_bh(&sta->lock);
+}
+
+void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid,
+                                       u16 initiator, u16 reason)
+{
+       struct ieee80211_local *local = sdata->local;
+       struct sta_info *sta;
+
+       /* stop HW Rx aggregation. ampdu_action existence
+        * already verified in session init so we add the BUG_ON */
+       BUG_ON(!local->ops->ampdu_action);
+
+       rcu_read_lock();
+
+       sta = sta_info_get(local, ra);
+       if (!sta) {
+               rcu_read_unlock();
+               return;
+       }
+
+       __ieee80211_stop_rx_ba_session(sta, tid, initiator, reason);
 
        rcu_read_unlock();
 }
@@ -115,7 +131,6 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
                                      u8 dialog_token, u16 status, u16 policy,
                                      u16 buf_size, u16 timeout)
 {
-       struct ieee80211_if_sta *ifsta = &sdata->u.sta;
        struct ieee80211_local *local = sdata->local;
        struct sk_buff *skb;
        struct ieee80211_mgmt *mgmt;
@@ -134,10 +149,12 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
        memset(mgmt, 0, 24);
        memcpy(mgmt->da, da, ETH_ALEN);
        memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
-       if (sdata->vif.type == NL80211_IFTYPE_AP)
+       if (sdata->vif.type == NL80211_IFTYPE_AP ||
+           sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
                memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN);
-       else
-               memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
+       else if (sdata->vif.type == NL80211_IFTYPE_STATION)
+               memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+
        mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
                                          IEEE80211_STYPE_ACTION);
 
@@ -154,7 +171,7 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
        mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout);
        mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
 
-       ieee80211_tx_skb(sdata, skb, 1);
+       ieee80211_tx_skb(sdata, skb);
 }
 
 void ieee80211_process_addba_request(struct ieee80211_local *local,
@@ -182,6 +199,14 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
 
        status = WLAN_STATUS_REQUEST_DECLINED;
 
+       if (test_sta_flags(sta, WLAN_STA_SUSPEND)) {
+#ifdef CONFIG_MAC80211_HT_DEBUG
+               printk(KERN_DEBUG "Suspend in progress. "
+                      "Denying ADDBA request\n");
+#endif
+               goto end_no_lock;
+       }
+
        /* sanity check for incoming parameters:
         * check if configuration can support the BA policy
         * and if buffer size does not exceeds max value */
@@ -245,19 +270,24 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
        /* prepare reordering buffer */
        tid_agg_rx->reorder_buf =
                kcalloc(buf_size, sizeof(struct sk_buff *), GFP_ATOMIC);
-       if (!tid_agg_rx->reorder_buf) {
+       tid_agg_rx->reorder_time =
+               kcalloc(buf_size, sizeof(unsigned long), GFP_ATOMIC);
+       if (!tid_agg_rx->reorder_buf || !tid_agg_rx->reorder_time) {
 #ifdef CONFIG_MAC80211_HT_DEBUG
                if (net_ratelimit())
                        printk(KERN_ERR "can not allocate reordering buffer "
                               "to tid %d\n", tid);
 #endif
+               kfree(tid_agg_rx->reorder_buf);
+               kfree(tid_agg_rx->reorder_time);
                kfree(sta->ampdu_mlme.tid_rx[tid]);
+               sta->ampdu_mlme.tid_rx[tid] = NULL;
                goto end;
        }
 
-       if (local->ops->ampdu_action)
-               ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START,
-                                              &sta->sta, tid, &start_seq_num);
+       ret = drv_ampdu_action(local, &sta->sdata->vif,
+                              IEEE80211_AMPDU_RX_START,
+                              &sta->sta, tid, &start_seq_num);
 #ifdef CONFIG_MAC80211_HT_DEBUG
        printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret);
 #endif /* CONFIG_MAC80211_HT_DEBUG */