Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /* Tom Kelly's Scalable TCP
0003  *
0004  * See http://www.deneholme.net/tom/scalable/
0005  *
0006  * John Heffner <jheffner@sc.edu>
0007  */
0008 
0009 #include <linux/module.h>
0010 #include <net/tcp.h>
0011 
0012 /* These factors derived from the recommended values in the aer:
0013  * .01 and 7/8.
0014  */
0015 #define TCP_SCALABLE_AI_CNT 100U
0016 #define TCP_SCALABLE_MD_SCALE   3
0017 
0018 static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
0019 {
0020     struct tcp_sock *tp = tcp_sk(sk);
0021 
0022     if (!tcp_is_cwnd_limited(sk))
0023         return;
0024 
0025     if (tcp_in_slow_start(tp)) {
0026         acked = tcp_slow_start(tp, acked);
0027         if (!acked)
0028             return;
0029     }
0030     tcp_cong_avoid_ai(tp, min(tcp_snd_cwnd(tp), TCP_SCALABLE_AI_CNT),
0031               acked);
0032 }
0033 
0034 static u32 tcp_scalable_ssthresh(struct sock *sk)
0035 {
0036     const struct tcp_sock *tp = tcp_sk(sk);
0037 
0038     return max(tcp_snd_cwnd(tp) - (tcp_snd_cwnd(tp)>>TCP_SCALABLE_MD_SCALE), 2U);
0039 }
0040 
0041 static struct tcp_congestion_ops tcp_scalable __read_mostly = {
0042     .ssthresh   = tcp_scalable_ssthresh,
0043     .undo_cwnd  = tcp_reno_undo_cwnd,
0044     .cong_avoid = tcp_scalable_cong_avoid,
0045 
0046     .owner      = THIS_MODULE,
0047     .name       = "scalable",
0048 };
0049 
0050 static int __init tcp_scalable_register(void)
0051 {
0052     return tcp_register_congestion_control(&tcp_scalable);
0053 }
0054 
0055 static void __exit tcp_scalable_unregister(void)
0056 {
0057     tcp_unregister_congestion_control(&tcp_scalable);
0058 }
0059 
0060 module_init(tcp_scalable_register);
0061 module_exit(tcp_scalable_unregister);
0062 
0063 MODULE_AUTHOR("John Heffner");
0064 MODULE_LICENSE("GPL");
0065 MODULE_DESCRIPTION("Scalable TCP");