From: Stefano Brivio <stefano.brivio@polimi.it>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: Chris Clayton <chris2553@googlemail.com>,
ivdoorn@gmail.com, linux-kernel@vger.kernel.org,
linux-wireless@vger.kernel.org, johannes@sipsolutions.net,
Mattias Nissler <mattias.nissler@gmx.de>,
Mike Kelly <pioto@pioto.org>
Subject: Re: 2.6.25-rc2 regression in rt61pci wireless driver
Date: Sun, 2 Mar 2008 11:33:10 +0100 [thread overview]
Message-ID: <20080302113310.7acbe9b3@morte> (raw)
In-Reply-To: <20080227172546.GD3078@tuxdriver.com>
On Wed, 27 Feb 2008 12:25:46 -0500
"John W. Linville" <linville@tuxdriver.com> wrote:
> That might be easier said than done. It looks like that patch depends
> on the big cfg80211 API change queued for 2.6.26.
>
> Stefano offered to rebase that on 2.6.25. Stefano, could you post
> that as part of this thread?
Sorry for the delay. This is based on 2.6.25-rc3. Please test.
---
Merge rate_control_pid_shift_adjust() to rate_control_pid_adjust_rate()
in order to make the learning algorithm aware of constraints on rates. Also
add some comments and rename variables.
This fixes a bug which prevented 802.11b/g non-AP STAs from working with
802.11b only AP STAs.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
---
Index: linux-2.6.24/net/mac80211/rc80211_pid_algo.c
===================================================================
--- linux-2.6.24.orig/net/mac80211/rc80211_pid_algo.c
+++ linux-2.6.24/net/mac80211/rc80211_pid_algo.c
@@ -2,7 +2,7 @@
* Copyright 2002-2005, Instant802 Networks, Inc.
* Copyright 2005, Devicescape Software, Inc.
* Copyright 2007, Mattias Nissler <mattias.nissler@gmx.de>
- * Copyright 2007, Stefano Brivio <stefano.brivio@polimi.it>
+ * Copyright 2007-2008, Stefano Brivio <stefano.brivio@polimi.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -63,72 +63,66 @@
* RC_PID_ARITH_SHIFT.
*/
-
-/* Shift the adjustment so that we won't switch to a lower rate if it exhibited
- * a worse failed frames behaviour and we'll choose the highest rate whose
- * failed frames behaviour is not worse than the one of the original rate
- * target. While at it, check that the adjustment is within the ranges. Then,
- * provide the new rate index. */
-static int rate_control_pid_shift_adjust(struct rc_pid_rateinfo *r,
- int adj, int cur, int l)
-{
- int i, j, k, tmp;
-
- j = r[cur].rev_index;
- i = j + adj;
-
- if (i < 0)
- return r[0].index;
- if (i >= l - 1)
- return r[l - 1].index;
-
- tmp = i;
-
- if (adj < 0) {
- for (k = j; k >= i; k--)
- if (r[k].diff <= r[j].diff)
- tmp = k;
- } else {
- for (k = i + 1; k + i < l; k++)
- if (r[k].diff <= r[i].diff)
- tmp = k;
- }
-
- return r[tmp].index;
-}
-
+/* Adjust the rate while ensuring that we won't switch to a lower rate if it
+ * exhibited a worse failed frames behaviour and we'll choose the highest rate
+ * whose failed frames behaviour is not worse than the one of the original rate
+ * target. While at it, check that the new rate is valid. */
static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
struct sta_info *sta, int adj,
struct rc_pid_rateinfo *rinfo)
{
struct ieee80211_sub_if_data *sdata;
struct ieee80211_hw_mode *mode;
- int newidx;
- int maxrate;
- int back = (adj > 0) ? 1 : -1;
+ int cur_sorted, new_sorted, probe, tmp, n_bitrates;
+ int cur = sta->txrate;
sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
mode = local->oper_hw_mode;
- maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1;
+ n_bitrates = mode->num_rates;
- newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate,
- mode->num_rates);
+ /* Map passed arguments to sorted values. */
+ cur_sorted = rinfo[cur].rev_index;
+ new_sorted = cur_sorted + adj;
+
+ /* Check limits. */
+ if (new_sorted < 0)
+ new_sorted = rinfo[0].rev_index;
+ else if (new_sorted >= n_bitrates)
+ new_sorted = rinfo[n_bitrates - 1].rev_index;
- while (newidx != sta->txrate) {
- if (rate_supported(sta, mode, newidx) &&
- (maxrate < 0 || newidx <= maxrate)) {
- sta->txrate = newidx;
- break;
- }
+ tmp = new_sorted;
- newidx += back;
+ if (adj < 0) {
+ /* Ensure that the rate decrease isn't disadvantageous. */
+ for (probe = cur_sorted; probe >= new_sorted; probe--)
+ if (rinfo[probe].diff <= rinfo[cur_sorted].diff &&
+ rate_supported(sta, mode, rinfo[probe].index))
+ tmp = probe;
+ } else {
+ /* Look for rate increase with zero (or below) cost. */
+ for (probe = new_sorted + 1; probe < n_bitrates; probe++)
+ if (rinfo[probe].diff <= rinfo[new_sorted].diff &&
+ rate_supported(sta, mode, rinfo[probe].index))
+ tmp = probe;
}
+ /* Fit the rate found to the nearest supported rate. */
+ do {
+ if (rate_supported(sta, mode, rinfo[tmp].index)) {
+ sta->txrate = rinfo[tmp].index;
+ break;
+ }
+ if (adj < 0)
+ tmp--;
+ else
+ tmp++;
+ } 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,
- newidx, mode->rates[newidx].rate);
+ cur, mode->rates[cur].rate);
#endif
}
--
Ciao
Stefano
next prev parent reply other threads:[~2008-03-02 10:48 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-16 12:06 2.6.25-rc2 regression in rt61pci wireless driver Chris Clayton
2008-02-18 18:11 ` Ivo van Doorn
2008-02-18 18:16 ` Ivo van Doorn
2008-02-18 22:51 ` Chris Clayton
2008-02-19 9:26 ` Ivo van Doorn
2008-02-19 19:00 ` Chris Clayton
2008-02-19 19:46 ` Ivo van Doorn
2008-02-19 20:44 ` Chris Clayton
2008-02-19 21:03 ` Ivo van Doorn
2008-02-19 23:04 ` [Rt2400-devel] " Chris Vine
2008-02-20 16:05 ` Dan Williams
2008-02-20 20:27 ` Chris Vine
2008-02-20 20:50 ` Ivo van Doorn
2008-02-20 21:16 ` Chris Vine
2008-02-21 21:07 ` Chris Vine
2008-02-21 21:51 ` Ivo van Doorn
2008-02-21 22:46 ` Chris Vine
2008-02-21 22:51 ` Ivo van Doorn
2008-02-21 23:04 ` Chris Clayton
2008-02-21 23:20 ` Chris Vine
2008-02-22 7:39 ` Chris Clayton
2008-02-22 19:11 ` Ivo van Doorn
2008-02-22 20:33 ` Chris Vine
2008-02-20 22:13 ` Chris Clayton
2008-02-22 15:46 ` Chris Clayton
2008-02-22 19:47 ` Ivo van Doorn
2008-02-25 21:04 ` Chris Clayton
2008-02-25 22:09 ` Ivo Van Doorn
2008-02-26 19:11 ` Chris Clayton
2008-02-26 19:48 ` John W. Linville
2008-02-26 20:30 ` Ivo Van Doorn
2008-02-26 21:44 ` Stefano Brivio
2008-02-26 21:13 ` Chris Clayton
2008-02-26 21:38 ` Stefano Brivio
2008-02-26 22:36 ` Chris Clayton
2008-02-27 7:26 ` Stefano Brivio
2008-02-27 15:51 ` John W. Linville
2008-02-27 17:25 ` John W. Linville
2008-02-27 17:45 ` Chris Clayton
2008-03-02 10:33 ` Stefano Brivio [this message]
2008-03-02 15:11 ` Chris Clayton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080302113310.7acbe9b3@morte \
--to=stefano.brivio@polimi.it \
--cc=chris2553@googlemail.com \
--cc=ivdoorn@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mattias.nissler@gmx.de \
--cc=pioto@pioto.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.