]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
mac80211: move txrate_idx into RC algorithms
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 11 Sep 2008 01:04:36 +0000 (03:04 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Sep 2008 20:48:24 +0000 (16:48 -0400)
The sta_info->txrate_idx member isn't used by all RC algorithms
in the way it was intended to be used, move it into those that
require it (only PID) and keep track in the core code of which
rate was last used for reporting to userspace and the mesh MLME.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath9k/rc.c
drivers/net/wireless/iwlwifi/iwl-3945-rs.c
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
net/mac80211/mesh_hwmp.c
net/mac80211/rc80211_pid.h
net/mac80211/rc80211_pid_algo.c
net/mac80211/sta_info.h
net/mac80211/tx.c
net/mac80211/wext.c

index 226d70c73fe65f6300538ef02f642498da654629..1cc9daf44550aac38cc231beb4e029a03c67c9de 100644 (file)
@@ -2039,7 +2039,6 @@ static void ath_rate_init(void *priv, void *priv_sta,
        DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
 
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-       sta->txrate_idx = rate_lowest_index(local, sband, sta);
 
        ath_setup_rates(local, sta);
        if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
index f751b909759228b3e80462b3f293b4b6e6715480..a279bf1dc9b034d6a49f86f98d8d9b6d133cb740 100644 (file)
@@ -334,13 +334,11 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
 
        for (i = IWL_RATE_COUNT - 1; i >= 0; i--) {
                if (sta->sta.supp_rates[local->hw.conf.channel->band] & (1 << i)) {
-                       sta->txrate_idx = i;
+                       rs_sta->last_txrate_idx = i;
                        break;
                }
        }
 
-       rs_sta->last_txrate_idx = sta->txrate_idx;
-
        /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */
        if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ)
                rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
@@ -809,15 +807,13 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
 
        rs_sta->last_txrate_idx = index;
        if (sband->band == IEEE80211_BAND_5GHZ)
-               sta->txrate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE;
+               sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE;
        else
-               sta->txrate_idx = rs_sta->last_txrate_idx;
+               sel->rate_idx = rs_sta->last_txrate_idx;
 
        rcu_read_unlock();
 
        IWL_DEBUG_RATE("leave: %d\n", index);
-
-       sel->rate_idx = sta->txrate_idx;
 }
 
 static struct rate_control_ops rs_ops = {
index f7191a9a7fb7f240251540fe453cf86f9ddc445d..a8711c314e6ac17224aab47a60aa7271baf97f89 100644 (file)
@@ -2064,14 +2064,6 @@ out:
        i = index;
        lq_sta->last_txrate_idx = i;
 
-       /* sta->txrate_idx is an index to A mode rates which start
-        * at IWL_FIRST_OFDM_RATE
-        */
-       if (lq_sta->band == IEEE80211_BAND_5GHZ)
-               sta->txrate_idx = i - IWL_FIRST_OFDM_RATE;
-       else
-               sta->txrate_idx = i;
-
        return;
 }
 
@@ -2234,7 +2226,6 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
 
        lq_sta->flush_timer = 0;
        lq_sta->supp_rates = sta->sta.supp_rates[sband->band];
-       sta->txrate_idx = 3;
        for (j = 0; j < LQ_SIZE; j++)
                for (i = 0; i < IWL_RATE_COUNT; i++)
                        rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
@@ -2269,11 +2260,11 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
        }
 
        /* Find highest tx rate supported by hardware and destination station */
+       lq_sta->last_txrate_idx = 3;
        for (i = 0; i < sband->n_bitrates; i++)
                if (sta->sta.supp_rates[sband->band] & BIT(i))
-                       sta->txrate_idx = i;
+                       lq_sta->last_txrate_idx = i;
 
-       lq_sta->last_txrate_idx = sta->txrate_idx;
        /* For MODE_IEEE80211A, skip over cck rates in global rate table */
        if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ)
                lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
index 15a5c99270a815149311931e11077ffdc1a702bc..501c7831adb4469627c8b7cd0a8c3b067478ff3b 100644 (file)
@@ -223,7 +223,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
        /* bitrate is in units of 100 Kbps, while we need rate in units of
         * 1Mbps. This will be corrected on tx_time computation.
         */
-       rate = sband->bitrates[sta->txrate_idx].bitrate;
+       rate = sband->bitrates[sta->last_txrate_idx].bitrate;
        tx_time = (device_constant + 10 * test_frame_len / rate);
        estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
        result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
index 0a9135b974b5d11817f60534338d272dd249aef1..ffafc5da572ec83f624a80a4b9fbd521cdfc3b26 100644 (file)
@@ -180,6 +180,8 @@ struct rc_pid_sta_info {
        u32 tx_num_failed;
        u32 tx_num_xmit;
 
+       int txrate_idx;
+
        /* Average failed frames percentage error (i.e. actual vs. target
         * percentage), scaled by RC_PID_SMOOTHING. This value is computed
         * using using an exponential weighted average technique:
index 24e44f52130217a7837304c9d89861fe1d150a5a..bc1c4569caa18c12557e94aef051e54436816a4c 100644 (file)
@@ -75,7 +75,8 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_supported_band *sband;
        int cur_sorted, new_sorted, probe, tmp, n_bitrates, band;
-       int cur = sta->txrate_idx;
+       struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv;
+       int cur = spinfo->txrate_idx;
 
        sdata = sta->sdata;
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
@@ -111,7 +112,7 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
        /* Fit the rate found to the nearest supported rate. */
        do {
                if (rate_supported(sta, band, rinfo[tmp].index)) {
-                       sta->txrate_idx = rinfo[tmp].index;
+                       spinfo->txrate_idx = rinfo[tmp].index;
                        break;
                }
                if (adj < 0)
@@ -121,9 +122,9 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
        } while (tmp < n_bitrates && tmp >= 0);
 
 #ifdef CONFIG_MAC80211_DEBUGFS
-       rate_control_pid_event_rate_change(
-               &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events,
-               sta->txrate_idx, sband->bitrates[sta->txrate_idx].bitrate);
+       rate_control_pid_event_rate_change(&spinfo->events,
+               spinfo->txrate_idx,
+               sband->bitrates[spinfo->txrate_idx].bitrate);
 #endif
 }
 
@@ -190,16 +191,16 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
        spinfo->tx_num_failed = 0;
 
        /* If we just switched rate, update the rate behaviour info. */
-       if (pinfo->oldrate != sta->txrate_idx) {
+       if (pinfo->oldrate != spinfo->txrate_idx) {
 
                i = rinfo[pinfo->oldrate].rev_index;
-               j = rinfo[sta->txrate_idx].rev_index;
+               j = rinfo[spinfo->txrate_idx].rev_index;
 
                tmp = (pf - spinfo->last_pf);
                tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT);
 
                rinfo[j].diff = rinfo[i].diff + tmp;
-               pinfo->oldrate = sta->txrate_idx;
+               pinfo->oldrate = spinfo->txrate_idx;
        }
        rate_control_pid_normalize(pinfo, sband->n_bitrates);
 
@@ -252,19 +253,20 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,
        if (!sta)
                goto unlock;
 
+       spinfo = sta->rate_ctrl_priv;
+
        /* Don't update the state if we're not controlling the rate. */
        sdata = sta->sdata;
        if (sdata->force_unicast_rateidx > -1) {
-               sta->txrate_idx = sdata->max_ratectrl_rateidx;
+               spinfo->txrate_idx = sdata->max_ratectrl_rateidx;
                goto unlock;
        }
 
        /* Ignore all frames that were sent with a different rate than the rate
         * we currently advise mac80211 to use. */
-       if (info->tx_rate_idx != sta->txrate_idx)
+       if (info->tx_rate_idx != spinfo->txrate_idx)
                goto unlock;
 
-       spinfo = sta->rate_ctrl_priv;
        spinfo->tx_num_xmit++;
 
 #ifdef CONFIG_MAC80211_DEBUGFS
@@ -301,6 +303,7 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct ieee80211_sub_if_data *sdata;
+       struct rc_pid_sta_info *spinfo;
        struct sta_info *sta;
        int rateidx;
        u16 fc;
@@ -321,10 +324,11 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
 
        /* If a forced rate is in effect, select it. */
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       spinfo = (struct rc_pid_sta_info *)sta->rate_ctrl_priv;
        if (sdata->force_unicast_rateidx > -1)
-               sta->txrate_idx = sdata->force_unicast_rateidx;
+               spinfo->txrate_idx = sdata->force_unicast_rateidx;
 
-       rateidx = sta->txrate_idx;
+       rateidx = spinfo->txrate_idx;
 
        if (rateidx >= sband->n_bitrates)
                rateidx = sband->n_bitrates - 1;
@@ -349,9 +353,10 @@ static void rate_control_pid_rate_init(void *priv, void *priv_sta,
         * Until that method is implemented, we will use the lowest supported
         * rate as a workaround. */
        struct ieee80211_supported_band *sband;
+       struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv;
 
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
-       sta->txrate_idx = rate_lowest_index(local, sband, sta);
+       spinfo->txrate_idx = rate_lowest_index(local, sband, sta);
        sta->fail_avg = 0;
 }
 
index 4dafa044b2f27e3d529f99e01b501362a4da6b55..5d8fabf7a68ba90f4de12bb392e47353bdafba18 100644 (file)
@@ -274,7 +274,7 @@ struct sta_info {
        unsigned long tx_packets;
        unsigned long tx_bytes;
        unsigned long tx_fragments;
-       int txrate_idx;
+       unsigned int last_txrate_idx;
        u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
        unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
index 07bf228d0b16859740c23c0d3e21d5f4528988f1..7468495d6f9ce943b7b0cbb661182605dd180310 100644 (file)
@@ -485,6 +485,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
 
        if (likely(tx->rate_idx < 0)) {
                rate_control_get_rate(tx->dev, sband, tx->skb, &rsel);
+               if (tx->sta)
+                       tx->sta->last_txrate_idx = rsel.rate_idx;
                tx->rate_idx = rsel.rate_idx;
                if (unlikely(rsel.probe_idx >= 0)) {
                        info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
index aef9707700fd5f1e0cb24d0b035e6477196d3421..7e0d53abde24bb9e10b86e55d1112b76eaa63331 100644 (file)
@@ -636,8 +636,8 @@ static int ieee80211_ioctl_giwrate(struct net_device *dev,
 
        sta = sta_info_get(local, sdata->u.sta.bssid);
 
-       if (sta && sta->txrate_idx < sband->n_bitrates)
-               rate->value = sband->bitrates[sta->txrate_idx].bitrate;
+       if (sta && sta->last_txrate_idx < sband->n_bitrates)
+               rate->value = sband->bitrates[sta->last_txrate_idx].bitrate;
        else
                rate->value = 0;