iwlwifi: use iwl_find_station less
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-agn.c
index 270635e..8a4b830 100644 (file)
@@ -156,7 +156,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
                        IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
                        return ret;
                }
-               iwl_clear_ucode_stations(priv, false);
+               iwl_clear_ucode_stations(priv);
                iwl_restore_stations(priv);
                ret = iwl_restore_default_wep_keys(priv);
                if (ret) {
@@ -188,7 +188,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
                }
                IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n");
                memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
-               iwl_clear_ucode_stations(priv, false);
+               iwl_clear_ucode_stations(priv);
                iwl_restore_stations(priv);
                ret = iwl_restore_default_wep_keys(priv);
                if (ret) {
@@ -2403,7 +2403,8 @@ static void __iwl_down(struct iwl_priv *priv)
        if (!exit_pending)
                set_bit(STATUS_EXIT_PENDING, &priv->status);
 
-       iwl_clear_ucode_stations(priv, true);
+       iwl_clear_ucode_stations(priv);
+       iwl_dealloc_bcast_station(priv);
 
        /* Unblock any waiting calls */
        wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2550,6 +2551,10 @@ static int __iwl_up(struct iwl_priv *priv)
                return -EIO;
        }
 
+       ret = iwl_alloc_bcast_station(priv, true);
+       if (ret)
+               return ret;
+
        iwl_prepare_card_hw(priv);
 
        if (!priv->hw_ready) {
@@ -2849,6 +2854,8 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
                             IEEE80211_HW_SUPPORTS_STATIC_SMPS;
 
        hw->sta_data_size = sizeof(struct iwl_station_priv);
+       hw->vif_data_size = sizeof(struct iwl_vif_priv);
+
        hw->wiphy->interface_modes =
                BIT(NL80211_IFTYPE_STATION) |
                BIT(NL80211_IFTYPE_ADHOC);
@@ -3032,7 +3039,6 @@ void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
                /* restore RXON assoc */
                priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
                iwlcore_commit_rxon(priv);
-               iwl_add_bcast_station(priv);
        }
        iwl_send_beacon_cmd(priv);
 
@@ -3064,7 +3070,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                           struct ieee80211_key_conf *key)
 {
        struct iwl_priv *priv = hw->priv;
-       const u8 *addr;
        int ret;
        u8 sta_id;
        bool is_default_wep_key = false;
@@ -3075,13 +3080,17 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
                return -EOPNOTSUPP;
        }
-       addr = sta ? sta->addr : iwl_bcast_addr;
-       sta_id = iwl_find_station(priv, addr);
-       if (sta_id == IWL_INVALID_STATION) {
-               IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
-                                  addr);
-               return -EINVAL;
 
+       if (sta) {
+               sta_id = iwl_sta_id(sta);
+
+               if (sta_id == IWL_INVALID_STATION) {
+                       IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
+                                          sta->addr);
+                       return -EINVAL;
+               }
+       } else {
+               sta_id = priv->hw_params.bcast_sta_id;
        }
 
        mutex_lock(&priv->mutex);
@@ -3130,8 +3139,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
 static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
                                struct ieee80211_vif *vif,
-                            enum ieee80211_ampdu_mlme_action action,
-                            struct ieee80211_sta *sta, u16 tid, u16 *ssn)
+                               enum ieee80211_ampdu_mlme_action action,
+                               struct ieee80211_sta *sta, u16 tid, u16 *ssn)
 {
        struct iwl_priv *priv = hw->priv;
        int ret;
@@ -3155,7 +3164,7 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
                        return ret;
        case IEEE80211_AMPDU_TX_START:
                IWL_DEBUG_HT(priv, "start Tx\n");
-               ret = iwlagn_tx_agg_start(priv, sta->addr, tid, ssn);
+               ret = iwlagn_tx_agg_start(priv, vif, sta->addr, tid, ssn);
                if (ret == 0) {
                        priv->_agn.agg_tids_count++;
                        IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
@@ -3164,7 +3173,7 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
                return ret;
        case IEEE80211_AMPDU_TX_STOP:
                IWL_DEBUG_HT(priv, "stop Tx\n");
-               ret = iwlagn_tx_agg_stop(priv, sta->addr, tid);
+               ret = iwlagn_tx_agg_stop(priv, vif, sta->addr, tid);
                if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) {
                        priv->_agn.agg_tids_count--;
                        IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
@@ -3206,7 +3215,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
                if (!sta_priv->asleep)
                        break;
                sta_priv->asleep = false;
-               sta_id = iwl_find_station(priv, sta->addr);
+               sta_id = iwl_sta_id(sta);
                if (sta_id != IWL_INVALID_STATION)
                        iwl_sta_modify_ps_wake(priv, sta_id);
                break;
@@ -3225,6 +3234,8 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
        int ret;
        u8 sta_id;
 
+       sta_priv->common.sta_id = IWL_INVALID_STATION;
+
        IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
                        sta->addr);
 
@@ -3241,12 +3252,14 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
                return ret;
        }
 
+       sta_priv->common.sta_id = sta_id;
+
        /* Initialize rate scaling */
        IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n",
                       sta->addr);
        iwl_rs_rate_init(priv, sta, sta_id);
 
-       return ret;
+       return 0;
 }
 
 /*****************************************************************************