~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv4/tcp_highspeed.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/ipv4/tcp_highspeed.c (Version linux-6.12-rc7) and /net/ipv4/tcp_highspeed.c (Version linux-4.15.18)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 /*                                                  1 /*
  3  * Sally Floyd's High Speed TCP (RFC 3649) con      2  * Sally Floyd's High Speed TCP (RFC 3649) congestion control
  4  *                                                  3  *
  5  * See https://www.icir.org/floyd/hstcp.html   !!   4  * See http://www.icir.org/floyd/hstcp.html
  6  *                                                  5  *
  7  * John Heffner <jheffner@psc.edu>                  6  * John Heffner <jheffner@psc.edu>
  8  */                                                 7  */
  9                                                     8 
 10 #include <linux/module.h>                           9 #include <linux/module.h>
 11 #include <net/tcp.h>                               10 #include <net/tcp.h>
 12                                                    11 
 13 /* From AIMD tables from RFC 3649 appendix B,      12 /* From AIMD tables from RFC 3649 appendix B,
 14  * with fixed-point MD scaled <<8.                 13  * with fixed-point MD scaled <<8.
 15  */                                                14  */
 16 static const struct hstcp_aimd_val {               15 static const struct hstcp_aimd_val {
 17         unsigned int cwnd;                         16         unsigned int cwnd;
 18         unsigned int md;                           17         unsigned int md;
 19 } hstcp_aimd_vals[] = {                            18 } hstcp_aimd_vals[] = {
 20         {     38,  128, /*  0.50 */ },             19         {     38,  128, /*  0.50 */ },
 21         {    118,  112, /*  0.44 */ },             20         {    118,  112, /*  0.44 */ },
 22         {    221,  104, /*  0.41 */ },             21         {    221,  104, /*  0.41 */ },
 23         {    347,   98, /*  0.38 */ },             22         {    347,   98, /*  0.38 */ },
 24         {    495,   93, /*  0.37 */ },             23         {    495,   93, /*  0.37 */ },
 25         {    663,   89, /*  0.35 */ },             24         {    663,   89, /*  0.35 */ },
 26         {    851,   86, /*  0.34 */ },             25         {    851,   86, /*  0.34 */ },
 27         {   1058,   83, /*  0.33 */ },             26         {   1058,   83, /*  0.33 */ },
 28         {   1284,   81, /*  0.32 */ },             27         {   1284,   81, /*  0.32 */ },
 29         {   1529,   78, /*  0.31 */ },             28         {   1529,   78, /*  0.31 */ },
 30         {   1793,   76, /*  0.30 */ },             29         {   1793,   76, /*  0.30 */ },
 31         {   2076,   74, /*  0.29 */ },             30         {   2076,   74, /*  0.29 */ },
 32         {   2378,   72, /*  0.28 */ },             31         {   2378,   72, /*  0.28 */ },
 33         {   2699,   71, /*  0.28 */ },             32         {   2699,   71, /*  0.28 */ },
 34         {   3039,   69, /*  0.27 */ },             33         {   3039,   69, /*  0.27 */ },
 35         {   3399,   68, /*  0.27 */ },             34         {   3399,   68, /*  0.27 */ },
 36         {   3778,   66, /*  0.26 */ },             35         {   3778,   66, /*  0.26 */ },
 37         {   4177,   65, /*  0.26 */ },             36         {   4177,   65, /*  0.26 */ },
 38         {   4596,   64, /*  0.25 */ },             37         {   4596,   64, /*  0.25 */ },
 39         {   5036,   62, /*  0.25 */ },             38         {   5036,   62, /*  0.25 */ },
 40         {   5497,   61, /*  0.24 */ },             39         {   5497,   61, /*  0.24 */ },
 41         {   5979,   60, /*  0.24 */ },             40         {   5979,   60, /*  0.24 */ },
 42         {   6483,   59, /*  0.23 */ },             41         {   6483,   59, /*  0.23 */ },
 43         {   7009,   58, /*  0.23 */ },             42         {   7009,   58, /*  0.23 */ },
 44         {   7558,   57, /*  0.22 */ },             43         {   7558,   57, /*  0.22 */ },
 45         {   8130,   56, /*  0.22 */ },             44         {   8130,   56, /*  0.22 */ },
 46         {   8726,   55, /*  0.22 */ },             45         {   8726,   55, /*  0.22 */ },
 47         {   9346,   54, /*  0.21 */ },             46         {   9346,   54, /*  0.21 */ },
 48         {   9991,   53, /*  0.21 */ },             47         {   9991,   53, /*  0.21 */ },
 49         {  10661,   52, /*  0.21 */ },             48         {  10661,   52, /*  0.21 */ },
 50         {  11358,   52, /*  0.20 */ },             49         {  11358,   52, /*  0.20 */ },
 51         {  12082,   51, /*  0.20 */ },             50         {  12082,   51, /*  0.20 */ },
 52         {  12834,   50, /*  0.20 */ },             51         {  12834,   50, /*  0.20 */ },
 53         {  13614,   49, /*  0.19 */ },             52         {  13614,   49, /*  0.19 */ },
 54         {  14424,   48, /*  0.19 */ },             53         {  14424,   48, /*  0.19 */ },
 55         {  15265,   48, /*  0.19 */ },             54         {  15265,   48, /*  0.19 */ },
 56         {  16137,   47, /*  0.19 */ },             55         {  16137,   47, /*  0.19 */ },
 57         {  17042,   46, /*  0.18 */ },             56         {  17042,   46, /*  0.18 */ },
 58         {  17981,   45, /*  0.18 */ },             57         {  17981,   45, /*  0.18 */ },
 59         {  18955,   45, /*  0.18 */ },             58         {  18955,   45, /*  0.18 */ },
 60         {  19965,   44, /*  0.17 */ },             59         {  19965,   44, /*  0.17 */ },
 61         {  21013,   43, /*  0.17 */ },             60         {  21013,   43, /*  0.17 */ },
 62         {  22101,   43, /*  0.17 */ },             61         {  22101,   43, /*  0.17 */ },
 63         {  23230,   42, /*  0.17 */ },             62         {  23230,   42, /*  0.17 */ },
 64         {  24402,   41, /*  0.16 */ },             63         {  24402,   41, /*  0.16 */ },
 65         {  25618,   41, /*  0.16 */ },             64         {  25618,   41, /*  0.16 */ },
 66         {  26881,   40, /*  0.16 */ },             65         {  26881,   40, /*  0.16 */ },
 67         {  28193,   39, /*  0.16 */ },             66         {  28193,   39, /*  0.16 */ },
 68         {  29557,   39, /*  0.15 */ },             67         {  29557,   39, /*  0.15 */ },
 69         {  30975,   38, /*  0.15 */ },             68         {  30975,   38, /*  0.15 */ },
 70         {  32450,   38, /*  0.15 */ },             69         {  32450,   38, /*  0.15 */ },
 71         {  33986,   37, /*  0.15 */ },             70         {  33986,   37, /*  0.15 */ },
 72         {  35586,   36, /*  0.14 */ },             71         {  35586,   36, /*  0.14 */ },
 73         {  37253,   36, /*  0.14 */ },             72         {  37253,   36, /*  0.14 */ },
 74         {  38992,   35, /*  0.14 */ },             73         {  38992,   35, /*  0.14 */ },
 75         {  40808,   35, /*  0.14 */ },             74         {  40808,   35, /*  0.14 */ },
 76         {  42707,   34, /*  0.13 */ },             75         {  42707,   34, /*  0.13 */ },
 77         {  44694,   33, /*  0.13 */ },             76         {  44694,   33, /*  0.13 */ },
 78         {  46776,   33, /*  0.13 */ },             77         {  46776,   33, /*  0.13 */ },
 79         {  48961,   32, /*  0.13 */ },             78         {  48961,   32, /*  0.13 */ },
 80         {  51258,   32, /*  0.13 */ },             79         {  51258,   32, /*  0.13 */ },
 81         {  53677,   31, /*  0.12 */ },             80         {  53677,   31, /*  0.12 */ },
 82         {  56230,   30, /*  0.12 */ },             81         {  56230,   30, /*  0.12 */ },
 83         {  58932,   30, /*  0.12 */ },             82         {  58932,   30, /*  0.12 */ },
 84         {  61799,   29, /*  0.12 */ },             83         {  61799,   29, /*  0.12 */ },
 85         {  64851,   28, /*  0.11 */ },             84         {  64851,   28, /*  0.11 */ },
 86         {  68113,   28, /*  0.11 */ },             85         {  68113,   28, /*  0.11 */ },
 87         {  71617,   27, /*  0.11 */ },             86         {  71617,   27, /*  0.11 */ },
 88         {  75401,   26, /*  0.10 */ },             87         {  75401,   26, /*  0.10 */ },
 89         {  79517,   26, /*  0.10 */ },             88         {  79517,   26, /*  0.10 */ },
 90         {  84035,   25, /*  0.10 */ },             89         {  84035,   25, /*  0.10 */ },
 91         {  89053,   24, /*  0.10 */ },             90         {  89053,   24, /*  0.10 */ },
 92 };                                                 91 };
 93                                                    92 
 94 #define HSTCP_AIMD_MAX  ARRAY_SIZE(hstcp_aimd_     93 #define HSTCP_AIMD_MAX  ARRAY_SIZE(hstcp_aimd_vals)
 95                                                    94 
 96 struct hstcp {                                     95 struct hstcp {
 97         u32     ai;                                96         u32     ai;
 98 };                                                 97 };
 99                                                    98 
100 static void hstcp_init(struct sock *sk)            99 static void hstcp_init(struct sock *sk)
101 {                                                 100 {
102         struct tcp_sock *tp = tcp_sk(sk);         101         struct tcp_sock *tp = tcp_sk(sk);
103         struct hstcp *ca = inet_csk_ca(sk);       102         struct hstcp *ca = inet_csk_ca(sk);
104                                                   103 
105         ca->ai = 0;                               104         ca->ai = 0;
106                                                   105 
107         /* Ensure the MD arithmetic works.  Th    106         /* Ensure the MD arithmetic works.  This is somewhat pedantic,
108          * since I don't think we will see a c    107          * since I don't think we will see a cwnd this large. :) */
109         tp->snd_cwnd_clamp = min_t(u32, tp->sn    108         tp->snd_cwnd_clamp = min_t(u32, tp->snd_cwnd_clamp, 0xffffffff/128);
110 }                                                 109 }
111                                                   110 
112 static void hstcp_cong_avoid(struct sock *sk,     111 static void hstcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
113 {                                                 112 {
114         struct tcp_sock *tp = tcp_sk(sk);         113         struct tcp_sock *tp = tcp_sk(sk);
115         struct hstcp *ca = inet_csk_ca(sk);       114         struct hstcp *ca = inet_csk_ca(sk);
116                                                   115 
117         if (!tcp_is_cwnd_limited(sk))             116         if (!tcp_is_cwnd_limited(sk))
118                 return;                           117                 return;
119                                                   118 
120         if (tcp_in_slow_start(tp))                119         if (tcp_in_slow_start(tp))
121                 tcp_slow_start(tp, acked);        120                 tcp_slow_start(tp, acked);
122         else {                                    121         else {
123                 /* Update AIMD parameters.        122                 /* Update AIMD parameters.
124                  *                                123                  *
125                  * We want to guarantee that:     124                  * We want to guarantee that:
126                  *     hstcp_aimd_vals[ca->ai-    125                  *     hstcp_aimd_vals[ca->ai-1].cwnd <
127                  *     snd_cwnd <=                126                  *     snd_cwnd <=
128                  *     hstcp_aimd_vals[ca->ai]    127                  *     hstcp_aimd_vals[ca->ai].cwnd
129                  */                               128                  */
130                 if (tcp_snd_cwnd(tp) > hstcp_a !! 129                 if (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd) {
131                         while (tcp_snd_cwnd(tp !! 130                         while (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd &&
132                                ca->ai < HSTCP_    131                                ca->ai < HSTCP_AIMD_MAX - 1)
133                                 ca->ai++;         132                                 ca->ai++;
134                 } else if (ca->ai && tcp_snd_c !! 133                 } else if (ca->ai && tp->snd_cwnd <= hstcp_aimd_vals[ca->ai-1].cwnd) {
135                         while (ca->ai && tcp_s !! 134                         while (ca->ai && tp->snd_cwnd <= hstcp_aimd_vals[ca->ai-1].cwnd)
136                                 ca->ai--;         135                                 ca->ai--;
137                 }                                 136                 }
138                                                   137 
139                 /* Do additive increase */        138                 /* Do additive increase */
140                 if (tcp_snd_cwnd(tp) < tp->snd !! 139                 if (tp->snd_cwnd < tp->snd_cwnd_clamp) {
141                         /* cwnd = cwnd + a(w)     140                         /* cwnd = cwnd + a(w) / cwnd */
142                         tp->snd_cwnd_cnt += ca    141                         tp->snd_cwnd_cnt += ca->ai + 1;
143                         if (tp->snd_cwnd_cnt > !! 142                         if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
144                                 tp->snd_cwnd_c !! 143                                 tp->snd_cwnd_cnt -= tp->snd_cwnd;
145                                 tcp_snd_cwnd_s !! 144                                 tp->snd_cwnd++;
146                         }                         145                         }
147                 }                                 146                 }
148         }                                         147         }
149 }                                                 148 }
150                                                   149 
151 static u32 hstcp_ssthresh(struct sock *sk)        150 static u32 hstcp_ssthresh(struct sock *sk)
152 {                                                 151 {
153         const struct tcp_sock *tp = tcp_sk(sk)    152         const struct tcp_sock *tp = tcp_sk(sk);
154         struct hstcp *ca = inet_csk_ca(sk);       153         struct hstcp *ca = inet_csk_ca(sk);
155                                                   154 
156         /* Do multiplicative decrease */          155         /* Do multiplicative decrease */
157         return max(tcp_snd_cwnd(tp) - ((tcp_sn !! 156         return max(tp->snd_cwnd - ((tp->snd_cwnd * hstcp_aimd_vals[ca->ai].md) >> 8), 2U);
158 }                                                 157 }
159                                                   158 
160 static struct tcp_congestion_ops tcp_highspeed    159 static struct tcp_congestion_ops tcp_highspeed __read_mostly = {
161         .init           = hstcp_init,             160         .init           = hstcp_init,
162         .ssthresh       = hstcp_ssthresh,         161         .ssthresh       = hstcp_ssthresh,
163         .undo_cwnd      = tcp_reno_undo_cwnd,     162         .undo_cwnd      = tcp_reno_undo_cwnd,
164         .cong_avoid     = hstcp_cong_avoid,       163         .cong_avoid     = hstcp_cong_avoid,
165                                                   164 
166         .owner          = THIS_MODULE,            165         .owner          = THIS_MODULE,
167         .name           = "highspeed"             166         .name           = "highspeed"
168 };                                                167 };
169                                                   168 
170 static int __init hstcp_register(void)            169 static int __init hstcp_register(void)
171 {                                                 170 {
172         BUILD_BUG_ON(sizeof(struct hstcp) > IC    171         BUILD_BUG_ON(sizeof(struct hstcp) > ICSK_CA_PRIV_SIZE);
173         return tcp_register_congestion_control    172         return tcp_register_congestion_control(&tcp_highspeed);
174 }                                                 173 }
175                                                   174 
176 static void __exit hstcp_unregister(void)         175 static void __exit hstcp_unregister(void)
177 {                                                 176 {
178         tcp_unregister_congestion_control(&tcp    177         tcp_unregister_congestion_control(&tcp_highspeed);
179 }                                                 178 }
180                                                   179 
181 module_init(hstcp_register);                      180 module_init(hstcp_register);
182 module_exit(hstcp_unregister);                    181 module_exit(hstcp_unregister);
183                                                   182 
184 MODULE_AUTHOR("John Heffner");                    183 MODULE_AUTHOR("John Heffner");
185 MODULE_LICENSE("GPL");                            184 MODULE_LICENSE("GPL");
186 MODULE_DESCRIPTION("High Speed TCP");             185 MODULE_DESCRIPTION("High Speed TCP");
187                                                   186 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php