Whamcloud - gitweb
0dd1544b70aa32f17aab27c239e69cc44a86fafb
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_modparams.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5  *
6  *   Author: Eric Barton <eric@bartonsoftware.com>
7  *
8  *   Portals is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Portals is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Portals; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include "socklnd.h"
23
24 static int sock_timeout = 50;
25 CFS_MODULE_PARM(sock_timeout, "i", int, 0644,
26                 "dead socket timeout (seconds)");
27
28 static int credits = 256;
29 CFS_MODULE_PARM(credits, "i", int, 0444,
30                 "# concurrent sends");
31
32 static int peer_credits = 8;
33 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
34                 "# concurrent sends to 1 peer");
35
36 static int peer_buffer_credits = 0;
37 CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
38                 "# per-peer router buffer credits");
39
40 static int peer_timeout = 180;
41 CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
42                 "Seconds without aliveness news to declare peer dead (<=0 to disable)");
43
44 static int nconnds = 4;
45 CFS_MODULE_PARM(nconnds, "i", int, 0444,
46                 "# connection daemons while starting");
47
48 static int nconnds_max = 64;
49 CFS_MODULE_PARM(nconnds_max, "i", int, 0444,
50                 "max # connection daemons");
51
52 static int min_reconnectms = 1000;
53 CFS_MODULE_PARM(min_reconnectms, "i", int, 0644,
54                 "min connection retry interval (mS)");
55
56 static int max_reconnectms = 60000;
57 CFS_MODULE_PARM(max_reconnectms, "i", int, 0644,
58                 "max connection retry interval (mS)");
59
60 #if defined(__APPLE__) && !defined(__DARWIN8__)
61 # define DEFAULT_EAGER_ACK 1
62 #else
63 # define DEFAULT_EAGER_ACK 0
64 #endif
65 static int eager_ack = DEFAULT_EAGER_ACK;
66 CFS_MODULE_PARM(eager_ack, "i", int, 0644,
67                 "send tcp ack packets eagerly");
68
69 static int typed_conns = 1;
70 CFS_MODULE_PARM(typed_conns, "i", int, 0444,
71                 "use different sockets for bulk");
72
73 static int min_bulk = (1<<10);
74 CFS_MODULE_PARM(min_bulk, "i", int, 0644,
75                 "smallest 'large' message");
76
77 #ifdef __APPLE__
78 # ifdef __DARWIN8__
79 #  define DEFAULT_BUFFER_SIZE (224*1024)
80 # else
81 #  define DEFAULT_BUFFER_SIZE (1152 * 1024)
82 # endif
83 #else
84 # define DEFAULT_BUFFER_SIZE 0
85 #endif
86 static int tx_buffer_size = DEFAULT_BUFFER_SIZE;
87 CFS_MODULE_PARM(tx_buffer_size, "i", int, 0644,
88                 "socket tx buffer size (0 for system default)");
89
90 static int rx_buffer_size = DEFAULT_BUFFER_SIZE;
91 CFS_MODULE_PARM(rx_buffer_size, "i", int, 0644,
92                 "socket rx buffer size (0 for system default)");
93
94 static int nagle = 0;
95 CFS_MODULE_PARM(nagle, "i", int, 0644,
96                 "enable NAGLE?");
97
98 static int round_robin = 1;
99 CFS_MODULE_PARM(round_robin, "i", int, 0644,
100                 "Round robin for multiple interfaces");
101
102 static int keepalive = 30;
103 CFS_MODULE_PARM(keepalive, "i", int, 0644,
104                 "# seconds before send keepalive");
105
106 static int keepalive_idle = 30;
107 CFS_MODULE_PARM(keepalive_idle, "i", int, 0644,
108                 "# idle seconds before probe");
109
110 #ifdef HAVE_BGL_SUPPORT
111 #define DEFAULT_KEEPALIVE_COUNT  100
112 #else
113 #define DEFAULT_KEEPALIVE_COUNT  5
114 #endif
115 static int keepalive_count = DEFAULT_KEEPALIVE_COUNT;
116 CFS_MODULE_PARM(keepalive_count, "i", int, 0644,
117                 "# missed probes == dead");
118
119 static int keepalive_intvl = 5;
120 CFS_MODULE_PARM(keepalive_intvl, "i", int, 0644,
121                 "seconds between probes");
122
123 static int enable_csum = 0;
124 CFS_MODULE_PARM(enable_csum, "i", int, 0644,
125                 "enable check sum");
126
127 static int inject_csum_error = 0;
128 CFS_MODULE_PARM(inject_csum_error, "i", int, 0644,
129                 "set non-zero to inject a checksum error");
130 #ifdef CPU_AFFINITY
131 static int enable_irq_affinity = 0;
132 CFS_MODULE_PARM(enable_irq_affinity, "i", int, 0644,
133                 "enable IRQ affinity");
134 #endif
135
136 static int nonblk_zcack = 1;
137 CFS_MODULE_PARM(nonblk_zcack, "i", int, 0644,
138                 "always send ZC-ACK on non-blocking connection");
139
140 static unsigned int zc_min_payload = (16 << 10);
141 CFS_MODULE_PARM(zc_min_payload, "i", int, 0644,
142                 "minimum payload size to zero copy");
143
144 static unsigned int zc_recv = 0;
145 CFS_MODULE_PARM(zc_recv, "i", int, 0644,
146                 "enable ZC recv for Chelsio driver");
147
148 static unsigned int zc_recv_min_nfrags = 16;
149 CFS_MODULE_PARM(zc_recv_min_nfrags, "i", int, 0644,
150                 "minimum # of fragments to enable ZC recv");
151
152 #ifdef SOCKNAL_BACKOFF
153 static int backoff_init = 3;
154 CFS_MODULE_PARM(backoff_init, "i", int, 0644,
155                 "seconds for initial tcp backoff");
156
157 static int backoff_max = 3;
158 CFS_MODULE_PARM(backoff_max, "i", int, 0644,
159                 "seconds for maximum tcp backoff");
160 #endif
161
162 #if SOCKNAL_VERSION_DEBUG
163 static int protocol = 3;
164 CFS_MODULE_PARM(protocol, "i", int, 0644,
165                 "protocol version");
166 #endif
167
168 ksock_tunables_t ksocknal_tunables;
169
170 int ksocknal_tunables_init(void)
171 {
172
173         /* initialize ksocknal_tunables structure */
174         ksocknal_tunables.ksnd_timeout            = &sock_timeout;
175         ksocknal_tunables.ksnd_nconnds            = &nconnds;
176         ksocknal_tunables.ksnd_nconnds_max        = &nconnds_max;
177         ksocknal_tunables.ksnd_min_reconnectms    = &min_reconnectms;
178         ksocknal_tunables.ksnd_max_reconnectms    = &max_reconnectms;
179         ksocknal_tunables.ksnd_eager_ack          = &eager_ack;
180         ksocknal_tunables.ksnd_typed_conns        = &typed_conns;
181         ksocknal_tunables.ksnd_min_bulk           = &min_bulk;
182         ksocknal_tunables.ksnd_tx_buffer_size     = &tx_buffer_size;
183         ksocknal_tunables.ksnd_rx_buffer_size     = &rx_buffer_size;
184         ksocknal_tunables.ksnd_nagle              = &nagle;
185         ksocknal_tunables.ksnd_round_robin        = &round_robin;
186         ksocknal_tunables.ksnd_keepalive          = &keepalive;
187         ksocknal_tunables.ksnd_keepalive_idle     = &keepalive_idle;
188         ksocknal_tunables.ksnd_keepalive_count    = &keepalive_count;
189         ksocknal_tunables.ksnd_keepalive_intvl    = &keepalive_intvl;
190         ksocknal_tunables.ksnd_credits            = &credits;
191         ksocknal_tunables.ksnd_peertxcredits      = &peer_credits;
192         ksocknal_tunables.ksnd_peerrtrcredits     = &peer_buffer_credits;
193         ksocknal_tunables.ksnd_peertimeout        = &peer_timeout;
194         ksocknal_tunables.ksnd_enable_csum        = &enable_csum;
195         ksocknal_tunables.ksnd_inject_csum_error  = &inject_csum_error;
196         ksocknal_tunables.ksnd_nonblk_zcack       = &nonblk_zcack;
197         ksocknal_tunables.ksnd_zc_min_payload     = &zc_min_payload;
198         ksocknal_tunables.ksnd_zc_recv            = &zc_recv;
199         ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
200
201 #ifdef CPU_AFFINITY
202         ksocknal_tunables.ksnd_irq_affinity       = &enable_irq_affinity;
203 #endif
204
205 #ifdef SOCKNAL_BACKOFF
206         ksocknal_tunables.ksnd_backoff_init       = &backoff_init;
207         ksocknal_tunables.ksnd_backoff_max        = &backoff_max;
208 #endif
209
210 #if SOCKNAL_VERSION_DEBUG
211         ksocknal_tunables.ksnd_protocol           = &protocol;
212 #endif
213
214 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
215         ksocknal_tunables.ksnd_sysctl             =  NULL;
216 #endif
217
218         if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
219                 *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10);
220
221         /* initialize platform-sepcific tunables */
222         return ksocknal_lib_tunables_init();
223 };
224
225 void ksocknal_tunables_fini(void)
226 {
227         ksocknal_lib_tunables_fini();
228 }