26 #include <linux/slab.h>
31 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
32 static bool ccid2_debug;
33 #define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a)
35 #define ccid2_pr_debug(format, a...)
65 hc->
tx_seqh->ccid2s_next = seqp;
81 if (ccid2_cwnd_network_limited(ccid2_hc_tx_sk(sk)))
86 static void ccid2_change_l_ack_ratio(
struct sock *sk,
u32 val)
96 if (val == 0 || val > max_ratio) {
97 DCCP_WARN(
"Limiting Ack Ratio (%u) to %u\n", val, max_ratio);
104 static void ccid2_check_l_ack_ratio(
struct sock *sk)
119 ccid2_change_l_ack_ratio(sk, hc->
tx_cwnd/2 ? : 1
U);
122 static void ccid2_change_l_seq_window(
struct sock *sk,
u64 val)
129 static void ccid2_hc_tx_rto_expire(
unsigned long data)
131 struct sock *sk = (
struct sock *)data;
133 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc);
162 ccid2_change_l_ack_ratio(sk, 1);
165 if (sender_was_blocked)
166 tasklet_schedule(&dccp_sk(sk)->dccps_xmitlet);
177 static bool ccid2_do_cwv =
true;
179 MODULE_PARM_DESC(ccid2_do_cwv,
"Perform RFC2861 Congestion Window Validation");
194 static void ccid2_cwnd_application_limited(
struct sock *sk,
const u32 now)
198 u32 init_win = rfc3390_bytes_to_packets(dccp_sk(sk)->dccps_mss_cache),
209 ccid2_check_l_ack_ratio(sk);
213 static void ccid2_cwnd_restart(
struct sock *sk,
const u32 now)
217 iwnd = rfc3390_bytes_to_packets(dccp_sk(sk)->dccps_mss_cache);
222 restart_cwnd =
min(cwnd, iwnd);
229 ccid2_check_l_ack_ratio(sk);
232 static void ccid2_hc_tx_packet_sent(
struct sock *sk,
unsigned int len)
240 if (ccid2_do_cwv && !hc->
tx_pipe &&
242 ccid2_cwnd_restart(sk, now);
248 if (ccid2_cwnd_network_limited(hc)) {
249 ccid2_update_used_window(hc, hc->
tx_cwnd);
259 ccid2_cwnd_application_limited(sk, now);
264 hc->
tx_seqh->ccid2s_sent = now;
266 next = hc->
tx_seqh->ccid2s_next;
269 if (ccid2_hc_tx_alloc_seq(hc)) {
270 DCCP_CRIT(
"packet history - out of memory!");
274 next = hc->
tx_seqh->ccid2s_next;
304 if (hc->tx_ackloss) {
305 if (hc->tx_arsent >= hc->
tx_cwnd) {
319 if (hc->tx_arsent >= denom) {
332 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG
356 static void ccid2_rtt_estimator(
struct sock *sk,
const long mrtt)
426 static void ccid2_new_ack(
struct sock *sk,
struct ccid2_seq *seqp,
427 unsigned int *maxincr)
453 else if (r_seq_used * CCID2_WIN_CHANGE_FACTOR < dp->dccps_r_seq_win/2)
472 static void ccid2_congestion_event(
struct sock *sk,
struct ccid2_seq *seqp)
486 ccid2_check_l_ack_ratio(sk);
503 static void ccid2_hc_tx_packet_recv(
struct sock *sk,
struct sk_buff *skb)
507 const bool sender_was_blocked = ccid2_cwnd_network_limited(hc);
512 unsigned int maxincr = 0;
527 if (dccp_delta_seqno(hc->
tx_rpseq, seqno) == 1)
537 #ifdef __CCID2_COPES_GRACEFULLY_WITH_ACK_CONGESTION_CONTROL__
552 if (dccp_packet_without_ack(skb))
567 seqp = hc->
tx_seqh->ccid2s_prev;
583 for (; avp->
len--; avp->
vec++) {
585 dccp_ackvec_runlen(avp->
vec));
588 (
unsigned long long)ackno,
589 dccp_ackvec_state(avp->
vec) >> 6,
590 dccp_ackvec_runlen(avp->
vec));
608 while (between48(seqp->
ccid2s_seq,ackno_end_rl,ackno)) {
615 ccid2_congestion_event(sk,
618 ccid2_new_ack(sk, seqp,
635 ackno =
SUB48(ackno_end_rl, 1);
648 seqp = hc->
tx_seqh->ccid2s_prev;
679 ccid2_congestion_event(sk, seqp);
692 if (!hc->
tx_seqt->ccid2s_acked)
705 if (sender_was_blocked && !ccid2_cwnd_network_limited(hc))
706 tasklet_schedule(&dccp_sk(sk)->dccps_xmitlet);
710 static int ccid2_hc_tx_init(
struct ccid *
ccid,
struct sock *sk)
729 if (ccid2_hc_tx_alloc_seq(hc))
742 static void ccid2_hc_tx_exit(
struct sock *sk)
754 static void ccid2_hc_rx_packet_recv(
struct sock *sk,
struct sk_buff *skb)
758 if (!dccp_data_packet(skb))
769 .ccid_name =
"TCP-like",
771 .ccid_hc_tx_init = ccid2_hc_tx_init,
772 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
773 .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet,
774 .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent,
775 .ccid_hc_tx_parse_options = ccid2_hc_tx_parse_options,
776 .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv,
778 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
781 #ifdef CONFIG_IP_DCCP_CCID2_DEBUG