iwlwifi: setup compressed BA handler
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-4965-rs.c
index 2adc228..2023031 100644 (file)
@@ -38,6 +38,7 @@
 #include "../net/mac80211/rate.h"
 
 #include "iwl-dev.h"
+#include "iwl-sta.h"
 #include "iwl-core.h"
 #include "iwl-helpers.h"
 
@@ -105,8 +106,6 @@ struct iwl4965_scale_tbl_info {
        struct iwl4965_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */
 };
 
-#ifdef CONFIG_IWL4965_HT
-
 struct iwl4965_traffic_load {
        unsigned long time_stamp;       /* age of the oldest statistics */
        u32 packet_count[TID_QUEUE_MAX_SIZE];   /* packet count in this time
@@ -118,8 +117,6 @@ struct iwl4965_traffic_load {
        u8 head;                        /* start of the circular buffer */
 };
 
-#endif /* CONFIG_IWL4965_HT */
-
 /**
  * struct iwl4965_lq_sta -- driver's rate scaling private structure
  *
@@ -157,16 +154,12 @@ struct iwl4965_lq_sta {
 
        struct iwl_link_quality_cmd lq;
        struct iwl4965_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */
-#ifdef CONFIG_IWL4965_HT
        struct iwl4965_traffic_load load[TID_MAX_LOAD_COUNT];
        u8 tx_agg_tid_en;
-#endif
 #ifdef CONFIG_MAC80211_DEBUGFS
        struct dentry *rs_sta_dbgfs_scale_table_file;
        struct dentry *rs_sta_dbgfs_stats_table_file;
-#ifdef CONFIG_IWL4965_HT
        struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
-#endif
        u32 dbg_fixed_rate;
 #endif
        struct iwl_priv *drv;
@@ -256,7 +249,6 @@ static inline u8 rs_is_valid_ant(u8 valid_antenna, u8 ant_type)
        return ((ant_type & valid_antenna) == ant_type);
 }
 
-#ifdef CONFIG_IWL4965_HT
 /*
  *     removes the old data from the statistics. All data that is older than
  *     TID_MAX_TIME_DIFF, will be deleted.
@@ -282,21 +274,21 @@ static void rs_tl_rm_old_stats(struct iwl4965_traffic_load *tl, u32 curr_time)
  *     increment traffic load value for tid and also remove
  *     any old values if passed the certain time period
  */
-static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data,
-                            struct ieee80211_hdr *hdr)
+static u8 rs_tl_add_packet(struct iwl4965_lq_sta *lq_data,
+                          struct ieee80211_hdr *hdr)
 {
        u32 curr_time = jiffies_to_msecs(jiffies);
        u32 time_diff;
        s32 index;
        struct iwl4965_traffic_load *tl = NULL;
-       u16 fc = le16_to_cpu(hdr->frame_control);
+       __le16 fc = hdr->frame_control;
        u8 tid;
 
-       if (ieee80211_is_qos_data(fc)) {
-               u8 *qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc));
+       if (ieee80211_is_data_qos(fc)) {
+               u8 *qc = ieee80211_get_qos_ctl(hdr);
                tid = qc[0] & 0xf;
        } else
-               return;
+               return MAX_TID_COUNT;
 
        tl = &lq_data->load[tid];
 
@@ -309,7 +301,7 @@ static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data,
                tl->queue_count = 1;
                tl->head = 0;
                tl->packet_count[0] = 1;
-               return;
+               return MAX_TID_COUNT;
        }
 
        time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time);
@@ -326,6 +318,8 @@ static void rs_tl_add_packet(struct iwl4965_lq_sta *lq_data,
 
        if ((index + 1) > tl->queue_count)
                tl->queue_count = index + 1;
+
+       return tid;
 }
 
 /*
@@ -389,8 +383,6 @@ static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid,
                        rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta);
 }
 
-#endif /* CONFIG_IWLWIFI_HT */
-
 static inline int get_num_of_ant_from_rate(u32 rate_n_flags)
 {
        return (!!(rate_n_flags & RATE_MCS_ANT_A_MSK) +
@@ -545,7 +537,7 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags,
        u8 num_of_ant = get_num_of_ant_from_rate(rate_n_flags);
        u8 mcs;
 
-       *rate_idx = iwl4965_hwrate_to_plcp_idx(rate_n_flags);
+       *rate_idx = iwl_hwrate_to_plcp_idx(rate_n_flags);
 
        if (*rate_idx  == IWL_RATE_INVALID) {
                *rate_idx = -1;
@@ -626,7 +618,6 @@ static int rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags,
 
 /* FIXME:RS: in 4965 we don't use greenfield at all */
 /* FIXME:RS: don't use greenfield for now in TX */
-/* #ifdef CONFIG_IWL4965_HT */
 #if 0
 static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf)
 {
@@ -634,12 +625,11 @@ static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf
                priv->current_ht_config.is_green_field &&
                !priv->current_ht_config.non_GF_STA_present);
 }
-#else
+#endif
 static inline u8 rs_use_green(struct iwl_priv *priv, struct ieee80211_conf *conf)
 {
        return 0;
 }
-#endif /* CONFIG_IWL4965_HT */
 
 /**
  * rs_get_supported_rates - get the available rates
@@ -785,8 +775,7 @@ out:
  * mac80211 sends us Tx status
  */
 static void rs_tx_status(void *priv_rate, struct net_device *dev,
-                        struct sk_buff *skb,
-                        struct ieee80211_tx_status *tx_resp)
+                        struct sk_buff *skb)
 {
        int status;
        u8 retries;
@@ -798,13 +787,14 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
        struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        struct ieee80211_hw *hw = local_to_hw(local);
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct iwl4965_rate_scale_data *window = NULL;
        struct iwl4965_rate_scale_data *search_win = NULL;
        u32 tx_rate;
        struct iwl4965_scale_tbl_info tbl_type;
        struct iwl4965_scale_tbl_info *curr_tbl, *search_tbl;
        u8 active_index = 0;
-       u16 fc = le16_to_cpu(hdr->frame_control);
+       __le16 fc = hdr->frame_control;
        s32 tpt = 0;
 
        IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n");
@@ -813,11 +803,11 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
                return;
 
        /* This packet was aggregated but doesn't carry rate scale info */
-       if ((tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) &&
-           !(tx_resp->flags & IEEE80211_TX_STATUS_AMPDU))
+       if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
+           !(info->flags & IEEE80211_TX_STAT_AMPDU))
                return;
 
-       retries = tx_resp->retry_count;
+       retries = info->status.retry_count;
 
        if (retries > 15)
                retries = 15;
@@ -862,20 +852,20 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
        if (priv->band == IEEE80211_BAND_5GHZ)
                rs_index -= IWL_FIRST_OFDM_RATE;
 
-       if ((tx_resp->control.tx_rate == NULL) ||
+       if ((info->tx_rate_idx < 0) ||
            (tbl_type.is_SGI ^
-               !!(tx_resp->control.flags & IEEE80211_TXCTL_SHORT_GI)) ||
+               !!(info->flags & IEEE80211_TX_CTL_SHORT_GI)) ||
            (tbl_type.is_fat ^
-               !!(tx_resp->control.flags & IEEE80211_TXCTL_40_MHZ_WIDTH)) ||
+               !!(info->flags & IEEE80211_TX_CTL_40_MHZ_WIDTH)) ||
            (tbl_type.is_dup ^
-               !!(tx_resp->control.flags & IEEE80211_TXCTL_DUP_DATA)) ||
-           (tbl_type.ant_type ^ tx_resp->control.antenna_sel_tx) ||
+               !!(info->flags & IEEE80211_TX_CTL_DUP_DATA)) ||
+           (tbl_type.ant_type ^ info->antenna_sel_tx) ||
            (!!(tx_rate & RATE_MCS_HT_MSK) ^
-               !!(tx_resp->control.flags & IEEE80211_TXCTL_OFDM_HT)) ||
+               !!(info->flags & IEEE80211_TX_CTL_OFDM_HT)) ||
            (!!(tx_rate & RATE_MCS_GF_MSK) ^
-               !!(tx_resp->control.flags & IEEE80211_TXCTL_GREEN_FIELD)) ||
+               !!(info->flags & IEEE80211_TX_CTL_GREEN_FIELD)) ||
            (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate !=
-               tx_resp->control.tx_rate->bitrate)) {
+            hw->wiphy->bands[info->band]->bitrates[info->tx_rate_idx].bitrate)) {
                IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate);
                goto out;
        }
@@ -929,10 +919,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
        rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index);
 
        /* Update frame history window with "success" if Tx got ACKed ... */
-       if (tx_resp->flags & IEEE80211_TX_STATUS_ACK)
-               status = 1;
-       else
-               status = 0;
+       status = !!(info->flags & IEEE80211_TX_STAT_ACK);
 
        /* If type matches "search" table,
         * add final tx status to "search" history */
@@ -943,10 +930,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
                        tpt = search_tbl->expected_tpt[rs_index];
                else
                        tpt = 0;
-               if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU)
+               if (info->flags & IEEE80211_TX_CTL_AMPDU)
                        rs_collect_tx_data(search_win, rs_index, tpt,
-                                          tx_resp->ampdu_ack_len,
-                                          tx_resp->ampdu_ack_map);
+                                          info->status.ampdu_ack_len,
+                                          info->status.ampdu_ack_map);
                else
                        rs_collect_tx_data(search_win, rs_index, tpt,
                                           1, status);
@@ -959,10 +946,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
                        tpt = curr_tbl->expected_tpt[rs_index];
                else
                        tpt = 0;
-               if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU)
+               if (info->flags & IEEE80211_TX_CTL_AMPDU)
                        rs_collect_tx_data(window, rs_index, tpt,
-                                          tx_resp->ampdu_ack_len,
-                                          tx_resp->ampdu_ack_map);
+                                          info->status.ampdu_ack_len,
+                                          info->status.ampdu_ack_map);
                else
                        rs_collect_tx_data(window, rs_index, tpt,
                                           1, status);
@@ -971,10 +958,10 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
        /* If not searching for new mode, increment success/failed counter
         * ... these help determine when to start searching again */
        if (lq_sta->stay_in_tbl) {
-               if (tx_resp->control.flags & IEEE80211_TXCTL_AMPDU) {
-                       lq_sta->total_success += tx_resp->ampdu_ack_map;
+               if (info->flags & IEEE80211_TX_CTL_AMPDU) {
+                       lq_sta->total_success += info->status.ampdu_ack_map;
                        lq_sta->total_failed +=
-                            (tx_resp->ampdu_ack_len - tx_resp->ampdu_ack_map);
+                            (info->status.ampdu_ack_len - info->status.ampdu_ack_map);
                } else {
                        if (status)
                                lq_sta->total_success++;
@@ -1053,7 +1040,6 @@ static void rs_set_expected_tpt_table(struct iwl4965_lq_sta *lq_sta,
                tbl->expected_tpt = expected_tpt_G;
 }
 
-#ifdef CONFIG_IWL4965_HT
 /*
  * Find starting rate for new "search" high-throughput mode of modulation.
  * Goal is to find lowest expected rate (under perfect conditions) that is
@@ -1148,7 +1134,6 @@ static s32 rs_get_best_rate(struct iwl_priv *priv,
 
                        /* Higher rate not available, use the original */
                        } else {
-                               new_rate = rate;
                                break;
                        }
                }
@@ -1156,12 +1141,10 @@ static s32 rs_get_best_rate(struct iwl_priv *priv,
 
        return new_rate;
 }
-#endif                         /* CONFIG_IWL4965_HT */
 
 /*
  * Set up search table for MIMO
  */
-#ifdef CONFIG_IWL4965_HT
 static int rs_switch_to_mimo2(struct iwl_priv *priv,
                             struct iwl4965_lq_sta *lq_sta,
                             struct ieee80211_conf *conf,
@@ -1225,16 +1208,6 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
                     tbl->current_rate, is_green);
        return 0;
 }
-#else
-static int rs_switch_to_mimo2(struct iwl_priv *priv,
-                            struct iwl4965_lq_sta *lq_sta,
-                            struct ieee80211_conf *conf,
-                            struct sta_info *sta,
-                            struct iwl4965_scale_tbl_info *tbl, int index)
-{
-       return -1;
-}
-#endif /*CONFIG_IWL4965_HT */
 
 /*
  * Set up search table for SISO
@@ -1245,7 +1218,6 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
                             struct sta_info *sta,
                             struct iwl4965_scale_tbl_info *tbl, int index)
 {
-#ifdef CONFIG_IWL4965_HT
        u16 rate_mask;
        u8 is_green = lq_sta->is_green;
        s32 rate;
@@ -1295,9 +1267,6 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
        IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n",
                     tbl->current_rate, is_green);
        return 0;
-#else
-       return -1;
-#endif /*CONFIG_IWL4965_HT */
 }
 
 /*
@@ -1339,7 +1308,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
                                lq_sta->search_better_tbl = 1;
                                goto out;
                        }
-
+                       break;
                case IWL_LEGACY_SWITCH_SISO:
                        IWL_DEBUG_RATE("LQ: Legacy switch to SISO\n");
 
@@ -1425,9 +1394,9 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
                                lq_sta->search_better_tbl = 1;
                                goto out;
                        }
-
+                       break;
                case IWL_SISO_SWITCH_MIMO2:
-                       IWL_DEBUG_RATE("LQ: SISO switch to MIMO\n");
+                       IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n");
                        memcpy(search_tbl, tbl, sz);
                        search_tbl->is_SGI = 0;
                        search_tbl->ant_type = ANT_AB; /*FIXME:RS*/
@@ -1682,7 +1651,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        int high_tpt = IWL_INVALID_VALUE;
        u32 fail_count;
        s8 scale_action = 0;
-       u16 fc, rate_mask;
+       __le16 fc;
+       u16 rate_mask;
        u8 update_lq = 0;
        struct iwl4965_lq_sta *lq_sta;
        struct iwl4965_scale_tbl_info *tbl, *tbl1;
@@ -1692,13 +1662,12 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        u8 active_tbl = 0;
        u8 done_search = 0;
        u16 high_low;
-#ifdef CONFIG_IWL4965_HT
+       s32 sr;
        u8 tid = MAX_TID_COUNT;
-#endif
 
        IWL_DEBUG_RATE("rate scale calculate new rate for skb\n");
 
-       fc = le16_to_cpu(hdr->frame_control);
+       fc = hdr->frame_control;
        if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) {
                /* Send management frames and broadcast/multicast data using
                 * lowest rate. */
@@ -1715,9 +1684,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        }
        lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv;
 
-#ifdef CONFIG_IWL4965_HT
-       rs_tl_add_packet(lq_sta, hdr);
-#endif
+       tid = rs_tl_add_packet(lq_sta, hdr);
+
        /*
         * Select rate-scale / modulation-mode table to work with in
         * the rest of this function:  "search" if searching for better
@@ -1845,8 +1813,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                        tbl = &(lq_sta->lq_info[active_tbl]);
 
                        /* Revert to "active" rate and throughput info */
-                       index = iwl4965_hwrate_to_plcp_idx(
-                                                       tbl->current_rate);
+                       index = iwl_hwrate_to_plcp_idx(tbl->current_rate);
                        current_tpt = lq_sta->last_tpt;
 
                        /* Need to set up a new rate table in uCode */
@@ -1867,6 +1834,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        low = high_low & 0xff;
        high = (high_low >> 8) & 0xff;
 
+       sr = window->success_ratio;
+
        /* Collect measured throughputs for current and adjacent rates */
        current_tpt = window->average_tpt;
        if (low != IWL_RATE_INVALID)
@@ -1874,19 +1843,22 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        if (high != IWL_RATE_INVALID)
                high_tpt = tbl->win[high].average_tpt;
 
-       /* Assume rate increase */
-       scale_action = 1;
+       scale_action = 0;
 
        /* Too many failures, decrease rate */
-       if ((window->success_ratio <= IWL_RATE_DECREASE_TH) ||
-           (current_tpt == 0)) {
+       if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) {
                IWL_DEBUG_RATE("decrease rate because of low success_ratio\n");
                scale_action = -1;
 
        /* No throughput measured yet for adjacent rates; try increase. */
        } else if ((low_tpt == IWL_INVALID_VALUE) &&
-                  (high_tpt == IWL_INVALID_VALUE))
-               scale_action = 1;
+                  (high_tpt == IWL_INVALID_VALUE)) {
+
+               if (high != IWL_RATE_INVALID && sr >= IWL_RATE_INCREASE_TH)
+                       scale_action = 1;
+               else if (low != IWL_RATE_INVALID)
+                       scale_action = -1;
+       }
 
        /* Both adjacent throughputs are measured, but neither one has better
         * throughput; we're using the best rate, don't change it! */
@@ -1902,9 +1874,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                /* Higher adjacent rate's throughput is measured */
                if (high_tpt != IWL_INVALID_VALUE) {
                        /* Higher rate has better throughput */
-                       if (high_tpt > current_tpt)
+                       if (high_tpt > current_tpt &&
+                                       sr >= IWL_RATE_INCREASE_TH) {
                                scale_action = 1;
-                       else {
+                       else {
                                IWL_DEBUG_RATE
                                    ("decrease rate because of high tpt\n");
                                scale_action = -1;
@@ -1917,23 +1890,17 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                                IWL_DEBUG_RATE
                                    ("decrease rate because of low tpt\n");
                                scale_action = -1;
-                       } else
+                       } else if (sr >= IWL_RATE_INCREASE_TH) {
                                scale_action = 1;
+                       }
                }
        }
 
        /* Sanity check; asked for decrease, but success rate or throughput
         * has been good at old rate.  Don't change it. */
-       if (scale_action == -1) {
-               if ((low != IWL_RATE_INVALID) &&
-                   ((window->success_ratio > IWL_RATE_HIGH_TH) ||
+       if ((scale_action == -1) && (low != IWL_RATE_INVALID) &&
+                   ((sr > IWL_RATE_HIGH_TH) ||
                     (current_tpt > (100 * tbl->expected_tpt[low]))))
-                       scale_action = 0;
-
-       /* Sanity check; asked for increase, but success rate has not been great
-        * even at old rate, higher rate will be worse.  Don't change it. */
-       } else if ((scale_action == 1) &&
-                  (window->success_ratio < IWL_RATE_INCREASE_TH))
                scale_action = 0;
 
        switch (scale_action) {
@@ -1962,7 +1929,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                    "high %d type %d\n",
                     index, scale_action, low, high, tbl->lq_type);
 
- lq_update:
+lq_update:
        /* Replace uCode's rate table for the destination station. */
        if (update_lq) {
                rate = rate_n_flags_from_tbl(tbl, index, is_green);
@@ -1979,7 +1946,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
         * 2)  Not just finishing up a search
         * 3)  Allowing a new search
         */
-       if (!update_lq && !done_search && !lq_sta->stay_in_tbl) {
+       if (!update_lq && !done_search && !lq_sta->stay_in_tbl && window->counter) {
                /* Save current throughput to compare with "search" throughput*/
                lq_sta->last_tpt = current_tpt;
 
@@ -2000,8 +1967,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                                rs_rate_scale_clear_window(&(tbl->win[i]));
 
                        /* Use new "search" start rate */
-                       index = iwl4965_hwrate_to_plcp_idx(
-                                                       tbl->current_rate);
+                       index = iwl_hwrate_to_plcp_idx(tbl->current_rate);
 
                        IWL_DEBUG_RATE("Switch current  mcs: %X index: %d\n",
                                     tbl->current_rate, index);
@@ -2016,9 +1982,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                 * before next round of mode comparisons. */
                tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
                if (is_legacy(tbl1->lq_type) &&
-#ifdef CONFIG_IWL4965_HT
                   (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE)) &&
-#endif
                    (lq_sta->action_counter >= 1)) {
                        lq_sta->action_counter = 0;
                        IWL_DEBUG_RATE("LQ: STAY in legacy table\n");
@@ -2030,14 +1994,12 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
                 * mode for a while before next round of mode comparisons. */
                if (lq_sta->enable_counter &&
                    (lq_sta->action_counter >= IWL_ACTION_LIMIT)) {
-#ifdef CONFIG_IWL4965_HT
                        if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) &&
                            (lq_sta->tx_agg_tid_en & (1 << tid)) &&
                            (tid != MAX_TID_COUNT)) {
                                IWL_DEBUG_RATE("try to aggregate tid %d\n", tid);
                                rs_tl_turn_on_agg(priv, tid, lq_sta, sta);
                        }
-#endif /*CONFIG_IWL4965_HT */
                        lq_sta->action_counter = 0;
                        rs_set_stay_in_table(priv, 0, lq_sta);
                }
@@ -2139,7 +2101,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
        struct ieee80211_conf *conf = &local->hw.conf;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        struct sta_info *sta;
-       u16 fc;
+       __le16 fc;
        struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
        struct iwl4965_lq_sta *lq_sta;
 
@@ -2151,10 +2113,10 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
 
        /* Send management frames and broadcast/multicast data using lowest
         * rate. */
-       fc = le16_to_cpu(hdr->frame_control);
+       fc = hdr->frame_control;
        if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
            !sta || !sta->rate_ctrl_priv) {
-               sel->rate = rate_lowest(local, sband, sta);
+               sel->rate_idx = rate_lowest_index(local, sband, sta);
                goto out;
        }
 
@@ -2184,11 +2146,13 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
 
 done:
        if ((i < 0) || (i > IWL_RATE_COUNT)) {
-               sel->rate = rate_lowest(local, sband, sta);
+               sel->rate_idx = rate_lowest_index(local, sband, sta);
                goto out;
        }
 
-       sel->rate = &priv->ieee_rates[i];
+       if (sband->band == IEEE80211_BAND_5GHZ)
+               i -= IWL_FIRST_OFDM_RATE;
+       sel->rate_idx = i;
 out:
        rcu_read_unlock();
 }
@@ -2280,30 +2244,23 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
        lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000);
        lq_sta->active_rate_basic = priv->active_rate_basic;
        lq_sta->band = priv->band;
-#ifdef CONFIG_IWL4965_HT
        /*
         * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3),
         * supp_rates[] does not; shift to convert format, force 9 MBits off.
         */
-       lq_sta->active_siso_rate =
-               priv->current_ht_config.supp_mcs_set[0] << 1;
-       lq_sta->active_siso_rate |=
-               priv->current_ht_config.supp_mcs_set[0] & 0x1;
+       lq_sta->active_siso_rate = conf->ht_conf.supp_mcs_set[0] << 1;
+       lq_sta->active_siso_rate |= conf->ht_conf.supp_mcs_set[0] & 0x1;
        lq_sta->active_siso_rate &= ~((u16)0x2);
        lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE;
 
        /* Same here */
-       lq_sta->active_mimo2_rate =
-               priv->current_ht_config.supp_mcs_set[1] << 1;
-       lq_sta->active_mimo2_rate |=
-               priv->current_ht_config.supp_mcs_set[1] & 0x1;
+       lq_sta->active_mimo2_rate = conf->ht_conf.supp_mcs_set[1] << 1;
+       lq_sta->active_mimo2_rate |= conf->ht_conf.supp_mcs_set[1] & 0x1;
        lq_sta->active_mimo2_rate &= ~((u16)0x2);
        lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE;
 
-       lq_sta->active_mimo3_rate =
-               priv->current_ht_config.supp_mcs_set[2] << 1;
-       lq_sta->active_mimo3_rate |=
-               priv->current_ht_config.supp_mcs_set[2] & 0x1;
+       lq_sta->active_mimo3_rate = conf->ht_conf.supp_mcs_set[2] << 1;
+       lq_sta->active_mimo3_rate |= conf->ht_conf.supp_mcs_set[2] & 0x1;
        lq_sta->active_mimo3_rate &= ~((u16)0x2);
        lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE;
 
@@ -2318,7 +2275,6 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
 
        /* as default allow aggregation for all tids */
        lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID;
-#endif /*CONFIG_IWL4965_HT*/
 #ifdef CONFIG_MAC80211_DEBUGFS
        lq_sta->drv = priv;
 #endif
@@ -2444,6 +2400,7 @@ static void rs_fill_link_cmd(const struct iwl_priv *priv,
                repeat_rate--;
        }
 
+       lq_cmd->agg_params.agg_frame_cnt_limit = 64;
        lq_cmd->agg_params.agg_dis_start_th = 3;
        lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000);
 }
@@ -2635,11 +2592,9 @@ static void rs_add_debugfs(void *priv, void *priv_sta,
        lq_sta->rs_sta_dbgfs_stats_table_file =
                debugfs_create_file("rate_stats_table", 0600, dir,
                        lq_sta, &rs_sta_dbgfs_stats_table_ops);
-#ifdef CONFIG_IWL4965_HT
        lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file =
                debugfs_create_u8("tx_agg_tid_enable", 0600, dir,
                &lq_sta->tx_agg_tid_en);
-#endif
 
 }
 
@@ -2648,9 +2603,7 @@ static void rs_remove_debugfs(void *priv, void *priv_sta)
        struct iwl4965_lq_sta *lq_sta = priv_sta;
        debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file);
        debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
-#ifdef CONFIG_IWL4965_HT
        debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file);
-#endif
 }
 #endif