aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-10 21:04:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-15 16:48:24 -0400
commitae17e986091637e7ef5a8224c7b689029b105131 (patch)
tree184fb207b36348f4ac989831b3425d9d67221e02 /net/mac80211
parent323ce79a9cdbf838ea577677b1ddace8e0b4d4c6 (diff)
mac80211: move txrate_idx into RC algorithms
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>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/rc80211_pid.h2
-rw-r--r--net/mac80211/rc80211_pid_algo.c33
-rw-r--r--net/mac80211/sta_info.h2
-rw-r--r--net/mac80211/tx.c2
-rw-r--r--net/mac80211/wext.c4
6 files changed, 27 insertions, 18 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 15a5c99270a8..501c7831adb4 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -223,7 +223,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
223 /* bitrate is in units of 100 Kbps, while we need rate in units of 223 /* bitrate is in units of 100 Kbps, while we need rate in units of
224 * 1Mbps. This will be corrected on tx_time computation. 224 * 1Mbps. This will be corrected on tx_time computation.
225 */ 225 */
226 rate = sband->bitrates[sta->txrate_idx].bitrate; 226 rate = sband->bitrates[sta->last_txrate_idx].bitrate;
227 tx_time = (device_constant + 10 * test_frame_len / rate); 227 tx_time = (device_constant + 10 * test_frame_len / rate);
228 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); 228 estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err));
229 result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ; 229 result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT) ;
diff --git a/net/mac80211/rc80211_pid.h b/net/mac80211/rc80211_pid.h
index 0a9135b974b5..ffafc5da572e 100644
--- a/net/mac80211/rc80211_pid.h
+++ b/net/mac80211/rc80211_pid.h
@@ -180,6 +180,8 @@ struct rc_pid_sta_info {
180 u32 tx_num_failed; 180 u32 tx_num_failed;
181 u32 tx_num_xmit; 181 u32 tx_num_xmit;
182 182
183 int txrate_idx;
184
183 /* Average failed frames percentage error (i.e. actual vs. target 185 /* Average failed frames percentage error (i.e. actual vs. target
184 * percentage), scaled by RC_PID_SMOOTHING. This value is computed 186 * percentage), scaled by RC_PID_SMOOTHING. This value is computed
185 * using using an exponential weighted average technique: 187 * using using an exponential weighted average technique:
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index 24e44f521302..bc1c4569caa1 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -75,7 +75,8 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
75 struct ieee80211_sub_if_data *sdata; 75 struct ieee80211_sub_if_data *sdata;
76 struct ieee80211_supported_band *sband; 76 struct ieee80211_supported_band *sband;
77 int cur_sorted, new_sorted, probe, tmp, n_bitrates, band; 77 int cur_sorted, new_sorted, probe, tmp, n_bitrates, band;
78 int cur = sta->txrate_idx; 78 struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv;
79 int cur = spinfo->txrate_idx;
79 80
80 sdata = sta->sdata; 81 sdata = sta->sdata;
81 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 82 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,
111 /* Fit the rate found to the nearest supported rate. */ 112 /* Fit the rate found to the nearest supported rate. */
112 do { 113 do {
113 if (rate_supported(sta, band, rinfo[tmp].index)) { 114 if (rate_supported(sta, band, rinfo[tmp].index)) {
114 sta->txrate_idx = rinfo[tmp].index; 115 spinfo->txrate_idx = rinfo[tmp].index;
115 break; 116 break;
116 } 117 }
117 if (adj < 0) 118 if (adj < 0)
@@ -121,9 +122,9 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
121 } while (tmp < n_bitrates && tmp >= 0); 122 } while (tmp < n_bitrates && tmp >= 0);
122 123
123#ifdef CONFIG_MAC80211_DEBUGFS 124#ifdef CONFIG_MAC80211_DEBUGFS
124 rate_control_pid_event_rate_change( 125 rate_control_pid_event_rate_change(&spinfo->events,
125 &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, 126 spinfo->txrate_idx,
126 sta->txrate_idx, sband->bitrates[sta->txrate_idx].bitrate); 127 sband->bitrates[spinfo->txrate_idx].bitrate);
127#endif 128#endif
128} 129}
129 130
@@ -190,16 +191,16 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
190 spinfo->tx_num_failed = 0; 191 spinfo->tx_num_failed = 0;
191 192
192 /* If we just switched rate, update the rate behaviour info. */ 193 /* If we just switched rate, update the rate behaviour info. */
193 if (pinfo->oldrate != sta->txrate_idx) { 194 if (pinfo->oldrate != spinfo->txrate_idx) {
194 195
195 i = rinfo[pinfo->oldrate].rev_index; 196 i = rinfo[pinfo->oldrate].rev_index;
196 j = rinfo[sta->txrate_idx].rev_index; 197 j = rinfo[spinfo->txrate_idx].rev_index;
197 198
198 tmp = (pf - spinfo->last_pf); 199 tmp = (pf - spinfo->last_pf);
199 tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT); 200 tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT);
200 201
201 rinfo[j].diff = rinfo[i].diff + tmp; 202 rinfo[j].diff = rinfo[i].diff + tmp;
202 pinfo->oldrate = sta->txrate_idx; 203 pinfo->oldrate = spinfo->txrate_idx;
203 } 204 }
204 rate_control_pid_normalize(pinfo, sband->n_bitrates); 205 rate_control_pid_normalize(pinfo, sband->n_bitrates);
205 206
@@ -252,19 +253,20 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,
252 if (!sta) 253 if (!sta)
253 goto unlock; 254 goto unlock;
254 255
256 spinfo = sta->rate_ctrl_priv;
257
255 /* Don't update the state if we're not controlling the rate. */ 258 /* Don't update the state if we're not controlling the rate. */
256 sdata = sta->sdata; 259 sdata = sta->sdata;
257 if (sdata->force_unicast_rateidx > -1) { 260 if (sdata->force_unicast_rateidx > -1) {
258 sta->txrate_idx = sdata->max_ratectrl_rateidx; 261 spinfo->txrate_idx = sdata->max_ratectrl_rateidx;
259 goto unlock; 262 goto unlock;
260 } 263 }
261 264
262 /* Ignore all frames that were sent with a different rate than the rate 265 /* Ignore all frames that were sent with a different rate than the rate
263 * we currently advise mac80211 to use. */ 266 * we currently advise mac80211 to use. */
264 if (info->tx_rate_idx != sta->txrate_idx) 267 if (info->tx_rate_idx != spinfo->txrate_idx)
265 goto unlock; 268 goto unlock;
266 269
267 spinfo = sta->rate_ctrl_priv;
268 spinfo->tx_num_xmit++; 270 spinfo->tx_num_xmit++;
269 271
270#ifdef CONFIG_MAC80211_DEBUGFS 272#ifdef CONFIG_MAC80211_DEBUGFS
@@ -301,6 +303,7 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
301 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 303 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
302 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 304 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
303 struct ieee80211_sub_if_data *sdata; 305 struct ieee80211_sub_if_data *sdata;
306 struct rc_pid_sta_info *spinfo;
304 struct sta_info *sta; 307 struct sta_info *sta;
305 int rateidx; 308 int rateidx;
306 u16 fc; 309 u16 fc;
@@ -321,10 +324,11 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
321 324
322 /* If a forced rate is in effect, select it. */ 325 /* If a forced rate is in effect, select it. */
323 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 326 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
327 spinfo = (struct rc_pid_sta_info *)sta->rate_ctrl_priv;
324 if (sdata->force_unicast_rateidx > -1) 328 if (sdata->force_unicast_rateidx > -1)
325 sta->txrate_idx = sdata->force_unicast_rateidx; 329 spinfo->txrate_idx = sdata->force_unicast_rateidx;
326 330
327 rateidx = sta->txrate_idx; 331 rateidx = spinfo->txrate_idx;
328 332
329 if (rateidx >= sband->n_bitrates) 333 if (rateidx >= sband->n_bitrates)
330 rateidx = sband->n_bitrates - 1; 334 rateidx = sband->n_bitrates - 1;
@@ -349,9 +353,10 @@ static void rate_control_pid_rate_init(void *priv, void *priv_sta,
349 * Until that method is implemented, we will use the lowest supported 353 * Until that method is implemented, we will use the lowest supported
350 * rate as a workaround. */ 354 * rate as a workaround. */
351 struct ieee80211_supported_band *sband; 355 struct ieee80211_supported_band *sband;
356 struct rc_pid_sta_info *spinfo = (void *)sta->rate_ctrl_priv;
352 357
353 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 358 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
354 sta->txrate_idx = rate_lowest_index(local, sband, sta); 359 spinfo->txrate_idx = rate_lowest_index(local, sband, sta);
355 sta->fail_avg = 0; 360 sta->fail_avg = 0;
356} 361}
357 362
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 4dafa044b2f2..5d8fabf7a68b 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -274,7 +274,7 @@ struct sta_info {
274 unsigned long tx_packets; 274 unsigned long tx_packets;
275 unsigned long tx_bytes; 275 unsigned long tx_bytes;
276 unsigned long tx_fragments; 276 unsigned long tx_fragments;
277 int txrate_idx; 277 unsigned int last_txrate_idx;
278 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; 278 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
279#ifdef CONFIG_MAC80211_DEBUG_COUNTERS 279#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
280 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES]; 280 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 07bf228d0b16..7468495d6f9c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -485,6 +485,8 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
485 485
486 if (likely(tx->rate_idx < 0)) { 486 if (likely(tx->rate_idx < 0)) {
487 rate_control_get_rate(tx->dev, sband, tx->skb, &rsel); 487 rate_control_get_rate(tx->dev, sband, tx->skb, &rsel);
488 if (tx->sta)
489 tx->sta->last_txrate_idx = rsel.rate_idx;
488 tx->rate_idx = rsel.rate_idx; 490 tx->rate_idx = rsel.rate_idx;
489 if (unlikely(rsel.probe_idx >= 0)) { 491 if (unlikely(rsel.probe_idx >= 0)) {
490 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE; 492 info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index aef9707700fd..7e0d53abde24 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -636,8 +636,8 @@ static int ieee80211_ioctl_giwrate(struct net_device *dev,
636 636
637 sta = sta_info_get(local, sdata->u.sta.bssid); 637 sta = sta_info_get(local, sdata->u.sta.bssid);
638 638
639 if (sta && sta->txrate_idx < sband->n_bitrates) 639 if (sta && sta->last_txrate_idx < sband->n_bitrates)
640 rate->value = sband->bitrates[sta->txrate_idx].bitrate; 640 rate->value = sband->bitrates[sta->last_txrate_idx].bitrate;
641 else 641 else
642 rate->value = 0; 642 rate->value = 0;
643 643