mac80211: rewrite HT handling
[linux-2.6-block.git] / drivers / net / wireless / iwlwifi / iwl-sta.c
index 61797f3f8d5c9a475b85d7fb980fe6a16dbb804a..218483d096cceabc7cb7cc42b8a6548b9d707f66 100644 (file)
@@ -45,7 +45,6 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
        int start = 0;
        int ret = IWL_INVALID_STATION;
        unsigned long flags;
-       DECLARE_MAC_BUF(mac);
 
        if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
            (priv->iw_mode == NL80211_IFTYPE_AP))
@@ -63,8 +62,8 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
                        goto out;
                }
 
-       IWL_DEBUG_ASSOC_LIMIT("can not find STA %s total %d\n",
-                             print_mac(mac, addr), priv->num_stations);
+       IWL_DEBUG_ASSOC_LIMIT("can not find STA %pM total %d\n",
+                             addr, priv->num_stations);
 
  out:
        spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -86,7 +85,6 @@ EXPORT_SYMBOL(iwl_get_ra_sta_id);
 static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
 {
        unsigned long flags;
-       DECLARE_MAC_BUF(mac);
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
@@ -94,8 +92,8 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
                IWL_ERROR("ACTIVATE a non DRIVER active station %d\n", sta_id);
 
        priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
-       IWL_DEBUG_ASSOC("Added STA to Ucode: %s\n",
-                       print_mac(mac, priv->stations[sta_id].sta.sta.addr));
+       IWL_DEBUG_ASSOC("Added STA to Ucode: %pM\n",
+                       priv->stations[sta_id].sta.sta.addr);
 
        spin_unlock_irqrestore(&priv->sta_lock, flags);
 }
@@ -183,7 +181,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
 EXPORT_SYMBOL(iwl_send_add_sta);
 
 static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
-                                  struct ieee80211_ht_info *sta_ht_inf)
+                                  struct ieee80211_sta_ht_cap *sta_ht_inf)
 {
        __le32 sta_flags;
        u8 mimo_ps_mode;
@@ -231,13 +229,12 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
  * iwl_add_station_flags - Add station to tables in driver and device
  */
 u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
-                        u8 flags, struct ieee80211_ht_info *ht_info)
+                        u8 flags, struct ieee80211_sta_ht_cap *ht_info)
 {
        int i;
        int sta_id = IWL_INVALID_STATION;
        struct iwl_station_entry *station;
        unsigned long flags_spin;
-       DECLARE_MAC_BUF(mac);
 
        spin_lock_irqsave(&priv->sta_lock, flags_spin);
        if (is_ap)
@@ -273,8 +270,8 @@ u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
 
        station = &priv->stations[sta_id];
        station->used = IWL_STA_DRIVER_ACTIVE;
-       IWL_DEBUG_ASSOC("Add STA to driver ID %d: %s\n",
-                       sta_id, print_mac(mac, addr));
+       IWL_DEBUG_ASSOC("Add STA to driver ID %d: %pM\n",
+                       sta_id, addr);
        priv->num_stations++;
 
        /* Set up the REPLY_ADD_STA command to send to device */
@@ -301,14 +298,11 @@ EXPORT_SYMBOL(iwl_add_station_flags);
 static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr)
 {
        unsigned long flags;
-       DECLARE_MAC_BUF(mac);
-
        u8 sta_id = iwl_find_station(priv, addr);
 
        BUG_ON(sta_id == IWL_INVALID_STATION);
 
-       IWL_DEBUG_ASSOC("Removed STA from Ucode: %s\n",
-                       print_mac(mac, addr));
+       IWL_DEBUG_ASSOC("Removed STA from Ucode: %pM\n", addr);
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
@@ -415,7 +409,6 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
        int sta_id = IWL_INVALID_STATION;
        int i, ret = -EINVAL;
        unsigned long flags;
-       DECLARE_MAC_BUF(mac);
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
@@ -435,18 +428,18 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
        if (unlikely(sta_id == IWL_INVALID_STATION))
                goto out;
 
-       IWL_DEBUG_ASSOC("Removing STA from driver:%d  %s\n",
-               sta_id, print_mac(mac, addr));
+       IWL_DEBUG_ASSOC("Removing STA from driver:%d  %pM\n",
+               sta_id, addr);
 
        if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
-               IWL_ERROR("Removing %s but non DRIVER active\n",
-                               print_mac(mac, addr));
+               IWL_ERROR("Removing %pM but non DRIVER active\n",
+                               addr);
                goto out;
        }
 
        if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
-               IWL_ERROR("Removing %s but non UCODE active\n",
-                               print_mac(mac, addr));
+               IWL_ERROR("Removing %pM but non UCODE active\n",
+                               addr);
                goto out;
        }
 
@@ -852,7 +845,7 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
        struct iwl_link_quality_cmd link_cmd = {
                .reserved1 = 0,
        };
-       u16 rate_flags;
+       u32 rate_flags;
 
        /* Set up the rate scaling to start at selected rate, fall back
         * all the way down to 1M in IEEE order, and then spin on 1M */
@@ -868,15 +861,16 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
                if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
                        rate_flags |= RATE_MCS_CCK_MSK;
 
-               /* Use Tx antenna B only */
-               rate_flags |= RATE_MCS_ANT_B_MSK; /*FIXME:RS*/
+               rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
+                               RATE_MCS_ANT_POS;
 
                link_cmd.rs_table[i].rate_n_flags =
                        iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
                r = iwl4965_get_prev_ieee_rate(r);
        }
 
-       link_cmd.general_params.single_stream_ant_msk = 2;
+       link_cmd.general_params.single_stream_ant_msk =
+                               first_antenna(priv->hw_params.valid_tx_ant);
        link_cmd.general_params.dual_stream_ant_msk = 3;
        link_cmd.agg_params.agg_dis_start_th = 3;
        link_cmd.agg_params.agg_time_limit = cpu_to_le16(4000);
@@ -896,20 +890,31 @@ static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, int is_ap)
  */
 int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
 {
+       struct ieee80211_sta *sta;
+       struct ieee80211_sta_ht_cap ht_config;
+       struct ieee80211_sta_ht_cap *cur_ht_config = NULL;
        u8 sta_id;
 
        /* Add station to device's station table */
-       struct ieee80211_conf *conf = &priv->hw->conf;
-       struct ieee80211_ht_info *cur_ht_config = &conf->ht_conf;
-
-       if ((is_ap) &&
-           (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) &&
-           (priv->iw_mode == NL80211_IFTYPE_STATION))
-               sta_id = iwl_add_station_flags(priv, addr, is_ap,
-                                                  0, cur_ht_config);
-       else
-               sta_id = iwl_add_station_flags(priv, addr, is_ap,
-                                                  0, NULL);
+
+       /*
+        * XXX: This check is definitely not correct, if we're an AP
+        *      it'll always be false which is not what we want, but
+        *      it doesn't look like iwlagn is prepared to be an HT
+        *      AP anyway.
+        */
+       if (priv->current_ht_config.is_ht) {
+               rcu_read_lock();
+               sta = ieee80211_find_sta(priv->hw, addr);
+               if (sta) {
+                       memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config));
+                       cur_ht_config = &ht_config;
+               }
+               rcu_read_unlock();
+       }
+
+       sta_id = iwl_add_station_flags(priv, addr, is_ap,
+                                      0, cur_ht_config);
 
        /* Set up default rate scaling table in device's station table */
        iwl_sta_init_lq(priv, addr, is_ap);
@@ -927,7 +932,6 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
 {
        int sta_id;
        u16 fc = le16_to_cpu(hdr->frame_control);
-       DECLARE_MAC_BUF(mac);
 
        /* If this frame is broadcast or management, use broadcast station id */
        if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) ||
@@ -962,9 +966,9 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
                if (sta_id != IWL_INVALID_STATION)
                        return sta_id;
 
-               IWL_DEBUG_DROP("Station %s not in station map. "
+               IWL_DEBUG_DROP("Station %pM not in station map. "
                               "Defaulting to broadcast...\n",
-                              print_mac(mac, hdr->addr1));
+                              hdr->addr1);
                iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
                return priv->hw_params.bcast_sta_id;