Linux 3.13-rc1
[linux-2.6-microblaze.git] / drivers / staging / lustre / lnet / klnds / socklnd / socklnd_modparams.c
1 /*
2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3  *
4  * Copyright (c) 2011, 2012, Intel Corporation.
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 /* Number of daemons in each thread pool which is percpt,
45  * we will estimate reasonable value based on CPUs if it's not set. */
46 static unsigned int nscheds;
47 CFS_MODULE_PARM(nscheds, "i", int, 0444,
48                 "# scheduler daemons in each pool while starting");
49
50 static int nconnds = 4;
51 CFS_MODULE_PARM(nconnds, "i", int, 0444,
52                 "# connection daemons while starting");
53
54 static int nconnds_max = 64;
55 CFS_MODULE_PARM(nconnds_max, "i", int, 0444,
56                 "max # connection daemons");
57
58 static int min_reconnectms = 1000;
59 CFS_MODULE_PARM(min_reconnectms, "i", int, 0644,
60                 "min connection retry interval (mS)");
61
62 static int max_reconnectms = 60000;
63 CFS_MODULE_PARM(max_reconnectms, "i", int, 0644,
64                 "max connection retry interval (mS)");
65
66 # define DEFAULT_EAGER_ACK 0
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 # define DEFAULT_BUFFER_SIZE 0
80 static int tx_buffer_size = DEFAULT_BUFFER_SIZE;
81 CFS_MODULE_PARM(tx_buffer_size, "i", int, 0644,
82                 "socket tx buffer size (0 for system default)");
83
84 static int rx_buffer_size = DEFAULT_BUFFER_SIZE;
85 CFS_MODULE_PARM(rx_buffer_size, "i", int, 0644,
86                 "socket rx buffer size (0 for system default)");
87
88 static int nagle = 0;
89 CFS_MODULE_PARM(nagle, "i", int, 0644,
90                 "enable NAGLE?");
91
92 static int round_robin = 1;
93 CFS_MODULE_PARM(round_robin, "i", int, 0644,
94                 "Round robin for multiple interfaces");
95
96 static int keepalive = 30;
97 CFS_MODULE_PARM(keepalive, "i", int, 0644,
98                 "# seconds before send keepalive");
99
100 static int keepalive_idle = 30;
101 CFS_MODULE_PARM(keepalive_idle, "i", int, 0644,
102                 "# idle seconds before probe");
103
104 #define DEFAULT_KEEPALIVE_COUNT  5
105 static int keepalive_count = DEFAULT_KEEPALIVE_COUNT;
106 CFS_MODULE_PARM(keepalive_count, "i", int, 0644,
107                 "# missed probes == dead");
108
109 static int keepalive_intvl = 5;
110 CFS_MODULE_PARM(keepalive_intvl, "i", int, 0644,
111                 "seconds between probes");
112
113 static int enable_csum = 0;
114 CFS_MODULE_PARM(enable_csum, "i", int, 0644,
115                 "enable check sum");
116
117 static int inject_csum_error = 0;
118 CFS_MODULE_PARM(inject_csum_error, "i", int, 0644,
119                 "set non-zero to inject a checksum error");
120
121 static int nonblk_zcack = 1;
122 CFS_MODULE_PARM(nonblk_zcack, "i", int, 0644,
123                 "always send ZC-ACK on non-blocking connection");
124
125 static unsigned int zc_min_payload = (16 << 10);
126 CFS_MODULE_PARM(zc_min_payload, "i", int, 0644,
127                 "minimum payload size to zero copy");
128
129 static unsigned int zc_recv = 0;
130 CFS_MODULE_PARM(zc_recv, "i", int, 0644,
131                 "enable ZC recv for Chelsio driver");
132
133 static unsigned int zc_recv_min_nfrags = 16;
134 CFS_MODULE_PARM(zc_recv_min_nfrags, "i", int, 0644,
135                 "minimum # of fragments to enable ZC recv");
136
137
138 #if SOCKNAL_VERSION_DEBUG
139 static int protocol = 3;
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_nscheds            = &nscheds;
152         ksocknal_tunables.ksnd_nconnds      = &nconnds;
153         ksocknal_tunables.ksnd_nconnds_max      = &nconnds_max;
154         ksocknal_tunables.ksnd_min_reconnectms    = &min_reconnectms;
155         ksocknal_tunables.ksnd_max_reconnectms    = &max_reconnectms;
156         ksocknal_tunables.ksnd_eager_ack          = &eager_ack;
157         ksocknal_tunables.ksnd_typed_conns      = &typed_conns;
158         ksocknal_tunables.ksnd_min_bulk    = &min_bulk;
159         ksocknal_tunables.ksnd_tx_buffer_size     = &tx_buffer_size;
160         ksocknal_tunables.ksnd_rx_buffer_size     = &rx_buffer_size;
161         ksocknal_tunables.ksnd_nagle          = &nagle;
162         ksocknal_tunables.ksnd_round_robin      = &round_robin;
163         ksocknal_tunables.ksnd_keepalive          = &keepalive;
164         ksocknal_tunables.ksnd_keepalive_idle     = &keepalive_idle;
165         ksocknal_tunables.ksnd_keepalive_count    = &keepalive_count;
166         ksocknal_tunables.ksnd_keepalive_intvl    = &keepalive_intvl;
167         ksocknal_tunables.ksnd_credits      = &credits;
168         ksocknal_tunables.ksnd_peertxcredits      = &peer_credits;
169         ksocknal_tunables.ksnd_peerrtrcredits     = &peer_buffer_credits;
170         ksocknal_tunables.ksnd_peertimeout      = &peer_timeout;
171         ksocknal_tunables.ksnd_enable_csum      = &enable_csum;
172         ksocknal_tunables.ksnd_inject_csum_error  = &inject_csum_error;
173         ksocknal_tunables.ksnd_nonblk_zcack       = &nonblk_zcack;
174         ksocknal_tunables.ksnd_zc_min_payload     = &zc_min_payload;
175         ksocknal_tunables.ksnd_zc_recv      = &zc_recv;
176         ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
177
178
179
180 #if SOCKNAL_VERSION_DEBUG
181         ksocknal_tunables.ksnd_protocol    = &protocol;
182 #endif
183
184 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
185         ksocknal_tunables.ksnd_sysctl        =  NULL;
186 #endif
187
188         if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
189                 *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10);
190
191         /* initialize platform-sepcific tunables */
192         return ksocknal_lib_tunables_init();
193 };
194
195 void ksocknal_tunables_fini(void)
196 {
197         ksocknal_lib_tunables_fini();
198 }