Whamcloud - gitweb
Branch HEAD
[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  2008 Sun Microsystems, Inc. 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 nconnds = 4;
37 CFS_MODULE_PARM(nconnds, "i", int, 0444,
38                 "# connection daemons");
39
40 static int min_reconnectms = 1000;
41 CFS_MODULE_PARM(min_reconnectms, "i", int, 0644,
42                 "min connection retry interval (mS)");
43
44 static int max_reconnectms = 60000;
45 CFS_MODULE_PARM(max_reconnectms, "i", int, 0644,
46                 "max connection retry interval (mS)");
47
48 #if defined(__APPLE__) && !defined(__DARWIN8__)
49 # define DEFAULT_EAGER_ACK 1
50 #else
51 # define DEFAULT_EAGER_ACK 0
52 #endif
53 static int eager_ack = DEFAULT_EAGER_ACK;
54 CFS_MODULE_PARM(eager_ack, "i", int, 0644,
55                 "send tcp ack packets eagerly");
56
57 static int typed_conns = 1;
58 CFS_MODULE_PARM(typed_conns, "i", int, 0444,
59                 "use different sockets for bulk");
60
61 static int min_bulk = (1<<10);
62 CFS_MODULE_PARM(min_bulk, "i", int, 0644,
63                 "smallest 'large' message");
64
65 #ifdef __APPLE__
66 # ifdef __DARWIN8__
67 #  define DEFAULT_BUFFER_SIZE (224*1024)
68 # else
69 #  define DEFAULT_BUFFER_SIZE (1152 * 1024)
70 # endif
71 #else
72 # define DEFAULT_BUFFER_SIZE 0
73 #endif
74 static int tx_buffer_size = DEFAULT_BUFFER_SIZE;
75 CFS_MODULE_PARM(tx_buffer_size, "i", int, 0644,
76                 "socket tx buffer size (0 for system default)");
77
78 static int rx_buffer_size = DEFAULT_BUFFER_SIZE;
79 CFS_MODULE_PARM(rx_buffer_size, "i", int, 0644,
80                 "socket rx buffer size (0 for system default)");
81
82 static int nagle = 0;
83 CFS_MODULE_PARM(nagle, "i", int, 0644,
84                 "enable NAGLE?");
85
86 static int keepalive_idle = 30;
87 CFS_MODULE_PARM(keepalive_idle, "i", int, 0644,
88                 "# idle seconds before probe");
89
90 #ifdef HAVE_BGL_SUPPORT
91 #define DEFAULT_KEEPALIVE_COUNT  100
92 #else
93 #define DEFAULT_KEEPALIVE_COUNT  5
94 #endif
95 static int keepalive_count = DEFAULT_KEEPALIVE_COUNT;
96 CFS_MODULE_PARM(keepalive_count, "i", int, 0644,
97                 "# missed probes == dead");
98
99 static int keepalive_intvl = 5;
100 CFS_MODULE_PARM(keepalive_intvl, "i", int, 0644,
101                 "seconds between probes");
102
103 static int enable_csum = 0;
104 CFS_MODULE_PARM(enable_csum, "i", int, 0644,
105                 "enable check sum");
106
107 static int inject_csum_error = 0;
108 CFS_MODULE_PARM(inject_csum_error, "i", int, 0644,
109                 "set non-zero to inject a checksum error");
110 #ifdef CPU_AFFINITY
111 static int enable_irq_affinity = 0;
112 CFS_MODULE_PARM(enable_irq_affinity, "i", int, 0644,
113                 "enable IRQ affinity");
114 #endif
115
116 static unsigned int zc_min_frag = (2<<10);
117 CFS_MODULE_PARM(zc_min_frag, "i", int, 0644,
118                 "minimum fragment to zero copy");
119
120 static unsigned int zc_recv = 0;
121 CFS_MODULE_PARM(zc_recv, "i", int, 0444,
122                 "enable ZC recv for Chelsio driver");
123
124 static unsigned int zc_recv_min_nfrags = 16;
125 CFS_MODULE_PARM(zc_recv_min_nfrags, "i", int, 0444,
126                 "minimum # of fragments to enable ZC recv");
127
128 #ifdef SOCKNAL_BACKOFF
129 static int backoff_init = 3;
130 CFS_MODULE_PARM(backoff_init, "i", int, 0644,
131                 "seconds for initial tcp backoff");
132
133 static int backoff_max = 3;
134 CFS_MODULE_PARM(backoff_max, "i", int, 0644,
135                 "seconds for maximum tcp backoff");
136 #endif
137
138 #if SOCKNAL_VERSION_DEBUG
139 static int protocol = 2;
140 CFS_MODULE_PARM(protocol, "i", int, 0644,
141                 "protocol version");
142 #endif
143
144 ksock_tunables_t ksocknal_tunables;
145
146 int ksocknal_tunables_init(void)
147 {
148
149         /* initialize ksocknal_tunables structure */
150         ksocknal_tunables.ksnd_timeout            = &sock_timeout;
151         ksocknal_tunables.ksnd_nconnds            = &nconnds;
152         ksocknal_tunables.ksnd_min_reconnectms    = &min_reconnectms;
153         ksocknal_tunables.ksnd_max_reconnectms    = &max_reconnectms;
154         ksocknal_tunables.ksnd_eager_ack          = &eager_ack;
155         ksocknal_tunables.ksnd_typed_conns        = &typed_conns;
156         ksocknal_tunables.ksnd_min_bulk           = &min_bulk;
157         ksocknal_tunables.ksnd_tx_buffer_size     = &tx_buffer_size;
158         ksocknal_tunables.ksnd_rx_buffer_size     = &rx_buffer_size;
159         ksocknal_tunables.ksnd_nagle              = &nagle;
160         ksocknal_tunables.ksnd_keepalive_idle     = &keepalive_idle;
161         ksocknal_tunables.ksnd_keepalive_count    = &keepalive_count;
162         ksocknal_tunables.ksnd_keepalive_intvl    = &keepalive_intvl;
163         ksocknal_tunables.ksnd_credits            = &credits;
164         ksocknal_tunables.ksnd_peercredits        = &peer_credits;
165         ksocknal_tunables.ksnd_enable_csum        = &enable_csum;
166         ksocknal_tunables.ksnd_inject_csum_error  = &inject_csum_error;
167         ksocknal_tunables.ksnd_zc_min_frag        = &zc_min_frag;
168         ksocknal_tunables.ksnd_zc_recv            = &zc_recv;
169         ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
170
171
172 #ifdef CPU_AFFINITY
173         ksocknal_tunables.ksnd_irq_affinity       = &enable_irq_affinity;
174 #endif
175
176 #ifdef SOCKNAL_BACKOFF
177         ksocknal_tunables.ksnd_backoff_init       = &backoff_init;
178         ksocknal_tunables.ksnd_backoff_max        = &backoff_max;
179 #endif
180
181 #if SOCKNAL_VERSION_DEBUG
182         ksocknal_tunables.ksnd_protocol           = &protocol;
183 #endif
184
185 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
186         ksocknal_tunables.ksnd_sysctl             =  NULL;
187 #endif
188
189         /* initialize platform-sepcific tunables */
190         return ksocknal_lib_tunables_init();
191 };
192
193 void ksocknal_tunables_fini(void)
194 {
195         ksocknal_lib_tunables_fini();
196 }