2 * net/dccp/ccids/ccid3.c
4 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
5 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz>
7 * An implementation of the DCCP protocol
9 * This code has been developed by the University of Waikato WAND
10 * research group. For further information please see http://www.wand.net.nz/
12 * This code also uses code from Lulea University, rereleased as GPL by its
14 * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon
16 * Changes to meet Linux coding standards, to make it meet latest ccid3 draft
17 * and to make it work as a loadable module in the DCCP stack written by
18 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>.
20 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
39 #include "lib/packet_history.h"
40 #include "lib/loss_interval.h"
45 * Reason for maths here is to avoid 32 bit overflow when a is big.
46 * With this we get close to the limit.
48 static u32 usecs_div(const u32 a, const u32 b)
50 const u32 div = a < (UINT_MAX / (USEC_PER_SEC / 10)) ? 10 :
51 a < (UINT_MAX / (USEC_PER_SEC / 50)) ? 50 :
52 a < (UINT_MAX / (USEC_PER_SEC / 100)) ? 100 :
53 a < (UINT_MAX / (USEC_PER_SEC / 500)) ? 500 :
54 a < (UINT_MAX / (USEC_PER_SEC / 1000)) ? 1000 :
55 a < (UINT_MAX / (USEC_PER_SEC / 5000)) ? 5000 :
56 a < (UINT_MAX / (USEC_PER_SEC / 10000)) ? 10000 :
57 a < (UINT_MAX / (USEC_PER_SEC / 50000)) ? 50000 :
59 const u32 tmp = a * (USEC_PER_SEC / div);
60 return (b >= 2 * div) ? tmp / (b / div) : tmp;
63 static int ccid3_debug;
66 #define ccid3_pr_debug(format, a...) \
67 do { if (ccid3_debug) \
68 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
71 #define ccid3_pr_debug(format, a...)
74 static struct dccp_tx_hist *ccid3_tx_hist;
75 static struct dccp_rx_hist *ccid3_rx_hist;
76 static struct dccp_li_hist *ccid3_li_hist;
79 static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state)
81 static char *ccid3_state_names[] = {
82 [TFRC_SSTATE_NO_SENT] = "NO_SENT",
83 [TFRC_SSTATE_NO_FBACK] = "NO_FBACK",
84 [TFRC_SSTATE_FBACK] = "FBACK",
85 [TFRC_SSTATE_TERM] = "TERM",
88 return ccid3_state_names[state];
92 static void ccid3_hc_tx_set_state(struct sock *sk,
93 enum ccid3_hc_tx_states state)
95 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
96 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state;
98 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
99 dccp_role(sk), sk, ccid3_tx_state_name(oldstate),
100 ccid3_tx_state_name(state));
101 WARN_ON(state == oldstate);
102 hctx->ccid3hctx_state = state;
105 /* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */
106 static inline void ccid3_calc_new_t_ipi(struct ccid3_hc_tx_sock *hctx)
109 * If no feedback spec says t_ipi is 1 second (set elsewhere and then
110 * doubles after every no feedback timer (separate function)
112 if (hctx->ccid3hctx_state != TFRC_SSTATE_NO_FBACK)
113 hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s,
117 /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */
118 static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx)
120 hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
121 TFRC_OPSYS_HALF_TIME_GRAN);
127 * x_calc = calcX(s, R, p);
128 * X = max(min(X_calc, 2 * X_recv), s / t_mbi);
130 * If (now - tld >= R)
131 * X = max(min(2 * X, 2 * X_recv), s / R);
134 static void ccid3_hc_tx_update_x(struct sock *sk)
136 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
138 /* To avoid large error in calcX */
139 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) {
140 hctx->ccid3hctx_x_calc = tfrc_calc_x(hctx->ccid3hctx_s,
143 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_calc,
144 2 * hctx->ccid3hctx_x_recv),
146 TFRC_MAX_BACK_OFF_TIME));
150 dccp_timestamp(sk, &now);
151 if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >=
152 hctx->ccid3hctx_rtt) {
153 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv,
154 hctx->ccid3hctx_x) * 2,
155 usecs_div(hctx->ccid3hctx_s,
156 hctx->ccid3hctx_rtt));
157 hctx->ccid3hctx_t_ld = now;
162 static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
164 struct sock *sk = (struct sock *)data;
165 unsigned long next_tmout = 0;
166 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
169 if (sock_owned_by_user(sk)) {
170 /* Try again later. */
171 /* XXX: set some sensible MIB */
172 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
177 ccid3_pr_debug("%s, sk=%p, state=%s\n", dccp_role(sk), sk,
178 ccid3_tx_state_name(hctx->ccid3hctx_state));
180 switch (hctx->ccid3hctx_state) {
181 case TFRC_SSTATE_TERM:
183 case TFRC_SSTATE_NO_FBACK:
184 /* Halve send rate */
185 hctx->ccid3hctx_x /= 2;
186 if (hctx->ccid3hctx_x < (hctx->ccid3hctx_s /
187 TFRC_MAX_BACK_OFF_TIME))
188 hctx->ccid3hctx_x = (hctx->ccid3hctx_s /
189 TFRC_MAX_BACK_OFF_TIME);
191 ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d "
194 ccid3_tx_state_name(hctx->ccid3hctx_state),
196 next_tmout = max_t(u32, 2 * usecs_div(hctx->ccid3hctx_s,
198 TFRC_INITIAL_TIMEOUT);
200 * FIXME - not sure above calculation is correct. See section
201 * 5 of CCID3 11 should adjust tx_t_ipi and double that to
205 case TFRC_SSTATE_FBACK:
207 * Check if IDLE since last timeout and recv rate is less than
210 if (!hctx->ccid3hctx_idle ||
211 (hctx->ccid3hctx_x_recv >=
212 4 * usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_rtt))) {
213 ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n",
215 ccid3_tx_state_name(hctx->ccid3hctx_state));
216 /* Halve sending rate */
218 /* If (X_calc > 2 * X_recv)
219 * X_recv = max(X_recv / 2, s / (2 * t_mbi));
221 * X_recv = X_calc / 4;
223 BUG_ON(hctx->ccid3hctx_p >= TFRC_SMALLEST_P &&
224 hctx->ccid3hctx_x_calc == 0);
226 /* check also if p is zero -> x_calc is infinity? */
227 if (hctx->ccid3hctx_p < TFRC_SMALLEST_P ||
228 hctx->ccid3hctx_x_calc > 2 * hctx->ccid3hctx_x_recv)
229 hctx->ccid3hctx_x_recv = max_t(u32, hctx->ccid3hctx_x_recv / 2,
230 hctx->ccid3hctx_s / (2 * TFRC_MAX_BACK_OFF_TIME));
232 hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc / 4;
234 /* Update sending rate */
235 ccid3_hc_tx_update_x(sk);
238 * Schedule no feedback timer to expire in
239 * max(4 * R, 2 * s / X)
241 next_tmout = max_t(u32, hctx->ccid3hctx_t_rto,
242 2 * usecs_div(hctx->ccid3hctx_s,
246 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
247 hctx->ccid3hctx_state);
251 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
252 jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout)));
253 hctx->ccid3hctx_idle = 1;
259 static int ccid3_hc_tx_send_packet(struct sock *sk,
260 struct sk_buff *skb, int len)
262 struct dccp_sock *dp = dccp_sk(sk);
263 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
264 struct dccp_tx_hist_entry *new_packet;
269 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
271 /* Check if pure ACK or Terminating*/
273 * XXX: We only call this function for DATA and DATAACK, on, these
274 * packets can have zero length, but why the comment about "pure ACK"?
276 if (unlikely(len == 0))
279 /* See if last packet allocated was not sent */
280 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
281 if (new_packet == NULL || new_packet->dccphtx_sent) {
282 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
286 if (unlikely(new_packet == NULL)) {
287 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough "
288 "mem to add to history, send refused\n",
289 __FUNCTION__, dccp_role(sk), sk);
293 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
296 dccp_timestamp(sk, &now);
298 switch (hctx->ccid3hctx_state) {
299 case TFRC_SSTATE_NO_SENT:
300 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
301 jiffies + usecs_to_jiffies(TFRC_INITIAL_TIMEOUT));
302 hctx->ccid3hctx_last_win_count = 0;
303 hctx->ccid3hctx_t_last_win_count = now;
304 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
305 hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI;
307 /* Set nominal send time for initial packet */
308 hctx->ccid3hctx_t_nom = now;
309 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
310 hctx->ccid3hctx_t_ipi);
311 ccid3_calc_new_delta(hctx);
314 case TFRC_SSTATE_NO_FBACK:
315 case TFRC_SSTATE_FBACK:
316 delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) -
317 hctx->ccid3hctx_delta);
319 /* divide by -1000 is to convert to ms and get sign right */
320 rc = delay > 0 ? delay : 0;
323 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
324 hctx->ccid3hctx_state);
329 /* Can we send? if so add options and add to packet history */
331 dp->dccps_hc_tx_insert_options = 1;
332 new_packet->dccphtx_ccval =
333 DCCP_SKB_CB(skb)->dccpd_ccval =
334 hctx->ccid3hctx_last_win_count;
335 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
336 hctx->ccid3hctx_t_ipi);
342 static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
344 const struct dccp_sock *dp = dccp_sk(sk);
345 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
348 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
350 dccp_timestamp(sk, &now);
352 /* check if we have sent a data packet */
354 unsigned long quarter_rtt;
355 struct dccp_tx_hist_entry *packet;
357 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
358 if (unlikely(packet == NULL)) {
359 LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't "
360 "exists in history!\n", __FUNCTION__);
363 if (unlikely(packet->dccphtx_sent)) {
364 LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in "
365 "history!\n", __FUNCTION__);
368 packet->dccphtx_tstamp = now;
369 packet->dccphtx_seqno = dp->dccps_gss;
371 * Check if win_count have changed
372 * Algorithm in "8.1. Window Counter Value" in RFC 4342.
374 quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count);
375 if (likely(hctx->ccid3hctx_rtt > 8))
376 quarter_rtt /= hctx->ccid3hctx_rtt / 4;
378 if (quarter_rtt > 0) {
379 hctx->ccid3hctx_t_last_win_count = now;
380 hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count +
381 min_t(unsigned long, quarter_rtt, 5)) % 16;
382 ccid3_pr_debug("%s, sk=%p, window changed from "
385 packet->dccphtx_ccval,
386 hctx->ccid3hctx_last_win_count);
389 hctx->ccid3hctx_idle = 0;
390 packet->dccphtx_rtt = hctx->ccid3hctx_rtt;
391 packet->dccphtx_sent = 1;
393 ccid3_pr_debug("%s, sk=%p, seqno=%llu NOT inserted!\n",
394 dccp_role(sk), sk, dp->dccps_gss);
396 switch (hctx->ccid3hctx_state) {
397 case TFRC_SSTATE_NO_SENT:
398 /* if first wasn't pure ack */
400 printk(KERN_CRIT "%s: %s, First packet sent is noted "
401 "as a data packet\n",
402 __FUNCTION__, dccp_role(sk));
404 case TFRC_SSTATE_NO_FBACK:
405 case TFRC_SSTATE_FBACK:
407 timeval_sub_usecs(&hctx->ccid3hctx_t_nom,
408 hctx->ccid3hctx_t_ipi);
409 ccid3_calc_new_t_ipi(hctx);
410 ccid3_calc_new_delta(hctx);
411 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
412 hctx->ccid3hctx_t_ipi);
416 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
417 hctx->ccid3hctx_state);
422 static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
424 const struct dccp_sock *dp = dccp_sk(sk);
425 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
426 struct ccid3_options_received *opt_recv;
427 struct dccp_tx_hist_entry *packet;
429 unsigned long next_tmout;
435 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM);
437 /* we are only interested in ACKs */
438 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
439 DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_DATAACK))
442 opt_recv = &hctx->ccid3hctx_options_received;
444 t_elapsed = dp->dccps_options_received.dccpor_elapsed_time * 10;
445 x_recv = opt_recv->ccid3or_receive_rate;
446 pinv = opt_recv->ccid3or_loss_event_rate;
448 switch (hctx->ccid3hctx_state) {
449 case TFRC_SSTATE_NO_SENT:
450 /* FIXME: what to do here? */
452 case TFRC_SSTATE_NO_FBACK:
453 case TFRC_SSTATE_FBACK:
454 /* Calculate new round trip sample by
455 * R_sample = (now - t_recvdata) - t_delay */
456 /* get t_recvdata from history */
457 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist,
458 DCCP_SKB_CB(skb)->dccpd_ack_seq);
459 if (unlikely(packet == NULL)) {
460 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno "
461 "%llu(%s) does't exist in history!\n",
462 __FUNCTION__, dccp_role(sk), sk,
463 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
464 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));
469 dccp_timestamp(sk, &now);
470 r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);
471 if (unlikely(r_sample <= t_elapsed))
472 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "
474 __FUNCTION__, r_sample, t_elapsed);
476 r_sample -= t_elapsed;
478 /* Update RTT estimate by
479 * If (No feedback recv)
482 * R = q * R + (1 - q) * R_sample;
484 * q is a constant, RFC 3448 recomments 0.9
486 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) {
487 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
488 hctx->ccid3hctx_rtt = r_sample;
490 hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 +
493 ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, "
494 "r_sample=%us\n", dccp_role(sk), sk,
495 hctx->ccid3hctx_rtt, r_sample);
497 /* Update timeout interval */
498 hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
501 /* Update receive rate */
502 hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */
504 /* Update loss event rate */
505 if (pinv == ~0 || pinv == 0)
506 hctx->ccid3hctx_p = 0;
508 hctx->ccid3hctx_p = 1000000 / pinv;
510 if (hctx->ccid3hctx_p < TFRC_SMALLEST_P) {
511 hctx->ccid3hctx_p = TFRC_SMALLEST_P;
512 ccid3_pr_debug("%s, sk=%p, Smallest p used!\n",
517 /* unschedule no feedback timer */
518 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer);
520 /* Update sending rate */
521 ccid3_hc_tx_update_x(sk);
523 /* Update next send time */
524 timeval_sub_usecs(&hctx->ccid3hctx_t_nom,
525 hctx->ccid3hctx_t_ipi);
526 ccid3_calc_new_t_ipi(hctx);
527 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
528 hctx->ccid3hctx_t_ipi);
529 ccid3_calc_new_delta(hctx);
531 /* remove all packets older than the one acked from history */
532 dccp_tx_hist_purge_older(ccid3_tx_hist,
533 &hctx->ccid3hctx_hist, packet);
535 * As we have calculated new ipi, delta, t_nom it is possible that
536 * we now can send a packet, so wake up dccp_wait_for_ccids.
538 sk->sk_write_space(sk);
541 * Schedule no feedback timer to expire in
542 * max(4 * R, 2 * s / X)
544 next_tmout = max(hctx->ccid3hctx_t_rto,
545 2 * usecs_div(hctx->ccid3hctx_s,
548 ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to "
549 "expire in %lu jiffies (%luus)\n",
551 usecs_to_jiffies(next_tmout), next_tmout);
553 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
554 jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout)));
557 hctx->ccid3hctx_idle = 1;
560 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
561 hctx->ccid3hctx_state);
566 static int ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb)
568 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
570 BUG_ON(hctx == NULL);
572 if (sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)
573 DCCP_SKB_CB(skb)->dccpd_ccval = hctx->ccid3hctx_last_win_count;
577 static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
578 unsigned char len, u16 idx,
579 unsigned char *value)
582 const struct dccp_sock *dp = dccp_sk(sk);
583 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
584 struct ccid3_options_received *opt_recv;
586 BUG_ON(hctx == NULL);
588 opt_recv = &hctx->ccid3hctx_options_received;
590 if (opt_recv->ccid3or_seqno != dp->dccps_gsr) {
591 opt_recv->ccid3or_seqno = dp->dccps_gsr;
592 opt_recv->ccid3or_loss_event_rate = ~0;
593 opt_recv->ccid3or_loss_intervals_idx = 0;
594 opt_recv->ccid3or_loss_intervals_len = 0;
595 opt_recv->ccid3or_receive_rate = 0;
599 case TFRC_OPT_LOSS_EVENT_RATE:
600 if (unlikely(len != 4)) {
601 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "
602 "len for TFRC_OPT_LOSS_EVENT_RATE\n",
603 __FUNCTION__, dccp_role(sk), sk);
606 opt_recv->ccid3or_loss_event_rate = ntohl(*(__be32 *)value);
607 ccid3_pr_debug("%s, sk=%p, LOSS_EVENT_RATE=%u\n",
609 opt_recv->ccid3or_loss_event_rate);
612 case TFRC_OPT_LOSS_INTERVALS:
613 opt_recv->ccid3or_loss_intervals_idx = idx;
614 opt_recv->ccid3or_loss_intervals_len = len;
615 ccid3_pr_debug("%s, sk=%p, LOSS_INTERVALS=(%u, %u)\n",
617 opt_recv->ccid3or_loss_intervals_idx,
618 opt_recv->ccid3or_loss_intervals_len);
620 case TFRC_OPT_RECEIVE_RATE:
621 if (unlikely(len != 4)) {
622 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid "
623 "len for TFRC_OPT_RECEIVE_RATE\n",
624 __FUNCTION__, dccp_role(sk), sk);
627 opt_recv->ccid3or_receive_rate = ntohl(*(__be32 *)value);
628 ccid3_pr_debug("%s, sk=%p, RECEIVE_RATE=%u\n",
630 opt_recv->ccid3or_receive_rate);
638 static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
640 struct dccp_sock *dp = dccp_sk(sk);
641 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
643 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
644 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
645 hctx->ccid3hctx_s = dp->dccps_packet_size;
647 hctx->ccid3hctx_s = TFRC_STD_PACKET_SIZE;
649 /* Set transmission rate to 1 packet per second */
650 hctx->ccid3hctx_x = hctx->ccid3hctx_s;
651 hctx->ccid3hctx_t_rto = USEC_PER_SEC;
652 hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT;
653 INIT_LIST_HEAD(&hctx->ccid3hctx_hist);
655 hctx->ccid3hctx_no_feedback_timer.function = ccid3_hc_tx_no_feedback_timer;
656 hctx->ccid3hctx_no_feedback_timer.data = (unsigned long)sk;
657 init_timer(&hctx->ccid3hctx_no_feedback_timer);
662 static void ccid3_hc_tx_exit(struct sock *sk)
664 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
666 BUG_ON(hctx == NULL);
668 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_TERM);
669 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer);
671 /* Empty packet history */
672 dccp_tx_hist_purge(ccid3_tx_hist, &hctx->ccid3hctx_hist);
676 * RX Half Connection methods
680 static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
682 static char *ccid3_rx_state_names[] = {
683 [TFRC_RSTATE_NO_DATA] = "NO_DATA",
684 [TFRC_RSTATE_DATA] = "DATA",
685 [TFRC_RSTATE_TERM] = "TERM",
688 return ccid3_rx_state_names[state];
692 static void ccid3_hc_rx_set_state(struct sock *sk,
693 enum ccid3_hc_rx_states state)
695 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
696 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state;
698 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
699 dccp_role(sk), sk, ccid3_rx_state_name(oldstate),
700 ccid3_rx_state_name(state));
701 WARN_ON(state == oldstate);
702 hcrx->ccid3hcrx_state = state;
705 static void ccid3_hc_rx_send_feedback(struct sock *sk)
707 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
708 struct dccp_sock *dp = dccp_sk(sk);
709 struct dccp_rx_hist_entry *packet;
712 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
714 dccp_timestamp(sk, &now);
716 switch (hcrx->ccid3hcrx_state) {
717 case TFRC_RSTATE_NO_DATA:
718 hcrx->ccid3hcrx_x_recv = 0;
720 case TFRC_RSTATE_DATA: {
721 const u32 delta = timeval_delta(&now,
722 &hcrx->ccid3hcrx_tstamp_last_feedback);
723 hcrx->ccid3hcrx_x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv,
728 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
729 hcrx->ccid3hcrx_state);
733 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist);
734 if (unlikely(packet == NULL)) {
735 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet "
737 __FUNCTION__, dccp_role(sk), sk);
741 hcrx->ccid3hcrx_tstamp_last_feedback = now;
742 hcrx->ccid3hcrx_ccval_last_counter = packet->dccphrx_ccval;
743 hcrx->ccid3hcrx_bytes_recv = 0;
745 /* Convert to multiples of 10us */
746 hcrx->ccid3hcrx_elapsed_time =
747 timeval_delta(&now, &packet->dccphrx_tstamp) / 10;
748 if (hcrx->ccid3hcrx_p == 0)
749 hcrx->ccid3hcrx_pinv = ~0;
751 hcrx->ccid3hcrx_pinv = 1000000 / hcrx->ccid3hcrx_p;
752 dp->dccps_hc_rx_insert_options = 1;
756 static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
758 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
761 BUG_ON(hcrx == NULL);
763 if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))
766 DCCP_SKB_CB(skb)->dccpd_ccval = hcrx->ccid3hcrx_ccval_last_counter;
768 if (dccp_packet_without_ack(skb))
771 x_recv = htonl(hcrx->ccid3hcrx_x_recv);
772 pinv = htonl(hcrx->ccid3hcrx_pinv);
774 if ((hcrx->ccid3hcrx_elapsed_time != 0 &&
775 dccp_insert_option_elapsed_time(sk, skb,
776 hcrx->ccid3hcrx_elapsed_time)) ||
777 dccp_insert_option_timestamp(sk, skb) ||
778 dccp_insert_option(sk, skb, TFRC_OPT_LOSS_EVENT_RATE,
779 &pinv, sizeof(pinv)) ||
780 dccp_insert_option(sk, skb, TFRC_OPT_RECEIVE_RATE,
781 &x_recv, sizeof(x_recv)))
787 /* calculate first loss interval
789 * returns estimated loss interval in usecs */
791 static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
793 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
794 struct dccp_rx_hist_entry *entry, *next, *tail = NULL;
795 u32 rtt, delta, x_recv, fval, p, tmp2;
796 struct timeval tstamp = { 0, };
802 list_for_each_entry_safe(entry, next, &hcrx->ccid3hcrx_hist,
804 if (dccp_rx_hist_entry_data_packet(entry)) {
809 tstamp = entry->dccphrx_tstamp;
810 win_count = entry->dccphrx_ccval;
814 interval = win_count - entry->dccphrx_ccval;
816 interval += TFRC_WIN_COUNT_LIMIT;
824 if (unlikely(step == 0)) {
825 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history "
826 "contains no data packets!\n",
827 __FUNCTION__, dccp_role(sk), sk);
831 if (unlikely(interval == 0)) {
832 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a "
833 "win_count interval > 0. Defaulting to 1\n",
834 __FUNCTION__, dccp_role(sk), sk);
839 LIMIT_NETDEBUG(KERN_WARNING "%s: tail is null\n",
843 rtt = timeval_delta(&tstamp, &tail->dccphrx_tstamp) * 4 / interval;
844 ccid3_pr_debug("%s, sk=%p, approximated RTT to %uus\n",
845 dccp_role(sk), sk, rtt);
849 dccp_timestamp(sk, &tstamp);
850 delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback);
851 x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta);
854 x_recv = hcrx->ccid3hcrx_x_recv;
856 tmp1 = (u64)x_recv * (u64)rtt;
857 do_div(tmp1,10000000);
861 LIMIT_NETDEBUG(KERN_WARNING "tmp2 = 0 "
862 "%s: x_recv = %u, rtt =%u\n",
863 __FUNCTION__, x_recv, rtt);
867 fval = (hcrx->ccid3hcrx_s * 100000) / tmp2;
868 /* do not alter order above or you will get overflow on 32 bit */
869 p = tfrc_calc_x_reverse_lookup(fval);
870 ccid3_pr_debug("%s, sk=%p, receive rate=%u bytes/s, implied "
871 "loss rate=%u\n", dccp_role(sk), sk, x_recv, p);
879 static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
881 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
882 struct dccp_li_hist_entry *head;
885 if (list_empty(&hcrx->ccid3hcrx_li_hist)) {
886 if (!dccp_li_hist_interval_new(ccid3_li_hist,
887 &hcrx->ccid3hcrx_li_hist, seq_loss, win_loss))
890 head = list_entry(hcrx->ccid3hcrx_li_hist.next,
891 struct dccp_li_hist_entry, dccplih_node);
892 head->dccplih_interval = ccid3_hc_rx_calc_first_li(sk);
894 struct dccp_li_hist_entry *entry;
895 struct list_head *tail;
897 head = list_entry(hcrx->ccid3hcrx_li_hist.next,
898 struct dccp_li_hist_entry, dccplih_node);
899 /* FIXME win count check removed as was wrong */
900 /* should make this check with receive history */
901 /* and compare there as per section 10.2 of RFC4342 */
903 /* new loss event detected */
904 /* calculate last interval length */
905 seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss);
906 entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC);
909 printk(KERN_CRIT "%s: out of memory\n",__FUNCTION__);
914 list_add(&entry->dccplih_node, &hcrx->ccid3hcrx_li_hist);
916 tail = hcrx->ccid3hcrx_li_hist.prev;
918 kmem_cache_free(ccid3_li_hist->dccplih_slab, tail);
920 /* Create the newest interval */
921 entry->dccplih_seqno = seq_loss;
922 entry->dccplih_interval = seq_temp;
923 entry->dccplih_win_count = win_loss;
927 static int ccid3_hc_rx_detect_loss(struct sock *sk,
928 struct dccp_rx_hist_entry *packet)
930 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
931 struct dccp_rx_hist_entry *rx_hist = dccp_rx_hist_head(&hcrx->ccid3hcrx_hist);
932 u64 seqno = packet->dccphrx_seqno;
938 tmp_seqno = hcrx->ccid3hcrx_seqno_nonloss;
941 follows48(packet->dccphrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) {
942 hcrx->ccid3hcrx_seqno_nonloss = seqno;
943 hcrx->ccid3hcrx_ccval_nonloss = packet->dccphrx_ccval;
948 while (dccp_delta_seqno(hcrx->ccid3hcrx_seqno_nonloss, seqno)
949 > TFRC_RECV_NUM_LATE_LOSS) {
951 ccid3_hc_rx_update_li(sk, hcrx->ccid3hcrx_seqno_nonloss,
952 hcrx->ccid3hcrx_ccval_nonloss);
953 tmp_seqno = hcrx->ccid3hcrx_seqno_nonloss;
954 dccp_inc_seqno(&tmp_seqno);
955 hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno;
956 dccp_inc_seqno(&tmp_seqno);
957 while (dccp_rx_hist_find_entry(&hcrx->ccid3hcrx_hist,
958 tmp_seqno, &ccval)) {
959 hcrx->ccid3hcrx_seqno_nonloss = tmp_seqno;
960 hcrx->ccid3hcrx_ccval_nonloss = ccval;
961 dccp_inc_seqno(&tmp_seqno);
965 /* FIXME - this code could be simplified with above while */
966 /* but works at moment */
967 if (follows48(packet->dccphrx_seqno, hcrx->ccid3hcrx_seqno_nonloss)) {
968 hcrx->ccid3hcrx_seqno_nonloss = seqno;
969 hcrx->ccid3hcrx_ccval_nonloss = packet->dccphrx_ccval;
973 dccp_rx_hist_add_packet(ccid3_rx_hist, &hcrx->ccid3hcrx_hist,
974 &hcrx->ccid3hcrx_li_hist, packet,
975 hcrx->ccid3hcrx_seqno_nonloss);
979 static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
981 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
982 const struct dccp_options_received *opt_recv;
983 struct dccp_rx_hist_entry *packet;
986 u32 p_prev, rtt_prev, r_sample, t_elapsed;
989 BUG_ON(hcrx == NULL ||
990 !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||
991 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA));
993 opt_recv = &dccp_sk(sk)->dccps_options_received;
995 switch (DCCP_SKB_CB(skb)->dccpd_type) {
997 if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
999 case DCCP_PKT_DATAACK:
1000 if (opt_recv->dccpor_timestamp_echo == 0)
1002 rtt_prev = hcrx->ccid3hcrx_rtt;
1003 dccp_timestamp(sk, &now);
1004 timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10);
1005 r_sample = timeval_usecs(&now);
1006 t_elapsed = opt_recv->dccpor_elapsed_time * 10;
1008 if (unlikely(r_sample <= t_elapsed))
1009 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, "
1011 __FUNCTION__, r_sample, t_elapsed);
1013 r_sample -= t_elapsed;
1015 if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
1016 hcrx->ccid3hcrx_rtt = r_sample;
1018 hcrx->ccid3hcrx_rtt = (hcrx->ccid3hcrx_rtt * 9) / 10 +
1021 if (rtt_prev != hcrx->ccid3hcrx_rtt)
1022 ccid3_pr_debug("%s, New RTT=%uus, elapsed time=%u\n",
1023 dccp_role(sk), hcrx->ccid3hcrx_rtt,
1024 opt_recv->dccpor_elapsed_time);
1028 default: /* We're not interested in other packet types, move along */
1032 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
1034 if (unlikely(packet == NULL)) {
1035 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to "
1036 "add rx packet to history, consider it lost!\n",
1037 __FUNCTION__, dccp_role(sk), sk);
1041 win_count = packet->dccphrx_ccval;
1043 loss = ccid3_hc_rx_detect_loss(sk, packet);
1045 if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK)
1048 switch (hcrx->ccid3hcrx_state) {
1049 case TFRC_RSTATE_NO_DATA:
1050 ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial "
1053 dccp_state_name(sk->sk_state), skb);
1054 ccid3_hc_rx_send_feedback(sk);
1055 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
1057 case TFRC_RSTATE_DATA:
1058 hcrx->ccid3hcrx_bytes_recv += skb->len -
1059 dccp_hdr(skb)->dccph_doff * 4;
1063 dccp_timestamp(sk, &now);
1064 if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >=
1065 hcrx->ccid3hcrx_rtt) {
1066 hcrx->ccid3hcrx_tstamp_last_ack = now;
1067 ccid3_hc_rx_send_feedback(sk);
1071 DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk,
1072 hcrx->ccid3hcrx_state);
1076 /* Dealing with packet loss */
1077 ccid3_pr_debug("%s, sk=%p(%s), data loss! Reacting...\n",
1078 dccp_role(sk), sk, dccp_state_name(sk->sk_state));
1080 p_prev = hcrx->ccid3hcrx_p;
1082 /* Calculate loss event rate */
1083 if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
1084 u32 i_mean = dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
1086 /* Scaling up by 1000000 as fixed decimal */
1088 hcrx->ccid3hcrx_p = 1000000 / i_mean;
1090 printk(KERN_CRIT "%s: empty loss hist\n",__FUNCTION__);
1094 if (hcrx->ccid3hcrx_p > p_prev) {
1095 ccid3_hc_rx_send_feedback(sk);
1100 static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
1102 struct dccp_sock *dp = dccp_sk(sk);
1103 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
1105 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1107 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
1108 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
1109 hcrx->ccid3hcrx_s = dp->dccps_packet_size;
1111 hcrx->ccid3hcrx_s = TFRC_STD_PACKET_SIZE;
1113 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
1114 INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist);
1115 INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
1116 dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack);
1117 hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack;
1118 hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */
1122 static void ccid3_hc_rx_exit(struct sock *sk)
1124 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1126 BUG_ON(hcrx == NULL);
1128 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM);
1130 /* Empty packet history */
1131 dccp_rx_hist_purge(ccid3_rx_hist, &hcrx->ccid3hcrx_hist);
1133 /* Empty loss interval history */
1134 dccp_li_hist_purge(ccid3_li_hist, &hcrx->ccid3hcrx_li_hist);
1137 static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1139 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1141 /* Listen socks doesn't have a private CCID block */
1142 if (sk->sk_state == DCCP_LISTEN)
1145 BUG_ON(hcrx == NULL);
1147 info->tcpi_ca_state = hcrx->ccid3hcrx_state;
1148 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
1149 info->tcpi_rcv_rtt = hcrx->ccid3hcrx_rtt;
1152 static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
1154 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1156 /* Listen socks doesn't have a private CCID block */
1157 if (sk->sk_state == DCCP_LISTEN)
1160 BUG_ON(hctx == NULL);
1162 info->tcpi_rto = hctx->ccid3hctx_t_rto;
1163 info->tcpi_rtt = hctx->ccid3hctx_rtt;
1166 static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
1167 u32 __user *optval, int __user *optlen)
1169 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1172 /* Listen socks doesn't have a private CCID block */
1173 if (sk->sk_state == DCCP_LISTEN)
1177 case DCCP_SOCKOPT_CCID_RX_INFO:
1178 if (len < sizeof(hcrx->ccid3hcrx_tfrc))
1180 len = sizeof(hcrx->ccid3hcrx_tfrc);
1181 val = &hcrx->ccid3hcrx_tfrc;
1184 return -ENOPROTOOPT;
1187 if (put_user(len, optlen) || copy_to_user(optval, val, len))
1193 static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
1194 u32 __user *optval, int __user *optlen)
1196 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1199 /* Listen socks doesn't have a private CCID block */
1200 if (sk->sk_state == DCCP_LISTEN)
1204 case DCCP_SOCKOPT_CCID_TX_INFO:
1205 if (len < sizeof(hctx->ccid3hctx_tfrc))
1207 len = sizeof(hctx->ccid3hctx_tfrc);
1208 val = &hctx->ccid3hctx_tfrc;
1211 return -ENOPROTOOPT;
1214 if (put_user(len, optlen) || copy_to_user(optval, val, len))
1220 static struct ccid_operations ccid3 = {
1221 .ccid_id = DCCPC_CCID3,
1222 .ccid_name = "ccid3",
1223 .ccid_owner = THIS_MODULE,
1224 .ccid_hc_tx_obj_size = sizeof(struct ccid3_hc_tx_sock),
1225 .ccid_hc_tx_init = ccid3_hc_tx_init,
1226 .ccid_hc_tx_exit = ccid3_hc_tx_exit,
1227 .ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet,
1228 .ccid_hc_tx_packet_sent = ccid3_hc_tx_packet_sent,
1229 .ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv,
1230 .ccid_hc_tx_insert_options = ccid3_hc_tx_insert_options,
1231 .ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options,
1232 .ccid_hc_rx_obj_size = sizeof(struct ccid3_hc_rx_sock),
1233 .ccid_hc_rx_init = ccid3_hc_rx_init,
1234 .ccid_hc_rx_exit = ccid3_hc_rx_exit,
1235 .ccid_hc_rx_insert_options = ccid3_hc_rx_insert_options,
1236 .ccid_hc_rx_packet_recv = ccid3_hc_rx_packet_recv,
1237 .ccid_hc_rx_get_info = ccid3_hc_rx_get_info,
1238 .ccid_hc_tx_get_info = ccid3_hc_tx_get_info,
1239 .ccid_hc_rx_getsockopt = ccid3_hc_rx_getsockopt,
1240 .ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt,
1243 module_param(ccid3_debug, int, 0444);
1244 MODULE_PARM_DESC(ccid3_debug, "Enable debug messages");
1246 static __init int ccid3_module_init(void)
1250 ccid3_rx_hist = dccp_rx_hist_new("ccid3");
1251 if (ccid3_rx_hist == NULL)
1254 ccid3_tx_hist = dccp_tx_hist_new("ccid3");
1255 if (ccid3_tx_hist == NULL)
1258 ccid3_li_hist = dccp_li_hist_new("ccid3");
1259 if (ccid3_li_hist == NULL)
1262 rc = ccid_register(&ccid3);
1264 goto out_free_loss_interval_history;
1268 out_free_loss_interval_history:
1269 dccp_li_hist_delete(ccid3_li_hist);
1270 ccid3_li_hist = NULL;
1272 dccp_tx_hist_delete(ccid3_tx_hist);
1273 ccid3_tx_hist = NULL;
1275 dccp_rx_hist_delete(ccid3_rx_hist);
1276 ccid3_rx_hist = NULL;
1279 module_init(ccid3_module_init);
1281 static __exit void ccid3_module_exit(void)
1283 ccid_unregister(&ccid3);
1285 if (ccid3_tx_hist != NULL) {
1286 dccp_tx_hist_delete(ccid3_tx_hist);
1287 ccid3_tx_hist = NULL;
1289 if (ccid3_rx_hist != NULL) {
1290 dccp_rx_hist_delete(ccid3_rx_hist);
1291 ccid3_rx_hist = NULL;
1293 if (ccid3_li_hist != NULL) {
1294 dccp_li_hist_delete(ccid3_li_hist);
1295 ccid3_li_hist = NULL;
1298 module_exit(ccid3_module_exit);
1300 MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
1301 "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
1302 MODULE_DESCRIPTION("DCCP TFRC CCID3 CCID");
1303 MODULE_LICENSE("GPL");
1304 MODULE_ALIAS("net-dccp-ccid-3");