2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2011, 2012, Intel Corporation.
6 * Author: Eric Barton <eric@bartonsoftware.com>
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.
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.
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.
24 static int sock_timeout = 50;
25 module_param(sock_timeout, int, 0644);
26 MODULE_PARM_DESC(sock_timeout, "dead socket timeout (seconds)");
28 static int credits = 256;
29 module_param(credits, int, 0444);
30 MODULE_PARM_DESC(credits, "# concurrent sends");
32 static int peer_credits = 8;
33 module_param(peer_credits, int, 0444);
34 MODULE_PARM_DESC(peer_credits, "# concurrent sends to 1 peer");
36 static int peer_buffer_credits;
37 module_param(peer_buffer_credits, int, 0444);
38 MODULE_PARM_DESC(peer_buffer_credits, "# per-peer router buffer credits");
40 static int peer_timeout = DEFAULT_PEER_TIMEOUT;
41 module_param(peer_timeout, int, 0444);
42 MODULE_PARM_DESC(peer_timeout, "Seconds without aliveness news to declare peer dead (<=0 to disable)");
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 module_param(nscheds, int, 0444);
48 MODULE_PARM_DESC(nscheds, "# scheduler daemons in each pool while starting");
50 static int nconnds = 4;
51 module_param(nconnds, int, 0444);
52 MODULE_PARM_DESC(nconnds, "# connection daemons while starting");
54 static int nconnds_max = 64;
55 module_param(nconnds_max, int, 0444);
56 MODULE_PARM_DESC(nconnds_max, "max # connection daemons");
58 static int min_reconnectms = 1000;
59 module_param(min_reconnectms, int, 0644);
60 MODULE_PARM_DESC(min_reconnectms, "min connection retry interval (mS)");
62 static int max_reconnectms = 60000;
63 module_param(max_reconnectms, int, 0644);
64 MODULE_PARM_DESC(max_reconnectms, "max connection retry interval (mS)");
67 module_param(eager_ack, int, 0644);
68 MODULE_PARM_DESC(eager_ack, "send tcp ack packets eagerly");
70 static int typed_conns = 1;
71 module_param(typed_conns, int, 0444);
72 MODULE_PARM_DESC(typed_conns, "use different sockets for bulk");
74 static int min_bulk = (1<<10);
75 module_param(min_bulk, int, 0644);
76 MODULE_PARM_DESC(min_bulk, "smallest 'large' message");
78 # define DEFAULT_BUFFER_SIZE 0
79 static int tx_buffer_size = DEFAULT_BUFFER_SIZE;
80 module_param(tx_buffer_size, int, 0644);
81 MODULE_PARM_DESC(tx_buffer_size, "socket tx buffer size (0 for system default)");
83 static int rx_buffer_size = DEFAULT_BUFFER_SIZE;
84 module_param(rx_buffer_size, int, 0644);
85 MODULE_PARM_DESC(rx_buffer_size, "socket rx buffer size (0 for system default)");
88 module_param(nagle, int, 0644);
89 MODULE_PARM_DESC(nagle, "enable NAGLE?");
91 static int round_robin = 1;
92 module_param(round_robin, int, 0644);
93 MODULE_PARM_DESC(round_robin, "Round robin for multiple interfaces");
95 static int keepalive = 30;
96 module_param(keepalive, int, 0644);
97 MODULE_PARM_DESC(keepalive, "# seconds before send keepalive");
99 static int keepalive_idle = 30;
100 module_param(keepalive_idle, int, 0644);
101 MODULE_PARM_DESC(keepalive_idle, "# idle seconds before probe");
103 #define DEFAULT_KEEPALIVE_COUNT 5
104 static int keepalive_count = DEFAULT_KEEPALIVE_COUNT;
105 module_param(keepalive_count, int, 0644);
106 MODULE_PARM_DESC(keepalive_count, "# missed probes == dead");
108 static int keepalive_intvl = 5;
109 module_param(keepalive_intvl, int, 0644);
110 MODULE_PARM_DESC(keepalive_intvl, "seconds between probes");
112 static int enable_csum = 0;
113 module_param(enable_csum, int, 0644);
114 MODULE_PARM_DESC(enable_csum, "enable check sum");
116 static int inject_csum_error = 0;
117 module_param(inject_csum_error, int, 0644);
118 MODULE_PARM_DESC(inject_csum_error, "set non-zero to inject a checksum error");
120 static int enable_irq_affinity = 0;
121 module_param(enable_irq_affinity, int, 0644);
122 MODULE_PARM_DESC(enable_irq_affinity, "enable IRQ affinity");
124 static int nonblk_zcack = 1;
125 module_param(nonblk_zcack, int, 0644);
126 MODULE_PARM_DESC(nonblk_zcack, "always send ZC-ACK on non-blocking connection");
128 static unsigned int zc_min_payload = (16 << 10);
129 module_param(zc_min_payload, int, 0644);
130 MODULE_PARM_DESC(zc_min_payload, "minimum payload size to zero copy");
132 static unsigned int zc_recv = 0;
133 module_param(zc_recv, int, 0644);
134 MODULE_PARM_DESC(zc_recv, "enable ZC recv for Chelsio driver");
136 static unsigned int zc_recv_min_nfrags = 16;
137 module_param(zc_recv_min_nfrags, int, 0644);
138 MODULE_PARM_DESC(zc_recv_min_nfrags, "minimum # of fragments to enable ZC recv");
140 #ifdef SOCKNAL_BACKOFF
141 static int backoff_init = 3;
142 module_param(backoff_init, int, 0644);
143 MODULE_PARM_DESC(backoff_init, "seconds for initial tcp backoff");
145 static int backoff_max = 3;
146 module_param(backoff_max, int, 0644);
147 MODULE_PARM_DESC(backoff_max, "seconds for maximum tcp backoff");
150 #if SOCKNAL_VERSION_DEBUG
151 static int protocol = 3;
152 module_param(protocol, int, 0644);
153 MODULE_PARM_DESC(protocol, "protocol version");
156 struct ksock_tunables ksocknal_tunables;
158 int ksocknal_tunables_init(void)
161 /* initialize ksocknal_tunables structure */
162 ksocknal_tunables.ksnd_timeout = &sock_timeout;
163 ksocknal_tunables.ksnd_nscheds = &nscheds;
164 ksocknal_tunables.ksnd_nconnds = &nconnds;
165 ksocknal_tunables.ksnd_nconnds_max = &nconnds_max;
166 ksocknal_tunables.ksnd_min_reconnectms = &min_reconnectms;
167 ksocknal_tunables.ksnd_max_reconnectms = &max_reconnectms;
168 ksocknal_tunables.ksnd_eager_ack = &eager_ack;
169 ksocknal_tunables.ksnd_typed_conns = &typed_conns;
170 ksocknal_tunables.ksnd_min_bulk = &min_bulk;
171 ksocknal_tunables.ksnd_tx_buffer_size = &tx_buffer_size;
172 ksocknal_tunables.ksnd_rx_buffer_size = &rx_buffer_size;
173 ksocknal_tunables.ksnd_nagle = &nagle;
174 ksocknal_tunables.ksnd_round_robin = &round_robin;
175 ksocknal_tunables.ksnd_keepalive = &keepalive;
176 ksocknal_tunables.ksnd_keepalive_idle = &keepalive_idle;
177 ksocknal_tunables.ksnd_keepalive_count = &keepalive_count;
178 ksocknal_tunables.ksnd_keepalive_intvl = &keepalive_intvl;
179 ksocknal_tunables.ksnd_credits = &credits;
180 ksocknal_tunables.ksnd_peertxcredits = &peer_credits;
181 ksocknal_tunables.ksnd_peerrtrcredits = &peer_buffer_credits;
182 ksocknal_tunables.ksnd_peertimeout = &peer_timeout;
183 ksocknal_tunables.ksnd_enable_csum = &enable_csum;
184 ksocknal_tunables.ksnd_inject_csum_error = &inject_csum_error;
185 ksocknal_tunables.ksnd_nonblk_zcack = &nonblk_zcack;
186 ksocknal_tunables.ksnd_zc_min_payload = &zc_min_payload;
187 ksocknal_tunables.ksnd_zc_recv = &zc_recv;
188 ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
190 if (enable_irq_affinity) {
191 CWARN("irq_affinity is removed from socklnd because modern "
192 "computer always has fast CPUs and more cores than "
193 "# NICs, although you still can set irq_affinity by "
194 "another way, please check manual for details.\n");
196 ksocknal_tunables.ksnd_irq_affinity = &enable_irq_affinity;
198 #ifdef SOCKNAL_BACKOFF
199 ksocknal_tunables.ksnd_backoff_init = &backoff_init;
200 ksocknal_tunables.ksnd_backoff_max = &backoff_max;
203 #if SOCKNAL_VERSION_DEBUG
204 ksocknal_tunables.ksnd_protocol = &protocol;
207 if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
208 *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10);