| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 1 | /* | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 2 | *  Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk> | 
|  | 3 | * | 
|  | 4 | *  Changes to meet Linux coding standards, and DCCP infrastructure fixes. | 
|  | 5 | * | 
|  | 6 | *  Copyright (c) 2006 Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 
|  | 7 | * | 
|  | 8 | *  This program is free software; you can redistribute it and/or modify | 
|  | 9 | *  it under the terms of the GNU General Public License as published by | 
|  | 10 | *  the Free Software Foundation; either version 2 of the License, or | 
|  | 11 | *  (at your option) any later version. | 
|  | 12 | * | 
|  | 13 | *  This program is distributed in the hope that it will be useful, | 
|  | 14 | *  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 15 | *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 16 | *  GNU General Public License for more details. | 
|  | 17 | * | 
|  | 18 | *  You should have received a copy of the GNU General Public License | 
|  | 19 | *  along with this program; if not, write to the Free Software | 
|  | 20 | *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|  | 21 | */ | 
|  | 22 |  | 
|  | 23 | /* | 
| Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 24 | * This implementation should follow RFC 4341 | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 25 | */ | 
| Gerrit Renker | e8ef967 | 2008-11-12 00:43:40 -0800 | [diff] [blame] | 26 | #include "../feat.h" | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 27 | #include "../ccid.h" | 
|  | 28 | #include "../dccp.h" | 
|  | 29 | #include "ccid2.h" | 
|  | 30 |  | 
| Gerrit Renker | 8411671 | 2006-11-20 18:26:03 -0200 | [diff] [blame] | 31 |  | 
|  | 32 | #ifdef CONFIG_IP_DCCP_CCID2_DEBUG | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 33 | static int ccid2_debug; | 
| Gerrit Renker | 8411671 | 2006-11-20 18:26:03 -0200 | [diff] [blame] | 34 | #define ccid2_pr_debug(format, a...)	DCCP_PR_DEBUG(ccid2_debug, format, ##a) | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 35 |  | 
|  | 36 | static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | 
|  | 37 | { | 
|  | 38 | int len = 0; | 
|  | 39 | int pipe = 0; | 
|  | 40 | struct ccid2_seq *seqp = hctx->ccid2hctx_seqh; | 
|  | 41 |  | 
|  | 42 | /* there is data in the chain */ | 
|  | 43 | if (seqp != hctx->ccid2hctx_seqt) { | 
|  | 44 | seqp = seqp->ccid2s_prev; | 
|  | 45 | len++; | 
|  | 46 | if (!seqp->ccid2s_acked) | 
|  | 47 | pipe++; | 
|  | 48 |  | 
|  | 49 | while (seqp != hctx->ccid2hctx_seqt) { | 
|  | 50 | struct ccid2_seq *prev = seqp->ccid2s_prev; | 
|  | 51 |  | 
|  | 52 | len++; | 
|  | 53 | if (!prev->ccid2s_acked) | 
|  | 54 | pipe++; | 
|  | 55 |  | 
|  | 56 | /* packets are sent sequentially */ | 
|  | 57 | BUG_ON(dccp_delta_seqno(seqp->ccid2s_seq, | 
|  | 58 | prev->ccid2s_seq ) >= 0); | 
|  | 59 | BUG_ON(time_before(seqp->ccid2s_sent, | 
|  | 60 | prev->ccid2s_sent)); | 
|  | 61 |  | 
|  | 62 | seqp = prev; | 
|  | 63 | } | 
|  | 64 | } | 
|  | 65 |  | 
|  | 66 | BUG_ON(pipe != hctx->ccid2hctx_pipe); | 
|  | 67 | ccid2_pr_debug("len of chain=%d\n", len); | 
|  | 68 |  | 
|  | 69 | do { | 
|  | 70 | seqp = seqp->ccid2s_prev; | 
|  | 71 | len++; | 
|  | 72 | } while (seqp != hctx->ccid2hctx_seqh); | 
|  | 73 |  | 
|  | 74 | ccid2_pr_debug("total len=%d\n", len); | 
|  | 75 | BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN); | 
|  | 76 | } | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 77 | #else | 
| Gerrit Renker | 8411671 | 2006-11-20 18:26:03 -0200 | [diff] [blame] | 78 | #define ccid2_pr_debug(format, a...) | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 79 | #define ccid2_hc_tx_check_sanity(hctx) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 80 | #endif | 
|  | 81 |  | 
| Gerrit Renker | cd1f7d3 | 2007-10-04 14:41:00 -0700 | [diff] [blame] | 82 | static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx) | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 83 | { | 
|  | 84 | struct ccid2_seq *seqp; | 
|  | 85 | int i; | 
|  | 86 |  | 
|  | 87 | /* check if we have space to preserve the pointer to the buffer */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 88 | if (hctx->ccid2hctx_seqbufc >= (sizeof(hctx->ccid2hctx_seqbuf) / | 
|  | 89 | sizeof(struct ccid2_seq*))) | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 90 | return -ENOMEM; | 
|  | 91 |  | 
|  | 92 | /* allocate buffer and initialize linked list */ | 
| Gerrit Renker | cd1f7d3 | 2007-10-04 14:41:00 -0700 | [diff] [blame] | 93 | seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any()); | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 94 | if (seqp == NULL) | 
|  | 95 | return -ENOMEM; | 
|  | 96 |  | 
| Gerrit Renker | cd1f7d3 | 2007-10-04 14:41:00 -0700 | [diff] [blame] | 97 | for (i = 0; i < (CCID2_SEQBUF_LEN - 1); i++) { | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 98 | seqp[i].ccid2s_next = &seqp[i + 1]; | 
|  | 99 | seqp[i + 1].ccid2s_prev = &seqp[i]; | 
|  | 100 | } | 
| Gerrit Renker | cd1f7d3 | 2007-10-04 14:41:00 -0700 | [diff] [blame] | 101 | seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = seqp; | 
|  | 102 | seqp->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 103 |  | 
|  | 104 | /* This is the first allocation.  Initiate the head and tail.  */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 105 | if (hctx->ccid2hctx_seqbufc == 0) | 
|  | 106 | hctx->ccid2hctx_seqh = hctx->ccid2hctx_seqt = seqp; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 107 | else { | 
|  | 108 | /* link the existing list with the one we just created */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 109 | hctx->ccid2hctx_seqh->ccid2s_next = seqp; | 
|  | 110 | seqp->ccid2s_prev = hctx->ccid2hctx_seqh; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 111 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 112 | hctx->ccid2hctx_seqt->ccid2s_prev = &seqp[CCID2_SEQBUF_LEN - 1]; | 
|  | 113 | seqp[CCID2_SEQBUF_LEN - 1].ccid2s_next = hctx->ccid2hctx_seqt; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 114 | } | 
|  | 115 |  | 
|  | 116 | /* store the original pointer to the buffer so we can free it */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 117 | hctx->ccid2hctx_seqbuf[hctx->ccid2hctx_seqbufc] = seqp; | 
|  | 118 | hctx->ccid2hctx_seqbufc++; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 119 |  | 
|  | 120 | return 0; | 
|  | 121 | } | 
|  | 122 |  | 
| Gerrit Renker | 6b57c93 | 2006-11-28 19:55:06 -0200 | [diff] [blame] | 123 | static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 124 | { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 125 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 126 |  | 
|  | 127 | if (hctx->ccid2hctx_pipe < hctx->ccid2hctx_cwnd) | 
|  | 128 | return 0; | 
|  | 129 |  | 
|  | 130 | return 1; /* XXX CCID should dequeue when ready instead of polling */ | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 131 | } | 
|  | 132 |  | 
| Gerrit Renker | df054e1 | 2007-11-24 21:32:53 -0200 | [diff] [blame] | 133 | static void ccid2_change_l_ack_ratio(struct sock *sk, u32 val) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 134 | { | 
|  | 135 | struct dccp_sock *dp = dccp_sk(sk); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 136 | u32 max_ratio = DIV_ROUND_UP(ccid2_hc_tx_sk(sk)->ccid2hctx_cwnd, 2); | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 137 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 138 | /* | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 139 | * Ensure that Ack Ratio does not exceed ceil(cwnd/2), which is (2) from | 
|  | 140 | * RFC 4341, 6.1.2. We ignore the statement that Ack Ratio 2 is always | 
|  | 141 | * acceptable since this causes starvation/deadlock whenever cwnd < 2. | 
|  | 142 | * The same problem arises when Ack Ratio is 0 (ie. Ack Ratio disabled). | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 143 | */ | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 144 | if (val == 0 || val > max_ratio) { | 
|  | 145 | DCCP_WARN("Limiting Ack Ratio (%u) to %u\n", val, max_ratio); | 
|  | 146 | val = max_ratio; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 147 | } | 
| Gerrit Renker | e8ef967 | 2008-11-12 00:43:40 -0800 | [diff] [blame] | 148 | if (val > DCCPF_ACK_RATIO_MAX) | 
|  | 149 | val = DCCPF_ACK_RATIO_MAX; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 150 |  | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 151 | if (val == dp->dccps_l_ack_ratio) | 
|  | 152 | return; | 
|  | 153 |  | 
| Gerrit Renker | df054e1 | 2007-11-24 21:32:53 -0200 | [diff] [blame] | 154 | ccid2_pr_debug("changing local ack ratio to %u\n", val); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 155 | dp->dccps_l_ack_ratio = val; | 
|  | 156 | } | 
|  | 157 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 158 | static void ccid2_change_srtt(struct ccid2_hc_tx_sock *hctx, long val) | 
|  | 159 | { | 
|  | 160 | ccid2_pr_debug("change SRTT to %ld\n", val); | 
|  | 161 | hctx->ccid2hctx_srtt = val; | 
|  | 162 | } | 
|  | 163 |  | 
|  | 164 | static void ccid2_start_rto_timer(struct sock *sk); | 
|  | 165 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 166 | static void ccid2_hc_tx_rto_expire(unsigned long data) | 
|  | 167 | { | 
|  | 168 | struct sock *sk = (struct sock *)data; | 
|  | 169 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 170 | long s; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 171 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 172 | bh_lock_sock(sk); | 
|  | 173 | if (sock_owned_by_user(sk)) { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 174 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, | 
|  | 175 | jiffies + HZ / 5); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 176 | goto out; | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | ccid2_pr_debug("RTO_EXPIRE\n"); | 
|  | 180 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 181 | ccid2_hc_tx_check_sanity(hctx); | 
|  | 182 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 183 | /* back-off timer */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 184 | hctx->ccid2hctx_rto <<= 1; | 
|  | 185 |  | 
|  | 186 | s = hctx->ccid2hctx_rto / HZ; | 
|  | 187 | if (s > 60) | 
|  | 188 | hctx->ccid2hctx_rto = 60 * HZ; | 
|  | 189 |  | 
|  | 190 | ccid2_start_rto_timer(sk); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 191 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 192 | /* adjust pipe, cwnd etc */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 193 | hctx->ccid2hctx_ssthresh = hctx->ccid2hctx_cwnd / 2; | 
|  | 194 | if (hctx->ccid2hctx_ssthresh < 2) | 
|  | 195 | hctx->ccid2hctx_ssthresh = 2; | 
|  | 196 | hctx->ccid2hctx_cwnd	 = 1; | 
|  | 197 | hctx->ccid2hctx_pipe	 = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 198 |  | 
|  | 199 | /* clear state about stuff we sent */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 200 | hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqh; | 
|  | 201 | hctx->ccid2hctx_packets_acked = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 202 |  | 
|  | 203 | /* clear ack ratio state. */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 204 | hctx->ccid2hctx_rpseq	 = 0; | 
|  | 205 | hctx->ccid2hctx_rpdupack = -1; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 206 | ccid2_change_l_ack_ratio(sk, 1); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 207 | ccid2_hc_tx_check_sanity(hctx); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 208 | out: | 
|  | 209 | bh_unlock_sock(sk); | 
| Andrea Bittau | 77ff72d | 2006-03-20 17:57:52 -0800 | [diff] [blame] | 210 | sock_put(sk); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 211 | } | 
|  | 212 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 213 | static void ccid2_start_rto_timer(struct sock *sk) | 
|  | 214 | { | 
|  | 215 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 216 |  | 
|  | 217 | ccid2_pr_debug("setting RTO timeout=%ld\n", hctx->ccid2hctx_rto); | 
|  | 218 |  | 
|  | 219 | BUG_ON(timer_pending(&hctx->ccid2hctx_rtotimer)); | 
|  | 220 | sk_reset_timer(sk, &hctx->ccid2hctx_rtotimer, | 
|  | 221 | jiffies + hctx->ccid2hctx_rto); | 
|  | 222 | } | 
|  | 223 |  | 
|  | 224 | static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 225 | { | 
|  | 226 | struct dccp_sock *dp = dccp_sk(sk); | 
|  | 227 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 228 | struct ccid2_seq *next; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 229 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 230 | hctx->ccid2hctx_pipe++; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 231 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 232 | hctx->ccid2hctx_seqh->ccid2s_seq   = dp->dccps_gss; | 
|  | 233 | hctx->ccid2hctx_seqh->ccid2s_acked = 0; | 
|  | 234 | hctx->ccid2hctx_seqh->ccid2s_sent  = jiffies; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 235 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 236 | next = hctx->ccid2hctx_seqh->ccid2s_next; | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 237 | /* check if we need to alloc more space */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 238 | if (next == hctx->ccid2hctx_seqt) { | 
| Gerrit Renker | 7d9e893 | 2007-10-04 14:41:26 -0700 | [diff] [blame] | 239 | if (ccid2_hc_tx_alloc_seq(hctx)) { | 
|  | 240 | DCCP_CRIT("packet history - out of memory!"); | 
|  | 241 | /* FIXME: find a more graceful way to bail out */ | 
|  | 242 | return; | 
|  | 243 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 244 | next = hctx->ccid2hctx_seqh->ccid2s_next; | 
|  | 245 | BUG_ON(next == hctx->ccid2hctx_seqt); | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 246 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 247 | hctx->ccid2hctx_seqh = next; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 248 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 249 | ccid2_pr_debug("cwnd=%d pipe=%d\n", hctx->ccid2hctx_cwnd, | 
|  | 250 | hctx->ccid2hctx_pipe); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 251 |  | 
| Gerrit Renker | 900bfed | 2007-11-24 21:58:33 -0200 | [diff] [blame] | 252 | /* | 
|  | 253 | * FIXME: The code below is broken and the variables have been removed | 
|  | 254 | * from the socket struct. The `ackloss' variable was always set to 0, | 
|  | 255 | * and with arsent there are several problems: | 
|  | 256 | *  (i) it doesn't just count the number of Acks, but all sent packets; | 
|  | 257 | *  (ii) it is expressed in # of packets, not # of windows, so the | 
|  | 258 | *  comparison below uses the wrong formula: Appendix A of RFC 4341 | 
|  | 259 | *  comes up with the number K = cwnd / (R^2 - R) of consecutive windows | 
|  | 260 | *  of data with no lost or marked Ack packets. If arsent were the # of | 
|  | 261 | *  consecutive Acks received without loss, then Ack Ratio needs to be | 
|  | 262 | *  decreased by 1 when | 
|  | 263 | *	      arsent >=  K * cwnd / R  =  cwnd^2 / (R^3 - R^2) | 
|  | 264 | *  where cwnd / R is the number of Acks received per window of data | 
|  | 265 | *  (cf. RFC 4341, App. A). The problems are that | 
|  | 266 | *  - arsent counts other packets as well; | 
|  | 267 | *  - the comparison uses a formula different from RFC 4341; | 
|  | 268 | *  - computing a cubic/quadratic equation each time is too complicated. | 
|  | 269 | *  Hence a different algorithm is needed. | 
|  | 270 | */ | 
|  | 271 | #if 0 | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 272 | /* Ack Ratio.  Need to maintain a concept of how many windows we sent */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 273 | hctx->ccid2hctx_arsent++; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 274 | /* We had an ack loss in this window... */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 275 | if (hctx->ccid2hctx_ackloss) { | 
|  | 276 | if (hctx->ccid2hctx_arsent >= hctx->ccid2hctx_cwnd) { | 
|  | 277 | hctx->ccid2hctx_arsent	= 0; | 
|  | 278 | hctx->ccid2hctx_ackloss	= 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 279 | } | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 280 | } else { | 
|  | 281 | /* No acks lost up to now... */ | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 282 | /* decrease ack ratio if enough packets were sent */ | 
|  | 283 | if (dp->dccps_l_ack_ratio > 1) { | 
|  | 284 | /* XXX don't calculate denominator each time */ | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 285 | int denom = dp->dccps_l_ack_ratio * dp->dccps_l_ack_ratio - | 
|  | 286 | dp->dccps_l_ack_ratio; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 287 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 288 | denom = hctx->ccid2hctx_cwnd * hctx->ccid2hctx_cwnd / denom; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 289 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 290 | if (hctx->ccid2hctx_arsent >= denom) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 291 | ccid2_change_l_ack_ratio(sk, dp->dccps_l_ack_ratio - 1); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 292 | hctx->ccid2hctx_arsent = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 293 | } | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 294 | } else { | 
|  | 295 | /* we can't increase ack ratio further [1] */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 296 | hctx->ccid2hctx_arsent = 0; /* or maybe set it to cwnd*/ | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 297 | } | 
|  | 298 | } | 
| Gerrit Renker | 900bfed | 2007-11-24 21:58:33 -0200 | [diff] [blame] | 299 | #endif | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 300 |  | 
|  | 301 | /* setup RTO timer */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 302 | if (!timer_pending(&hctx->ccid2hctx_rtotimer)) | 
|  | 303 | ccid2_start_rto_timer(sk); | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 304 |  | 
| Andrea Bittau | 8d424f6 | 2006-09-19 13:12:44 -0700 | [diff] [blame] | 305 | #ifdef CONFIG_IP_DCCP_CCID2_DEBUG | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 306 | do { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 307 | struct ccid2_seq *seqp = hctx->ccid2hctx_seqt; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 308 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 309 | while (seqp != hctx->ccid2hctx_seqh) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 310 | ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", | 
| Arnaldo Carvalho de Melo | 8109b02 | 2006-12-10 16:01:18 -0200 | [diff] [blame] | 311 | (unsigned long long)seqp->ccid2s_seq, | 
| Randy Dunlap | 234af48 | 2006-10-29 16:03:30 -0800 | [diff] [blame] | 312 | seqp->ccid2s_acked, seqp->ccid2s_sent); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 313 | seqp = seqp->ccid2s_next; | 
|  | 314 | } | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 315 | } while (0); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 316 | ccid2_pr_debug("=========\n"); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 317 | ccid2_hc_tx_check_sanity(hctx); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 318 | #endif | 
|  | 319 | } | 
|  | 320 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 321 | /* XXX Lame code duplication! | 
|  | 322 | * returns -1 if none was found. | 
|  | 323 | * else returns the next offset to use in the function call. | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 324 | */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 325 | static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset, | 
|  | 326 | unsigned char **vec, unsigned char *veclen) | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 327 | { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 328 | const struct dccp_hdr *dh = dccp_hdr(skb); | 
|  | 329 | unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb); | 
|  | 330 | unsigned char *opt_ptr; | 
|  | 331 | const unsigned char *opt_end = (unsigned char *)dh + | 
|  | 332 | (dh->dccph_doff * 4); | 
|  | 333 | unsigned char opt, len; | 
|  | 334 | unsigned char *value; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 335 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 336 | BUG_ON(offset < 0); | 
|  | 337 | options += offset; | 
|  | 338 | opt_ptr = options; | 
|  | 339 | if (opt_ptr >= opt_end) | 
|  | 340 | return -1; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 341 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 342 | while (opt_ptr != opt_end) { | 
|  | 343 | opt   = *opt_ptr++; | 
|  | 344 | len   = 0; | 
|  | 345 | value = NULL; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 346 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 347 | /* Check if this isn't a single byte option */ | 
|  | 348 | if (opt > DCCPO_MAX_RESERVED) { | 
|  | 349 | if (opt_ptr == opt_end) | 
|  | 350 | goto out_invalid_option; | 
|  | 351 |  | 
|  | 352 | len = *opt_ptr++; | 
|  | 353 | if (len < 3) | 
|  | 354 | goto out_invalid_option; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 355 | /* | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 356 | * Remove the type and len fields, leaving | 
|  | 357 | * just the value size | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 358 | */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 359 | len     -= 2; | 
|  | 360 | value   = opt_ptr; | 
|  | 361 | opt_ptr += len; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 362 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 363 | if (opt_ptr > opt_end) | 
|  | 364 | goto out_invalid_option; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 365 | } | 
|  | 366 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 367 | switch (opt) { | 
|  | 368 | case DCCPO_ACK_VECTOR_0: | 
|  | 369 | case DCCPO_ACK_VECTOR_1: | 
|  | 370 | *vec	= value; | 
|  | 371 | *veclen = len; | 
|  | 372 | return offset + (opt_ptr - options); | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 373 | } | 
|  | 374 | } | 
|  | 375 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 376 | return -1; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 377 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 378 | out_invalid_option: | 
|  | 379 | DCCP_BUG("Invalid option - this should not happen (previous parsing)!"); | 
|  | 380 | return -1; | 
| Gerrit Renker | 1435562 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 381 | } | 
|  | 382 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 383 | static void ccid2_hc_tx_kill_rto_timer(struct sock *sk) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 384 | { | 
|  | 385 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 386 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 387 | sk_stop_timer(sk, &hctx->ccid2hctx_rtotimer); | 
|  | 388 | ccid2_pr_debug("deleted RTO timer\n"); | 
|  | 389 | } | 
|  | 390 |  | 
|  | 391 | static inline void ccid2_new_ack(struct sock *sk, | 
|  | 392 | struct ccid2_seq *seqp, | 
|  | 393 | unsigned int *maxincr) | 
|  | 394 | { | 
|  | 395 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 396 |  | 
|  | 397 | if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) { | 
|  | 398 | if (*maxincr > 0 && ++hctx->ccid2hctx_packets_acked == 2) { | 
|  | 399 | hctx->ccid2hctx_cwnd += 1; | 
|  | 400 | *maxincr	     -= 1; | 
|  | 401 | hctx->ccid2hctx_packets_acked = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 402 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 403 | } else if (++hctx->ccid2hctx_packets_acked >= hctx->ccid2hctx_cwnd) { | 
|  | 404 | hctx->ccid2hctx_cwnd += 1; | 
|  | 405 | hctx->ccid2hctx_packets_acked = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 406 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 407 |  | 
|  | 408 | /* update RTO */ | 
|  | 409 | if (hctx->ccid2hctx_srtt == -1 || | 
|  | 410 | time_after(jiffies, hctx->ccid2hctx_lastrtt + hctx->ccid2hctx_srtt)) { | 
|  | 411 | unsigned long r = (long)jiffies - (long)seqp->ccid2s_sent; | 
|  | 412 | int s; | 
|  | 413 |  | 
|  | 414 | /* first measurement */ | 
|  | 415 | if (hctx->ccid2hctx_srtt == -1) { | 
|  | 416 | ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", | 
|  | 417 | r, jiffies, | 
|  | 418 | (unsigned long long)seqp->ccid2s_seq); | 
|  | 419 | ccid2_change_srtt(hctx, r); | 
|  | 420 | hctx->ccid2hctx_rttvar = r >> 1; | 
|  | 421 | } else { | 
|  | 422 | /* RTTVAR */ | 
|  | 423 | long tmp = hctx->ccid2hctx_srtt - r; | 
|  | 424 | long srtt; | 
|  | 425 |  | 
|  | 426 | if (tmp < 0) | 
|  | 427 | tmp *= -1; | 
|  | 428 |  | 
|  | 429 | tmp >>= 2; | 
|  | 430 | hctx->ccid2hctx_rttvar *= 3; | 
|  | 431 | hctx->ccid2hctx_rttvar >>= 2; | 
|  | 432 | hctx->ccid2hctx_rttvar += tmp; | 
|  | 433 |  | 
|  | 434 | /* SRTT */ | 
|  | 435 | srtt = hctx->ccid2hctx_srtt; | 
|  | 436 | srtt *= 7; | 
|  | 437 | srtt >>= 3; | 
|  | 438 | tmp = r >> 3; | 
|  | 439 | srtt += tmp; | 
|  | 440 | ccid2_change_srtt(hctx, srtt); | 
|  | 441 | } | 
|  | 442 | s = hctx->ccid2hctx_rttvar << 2; | 
|  | 443 | /* clock granularity is 1 when based on jiffies */ | 
|  | 444 | if (!s) | 
|  | 445 | s = 1; | 
|  | 446 | hctx->ccid2hctx_rto = hctx->ccid2hctx_srtt + s; | 
|  | 447 |  | 
|  | 448 | /* must be at least a second */ | 
|  | 449 | s = hctx->ccid2hctx_rto / HZ; | 
|  | 450 | /* DCCP doesn't require this [but I like it cuz my code sux] */ | 
|  | 451 | #if 1 | 
|  | 452 | if (s < 1) | 
|  | 453 | hctx->ccid2hctx_rto = HZ; | 
|  | 454 | #endif | 
|  | 455 | /* max 60 seconds */ | 
|  | 456 | if (s > 60) | 
|  | 457 | hctx->ccid2hctx_rto = HZ * 60; | 
|  | 458 |  | 
|  | 459 | hctx->ccid2hctx_lastrtt = jiffies; | 
|  | 460 |  | 
|  | 461 | ccid2_pr_debug("srtt: %ld rttvar: %ld rto: %ld (HZ=%d) R=%lu\n", | 
|  | 462 | hctx->ccid2hctx_srtt, hctx->ccid2hctx_rttvar, | 
|  | 463 | hctx->ccid2hctx_rto, HZ, r); | 
|  | 464 | } | 
|  | 465 |  | 
|  | 466 | /* we got a new ack, so re-start RTO timer */ | 
|  | 467 | ccid2_hc_tx_kill_rto_timer(sk); | 
|  | 468 | ccid2_start_rto_timer(sk); | 
|  | 469 | } | 
|  | 470 |  | 
|  | 471 | static void ccid2_hc_tx_dec_pipe(struct sock *sk) | 
|  | 472 | { | 
|  | 473 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 474 |  | 
|  | 475 | if (hctx->ccid2hctx_pipe == 0) | 
|  | 476 | DCCP_BUG("pipe == 0"); | 
|  | 477 | else | 
|  | 478 | hctx->ccid2hctx_pipe--; | 
|  | 479 |  | 
|  | 480 | if (hctx->ccid2hctx_pipe == 0) | 
|  | 481 | ccid2_hc_tx_kill_rto_timer(sk); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 482 | } | 
|  | 483 |  | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 484 | static void ccid2_congestion_event(struct sock *sk, struct ccid2_seq *seqp) | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 485 | { | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 486 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 487 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 488 | if (time_before(seqp->ccid2s_sent, hctx->ccid2hctx_last_cong)) { | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 489 | ccid2_pr_debug("Multiple losses in an RTT---treating as one\n"); | 
|  | 490 | return; | 
|  | 491 | } | 
|  | 492 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 493 | hctx->ccid2hctx_last_cong = jiffies; | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 494 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 495 | hctx->ccid2hctx_cwnd     = hctx->ccid2hctx_cwnd / 2 ? : 1U; | 
|  | 496 | hctx->ccid2hctx_ssthresh = max(hctx->ccid2hctx_cwnd, 2U); | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 497 |  | 
|  | 498 | /* Avoid spurious timeouts resulting from Ack Ratio > cwnd */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 499 | if (dccp_sk(sk)->dccps_l_ack_ratio > hctx->ccid2hctx_cwnd) | 
|  | 500 | ccid2_change_l_ack_ratio(sk, hctx->ccid2hctx_cwnd); | 
| Gerrit Renker | c8bf462 | 2008-09-04 07:30:19 +0200 | [diff] [blame] | 501 | } | 
|  | 502 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 503 | static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | 
|  | 504 | { | 
|  | 505 | struct dccp_sock *dp = dccp_sk(sk); | 
|  | 506 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
|  | 507 | u64 ackno, seqno; | 
|  | 508 | struct ccid2_seq *seqp; | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 509 | unsigned char *vector; | 
|  | 510 | unsigned char veclen; | 
|  | 511 | int offset = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 512 | int done = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 513 | unsigned int maxincr = 0; | 
|  | 514 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 515 | ccid2_hc_tx_check_sanity(hctx); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 516 | /* check reverse path congestion */ | 
|  | 517 | seqno = DCCP_SKB_CB(skb)->dccpd_seq; | 
|  | 518 |  | 
|  | 519 | /* XXX this whole "algorithm" is broken.  Need to fix it to keep track | 
|  | 520 | * of the seqnos of the dupacks so that rpseq and rpdupack are correct | 
|  | 521 | * -sorbo. | 
|  | 522 | */ | 
|  | 523 | /* need to bootstrap */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 524 | if (hctx->ccid2hctx_rpdupack == -1) { | 
|  | 525 | hctx->ccid2hctx_rpdupack = 0; | 
|  | 526 | hctx->ccid2hctx_rpseq = seqno; | 
| Arnaldo Carvalho de Melo | c0c736d | 2006-03-20 22:05:37 -0800 | [diff] [blame] | 527 | } else { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 528 | /* check if packet is consecutive */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 529 | if (dccp_delta_seqno(hctx->ccid2hctx_rpseq, seqno) == 1) | 
|  | 530 | hctx->ccid2hctx_rpseq = seqno; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 531 | /* it's a later packet */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 532 | else if (after48(seqno, hctx->ccid2hctx_rpseq)) { | 
|  | 533 | hctx->ccid2hctx_rpdupack++; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 534 |  | 
|  | 535 | /* check if we got enough dupacks */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 536 | if (hctx->ccid2hctx_rpdupack >= NUMDUPACK) { | 
|  | 537 | hctx->ccid2hctx_rpdupack = -1; /* XXX lame */ | 
|  | 538 | hctx->ccid2hctx_rpseq = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 539 |  | 
| Gerrit Renker | df054e1 | 2007-11-24 21:32:53 -0200 | [diff] [blame] | 540 | ccid2_change_l_ack_ratio(sk, 2 * dp->dccps_l_ack_ratio); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 541 | } | 
|  | 542 | } | 
|  | 543 | } | 
|  | 544 |  | 
|  | 545 | /* check forward path congestion */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 546 | /* still didn't send out new data packets */ | 
|  | 547 | if (hctx->ccid2hctx_seqh == hctx->ccid2hctx_seqt) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 548 | return; | 
|  | 549 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 550 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 
|  | 551 | case DCCP_PKT_ACK: | 
|  | 552 | case DCCP_PKT_DATAACK: | 
|  | 553 | break; | 
|  | 554 | default: | 
|  | 555 | return; | 
|  | 556 | } | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 557 |  | 
|  | 558 | ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 559 | if (after48(ackno, hctx->ccid2hctx_high_ack)) | 
|  | 560 | hctx->ccid2hctx_high_ack = ackno; | 
| Andrea Bittau | 32aac18 | 2006-11-16 14:28:40 -0200 | [diff] [blame] | 561 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 562 | seqp = hctx->ccid2hctx_seqt; | 
| Andrea Bittau | 32aac18 | 2006-11-16 14:28:40 -0200 | [diff] [blame] | 563 | while (before48(seqp->ccid2s_seq, ackno)) { | 
|  | 564 | seqp = seqp->ccid2s_next; | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 565 | if (seqp == hctx->ccid2hctx_seqh) { | 
|  | 566 | seqp = hctx->ccid2hctx_seqh->ccid2s_prev; | 
| Andrea Bittau | 32aac18 | 2006-11-16 14:28:40 -0200 | [diff] [blame] | 567 | break; | 
|  | 568 | } | 
|  | 569 | } | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 570 |  | 
| Gerrit Renker | a302002 | 2007-11-24 22:10:29 -0200 | [diff] [blame] | 571 | /* | 
|  | 572 | * In slow-start, cwnd can increase up to a maximum of Ack Ratio/2 | 
|  | 573 | * packets per acknowledgement. Rounding up avoids that cwnd is not | 
|  | 574 | * advanced when Ack Ratio is 1 and gives a slight edge otherwise. | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 575 | */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 576 | if (hctx->ccid2hctx_cwnd < hctx->ccid2hctx_ssthresh) | 
| Gerrit Renker | a302002 | 2007-11-24 22:10:29 -0200 | [diff] [blame] | 577 | maxincr = DIV_ROUND_UP(dp->dccps_l_ack_ratio, 2); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 578 |  | 
|  | 579 | /* go through all ack vectors */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 580 | while ((offset = ccid2_ackvector(sk, skb, offset, | 
|  | 581 | &vector, &veclen)) != -1) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 582 | /* go through this ack vector */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 583 | while (veclen--) { | 
|  | 584 | const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK; | 
|  | 585 | u64 ackno_end_rl = SUB48(ackno, rl); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 586 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 587 | ccid2_pr_debug("ackvec start:%llu end:%llu\n", | 
| Randy Dunlap | 234af48 | 2006-10-29 16:03:30 -0800 | [diff] [blame] | 588 | (unsigned long long)ackno, | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 589 | (unsigned long long)ackno_end_rl); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 590 | /* if the seqno we are analyzing is larger than the | 
|  | 591 | * current ackno, then move towards the tail of our | 
|  | 592 | * seqnos. | 
|  | 593 | */ | 
|  | 594 | while (after48(seqp->ccid2s_seq, ackno)) { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 595 | if (seqp == hctx->ccid2hctx_seqt) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 596 | done = 1; | 
|  | 597 | break; | 
|  | 598 | } | 
|  | 599 | seqp = seqp->ccid2s_prev; | 
|  | 600 | } | 
|  | 601 | if (done) | 
|  | 602 | break; | 
|  | 603 |  | 
|  | 604 | /* check all seqnos in the range of the vector | 
|  | 605 | * run length | 
|  | 606 | */ | 
|  | 607 | while (between48(seqp->ccid2s_seq,ackno_end_rl,ackno)) { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 608 | const u8 state = *vector & | 
|  | 609 | DCCP_ACKVEC_STATE_MASK; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 610 |  | 
|  | 611 | /* new packet received or marked */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 612 | if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED && | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 613 | !seqp->ccid2s_acked) { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 614 | if (state == | 
|  | 615 | DCCP_ACKVEC_STATE_ECN_MARKED) { | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 616 | ccid2_congestion_event(sk, | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 617 | seqp); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 618 | } else | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 619 | ccid2_new_ack(sk, seqp, | 
|  | 620 | &maxincr); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 621 |  | 
|  | 622 | seqp->ccid2s_acked = 1; | 
|  | 623 | ccid2_pr_debug("Got ack for %llu\n", | 
| Randy Dunlap | 234af48 | 2006-10-29 16:03:30 -0800 | [diff] [blame] | 624 | (unsigned long long)seqp->ccid2s_seq); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 625 | ccid2_hc_tx_dec_pipe(sk); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 626 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 627 | if (seqp == hctx->ccid2hctx_seqt) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 628 | done = 1; | 
|  | 629 | break; | 
|  | 630 | } | 
| Gerrit Renker | 3de5489 | 2007-11-24 20:37:48 -0200 | [diff] [blame] | 631 | seqp = seqp->ccid2s_prev; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 632 | } | 
|  | 633 | if (done) | 
|  | 634 | break; | 
|  | 635 |  | 
| Gerrit Renker | cfbbeab | 2007-11-24 20:43:59 -0200 | [diff] [blame] | 636 | ackno = SUB48(ackno_end_rl, 1); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 637 | vector++; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 638 | } | 
|  | 639 | if (done) | 
|  | 640 | break; | 
|  | 641 | } | 
|  | 642 |  | 
|  | 643 | /* The state about what is acked should be correct now | 
|  | 644 | * Check for NUMDUPACK | 
|  | 645 | */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 646 | seqp = hctx->ccid2hctx_seqt; | 
|  | 647 | while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) { | 
| Andrea Bittau | 32aac18 | 2006-11-16 14:28:40 -0200 | [diff] [blame] | 648 | seqp = seqp->ccid2s_next; | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 649 | if (seqp == hctx->ccid2hctx_seqh) { | 
|  | 650 | seqp = hctx->ccid2hctx_seqh->ccid2s_prev; | 
| Andrea Bittau | 32aac18 | 2006-11-16 14:28:40 -0200 | [diff] [blame] | 651 | break; | 
|  | 652 | } | 
|  | 653 | } | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 654 | done = 0; | 
|  | 655 | while (1) { | 
|  | 656 | if (seqp->ccid2s_acked) { | 
|  | 657 | done++; | 
| Gerrit Renker | 63df18a | 2007-11-24 22:04:35 -0200 | [diff] [blame] | 658 | if (done == NUMDUPACK) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 659 | break; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 660 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 661 | if (seqp == hctx->ccid2hctx_seqt) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 662 | break; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 663 | seqp = seqp->ccid2s_prev; | 
|  | 664 | } | 
|  | 665 |  | 
|  | 666 | /* If there are at least 3 acknowledgements, anything unacknowledged | 
|  | 667 | * below the last sequence number is considered lost | 
|  | 668 | */ | 
| Gerrit Renker | 63df18a | 2007-11-24 22:04:35 -0200 | [diff] [blame] | 669 | if (done == NUMDUPACK) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 670 | struct ccid2_seq *last_acked = seqp; | 
|  | 671 |  | 
|  | 672 | /* check for lost packets */ | 
|  | 673 | while (1) { | 
|  | 674 | if (!seqp->ccid2s_acked) { | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 675 | ccid2_pr_debug("Packet lost: %llu\n", | 
| Randy Dunlap | 234af48 | 2006-10-29 16:03:30 -0800 | [diff] [blame] | 676 | (unsigned long long)seqp->ccid2s_seq); | 
| Andrea Bittau | 374bcf3 | 2006-09-19 13:14:43 -0700 | [diff] [blame] | 677 | /* XXX need to traverse from tail -> head in | 
|  | 678 | * order to detect multiple congestion events in | 
|  | 679 | * one ack vector. | 
|  | 680 | */ | 
| Gerrit Renker | d50ad16 | 2007-11-24 21:40:24 -0200 | [diff] [blame] | 681 | ccid2_congestion_event(sk, seqp); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 682 | ccid2_hc_tx_dec_pipe(sk); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 683 | } | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 684 | if (seqp == hctx->ccid2hctx_seqt) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 685 | break; | 
|  | 686 | seqp = seqp->ccid2s_prev; | 
|  | 687 | } | 
|  | 688 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 689 | hctx->ccid2hctx_seqt = last_acked; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 690 | } | 
|  | 691 |  | 
|  | 692 | /* trim acked packets in tail */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 693 | while (hctx->ccid2hctx_seqt != hctx->ccid2hctx_seqh) { | 
|  | 694 | if (!hctx->ccid2hctx_seqt->ccid2s_acked) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 695 | break; | 
|  | 696 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 697 | hctx->ccid2hctx_seqt = hctx->ccid2hctx_seqt->ccid2s_next; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 698 | } | 
|  | 699 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 700 | ccid2_hc_tx_check_sanity(hctx); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 701 | } | 
|  | 702 |  | 
| Arnaldo Carvalho de Melo | 91f0ebf | 2006-03-20 19:21:44 -0800 | [diff] [blame] | 703 | static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 704 | { | 
| YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 705 | struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid); | 
| Gerrit Renker | b00d2bb | 2007-11-24 21:44:30 -0200 | [diff] [blame] | 706 | struct dccp_sock *dp = dccp_sk(sk); | 
|  | 707 | u32 max_ratio; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 708 |  | 
| Gerrit Renker | b00d2bb | 2007-11-24 21:44:30 -0200 | [diff] [blame] | 709 | /* RFC 4341, 5: initialise ssthresh to arbitrarily high (max) value */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 710 | hctx->ccid2hctx_ssthresh  = ~0U; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 711 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 712 | /* | 
|  | 713 | * RFC 4341, 5: "The cwnd parameter is initialized to at most four | 
|  | 714 | * packets for new connections, following the rules from [RFC3390]". | 
|  | 715 | * We need to convert the bytes of RFC3390 into the packets of RFC 4341. | 
|  | 716 | */ | 
|  | 717 | hctx->ccid2hctx_cwnd = clamp(4380U / dp->dccps_mss_cache, 2U, 4U); | 
| Gerrit Renker | b00d2bb | 2007-11-24 21:44:30 -0200 | [diff] [blame] | 718 |  | 
|  | 719 | /* Make sure that Ack Ratio is enabled and within bounds. */ | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 720 | max_ratio = DIV_ROUND_UP(hctx->ccid2hctx_cwnd, 2); | 
| Gerrit Renker | b00d2bb | 2007-11-24 21:44:30 -0200 | [diff] [blame] | 721 | if (dp->dccps_l_ack_ratio == 0 || dp->dccps_l_ack_ratio > max_ratio) | 
|  | 722 | dp->dccps_l_ack_ratio = max_ratio; | 
|  | 723 |  | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 724 | /* XXX init ~ to window size... */ | 
| Gerrit Renker | cd1f7d3 | 2007-10-04 14:41:00 -0700 | [diff] [blame] | 725 | if (ccid2_hc_tx_alloc_seq(hctx)) | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 726 | return -ENOMEM; | 
| Arnaldo Carvalho de Melo | 91f0ebf | 2006-03-20 19:21:44 -0800 | [diff] [blame] | 727 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 728 | hctx->ccid2hctx_rto	 = 3 * HZ; | 
|  | 729 | ccid2_change_srtt(hctx, -1); | 
|  | 730 | hctx->ccid2hctx_rttvar	 = -1; | 
|  | 731 | hctx->ccid2hctx_rpdupack = -1; | 
|  | 732 | hctx->ccid2hctx_last_cong = jiffies; | 
|  | 733 | setup_timer(&hctx->ccid2hctx_rtotimer, ccid2_hc_tx_rto_expire, | 
|  | 734 | (unsigned long)sk); | 
|  | 735 |  | 
|  | 736 | ccid2_hc_tx_check_sanity(hctx); | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 737 | return 0; | 
|  | 738 | } | 
|  | 739 |  | 
|  | 740 | static void ccid2_hc_tx_exit(struct sock *sk) | 
|  | 741 | { | 
| YOSHIFUJI Hideaki | c9eaf17 | 2007-02-09 23:24:38 +0900 | [diff] [blame] | 742 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 743 | int i; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 744 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 745 | ccid2_hc_tx_kill_rto_timer(sk); | 
| Andrea Bittau | 07978aa | 2006-09-19 13:13:37 -0700 | [diff] [blame] | 746 |  | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 747 | for (i = 0; i < hctx->ccid2hctx_seqbufc; i++) | 
|  | 748 | kfree(hctx->ccid2hctx_seqbuf[i]); | 
|  | 749 | hctx->ccid2hctx_seqbufc = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 750 | } | 
|  | 751 |  | 
|  | 752 | static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 
|  | 753 | { | 
|  | 754 | const struct dccp_sock *dp = dccp_sk(sk); | 
|  | 755 | struct ccid2_hc_rx_sock *hcrx = ccid2_hc_rx_sk(sk); | 
|  | 756 |  | 
|  | 757 | switch (DCCP_SKB_CB(skb)->dccpd_type) { | 
|  | 758 | case DCCP_PKT_DATA: | 
|  | 759 | case DCCP_PKT_DATAACK: | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 760 | hcrx->ccid2hcrx_data++; | 
|  | 761 | if (hcrx->ccid2hcrx_data >= dp->dccps_r_ack_ratio) { | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 762 | dccp_send_ack(sk); | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 763 | hcrx->ccid2hcrx_data = 0; | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 764 | } | 
|  | 765 | break; | 
|  | 766 | } | 
|  | 767 | } | 
|  | 768 |  | 
| Gerrit Renker | ddebc97 | 2009-01-04 21:42:53 -0800 | [diff] [blame] | 769 | struct ccid_operations ccid2_ops = { | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 770 | .ccid_id		= DCCPC_CCID2, | 
|  | 771 | .ccid_name		= "TCP-like", | 
| Gerrit Renker | 410e27a | 2008-09-09 13:27:22 +0200 | [diff] [blame] | 772 | .ccid_hc_tx_obj_size	= sizeof(struct ccid2_hc_tx_sock), | 
|  | 773 | .ccid_hc_tx_init	= ccid2_hc_tx_init, | 
|  | 774 | .ccid_hc_tx_exit	= ccid2_hc_tx_exit, | 
|  | 775 | .ccid_hc_tx_send_packet	= ccid2_hc_tx_send_packet, | 
|  | 776 | .ccid_hc_tx_packet_sent	= ccid2_hc_tx_packet_sent, | 
|  | 777 | .ccid_hc_tx_packet_recv	= ccid2_hc_tx_packet_recv, | 
|  | 778 | .ccid_hc_rx_obj_size	= sizeof(struct ccid2_hc_rx_sock), | 
|  | 779 | .ccid_hc_rx_packet_recv	= ccid2_hc_rx_packet_recv, | 
| Andrea Bittau | 2a91aa3 | 2006-03-20 17:41:47 -0800 | [diff] [blame] | 780 | }; | 
|  | 781 |  | 
| Gerrit Renker | 8411671 | 2006-11-20 18:26:03 -0200 | [diff] [blame] | 782 | #ifdef CONFIG_IP_DCCP_CCID2_DEBUG | 
| Gerrit Renker | 4326499 | 2008-08-23 13:28:27 +0200 | [diff] [blame] | 783 | module_param(ccid2_debug, bool, 0644); | 
| Gerrit Renker | ddebc97 | 2009-01-04 21:42:53 -0800 | [diff] [blame] | 784 | MODULE_PARM_DESC(ccid2_debug, "Enable CCID-2 debug messages"); | 
| Gerrit Renker | 8411671 | 2006-11-20 18:26:03 -0200 | [diff] [blame] | 785 | #endif |