aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-04-30 14:30:45 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-05-10 18:09:05 -0400
commit2a87c26bbe9587baeb9e56d3ce0b4971bd777643 (patch)
tree1c04fc0eebe00cf3ffe6219f3b6d195f3cfae05a /drivers/net/wireless
parent64ba9a54c60990416c4098c63792c37d8fccb9e1 (diff)
iwlwifi: use iwl_find_station less
Since we now store the station ID in each station struct, many places need not look at the station table any more since they can just pull the station ID out of the struct. Remove iwl_get_sta_id() and use iwl_sta_id() instead as appropriate. This reduces the amount of code needed to find the right station significantly, and works since mac80211 passes the station only after it has been fully initialised, ie. even if TX races with station addition it will only be passed to TX once the addition is complete. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c56
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c23
5 files changed, 29 insertions, 78 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 6a306e849584..89c85d1043ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -566,11 +566,11 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
566 566
567 hdr_len = ieee80211_hdrlen(fc); 567 hdr_len = ieee80211_hdrlen(fc);
568 568
569 /* Find (or create) index into station table for destination station */ 569 /* Find index into station table for destination station */
570 if (info->flags & IEEE80211_TX_CTL_INJECTED) 570 if (!info->control.sta)
571 sta_id = priv->hw_params.bcast_sta_id; 571 sta_id = priv->hw_params.bcast_sta_id;
572 else 572 else
573 sta_id = iwl_get_sta_id(priv, hdr); 573 sta_id = iwl_sta_id(info->control.sta);
574 if (sta_id == IWL_INVALID_STATION) { 574 if (sta_id == IWL_INVALID_STATION) {
575 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 575 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
576 hdr->addr1); 576 hdr->addr1);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index b2c5665c516e..8a4b83073540 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3070,7 +3070,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3070 struct ieee80211_key_conf *key) 3070 struct ieee80211_key_conf *key)
3071{ 3071{
3072 struct iwl_priv *priv = hw->priv; 3072 struct iwl_priv *priv = hw->priv;
3073 const u8 *addr;
3074 int ret; 3073 int ret;
3075 u8 sta_id; 3074 u8 sta_id;
3076 bool is_default_wep_key = false; 3075 bool is_default_wep_key = false;
@@ -3081,13 +3080,17 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3081 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 3080 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
3082 return -EOPNOTSUPP; 3081 return -EOPNOTSUPP;
3083 } 3082 }
3084 addr = sta ? sta->addr : iwl_bcast_addr;
3085 sta_id = iwl_find_station(priv, addr);
3086 if (sta_id == IWL_INVALID_STATION) {
3087 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
3088 addr);
3089 return -EINVAL;
3090 3083
3084 if (sta) {
3085 sta_id = iwl_sta_id(sta);
3086
3087 if (sta_id == IWL_INVALID_STATION) {
3088 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
3089 sta->addr);
3090 return -EINVAL;
3091 }
3092 } else {
3093 sta_id = priv->hw_params.bcast_sta_id;
3091 } 3094 }
3092 3095
3093 mutex_lock(&priv->mutex); 3096 mutex_lock(&priv->mutex);
@@ -3212,7 +3215,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3212 if (!sta_priv->asleep) 3215 if (!sta_priv->asleep)
3213 break; 3216 break;
3214 sta_priv->asleep = false; 3217 sta_priv->asleep = false;
3215 sta_id = iwl_find_station(priv, sta->addr); 3218 sta_id = iwl_sta_id(sta);
3216 if (sta_id != IWL_INVALID_STATION) 3219 if (sta_id != IWL_INVALID_STATION)
3217 iwl_sta_modify_ps_wake(priv, sta_id); 3220 iwl_sta_modify_ps_wake(priv, sta_id);
3218 break; 3221 break;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index d1986dedc863..4be7940ad566 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -1307,62 +1307,6 @@ void iwl_dealloc_bcast_station(struct iwl_priv *priv)
1307EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station); 1307EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station);
1308 1308
1309/** 1309/**
1310 * iwl_get_sta_id - Find station's index within station table
1311 *
1312 * If new IBSS station, create new entry in station table
1313 */
1314int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1315{
1316 int sta_id;
1317 __le16 fc = hdr->frame_control;
1318
1319 /* If this frame is broadcast or management, use broadcast station id */
1320 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1))
1321 return priv->hw_params.bcast_sta_id;
1322
1323 switch (priv->iw_mode) {
1324
1325 /* If we are a client station in a BSS network, use the special
1326 * AP station entry (that's the only station we communicate with) */
1327 case NL80211_IFTYPE_STATION:
1328 /*
1329 * If addition of station not complete yet, which means
1330 * that rate scaling has not been initialized, then return
1331 * the broadcast station.
1332 */
1333 if (!(priv->stations[IWL_AP_ID].used & IWL_STA_UCODE_ACTIVE))
1334 return priv->hw_params.bcast_sta_id;
1335 return IWL_AP_ID;
1336
1337 /* If we are an AP, then find the station, or use BCAST */
1338 case NL80211_IFTYPE_AP:
1339 sta_id = iwl_find_station(priv, hdr->addr1);
1340 if (sta_id != IWL_INVALID_STATION)
1341 return sta_id;
1342 return priv->hw_params.bcast_sta_id;
1343
1344 /* If this frame is going out to an IBSS network, find the station,
1345 * or create a new station table entry */
1346 case NL80211_IFTYPE_ADHOC:
1347 sta_id = iwl_find_station(priv, hdr->addr1);
1348 if (sta_id != IWL_INVALID_STATION)
1349 return sta_id;
1350
1351 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1352 "Defaulting to broadcast...\n",
1353 hdr->addr1);
1354 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
1355 return priv->hw_params.bcast_sta_id;
1356
1357 default:
1358 IWL_WARN(priv, "Unknown mode of operation: %d\n",
1359 priv->iw_mode);
1360 return priv->hw_params.bcast_sta_id;
1361 }
1362}
1363EXPORT_SYMBOL(iwl_get_sta_id);
1364
1365/**
1366 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table 1310 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
1367 */ 1311 */
1368void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) 1312void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index 7229e2c0f770..646f644974ca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -29,6 +29,8 @@
29#ifndef __iwl_sta_h__ 29#ifndef __iwl_sta_h__
30#define __iwl_sta_h__ 30#define __iwl_sta_h__
31 31
32#include "iwl-dev.h"
33
32#define HW_KEY_DYNAMIC 0 34#define HW_KEY_DYNAMIC 0
33#define HW_KEY_DEFAULT 1 35#define HW_KEY_DEFAULT 1
34 36
@@ -65,7 +67,6 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv);
65int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq); 67int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq);
66void iwl_dealloc_bcast_station(struct iwl_priv *priv); 68void iwl_dealloc_bcast_station(struct iwl_priv *priv);
67int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 69int iwl_get_free_ucode_key_index(struct iwl_priv *priv);
68int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
69int iwl_send_add_sta(struct iwl_priv *priv, 70int iwl_send_add_sta(struct iwl_priv *priv,
70 struct iwl_addsta_cmd *sta, u8 flags); 71 struct iwl_addsta_cmd *sta, u8 flags);
71int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs, 72int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 48fb59bbfbd9..4916f2365501 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -508,11 +508,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
508 508
509 hdr_len = ieee80211_hdrlen(fc); 509 hdr_len = ieee80211_hdrlen(fc);
510 510
511 /* Find (or create) index into station table for destination station */ 511 /* Find index into station table for destination station */
512 if (info->flags & IEEE80211_TX_CTL_INJECTED) 512 if (!info->control.sta)
513 sta_id = priv->hw_params.bcast_sta_id; 513 sta_id = priv->hw_params.bcast_sta_id;
514 else 514 else
515 sta_id = iwl_get_sta_id(priv, hdr); 515 sta_id = iwl_sta_id(info->control.sta);
516 if (sta_id == IWL_INVALID_STATION) { 516 if (sta_id == IWL_INVALID_STATION) {
517 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 517 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
518 hdr->addr1); 518 hdr->addr1);
@@ -3321,7 +3321,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3321 struct ieee80211_key_conf *key) 3321 struct ieee80211_key_conf *key)
3322{ 3322{
3323 struct iwl_priv *priv = hw->priv; 3323 struct iwl_priv *priv = hw->priv;
3324 const u8 *addr;
3325 int ret = 0; 3324 int ret = 0;
3326 u8 sta_id = IWL_INVALID_STATION; 3325 u8 sta_id = IWL_INVALID_STATION;
3327 u8 static_key; 3326 u8 static_key;
@@ -3333,15 +3332,19 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3333 return -EOPNOTSUPP; 3332 return -EOPNOTSUPP;
3334 } 3333 }
3335 3334
3336 addr = sta ? sta->addr : iwl_bcast_addr;
3337 static_key = !iwl_is_associated(priv); 3335 static_key = !iwl_is_associated(priv);
3338 3336
3339 if (!static_key) { 3337 if (!static_key) {
3340 sta_id = iwl_find_station(priv, addr); 3338 if (!sta) {
3341 if (sta_id == IWL_INVALID_STATION) { 3339 sta_id = priv->hw_params.bcast_sta_id;
3342 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n", 3340 } else {
3343 addr); 3341 sta_id = iwl_sta_id(sta);
3344 return -EINVAL; 3342 if (sta_id == IWL_INVALID_STATION) {
3343 IWL_DEBUG_MAC80211(priv,
3344 "leave - %pM not in station map.\n",
3345 sta->addr);
3346 return -EINVAL;
3347 }
3345 } 3348 }
3346 } 3349 }
3347 3350