aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/ccid3.c
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/ccid3.c
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/ccid3.c')
-rw-r--r--net/dccp/ccids/ccid3.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 94a322863844..42893b1dfa09 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -192,7 +192,7 @@ static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
192{ 192{
193 const u16 old_s = hctx->ccid3hctx_s; 193 const u16 old_s = hctx->ccid3hctx_s;
194 194
195 hctx->ccid3hctx_s = old_s == 0 ? len : (9 * old_s + len) / 10; 195 hctx->ccid3hctx_s = tfrc_ewma(hctx->ccid3hctx_s, len, 9);
196 196
197 if (hctx->ccid3hctx_s != old_s) 197 if (hctx->ccid3hctx_s != old_s)
198 ccid3_update_send_interval(hctx); 198 ccid3_update_send_interval(hctx);
@@ -449,25 +449,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
449 449
450 now = ktime_get_real(); 450 now = ktime_get_real();
451 /* 451 /*
452 * Calculate new round trip sample as per [RFC 3448, 4.3] by 452 * Calculate new RTT sample and update moving average
453 * R_sample = (now - t_recvdata) - t_elapsed
454 */ 453 */
455 r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, packet->dccphtx_tstamp)); 454 r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, packet->dccphtx_tstamp));
455 hctx->ccid3hctx_rtt = tfrc_ewma(hctx->ccid3hctx_rtt, r_sample, 9);
456 456
457 /*
458 * Update RTT estimate by
459 * If (No feedback recv)
460 * R = R_sample;
461 * Else
462 * R = q * R + (1 - q) * R_sample;
463 *
464 * q is a constant, RFC 3448 recomments 0.9
465 */
466 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) { 457 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) {
467 /* 458 /*
468 * Larger Initial Windows [RFC 4342, sec. 5] 459 * Larger Initial Windows [RFC 4342, sec. 5]
469 */ 460 */
470 hctx->ccid3hctx_rtt = r_sample;
471 hctx->ccid3hctx_x = rfc3390_initial_rate(sk); 461 hctx->ccid3hctx_x = rfc3390_initial_rate(sk);
472 hctx->ccid3hctx_t_ld = now; 462 hctx->ccid3hctx_t_ld = now;
473 463
@@ -481,8 +471,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
481 471
482 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); 472 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
483 } else { 473 } else {
484 hctx->ccid3hctx_rtt = (9 * hctx->ccid3hctx_rtt +
485 r_sample) / 10;
486 474
487 /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ 475 /* Update sending rate (step 4 of [RFC 3448, 4.3]) */
488 if (hctx->ccid3hctx_p > 0) 476 if (hctx->ccid3hctx_p > 0)
@@ -700,11 +688,8 @@ static void ccid3_hc_rx_set_state(struct sock *sk,
700 688
701static inline void ccid3_hc_rx_update_s(struct ccid3_hc_rx_sock *hcrx, int len) 689static inline void ccid3_hc_rx_update_s(struct ccid3_hc_rx_sock *hcrx, int len)
702{ 690{
703 if (unlikely(len == 0)) /* don't update on empty packets (e.g. ACKs) */ 691 if (likely(len > 0)) /* don't update on empty packets (e.g. ACKs) */
704 ccid3_pr_debug("Packet payload length is 0 - not updating\n"); 692 hcrx->ccid3hcrx_s = tfrc_ewma(hcrx->ccid3hcrx_s, len, 9);
705 else
706 hcrx->ccid3hcrx_s = hcrx->ccid3hcrx_s == 0 ? len :
707 (9 * hcrx->ccid3hcrx_s + len) / 10;
708} 693}
709 694
710static void ccid3_hc_rx_send_feedback(struct sock *sk) 695static void ccid3_hc_rx_send_feedback(struct sock *sk)