linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Brivio <stefano.brivio@polimi.it>
To: linux-wireless <linux-wireless@vger.kernel.org>,
	Mattias Nissler <mattias.nissler@gmx.de>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	Johannes Berg <johannes@sipsolutions.net>
Subject: [RFC/T][PATCH 2/3] rc80211-pid: introduce PID sharpening factor
Date: Sun, 9 Dec 2007 21:21:33 +0100	[thread overview]
Message-ID: <20071209212133.43030d03@morte> (raw)
In-Reply-To: <20071209211547.2d7fca32@morte>

This patch introduces a PID sharpening factor for faster response on
association and interpolation.


Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>

---

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,15 @@
  *
  * 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 interpolation), heading to zero over time
  * 	CP	Proportional coefficient
  * 	CI	Integral coefficient
  * 	CD	Derivative coefficient
@@ -65,6 +67,11 @@
 #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 RATE_CONTROL_SHARPENING_SHIFT 2
+#define RATE_CONTROL_SHARPENING (1 << RATE_CONTROL_SHARPENING_SHIFT)
+#define RATE_CONTROL_SHARPENING_DURATION 1
+
 /* Fixed point arithmetic shifting amount. */
 #define RC_PID_ARITH_SHIFT 8
 
@@ -127,8 +134,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
@@ -271,10 +281,12 @@ static void rate_control_pid_sample(stru
 	spinfo->last_sample = jiffies;
 
 	/* If no frames were transmitted, we assume the old sample is
-	 * still a good measurement and copy it. */
-	if (spinfo->tx_num_xmit == 0)
+	 * still a good measurement and copy it, and turn the sharpening factor
+	 * on. */
+	if (spinfo->tx_num_xmit == 0) {
 		pf = spinfo->last_pf;
-	else {
+		spinfo->sharp_cnt = RATE_CONTROL_SHARPENING_DURATION;
+	} else {
 		pf = spinfo->tx_num_failed * 100 / spinfo->tx_num_xmit;
 		pf <<= RC_PID_ARITH_SHIFT;
 
@@ -314,8 +326,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 + RATE_CONTROL_SHARPENING * 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

  parent reply	other threads:[~2007-12-09 20:27 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-09 20:15 [RFC/T][PATCH 0/3] rc80211-pid: PID controller enhancements Stefano Brivio
2007-12-09 20:19 ` [RFC/T][PATCH 1/3] rc80211-pid: introduce rate behaviour learning algorithm Stefano Brivio
2007-12-09 22:25   ` Mattias Nissler
2007-12-09 23:21     ` Stefano Brivio
2007-12-10  0:17       ` Stefano Brivio
2007-12-10  2:24       ` [RFC/T][PATCH v2 " Stefano Brivio
2007-12-10  6:51         ` Mattias Nissler
2007-12-10  7:23           ` Stefano Brivio
2007-12-11 23:29           ` [RFC/T][PATCH v3 " Stefano Brivio
2007-12-12  0:25             ` [RFC/T][PATCH v4 " Stefano Brivio
2007-12-10  6:48       ` [RFC/T][PATCH " Mattias Nissler
2007-12-10  8:03         ` Stefano Brivio
2007-12-10 20:48           ` Mattias Nissler
2007-12-10 20:56           ` Mattias Nissler
2007-12-10 21:30             ` Stefano Brivio
2007-12-10 22:05               ` Mattias Nissler
2007-12-10  8:08     ` Stefano Brivio
2007-12-10 20:51       ` Mattias Nissler
2007-12-10 21:22         ` Stefano Brivio
2007-12-10 21:31           ` st3
2007-12-10 22:09           ` Mattias Nissler
2007-12-11 14:52         ` Johannes Berg
2007-12-11 17:23           ` Mattias Nissler
2007-12-12 17:13             ` Johannes Berg
2007-12-12 20:06               ` Mattias Nissler
2007-12-12 21:34                 ` Stefano Brivio
2007-12-13 11:42                 ` Johannes Berg
2007-12-14  5:27                   ` Jouni Malinen
2007-12-14 12:09                     ` Johannes Berg
2007-12-13  8:00             ` Holger Schurig
2007-12-11 14:51       ` Johannes Berg
2007-12-09 20:21 ` Stefano Brivio [this message]
2007-12-09 22:29   ` [RFC/T][PATCH 2/3] rc80211-pid: introduce PID sharpening factor Mattias Nissler
2007-12-09 23:31     ` Stefano Brivio
2007-12-09 23:53       ` Mattias Nissler
2007-12-10  2:28         ` [RFC/T][PATCH v2 " Stefano Brivio
2007-12-10  6:28           ` Mattias Nissler
2007-12-10  7:21             ` Stefano Brivio
2007-12-10  7:44               ` Mattias Nissler
2007-12-10  8:17                 ` Stefano Brivio
2007-12-11 23:31                 ` [RFC/T][PATCH v3 " Stefano Brivio
2007-12-09 20:28 ` [RFC/T][PATCH 3/3] rc80211-pid: allow for parameters to be set through sysfs Stefano Brivio
2007-12-09 22:30   ` Mattias Nissler
2007-12-10  2:31     ` [RFC/T][PATCH v2 " Stefano Brivio
2007-12-16  9:40   ` [RFC/T][PATCH " 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=20071209212133.43030d03@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).