blob: 471571e1ab2661e3a38c398a223037c2feafc7d6 [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
John Heffner0e579762005-06-23 12:29:07 -07002/* Tom Kelly's Scalable TCP
3 *
Joe Perchesa52b8bd2009-02-24 16:40:16 -08004 * See http://www.deneholme.net/tom/scalable/
John Heffner0e579762005-06-23 12:29:07 -07005 *
6 * John Heffner <jheffner@sc.edu>
7 */
8
John Heffner0e579762005-06-23 12:29:07 -07009#include <linux/module.h>
10#include <net/tcp.h>
11
12/* These factors derived from the recommended values in the aer:
13 * .01 and and 7/8. We use 50 instead of 100 to account for
14 * delayed ack.
15 */
16#define TCP_SCALABLE_AI_CNT 50U
17#define TCP_SCALABLE_MD_SCALE 3
18
Eric Dumazet24901552014-05-02 21:18:05 -070019static void tcp_scalable_cong_avoid(struct sock *sk, u32 ack, u32 acked)
John Heffner0e579762005-06-23 12:29:07 -070020{
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030021 struct tcp_sock *tp = tcp_sk(sk);
Stephen Hemmingerf4805ed2005-11-10 16:53:30 -080022
Eric Dumazet24901552014-05-02 21:18:05 -070023 if (!tcp_is_cwnd_limited(sk))
John Heffner0e579762005-06-23 12:29:07 -070024 return;
25
Yuchung Cheng071d5082015-07-09 13:16:29 -070026 if (tcp_in_slow_start(tp))
Yuchung Cheng9f9843a72013-10-31 11:07:31 -070027 tcp_slow_start(tp, acked);
Ilpo Järvinen758ce5c2009-02-28 04:44:37 +000028 else
Neal Cardwelle73ebb02015-01-28 20:01:35 -050029 tcp_cong_avoid_ai(tp, min(tp->snd_cwnd, TCP_SCALABLE_AI_CNT),
30 1);
John Heffner0e579762005-06-23 12:29:07 -070031}
32
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030033static u32 tcp_scalable_ssthresh(struct sock *sk)
John Heffner0e579762005-06-23 12:29:07 -070034{
Arnaldo Carvalho de Melo6687e982005-08-10 04:03:31 -030035 const struct tcp_sock *tp = tcp_sk(sk);
stephen hemminger688d1942014-08-29 23:32:05 -070036
John Heffner0e579762005-06-23 12:29:07 -070037 return max(tp->snd_cwnd - (tp->snd_cwnd>>TCP_SCALABLE_MD_SCALE), 2U);
38}
39
Stephen Hemmingera252beb2011-03-10 00:40:17 -080040static struct tcp_congestion_ops tcp_scalable __read_mostly = {
John Heffner0e579762005-06-23 12:29:07 -070041 .ssthresh = tcp_scalable_ssthresh,
Yuchung Chengf1722a12017-08-03 20:38:52 -070042 .undo_cwnd = tcp_reno_undo_cwnd,
John Heffner0e579762005-06-23 12:29:07 -070043 .cong_avoid = tcp_scalable_cong_avoid,
John Heffner0e579762005-06-23 12:29:07 -070044
45 .owner = THIS_MODULE,
46 .name = "scalable",
47};
48
49static int __init tcp_scalable_register(void)
50{
51 return tcp_register_congestion_control(&tcp_scalable);
52}
53
54static void __exit tcp_scalable_unregister(void)
55{
56 tcp_unregister_congestion_control(&tcp_scalable);
57}
58
59module_init(tcp_scalable_register);
60module_exit(tcp_scalable_unregister);
61
62MODULE_AUTHOR("John Heffner");
63MODULE_LICENSE("GPL");
64MODULE_DESCRIPTION("Scalable TCP");