All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Yi <yi.zhu@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>,
	Tomas Winkler <tomas.winkler@intel.com>,
	Zhu Yi <yi.zhu@intel.com>
Subject: [PATCH 06/33] iwlwifi: send ADD_STA before RXON with assoc bit
Date: Mon, 30 Jun 2008 17:23:06 +0800	[thread overview]
Message-ID: <1214817813-17639-7-git-send-email-yi.zhu@intel.com> (raw)
In-Reply-To: <1214817813-17639-6-git-send-email-yi.zhu@intel.com>

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

This patch fixes a bug in association flow. As soon as RXON with assoc bit
is sent, uCode expects to have an entry in its station table that describe
the AP. Receiving a beacon from an HT AP before sending ADD_STA results a
uCode error. This patch sends first the ADD_STA (bcast and bssid) and only
then RXON with assoc bit set

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl4965-base.c |   79 ++++++++++++++++-----------
 1 files changed, 46 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index a2dffe4..0a279d1 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -241,16 +241,18 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 	/* cast away the const for active_rxon in this function */
 	struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
 	DECLARE_MAC_BUF(mac);
-	int rc = 0;
+	int ret;
+	bool new_assoc =
+		!!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK);
 
 	if (!iwl_is_alive(priv))
-		return -1;
+		return -EBUSY;
 
 	/* always get timestamp with Rx frame */
 	priv->staging_rxon.flags |= RXON_FLG_TSF2HOST_MSK;
 
-	rc = iwl4965_check_rxon_cmd(&priv->staging_rxon);
-	if (rc) {
+	ret = iwl4965_check_rxon_cmd(&priv->staging_rxon);
+	if (ret) {
 		IWL_ERROR("Invalid RXON configuration.  Not committing.\n");
 		return -EINVAL;
 	}
@@ -259,15 +261,13 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 	 * iwl4965_rxon_assoc_cmd which is used to reconfigure filter
 	 * and other flags for the current radio configuration. */
 	if (!iwl4965_full_rxon_required(priv)) {
-		rc = iwl_send_rxon_assoc(priv);
-		if (rc) {
-			IWL_ERROR("Error setting RXON_ASSOC "
-				  "configuration (%d).\n", rc);
-			return rc;
+		ret = iwl_send_rxon_assoc(priv);
+		if (ret) {
+			IWL_ERROR("Error setting RXON_ASSOC (%d)\n", ret);
+			return ret;
 		}
 
 		memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
-
 		return 0;
 	}
 
@@ -278,22 +278,20 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 	 * an RXON_ASSOC and the new config wants the associated mask enabled,
 	 * we must clear the associated from the active configuration
 	 * before we apply the new config */
-	if (iwl_is_associated(priv) &&
-	    (priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK)) {
+	if (iwl_is_associated(priv) && new_assoc) {
 		IWL_DEBUG_INFO("Toggling associated bit on current RXON\n");
 		active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
 
-		rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
+		ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
 				      sizeof(struct iwl_rxon_cmd),
 				      &priv->active_rxon);
 
 		/* If the mask clearing failed then we set
 		 * active_rxon back to what it was previously */
-		if (rc) {
+		if (ret) {
 			active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
-			IWL_ERROR("Error clearing ASSOC_MSK on current "
-				  "configuration (%d).\n", rc);
-			return rc;
+			IWL_ERROR("Error clearing ASSOC_MSK (%d)\n", ret);
+			return ret;
 		}
 	}
 
@@ -301,18 +299,25 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 		       "* with%s RXON_FILTER_ASSOC_MSK\n"
 		       "* channel = %d\n"
 		       "* bssid = %s\n",
-		       ((priv->staging_rxon.filter_flags &
-			 RXON_FILTER_ASSOC_MSK) ? "" : "out"),
+		       (new_assoc ? "" : "out"),
 		       le16_to_cpu(priv->staging_rxon.channel),
 		       print_mac(mac, priv->staging_rxon.bssid_addr));
 
 	iwl4965_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto);
-	/* Apply the new configuration */
-	rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
+
+	/* Apply the new configuration
+	 * RXON unassoc clears the station table in uCode, send it before
+	 * we add the bcast station. If assoc bit is set, we will send RXON
+	 * after having added the bcast and bssid station.
+	 */
+	if (!new_assoc) {
+		ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
 			      sizeof(struct iwl_rxon_cmd), &priv->staging_rxon);
-	if (rc) {
-		IWL_ERROR("Error setting new configuration (%d).\n", rc);
-		return rc;
+		if (ret) {
+			IWL_ERROR("Error setting new RXON (%d)\n", ret);
+			return ret;
+		}
+		memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
 	}
 
 	iwlcore_clear_stations_table(priv);
@@ -322,27 +327,24 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 
 	iwl_init_sensitivity(priv);
 
-	memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
-
 	/* If we issue a new RXON command which required a tune then we must
 	 * send a new TXPOWER command or we won't be able to Tx any frames */
-	rc = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
-	if (rc) {
-		IWL_ERROR("Error sending TX power (%d).\n", rc);
-		return rc;
+	ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
+	if (ret) {
+		IWL_ERROR("Error sending TX power (%d)\n", ret);
+		return ret;
 	}
 
 	/* Add the broadcast address so we can send broadcast frames */
 	if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) ==
-	    IWL_INVALID_STATION) {
+						IWL_INVALID_STATION) {
 		IWL_ERROR("Error adding BROADCAST address for transmit.\n");
 		return -EIO;
 	}
 
 	/* If we have set the ASSOC_MSK and we are in BSS mode then
 	 * add the IWL_AP_ID to the station rate table */
-	if (iwl_is_associated(priv) &&
-	    (priv->iw_mode == IEEE80211_IF_TYPE_STA)) {
+	if (new_assoc && (priv->iw_mode == IEEE80211_IF_TYPE_STA)) {
 		if (iwl_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1)
 		    == IWL_INVALID_STATION) {
 			IWL_ERROR("Error adding AP address for transmit.\n");
@@ -352,6 +354,17 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 		if (priv->default_wep_key &&
 		    iwl_send_static_wepkey_cmd(priv, 0))
 			IWL_ERROR("Could not send WEP static key.\n");
+
+		/* Apply the new configuration
+		 * RXON assoc doesn't clear the station table in uCode,
+		 */
+		ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
+			      sizeof(struct iwl_rxon_cmd), &priv->staging_rxon);
+		if (ret) {
+			IWL_ERROR("Error setting new RXON (%d)\n", ret);
+			return ret;
+		}
+		memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
 	}
 
 	return 0;
-- 
1.5.3.6


  reply	other threads:[~2008-06-30  9:26 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30  9:23 [PATCH 00/33] iwlwifi driver 06/30 updates Zhu Yi
2008-06-30  9:23 ` [PATCH 01/33] iwlwifi: configure uCode to use open loop tx power algorithm Zhu Yi
2008-06-30  9:23   ` [PATCH 02/33] iwlwifi: Add eeprom version to the version file in sysfs Zhu Yi
2008-06-30  9:23     ` [PATCH 03/33] iwlwifi: better station table maintenance Zhu Yi
2008-06-30  9:23       ` [PATCH 04/33] iwlwifi: use iwl_is_associated when possible Zhu Yi
2008-06-30  9:23         ` [PATCH 05/33] iwlwifi: add REPLY_TX_POWER_DBM_CMD to get_cmd_string Zhu Yi
2008-06-30  9:23           ` Zhu Yi [this message]
2008-06-30  9:23             ` [PATCH 07/33] iwlwifi: move RX stats to core, and move temperature to handler Zhu Yi
2008-06-30  9:23               ` [PATCH 08/33] iwlwifi: don't send REPLY_REMOVE_ALL_STA upon exit Zhu Yi
2008-06-30  9:23                 ` [PATCH 09/33] iwlwifi: move RX handlers to iwl-rx.c Zhu Yi
2008-06-30  9:23                   ` [PATCH 10/33] iwlwifi: remove useless network and duplicate checking Zhu Yi
2008-06-30  9:23                     ` [PATCH 11/33] iwlwifi: setup compressed BA handler Zhu Yi
2008-06-30  9:23                       ` [PATCH 12/33] iwlwifi: move rx aggregation functions to iwl-rx.c Zhu Yi
2008-06-30  9:23                         ` [PATCH 13/33] iwlwifi: remove obsolete lq_ready use Zhu Yi
2008-06-30  9:23                           ` [PATCH 14/33] iwlwifi: fix IBSS association flow Zhu Yi
2008-06-30  9:23                             ` [PATCH 15/33] iwlwifi: keep the STATUS_EXIT_PENDING flag till the end of down flow Zhu Yi
2008-06-30  9:23                               ` [PATCH 16/33] mac80211: add beacon timestamp to beacon template in IBSS Zhu Yi
2008-06-30  9:23                                 ` [PATCH 17/33] iwlwifi: adjust TSF " Zhu Yi
2008-06-30  9:23                                   ` [PATCH 18/33] iwlwifi : Patch adds rfkill subsystem for 3945 Zhu Yi
2008-06-30  9:23                                     ` [PATCH 19/33] iwlwifi: don't bring up interface if RF-kill avoids radio Zhu Yi
2008-06-30  9:23                                       ` [PATCH 20/33] iwlwifi: unite common settings of HW params Zhu Yi
2008-06-30  9:23                                         ` [PATCH 21/33] iwlwifi: control 11n capabilities through module param Zhu Yi
2008-06-30  9:23                                           ` [PATCH 22/33] iwlwifi: Remove unnecessary code Zhu Yi
2008-06-30  9:23                                             ` [PATCH 23/33] iwlwifi: eliminate iwl4965_mac_get_tsf Zhu Yi
2008-06-30  9:23                                               ` [PATCH 24/33] iwlwifi: blocking mac_start until uCode is complete Zhu Yi
2008-06-30  9:23                                                 ` [PATCH 25/33] iwlwifi: clean up HW RF-kill state machine and restarts Zhu Yi
2008-06-30  9:23                                                   ` [PATCH 26/33] iwlwifi: fix 4965 uCode load Zhu Yi
2008-06-30  9:23                                                     ` [PATCH 27/33] iwlwifi: fix incorrect 5GHz rates reported in monitor mode Zhu Yi
2008-06-30  9:23                                                       ` [PATCH 28/33] iwlwifi: fix incorrect monitor mode operation Zhu Yi
2008-06-30  9:23                                                         ` [PATCH 29/33] iwlwifi: drop skb silently for Tx request in monitor mode Zhu Yi
2008-06-30  9:23                                                           ` [PATCH 30/33] iwlwifi: enable packet injection for iwl3945 Zhu Yi
2008-06-30  9:23                                                             ` [PATCH 31/33] iwlwifi: fix iwl4965 temperature callback calibration issue Zhu Yi
2008-06-30  9:23                                                               ` [PATCH 32/33] iwl3945: remove RFKILL_STATE_HARD_BLOCKED warnings Zhu Yi
2008-06-30  9:23                                                                 ` [PATCH 33/33] iwlwifi: remove the input device from rfkill_mngr Zhu Yi
2008-06-30 10:07                                                             ` [PATCH 30/33] iwlwifi: enable packet injection for iwl3945 Stefanik Gábor
2008-06-30 10:22                                                           ` [PATCH 29/33] iwlwifi: drop skb silently for Tx request in monitor mode Stefanik Gábor
2008-06-30 10:26                                                             ` Michael Buesch
2008-06-30 10:28                                                               ` Stefanik Gábor
2008-07-02  1:07                                                                 ` Zhu Yi
2008-06-30  9:56 ` [PATCH 00/33] iwlwifi driver 06/30 updates drago01
2008-07-02  3:05   ` Zhu Yi
2008-07-02  8:39     ` drago01
2008-07-02  8:41       ` Zhu Yi
2008-07-02  8:51         ` drago01

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=1214817813-17639-7-git-send-email-yi.zhu@intel.com \
    --to=yi.zhu@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=gregory.greenman@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=tomas.winkler@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.