Merge branch 'master' of git://git.infradead.org/users/linville/wireless-next into...
[pandora-kernel.git] / net / mac80211 / mlme.c
index 2f92ae2..0e5d8da 100644 (file)
@@ -160,7 +160,8 @@ static int ecw2cw(int ecw)
  */
 static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
                               struct ieee80211_ht_info *hti,
-                              const u8 *bssid, u16 ap_ht_cap_flags)
+                              const u8 *bssid, u16 ap_ht_cap_flags,
+                              bool beacon_htcap_ie)
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_supported_band *sband;
@@ -232,6 +233,21 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
                WARN_ON(!ieee80211_set_channel_type(local, sdata, channel_type));
        }
 
+       if (beacon_htcap_ie && (prev_chantype != channel_type)) {
+               /*
+                * Whenever the AP announces the HT mode change that can be
+                * 40MHz intolerant or etc., it would be safer to stop tx
+                * queues before doing hw config to avoid buffer overflow.
+                */
+               ieee80211_stop_queues_by_reason(&sdata->local->hw,
+                               IEEE80211_QUEUE_STOP_REASON_CHTYPE_CHANGE);
+
+               /* flush out all packets */
+               synchronize_net();
+
+               drv_flush(local, false);
+       }
+
        /* channel_type change automatically detected */
        ieee80211_hw_config(local, 0);
 
@@ -243,6 +259,10 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
                                                 IEEE80211_RC_HT_CHANGED,
                                                 channel_type);
                rcu_read_unlock();
+
+               if (beacon_htcap_ie)
+                       ieee80211_wake_queues_by_reason(&sdata->local->hw,
+                               IEEE80211_QUEUE_STOP_REASON_CHTYPE_CHANGE);
        }
 
        ht_opmode = le16_to_cpu(hti->operation_mode);
@@ -328,6 +348,7 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
 {
        struct sk_buff *skb;
        struct ieee80211_hdr_3addr *nullfunc;
+       struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 
        skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif);
        if (!skb)
@@ -338,6 +359,10 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
                nullfunc->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
 
        IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
+       if (ifmgd->flags & (IEEE80211_STA_BEACON_POLL |
+                           IEEE80211_STA_CONNECTION_POLL))
+               IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE;
+
        ieee80211_tx_skb(sdata, skb);
 }
 
@@ -607,7 +632,7 @@ static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_managed *mgd = &sdata->u.mgd;
        struct sta_info *sta = NULL;
-       u32 sta_flags = 0;
+       bool authorized = false;
 
        if (!mgd->powersave)
                return false;
@@ -625,13 +650,10 @@ static bool ieee80211_powersave_allowed(struct ieee80211_sub_if_data *sdata)
        rcu_read_lock();
        sta = sta_info_get(sdata, mgd->bssid);
        if (sta)
-               sta_flags = get_sta_flags(sta);
+               authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
        rcu_read_unlock();
 
-       if (!(sta_flags & WLAN_STA_AUTHORIZED))
-               return false;
-
-       return true;
+       return authorized;
 }
 
 /* need to hold RTNL or interface lock */
@@ -916,8 +938,8 @@ static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
                            params.aifs, params.cw_min, params.cw_max,
                            params.txop, params.uapsd);
 #endif
-               local->tx_conf[queue] = params;
-               if (drv_conf_tx(local, queue, &params))
+               sdata->tx_conf[queue] = params;
+               if (drv_conf_tx(local, sdata, queue, &params))
                        wiphy_debug(local->hw.wiphy,
                                    "failed to set TX queue parameters for queue %d\n",
                                    queue);
@@ -1075,7 +1097,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        mutex_lock(&local->sta_mtx);
        sta = sta_info_get(sdata, bssid);
        if (sta) {
-               set_sta_flags(sta, WLAN_STA_BLOCK_BA);
+               set_sta_flag(sta, WLAN_STA_BLOCK_BA);
                ieee80211_sta_tear_down_BA_sessions(sta, tx);
        }
        mutex_unlock(&local->sta_mtx);
@@ -1117,8 +1139,9 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
        changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT;
        ieee80211_bss_info_change_notify(sdata, changed);
 
+       /* remove AP and TDLS peers */
        if (remove_sta)
-               sta_info_destroy_addr(sdata, bssid);
+               sta_info_flush(local, sdata);
 
        del_timer_sync(&sdata->u.mgd.conn_mon_timer);
        del_timer_sync(&sdata->u.mgd.bcn_mon_timer);
@@ -1219,7 +1242,7 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata)
        } else {
                ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID);
                ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0,
-                                        (u32) -1, true);
+                                        (u32) -1, true, false);
        }
 
        ifmgd->probe_send_count++;
@@ -1492,10 +1515,11 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
                return false;
        }
 
-       set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC |
-                          WLAN_STA_ASSOC_AP);
+       set_sta_flag(sta, WLAN_STA_AUTH);
+       set_sta_flag(sta, WLAN_STA_ASSOC);
+       set_sta_flag(sta, WLAN_STA_ASSOC_AP);
        if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT))
-               set_sta_flags(sta, WLAN_STA_AUTHORIZED);
+               set_sta_flag(sta, WLAN_STA_AUTHORIZED);
 
        rates = 0;
        basic_rates = 0;
@@ -1554,10 +1578,10 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
        rate_control_rate_init(sta);
 
        if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED)
-               set_sta_flags(sta, WLAN_STA_MFP);
+               set_sta_flag(sta, WLAN_STA_MFP);
 
        if (elems.wmm_param)
-               set_sta_flags(sta, WLAN_STA_WME);
+               set_sta_flag(sta, WLAN_STA_WME);
 
        /* sta_info_reinsert will also unlock the mutex lock */
        err = sta_info_reinsert(sta);
@@ -1588,7 +1612,8 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
            (sdata->local->hw.queues >= 4) &&
            !(ifmgd->flags & IEEE80211_STA_DISABLE_11N))
                changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
-                                              cbss->bssid, ap_ht_cap_flags);
+                                              cbss->bssid, ap_ht_cap_flags,
+                                              false);
 
        /* set AID and assoc capability,
         * ieee80211_set_associated() will tell the driver */
@@ -1921,24 +1946,8 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
 
                rcu_read_unlock();
 
-               /*
-                * Whenever the AP announces the HT mode change that can be
-                * 40MHz intolerant or etc., it would be safer to stop tx
-                * queues before doing hw config to avoid buffer overflow.
-                */
-               ieee80211_stop_queues_by_reason(&sdata->local->hw,
-                               IEEE80211_QUEUE_STOP_REASON_CHTYPE_CHANGE);
-
-               /* flush out all packets */
-               synchronize_net();
-
-               drv_flush(local, false);
-
                changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
-                                              bssid, ap_ht_cap_flags);
-
-               ieee80211_wake_queues_by_reason(&sdata->local->hw,
-                               IEEE80211_QUEUE_STOP_REASON_CHTYPE_CHANGE);
+                                              bssid, ap_ht_cap_flags, true);
        }
 
        /* Note: country IE parsing is done for us by cfg80211 */
@@ -2733,7 +2742,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
                                       req->reason_code, cookie,
                                       !req->local_state_change);
        if (assoc_bss)
-               sta_info_destroy_addr(sdata, bssid);
+               sta_info_flush(sdata->local, sdata);
 
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);
@@ -2773,7 +2782,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
        ieee80211_send_deauth_disassoc(sdata, req->bss->bssid,
                        IEEE80211_STYPE_DISASSOC, req->reason_code,
                        cookie, !req->local_state_change);
-       sta_info_destroy_addr(sdata, bssid);
+       sta_info_flush(sdata->local, sdata);
 
        mutex_lock(&sdata->local->mtx);
        ieee80211_recalc_idle(sdata->local);