Linux wireless drivers development
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	ipw3945-devel@lists.sourceforge.net,
	Johannes Berg <johannes.berg@intel.com>,
	Reinette Chatre <reinette.chatre@intel.com>
Subject: [PATCH 41/47] iwlwifi: use iwl_find_station less
Date: Mon, 10 May 2010 15:28:12 -0700	[thread overview]
Message-ID: <1273530498-11876-42-git-send-email-reinette.chatre@intel.com> (raw)
In-Reply-To: <1273530498-11876-1-git-send-email-reinette.chatre@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

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>
---
 drivers/net/wireless/iwlwifi/iwl-agn-tx.c   |    6 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c      |   19 +++++----
 drivers/net/wireless/iwlwifi/iwl-sta.c      |   56 ---------------------------
 drivers/net/wireless/iwlwifi/iwl-sta.h      |    3 +-
 drivers/net/wireless/iwlwifi/iwl3945-base.c |   23 ++++++-----
 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 6a306e8..89c85d1 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)
 
 	hdr_len = ieee80211_hdrlen(fc);
 
-	/* Find (or create) index into station table for destination station */
-	if (info->flags & IEEE80211_TX_CTL_INJECTED)
+	/* Find index into station table for destination station */
+	if (!info->control.sta)
 		sta_id = priv->hw_params.bcast_sta_id;
 	else
-		sta_id = iwl_get_sta_id(priv, hdr);
+		sta_id = iwl_sta_id(info->control.sta);
 	if (sta_id == IWL_INVALID_STATION) {
 		IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
 			       hdr->addr1);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index b2c5665..8a4b830 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,
 			   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;
@@ -3081,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);
@@ -3212,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;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index d1986de..4be7940 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)
 EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station);
 
 /**
- * iwl_get_sta_id - Find station's index within station table
- *
- * If new IBSS station, create new entry in station table
- */
-int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
-{
-	int sta_id;
-	__le16 fc = hdr->frame_control;
-
-	/* If this frame is broadcast or management, use broadcast station id */
-	if (!ieee80211_is_data(fc) ||  is_multicast_ether_addr(hdr->addr1))
-		return priv->hw_params.bcast_sta_id;
-
-	switch (priv->iw_mode) {
-
-	/* If we are a client station in a BSS network, use the special
-	 * AP station entry (that's the only station we communicate with) */
-	case NL80211_IFTYPE_STATION:
-		/*
-		 * If addition of station not complete yet, which means
-		 * that rate scaling has not been initialized, then return
-		 * the broadcast station.
-		 */
-		if (!(priv->stations[IWL_AP_ID].used & IWL_STA_UCODE_ACTIVE))
-			return priv->hw_params.bcast_sta_id;
-		return IWL_AP_ID;
-
-	/* If we are an AP, then find the station, or use BCAST */
-	case NL80211_IFTYPE_AP:
-		sta_id = iwl_find_station(priv, hdr->addr1);
-		if (sta_id != IWL_INVALID_STATION)
-			return sta_id;
-		return priv->hw_params.bcast_sta_id;
-
-	/* If this frame is going out to an IBSS network, find the station,
-	 * or create a new station table entry */
-	case NL80211_IFTYPE_ADHOC:
-		sta_id = iwl_find_station(priv, hdr->addr1);
-		if (sta_id != IWL_INVALID_STATION)
-			return sta_id;
-
-		IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
-			       "Defaulting to broadcast...\n",
-			       hdr->addr1);
-		iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
-		return priv->hw_params.bcast_sta_id;
-
-	default:
-		IWL_WARN(priv, "Unknown mode of operation: %d\n",
-			priv->iw_mode);
-		return priv->hw_params.bcast_sta_id;
-	}
-}
-EXPORT_SYMBOL(iwl_get_sta_id);
-
-/**
  * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
  */
 void 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 7229e2c..646f644 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -29,6 +29,8 @@
 #ifndef __iwl_sta_h__
 #define __iwl_sta_h__
 
+#include "iwl-dev.h"
+
 #define HW_KEY_DYNAMIC 0
 #define HW_KEY_DEFAULT 1
 
@@ -65,7 +67,6 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv);
 int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq);
 void iwl_dealloc_bcast_station(struct iwl_priv *priv);
 int iwl_get_free_ucode_key_index(struct iwl_priv *priv);
-int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
 int iwl_send_add_sta(struct iwl_priv *priv,
 		     struct iwl_addsta_cmd *sta, u8 flags);
 int 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 48fb59b..4916f23 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)
 
 	hdr_len = ieee80211_hdrlen(fc);
 
-	/* Find (or create) index into station table for destination station */
-	if (info->flags & IEEE80211_TX_CTL_INJECTED)
+	/* Find index into station table for destination station */
+	if (!info->control.sta)
 		sta_id = priv->hw_params.bcast_sta_id;
 	else
-		sta_id = iwl_get_sta_id(priv, hdr);
+		sta_id = iwl_sta_id(info->control.sta);
 	if (sta_id == IWL_INVALID_STATION) {
 		IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
 			       hdr->addr1);
@@ -3321,7 +3321,6 @@ static int iwl3945_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 = 0;
 	u8 sta_id = IWL_INVALID_STATION;
 	u8 static_key;
@@ -3333,15 +3332,19 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		return -EOPNOTSUPP;
 	}
 
-	addr = sta ? sta->addr : iwl_bcast_addr;
 	static_key = !iwl_is_associated(priv);
 
 	if (!static_key) {
-		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 = priv->hw_params.bcast_sta_id;
+		} else {
+			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;
+			}
 		}
 	}
 
-- 
1.6.3.3


  parent reply	other threads:[~2010-05-10 22:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10 22:27 [PATCH 00/47] iwlwifi updates for 2.6.35 Reinette Chatre
2010-05-10 22:27 ` [PATCH 01/47] iwlwifi: rename 6000 series Gen2 devices to Gen2a Reinette Chatre
2010-05-10 22:46   ` Gábor Stefanik
2010-05-10 22:52     ` Zhao, Shanyu
2010-05-10 22:27 ` [PATCH 02/47] iwl3945: fix scan races Reinette Chatre
2010-05-10 22:27 ` [PATCH 03/47] iwlwifi: remove powersave debugfs if it is not supported Reinette Chatre
2010-05-10 22:27 ` [PATCH 04/47] iwlwifi: rename "tx_power" to "chain_tx_power" Reinette Chatre
2010-05-10 22:27 ` [PATCH 05/47] iwlwifi: use vif iwl_bss_info_changed Reinette Chatre
2010-05-10 22:27 ` [PATCH 06/47] iwlwifi: remove device type checking for tx power in debugfs Reinette Chatre
2010-05-10 22:27 ` [PATCH 07/47] iwlwifi: use .cfg to enable/disable continuous ucode trace Reinette Chatre
2010-05-10 22:27 ` [PATCH 08/47] iwlwifi: use cfg to configure calibration operation Reinette Chatre
2010-05-10 22:27 ` [PATCH 09/47] iwlwifi: give correct return information for tx power debugfs Reinette Chatre
2010-05-10 22:27 ` [PATCH 10/47] iwlwifi: wimax co-exist code clean up Reinette Chatre
2010-05-10 22:27 ` [PATCH 11/47] iwlwifi: checking for all the possible failure cases Reinette Chatre
2010-05-10 22:27 ` [PATCH 12/47] iwlwifi: dump firmware build info in error case Reinette Chatre
2010-05-10 22:27 ` [PATCH 13/47] iwlwifi: make bcast LQ command available for later restore actions Reinette Chatre
2010-05-10 22:27 ` [PATCH 14/47] iwl3945: use iwl3945_add_bcast_station Reinette Chatre
2010-05-10 22:27 ` [PATCH 15/47] iwlwifi: pass address to iwl_remove_station Reinette Chatre
2010-05-10 22:27 ` [PATCH 16/47] iwlwifi: manage IBSS station properly Reinette Chatre
2010-05-10 22:27 ` [PATCH 17/47] iwlagn: show and store firmware build number Reinette Chatre
2010-05-10 22:27 ` [PATCH 18/47] iwl3945: remove ucode access indirection Reinette Chatre
2010-05-10 22:27 ` [PATCH 19/47] iwlwifi: remove ucode virtual functions Reinette Chatre
2010-05-10 22:27 ` [PATCH 20/47] iwlwifi: move eeprom version printout to eeprom init Reinette Chatre
2010-05-10 22:27 ` [PATCH 21/47] iwlagn: prepare for new firmware file format Reinette Chatre
2010-05-10 22:27 ` [PATCH 22/47] iwlagn: implement loading a new firmware file type Reinette Chatre
2010-05-10 22:27 ` [PATCH 23/47] iwl3945: add plcp error checking Reinette Chatre
2010-05-10 22:27 ` [PATCH 24/47] iwlwifi: remove rts_threshold Reinette Chatre
2010-05-10 22:27 ` [PATCH 25/47] iwlagn: move iwl_get_ra_sta_id to 4965 Reinette Chatre
2010-05-10 22:27 ` [PATCH 26/47] iwlagn: use vif->type to check station Reinette Chatre
2010-05-10 22:27 ` [PATCH 27/47] iwlwifi: apply filter flags directly Reinette Chatre
2010-05-10 22:27 ` [PATCH 28/47] iwlwifi: push virtual interface through Reinette Chatre
2010-05-10 22:28 ` [PATCH 29/47] iwlagn: use virtual interface in TX aggregation handling Reinette Chatre
2010-05-10 22:28 ` [PATCH 30/47] iwlwifi: remove useless priv->vif check Reinette Chatre
2010-05-10 22:28 ` [PATCH 31/47] iwlwifi: use vif in iwl_ht_conf Reinette Chatre
2010-05-10 22:28 ` [PATCH 32/47] iwlwifi: note that priv->bssid is used only by 3945 Reinette Chatre
2010-05-10 22:28 ` [PATCH 33/47] iwlwifi: fix iwl_sta_init_lq station ID Reinette Chatre
2010-05-10 22:28 ` [PATCH 34/47] iwlwifi: split allocation/sending local station LQ Reinette Chatre
2010-05-10 22:28 ` [PATCH 35/47] iwlwifi: rework broadcast station management Reinette Chatre
2010-05-10 22:28 ` [PATCH 36/47] iwlagn: work around rate scaling reset delay Reinette Chatre
2010-05-10 22:28 ` [PATCH 37/47] iwlwifi: "tx power per chain" are part of ucode_tx_stats Reinette Chatre
2010-05-10 22:28 ` [PATCH 38/47] iwlwifi: provide more comments for cfg structure Reinette Chatre
2010-05-10 22:28 ` [PATCH 39/47] iwlwifi: track station IDs Reinette Chatre
2010-05-10 22:28 ` [PATCH 40/47] iwlwifi: add iwl_sta_id() Reinette Chatre
2010-05-10 22:28 ` Reinette Chatre [this message]
2010-05-10 22:28 ` [PATCH 42/47] iwlagn: use iwl_sta_id() for aggregation Reinette Chatre
2010-05-10 22:28 ` [PATCH 43/47] iwlwifi: use iwl_sta_id() for TKIP key update Reinette Chatre
2010-05-10 22:28 ` [PATCH 44/47] iwlwifi: move iwl_find_station() to 4965 Reinette Chatre
2010-05-10 22:28 ` [PATCH 45/47] iwlwifi: rename iwl_add_local_station Reinette Chatre
2010-05-10 22:28 ` [PATCH 46/47] iwlwifi: remove pointless HT check Reinette Chatre
2010-05-10 22:28 ` [PATCH 47/47] iwlwifi: clear driver stations when going down Reinette Chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273530498-11876-42-git-send-email-reinette.chatre@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=ipw3945-devel@lists.sourceforge.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox