Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[pandora-kernel.git] / drivers / net / wireless / iwlwifi / iwl-4965-rs.c
index a928741..3ccb84a 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"
 
@@ -273,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];
 
@@ -300,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);
@@ -317,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;
 }
 
 /*
@@ -534,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;
@@ -791,7 +794,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
        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");
@@ -819,9 +822,6 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
 
        lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv;
 
-       if (!priv->lq_mngr.lq_ready)
-               goto out;
-
        if ((priv->iw_mode == IEEE80211_IF_TYPE_IBSS) &&
            !lq_sta->ibss_sta_added)
                goto out;
@@ -1648,7 +1648,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;
@@ -1663,7 +1664,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
 
        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. */
@@ -1674,13 +1675,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
        if (!sta || !sta->rate_ctrl_priv)
                return;
 
-       if (!priv->lq_mngr.lq_ready) {
-               IWL_DEBUG_RATE("still rate scaling not ready\n");
-               return;
-       }
        lq_sta = (struct iwl4965_lq_sta *)sta->rate_ctrl_priv;
 
-       rs_tl_add_packet(lq_sta, hdr);
+       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
@@ -1808,8 +1806,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 */
@@ -1963,8 +1960,7 @@ lq_update:
                                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);
@@ -2098,7 +2094,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;
 
@@ -2110,7 +2106,7 @@ 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_idx = rate_lowest_index(local, sband, sta);
@@ -2137,11 +2133,8 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
                        lq_sta->ibss_sta_added = 1;
                        rs_initialize_lq(priv, conf, sta);
                }
-               if (!lq_sta->ibss_sta_added)
-                       goto done;
        }
 
-done:
        if ((i < 0) || (i > IWL_RATE_COUNT)) {
                sel->rate_idx = rate_lowest_index(local, sband, sta);
                goto out;
@@ -2272,12 +2265,7 @@ 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;
-#ifdef CONFIG_MAC80211_DEBUGFS
        lq_sta->drv = priv;
-#endif
-
-       if (priv->assoc_station_added)
-               priv->lq_mngr.lq_ready = 1;
 
        rs_initialize_lq(priv, conf, sta);
 }
@@ -2418,7 +2406,7 @@ static void rs_clear(void *priv_rate)
 
        IWL_DEBUG_RATE("enter\n");
 
-       priv->lq_mngr.lq_ready = 0;
+       /* TODO - add rate scale state reset */
 
        IWL_DEBUG_RATE("leave\n");
 }
@@ -2713,13 +2701,6 @@ int iwl4965_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id)
        return cnt;
 }
 
-void iwl4965_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
-{
-       struct iwl_priv *priv = hw->priv;
-
-       priv->lq_mngr.lq_ready = 1;
-}
-
 int iwl4965_rate_control_register(void)
 {
        return ieee80211_rate_control_register(&rs_ops);