Whamcloud - gitweb
ef42ffec40c22b96e945ee3bd3165445cf78943f
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd_modparams.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2006 Cluster File Systems, Inc.
5  *   Author: Eric Barton <eric@bartonsoftware.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org.
8  *
9  *   Lustre is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Lustre is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Lustre; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include "o2iblnd.h"
25
26 static int service = 987;
27 CFS_MODULE_PARM(service, "i", int, 0444,
28                 "service number (within RDMA_PS_TCP)");
29
30 static int cksum = 0;
31 CFS_MODULE_PARM(cksum, "i", int, 0644,
32                 "set non-zero to enable message (not RDMA) checksums");
33
34 static int timeout = 50;
35 CFS_MODULE_PARM(timeout, "i", int, 0644,
36                 "timeout (seconds)");
37
38 static int ntx = 256;
39 CFS_MODULE_PARM(ntx, "i", int, 0444,
40                 "# of message descriptors");
41
42 static int credits = 64;
43 CFS_MODULE_PARM(credits, "i", int, 0444,
44                 "# concurrent sends");
45
46 static int peer_credits = 8;
47 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
48                 "# concurrent sends to 1 peer");
49
50 static char *ipif_name = "ib0";
51 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
52                 "IPoIB interface name");
53
54 static int retry_count = 5;
55 CFS_MODULE_PARM(retry_count, "i", int, 0644,
56                 "Retransmissions when no ACK received");
57
58 static int rnr_retry_count = 6;
59 CFS_MODULE_PARM(rnr_retry_count, "i", int, 0644,
60                 "RNR retransmissions");
61
62 static int keepalive = 100;
63 CFS_MODULE_PARM(keepalive, "i", int, 0644,
64                 "Idle time in seconds before sending a keepalive");
65
66 static int ib_mtu = 0;
67 CFS_MODULE_PARM(ib_mtu, "i", int, 0444,
68                 "IB MTU 256/512/1024/2048/4096");
69
70 #if IBLND_MAP_ON_DEMAND
71 static int concurrent_sends = IBLND_RX_MSGS;
72 #else
73 static int concurrent_sends = IBLND_MSG_QUEUE_SIZE;
74 #endif
75 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
76                 "send work-queue sizing");
77
78 #if IBLND_MAP_ON_DEMAND
79 static int fmr_pool_size = 512;
80 CFS_MODULE_PARM(fmr_pool_size, "i", int, 0444,
81                 "size of the fmr pool (>= ntx)");
82
83 static int fmr_flush_trigger = 384;
84 CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
85                 "# dirty FMRs that triggers pool flush");
86
87 static int fmr_cache = 1;
88 CFS_MODULE_PARM(fmr_cache, "i", int, 0444,
89                 "non-zero to enable FMR caching");
90 #endif
91
92 kib_tunables_t kiblnd_tunables = {
93         .kib_service                = &service,
94         .kib_cksum                  = &cksum,
95         .kib_timeout                = &timeout,
96         .kib_keepalive              = &keepalive,
97         .kib_ntx                    = &ntx,
98         .kib_credits                = &credits,
99         .kib_peercredits            = &peer_credits,
100         .kib_default_ipif           = &ipif_name,
101         .kib_retry_count            = &retry_count,
102         .kib_rnr_retry_count        = &rnr_retry_count,
103         .kib_concurrent_sends       = &concurrent_sends,
104         .kib_ib_mtu                 = &ib_mtu,
105 #if IBLND_MAP_ON_DEMAND
106         .kib_fmr_pool_size          = &fmr_pool_size,
107         .kib_fmr_flush_trigger      = &fmr_flush_trigger,
108         .kib_fmr_cache              = &fmr_cache,
109 #endif
110 };
111
112 #if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM
113
114 static char ipif_basename_space[32];
115
116 static ctl_table kiblnd_ctl_table[] = {
117         {1, "service", &service, 
118          sizeof(int), 0444, NULL, &proc_dointvec},
119         {2, "cksum", &cksum, 
120          sizeof(int), 0644, NULL, &proc_dointvec},
121         {3, "timeout", &timeout, 
122          sizeof(int), 0644, NULL, &proc_dointvec},
123         {4, "ntx", &ntx, 
124          sizeof(int), 0444, NULL, &proc_dointvec},
125         {5, "credits", &credits, 
126          sizeof(int), 0444, NULL, &proc_dointvec},
127         {6, "peer_credits", &peer_credits, 
128          sizeof(int), 0444, NULL, &proc_dointvec},
129         {7, "ipif_name", ipif_basename_space, 
130          sizeof(ipif_basename_space), 0444, NULL, &proc_dostring},
131         {8, "retry_count", &retry_count, 
132          sizeof(int), 0644, NULL, &proc_dointvec},
133         {9, "rnr_retry_count", &rnr_retry_count, 
134          sizeof(int), 0644, NULL, &proc_dointvec},
135         {10, "keepalive", &keepalive, 
136          sizeof(int), 0644, NULL, &proc_dointvec},
137         {11, "concurrent_sends", &concurrent_sends, 
138          sizeof(int), 0644, NULL, &proc_dointvec},
139         {12, "ib_mtu", &ib_mtu, 
140          sizeof(int), 0444, NULL, &proc_dointvec},
141 #if IBLND_MAP_ON_DEMAND
142         {12, "fmr_pool_size", &fmr_pool_size, 
143          sizeof(int), 0444, NULL, &proc_dointvec},
144         {13, "fmr_flush_trigger", &fmr_flush_trigger, 
145          sizeof(int), 0444, NULL, &proc_dointvec},
146         {14, "fmr_cache", &fmr_cache, 
147          sizeof(int), 0444, NULL, &proc_dointvec},
148 #endif
149         {0}
150 };
151
152 static ctl_table kiblnd_top_ctl_table[] = {
153         {203, "o2iblnd", NULL, 0, 0555, kiblnd_ctl_table},
154         {0}
155 };
156
157 void
158 kiblnd_initstrtunable(char *space, char *str, int size)
159 {
160         strncpy(space, str, size);
161         space[size-1] = 0;
162 }
163
164 void
165 kiblnd_sysctl_init (void)
166 {
167         kiblnd_initstrtunable(ipif_basename_space, ipif_name,
168                               sizeof(ipif_basename_space));
169
170         kiblnd_tunables.kib_sysctl =
171                 register_sysctl_table(kiblnd_top_ctl_table, 0);
172
173         if (kiblnd_tunables.kib_sysctl == NULL)
174                 CWARN("Can't setup /proc tunables\n");
175 }
176
177 void
178 kiblnd_sysctl_fini (void)
179 {
180         if (kiblnd_tunables.kib_sysctl != NULL)
181                 unregister_sysctl_table(kiblnd_tunables.kib_sysctl);
182 }
183
184 #else
185
186 void
187 kiblnd_sysctl_init (void)
188 {
189 }
190
191 void
192 kiblnd_sysctl_fini (void)
193 {
194 }
195
196 #endif
197
198 int
199 kiblnd_tunables_init (void)
200 {
201         kiblnd_sysctl_init();
202         
203         if (*kiblnd_tunables.kib_concurrent_sends > IBLND_RX_MSGS)
204                 *kiblnd_tunables.kib_concurrent_sends = IBLND_RX_MSGS;
205         if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE)
206                 *kiblnd_tunables.kib_concurrent_sends = IBLND_MSG_QUEUE_SIZE;
207
208         return 0;
209 }
210
211 void
212 kiblnd_tunables_fini (void)
213 {
214         kiblnd_sysctl_fini();
215 }
216
217
218