diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-08-10 03:03:31 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:56:18 -0400 |
commit | 6687e988d9aeaccad6774e6a8304f681f3ec0a03 (patch) | |
tree | ecd3d28f9989847aa1dcde4782de0210aeadc290 /net/ipv4/tcp_hybla.c | |
parent | 64ce207306debd7157f47282be94770407bec01c (diff) |
[ICSK]: Move TCP congestion avoidance members to icsk
This changeset basically moves tcp_sk()->{ca_ops,ca_state,etc} to inet_csk(),
minimal renaming/moving done in this changeset to ease review.
Most of it is just changes of struct tcp_sock * to struct sock * parameters.
With this we move to a state closer to two interesting goals:
1. Generalisation of net/ipv4/tcp_diag.c, becoming inet_diag.c, being used
for any INET transport protocol that has struct inet_hashinfo and are
derived from struct inet_connection_sock. Keeps the userspace API, that will
just not display DCCP sockets, while newer versions of tools can support
DCCP.
2. INET generic transport pluggable Congestion Avoidance infrastructure, using
the current TCP CA infrastructure with DCCP.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_hybla.c')
-rw-r--r-- | net/ipv4/tcp_hybla.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/net/ipv4/tcp_hybla.c b/net/ipv4/tcp_hybla.c index 13a66342c304..77add63623df 100644 --- a/net/ipv4/tcp_hybla.c +++ b/net/ipv4/tcp_hybla.c | |||
@@ -33,19 +33,20 @@ MODULE_PARM_DESC(rtt0, "reference rout trip time (ms)"); | |||
33 | 33 | ||
34 | 34 | ||
35 | /* This is called to refresh values for hybla parameters */ | 35 | /* This is called to refresh values for hybla parameters */ |
36 | static inline void hybla_recalc_param (struct tcp_sock *tp) | 36 | static inline void hybla_recalc_param (struct sock *sk) |
37 | { | 37 | { |
38 | struct hybla *ca = tcp_ca(tp); | 38 | struct hybla *ca = inet_csk_ca(sk); |
39 | 39 | ||
40 | ca->rho_3ls = max_t(u32, tp->srtt / msecs_to_jiffies(rtt0), 8); | 40 | ca->rho_3ls = max_t(u32, tcp_sk(sk)->srtt / msecs_to_jiffies(rtt0), 8); |
41 | ca->rho = ca->rho_3ls >> 3; | 41 | ca->rho = ca->rho_3ls >> 3; |
42 | ca->rho2_7ls = (ca->rho_3ls * ca->rho_3ls) << 1; | 42 | ca->rho2_7ls = (ca->rho_3ls * ca->rho_3ls) << 1; |
43 | ca->rho2 = ca->rho2_7ls >>7; | 43 | ca->rho2 = ca->rho2_7ls >>7; |
44 | } | 44 | } |
45 | 45 | ||
46 | static void hybla_init(struct tcp_sock *tp) | 46 | static void hybla_init(struct sock *sk) |
47 | { | 47 | { |
48 | struct hybla *ca = tcp_ca(tp); | 48 | struct tcp_sock *tp = tcp_sk(sk); |
49 | struct hybla *ca = inet_csk_ca(sk); | ||
49 | 50 | ||
50 | ca->rho = 0; | 51 | ca->rho = 0; |
51 | ca->rho2 = 0; | 52 | ca->rho2 = 0; |
@@ -57,17 +58,16 @@ static void hybla_init(struct tcp_sock *tp) | |||
57 | tp->snd_cwnd_clamp = 65535; | 58 | tp->snd_cwnd_clamp = 65535; |
58 | 59 | ||
59 | /* 1st Rho measurement based on initial srtt */ | 60 | /* 1st Rho measurement based on initial srtt */ |
60 | hybla_recalc_param(tp); | 61 | hybla_recalc_param(sk); |
61 | 62 | ||
62 | /* set minimum rtt as this is the 1st ever seen */ | 63 | /* set minimum rtt as this is the 1st ever seen */ |
63 | ca->minrtt = tp->srtt; | 64 | ca->minrtt = tp->srtt; |
64 | tp->snd_cwnd = ca->rho; | 65 | tp->snd_cwnd = ca->rho; |
65 | } | 66 | } |
66 | 67 | ||
67 | static void hybla_state(struct tcp_sock *tp, u8 ca_state) | 68 | static void hybla_state(struct sock *sk, u8 ca_state) |
68 | { | 69 | { |
69 | struct hybla *ca = tcp_ca(tp); | 70 | struct hybla *ca = inet_csk_ca(sk); |
70 | |||
71 | ca->hybla_en = (ca_state == TCP_CA_Open); | 71 | ca->hybla_en = (ca_state == TCP_CA_Open); |
72 | } | 72 | } |
73 | 73 | ||
@@ -86,27 +86,28 @@ static inline u32 hybla_fraction(u32 odds) | |||
86 | * o Give cwnd a new value based on the model proposed | 86 | * o Give cwnd a new value based on the model proposed |
87 | * o remember increments <1 | 87 | * o remember increments <1 |
88 | */ | 88 | */ |
89 | static void hybla_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt, | 89 | static void hybla_cong_avoid(struct sock *sk, u32 ack, u32 rtt, |
90 | u32 in_flight, int flag) | 90 | u32 in_flight, int flag) |
91 | { | 91 | { |
92 | struct hybla *ca = tcp_ca(tp); | 92 | struct tcp_sock *tp = tcp_sk(sk); |
93 | struct hybla *ca = inet_csk_ca(sk); | ||
93 | u32 increment, odd, rho_fractions; | 94 | u32 increment, odd, rho_fractions; |
94 | int is_slowstart = 0; | 95 | int is_slowstart = 0; |
95 | 96 | ||
96 | /* Recalculate rho only if this srtt is the lowest */ | 97 | /* Recalculate rho only if this srtt is the lowest */ |
97 | if (tp->srtt < ca->minrtt){ | 98 | if (tp->srtt < ca->minrtt){ |
98 | hybla_recalc_param(tp); | 99 | hybla_recalc_param(sk); |
99 | ca->minrtt = tp->srtt; | 100 | ca->minrtt = tp->srtt; |
100 | } | 101 | } |
101 | 102 | ||
102 | if (!ca->hybla_en) | 103 | if (!ca->hybla_en) |
103 | return tcp_reno_cong_avoid(tp, ack, rtt, in_flight, flag); | 104 | return tcp_reno_cong_avoid(sk, ack, rtt, in_flight, flag); |
104 | 105 | ||
105 | if (in_flight < tp->snd_cwnd) | 106 | if (in_flight < tp->snd_cwnd) |
106 | return; | 107 | return; |
107 | 108 | ||
108 | if (ca->rho == 0) | 109 | if (ca->rho == 0) |
109 | hybla_recalc_param(tp); | 110 | hybla_recalc_param(sk); |
110 | 111 | ||
111 | rho_fractions = ca->rho_3ls - (ca->rho << 3); | 112 | rho_fractions = ca->rho_3ls - (ca->rho << 3); |
112 | 113 | ||
@@ -170,7 +171,7 @@ static struct tcp_congestion_ops tcp_hybla = { | |||
170 | 171 | ||
171 | static int __init hybla_register(void) | 172 | static int __init hybla_register(void) |
172 | { | 173 | { |
173 | BUG_ON(sizeof(struct hybla) > TCP_CA_PRIV_SIZE); | 174 | BUG_ON(sizeof(struct hybla) > ICSK_CA_PRIV_SIZE); |
174 | return tcp_register_congestion_control(&tcp_hybla); | 175 | return tcp_register_congestion_control(&tcp_hybla); |
175 | } | 176 | } |
176 | 177 | ||