aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2009-10-04 20:53:11 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-07 16:51:22 -0400
commit388d5e9905dd80648fff5ccaefdd8c0fcedb3eae (patch)
tree43372d8c54d888f5d697bd7ef8f6d1d20f923d93 /net/dccp
parentb1c00fe3cf8f54d97d20cdf196145a106f04bd63 (diff)
dccp ccid-3: Overhaul CCID naming convention 2/2
This implements the new naming scheme also for 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.c321
-rw-r--r--net/dccp/ccids/ccid3.h120
-rw-r--r--net/dccp/probe.c10
3 files changed, 213 insertions, 238 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 34dcc798c457..6b8d67ba7fe7 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -65,13 +65,13 @@ 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 *hctx = ccid3_hc_tx_sk(sk);
68 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; 68 enum ccid3_hc_tx_states oldstate = hctx->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->ccid3hctx_state = state; 74 hctx->tx_state = state;
75} 75}
76 76
77/* 77/*
@@ -86,10 +86,9 @@ static void ccid3_hc_tx_set_state(struct sock *sk,
86static inline u64 rfc3390_initial_rate(struct sock *sk) 86static 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 *hctx = ccid3_hc_tx_sk(sk);
89 const __u32 w_init = clamp_t(__u32, 4380U, 89 const __u32 w_init = clamp_t(__u32, 4380U, 2 * hctx->tx_s, 4 * hctx->tx_s);
90 2 * hctx->ccid3hctx_s, 4 * hctx->ccid3hctx_s);
91 90
92 return scaled_div(w_init << 6, hctx->ccid3hctx_rtt); 91 return scaled_div(w_init << 6, hctx->tx_rtt);
93} 92}
94 93
95/* 94/*
@@ -98,24 +97,20 @@ static inline u64 rfc3390_initial_rate(struct sock *sk)
98static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx) 97static void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx)
99{ 98{
100 /* 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) */
101 hctx->ccid3hctx_t_ipi = scaled_div32(((u64)hctx->ccid3hctx_s) << 6, 100 hctx->tx_t_ipi = scaled_div32(((u64)hctx->tx_s) << 6, hctx->tx_x);
102 hctx->ccid3hctx_x);
103 101
104 /* 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) */
105 hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, 103 hctx->tx_delta = min_t(u32, hctx->tx_t_ipi / 2, TFRC_OPSYS_HALF_TIME_GRAN);
106 TFRC_OPSYS_HALF_TIME_GRAN);
107
108 ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n",
109 hctx->ccid3hctx_t_ipi, hctx->ccid3hctx_delta,
110 hctx->ccid3hctx_s, (unsigned)(hctx->ccid3hctx_x >> 6));
111 104
105 ccid3_pr_debug("t_ipi=%u, delta=%u, s=%u, X=%u\n", hctx->tx_t_ipi,
106 hctx->tx_delta, hctx->tx_s, (unsigned)(hctx->tx_x >> 6));
112} 107}
113 108
114static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hctx, ktime_t now) 109static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hctx, ktime_t now)
115{ 110{
116 u32 delta = ktime_us_delta(now, hctx->ccid3hctx_t_last_win_count); 111 u32 delta = ktime_us_delta(now, hctx->tx_t_last_win_count);
117 112
118 return delta / hctx->ccid3hctx_rtt; 113 return delta / hctx->tx_rtt;
119} 114}
120 115
121/** 116/**
@@ -131,8 +126,8 @@ static u32 ccid3_hc_tx_idle_rtt(struct ccid3_hc_tx_sock *hctx, ktime_t now)
131static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp) 126static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp)
132{ 127{
133 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 128 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
134 __u64 min_rate = 2 * hctx->ccid3hctx_x_recv; 129 __u64 min_rate = 2 * hctx->tx_x_recv;
135 const __u64 old_x = hctx->ccid3hctx_x; 130 const __u64 old_x = hctx->tx_x;
136 ktime_t now = stamp ? *stamp : ktime_get_real(); 131 ktime_t now = stamp ? *stamp : ktime_get_real();
137 132
138 /* 133 /*
@@ -143,33 +138,27 @@ static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp)
143 */ 138 */
144 if (ccid3_hc_tx_idle_rtt(hctx, now) >= 2) { 139 if (ccid3_hc_tx_idle_rtt(hctx, now) >= 2) {
145 min_rate = rfc3390_initial_rate(sk); 140 min_rate = rfc3390_initial_rate(sk);
146 min_rate = max(min_rate, 2 * hctx->ccid3hctx_x_recv); 141 min_rate = max(min_rate, 2 * hctx->tx_x_recv);
147 } 142 }
148 143
149 if (hctx->ccid3hctx_p > 0) { 144 if (hctx->tx_p > 0) {
150 145
151 hctx->ccid3hctx_x = min(((__u64)hctx->ccid3hctx_x_calc) << 6, 146 hctx->tx_x = min(((__u64)hctx->tx_x_calc) << 6, min_rate);
152 min_rate); 147 hctx->tx_x = max(hctx->tx_x, (((__u64)hctx->tx_s) << 6) / TFRC_T_MBI);
153 hctx->ccid3hctx_x = max(hctx->ccid3hctx_x,
154 (((__u64)hctx->ccid3hctx_s) << 6) /
155 TFRC_T_MBI);
156 148
157 } else if (ktime_us_delta(now, hctx->ccid3hctx_t_ld) 149 } else if (ktime_us_delta(now, hctx->tx_t_ld) - (s64)hctx->tx_rtt >= 0) {
158 - (s64)hctx->ccid3hctx_rtt >= 0) {
159 150
160 hctx->ccid3hctx_x = min(2 * hctx->ccid3hctx_x, min_rate); 151 hctx->tx_x = min(2 * hctx->tx_x, min_rate);
161 hctx->ccid3hctx_x = max(hctx->ccid3hctx_x, 152 hctx->tx_x = max(hctx->tx_x, scaled_div(((__u64)hctx->tx_s) << 6,
162 scaled_div(((__u64)hctx->ccid3hctx_s) << 6, 153 hctx->tx_rtt));
163 hctx->ccid3hctx_rtt)); 154 hctx->tx_t_ld = now;
164 hctx->ccid3hctx_t_ld = now;
165 } 155 }
166 156
167 if (hctx->ccid3hctx_x != old_x) { 157 if (hctx->tx_x != old_x) {
168 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, "
169 "X_recv=%u\n", (unsigned)(old_x >> 6), 159 "X_recv=%u\n", (unsigned)(old_x >> 6),
170 (unsigned)(hctx->ccid3hctx_x >> 6), 160 (unsigned)(hctx->tx_x >> 6), hctx->tx_x_calc,
171 hctx->ccid3hctx_x_calc, 161 (unsigned)(hctx->tx_x_recv >> 6));
172 (unsigned)(hctx->ccid3hctx_x_recv >> 6));
173 162
174 ccid3_update_send_interval(hctx); 163 ccid3_update_send_interval(hctx);
175 } 164 }
@@ -181,11 +170,11 @@ static void ccid3_hc_tx_update_x(struct sock *sk, ktime_t *stamp)
181 */ 170 */
182static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len) 171static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
183{ 172{
184 const u16 old_s = hctx->ccid3hctx_s; 173 const u16 old_s = hctx->tx_s;
185 174
186 hctx->ccid3hctx_s = tfrc_ewma(hctx->ccid3hctx_s, len, 9); 175 hctx->tx_s = tfrc_ewma(hctx->tx_s, len, 9);
187 176
188 if (hctx->ccid3hctx_s != old_s) 177 if (hctx->tx_s != old_s)
189 ccid3_update_send_interval(hctx); 178 ccid3_update_send_interval(hctx);
190} 179}
191 180
@@ -196,13 +185,13 @@ static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
196static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hctx, 185static inline void ccid3_hc_tx_update_win_count(struct ccid3_hc_tx_sock *hctx,
197 ktime_t now) 186 ktime_t now)
198{ 187{
199 u32 delta = ktime_us_delta(now, hctx->ccid3hctx_t_last_win_count), 188 u32 delta = ktime_us_delta(now, hctx->tx_t_last_win_count),
200 quarter_rtts = (4 * delta) / hctx->ccid3hctx_rtt; 189 quarter_rtts = (4 * delta) / hctx->tx_rtt;
201 190
202 if (quarter_rtts > 0) { 191 if (quarter_rtts > 0) {
203 hctx->ccid3hctx_t_last_win_count = now; 192 hctx->tx_t_last_win_count = now;
204 hctx->ccid3hctx_last_win_count += min(quarter_rtts, 5U); 193 hctx->tx_last_win_count += min(quarter_rtts, 5U);
205 hctx->ccid3hctx_last_win_count &= 0xF; /* mod 16 */ 194 hctx->tx_last_win_count &= 0xF; /* mod 16 */
206 } 195 }
207} 196}
208 197
@@ -220,23 +209,22 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
220 } 209 }
221 210
222 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,
223 ccid3_tx_state_name(hctx->ccid3hctx_state)); 212 ccid3_tx_state_name(hctx->tx_state));
224 213
225 if (hctx->ccid3hctx_state == TFRC_SSTATE_FBACK) 214 if (hctx->tx_state == TFRC_SSTATE_FBACK)
226 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); 215 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
227 else if (hctx->ccid3hctx_state != TFRC_SSTATE_NO_FBACK) 216 else if (hctx->tx_state != TFRC_SSTATE_NO_FBACK)
228 goto out; 217 goto out;
229 218
230 /* 219 /*
231 * 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
232 */ 221 */
233 if (hctx->ccid3hctx_t_rto == 0 || /* no feedback received yet */ 222 if (hctx->tx_t_rto == 0 || /* no feedback received yet */
234 hctx->ccid3hctx_p == 0) { 223 hctx->tx_p == 0) {
235 224
236 /* halve send rate directly */ 225 /* halve send rate directly */
237 hctx->ccid3hctx_x = max(hctx->ccid3hctx_x / 2, 226 hctx->tx_x = max(hctx->tx_x / 2,
238 (((__u64)hctx->ccid3hctx_s) << 6) / 227 (((__u64)hctx->tx_s) << 6) / TFRC_T_MBI);
239 TFRC_T_MBI);
240 ccid3_update_send_interval(hctx); 228 ccid3_update_send_interval(hctx);
241 } else { 229 } else {
242 /* 230 /*
@@ -249,33 +237,33 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
249 * 237 *
250 * 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
251 */ 239 */
252 BUG_ON(hctx->ccid3hctx_p && !hctx->ccid3hctx_x_calc); 240 BUG_ON(hctx->tx_p && !hctx->tx_x_calc);
253 241
254 if (hctx->ccid3hctx_x_calc > (hctx->ccid3hctx_x_recv >> 5)) 242 if (hctx->tx_x_calc > (hctx->tx_x_recv >> 5))
255 hctx->ccid3hctx_x_recv = 243 hctx->tx_x_recv =
256 max(hctx->ccid3hctx_x_recv / 2, 244 max(hctx->tx_x_recv / 2,
257 (((__u64)hctx->ccid3hctx_s) << 6) / 245 (((__u64)hctx->tx_s) << 6) /
258 (2 * TFRC_T_MBI)); 246 (2 * TFRC_T_MBI));
259 else { 247 else {
260 hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc; 248 hctx->tx_x_recv = hctx->tx_x_calc;
261 hctx->ccid3hctx_x_recv <<= 4; 249 hctx->tx_x_recv <<= 4;
262 } 250 }
263 ccid3_hc_tx_update_x(sk, NULL); 251 ccid3_hc_tx_update_x(sk, NULL);
264 } 252 }
265 ccid3_pr_debug("Reduced X to %llu/64 bytes/sec\n", 253 ccid3_pr_debug("Reduced X to %llu/64 bytes/sec\n",
266 (unsigned long long)hctx->ccid3hctx_x); 254 (unsigned long long)hctx->tx_x);
267 255
268 /* 256 /*
269 * Set new timeout for the nofeedback timer. 257 * Set new timeout for the nofeedback timer.
270 * See comments in packet_recv() regarding the value of t_RTO. 258 * See comments in packet_recv() regarding the value of t_RTO.
271 */ 259 */
272 if (unlikely(hctx->ccid3hctx_t_rto == 0)) /* no feedback yet */ 260 if (unlikely(hctx->tx_t_rto == 0)) /* no feedback yet */
273 t_nfb = TFRC_INITIAL_TIMEOUT; 261 t_nfb = TFRC_INITIAL_TIMEOUT;
274 else 262 else
275 t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi); 263 t_nfb = max(hctx->tx_t_rto, 2 * hctx->tx_t_ipi);
276 264
277restart_timer: 265restart_timer:
278 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 266 sk_reset_timer(sk, &hctx->tx_no_feedback_timer,
279 jiffies + usecs_to_jiffies(t_nfb)); 267 jiffies + usecs_to_jiffies(t_nfb));
280out: 268out:
281 bh_unlock_sock(sk); 269 bh_unlock_sock(sk);
@@ -303,18 +291,17 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
303 if (unlikely(skb->len == 0)) 291 if (unlikely(skb->len == 0))
304 return -EBADMSG; 292 return -EBADMSG;
305 293
306 switch (hctx->ccid3hctx_state) { 294 switch (hctx->tx_state) {
307 case TFRC_SSTATE_NO_SENT: 295 case TFRC_SSTATE_NO_SENT:
308 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 296 sk_reset_timer(sk, &hctx->tx_no_feedback_timer, (jiffies +
309 (jiffies +
310 usecs_to_jiffies(TFRC_INITIAL_TIMEOUT))); 297 usecs_to_jiffies(TFRC_INITIAL_TIMEOUT)));
311 hctx->ccid3hctx_last_win_count = 0; 298 hctx->tx_last_win_count = 0;
312 hctx->ccid3hctx_t_last_win_count = now; 299 hctx->tx_t_last_win_count = now;
313 300
314 /* Set t_0 for initial packet */ 301 /* Set t_0 for initial packet */
315 hctx->ccid3hctx_t_nom = now; 302 hctx->tx_t_nom = now;
316 303
317 hctx->ccid3hctx_s = skb->len; 304 hctx->tx_s = skb->len;
318 305
319 /* 306 /*
320 * Use initial RTT sample when available: recommended by erratum 307 * Use initial RTT sample when available: recommended by erratum
@@ -323,9 +310,9 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
323 */ 310 */
324 if (dp->dccps_syn_rtt) { 311 if (dp->dccps_syn_rtt) {
325 ccid3_pr_debug("SYN RTT = %uus\n", dp->dccps_syn_rtt); 312 ccid3_pr_debug("SYN RTT = %uus\n", dp->dccps_syn_rtt);
326 hctx->ccid3hctx_rtt = dp->dccps_syn_rtt; 313 hctx->tx_rtt = dp->dccps_syn_rtt;
327 hctx->ccid3hctx_x = rfc3390_initial_rate(sk); 314 hctx->tx_x = rfc3390_initial_rate(sk);
328 hctx->ccid3hctx_t_ld = now; 315 hctx->tx_t_ld = now;
329 } else { 316 } else {
330 /* 317 /*
331 * Sender does not have RTT sample: 318 * Sender does not have RTT sample:
@@ -333,9 +320,9 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
333 * is needed in several parts (e.g. window counter); 320 * is needed in several parts (e.g. window counter);
334 * - set sending rate X_pps = 1pps as per RFC 3448, 4.2. 321 * - set sending rate X_pps = 1pps as per RFC 3448, 4.2.
335 */ 322 */
336 hctx->ccid3hctx_rtt = DCCP_FALLBACK_RTT; 323 hctx->tx_rtt = DCCP_FALLBACK_RTT;
337 hctx->ccid3hctx_x = hctx->ccid3hctx_s; 324 hctx->tx_x = hctx->tx_s;
338 hctx->ccid3hctx_x <<= 6; 325 hctx->tx_x <<= 6;
339 } 326 }
340 ccid3_update_send_interval(hctx); 327 ccid3_update_send_interval(hctx);
341 328
@@ -343,7 +330,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
343 break; 330 break;
344 case TFRC_SSTATE_NO_FBACK: 331 case TFRC_SSTATE_NO_FBACK:
345 case TFRC_SSTATE_FBACK: 332 case TFRC_SSTATE_FBACK:
346 delay = ktime_us_delta(hctx->ccid3hctx_t_nom, now); 333 delay = ktime_us_delta(hctx->tx_t_nom, now);
347 ccid3_pr_debug("delay=%ld\n", (long)delay); 334 ccid3_pr_debug("delay=%ld\n", (long)delay);
348 /* 335 /*
349 * Scheduling of packet transmissions [RFC 3448, 4.6] 336 * Scheduling of packet transmissions [RFC 3448, 4.6]
@@ -353,7 +340,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
353 * else 340 * else
354 * // send the packet in (t_nom - t_now) milliseconds. 341 * // send the packet in (t_nom - t_now) milliseconds.
355 */ 342 */
356 if (delay - (s64)hctx->ccid3hctx_delta >= 1000) 343 if (delay - (s64)hctx->tx_delta >= 1000)
357 return (u32)delay / 1000L; 344 return (u32)delay / 1000L;
358 345
359 ccid3_hc_tx_update_win_count(hctx, now); 346 ccid3_hc_tx_update_win_count(hctx, now);
@@ -365,11 +352,10 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
365 352
366 /* prepare to send now (add options etc.) */ 353 /* prepare to send now (add options etc.) */
367 dp->dccps_hc_tx_insert_options = 1; 354 dp->dccps_hc_tx_insert_options = 1;
368 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count; 355 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->tx_last_win_count;
369 356
370 /* set the nominal send time for the next following packet */ 357 /* set the nominal send time for the next following packet */
371 hctx->ccid3hctx_t_nom = ktime_add_us(hctx->ccid3hctx_t_nom, 358 hctx->tx_t_nom = ktime_add_us(hctx->tx_t_nom, hctx->tx_t_ipi);
372 hctx->ccid3hctx_t_ipi);
373 return 0; 359 return 0;
374} 360}
375 361
@@ -380,7 +366,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more,
380 366
381 ccid3_hc_tx_update_s(hctx, len); 367 ccid3_hc_tx_update_s(hctx, len);
382 368
383 if (tfrc_tx_hist_add(&hctx->ccid3hctx_hist, dccp_sk(sk)->dccps_gss)) 369 if (tfrc_tx_hist_add(&hctx->tx_hist, dccp_sk(sk)->dccps_gss))
384 DCCP_CRIT("packet history - out of memory!"); 370 DCCP_CRIT("packet history - out of memory!");
385} 371}
386 372
@@ -397,15 +383,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
397 DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK)) 383 DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK))
398 return; 384 return;
399 /* ... and only in the established state */ 385 /* ... and only in the established state */
400 if (hctx->ccid3hctx_state != TFRC_SSTATE_FBACK && 386 if (hctx->tx_state != TFRC_SSTATE_FBACK &&
401 hctx->ccid3hctx_state != TFRC_SSTATE_NO_FBACK) 387 hctx->tx_state != TFRC_SSTATE_NO_FBACK)
402 return; 388 return;
403 389
404 opt_recv = &hctx->ccid3hctx_options_received; 390 opt_recv = &hctx->tx_options_received;
405 now = ktime_get_real(); 391 now = ktime_get_real();
406 392
407 /* Estimate RTT from history if ACK number is valid */ 393 /* Estimate RTT from history if ACK number is valid */
408 r_sample = tfrc_tx_hist_rtt(hctx->ccid3hctx_hist, 394 r_sample = tfrc_tx_hist_rtt(hctx->tx_hist,
409 DCCP_SKB_CB(skb)->dccpd_ack_seq, now); 395 DCCP_SKB_CB(skb)->dccpd_ack_seq, now);
410 if (r_sample == 0) { 396 if (r_sample == 0) {
411 DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk, 397 DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk,
@@ -415,37 +401,37 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
415 } 401 }
416 402
417 /* Update receive rate in units of 64 * bytes/second */ 403 /* Update receive rate in units of 64 * bytes/second */
418 hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate; 404 hctx->tx_x_recv = opt_recv->ccid3or_receive_rate;
419 hctx->ccid3hctx_x_recv <<= 6; 405 hctx->tx_x_recv <<= 6;
420 406
421 /* Update loss event rate (which is scaled by 1e6) */ 407 /* Update loss event rate (which is scaled by 1e6) */
422 pinv = opt_recv->ccid3or_loss_event_rate; 408 pinv = opt_recv->ccid3or_loss_event_rate;
423 if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */ 409 if (pinv == ~0U || pinv == 0) /* see RFC 4342, 8.5 */
424 hctx->ccid3hctx_p = 0; 410 hctx->tx_p = 0;
425 else /* can not exceed 100% */ 411 else /* can not exceed 100% */
426 hctx->ccid3hctx_p = scaled_div(1, pinv); 412 hctx->tx_p = scaled_div(1, pinv);
427 /* 413 /*
428 * Validate new RTT sample and update moving average 414 * Validate new RTT sample and update moving average
429 */ 415 */
430 r_sample = dccp_sample_rtt(sk, r_sample); 416 r_sample = dccp_sample_rtt(sk, r_sample);
431 hctx->ccid3hctx_rtt = tfrc_ewma(hctx->ccid3hctx_rtt, r_sample, 9); 417 hctx->tx_rtt = tfrc_ewma(hctx->tx_rtt, r_sample, 9);
432 /* 418 /*
433 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3 419 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
434 */ 420 */
435 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) { 421 if (hctx->tx_state == TFRC_SSTATE_NO_FBACK) {
436 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); 422 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
437 423
438 if (hctx->ccid3hctx_t_rto == 0) { 424 if (hctx->tx_t_rto == 0) {
439 /* 425 /*
440 * Initial feedback packet: Larger Initial Windows (4.2) 426 * Initial feedback packet: Larger Initial Windows (4.2)
441 */ 427 */
442 hctx->ccid3hctx_x = rfc3390_initial_rate(sk); 428 hctx->tx_x = rfc3390_initial_rate(sk);
443 hctx->ccid3hctx_t_ld = now; 429 hctx->tx_t_ld = now;
444 430
445 ccid3_update_send_interval(hctx); 431 ccid3_update_send_interval(hctx);
446 432
447 goto done_computing_x; 433 goto done_computing_x;
448 } else if (hctx->ccid3hctx_p == 0) { 434 } else if (hctx->tx_p == 0) {
449 /* 435 /*
450 * First feedback after nofeedback timer expiry (4.3) 436 * First feedback after nofeedback timer expiry (4.3)
451 */ 437 */
@@ -454,25 +440,20 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
454 } 440 }
455 441
456 /* Update sending rate (step 4 of [RFC 3448, 4.3]) */ 442 /* Update sending rate (step 4 of [RFC 3448, 4.3]) */
457 if (hctx->ccid3hctx_p > 0) 443 if (hctx->tx_p > 0)
458 hctx->ccid3hctx_x_calc = 444 hctx->tx_x_calc = tfrc_calc_x(hctx->tx_s, hctx->tx_rtt, hctx->tx_p);
459 tfrc_calc_x(hctx->ccid3hctx_s,
460 hctx->ccid3hctx_rtt,
461 hctx->ccid3hctx_p);
462 ccid3_hc_tx_update_x(sk, &now); 445 ccid3_hc_tx_update_x(sk, &now);
463 446
464done_computing_x: 447done_computing_x:
465 ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, " 448 ccid3_pr_debug("%s(%p), RTT=%uus (sample=%uus), s=%u, "
466 "p=%u, X_calc=%u, X_recv=%u, X=%u\n", 449 "p=%u, X_calc=%u, X_recv=%u, X=%u\n",
467 dccp_role(sk), 450 dccp_role(sk), sk, hctx->tx_rtt, r_sample,
468 sk, hctx->ccid3hctx_rtt, r_sample, 451 hctx->tx_s, hctx->tx_p, hctx->tx_x_calc,
469 hctx->ccid3hctx_s, hctx->ccid3hctx_p, 452 (unsigned)(hctx->tx_x_recv >> 6),
470 hctx->ccid3hctx_x_calc, 453 (unsigned)(hctx->tx_x >> 6));
471 (unsigned)(hctx->ccid3hctx_x_recv >> 6),
472 (unsigned)(hctx->ccid3hctx_x >> 6));
473 454
474 /* unschedule no feedback timer */ 455 /* unschedule no feedback timer */
475 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer); 456 sk_stop_timer(sk, &hctx->tx_no_feedback_timer);
476 457
477 /* 458 /*
478 * As we have calculated new ipi, delta, t_nom it is possible 459 * As we have calculated new ipi, delta, t_nom it is possible
@@ -486,21 +467,19 @@ done_computing_x:
486 * This can help avoid triggering the nofeedback timer too 467 * This can help avoid triggering the nofeedback timer too
487 * often ('spinning') on LANs with small RTTs. 468 * often ('spinning') on LANs with small RTTs.
488 */ 469 */
489 hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt, 470 hctx->tx_t_rto = max_t(u32, 4 * hctx->tx_rtt, (CONFIG_IP_DCCP_CCID3_RTO *
490 (CONFIG_IP_DCCP_CCID3_RTO * 471 (USEC_PER_SEC / 1000)));
491 (USEC_PER_SEC / 1000)));
492 /* 472 /*
493 * Schedule no feedback timer to expire in 473 * Schedule no feedback timer to expire in
494 * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi) 474 * max(t_RTO, 2 * s/X) = max(t_RTO, 2 * t_ipi)
495 */ 475 */
496 t_nfb = max(hctx->ccid3hctx_t_rto, 2 * hctx->ccid3hctx_t_ipi); 476 t_nfb = max(hctx->tx_t_rto, 2 * hctx->tx_t_ipi);
497 477
498 ccid3_pr_debug("%s(%p), Scheduled no feedback timer to " 478 ccid3_pr_debug("%s(%p), Scheduled no feedback timer to "
499 "expire in %lu jiffies (%luus)\n", 479 "expire in %lu jiffies (%luus)\n",
500 dccp_role(sk), 480 dccp_role(sk), sk, usecs_to_jiffies(t_nfb), t_nfb);
501 sk, usecs_to_jiffies(t_nfb), t_nfb);
502 481
503 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 482 sk_reset_timer(sk, &hctx->tx_no_feedback_timer,
504 jiffies + usecs_to_jiffies(t_nfb)); 483 jiffies + usecs_to_jiffies(t_nfb));
505} 484}
506 485
@@ -514,7 +493,7 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
514 struct ccid3_options_received *opt_recv; 493 struct ccid3_options_received *opt_recv;
515 __be32 opt_val; 494 __be32 opt_val;
516 495
517 opt_recv = &hctx->ccid3hctx_options_received; 496 opt_recv = &hctx->tx_options_received;
518 497
519 if (opt_recv->ccid3or_seqno != dp->dccps_gsr) { 498 if (opt_recv->ccid3or_seqno != dp->dccps_gsr) {
520 opt_recv->ccid3or_seqno = dp->dccps_gsr; 499 opt_recv->ccid3or_seqno = dp->dccps_gsr;
@@ -570,11 +549,10 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
570{ 549{
571 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid); 550 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
572 551
573 hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; 552 hctx->tx_state = TFRC_SSTATE_NO_SENT;
574 hctx->ccid3hctx_hist = NULL; 553 hctx->tx_hist = NULL;
575 setup_timer(&hctx->ccid3hctx_no_feedback_timer, 554 setup_timer(&hctx->tx_no_feedback_timer,
576 ccid3_hc_tx_no_feedback_timer, (unsigned long)sk); 555 ccid3_hc_tx_no_feedback_timer, (unsigned long)sk);
577
578 return 0; 556 return 0;
579} 557}
580 558
@@ -583,9 +561,9 @@ static void ccid3_hc_tx_exit(struct sock *sk)
583 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 561 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
584 562
585 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM); 563 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM);
586 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer); 564 sk_stop_timer(sk, &hctx->tx_no_feedback_timer);
587 565
588 tfrc_tx_hist_purge(&hctx->ccid3hctx_hist); 566 tfrc_tx_hist_purge(&hctx->tx_hist);
589} 567}
590 568
591static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) 569static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
@@ -597,8 +575,8 @@ static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
597 return; 575 return;
598 576
599 hctx = ccid3_hc_tx_sk(sk); 577 hctx = ccid3_hc_tx_sk(sk);
600 info->tcpi_rto = hctx->ccid3hctx_t_rto; 578 info->tcpi_rto = hctx->tx_t_rto;
601 info->tcpi_rtt = hctx->ccid3hctx_rtt; 579 info->tcpi_rtt = hctx->tx_rtt;
602} 580}
603 581
604static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len, 582static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
@@ -614,10 +592,10 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
614 hctx = ccid3_hc_tx_sk(sk); 592 hctx = ccid3_hc_tx_sk(sk);
615 switch (optname) { 593 switch (optname) {
616 case DCCP_SOCKOPT_CCID_TX_INFO: 594 case DCCP_SOCKOPT_CCID_TX_INFO:
617 if (len < sizeof(hctx->ccid3hctx_tfrc)) 595 if (len < sizeof(hctx->tx_tfrc))
618 return -EINVAL; 596 return -EINVAL;
619 len = sizeof(hctx->ccid3hctx_tfrc); 597 len = sizeof(hctx->tx_tfrc);
620 val = &hctx->ccid3hctx_tfrc; 598 val = &hctx->tx_tfrc;
621 break; 599 break;
622 default: 600 default:
623 return -ENOPROTOOPT; 601 return -ENOPROTOOPT;
@@ -658,13 +636,13 @@ static void ccid3_hc_rx_set_state(struct sock *sk,
658 enum ccid3_hc_rx_states state) 636 enum ccid3_hc_rx_states state)
659{ 637{
660 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 638 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
661 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; 639 enum ccid3_hc_rx_states oldstate = hcrx->rx_state;
662 640
663 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", 641 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
664 dccp_role(sk), sk, ccid3_rx_state_name(oldstate), 642 dccp_role(sk), sk, ccid3_rx_state_name(oldstate),
665 ccid3_rx_state_name(state)); 643 ccid3_rx_state_name(state));
666 WARN_ON(state == oldstate); 644 WARN_ON(state == oldstate);
667 hcrx->ccid3hcrx_state = state; 645 hcrx->rx_state = state;
668} 646}
669 647
670static void ccid3_hc_rx_send_feedback(struct sock *sk, 648static void ccid3_hc_rx_send_feedback(struct sock *sk,
@@ -676,15 +654,15 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
676 ktime_t now; 654 ktime_t now;
677 s64 delta = 0; 655 s64 delta = 0;
678 656
679 if (unlikely(hcrx->ccid3hcrx_state == TFRC_RSTATE_TERM)) 657 if (unlikely(hcrx->rx_state == TFRC_RSTATE_TERM))
680 return; 658 return;
681 659
682 now = ktime_get_real(); 660 now = ktime_get_real();
683 661
684 switch (fbtype) { 662 switch (fbtype) {
685 case CCID3_FBACK_INITIAL: 663 case CCID3_FBACK_INITIAL:
686 hcrx->ccid3hcrx_x_recv = 0; 664 hcrx->rx_x_recv = 0;
687 hcrx->ccid3hcrx_pinv = ~0U; /* see RFC 4342, 8.5 */ 665 hcrx->rx_pinv = ~0U; /* see RFC 4342, 8.5 */
688 break; 666 break;
689 case CCID3_FBACK_PARAM_CHANGE: 667 case CCID3_FBACK_PARAM_CHANGE:
690 /* 668 /*
@@ -697,27 +675,26 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
697 * the number of bytes since last feedback. 675 * the number of bytes since last feedback.
698 * This is a safe fallback, since X is bounded above by X_calc. 676 * This is a safe fallback, since X is bounded above by X_calc.
699 */ 677 */
700 if (hcrx->ccid3hcrx_x_recv > 0) 678 if (hcrx->rx_x_recv > 0)
701 break; 679 break;
702 /* fall through */ 680 /* fall through */
703 case CCID3_FBACK_PERIODIC: 681 case CCID3_FBACK_PERIODIC:
704 delta = ktime_us_delta(now, hcrx->ccid3hcrx_tstamp_last_feedback); 682 delta = ktime_us_delta(now, hcrx->rx_tstamp_last_feedback);
705 if (delta <= 0) 683 if (delta <= 0)
706 DCCP_BUG("delta (%ld) <= 0", (long)delta); 684 DCCP_BUG("delta (%ld) <= 0", (long)delta);
707 else 685 else
708 hcrx->ccid3hcrx_x_recv = 686 hcrx->rx_x_recv = scaled_div32(hcrx->rx_bytes_recv, delta);
709 scaled_div32(hcrx->ccid3hcrx_bytes_recv, delta);
710 break; 687 break;
711 default: 688 default:
712 return; 689 return;
713 } 690 }
714 691
715 ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta, 692 ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta,
716 hcrx->ccid3hcrx_x_recv, hcrx->ccid3hcrx_pinv); 693 hcrx->rx_x_recv, hcrx->rx_pinv);
717 694
718 hcrx->ccid3hcrx_tstamp_last_feedback = now; 695 hcrx->rx_tstamp_last_feedback = now;
719 hcrx->ccid3hcrx_last_counter = dccp_hdr(skb)->dccph_ccval; 696 hcrx->rx_last_counter = dccp_hdr(skb)->dccph_ccval;
720 hcrx->ccid3hcrx_bytes_recv = 0; 697 hcrx->rx_bytes_recv = 0;
721 698
722 dp->dccps_hc_rx_insert_options = 1; 699 dp->dccps_hc_rx_insert_options = 1;
723 dccp_send_ack(sk); 700 dccp_send_ack(sk);
@@ -736,8 +713,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
736 if (dccp_packet_without_ack(skb)) 713 if (dccp_packet_without_ack(skb))
737 return 0; 714 return 0;
738 715
739 x_recv = htonl(hcrx->ccid3hcrx_x_recv); 716 x_recv = htonl(hcrx->rx_x_recv);
740 pinv = htonl(hcrx->ccid3hcrx_pinv); 717 pinv = htonl(hcrx->rx_pinv);
741 718
742 if (dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE, 719 if (dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE,
743 &pinv, sizeof(pinv)) || 720 &pinv, sizeof(pinv)) ||
@@ -764,22 +741,22 @@ static u32 ccid3_first_li(struct sock *sk)
764 u32 x_recv, p, delta; 741 u32 x_recv, p, delta;
765 u64 fval; 742 u64 fval;
766 743
767 if (hcrx->ccid3hcrx_rtt == 0) { 744 if (hcrx->rx_rtt == 0) {
768 DCCP_WARN("No RTT estimate available, using fallback RTT\n"); 745 DCCP_WARN("No RTT estimate available, using fallback RTT\n");
769 hcrx->ccid3hcrx_rtt = DCCP_FALLBACK_RTT; 746 hcrx->rx_rtt = DCCP_FALLBACK_RTT;
770 } 747 }
771 748
772 delta = ktime_to_us(net_timedelta(hcrx->ccid3hcrx_tstamp_last_feedback)); 749 delta = ktime_to_us(net_timedelta(hcrx->rx_tstamp_last_feedback));
773 x_recv = scaled_div32(hcrx->ccid3hcrx_bytes_recv, delta); 750 x_recv = scaled_div32(hcrx->rx_bytes_recv, delta);
774 if (x_recv == 0) { /* would also trigger divide-by-zero */ 751 if (x_recv == 0) { /* would also trigger divide-by-zero */
775 DCCP_WARN("X_recv==0\n"); 752 DCCP_WARN("X_recv==0\n");
776 if ((x_recv = hcrx->ccid3hcrx_x_recv) == 0) { 753 if ((x_recv = hcrx->rx_x_recv) == 0) {
777 DCCP_BUG("stored value of X_recv is zero"); 754 DCCP_BUG("stored value of X_recv is zero");
778 return ~0U; 755 return ~0U;
779 } 756 }
780 } 757 }
781 758
782 fval = scaled_div(hcrx->ccid3hcrx_s, hcrx->ccid3hcrx_rtt); 759 fval = scaled_div(hcrx->rx_s, hcrx->rx_rtt);
783 fval = scaled_div32(fval, x_recv); 760 fval = scaled_div32(fval, x_recv);
784 p = tfrc_calc_x_reverse_lookup(fval); 761 p = tfrc_calc_x_reverse_lookup(fval);
785 762
@@ -796,14 +773,14 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
796 const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp; 773 const u64 ndp = dccp_sk(sk)->dccps_options_received.dccpor_ndp;
797 const bool is_data_packet = dccp_data_packet(skb); 774 const bool is_data_packet = dccp_data_packet(skb);
798 775
799 if (unlikely(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)) { 776 if (unlikely(hcrx->rx_state == TFRC_RSTATE_NO_DATA)) {
800 if (is_data_packet) { 777 if (is_data_packet) {
801 const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4; 778 const u32 payload = skb->len - dccp_hdr(skb)->dccph_doff * 4;
802 do_feedback = CCID3_FBACK_INITIAL; 779 do_feedback = CCID3_FBACK_INITIAL;
803 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); 780 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
804 hcrx->ccid3hcrx_s = payload; 781 hcrx->rx_s = payload;
805 /* 782 /*
806 * Not necessary to update ccid3hcrx_bytes_recv here, 783 * Not necessary to update rx_bytes_recv here,
807 * since X_recv = 0 for the first feedback packet (cf. 784 * since X_recv = 0 for the first feedback packet (cf.
808 * RFC 3448, 6.3) -- gerrit 785 * RFC 3448, 6.3) -- gerrit
809 */ 786 */
@@ -811,7 +788,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
811 goto update_records; 788 goto update_records;
812 } 789 }
813 790
814 if (tfrc_rx_hist_duplicate(&hcrx->ccid3hcrx_hist, skb)) 791 if (tfrc_rx_hist_duplicate(&hcrx->rx_hist, skb))
815 return; /* done receiving */ 792 return; /* done receiving */
816 793
817 if (is_data_packet) { 794 if (is_data_packet) {
@@ -819,20 +796,20 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
819 /* 796 /*
820 * Update moving-average of s and the sum of received payload bytes 797 * Update moving-average of s and the sum of received payload bytes
821 */ 798 */
822 hcrx->ccid3hcrx_s = tfrc_ewma(hcrx->ccid3hcrx_s, payload, 9); 799 hcrx->rx_s = tfrc_ewma(hcrx->rx_s, payload, 9);
823 hcrx->ccid3hcrx_bytes_recv += payload; 800 hcrx->rx_bytes_recv += payload;
824 } 801 }
825 802
826 /* 803 /*
827 * Perform loss detection and handle pending losses 804 * Perform loss detection and handle pending losses
828 */ 805 */
829 if (tfrc_rx_handle_loss(&hcrx->ccid3hcrx_hist, &hcrx->ccid3hcrx_li_hist, 806 if (tfrc_rx_handle_loss(&hcrx->rx_hist, &hcrx->rx_li_hist,
830 skb, ndp, ccid3_first_li, sk)) { 807 skb, ndp, ccid3_first_li, sk)) {
831 do_feedback = CCID3_FBACK_PARAM_CHANGE; 808 do_feedback = CCID3_FBACK_PARAM_CHANGE;
832 goto done_receiving; 809 goto done_receiving;
833 } 810 }
834 811
835 if (tfrc_rx_hist_loss_pending(&hcrx->ccid3hcrx_hist)) 812 if (tfrc_rx_hist_loss_pending(&hcrx->rx_hist))
836 return; /* done receiving */ 813 return; /* done receiving */
837 814
838 /* 815 /*
@@ -841,17 +818,17 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
841 if (unlikely(!is_data_packet)) 818 if (unlikely(!is_data_packet))
842 goto update_records; 819 goto update_records;
843 820
844 if (!tfrc_lh_is_initialised(&hcrx->ccid3hcrx_li_hist)) { 821 if (!tfrc_lh_is_initialised(&hcrx->rx_li_hist)) {
845 const u32 sample = tfrc_rx_hist_sample_rtt(&hcrx->ccid3hcrx_hist, skb); 822 const u32 sample = tfrc_rx_hist_sample_rtt(&hcrx->rx_hist, skb);
846 /* 823 /*
847 * Empty loss history: no loss so far, hence p stays 0. 824 * Empty loss history: no loss so far, hence p stays 0.
848 * Sample RTT values, since an RTT estimate is required for the 825 * Sample RTT values, since an RTT estimate is required for the
849 * computation of p when the first loss occurs; RFC 3448, 6.3.1. 826 * computation of p when the first loss occurs; RFC 3448, 6.3.1.
850 */ 827 */
851 if (sample != 0) 828 if (sample != 0)
852 hcrx->ccid3hcrx_rtt = tfrc_ewma(hcrx->ccid3hcrx_rtt, sample, 9); 829 hcrx->rx_rtt = tfrc_ewma(hcrx->rx_rtt, sample, 9);
853 830
854 } else if (tfrc_lh_update_i_mean(&hcrx->ccid3hcrx_li_hist, skb)) { 831 } else if (tfrc_lh_update_i_mean(&hcrx->rx_li_hist, skb)) {
855 /* 832 /*
856 * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean 833 * Step (3) of [RFC 3448, 6.1]: Recompute I_mean and, if I_mean
857 * has decreased (resp. p has increased), send feedback now. 834 * has decreased (resp. p has increased), send feedback now.
@@ -862,11 +839,11 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
862 /* 839 /*
863 * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3 840 * Check if the periodic once-per-RTT feedback is due; RFC 4342, 10.3
864 */ 841 */
865 if (SUB16(dccp_hdr(skb)->dccph_ccval, hcrx->ccid3hcrx_last_counter) > 3) 842 if (SUB16(dccp_hdr(skb)->dccph_ccval, hcrx->rx_last_counter) > 3)
866 do_feedback = CCID3_FBACK_PERIODIC; 843 do_feedback = CCID3_FBACK_PERIODIC;
867 844
868update_records: 845update_records:
869 tfrc_rx_hist_add_packet(&hcrx->ccid3hcrx_hist, skb, ndp); 846 tfrc_rx_hist_add_packet(&hcrx->rx_hist, skb, ndp);
870 847
871done_receiving: 848done_receiving:
872 if (do_feedback) 849 if (do_feedback)
@@ -877,9 +854,9 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
877{ 854{
878 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid); 855 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
879 856
880 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; 857 hcrx->rx_state = TFRC_RSTATE_NO_DATA;
881 tfrc_lh_init(&hcrx->ccid3hcrx_li_hist); 858 tfrc_lh_init(&hcrx->rx_li_hist);
882 return tfrc_rx_hist_alloc(&hcrx->ccid3hcrx_hist); 859 return tfrc_rx_hist_alloc(&hcrx->rx_hist);
883} 860}
884 861
885static void ccid3_hc_rx_exit(struct sock *sk) 862static void ccid3_hc_rx_exit(struct sock *sk)
@@ -888,8 +865,8 @@ static void ccid3_hc_rx_exit(struct sock *sk)
888 865
889 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); 866 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);
890 867
891 tfrc_rx_hist_purge(&hcrx->ccid3hcrx_hist); 868 tfrc_rx_hist_purge(&hcrx->rx_hist);
892 tfrc_lh_cleanup(&hcrx->ccid3hcrx_li_hist); 869 tfrc_lh_cleanup(&hcrx->rx_li_hist);
893} 870}
894 871
895static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 872static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
@@ -901,9 +878,9 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
901 return; 878 return;
902 879
903 hcrx = ccid3_hc_rx_sk(sk); 880 hcrx = ccid3_hc_rx_sk(sk);
904 info->tcpi_ca_state = hcrx->ccid3hcrx_state; 881 info->tcpi_ca_state = hcrx->rx_state;
905 info->tcpi_options |= TCPI_OPT_TIMESTAMPS; 882 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
906 info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt; 883 info->tcpi_rcv_rtt = hcrx->rx_rtt;
907} 884}
908 885
909static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len, 886static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
@@ -922,10 +899,10 @@ static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
922 case DCCP_SOCKOPT_CCID_RX_INFO: 899 case DCCP_SOCKOPT_CCID_RX_INFO:
923 if (len < sizeof(rx_info)) 900 if (len < sizeof(rx_info))
924 return -EINVAL; 901 return -EINVAL;
925 rx_info.tfrcrx_x_recv = hcrx->ccid3hcrx_x_recv; 902 rx_info.tfrcrx_x_recv = hcrx->rx_x_recv;
926 rx_info.tfrcrx_rtt = hcrx->ccid3hcrx_rtt; 903 rx_info.tfrcrx_rtt = hcrx->rx_rtt;
927 rx_info.tfrcrx_p = hcrx->ccid3hcrx_pinv == 0 ? ~0U : 904 rx_info.tfrcrx_p = hcrx->rx_pinv == 0 ? ~0U :
928 scaled_div(1, hcrx->ccid3hcrx_pinv); 905 scaled_div(1, hcrx->rx_pinv);
929 len = sizeof(rx_info); 906 len = sizeof(rx_info);
930 val = &rx_info; 907 val = &rx_info;
931 break; 908 break;
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index e5a244143846..032635776653 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -75,44 +75,44 @@ enum ccid3_hc_tx_states {
75 75
76/** 76/**
77 * struct ccid3_hc_tx_sock - CCID3 sender half-connection socket 77 * struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
78 * @ccid3hctx_x - Current sending rate in 64 * bytes per second 78 * @tx_x: Current sending rate in 64 * bytes per second
79 * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second 79 * @tx_x_recv: Receive rate in 64 * bytes per second
80 * @ccid3hctx_x_calc - Calculated rate in bytes per second 80 * @tx_x_calc: Calculated rate in bytes per second
81 * @ccid3hctx_rtt - Estimate of current round trip time in usecs 81 * @tx_rtt: Estimate of current round trip time in usecs
82 * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 82 * @tx_p: Current loss event rate (0-1) scaled by 1000000
83 * @ccid3hctx_s - Packet size in bytes 83 * @tx_s: Packet size in bytes
84 * @ccid3hctx_t_rto - Nofeedback Timer setting in usecs 84 * @tx_t_rto: Nofeedback Timer setting in usecs
85 * @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) in usecs 85 * @tx_t_ipi: Interpacket (send) interval (RFC 3448, 4.6) in usecs
86 * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states 86 * @tx_state: Sender state, one of %ccid3_hc_tx_states
87 * @ccid3hctx_last_win_count - Last window counter sent 87 * @tx_last_win_count: Last window counter sent
88 * @ccid3hctx_t_last_win_count - Timestamp of earliest packet 88 * @tx_t_last_win_count: Timestamp of earliest packet
89 * with last_win_count value sent 89 * with last_win_count value sent
90 * @ccid3hctx_no_feedback_timer - Handle to no feedback timer 90 * @tx_no_feedback_timer: Handle to no feedback timer
91 * @ccid3hctx_t_ld - Time last doubled during slow start 91 * @tx_t_ld: Time last doubled during slow start
92 * @ccid3hctx_t_nom - Nominal send time of next packet 92 * @tx_t_nom: Nominal send time of next packet
93 * @ccid3hctx_delta - Send timer delta (RFC 3448, 4.6) in usecs 93 * @tx_delta: Send timer delta (RFC 3448, 4.6) in usecs
94 * @ccid3hctx_hist - Packet history 94 * @tx_hist: Packet history
95 * @ccid3hctx_options_received - Parsed set of retrieved options 95 * @tx_options_received: Parsed set of retrieved options
96 */ 96 */
97struct ccid3_hc_tx_sock { 97struct ccid3_hc_tx_sock {
98 struct tfrc_tx_info ccid3hctx_tfrc; 98 struct tfrc_tx_info tx_tfrc;
99#define ccid3hctx_x ccid3hctx_tfrc.tfrctx_x 99#define tx_x tx_tfrc.tfrctx_x
100#define ccid3hctx_x_recv ccid3hctx_tfrc.tfrctx_x_recv 100#define tx_x_recv tx_tfrc.tfrctx_x_recv
101#define ccid3hctx_x_calc ccid3hctx_tfrc.tfrctx_x_calc 101#define tx_x_calc tx_tfrc.tfrctx_x_calc
102#define ccid3hctx_rtt ccid3hctx_tfrc.tfrctx_rtt 102#define tx_rtt tx_tfrc.tfrctx_rtt
103#define ccid3hctx_p ccid3hctx_tfrc.tfrctx_p 103#define tx_p tx_tfrc.tfrctx_p
104#define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto 104#define tx_t_rto tx_tfrc.tfrctx_rto
105#define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi 105#define tx_t_ipi tx_tfrc.tfrctx_ipi
106 u16 ccid3hctx_s; 106 u16 tx_s;
107 enum ccid3_hc_tx_states ccid3hctx_state:8; 107 enum ccid3_hc_tx_states tx_state:8;
108 u8 ccid3hctx_last_win_count; 108 u8 tx_last_win_count;
109 ktime_t ccid3hctx_t_last_win_count; 109 ktime_t tx_t_last_win_count;
110 struct timer_list ccid3hctx_no_feedback_timer; 110 struct timer_list tx_no_feedback_timer;
111 ktime_t ccid3hctx_t_ld; 111 ktime_t tx_t_ld;
112 ktime_t ccid3hctx_t_nom; 112 ktime_t tx_t_nom;
113 u32 ccid3hctx_delta; 113 u32 tx_delta;
114 struct tfrc_tx_hist_entry *ccid3hctx_hist; 114 struct tfrc_tx_hist_entry *tx_hist;
115 struct ccid3_options_received ccid3hctx_options_received; 115 struct ccid3_options_received tx_options_received;
116}; 116};
117 117
118static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 118static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
@@ -131,32 +131,32 @@ enum ccid3_hc_rx_states {
131 131
132/** 132/**
133 * struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket 133 * struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket
134 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) 134 * @rx_x_recv: Receiver estimate of send rate (RFC 3448 4.3)
135 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) 135 * @rx_rtt: Receiver estimate of rtt (non-standard)
136 * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4) 136 * @rx_p: Current loss event rate (RFC 3448 5.4)
137 * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) 137 * @rx_last_counter: Tracks window counter (RFC 4342, 8.1)
138 * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states 138 * @rx_state: Receiver state, one of %ccid3_hc_rx_states
139 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes 139 * @rx_bytes_recv: Total sum of DCCP payload bytes
140 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) 140 * @rx_x_recv: Receiver estimate of send rate (RFC 3448, sec. 4.3)
141 * @ccid3hcrx_rtt - Receiver estimate of RTT 141 * @rx_rtt: Receiver estimate of RTT
142 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent 142 * @rx_tstamp_last_feedback: Time at which last feedback was sent
143 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent 143 * @rx_tstamp_last_ack: Time at which last feedback was sent
144 * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling) 144 * @rx_hist: Packet history (loss detection + RTT sampling)
145 * @ccid3hcrx_li_hist - Loss Interval database 145 * @rx_li_hist: Loss Interval database
146 * @ccid3hcrx_s - Received packet size in bytes 146 * @rx_s: Received packet size in bytes
147 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) 147 * @rx_pinv: Inverse of Loss Event Rate (RFC 4342, sec. 8.5)
148 */ 148 */
149struct ccid3_hc_rx_sock { 149struct ccid3_hc_rx_sock {
150 u8 ccid3hcrx_last_counter:4; 150 u8 rx_last_counter:4;
151 enum ccid3_hc_rx_states ccid3hcrx_state:8; 151 enum ccid3_hc_rx_states rx_state:8;
152 u32 ccid3hcrx_bytes_recv; 152 u32 rx_bytes_recv;
153 u32 ccid3hcrx_x_recv; 153 u32 rx_x_recv;
154 u32 ccid3hcrx_rtt; 154 u32 rx_rtt;
155 ktime_t ccid3hcrx_tstamp_last_feedback; 155 ktime_t rx_tstamp_last_feedback;
156 struct tfrc_rx_hist ccid3hcrx_hist; 156 struct tfrc_rx_hist rx_hist;
157 struct tfrc_loss_hist ccid3hcrx_li_hist; 157 struct tfrc_loss_hist rx_li_hist;
158 u16 ccid3hcrx_s; 158 u16 rx_s;
159#define ccid3hcrx_pinv ccid3hcrx_li_hist.i_mean 159#define rx_pinv rx_li_hist.i_mean
160}; 160};
161 161
162static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) 162static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 37731da41481..430d16fd6f59 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -83,14 +83,12 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
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 (hctx)
86 printl("%pI4:%u %pI4:%u %d %d %d %d %u " 86 printl("%pI4:%u %pI4:%u %d %d %d %d %u %llu %llu %d\n",
87 "%llu %llu %d\n",
88 &inet->saddr, ntohs(inet->sport), 87 &inet->saddr, ntohs(inet->sport),
89 &inet->daddr, ntohs(inet->dport), size, 88 &inet->daddr, ntohs(inet->dport), size,
90 hctx->ccid3hctx_s, hctx->ccid3hctx_rtt, 89 hctx->tx_s, hctx->tx_rtt, hctx->tx_p,
91 hctx->ccid3hctx_p, hctx->ccid3hctx_x_calc, 90 hctx->tx_x_calc, hctx->tx_x_recv >> 6,
92 hctx->ccid3hctx_x_recv >> 6, 91 hctx->tx_x >> 6, hctx->tx_t_ipi);
93 hctx->ccid3hctx_x >> 6, hctx->ccid3hctx_t_ipi);
94 else 92 else
95 printl("%pI4:%u %pI4:%u %d\n", 93 printl("%pI4:%u %pI4:%u %d\n",
96 &inet->saddr, ntohs(inet->sport), 94 &inet->saddr, ntohs(inet->sport),