• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2022 Huawei Device Co., Ltd.
4  *
5  * NewIP INET
6  * An implementation of the TCP/IP protocol suite for the LINUX
7  * operating system. NewIP INET is implemented using the  BSD Socket
8  * interface as the means of communication with the user level.
9  *
10  * Description: Definitions for the NewIP parameter module.
11  *
12  * Author: Yang Yanjun <yangyanjun@huawei.com>
13  *
14  * Data: 2022-07-25
15  */
16 #define pr_fmt(fmt) KBUILD_MODNAME ": [%s:%d] " fmt, __func__, __LINE__
17 
18 #include <net/dst.h>
19 #include <net/tcp.h>
20 #include <net/tcp_nip.h>
21 #include <net/inet_common.h>
22 #include <linux/module.h>
23 #include <linux/sysctl.h>
24 #include <linux/kernel.h>
25 #include <linux/errqueue.h>
26 
27 /*********************************************************************************************/
28 /*                            Newip protocol name                                            */
29 /*********************************************************************************************/
30 int g_af_ninet = AF_NINET;
31 module_param_named(af_ninet, g_af_ninet, int, 0444);
32 
33 /*********************************************************************************************/
34 /*                            Rto timeout timer period (HZ/n)                                */
35 /*********************************************************************************************/
36 /* RTT RTO in the small-delay scenario */
37 int g_nip_rto = 50;
38 module_param_named(nip_rto, g_nip_rto, int, 0644);
39 
get_nip_rto(void)40 int get_nip_rto(void)
41 {
42 	return g_nip_rto;
43 }
44 
45 int g_nip_dynamic_rto_max = 60; // 60ms
46 module_param_named(nip_dynamic_rto_max, g_nip_dynamic_rto_max, int, 0644);
47 
get_nip_dynamic_rto_max(void)48 int get_nip_dynamic_rto_max(void)
49 {
50 	return g_nip_dynamic_rto_max;
51 }
52 
53 int g_nip_dynamic_rto_min = 20; // 20ms
54 module_param_named(nip_dynamic_rto_min, g_nip_dynamic_rto_min, int, 0644);
55 
get_nip_dynamic_rto_min(void)56 int get_nip_dynamic_rto_min(void)
57 {
58 	return g_nip_dynamic_rto_min;
59 }
60 
61 int g_nip_srtt_factor = 4;
62 module_param_named(nip_srtt_factor, g_nip_srtt_factor, int, 0644);
63 
get_nip_srtt_factor(void)64 int get_nip_srtt_factor(void)
65 {
66 	return g_nip_srtt_factor;
67 }
68 
69 /*********************************************************************************************/
70 /*                                    BW parameters                                          */
71 /*********************************************************************************************/
72 int g_nip_br_max_bw = 400000;
73 module_param_named(nip_br_max_bw, g_nip_br_max_bw, int, 0644);
74 
get_nip_br_max_bw(void)75 int get_nip_br_max_bw(void)
76 {
77 	return g_nip_br_max_bw;
78 }
79 
80 /*********************************************************************************************/
81 /*                            TCP sending and receiving buffer configuration                 */
82 /*********************************************************************************************/
83 int g_nip_sndbuf = 1050000; // 1M
84 module_param_named(nip_sndbuf, g_nip_sndbuf, int, 0644);
85 
get_nip_sndbuf(void)86 int get_nip_sndbuf(void)
87 {
88 	return g_nip_sndbuf;
89 }
90 
91 int g_nip_rcvbuf = 2000000; // 2M
92 module_param_named(nip_rcvbuf, g_nip_rcvbuf, int, 0644);
93 
get_nip_rcvbuf(void)94 int get_nip_rcvbuf(void)
95 {
96 	return g_nip_rcvbuf;
97 }
98 
99 /*********************************************************************************************/
100 /*                            Window configuration                                           */
101 /*********************************************************************************************/
102 /* Maximum receiving window */
103 bool g_wscale_enable = 1;
104 module_param_named(wscale_enable, g_wscale_enable, bool, 0644);
105 
get_wscale_enable(void)106 bool get_wscale_enable(void)
107 {
108 	return g_wscale_enable;
109 }
110 
111 /* Window scale configuration, 2^n */
112 int g_wscale = 7;
113 module_param_named(wscale, g_wscale, int, 0644);
114 
get_wscale(void)115 int get_wscale(void)
116 {
117 	return g_wscale;
118 }
119 
120 /*********************************************************************************************/
121 /*                            Enables the debugging of special scenarios                     */
122 /*********************************************************************************************/
123 /* After receiving n packets, an ACK packet is sent */
124 int g_ack_num = 5;
125 module_param_named(ack_num, g_ack_num, int, 0644);
126 
get_ack_num(void)127 int get_ack_num(void)
128 {
129 	return g_ack_num;
130 }
131 
132 /* Reset the packet sending window threshold after receiving n ACK packets */
133 int g_nip_ssthresh_reset = 10000000; // 10M
134 module_param_named(nip_ssthresh_reset, g_nip_ssthresh_reset, int, 0644);
135 
get_nip_ssthresh_reset(void)136 int get_nip_ssthresh_reset(void)
137 {
138 	return g_nip_ssthresh_reset;
139 }
140 
141 /*********************************************************************************************/
142 /*                            Retransmission parameters after ACK                            */
143 /*********************************************************************************************/
144 /* Three DUP ACK packets indicates the number of retransmission packets */
145 int g_dup_ack_retrans_num = 5;
146 module_param_named(dup_ack_retrans_num, g_dup_ack_retrans_num, int, 0644);
147 
get_dup_ack_retrans_num(void)148 int get_dup_ack_retrans_num(void)
149 {
150 	return g_dup_ack_retrans_num;
151 }
152 
153 /* Common ACK Indicates the number of retransmissions */
154 int g_ack_retrans_num = 5;
155 module_param_named(ack_retrans_num, g_ack_retrans_num, int, 0644);
156 
get_ack_retrans_num(void)157 int get_ack_retrans_num(void)
158 {
159 	return g_ack_retrans_num;
160 }
161 
162 int g_dup_ack_snd_max = 6;
163 module_param_named(dup_ack_snd_max, g_dup_ack_snd_max, int, 0644);
164 
get_dup_ack_snd_max(void)165 int get_dup_ack_snd_max(void)
166 {
167 	return g_dup_ack_snd_max;
168 }
169 
170 /*********************************************************************************************/
171 /*                            RTT timestamp parameters                                       */
172 /*********************************************************************************************/
173 int g_rtt_tstamp_rto_up = 100;  // rtt_tstamp >= 100  ==> shorten rto
174 module_param_named(rtt_tstamp_rto_up, g_rtt_tstamp_rto_up, int, 0644);
175 
get_rtt_tstamp_rto_up(void)176 int get_rtt_tstamp_rto_up(void)
177 {
178 	return g_rtt_tstamp_rto_up;
179 }
180 
181 int g_rtt_tstamp_high = 30;     // rtt_tstamp >= 30  ==> ssthresh = 100K
182 module_param_named(rtt_tstamp_high, g_rtt_tstamp_high, int, 0644);
183 
get_rtt_tstamp_high(void)184 int get_rtt_tstamp_high(void)
185 {
186 	return g_rtt_tstamp_high;
187 }
188 
189 int g_rtt_tstamp_mid_high = 20; // rtt_tstamp >= 20  ==> ssthresh = 250K
190 module_param_named(rtt_tstamp_mid_high, g_rtt_tstamp_mid_high, int, 0644);
191 
get_rtt_tstamp_mid_high(void)192 int get_rtt_tstamp_mid_high(void)
193 {
194 	return g_rtt_tstamp_mid_high;
195 }
196 
197 /* rtt_tstamp >= 10  ==> ssthresh = 1M (500K ~ 1M)
198  * rtt_tstamp <  10  ==> ssthresh = 1.5M
199  */
200 int g_rtt_tstamp_mid_low = 10;
201 module_param_named(rtt_tstamp_mid_low, g_rtt_tstamp_mid_low, int, 0644);
202 
get_rtt_tstamp_mid_low(void)203 int get_rtt_tstamp_mid_low(void)
204 {
205 	return g_rtt_tstamp_mid_low;
206 }
207 
208 int g_ack_to_nxt_snd_tstamp = 500;
209 module_param_named(ack_to_nxt_snd_tstamp, g_ack_to_nxt_snd_tstamp, int, 0644);
210 
get_ack_to_nxt_snd_tstamp(void)211 int get_ack_to_nxt_snd_tstamp(void)
212 {
213 	return g_ack_to_nxt_snd_tstamp;
214 }
215 
216 /*********************************************************************************************/
217 /*                            Window threshold parameters                                    */
218 /*********************************************************************************************/
219 bool g_ssthresh_enable = 1;
220 module_param_named(ssthresh_enable, g_ssthresh_enable, bool, 0644);
221 
get_ssthresh_enable(void)222 bool get_ssthresh_enable(void)
223 {
224 	return g_ssthresh_enable;
225 }
226 
227 int g_nip_ssthresh_default = 300000; // 300K
228 module_param_named(nip_ssthresh_default, g_nip_ssthresh_default, int, 0644);
229 
get_nip_ssthresh_default(void)230 int get_nip_ssthresh_default(void)
231 {
232 	return g_nip_ssthresh_default;
233 }
234 
235 int g_ssthresh_high = 1500000;       // rtt_tstamp <  10  ==> ssthresh = 1.5M
236 module_param_named(ssthresh_high, g_ssthresh_high, int, 0644);
237 
get_ssthresh_high(void)238 int get_ssthresh_high(void)
239 {
240 	return g_ssthresh_high;
241 }
242 
243 int g_ssthresh_mid_high = 1000000;   // rtt_tstamp >= 10  ==> ssthresh = 1M (500K ~ 1M)
244 module_param_named(ssthresh_mid_high, g_ssthresh_mid_high, int, 0644);
245 
get_ssthresh_mid_high(void)246 int get_ssthresh_mid_high(void)
247 {
248 	return g_ssthresh_mid_high;
249 }
250 
251 int g_ssthresh_mid_low = 250000;     // rtt_tstamp >= 20  ==> ssthresh = 250K
252 module_param_named(ssthresh_mid_low, g_ssthresh_mid_low, int, 0644);
253 
get_ssthresh_mid_low(void)254 int get_ssthresh_mid_low(void)
255 {
256 	return g_ssthresh_mid_low;
257 }
258 
259 int g_ssthresh_low = 100000;         // rtt_tstamp >= 30  ==> ssthresh = 100K
260 module_param_named(ssthresh_low, g_ssthresh_low, int, 0644);
261 
get_ssthresh_low(void)262 int get_ssthresh_low(void)
263 {
264 	return g_ssthresh_low;
265 }
266 
267 int g_ssthresh_low_min = 10000;      // rtt_tstamp >= 100  ==> ssthresh = 10K
268 module_param_named(ssthresh_low_min, g_ssthresh_low_min, int, 0644);
269 
get_ssthresh_low_min(void)270 int get_ssthresh_low_min(void)
271 {
272 	return g_ssthresh_low_min;
273 }
274 
275 int g_ssthresh_high_step = 1;
276 module_param_named(ssthresh_high_step, g_ssthresh_high_step, int, 0644);
277 
get_ssthresh_high_step(void)278 int get_ssthresh_high_step(void)
279 {
280 	return g_ssthresh_high_step;
281 }
282 
283 int g_ssthresh_br_max = 100000; // ssthresh = 100K
284 module_param_named(nip_ssthresh_br_max, g_ssthresh_br_max, int, 0644);
285 
get_ssthresh_br_max(void)286 int get_ssthresh_br_max(void)
287 {
288 	return g_ssthresh_br_max;
289 }
290 
291 /*********************************************************************************************/
292 /*                            keepalive parameters                                           */
293 /*********************************************************************************************/
294 int g_nip_idle_ka_probes_out = 20;
295 module_param_named(nip_idle_ka_probes_out, g_nip_idle_ka_probes_out, int, 0644);
296 
get_nip_idle_ka_probes_out(void)297 int get_nip_idle_ka_probes_out(void)
298 {
299 	return g_nip_idle_ka_probes_out;
300 }
301 
302 int g_nip_keepalive_time = 25;
303 module_param_named(nip_keepalive_time, g_nip_keepalive_time, int, 0644);
304 
get_nip_keepalive_time(void)305 int get_nip_keepalive_time(void)
306 {
307 	return g_nip_keepalive_time;
308 }
309 
310 int g_nip_keepalive_intvl = 25;
311 module_param_named(nip_keepalive_intvl, g_nip_keepalive_intvl, int, 0644);
312 
get_nip_keepalive_intvl(void)313 int get_nip_keepalive_intvl(void)
314 {
315 	return g_nip_keepalive_intvl;
316 }
317 
318 /*********************************************************************************************/
319 /*                            probe parameters                                               */
320 /*********************************************************************************************/
321 int g_nip_probe_max = 2000;
322 module_param_named(nip_probe_max, g_nip_probe_max, int, 0644);
323 
get_nip_probe_max(void)324 int get_nip_probe_max(void)
325 {
326 	return g_nip_probe_max;
327 }
328 
329 /*********************************************************************************************/
330 /*                            window mode parameters                                         */
331 /*********************************************************************************************/
332 bool g_nip_tcp_snd_win_enable;
333 module_param_named(nip_tcp_snd_win_enable, g_nip_tcp_snd_win_enable, bool, 0644);
334 
get_nip_tcp_snd_win_enable(void)335 bool get_nip_tcp_snd_win_enable(void)
336 {
337 	return g_nip_tcp_snd_win_enable;
338 }
339 
340 bool g_nip_tcp_rcv_win_enable = true;
341 module_param_named(nip_tcp_rcv_win_enable, g_nip_tcp_rcv_win_enable, bool, 0644);
342 
get_nip_tcp_rcv_win_enable(void)343 bool get_nip_tcp_rcv_win_enable(void)
344 {
345 	return g_nip_tcp_rcv_win_enable;
346 }
347 
348 /*********************************************************************************************/
349 /*                            nip debug parameters                                           */
350 /*********************************************************************************************/
351 /* Debugging for control DEBUG */
352 bool g_nip_debug;
353 module_param_named(nip_debug, g_nip_debug, bool, 0644);
354 
get_nip_debug(void)355 bool get_nip_debug(void)
356 {
357 	return g_nip_debug;
358 }
359 
360 /* Debugging of threshold change */
361 bool g_rtt_ssthresh_debug;
362 module_param_named(rtt_ssthresh_debug, g_rtt_ssthresh_debug, bool, 0644);
363 
get_rtt_ssthresh_debug(void)364 bool get_rtt_ssthresh_debug(void)
365 {
366 	return g_rtt_ssthresh_debug;
367 }
368 
369 /* Debugging of packet retransmission after ACK */
370 bool g_ack_retrans_debug;
371 module_param_named(ack_retrans_debug, g_ack_retrans_debug, bool, 0644);
372 
get_ack_retrans_debug(void)373 bool get_ack_retrans_debug(void)
374 {
375 	return g_ack_retrans_debug;
376 }
377 
378