Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / klnds / qswlnd / qswlnd_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  * This file is part of Portals, http://www.lustre.org
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
25 #include "qswlnd.h"
26
27 static int tx_maxcontig = (1<<10);
28 CFS_MODULE_PARM(tx_maxcontig, "i", int, 0444,
29                 "maximum payload to de-fragment");
30
31 static int ntxmsgs = 512;
32 CFS_MODULE_PARM(ntxmsgs, "i", int, 0444,
33                 "# tx msg buffers");
34
35 static int credits = 128;
36 CFS_MODULE_PARM(credits, "i", int, 0444,
37                 "# concurrent sends");
38
39 static int peer_credits = 8;
40 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
41                 "# per-peer concurrent sends");
42
43 static int nrxmsgs_large = 64;
44 CFS_MODULE_PARM(nrxmsgs_large, "i", int, 0444,
45                 "# 'large' rx msg buffers");
46
47 static int ep_envelopes_large = 256;
48 CFS_MODULE_PARM(ep_envelopes_large, "i", int, 0444,
49                 "# 'large' rx msg envelope buffers");
50
51 static int nrxmsgs_small = 256;
52 CFS_MODULE_PARM(nrxmsgs_small, "i", int, 0444,
53                 "# 'small' rx msg buffers");
54
55 static int ep_envelopes_small = 2048;
56 CFS_MODULE_PARM(ep_envelopes_small, "i", int, 0444,
57                 "# 'small' rx msg envelope buffers");
58
59 static int optimized_puts = (32<<10);
60 CFS_MODULE_PARM(optimized_puts, "i", int, 0644,
61                 "zero-copy puts >= this size");
62
63 static int optimized_gets = 2048;
64 CFS_MODULE_PARM(optimized_gets, "i", int, 0644,
65                 "zero-copy gets >= this size");
66
67 #if KQSW_CKSUM
68 static int inject_csum_error = 0;
69 CFS_MODULE_PARM(inject_csum_error, "i", int, 0644,
70                 "test checksumming");
71 #endif
72
73 kqswnal_tunables_t kqswnal_tunables = {
74         .kqn_tx_maxcontig       = &tx_maxcontig,
75         .kqn_ntxmsgs            = &ntxmsgs,
76         .kqn_credits            = &credits,
77         .kqn_peercredits        = &peer_credits,
78         .kqn_nrxmsgs_large      = &nrxmsgs_large,
79         .kqn_ep_envelopes_large = &ep_envelopes_large,
80         .kqn_nrxmsgs_small      = &nrxmsgs_small,
81         .kqn_ep_envelopes_small = &ep_envelopes_small,
82         .kqn_optimized_puts     = &optimized_puts,
83         .kqn_optimized_gets     = &optimized_gets,
84 #if KQSW_CKSUM
85         .kqn_inject_csum_error  = &inject_csum_error,
86 #endif
87 };
88
89 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
90
91 #ifndef HAVE_SYSCTL_UNNUMBERED
92
93 enum
94         KQSWNAL_TX_MAXCONTIG = 1,
95         KQSWNAL_NTXMSG,
96         KQSWNAL_CREDITS,
97         KQSWNAL_PEERCREDITS,
98         KQSWNAL_NRXMSGS_LARGE,
99         KQSWNAL_EP_ENVELOPES_LARGE,
100         KQSWNAL_NRXMSGS_SMALL,
101         KQSWNAL_EP_ENVELOPES_SMALL,
102         KQSWNAL_OPTIMIZED_PUTS,
103         KQSWNAL_OPTIMIZED_GETS,
104         KQSWNAL_INJECT_CSUM_ERROR
105 };
106 #else
107
108 #define KQSWNAL_TX_MAXCONTIG    CTL_UNNUMBERED
109 #define KQSWNAL_NTXMSG          CTL_UNNUMBERED
110 #define KQSWNAL_CREDITS         CTL_UNNUMBERED
111 #define KQSWNAL_PEERCREDITS     CTL_UNNUMBERED
112 #define KQSWNAL_NRXMSGS_LARGE   CTL_UNNUMBERED
113 #define KQSWNAL_EP_ENVELOPES_LARGE CTL_UNNUMBERED
114 #define KQSWNAL_NRXMSGS_SMALL   CTL_UNNUMBERED
115 #define KQSWNAL_EP_ENVELOPES_SMALL CTL_UNNUMBERED
116 #define KQSWNAL_OPTIMIZED_PUTS  CTL_UNNUMBERED
117 #define KQSWNAL_OPTIMIZED_GETS  CTL_UNNUMBERED
118 #define KQSWNAL_INJECT_CSUM_ERROR CTL_UNNUMBERED
119
120 #endif
121
122 static cfs_sysctl_table_t kqswnal_ctl_table[] = {
123         {
124                 .ctl_name = KQSWNAL_TX_MAXCONTIG,
125                 .procname = "tx_maxcontig",
126                 .data     = &tx_maxcontig,
127                 .maxlen   = sizeof (int),
128                 .mode     = 0444,
129                 .proc_handler = &proc_dointvec
130         },
131         {
132                 .ctl_name = KQSWNAL_NTXMSG,
133                 .procname = "ntxmsgs",
134                 .data     = &ntxmsgs,
135                 .maxlen   = sizeof (int),
136                 .mode     = 0444,
137                 .proc_handler = &proc_dointvec
138         },
139         {
140                 .ctl_name = KQSWNAL_CREDITS,
141                 .procname = "credits",
142                 .data     = &credits,
143                 .maxlen   = sizeof (int),
144                 .mode     = 0444,
145                 .proc_handler = &proc_dointvec
146         },
147         {
148                 .ctl_name = KQSWNAL_PEERCREDITS,
149                 .procname = "peer_credits",
150                 .data     = &peer_credits,
151                 .maxlen   = sizeof (int),
152                 .mode     = 0444,
153                 .proc_handler = &proc_dointvec
154         },
155         {
156                 .ctl_name = KQSWNAL_NRXMSGS_LARGE,
157                 .procname = "nrxmsgs_large",
158                 .data     = &nrxmsgs_large,
159                 .maxlen   = sizeof (int),
160                 .mode     = 0444,
161                 .proc_handler = &proc_dointvec
162         },
163         {
164                 .ctl_name = KQSWNAL_EP_ENVELOPES_LARGE,
165                 .procname = "ep_envelopes_large",
166                 .data     = &ep_envelopes_large,
167                 .maxlen   = sizeof (int),
168                 .mode     = 0444,
169                 .proc_handler = &proc_dointvec
170         },
171         {
172                 .ctl_name = KQSWNAL_NRXMSGS_SMALL,
173                 .procname = "nrxmsgs_small",
174                 .data     = &nrxmsgs_small,
175                 .maxlen   = sizeof (int),
176                 .mode     = 0444,
177                 .proc_handler = &proc_dointvec
178         },
179         {
180                 .ctl_name = KQSWNAL_EP_ENVELOPES_SMALL,
181                 .procname = "ep_envelopes_small",
182                 .data     = &ep_envelopes_small,
183                 .maxlen   = sizeof (int),
184                 .mode     = 0444,
185                 .proc_handler = &proc_dointvec
186         },
187         {
188                 .ctl_name = KQSWNAL_OPTIMIZED_PUTS,
189                 .procname = "optimized_puts",
190                 .data     = &optimized_puts,
191                 .maxlen   = sizeof (int),
192                 .mode     = 0644,
193                 .proc_handler = &proc_dointvec
194         },
195         {
196                 .ctl_name = KQSWNAL_OPTIMIZED_GETS,
197                 .procname = "optimized_gets",
198                 .data     = &optimized_gets,
199                 .maxlen   = sizeof (int),
200                 .mode     = 0644,
201                 .proc_handler = &proc_dointvec
202         },
203 #if KQSW_CKSUM
204         {
205                 .ctl_name = KQSWNAL_INJECT_CSUM_ERROR,
206                 .procname = "inject_csum_error",
207                 .data     = &inject_csum_error,
208                 .maxlen   = sizeof (int),
209                 .mode     = 0644,
210                 .proc_handler = &proc_dointvec
211         },
212 #endif
213         {0}
214 };
215
216 static cfs_sysctl_table_t kqswnal_top_ctl_table[] = {
217         {
218                 .ctl_name = CTL_KQSWNAL,
219                 .procname = "qswnal",
220                 .data     = NULL,
221                 .maxlen   = 0,
222                 .mode     = 0555,
223                 .child    = kqswnal_ctl_table
224         },
225         {0}
226 };
227
228 int
229 kqswnal_tunables_init ()
230 {
231         kqswnal_tunables.kqn_sysctl =
232                 cfs_register_sysctl_table(kqswnal_top_ctl_table, 0);
233
234         if (kqswnal_tunables.kqn_sysctl == NULL)
235                 CWARN("Can't setup /proc tunables\n");
236
237         return 0;
238 }
239
240 void
241 kqswnal_tunables_fini ()
242 {
243         if (kqswnal_tunables.kqn_sysctl != NULL)
244                 cfs_unregister_sysctl_table(kqswnal_tunables.kqn_sysctl);
245 }
246 #else
247 int
248 kqswnal_tunables_init ()
249 {
250         return 0;
251 }
252
253 void
254 kqswnal_tunables_fini ()
255 {
256 }
257 #endif