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