aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/lib
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-11-20 15:09:59 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:54:43 -0500
commitc3ada46a009001e144b29736880962f24ee2afdf (patch)
treea475095e2ef5bff2f0d94a24ca94776578fe1c75 /net/dccp/ccids/lib
parenta5358fdc9c52e44d79dcd144375e089e166508d7 (diff)
[CCID3]: Inline for moving average
The moving average computation occurs so frequently in the CCID 3 code that it merits an inline function of its own. This is uses a suggestion by Arnaldo as per http://www.mail-archive.com/dccp@vger.kernel.org/msg01662.html Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ccids/lib')
-rw-r--r--net/dccp/ccids/lib/tfrc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index faf5f7e219e3..5a0ba86df183 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -37,6 +37,15 @@ static inline u32 scaled_div32(u64 a, u32 b)
37 return result; 37 return result;
38} 38}
39 39
40/**
41 * tfrc_ewma - Exponentially weighted moving average
42 * @weight: Weight to be used as damping factor, in units of 1/10
43 */
44static inline u32 tfrc_ewma(const u32 avg, const u32 newval, const u8 weight)
45{
46 return avg ? (weight * avg + (10 - weight) * newval) / 10 : newval;
47}
48
40extern u32 tfrc_calc_x(u16 s, u32 R, u32 p); 49extern u32 tfrc_calc_x(u16 s, u32 R, u32 p);
41extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue); 50extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue);
42 51