Whamcloud - gitweb
LU-1346 gnilnd: remove libcfs abstractions
[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 #ifndef HAVE_SYSCTL_UNNUMBERED
90
91 enum
92         KQSWNAL_TX_MAXCONTIG = 1,
93         KQSWNAL_NTXMSG,
94         KQSWNAL_CREDITS,
95         KQSWNAL_PEERCREDITS,
96         KQSWNAL_NRXMSGS_LARGE,
97         KQSWNAL_EP_ENVELOPES_LARGE,
98         KQSWNAL_NRXMSGS_SMALL,
99         KQSWNAL_EP_ENVELOPES_SMALL,
100         KQSWNAL_OPTIMIZED_PUTS,
101         KQSWNAL_OPTIMIZED_GETS,
102         KQSWNAL_INJECT_CSUM_ERROR
103 };
104 #else
105
106 #define KQSWNAL_TX_MAXCONTIG    CTL_UNNUMBERED
107 #define KQSWNAL_NTXMSG          CTL_UNNUMBERED
108 #define KQSWNAL_CREDITS         CTL_UNNUMBERED
109 #define KQSWNAL_PEERCREDITS     CTL_UNNUMBERED
110 #define KQSWNAL_NRXMSGS_LARGE   CTL_UNNUMBERED
111 #define KQSWNAL_EP_ENVELOPES_LARGE CTL_UNNUMBERED
112 #define KQSWNAL_NRXMSGS_SMALL   CTL_UNNUMBERED
113 #define KQSWNAL_EP_ENVELOPES_SMALL CTL_UNNUMBERED
114 #define KQSWNAL_OPTIMIZED_PUTS  CTL_UNNUMBERED
115 #define KQSWNAL_OPTIMIZED_GETS  CTL_UNNUMBERED
116 #define KQSWNAL_INJECT_CSUM_ERROR CTL_UNNUMBERED
117
118 #endif
119
120 static struct ctl_table kqswnal_ctl_table[] = {
121         {
122                 .ctl_name = KQSWNAL_TX_MAXCONTIG,
123                 .procname = "tx_maxcontig",
124                 .data     = &tx_maxcontig,
125                 .maxlen   = sizeof (int),
126                 .mode     = 0444,
127                 .proc_handler = &proc_dointvec
128         },
129         {
130                 .ctl_name = KQSWNAL_NTXMSG,
131                 .procname = "ntxmsgs",
132                 .data     = &ntxmsgs,
133                 .maxlen   = sizeof (int),
134                 .mode     = 0444,
135                 .proc_handler = &proc_dointvec
136         },
137         {
138                 .ctl_name = KQSWNAL_CREDITS,
139                 .procname = "credits",
140                 .data     = &credits,
141                 .maxlen   = sizeof (int),
142                 .mode     = 0444,
143                 .proc_handler = &proc_dointvec
144         },
145         {
146                 .ctl_name = KQSWNAL_PEERCREDITS,
147                 .procname = "peer_credits",
148                 .data     = &peer_credits,
149                 .maxlen   = sizeof (int),
150                 .mode     = 0444,
151                 .proc_handler = &proc_dointvec
152         },
153         {
154                 .ctl_name = KQSWNAL_NRXMSGS_LARGE,
155                 .procname = "nrxmsgs_large",
156                 .data     = &nrxmsgs_large,
157                 .maxlen   = sizeof (int),
158                 .mode     = 0444,
159                 .proc_handler = &proc_dointvec
160         },
161         {
162                 .ctl_name = KQSWNAL_EP_ENVELOPES_LARGE,
163                 .procname = "ep_envelopes_large",
164                 .data     = &ep_envelopes_large,
165                 .maxlen   = sizeof (int),
166                 .mode     = 0444,
167                 .proc_handler = &proc_dointvec
168         },
169         {
170                 .ctl_name = KQSWNAL_NRXMSGS_SMALL,
171                 .procname = "nrxmsgs_small",
172                 .data     = &nrxmsgs_small,
173                 .maxlen   = sizeof (int),
174                 .mode     = 0444,
175                 .proc_handler = &proc_dointvec
176         },
177         {
178                 .ctl_name = KQSWNAL_EP_ENVELOPES_SMALL,
179                 .procname = "ep_envelopes_small",
180                 .data     = &ep_envelopes_small,
181                 .maxlen   = sizeof (int),
182                 .mode     = 0444,
183                 .proc_handler = &proc_dointvec
184         },
185         {
186                 .ctl_name = KQSWNAL_OPTIMIZED_PUTS,
187                 .procname = "optimized_puts",
188                 .data     = &optimized_puts,
189                 .maxlen   = sizeof (int),
190                 .mode     = 0644,
191                 .proc_handler = &proc_dointvec
192         },
193         {
194                 .ctl_name = KQSWNAL_OPTIMIZED_GETS,
195                 .procname = "optimized_gets",
196                 .data     = &optimized_gets,
197                 .maxlen   = sizeof (int),
198                 .mode     = 0644,
199                 .proc_handler = &proc_dointvec
200         },
201 #if KQSW_CKSUM
202         {
203                 .ctl_name = KQSWNAL_INJECT_CSUM_ERROR,
204                 .procname = "inject_csum_error",
205                 .data     = &inject_csum_error,
206                 .maxlen   = sizeof (int),
207                 .mode     = 0644,
208                 .proc_handler = &proc_dointvec
209         },
210 #endif
211         {0}
212 };
213
214 static struct ctl_table kqswnal_top_ctl_table[] = {
215         {
216                 .ctl_name = CTL_KQSWNAL,
217                 .procname = "qswnal",
218                 .data     = NULL,
219                 .maxlen   = 0,
220                 .mode     = 0555,
221                 .child    = kqswnal_ctl_table
222         },
223         {0}
224 };
225
226 int
227 kqswnal_tunables_init ()
228 {
229         kqswnal_tunables.kqn_sysctl =
230                 register_sysctl_table(kqswnal_top_ctl_table);
231
232         if (kqswnal_tunables.kqn_sysctl == NULL)
233                 CWARN("Can't setup /proc tunables\n");
234
235         return 0;
236 }
237
238 void kqswnal_tunables_fini()
239 {
240         if (kqswnal_tunables.kqn_sysctl != NULL)
241                 unregister_sysctl_table(kqswnal_tunables.kqn_sysctl);
242 }
243 #else
244 int
245 kqswnal_tunables_init ()
246 {
247         return 0;
248 }
249
250 void
251 kqswnal_tunables_fini ()
252 {
253 }
254 #endif