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