diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2009-10-04 20:53:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-07 16:51:24 -0400 |
commit | 996ccf49005662ee7fee38a45be5cb27bf370b1d (patch) | |
tree | 5aeea073a9e399ca7536f03f23dc48860047687a /net/dccp | |
parent | 77d2dd93742222973d253443d98ab8402d641038 (diff) |
dccp ccid-3: Remove CCID naming redundancy 2/2
This continues the previous patch, by applying the same change to CCID-3.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 371 | ||||
-rw-r--r-- | net/dccp/probe.c | 12 |
2 files changed, 191 insertions, 192 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 6b8d67ba7fe7..bcd7632299f5 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -64,14 +64,14 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) | |||
64 | static void ccid3_hc_tx_set_state(struct sock *sk, | 64 | static void ccid3_hc_tx_set_state(struct sock *sk, |
65 | enum ccid3_hc_tx_states state) | 65 | enum ccid3_hc_tx_states state) |
66 | { | 66 | { |
67 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 67 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
68 | enum ccid3_hc_tx_states oldstate = hctx->tx_state; | 68 | enum ccid3_hc_tx_states oldstate = hc->tx_state; |
69 | 69 | ||
70 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 70 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
71 | dccp_role(sk), sk, ccid3_tx_state_name(oldstate), | 71 | dccp_role(sk), sk, ccid3_tx_state_name(oldstate), |
72 | ccid3_tx_state_name(state)); | 72 | ccid3_tx_state_name(state)); |
73 | WARN_ON(state == oldstate); | 73 | WARN_ON(state == oldstate); |
74 | hctx->tx_state = state; | 74 | hc->tx_state = state; |
75 | } | 75 | } |
76 | 76 | ||
77 | /* | 77 | /* |
@@ -85,32 +85,32 @@ static void ccid3_hc_tx_set_state(struct sock *sk, | |||
85 | */ | 85 | */ |
86 | static inline u64 rfc3390_initial_rate(struct sock *sk) | 86 | static inline u64 rfc3390_initial_rate(struct sock *sk) |
87 | { | 87 | { |
88 | const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 88 | const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
89 | const __u32 w_init = clamp_t(__u32, 4380U, 2 * hctx->tx_s, 4 * hctx->tx_s); | 89 | const __u32 w_init = clamp_t(__u32, 4380U, 2 * hc->tx_s, 4 * hc->tx_s); |
90 | 90 | ||
91 | return scaled_div(w_init << 6, hctx->tx_rtt); | 91 | return scaled_div(w_init << 6, hc->tx_rtt); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * Recalculate t_ipi and delta (should be called whenever X changes) | 95 | * Recalculate t_ipi and delta (should be called whenever X changes) |
96 | */ | 96 | */ |
97 | static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx) | 97 | static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hc) |
98 | { | 98 | { |
99 | /* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */ | 99 | /* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */ |
100 | hctx->tx_t_ipi = scaled_div32(((u64)hctx->tx_s) << 6, hctx->tx_x); | 100 | hc->tx_t_ipi = scaled_div32(((u64)hc->tx_s) << 6, hc->tx_x); |
101 | 101 | ||
102 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ | 102 | /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ |
103 | hctx->tx_delta = min_t(u32, hctx->tx_t_ipi / 2, TFRC_OPSYS_HALF_TIME_GRAN); | 103 | hc->tx_delta = min_t(u32, hc->tx_t_ipi / 2, TFRC_OPSYS_HALF_TIME_GRAN); |
104 | 104 | ||
105 | ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n", hctx->tx_t_ipi, | 105 | ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n", hc->tx_t_ipi, |
106 | hctx->tx_delta, hctx->tx_s, (unsigned)(hctx->tx_x >> 6)); | 106 | hc->tx_delta, hc->tx_s, (unsigned)(hc->tx_x >> 6)); |
107 | } | 107 | } |
108 | 108 | ||
109 | static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hctx, ktime_t now) | 109 | static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hc, ktime_t now) |
110 | { | 110 | { |
111 | u32 delta = ktime_us_delta(now, hctx->tx_t_last_win_count); | 111 | u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count); |
112 | 112 | ||
113 | return delta / hctx->tx_rtt; | 113 | return delta / hc->tx_rtt; |
114 | } | 114 | } |
115 | 115 | ||
116 | /** | 116 | /** |
@@ -125,9 +125,9 @@ static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hctx, ktime_t now) | |||
125 | */ | 125 | */ |
126 | static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp) | 126 | static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp) |
127 | { | 127 | { |
128 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 128 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
129 | __u64 min_rate = 2 * hctx->tx_x_recv; | 129 | __u64 min_rate = 2 * hc->tx_x_recv; |
130 | const __u64 old_x = hctx->tx_x; | 130 | const __u64 old_x = hc->tx_x; |
131 | ktime_t now = stamp ? *stamp : ktime_get_real(); | 131 | ktime_t now = stamp ? *stamp : ktime_get_real(); |
132 | 132 | ||
133 | /* | 133 | /* |
@@ -136,31 +136,31 @@ static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp) | |||
136 | * a sender is idle if it has not sent anything over a 2-RTT-period. | 136 | * a sender is idle if it has not sent anything over a 2-RTT-period. |
137 | * For consistency with X and X_recv, min_rate is also scaled by 2^6. | 137 | * For consistency with X and X_recv, min_rate is also scaled by 2^6. |
138 | */ | 138 | */ |
139 | if (ccid3_hc_tx_idle_rtt(hctx, now) >= 2) { | 139 | if (ccid3_hc_tx_idle_rtt(hc, now) >= 2) { |
140 | min_rate = rfc3390_initial_rate(sk); | 140 | min_rate = rfc3390_initial_rate(sk); |
141 | min_rate = max(min_rate, 2 * hctx->tx_x_recv); | 141 | min_rate = max(min_rate, 2 * hc->tx_x_recv); |
142 | } | 142 | } |
143 | 143 | ||
144 | if (hctx->tx_p > 0) { | 144 | if (hc->tx_p > 0) { |
145 | 145 | ||
146 | hctx->tx_x = min(((__u64)hctx->tx_x_calc) << 6, min_rate); | 146 | hc->tx_x = min(((__u64)hc->tx_x_calc) << 6, min_rate); |
147 | hctx->tx_x = max(hctx->tx_x, (((__u64)hctx->tx_s) << 6) / TFRC_T_MBI); | 147 | hc->tx_x = max(hc->tx_x, (((__u64)hc->tx_s) << 6) / TFRC_T_MBI); |
148 | 148 | ||
149 | } else if (ktime_us_delta(now, hctx->tx_t_ld) - (s64)hctx->tx_rtt >= 0) { | 149 | } else if (ktime_us_delta(now, hc->tx_t_ld) - (s64)hc->tx_rtt >= 0) { |
150 | 150 | ||
151 | hctx->tx_x = min(2 * hctx->tx_x, min_rate); | 151 | hc->tx_x = min(2 * hc->tx_x, min_rate); |
152 | hctx->tx_x = max(hctx->tx_x, scaled_div(((__u64)hctx->tx_s) << 6, | 152 | hc->tx_x = max(hc->tx_x, |
153 | hctx->tx_rtt)); | 153 | scaled_div(((__u64)hc->tx_s) << 6, hc->tx_rtt)); |
154 | hctx->tx_t_ld = now; | 154 | hc->tx_t_ld = now; |
155 | } | 155 | } |
156 | 156 | ||
157 | if (hctx->tx_x != old_x) { | 157 | if (hc->tx_x != old_x) { |
158 | ccid3_pr_debug("X_prev=%u, X_now=%u, X_calc=%u, " | 158 | ccid3_pr_debug("X_prev=%u, X_now=%u, X_calc=%u, " |
159 | "X_recv=%u\n", (unsigned)(old_x >> 6), | 159 | "X_recv=%u\n", (unsigned)(old_x >> 6), |
160 | (unsigned)(hctx->tx_x >> 6), hctx->tx_x_calc, | 160 | (unsigned)(hc->tx_x >> 6), hc->tx_x_calc, |
161 | (unsigned)(hctx->tx_x_recv >> 6)); | 161 | (unsigned)(hc->tx_x_recv >> 6)); |
162 | 162 | ||
163 | ccid3_update_send_interval(hctx); | 163 | ccid3_update_send_interval(hc); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
@@ -168,37 +168,37 @@ static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp) | |||
168 | * Track the mean packet size `s' (cf. RFC 4342, 5.3 and RFC 3448, 4.1) | 168 | * Track the mean packet size `s' (cf. RFC 4342, 5.3 and RFC 3448, 4.1) |
169 | * @len: DCCP packet payload size in bytes | 169 | * @len: DCCP packet payload size in bytes |
170 | */ | 170 | */ |
171 | static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len) | 171 | static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hc, int len) |
172 | { | 172 | { |
173 | const u16 old_s = hctx->tx_s; | 173 | const u16 old_s = hc->tx_s; |
174 | 174 | ||
175 | hctx->tx_s = tfrc_ewma(hctx->tx_s, len, 9); | 175 | hc->tx_s = tfrc_ewma(hc->tx_s, len, 9); |
176 | 176 | ||
177 | if (hctx->tx_s != old_s) | 177 | if (hc->tx_s != old_s) |
178 | ccid3_update_send_interval(hctx); | 178 | ccid3_update_send_interval(hc); |
179 | } | 179 | } |
180 | 180 | ||
181 | /* | 181 | /* |
182 | * Update Window Counter using the algorithm from [RFC 4342, 8.1]. | 182 | * Update Window Counter using the algorithm from [RFC 4342, 8.1]. |
183 | * As elsewhere, RTT > 0 is assumed by using dccp_sample_rtt(). | 183 | * As elsewhere, RTT > 0 is assumed by using dccp_sample_rtt(). |
184 | */ | 184 | */ |
185 | static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hctx, | 185 | static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hc, |
186 | ktime_t now) | 186 | ktime_t now) |
187 | { | 187 | { |
188 | u32 delta = ktime_us_delta(now, hctx->tx_t_last_win_count), | 188 | u32 delta = ktime_us_delta(now, hc->tx_t_last_win_count), |
189 | quarter_rtts = (4 * delta) / hctx->tx_rtt; | 189 | quarter_rtts = (4 * delta) / hc->tx_rtt; |
190 | 190 | ||
191 | if (quarter_rtts > 0) { | 191 | if (quarter_rtts > 0) { |
192 | hctx->tx_t_last_win_count = now; | 192 | hc->tx_t_last_win_count = now; |
193 | hctx->tx_last_win_count += min(quarter_rtts, 5U); | 193 | hc->tx_last_win_count += min(quarter_rtts, 5U); |
194 | hctx->tx_last_win_count &= 0xF; /* mod 16 */ | 194 | hc->tx_last_win_count &= 0xF; /* mod 16 */ |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | 198 | static void ccid3_hc_tx_no_feedback_timer(unsigned long data) |
199 | { | 199 | { |
200 | struct sock *sk = (struct sock *)data; | 200 | struct sock *sk = (struct sock *)data; |
201 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 201 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
202 | unsigned long t_nfb = USEC_PER_SEC / 5; | 202 | unsigned long t_nfb = USEC_PER_SEC / 5; |
203 | 203 | ||
204 | bh_lock_sock(sk); | 204 | bh_lock_sock(sk); |
@@ -209,23 +209,23 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | ccid3_pr_debug("%s(%p, state=%s) - entry \n", dccp_role(sk), sk, | 211 | ccid3_pr_debug("%s(%p, state=%s) - entry \n", dccp_role(sk), sk, |
212 | ccid3_tx_state_name(hctx->tx_state)); | 212 | ccid3_tx_state_name(hc->tx_state)); |
213 | 213 | ||
214 | if (hctx->tx_state == TFRC_SSTATE_FBACK) | 214 | if (hc->tx_state == TFRC_SSTATE_FBACK) |
215 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); | 215 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); |
216 | else if (hctx->tx_state != TFRC_SSTATE_NO_FBACK) | 216 | else if (hc->tx_state != TFRC_SSTATE_NO_FBACK) |
217 | goto out; | 217 | goto out; |
218 | 218 | ||
219 | /* | 219 | /* |
220 | * Determine new allowed sending rate X as per draft rfc3448bis-00, 4.4 | 220 | * Determine new allowed sending rate X as per draft rfc3448bis-00, 4.4 |
221 | */ | 221 | */ |
222 | if (hctx->tx_t_rto == 0 || /* no feedback received yet */ | 222 | if (hc->tx_t_rto == 0 || /* no feedback received yet */ |
223 | hctx->tx_p == 0) { | 223 | hc->tx_p == 0) { |
224 | 224 | ||
225 | /* halve send rate directly */ | 225 | /* halve send rate directly */ |
226 | hctx->tx_x = max(hctx->tx_x / 2, | 226 | hc->tx_x = max(hc->tx_x / 2, |
227 | (((__u64)hctx->tx_s) << 6) / TFRC_T_MBI); | 227 | (((__u64)hc->tx_s) << 6) / TFRC_T_MBI); |
228 | ccid3_update_send_interval(hctx); | 228 | ccid3_update_send_interval(hc); |
229 | } else { | 229 | } else { |
230 | /* | 230 | /* |
231 | * Modify the cached value of X_recv | 231 | * Modify the cached value of X_recv |
@@ -237,33 +237,32 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
237 | * | 237 | * |
238 | * Note that X_recv is scaled by 2^6 while X_calc is not | 238 | * Note that X_recv is scaled by 2^6 while X_calc is not |
239 | */ | 239 | */ |
240 | BUG_ON(hctx->tx_p && !hctx->tx_x_calc); | 240 | BUG_ON(hc->tx_p && !hc->tx_x_calc); |
241 | 241 | ||
242 | if (hctx->tx_x_calc > (hctx->tx_x_recv >> 5)) | 242 | if (hc->tx_x_calc > (hc->tx_x_recv >> 5)) |
243 | hctx->tx_x_recv = | 243 | hc->tx_x_recv = |
244 | max(hctx->tx_x_recv / 2, | 244 | max(hc->tx_x_recv / 2, |
245 | (((__u64)hctx->tx_s) << 6) / | 245 | (((__u64)hc->tx_s) << 6) / (2*TFRC_T_MBI)); |
246 | (2 * TFRC_T_MBI)); | ||
247 | else { | 246 | else { |
248 | hctx->tx_x_recv = hctx->tx_x_calc; | 247 | hc->tx_x_recv = hc->tx_x_calc; |
249 | hctx->tx_x_recv <<= 4; | 248 | hc->tx_x_recv <<= 4; |
250 | } | 249 | } |
251 | ccid3_hc_tx_update_x(sk, NULL); | 250 | ccid3_hc_tx_update_x(sk, NULL); |
252 | } | 251 | } |
253 | ccid3_pr_debug("Reduced X to %llu/64 bytes/sec\n", | 252 | ccid3_pr_debug("Reduced X to %llu/64 bytes/sec\n", |
254 | (unsigned long long)hctx->tx_x); | 253 | (unsigned long long)hc->tx_x); |
255 | 254 | ||
256 | /* | 255 | /* |
257 | * Set new timeout for the nofeedback timer. | 256 | * Set new timeout for the nofeedback timer. |
258 | * See comments in packet_recv() regarding the value of t_RTO. | 257 | * See comments in packet_recv() regarding the value of t_RTO. |
259 | */ | 258 | */ |
260 | if (unlikely(hctx->tx_t_rto == 0)) /* no feedback yet */ | 259 | if (unlikely(hc->tx_t_rto == 0)) /* no feedback yet */ |
261 | t_nfb = TFRC_INITIAL_TIMEOUT; | 260 | t_nfb = TFRC_INITIAL_TIMEOUT; |
262 | else | 261 | else |
263 | t_nfb = max(hctx->tx_t_rto, 2 * hctx->tx_t_ipi); | 262 | t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi); |
264 | 263 | ||
265 | restart_timer: | 264 | restart_timer: |
266 | sk_reset_timer(sk, &hctx->tx_no_feedback_timer, | 265 | sk_reset_timer(sk, &hc->tx_no_feedback_timer, |
267 | jiffies + usecs_to_jiffies(t_nfb)); | 266 | jiffies + usecs_to_jiffies(t_nfb)); |
268 | out: | 267 | out: |
269 | bh_unlock_sock(sk); | 268 | bh_unlock_sock(sk); |
@@ -279,7 +278,7 @@ out: | |||
279 | static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | 278 | static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) |
280 | { | 279 | { |
281 | struct dccp_sock *dp = dccp_sk(sk); | 280 | struct dccp_sock *dp = dccp_sk(sk); |
282 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 281 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
283 | ktime_t now = ktime_get_real(); | 282 | ktime_t now = ktime_get_real(); |
284 | s64 delay; | 283 | s64 delay; |
285 | 284 | ||
@@ -291,17 +290,17 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
291 | if (unlikely(skb->len == 0)) | 290 | if (unlikely(skb->len == 0)) |
292 | return -EBADMSG; | 291 | return -EBADMSG; |
293 | 292 | ||
294 | switch (hctx->tx_state) { | 293 | switch (hc->tx_state) { |
295 | case TFRC_SSTATE_NO_SENT: | 294 | case TFRC_SSTATE_NO_SENT: |
296 | sk_reset_timer(sk, &hctx->tx_no_feedback_timer, (jiffies + | 295 | sk_reset_timer(sk, &hc->tx_no_feedback_timer, (jiffies + |
297 | usecs_to_jiffies(TFRC_INITIAL_TIMEOUT))); | 296 | usecs_to_jiffies(TFRC_INITIAL_TIMEOUT))); |
298 | hctx->tx_last_win_count = 0; | 297 | hc->tx_last_win_count = 0; |
299 | hctx->tx_t_last_win_count = now; | 298 | hc->tx_t_last_win_count = now; |
300 | 299 | ||
301 | /* Set t_0 for initial packet */ | 300 | /* Set t_0 for initial packet */ |
302 | hctx->tx_t_nom = now; | 301 | hc->tx_t_nom = now; |
303 | 302 | ||
304 | hctx->tx_s = skb->len; | 303 | hc->tx_s = skb->len; |
305 | 304 | ||
306 | /* | 305 | /* |
307 | * Use initial RTT sample when available: recommended by erratum | 306 | * Use initial RTT sample when available: recommended by erratum |
@@ -310,9 +309,9 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
310 | */ | 309 | */ |
311 | if (dp->dccps_syn_rtt) { | 310 | if (dp->dccps_syn_rtt) { |
312 | ccid3_pr_debug("SYN RTT = %uus\n", dp->dccps_syn_rtt); | 311 | ccid3_pr_debug("SYN RTT = %uus\n", dp->dccps_syn_rtt); |
313 | hctx->tx_rtt = dp->dccps_syn_rtt; | 312 | hc->tx_rtt = dp->dccps_syn_rtt; |
314 | hctx->tx_x = rfc3390_initial_rate(sk); | 313 | hc->tx_x = rfc3390_initial_rate(sk); |
315 | hctx->tx_t_ld = now; | 314 | hc->tx_t_ld = now; |
316 | } else { | 315 | } else { |
317 | /* | 316 | /* |
318 | * Sender does not have RTT sample: | 317 | * Sender does not have RTT sample: |
@@ -320,17 +319,17 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
320 | * is needed in several parts (e.g. window counter); | 319 | * is needed in several parts (e.g. window counter); |
321 | * - set sending rate X_pps = 1pps as per RFC 3448, 4.2. | 320 | * - set sending rate X_pps = 1pps as per RFC 3448, 4.2. |
322 | */ | 321 | */ |
323 | hctx->tx_rtt = DCCP_FALLBACK_RTT; | 322 | hc->tx_rtt = DCCP_FALLBACK_RTT; |
324 | hctx->tx_x = hctx->tx_s; | 323 | hc->tx_x = hc->tx_s; |
325 | hctx->tx_x <<= 6; | 324 | hc->tx_x <<= 6; |
326 | } | 325 | } |
327 | ccid3_update_send_interval(hctx); | 326 | ccid3_update_send_interval(hc); |
328 | 327 | ||
329 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); | 328 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); |
330 | break; | 329 | break; |
331 | case TFRC_SSTATE_NO_FBACK: | 330 | case TFRC_SSTATE_NO_FBACK: |
332 | case TFRC_SSTATE_FBACK: | 331 | case TFRC_SSTATE_FBACK: |
333 | delay = ktime_us_delta(hctx->tx_t_nom, now); | 332 | delay = ktime_us_delta(hc->tx_t_nom, now); |
334 | ccid3_pr_debug("delay=%ld\n", (long)delay); | 333 | ccid3_pr_debug("delay=%ld\n", (long)delay); |
335 | /* | 334 | /* |
336 | * Scheduling of packet transmissions [RFC 3448, 4.6] | 335 | * Scheduling of packet transmissions [RFC 3448, 4.6] |
@@ -340,10 +339,10 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
340 | * else | 339 | * else |
341 | * // send the packet in (t_nom - t_now) milliseconds. | 340 | * // send the packet in (t_nom - t_now) milliseconds. |
342 | */ | 341 | */ |
343 | if (delay - (s64)hctx->tx_delta >= 1000) | 342 | if (delay - (s64)hc->tx_delta >= 1000) |
344 | return (u32)delay / 1000L; | 343 | return (u32)delay / 1000L; |
345 | 344 | ||
346 | ccid3_hc_tx_update_win_count(hctx, now); | 345 | ccid3_hc_tx_update_win_count(hc, now); |
347 | break; | 346 | break; |
348 | case TFRC_SSTATE_TERM: | 347 | case TFRC_SSTATE_TERM: |
349 | DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk); | 348 | DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk); |
@@ -352,27 +351,27 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
352 | 351 | ||
353 | /* prepare to send now (add options etc.) */ | 352 | /* prepare to send now (add options etc.) */ |
354 | dp->dccps_hc_tx_insert_options = 1; | 353 | dp->dccps_hc_tx_insert_options = 1; |
355 | DCCP_SKB_CB(skb)->dccpd_ccval = hctx->tx_last_win_count; | 354 | DCCP_SKB_CB(skb)->dccpd_ccval = hc->tx_last_win_count; |
356 | 355 | ||
357 | /* set the nominal send time for the next following packet */ | 356 | /* set the nominal send time for the next following packet */ |
358 | hctx->tx_t_nom = ktime_add_us(hctx->tx_t_nom, hctx->tx_t_ipi); | 357 | hc->tx_t_nom = ktime_add_us(hc->tx_t_nom, hc->tx_t_ipi); |
359 | return 0; | 358 | return 0; |
360 | } | 359 | } |
361 | 360 | ||
362 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, | 361 | static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, |
363 | unsigned int len) | 362 | unsigned int len) |
364 | { | 363 | { |
365 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 364 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
366 | 365 | ||
367 | ccid3_hc_tx_update_s(hctx, len); | 366 | ccid3_hc_tx_update_s(hc, len); |
368 | 367 | ||
369 | if (tfrc_tx_hist_add(&hctx->tx_hist, dccp_sk(sk)->dccps_gss)) | 368 | if (tfrc_tx_hist_add(&hc->tx_hist, dccp_sk(sk)->dccps_gss)) |
370 | DCCP_CRIT("packet history - out of memory!"); | 369 | DCCP_CRIT("packet history - out of memory!"); |
371 | } | 370 | } |
372 | 371 | ||
373 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | 372 | static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) |
374 | { | 373 | { |
375 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 374 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
376 | struct ccid3_options_received *opt_recv; | 375 | struct ccid3_options_received *opt_recv; |
377 | ktime_t now; | 376 | ktime_t now; |
378 | unsigned long t_nfb; | 377 | unsigned long t_nfb; |
@@ -383,15 +382,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
383 | DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK)) | 382 | DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK)) |
384 | return; | 383 | return; |
385 | /* ... and only in the established state */ | 384 | /* ... and only in the established state */ |
386 | if (hctx->tx_state != TFRC_SSTATE_FBACK && | 385 | if (hc->tx_state != TFRC_SSTATE_FBACK && |
387 | hctx->tx_state != TFRC_SSTATE_NO_FBACK) | 386 | hc->tx_state != TFRC_SSTATE_NO_FBACK) |
388 | return; | 387 | return; |
389 | 388 | ||
390 | opt_recv = &hctx->tx_options_received; | 389 | opt_recv = &hc->tx_options_received; |
391 | now = ktime_get_real(); | 390 | now = ktime_get_real(); |
392 | 391 | ||
393 | /* Estimate RTT from history if ACK number is valid */ | 392 | /* Estimate RTT from history if ACK number is valid */ |
394 | r_sample = tfrc_tx_hist_rtt(hctx->tx_hist, | 393 | r_sample = tfrc_tx_hist_rtt(hc->tx_hist, |
395 | DCCP_SKB_CB(skb)->dccpd_ack_seq, now); | 394 | DCCP_SKB_CB(skb)->dccpd_ack_seq, now); |
396 | if (r_sample == 0) { | 395 | if (r_sample == 0) { |
397 | DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk, | 396 | DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk, |
@@ -401,37 +400,37 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
401 | } | 400 | } |
402 | 401 | ||
403 | /* Update receive rate in units of 64 * bytes/second */ | 402 | /* Update receive rate in units of 64 * bytes/second */ |
404 | hctx->tx_x_recv = opt_recv->ccid3or_receive_rate; | 403 | hc->tx_x_recv = opt_recv->ccid3or_receive_rate; |
405 | hctx->tx_x_recv <<= 6; | 404 | hc->tx_x_recv <<= 6; |
406 | 405 | ||
407 | /* Update loss event rate (which is scaled by 1e6) */ | 406 | /* Update loss event rate (which is scaled by 1e6) */ |
408 | pinv = opt_recv->ccid3or_loss_event_rate; | 407 | pinv = opt_recv->ccid3or_loss_event_rate; |
409 | if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */ | 408 | if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */ |
410 | hctx->tx_p = 0; | 409 | hc->tx_p = 0; |
411 | else /* can not exceed 100% */ | 410 | else /* can not exceed 100% */ |
412 | hctx->tx_p = scaled_div(1, pinv); | 411 | hc->tx_p = scaled_div(1, pinv); |
413 | /* | 412 | /* |
414 | * Validate new RTT sample and update moving average | 413 | * Validate new RTT sample and update moving average |
415 | */ | 414 | */ |
416 | r_sample = dccp_sample_rtt(sk, r_sample); | 415 | r_sample = dccp_sample_rtt(sk, r_sample); |
417 | hctx->tx_rtt = tfrc_ewma(hctx->tx_rtt, r_sample, 9); | 416 | hc->tx_rtt = tfrc_ewma(hc->tx_rtt, r_sample, 9); |
418 | /* | 417 | /* |
419 | * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3 | 418 | * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3 |
420 | */ | 419 | */ |
421 | if (hctx->tx_state == TFRC_SSTATE_NO_FBACK) { | 420 | if (hc->tx_state == TFRC_SSTATE_NO_FBACK) { |
422 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); | 421 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); |
423 | 422 | ||
424 | if (hctx->tx_t_rto == 0) { | 423 | if (hc->tx_t_rto == 0) { |
425 | /* | 424 | /* |
426 | * Initial feedback packet: Larger Initial Windows (4.2) | 425 | * Initial feedback packet: Larger Initial Windows (4.2) |
427 | */ | 426 | */ |
428 | hctx->tx_x = rfc3390_initial_rate(sk); | 427 | hc->tx_x = rfc3390_initial_rate(sk); |
429 | hctx->tx_t_ld = now; | 428 | hc->tx_t_ld = now; |
430 | 429 | ||
431 | ccid3_update_send_interval(hctx); | 430 | ccid3_update_send_interval(hc); |
432 | 431 | ||
433 | goto done_computing_x; | 432 | goto done_computing_x; |
434 | } else if (hctx->tx_p == 0) { | 433 | } else if (hc->tx_p == 0) { |
435 | /* | 434 | /* |
436 | * First feedback after nofeedback timer expiry (4.3) | 435 | * First feedback after nofeedback timer expiry (4.3) |
437 | */ | 436 | */ |
@@ -440,20 +439,20 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
440 | } | 439 | } |
441 | 440 | ||
442 | /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ | 441 | /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ |
443 | if (hctx->tx_p > 0) | 442 | if (hc->tx_p > 0) |
444 | hctx->tx_x_calc = tfrc_calc_x(hctx->tx_s, hctx->tx_rtt, hctx->tx_p); | 443 | hc->tx_x_calc = tfrc_calc_x(hc->tx_s, hc->tx_rtt, hc->tx_p); |
445 | ccid3_hc_tx_update_x(sk, &now); | 444 | ccid3_hc_tx_update_x(sk, &now); |
446 | 445 | ||
447 | done_computing_x: | 446 | done_computing_x: |
448 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, " | 447 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, " |
449 | "p=%u, X_calc=%u, X_recv=%u, X=%u\n", | 448 | "p=%u, X_calc=%u, X_recv=%u, X=%u\n", |
450 | dccp_role(sk), sk, hctx->tx_rtt, r_sample, | 449 | dccp_role(sk), sk, hc->tx_rtt, r_sample, |
451 | hctx->tx_s, hctx->tx_p, hctx->tx_x_calc, | 450 | hc->tx_s, hc->tx_p, hc->tx_x_calc, |
452 | (unsigned)(hctx->tx_x_recv >> 6), | 451 | (unsigned)(hc->tx_x_recv >> 6), |
453 | (unsigned)(hctx->tx_x >> 6)); | 452 | (unsigned)(hc->tx_x >> 6)); |
454 | 453 | ||
455 | /* unschedule no feedback timer */ | 454 | /* unschedule no feedback timer */ |
456 | sk_stop_timer(sk, &hctx->tx_no_feedback_timer); | 455 | sk_stop_timer(sk, &hc->tx_no_feedback_timer); |
457 | 456 | ||
458 | /* | 457 | /* |
459 | * As we have calculated new ipi, delta, t_nom it is possible | 458 | * As we have calculated new ipi, delta, t_nom it is possible |
@@ -467,19 +466,19 @@ done_computing_x: | |||
467 | * This can help avoid triggering the nofeedback timer too | 466 | * This can help avoid triggering the nofeedback timer too |
468 | * often ('spinning') on LANs with small RTTs. | 467 | * often ('spinning') on LANs with small RTTs. |
469 | */ | 468 | */ |
470 | hctx->tx_t_rto = max_t(u32, 4 * hctx->tx_rtt, (CONFIG_IP_DCCP_CCID3_RTO * | 469 | hc->tx_t_rto = max_t(u32, 4 * hc->tx_rtt, (CONFIG_IP_DCCP_CCID3_RTO * |
471 | (USEC_PER_SEC / 1000))); | 470 | (USEC_PER_SEC / 1000))); |
472 | /* | 471 | /* |
473 | * Schedule no feedback timer to expire in | 472 | * Schedule no feedback timer to expire in |
474 | * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi) | 473 | * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi) |
475 | */ | 474 | */ |
476 | t_nfb = max(hctx->tx_t_rto, 2 * hctx->tx_t_ipi); | 475 | t_nfb = max(hc->tx_t_rto, 2 * hc->tx_t_ipi); |
477 | 476 | ||
478 | ccid3_pr_debug("%s(%p), Scheduled no feedback timer to " | 477 | ccid3_pr_debug("%s(%p), Scheduled no feedback timer to " |
479 | "expire in %lu jiffies (%luus)\n", | 478 | "expire in %lu jiffies (%luus)\n", |
480 | dccp_role(sk), sk, usecs_to_jiffies(t_nfb), t_nfb); | 479 | dccp_role(sk), sk, usecs_to_jiffies(t_nfb), t_nfb); |
481 | 480 | ||
482 | sk_reset_timer(sk, &hctx->tx_no_feedback_timer, | 481 | sk_reset_timer(sk, &hc->tx_no_feedback_timer, |
483 | jiffies + usecs_to_jiffies(t_nfb)); | 482 | jiffies + usecs_to_jiffies(t_nfb)); |
484 | } | 483 | } |
485 | 484 | ||
@@ -489,11 +488,11 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
489 | { | 488 | { |
490 | int rc = 0; | 489 | int rc = 0; |
491 | const struct dccp_sock *dp = dccp_sk(sk); | 490 | const struct dccp_sock *dp = dccp_sk(sk); |
492 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 491 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
493 | struct ccid3_options_received *opt_recv; | 492 | struct ccid3_options_received *opt_recv; |
494 | __be32 opt_val; | 493 | __be32 opt_val; |
495 | 494 | ||
496 | opt_recv = &hctx->tx_options_received; | 495 | opt_recv = &hc->tx_options_received; |
497 | 496 | ||
498 | if (opt_recv->ccid3or_seqno != dp->dccps_gsr) { | 497 | if (opt_recv->ccid3or_seqno != dp->dccps_gsr) { |
499 | opt_recv->ccid3or_seqno = dp->dccps_gsr; | 498 | opt_recv->ccid3or_seqno = dp->dccps_gsr; |
@@ -547,55 +546,55 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option, | |||
547 | 546 | ||
548 | static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) | 547 | static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) |
549 | { | 548 | { |
550 | struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid); | 549 | struct ccid3_hc_tx_sock *hc = ccid_priv(ccid); |
551 | 550 | ||
552 | hctx->tx_state = TFRC_SSTATE_NO_SENT; | 551 | hc->tx_state = TFRC_SSTATE_NO_SENT; |
553 | hctx->tx_hist = NULL; | 552 | hc->tx_hist = NULL; |
554 | setup_timer(&hctx->tx_no_feedback_timer, | 553 | setup_timer(&hc->tx_no_feedback_timer, |
555 | ccid3_hc_tx_no_feedback_timer, (unsigned long)sk); | 554 | ccid3_hc_tx_no_feedback_timer, (unsigned long)sk); |
556 | return 0; | 555 | return 0; |
557 | } | 556 | } |
558 | 557 | ||
559 | static void ccid3_hc_tx_exit(struct sock *sk) | 558 | static void ccid3_hc_tx_exit(struct sock *sk) |
560 | { | 559 | { |
561 | struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); | 560 | struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk); |
562 | 561 | ||
563 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); | 562 | ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); |
564 | sk_stop_timer(sk, &hctx->tx_no_feedback_timer); | 563 | sk_stop_timer(sk, &hc->tx_no_feedback_timer); |
565 | 564 | ||
566 | tfrc_tx_hist_purge(&hctx->tx_hist); | 565 | tfrc_tx_hist_purge(&hc->tx_hist); |
567 | } | 566 | } |
568 | 567 | ||
569 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) | 568 | static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) |
570 | { | 569 | { |
571 | struct ccid3_hc_tx_sock *hctx; | 570 | struct ccid3_hc_tx_sock *hc; |
572 | 571 | ||
573 | /* Listen socks doesn't have a private CCID block */ | 572 | /* Listen socks doesn't have a private CCID block */ |
574 | if (sk->sk_state == DCCP_LISTEN) | 573 | if (sk->sk_state == DCCP_LISTEN) |
575 | return; | 574 | return; |
576 | 575 | ||
577 | hctx = ccid3_hc_tx_sk(sk); | 576 | hc = ccid3_hc_tx_sk(sk); |
578 | info->tcpi_rto = hctx->tx_t_rto; | 577 | info->tcpi_rto = hc->tx_t_rto; |
579 | info->tcpi_rtt = hctx->tx_rtt; | 578 | info->tcpi_rtt = hc->tx_rtt; |
580 | } | 579 | } |
581 | 580 | ||
582 | static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len, | 581 | static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len, |
583 | u32 __user *optval, int __user *optlen) | 582 | u32 __user *optval, int __user *optlen) |
584 | { | 583 | { |
585 | const struct ccid3_hc_tx_sock *hctx; | 584 | const struct ccid3_hc_tx_sock *hc; |
586 | const void *val; | 585 | const void *val; |
587 | 586 | ||
588 | /* Listen socks doesn't have a private CCID block */ | 587 | /* Listen socks doesn't have a private CCID block */ |
589 | if (sk->sk_state == DCCP_LISTEN) | 588 | if (sk->sk_state == DCCP_LISTEN) |
590 | return -EINVAL; | 589 | return -EINVAL; |
591 | 590 | ||
592 | hctx = ccid3_hc_tx_sk(sk); | 591 | hc = ccid3_hc_tx_sk(sk); |
593 | switch (optname) { | 592 | switch (optname) { |
594 | case DCCP_SOCKOPT_CCID_TX_INFO: | 593 | case DCCP_SOCKOPT_CCID_TX_INFO: |
595 | if (len < sizeof(hctx->tx_tfrc)) | 594 | if (len < sizeof(hc->tx_tfrc)) |
596 | return -EINVAL; | 595 | return -EINVAL; |
597 | len = sizeof(hctx->tx_tfrc); | 596 | len = sizeof(hc->tx_tfrc); |
598 | val = &hctx->tx_tfrc; | 597 | val = &hc->tx_tfrc; |
599 | break; | 598 | break; |
600 | default: | 599 | default: |
601 | return -ENOPROTOOPT; | 600 | return -ENOPROTOOPT; |
@@ -635,34 +634,34 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) | |||
635 | static void ccid3_hc_rx_set_state(struct sock *sk, | 634 | static void ccid3_hc_rx_set_state(struct sock *sk, |
636 | enum ccid3_hc_rx_states state) | 635 | enum ccid3_hc_rx_states state) |
637 | { | 636 | { |
638 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 637 | struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); |
639 | enum ccid3_hc_rx_states oldstate = hcrx->rx_state; | 638 | enum ccid3_hc_rx_states oldstate = hc->rx_state; |
640 | 639 | ||
641 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", | 640 | ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", |
642 | dccp_role(sk), sk, ccid3_rx_state_name(oldstate), | 641 | dccp_role(sk), sk, ccid3_rx_state_name(oldstate), |
643 | ccid3_rx_state_name(state)); | 642 | ccid3_rx_state_name(state)); |
644 | WARN_ON(state == oldstate); | 643 | WARN_ON(state == oldstate); |
645 | hcrx->rx_state = state; | 644 | hc->rx_state = state; |
646 | } | 645 | } |
647 | 646 | ||
648 | static void ccid3_hc_rx_send_feedback(struct sock *sk, | 647 | static void ccid3_hc_rx_send_feedback(struct sock *sk, |
649 | const struct sk_buff *skb, | 648 | const struct sk_buff *skb, |
650 | enum ccid3_fback_type fbtype) | 649 | enum ccid3_fback_type fbtype) |
651 | { | 650 | { |
652 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 651 | struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); |
653 | struct dccp_sock *dp = dccp_sk(sk); | 652 | struct dccp_sock *dp = dccp_sk(sk); |
654 | ktime_t now; | 653 | ktime_t now; |
655 | s64 delta = 0; | 654 | s64 delta = 0; |
656 | 655 | ||
657 | if (unlikely(hcrx->rx_state == TFRC_RSTATE_TERM)) | 656 | if (unlikely(hc->rx_state == TFRC_RSTATE_TERM)) |
658 | return; | 657 | return; |
659 | 658 | ||
660 | now = ktime_get_real(); | 659 | now = ktime_get_real(); |
661 | 660 | ||
662 | switch (fbtype) { | 661 | switch (fbtype) { |
663 | case CCID3_FBACK_INITIAL: | 662 | case CCID3_FBACK_INITIAL: |
664 | hcrx->rx_x_recv = 0; | 663 | hc->rx_x_recv = 0; |
665 | hcrx->rx_pinv = ~0U; /* see RFC 4342, 8.5 */ | 664 | hc->rx_pinv = ~0U; /* see RFC 4342, 8.5 */ |
666 | break; | 665 | break; |
667 | case CCID3_FBACK_PARAM_CHANGE: | 666 | case CCID3_FBACK_PARAM_CHANGE: |
668 | /* | 667 | /* |
@@ -675,26 +674,26 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, | |||
675 | * the number of bytes since last feedback. | 674 | * the number of bytes since last feedback. |
676 | * This is a safe fallback, since X is bounded above by X_calc. | 675 | * This is a safe fallback, since X is bounded above by X_calc. |
677 | */ | 676 | */ |
678 | if (hcrx->rx_x_recv > 0) | 677 | if (hc->rx_x_recv > 0) |
679 | break; | 678 | break; |
680 | /* fall through */ | 679 | /* fall through */ |
681 | case CCID3_FBACK_PERIODIC: | 680 | case CCID3_FBACK_PERIODIC: |
682 | delta = ktime_us_delta(now, hcrx->rx_tstamp_last_feedback); | 681 | delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback); |
683 | if (delta <= 0) | 682 | if (delta <= 0) |
684 | DCCP_BUG("delta (%ld) <= 0", (long)delta); | 683 | DCCP_BUG("delta (%ld) <= 0", (long)delta); |
685 | else | 684 | else |
686 | hcrx->rx_x_recv = scaled_div32(hcrx->rx_bytes_recv, delta); | 685 | hc->rx_x_recv = scaled_div32(hc->rx_bytes_recv, delta); |
687 | break; | 686 | break; |
688 | default: | 687 | default: |
689 | return; | 688 | return; |
690 | } | 689 | } |
691 | 690 | ||
692 | ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta, | 691 | ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta, |
693 | hcrx->rx_x_recv, hcrx->rx_pinv); | 692 | hc->rx_x_recv, hc->rx_pinv); |
694 | 693 | ||
695 | hcrx->rx_tstamp_last_feedback = now; | 694 | hc->rx_tstamp_last_feedback = now; |
696 | hcrx->rx_last_counter = dccp_hdr(skb)->dccph_ccval; | 695 | hc->rx_last_counter = dccp_hdr(skb)->dccph_ccval; |
697 | hcrx->rx_bytes_recv = 0; | 696 | hc->rx_bytes_recv = 0; |
698 | 697 | ||
699 | dp->dccps_hc_rx_insert_options = 1; | 698 | dp->dccps_hc_rx_insert_options = 1; |
700 | dccp_send_ack(sk); | 699 | dccp_send_ack(sk); |
@@ -702,19 +701,19 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, | |||
702 | 701 | ||
703 | static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | 702 | static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) |
704 | { | 703 | { |
705 | const struct ccid3_hc_rx_sock *hcrx; | 704 | const struct ccid3_hc_rx_sock *hc; |
706 | __be32 x_recv, pinv; | 705 | __be32 x_recv, pinv; |
707 | 706 | ||
708 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) | 707 | if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) |
709 | return 0; | 708 | return 0; |
710 | 709 | ||
711 | hcrx = ccid3_hc_rx_sk(sk); | 710 | hc = ccid3_hc_rx_sk(sk); |
712 | 711 | ||
713 | if (dccp_packet_without_ack(skb)) | 712 | if (dccp_packet_without_ack(skb)) |
714 | return 0; | 713 | return 0; |
715 | 714 | ||
716 | x_recv = htonl(hcrx->rx_x_recv); | 715 | x_recv = htonl(hc->rx_x_recv); |
717 | pinv = htonl(hcrx->rx_pinv); | 716 | pinv = htonl(hc->rx_pinv); |
718 | 717 | ||
719 | if (dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE, | 718 | if (dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE, |
720 | &pinv, sizeof(pinv)) || | 719 | &pinv, sizeof(pinv)) || |
@@ -737,26 +736,26 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
737 | */ | 736 | */ |
738 | static u32 ccid3_first_li(struct sock *sk) | 737 | static u32 ccid3_first_li(struct sock *sk) |
739 | { | 738 | { |
740 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 739 | struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); |
741 | u32 x_recv, p, delta; | 740 | u32 x_recv, p, delta; |
742 | u64 fval; | 741 | u64 fval; |
743 | 742 | ||
744 | if (hcrx->rx_rtt == 0) { | 743 | if (hc->rx_rtt == 0) { |
745 | DCCP_WARN("No RTT estimate available, using fallback RTT\n"); | 744 | DCCP_WARN("No RTT estimate available, using fallback RTT\n"); |
746 | hcrx->rx_rtt = DCCP_FALLBACK_RTT; | 745 | hc->rx_rtt = DCCP_FALLBACK_RTT; |
747 | } | 746 | } |
748 | 747 | ||
749 | delta = ktime_to_us(net_timedelta(hcrx->rx_tstamp_last_feedback)); | 748 | delta = ktime_to_us(net_timedelta(hc->rx_tstamp_last_feedback)); |
750 | x_recv = scaled_div32(hcrx->rx_bytes_recv, delta); | 749 | x_recv = scaled_div32(hc->rx_bytes_recv, delta); |
751 | if (x_recv == 0) { /* would also trigger divide-by-zero */ | 750 | if (x_recv == 0) { /* would also trigger divide-by-zero */ |
752 | DCCP_WARN("X_recv==0\n"); | 751 | DCCP_WARN("X_recv==0\n"); |
753 | if ((x_recv = hcrx->rx_x_recv) == 0) { | 752 | if ((x_recv = hc->rx_x_recv) == 0) { |
754 | DCCP_BUG("stored value of X_recv is zero"); | 753 | DCCP_BUG("stored value of X_recv is zero"); |
755 | return ~0U; | 754 | return ~0U; |
756 | } | 755 | } |
757 | } | 756 | } |
758 | 757 | ||
759 | fval = scaled_div(hcrx->rx_s, hcrx->rx_rtt); | 758 | fval = scaled_div(hc->rx_s, hc->rx_rtt); |
760 | fval = scaled_div32(fval, x_recv); | 759 | fval = scaled_div32(fval, x_recv); |
761 | p = tfrc_calc_x_reverse_lookup(fval); | 760 | p = tfrc_calc_x_reverse_lookup(fval); |
762 | 761 | ||
@@ -768,17 +767,17 @@ static u32 ccid3_first_li(struct sock *sk) | |||
768 | 767 | ||
769 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 768 | static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
770 | { | 769 | { |
771 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 770 | struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); |
772 | enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE; | 771 | enum ccid3_fback_type do_feedback = CCID3_FBACK_NONE; |
773 | const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp; | 772 | const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp; |
774 | const bool is_data_packet = dccp_data_packet(skb); | 773 | const bool is_data_packet = dccp_data_packet(skb); |
775 | 774 | ||
776 | if (unlikely(hcrx->rx_state == TFRC_RSTATE_NO_DATA)) { | 775 | if (unlikely(hc->rx_state == TFRC_RSTATE_NO_DATA)) { |
777 | if (is_data_packet) { | 776 | if (is_data_packet) { |
778 | const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; | 777 | const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; |
779 | do_feedback = CCID3_FBACK_INITIAL; | 778 | do_feedback = CCID3_FBACK_INITIAL; |
780 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); | 779 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); |
781 | hcrx->rx_s = payload; | 780 | hc->rx_s = payload; |
782 | /* | 781 | /* |
783 | * Not necessary to update rx_bytes_recv here, | 782 | * Not necessary to update rx_bytes_recv here, |
784 | * since X_recv = 0 for the first feedback packet (cf. | 783 | * since X_recv = 0 for the first feedback packet (cf. |
@@ -788,7 +787,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
788 | goto update_records; | 787 | goto update_records; |
789 | } | 788 | } |
790 | 789 | ||
791 | if (tfrc_rx_hist_duplicate(&hcrx->rx_hist, skb)) | 790 | if (tfrc_rx_hist_duplicate(&hc->rx_hist, skb)) |
792 | return; /* done receiving */ | 791 | return; /* done receiving */ |
793 | 792 | ||
794 | if (is_data_packet) { | 793 | if (is_data_packet) { |
@@ -796,20 +795,20 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
796 | /* | 795 | /* |
797 | * Update moving-average of s and the sum of received payload bytes | 796 | * Update moving-average of s and the sum of received payload bytes |
798 | */ | 797 | */ |
799 | hcrx->rx_s = tfrc_ewma(hcrx->rx_s, payload, 9); | 798 | hc->rx_s = tfrc_ewma(hc->rx_s, payload, 9); |
800 | hcrx->rx_bytes_recv += payload; | 799 | hc->rx_bytes_recv += payload; |
801 | } | 800 | } |
802 | 801 | ||
803 | /* | 802 | /* |
804 | * Perform loss detection and handle pending losses | 803 | * Perform loss detection and handle pending losses |
805 | */ | 804 | */ |
806 | if (tfrc_rx_handle_loss(&hcrx->rx_hist, &hcrx->rx_li_hist, | 805 | if (tfrc_rx_handle_loss(&hc->rx_hist, &hc->rx_li_hist, |
807 | skb, ndp, ccid3_first_li, sk)) { | 806 | skb, ndp, ccid3_first_li, sk)) { |
808 | do_feedback = CCID3_FBACK_PARAM_CHANGE; | 807 | do_feedback = CCID3_FBACK_PARAM_CHANGE; |
809 | goto done_receiving; | 808 | goto done_receiving; |
810 | } | 809 | } |
811 | 810 | ||
812 | if (tfrc_rx_hist_loss_pending(&hcrx->rx_hist)) | 811 | if (tfrc_rx_hist_loss_pending(&hc->rx_hist)) |
813 | return; /* done receiving */ | 812 | return; /* done receiving */ |
814 | 813 | ||
815 | /* | 814 | /* |
@@ -818,17 +817,17 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
818 | if (unlikely(!is_data_packet)) | 817 | if (unlikely(!is_data_packet)) |
819 | goto update_records; | 818 | goto update_records; |
820 | 819 | ||
821 | if (!tfrc_lh_is_initialised(&hcrx->rx_li_hist)) { | 820 | if (!tfrc_lh_is_initialised(&hc->rx_li_hist)) { |
822 | const u32 sample = tfrc_rx_hist_sample_rtt(&hcrx->rx_hist, skb); | 821 | const u32 sample = tfrc_rx_hist_sample_rtt(&hc->rx_hist, skb); |
823 | /* | 822 | /* |
824 | * Empty loss history: no loss so far, hence p stays 0. | 823 | * Empty loss history: no loss so far, hence p stays 0. |
825 | * Sample RTT values, since an RTT estimate is required for the | 824 | * Sample RTT values, since an RTT estimate is required for the |
826 | * computation of p when the first loss occurs; RFC 3448, 6.3.1. | 825 | * computation of p when the first loss occurs; RFC 3448, 6.3.1. |
827 | */ | 826 | */ |
828 | if (sample != 0) | 827 | if (sample != 0) |
829 | hcrx->rx_rtt = tfrc_ewma(hcrx->rx_rtt, sample, 9); | 828 | hc->rx_rtt = tfrc_ewma(hc->rx_rtt, sample, 9); |
830 | 829 | ||
831 | } else if (tfrc_lh_update_i_mean(&hcrx->rx_li_hist, skb)) { | 830 | } else if (tfrc_lh_update_i_mean(&hc->rx_li_hist, skb)) { |
832 | /* | 831 | /* |
833 | * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean | 832 | * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean |
834 | * has decreased (resp. p has increased), send feedback now. | 833 | * has decreased (resp. p has increased), send feedback now. |
@@ -839,11 +838,11 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
839 | /* | 838 | /* |
840 | * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 | 839 | * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 |
841 | */ | 840 | */ |
842 | if (SUB16(dccp_hdr(skb)->dccph_ccval, hcrx->rx_last_counter) > 3) | 841 | if (SUB16(dccp_hdr(skb)->dccph_ccval, hc->rx_last_counter) > 3) |
843 | do_feedback = CCID3_FBACK_PERIODIC; | 842 | do_feedback = CCID3_FBACK_PERIODIC; |
844 | 843 | ||
845 | update_records: | 844 | update_records: |
846 | tfrc_rx_hist_add_packet(&hcrx->rx_hist, skb, ndp); | 845 | tfrc_rx_hist_add_packet(&hc->rx_hist, skb, ndp); |
847 | 846 | ||
848 | done_receiving: | 847 | done_receiving: |
849 | if (do_feedback) | 848 | if (do_feedback) |
@@ -852,41 +851,41 @@ done_receiving: | |||
852 | 851 | ||
853 | static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) | 852 | static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) |
854 | { | 853 | { |
855 | struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid); | 854 | struct ccid3_hc_rx_sock *hc = ccid_priv(ccid); |
856 | 855 | ||
857 | hcrx->rx_state = TFRC_RSTATE_NO_DATA; | 856 | hc->rx_state = TFRC_RSTATE_NO_DATA; |
858 | tfrc_lh_init(&hcrx->rx_li_hist); | 857 | tfrc_lh_init(&hc->rx_li_hist); |
859 | return tfrc_rx_hist_alloc(&hcrx->rx_hist); | 858 | return tfrc_rx_hist_alloc(&hc->rx_hist); |
860 | } | 859 | } |
861 | 860 | ||
862 | static void ccid3_hc_rx_exit(struct sock *sk) | 861 | static void ccid3_hc_rx_exit(struct sock *sk) |
863 | { | 862 | { |
864 | struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); | 863 | struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); |
865 | 864 | ||
866 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); | 865 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); |
867 | 866 | ||
868 | tfrc_rx_hist_purge(&hcrx->rx_hist); | 867 | tfrc_rx_hist_purge(&hc->rx_hist); |
869 | tfrc_lh_cleanup(&hcrx->rx_li_hist); | 868 | tfrc_lh_cleanup(&hc->rx_li_hist); |
870 | } | 869 | } |
871 | 870 | ||
872 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) | 871 | static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) |
873 | { | 872 | { |
874 | const struct ccid3_hc_rx_sock *hcrx; | 873 | const struct ccid3_hc_rx_sock *hc; |
875 | 874 | ||
876 | /* Listen socks doesn't have a private CCID block */ | 875 | /* Listen socks doesn't have a private CCID block */ |
877 | if (sk->sk_state == DCCP_LISTEN) | 876 | if (sk->sk_state == DCCP_LISTEN) |
878 | return; | 877 | return; |
879 | 878 | ||
880 | hcrx = ccid3_hc_rx_sk(sk); | 879 | hc = ccid3_hc_rx_sk(sk); |
881 | info->tcpi_ca_state = hcrx->rx_state; | 880 | info->tcpi_ca_state = hc->rx_state; |
882 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; | 881 | info->tcpi_options |= TCPI_OPT_TIMESTAMPS; |
883 | info->tcpi_rcv_rtt = hcrx->rx_rtt; | 882 | info->tcpi_rcv_rtt = hc->rx_rtt; |
884 | } | 883 | } |
885 | 884 | ||
886 | static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len, | 885 | static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len, |
887 | u32 __user *optval, int __user *optlen) | 886 | u32 __user *optval, int __user *optlen) |
888 | { | 887 | { |
889 | const struct ccid3_hc_rx_sock *hcrx; | 888 | const struct ccid3_hc_rx_sock *hc; |
890 | struct tfrc_rx_info rx_info; | 889 | struct tfrc_rx_info rx_info; |
891 | const void *val; | 890 | const void *val; |
892 | 891 | ||
@@ -894,15 +893,15 @@ static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len, | |||
894 | if (sk->sk_state == DCCP_LISTEN) | 893 | if (sk->sk_state == DCCP_LISTEN) |
895 | return -EINVAL; | 894 | return -EINVAL; |
896 | 895 | ||
897 | hcrx = ccid3_hc_rx_sk(sk); | 896 | hc = ccid3_hc_rx_sk(sk); |
898 | switch (optname) { | 897 | switch (optname) { |
899 | case DCCP_SOCKOPT_CCID_RX_INFO: | 898 | case DCCP_SOCKOPT_CCID_RX_INFO: |
900 | if (len < sizeof(rx_info)) | 899 | if (len < sizeof(rx_info)) |
901 | return -EINVAL; | 900 | return -EINVAL; |
902 | rx_info.tfrcrx_x_recv = hcrx->rx_x_recv; | 901 | rx_info.tfrcrx_x_recv = hc->rx_x_recv; |
903 | rx_info.tfrcrx_rtt = hcrx->rx_rtt; | 902 | rx_info.tfrcrx_rtt = hc->rx_rtt; |
904 | rx_info.tfrcrx_p = hcrx->rx_pinv == 0 ? ~0U : | 903 | rx_info.tfrcrx_p = hc->rx_pinv == 0 ? ~0U : |
905 | scaled_div(1, hcrx->rx_pinv); | 904 | scaled_div(1, hc->rx_pinv); |
906 | len = sizeof(rx_info); | 905 | len = sizeof(rx_info); |
907 | val = &rx_info; | 906 | val = &rx_info; |
908 | break; | 907 | break; |
diff --git a/net/dccp/probe.c b/net/dccp/probe.c index 430d16fd6f59..5e6ec8b9b7b6 100644 --- a/net/dccp/probe.c +++ b/net/dccp/probe.c | |||
@@ -75,20 +75,20 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
75 | struct msghdr *msg, size_t size) | 75 | struct msghdr *msg, size_t size) |
76 | { | 76 | { |
77 | const struct inet_sock *inet = inet_sk(sk); | 77 | const struct inet_sock *inet = inet_sk(sk); |
78 | struct ccid3_hc_tx_sock *hctx = NULL; | 78 | struct ccid3_hc_tx_sock *hc = NULL; |
79 | 79 | ||
80 | if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3) | 80 | if (ccid_get_current_tx_ccid(dccp_sk(sk)) == DCCPC_CCID3) |
81 | hctx = ccid3_hc_tx_sk(sk); | 81 | hc = ccid3_hc_tx_sk(sk); |
82 | 82 | ||
83 | if (port == 0 || ntohs(inet->dport) == port || | 83 | if (port == 0 || ntohs(inet->dport) == port || |
84 | ntohs(inet->sport) == port) { | 84 | ntohs(inet->sport) == port) { |
85 | if (hctx) | 85 | if (hc) |
86 | printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n", | 86 | printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n", |
87 | &inet->saddr, ntohs(inet->sport), | 87 | &inet->saddr, ntohs(inet->sport), |
88 | &inet->daddr, ntohs(inet->dport), size, | 88 | &inet->daddr, ntohs(inet->dport), size, |
89 | hctx->tx_s, hctx->tx_rtt, hctx->tx_p, | 89 | hc->tx_s, hc->tx_rtt, hc->tx_p, |
90 | hctx->tx_x_calc, hctx->tx_x_recv >> 6, | 90 | hc->tx_x_calc, hc->tx_x_recv >> 6, |
91 | hctx->tx_x >> 6, hctx->tx_t_ipi); | 91 | hc->tx_x >> 6, hc->tx_t_ipi); |
92 | else | 92 | else |
93 | printl("%pI4:%u %pI4:%u %d\n", | 93 | printl("%pI4:%u %pI4:%u %d\n", |
94 | &inet->saddr, ntohs(inet->sport), | 94 | &inet->saddr, ntohs(inet->sport), |