staging: wfx: drop unnecessary filter configuration when disabling filter
[linux-2.6-microblaze.git] / drivers / staging / wfx / sta.c
index 3ad0b67..57304ed 100644 (file)
@@ -84,7 +84,6 @@ static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon)
        };
 
        if (!filter_beacon) {
-               hif_set_beacon_filter_table(wvif, 0, NULL);
                hif_beacon_filter_control(wvif, 0, 1);
        } else {
                hif_set_beacon_filter_table(wvif, 3, filter_ies);
@@ -139,10 +138,8 @@ u64 wfx_prepare_multicast(struct ieee80211_hw *hw,
        return 0;
 }
 
-void wfx_configure_filter(struct ieee80211_hw *hw,
-                            unsigned int changed_flags,
-                            unsigned int *total_flags,
-                            u64 unused)
+void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
+                         unsigned int *total_flags, u64 unused)
 {
        struct wfx_vif *wvif = NULL;
        struct wfx_dev *wdev = hw->priv;
@@ -253,7 +250,7 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                   u16 queue, const struct ieee80211_tx_queue_params *params)
 {
        struct wfx_dev *wdev = hw->priv;
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
        int old_uapsd = wvif->uapsd_mask;
 
        WARN_ON(queue >= hw->queues);
@@ -317,20 +314,6 @@ void wfx_set_default_unicast_key(struct ieee80211_hw *hw,
        hif_wep_default_key_id(wvif, idx);
 }
 
-// Call it with wdev->conf_mutex locked
-static void wfx_do_unjoin(struct wfx_vif *wvif)
-{
-       /* Unjoin is a reset. */
-       wfx_tx_lock_flush(wvif->wdev);
-       hif_reset(wvif, false);
-       wfx_tx_policy_init(wvif);
-       if (wvif_count(wvif->wdev) <= 1)
-               hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
-       wfx_tx_unlock(wvif->wdev);
-       wvif->bss_not_support_ps_poll = false;
-       cancel_delayed_work_sync(&wvif->beacon_loss_work);
-}
-
 static void wfx_set_mfp(struct wfx_vif *wvif,
                        struct cfg80211_bss *bss)
 {
@@ -347,8 +330,7 @@ static void wfx_set_mfp(struct wfx_vif *wvif,
 
        rcu_read_lock();
        if (bss)
-               ptr = (const u16 *) ieee80211_bss_get_ie(bss,
-                                                             WLAN_EID_RSN);
+               ptr = (const u16 *)ieee80211_bss_get_ie(bss, WLAN_EID_RSN);
 
        if (ptr) {
                ptr += pairwise_cipher_suite_count_offset;
@@ -362,6 +344,24 @@ static void wfx_set_mfp(struct wfx_vif *wvif,
        hif_set_mfp(wvif, mfpc, mfpr);
 }
 
+void wfx_reset(struct wfx_vif *wvif)
+{
+       struct wfx_dev *wdev = wvif->wdev;
+
+       wfx_tx_lock_flush(wdev);
+       hif_reset(wvif, false);
+       wfx_tx_policy_init(wvif);
+       if (wvif_count(wdev) <= 1)
+               hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
+       wfx_tx_unlock(wdev);
+       wvif->join_in_progress = false;
+       wvif->bss_not_support_ps_poll = false;
+       cancel_delayed_work_sync(&wvif->beacon_loss_work);
+       wvif =  NULL;
+       while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
+               wfx_update_pm(wvif);
+}
+
 static void wfx_do_join(struct wfx_vif *wvif)
 {
        int ret;
@@ -395,10 +395,11 @@ static void wfx_do_join(struct wfx_vif *wvif)
        wfx_set_mfp(wvif, bss);
        cfg80211_put_bss(wvif->wdev->hw->wiphy, bss);
 
+       wvif->join_in_progress = true;
        ret = hif_join(wvif, conf, wvif->channel, ssid, ssidlen);
        if (ret) {
                ieee80211_connection_loss(wvif->vif);
-               wfx_do_unjoin(wvif);
+               wfx_reset(wvif);
        } else {
                /* Due to beacon filtering it is possible that the
                 * AP's beacon is not known for the mac80211 stack.
@@ -413,8 +414,8 @@ static void wfx_do_join(struct wfx_vif *wvif)
 int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                struct ieee80211_sta *sta)
 {
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
-       struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+       struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *)&sta->drv_priv;
 
        spin_lock_init(&sta_priv->lock);
        sta_priv->vif_id = wvif->id;
@@ -434,8 +435,8 @@ int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 int wfx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                   struct ieee80211_sta *sta)
 {
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
-       struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+       struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *)&sta->drv_priv;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(sta_priv->buffered); i++)
@@ -474,7 +475,12 @@ static int wfx_upload_ap_templates(struct wfx_vif *wvif)
 int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+       struct wfx_dev *wdev = wvif->wdev;
 
+       wvif =  NULL;
+       while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
+               wfx_update_pm(wvif);
+       wvif = (struct wfx_vif *)vif->drv_priv;
        wfx_upload_ap_templates(wvif);
        hif_start(wvif, &vif->bss_conf, wvif->channel);
        return 0;
@@ -484,16 +490,13 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
-       hif_reset(wvif, false);
-       wfx_tx_policy_init(wvif);
-       if (wvif_count(wvif->wdev) <= 1)
-               hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
-       wvif->bss_not_support_ps_poll = false;
+       wfx_reset(wvif);
 }
 
 static void wfx_join_finalize(struct wfx_vif *wvif,
                              struct ieee80211_bss_conf *info)
 {
+       wvif->join_in_progress = false;
        hif_set_association_mode(wvif, info);
        hif_keep_alive_period(wvif, 0);
        // beacon_loss_count is defined to 7 in net/mac80211/mlme.c. Let's use
@@ -516,7 +519,7 @@ void wfx_leave_ibss(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
-       wfx_do_unjoin(wvif);
+       wfx_reset(wvif);
 }
 
 static void wfx_enable_beacon(struct wfx_vif *wvif, bool enable)
@@ -532,13 +535,11 @@ static void wfx_enable_beacon(struct wfx_vif *wvif, bool enable)
        hif_beacon_transmit(wvif, enable);
 }
 
-void wfx_bss_info_changed(struct ieee80211_hw *hw,
-                            struct ieee80211_vif *vif,
-                            struct ieee80211_bss_conf *info,
-                            u32 changed)
+void wfx_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                         struct ieee80211_bss_conf *info, u32 changed)
 {
        struct wfx_dev *wdev = hw->priv;
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
        int i;
 
        mutex_lock(&wdev->conf_mutex);
@@ -585,7 +586,7 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
                if (info->assoc || info->ibss_joined)
                        wfx_join_finalize(wvif, info);
                else if (!info->assoc && vif->type == NL80211_IFTYPE_STATION)
-                       wfx_do_unjoin(wvif);
+                       wfx_reset(wvif);
                else
                        dev_warn(wdev->dev, "%s: misunderstood change: ASSOC\n",
                                 __func__);
@@ -707,7 +708,7 @@ void wfx_change_chanctx(struct ieee80211_hw *hw,
 int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                           struct ieee80211_chanctx_conf *conf)
 {
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
        struct ieee80211_channel *ch = conf->def.chan;
 
        WARN(wvif->channel, "channel overwrite");
@@ -720,7 +721,7 @@ void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw,
                              struct ieee80211_vif *vif,
                              struct ieee80211_chanctx_conf *conf)
 {
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
        struct ieee80211_channel *ch = conf->def.chan;
 
        WARN(wvif->channel != ch, "channel mismatch");
@@ -736,7 +737,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        int i, ret = 0;
        struct wfx_dev *wdev = hw->priv;
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
        vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
                             IEEE80211_VIF_SUPPORTS_UAPSD |
@@ -794,17 +795,14 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
                        hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
                else
                        hif_set_block_ack_policy(wvif, 0x00, 0x00);
-               // Combo force powersave mode. We can re-enable it now
-               ret = wfx_update_pm(wvif);
        }
        return ret;
 }
 
-void wfx_remove_interface(struct ieee80211_hw *hw,
-                         struct ieee80211_vif *vif)
+void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct wfx_dev *wdev = hw->priv;
-       struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
 
        wait_for_completion_timeout(&wvif->set_pm_mode_complete, msecs_to_jiffies(300));
 
@@ -827,8 +825,6 @@ void wfx_remove_interface(struct ieee80211_hw *hw,
                        hif_set_block_ack_policy(wvif, 0xFF, 0xFF);
                else
                        hif_set_block_ack_policy(wvif, 0x00, 0x00);
-               // Combo force powersave mode. We can re-enable it now
-               wfx_update_pm(wvif);
        }
 }