From: Stefano Brivio <stefano.brivio@polimi.it>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: Johannes Berg <johannes@sipsolutions.net>,
Mattias Nissler <mattias.nissler@gmx.de>,
linux-wireless@vger.kernel.org,
Stefano Brivio <stefano.brivio@polimi.it>
Subject: [PATCH v3 5/8] rc80211-pid: add sharpening factor
Date: Wed, 19 Dec 2007 01:26:52 +0100 [thread overview]
Message-ID: <20071219012652.25a45c5e@morte> (raw)
In-Reply-To: <20071219001955.055692620@polimi.it>
This patch introduces a PID sharpening factor for faster response after
association and low activity events.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
---
rc80211_pid.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
Index: wireless-2.6/net/mac80211/rc80211_pid.c
===================================================================
--- wireless-2.6.orig/net/mac80211/rc80211_pid.c
+++ wireless-2.6/net/mac80211/rc80211_pid.c
@@ -23,13 +23,16 @@
*
* The controller basically computes the following:
*
- * adj = CP * err + CI * err_avg + CD * (err - last_err)
+ * adj = CP * err + CI * err_avg + CD * (err - last_err) * (1 + sharpening)
*
* where
* adj adjustment value that is used to switch TX rate (see below)
* err current error: target vs. current failed frames percentage
* last_err last error
* err_avg average (i.e. poor man's integral) of recent errors
+ * sharpening non-zero when fast response is needed (i.e. right after
+ * association or no frames sent for a long time), heading
+ * to zero over time
* CP Proportional coefficient
* CI Integral coefficient
* CD Derivative coefficient
@@ -65,6 +68,10 @@
#define RC_PID_SMOOTHING_SHIFT 3
#define RC_PID_SMOOTHING (1 << RC_PID_SMOOTHING_SHIFT)
+/* Sharpening factor (used for D part of PID controller) */
+#define RC_PID_SHARPENING_FACTOR 0
+#define RC_PID_SHARPENING_DURATION 0
+
/* Fixed point arithmetic shifting amount. */
#define RC_PID_ARITH_SHIFT 8
@@ -131,8 +138,11 @@ struct rc_pid_sta_info {
*/
s32 err_avg_sc;
- /* Last framed failes percentage sample */
+ /* Last framed failes percentage sample. */
u32 last_pf;
+
+ /* Sharpening needed. */
+ u8 sharp_cnt;
};
/* Algorithm parameters. We keep them on a per-algorithm approach, so they can
@@ -267,20 +277,26 @@ static void rate_control_pid_sample(stru
mode = local->oper_hw_mode;
spinfo = sta->rate_ctrl_priv;
+
+ /* In case nothing happened during the previous control interval, turn
+ * the sharpening factor on. */
+ if (jiffies - spinfo->last_sample > 2 * RC_PID_INTERVAL)
+ spinfo->sharp_cnt = RC_PID_SHARPENING_DURATION;
+
spinfo->last_sample = jiffies;
- /* If no frames were transmitted, we assume the old sample is
+ /* This should never happen, but in case, we assume the old sample is
* still a good measurement and copy it. */
- if (spinfo->tx_num_xmit == 0)
+ if (unlikely(spinfo->tx_num_xmit == 0))
pf = spinfo->last_pf;
else {
pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit;
pf <<= RC_PID_ARITH_SHIFT;
-
- spinfo->tx_num_xmit = 0;
- spinfo->tx_num_failed = 0;
}
+ spinfo->tx_num_xmit = 0;
+ spinfo->tx_num_failed = 0;
+
/* If we just switched rate, update the rate behaviour info. */
if (pinfo->oldrate != sta->txrate) {
@@ -302,8 +318,11 @@ static void rate_control_pid_sample(stru
spinfo->err_avg_sc = spinfo->err_avg_sc - err_avg + err_prop;
err_int = spinfo->err_avg_sc >> RC_PID_SMOOTHING_SHIFT;
- err_der = pf - spinfo->last_pf;
+ err_der = pf - spinfo->last_pf
+ * (1 + RC_PID_SHARPENING_FACTOR * spinfo->sharp_cnt);
spinfo->last_pf = pf;
+ if (spinfo->sharp_cnt)
+ spinfo->sharp_cnt--;
/* Compute the controller output. */
adj = (err_prop * pinfo->coeff_p + err_int * pinfo->coeff_i
--
Ciao
Stefano
next prev parent reply other threads:[~2007-12-19 0:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071219001955.055692620@polimi.it>
2007-12-19 0:25 ` [PATCH v3 1/8] mac80211: clean up rate selection Stefano Brivio
2007-12-19 16:42 ` Johannes Berg
2007-12-20 12:50 ` [PATCH v4 " Stefano Brivio
2007-12-19 0:25 ` [PATCH v3 2/8] mac80211: add PID controller based rate control algorithm Stefano Brivio
2007-12-19 0:26 ` [PATCH v3 3/8] mac80211: make PID rate control algorithm the default Stefano Brivio
2007-12-19 0:26 ` [PATCH v3 4/8] rc80211-pid: add rate behaviour learning algorithm Stefano Brivio
2007-12-19 0:26 ` Stefano Brivio [this message]
2007-12-19 0:27 ` [PATCH v3 6/8] rc80211-pid: add debugging Stefano Brivio
2007-12-19 0:27 ` [PATCH v3 7/8] debugfs: allow access to signed values Stefano Brivio
2007-12-19 6:45 ` Greg KH
2007-12-19 9:20 ` Stefano Brivio
2007-12-19 14:29 ` John W. Linville
2007-12-19 9:28 ` [PATCH v4 " Stefano Brivio
2007-12-19 16:00 ` [PATCH v3 " Johannes Berg
2007-12-20 12:15 ` [PATCH v4 " Stefano Brivio
2007-12-20 12:47 ` Arnd Bergmann
2007-12-28 18:58 ` Christoph Hellwig
2007-12-28 19:15 ` Johannes Berg
2007-12-29 18:20 ` Stefano Brivio
2007-12-20 12:40 ` [PATCH v5 " Stefano Brivio
2007-12-20 14:34 ` John W. Linville
2007-12-19 0:27 ` [PATCH v3 8/8] rc80211-pid: export tuning parameters through debugfs Stefano Brivio
2007-12-19 16:49 ` Johannes Berg
2007-12-20 12:27 ` [PATCH v4 " Stefano Brivio
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=20071219012652.25a45c5e@morte \
--to=stefano.brivio@polimi.it \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mattias.nissler@gmx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).