diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-11-27 17:31:33 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:30:51 -0500 |
commit | 17893bc1a632e195574dc0dd9751243f0d5993d2 (patch) | |
tree | 7c036e23439d1cf5afbc63b147b7d1fbd8345eca /net/dccp | |
parent | 48e03eee715b9e19df03153f2bcce6413632afcb (diff) |
[DCCP] ccid3: Consistently update t_nom, t_ipi, t_delta
This patch:
* consolidates updating of parameters (t_nom, t_ipi, t_delta) which
need to be updated at the same time, since they are inter-dependent
* removes two inline functions which are no longer needed as a result of
the above consolidation
* resolves a FIXME regarding the re-calculation of t_ipi within the nofeedback
timer, in the state where no feedback has previously been received
* ties updating these parameters to updating the sending rate X, exploiting
that all three parameters in turn depend on X; and using a small optimisation
which can reduce the number of required instructions: only update the three
parameters when X really changes
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 9297fca78683..4342caf53251 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -100,19 +100,24 @@ static void ccid3_hc_tx_set_state(struct sock *sk, | |||
100 | hctx->ccid3hctx_state = state; | 100 | hctx->ccid3hctx_state = state; |
101 | } | 101 | } |
102 | 102 | ||
103 | /* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */ | 103 | /* |
104 | static inline void ccid3_calc_new_t_ipi(struct ccid3_hc_tx_sock *hctx) | 104 | * Recalculate scheduled nominal send time t_nom, inter-packet interval |
105 | * t_ipi, and delta value. Should be called after each change to X. | ||
106 | */ | ||
107 | static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx) | ||
105 | { | 108 | { |
109 | timeval_sub_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi); | ||
110 | |||
111 | /* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */ | ||
106 | hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_x); | 112 | hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_x); |
107 | } | ||
108 | 113 | ||
109 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ | 114 | /* Update nominal send time with regard to the new t_ipi */ |
110 | static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) | 115 | timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi); |
111 | { | 116 | |
117 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ | ||
112 | hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, | 118 | hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, |
113 | TFRC_OPSYS_HALF_TIME_GRAN); | 119 | TFRC_OPSYS_HALF_TIME_GRAN); |
114 | } | 120 | } |
115 | |||
116 | /* | 121 | /* |
117 | * Update X by | 122 | * Update X by |
118 | * If (p > 0) | 123 | * If (p > 0) |
@@ -126,6 +131,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) | |||
126 | static void ccid3_hc_tx_update_x(struct sock *sk) | 131 | static void ccid3_hc_tx_update_x(struct sock *sk) |
127 | { | 132 | { |
128 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 133 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); |
134 | const __u32 old_x = hctx->ccid3hctx_x; | ||
129 | 135 | ||
130 | /* To avoid large error in calcX */ | 136 | /* To avoid large error in calcX */ |
131 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { | 137 | if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { |
@@ -149,6 +155,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
149 | hctx->ccid3hctx_t_ld = now; | 155 | hctx->ccid3hctx_t_ld = now; |
150 | } | 156 | } |
151 | } | 157 | } |
158 | if (hctx->ccid3hctx_x != old_x) | ||
159 | ccid3_update_send_time(hctx); | ||
152 | } | 160 | } |
153 | 161 | ||
154 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | 162 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) |
@@ -184,11 +192,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
184 | /* The value of R is still undefined and so we can not recompute | 192 | /* The value of R is still undefined and so we can not recompute |
185 | * the timout value. Keep initial value as per [RFC 4342, 5]. */ | 193 | * the timout value. Keep initial value as per [RFC 4342, 5]. */ |
186 | next_tmout = TFRC_INITIAL_TIMEOUT; | 194 | next_tmout = TFRC_INITIAL_TIMEOUT; |
187 | /* | 195 | ccid3_update_send_time(hctx); |
188 | * FIXME - not sure above calculation is correct. See section | ||
189 | * 5 of CCID3 11 should adjust tx_t_ipi and double that to | ||
190 | * achieve it really | ||
191 | */ | ||
192 | break; | 196 | break; |
193 | case TFRC_SSTATE_FBACK: | 197 | case TFRC_SSTATE_FBACK: |
194 | /* | 198 | /* |
@@ -479,17 +483,9 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
479 | /* unschedule no feedback timer */ | 483 | /* unschedule no feedback timer */ |
480 | sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer); | 484 | sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer); |
481 | 485 | ||
482 | /* Update sending rate */ | 486 | /* Update sending rate (and likely t_ipi, t_nom, and delta) */ |
483 | ccid3_hc_tx_update_x(sk); | 487 | ccid3_hc_tx_update_x(sk); |
484 | 488 | ||
485 | /* Update next send time */ | ||
486 | timeval_sub_usecs(&hctx->ccid3hctx_t_nom, | ||
487 | hctx->ccid3hctx_t_ipi); | ||
488 | ccid3_calc_new_t_ipi(hctx); | ||
489 | timeval_add_usecs(&hctx->ccid3hctx_t_nom, | ||
490 | hctx->ccid3hctx_t_ipi); | ||
491 | ccid3_calc_new_delta(hctx); | ||
492 | |||
493 | /* remove all packets older than the one acked from history */ | 489 | /* remove all packets older than the one acked from history */ |
494 | dccp_tx_hist_purge_older(ccid3_tx_hist, | 490 | dccp_tx_hist_purge_older(ccid3_tx_hist, |
495 | &hctx->ccid3hctx_hist, packet); | 491 | &hctx->ccid3hctx_hist, packet); |