Whamcloud - gitweb
LU-2800 autoconf: clean up sysctl table handling
[fs/lustre-release.git] / lnet / klnds / qswlnd / qswlnd_modparams.c
1 /*
2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3  *
4  * Author: Eric Barton <eric@bartonsoftware.com>
5  *
6  * This file is part of Portals, http://www.lustre.org
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
23 #include "qswlnd.h"
24
25 static int tx_maxcontig = (1<<10);
26 CFS_MODULE_PARM(tx_maxcontig, "i", int, 0444,
27                 "maximum payload to de-fragment");
28
29 static int ntxmsgs = 512;
30 CFS_MODULE_PARM(ntxmsgs, "i", int, 0444,
31                 "# tx msg buffers");
32
33 static int credits = 128;
34 CFS_MODULE_PARM(credits, "i", int, 0444,
35                 "# concurrent sends");
36
37 static int peer_credits = 8;
38 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
39                 "# per-peer concurrent sends");
40
41 static int nrxmsgs_large = 64;
42 CFS_MODULE_PARM(nrxmsgs_large, "i", int, 0444,
43                 "# 'large' rx msg buffers");
44
45 static int ep_envelopes_large = 256;
46 CFS_MODULE_PARM(ep_envelopes_large, "i", int, 0444,
47                 "# 'large' rx msg envelope buffers");
48
49 static int nrxmsgs_small = 256;
50 CFS_MODULE_PARM(nrxmsgs_small, "i", int, 0444,
51                 "# 'small' rx msg buffers");
52
53 static int ep_envelopes_small = 2048;
54 CFS_MODULE_PARM(ep_envelopes_small, "i", int, 0444,
55                 "# 'small' rx msg envelope buffers");
56
57 static int optimized_puts = (32<<10);
58 CFS_MODULE_PARM(optimized_puts, "i", int, 0644,
59                 "zero-copy puts >= this size");
60
61 static int optimized_gets = 2048;
62 CFS_MODULE_PARM(optimized_gets, "i", int, 0644,
63                 "zero-copy gets >= this size");
64
65 #if KQSW_CKSUM
66 static int inject_csum_error = 0;
67 CFS_MODULE_PARM(inject_csum_error, "i", int, 0644,
68                 "test checksumming");
69 #endif
70
71 kqswnal_tunables_t kqswnal_tunables = {
72         .kqn_tx_maxcontig       = &tx_maxcontig,
73         .kqn_ntxmsgs            = &ntxmsgs,
74         .kqn_credits            = &credits,
75         .kqn_peercredits        = &peer_credits,
76         .kqn_nrxmsgs_large      = &nrxmsgs_large,
77         .kqn_ep_envelopes_large = &ep_envelopes_large,
78         .kqn_nrxmsgs_small      = &nrxmsgs_small,
79         .kqn_ep_envelopes_small = &ep_envelopes_small,
80         .kqn_optimized_puts     = &optimized_puts,
81         .kqn_optimized_gets     = &optimized_gets,
82 #if KQSW_CKSUM
83         .kqn_inject_csum_error  = &inject_csum_error,
84 #endif
85 };
86
87 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
88
89 static struct ctl_table kqswnal_ctl_table[] = {
90         {
91                 INIT_CTL_NAME
92                 .procname       = "tx_maxcontig",
93                 .data           = &tx_maxcontig,
94                 .maxlen         = sizeof (int),
95                 .mode           = 0444,
96                 .proc_handler   = &proc_dointvec
97         },
98         {
99                 INIT_CTL_NAME
100                 .procname       = "ntxmsgs",
101                 .data           = &ntxmsgs,
102                 .maxlen         = sizeof (int),
103                 .mode           = 0444,
104                 .proc_handler   = &proc_dointvec
105         },
106         {
107                 INIT_CTL_NAME
108                 .procname       = "credits",
109                 .data           = &credits,
110                 .maxlen         = sizeof (int),
111                 .mode           = 0444,
112                 .proc_handler   = &proc_dointvec
113         },
114         {
115                 INIT_CTL_NAME
116                 .procname       = "peer_credits",
117                 .data           = &peer_credits,
118                 .maxlen         = sizeof (int),
119                 .mode           = 0444,
120                 .proc_handler   = &proc_dointvec
121         },
122         {
123                 INIT_CTL_NAME
124                 .procname       = "nrxmsgs_large",
125                 .data           = &nrxmsgs_large,
126                 .maxlen         = sizeof (int),
127                 .mode           = 0444,
128                 .proc_handler   = &proc_dointvec
129         },
130         {
131                 INIT_CTL_NAME
132                 .procname       = "ep_envelopes_large",
133                 .data           = &ep_envelopes_large,
134                 .maxlen         = sizeof (int),
135                 .mode           = 0444,
136                 .proc_handler   = &proc_dointvec
137         },
138         {
139                 INIT_CTL_NAME
140                 .procname       = "nrxmsgs_small",
141                 .data           = &nrxmsgs_small,
142                 .maxlen         = sizeof (int),
143                 .mode           = 0444,
144                 .proc_handler   = &proc_dointvec
145         },
146         {
147                 INIT_CTL_NAME
148                 .procname       = "ep_envelopes_small",
149                 .data           = &ep_envelopes_small,
150                 .maxlen         = sizeof (int),
151                 .mode           = 0444,
152                 .proc_handler   = &proc_dointvec
153         },
154         {
155                 INIT_CTL_NAME
156                 .procname       = "optimized_puts",
157                 .data           = &optimized_puts,
158                 .maxlen         = sizeof (int),
159                 .mode           = 0644,
160                 .proc_handler   = &proc_dointvec
161         },
162         {
163                 INIT_CTL_NAME
164                 .procname       = "optimized_gets",
165                 .data           = &optimized_gets,
166                 .maxlen         = sizeof (int),
167                 .mode           = 0644,
168                 .proc_handler   = &proc_dointvec
169         },
170 #if KQSW_CKSUM
171         {
172                 INIT_CTL_NAME
173                 .procname       = "inject_csum_error",
174                 .data           = &inject_csum_error,
175                 .maxlen         = sizeof (int),
176                 .mode           = 0644,
177                 .proc_handler   = &proc_dointvec
178         },
179 #endif
180         { 0 }
181 };
182
183 static struct ctl_table kqswnal_top_ctl_table[] = {
184         {
185                 INIT_CTL_NAME
186                 .procname       = "qswnal",
187                 .data           = NULL,
188                 .maxlen         = 0,
189                 .mode           = 0555,
190                 .child          = kqswnal_ctl_table
191         },
192         { 0 }
193 };
194
195 int
196 kqswnal_tunables_init ()
197 {
198         kqswnal_tunables.kqn_sysctl =
199                 register_sysctl_table(kqswnal_top_ctl_table);
200
201         if (kqswnal_tunables.kqn_sysctl == NULL)
202                 CWARN("Can't setup /proc tunables\n");
203
204         return 0;
205 }
206
207 void kqswnal_tunables_fini()
208 {
209         if (kqswnal_tunables.kqn_sysctl != NULL)
210                 unregister_sysctl_table(kqswnal_tunables.kqn_sysctl);
211 }
212 #else
213 int
214 kqswnal_tunables_init ()
215 {
216         return 0;
217 }
218
219 void
220 kqswnal_tunables_fini ()
221 {
222 }
223 #endif