iwlwifi: fix station HT parameters

My patch "iwlwifi: simplify auth/assoc flow"
caused a serious throughput degradation due
to me forgetting that there are HT settings
in the station table. To restore throughput,
set these parameters correctly when the sta
moves to assoc state.

This patch should probably be merged with
the auth/assoc redesign patch for upstream.
In that case, this paragraph should be added
to the commit log as the third paragraph
(before talking about RXON):

However, as we only get the station HT data
when the station moves into assoc state, we
also need to program this into the device
(and copy it into our database) then.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
index 8160f61..7f93715 100644
--- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c
+++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
@@ -740,8 +740,9 @@
 				enum ieee80211_sta_state new_state)
 {
 	struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
+	struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
 	enum {
-		NONE, ADD, REMOVE, RATE_INIT, ADD_RATE_INIT,
+		NONE, ADD, REMOVE, HT_RATE_INIT, ADD_RATE_INIT,
 	} op = NONE;
 	int ret;
 
@@ -758,7 +759,7 @@
 			op = REMOVE;
 		else if (old_state == IEEE80211_STA_AUTH &&
 			 new_state == IEEE80211_STA_ASSOC)
-			op = RATE_INIT;
+			op = HT_RATE_INIT;
 	} else {
 		if (old_state == IEEE80211_STA_AUTH &&
 		    new_state == IEEE80211_STA_ASSOC)
@@ -779,8 +780,6 @@
 		ret = iwlagn_mac_sta_add(hw, vif, sta);
 		if (ret)
 			break;
-		/* fall through */
-	case RATE_INIT:
 		/* Initialize rate scaling */
 		IWL_DEBUG_INFO(priv,
 			       "Initializing rate scaling for station %pM\n",
@@ -788,6 +787,17 @@
 		iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
 		ret = 0;
 		break;
+	case HT_RATE_INIT:
+		/* Initialize rate scaling */
+		ret = iwl_sta_update_ht(priv, vif_priv->ctx, sta);
+		if (ret)
+			break;
+		IWL_DEBUG_INFO(priv,
+			       "Initializing rate scaling for station %pM\n",
+			       sta->addr);
+		iwl_rs_rate_init(priv, sta, iwl_sta_id(sta));
+		ret = 0;
+		break;
 	default:
 		ret = 0;
 		break;