Whamcloud - gitweb
48ed02f39dc487661f67cc0233a99e41693756c6
[fs/lustre-release.git] / lnet / klnds / gmlnd / gmlnd_module.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  *
32  * Copyright (c) 2003 Los Alamos National Laboratory (LANL)
33  */
34 /*
35  * This file is part of Lustre, http://www.lustre.org/
36  * Lustre is a trademark of Sun Microsystems, Inc.
37  */
38
39 #include "gmlnd.h"
40
41
42 static int port = 4;
43 CFS_MODULE_PARM(port, "i", int, 0444,
44                 "GM port to use for communications");
45
46 static int ntx = 256;
47 CFS_MODULE_PARM(ntx, "i", int, 0444,
48                 "# tx descriptors");
49
50 static int credits = 128;
51 CFS_MODULE_PARM(credits, "i", int, 0444,
52                 "# concurrent sends");
53
54 static int peer_credits = 8;
55 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
56                 "# concurrent sends per peer");
57
58 static int nlarge_tx_bufs = 32;
59 CFS_MODULE_PARM(nlarge_tx_bufs, "i", int, 0444,
60                 "# large tx message buffers");
61
62 static int nrx_small = 128;
63 CFS_MODULE_PARM(nrx_small, "i", int, 0444,
64                 "# small rx message buffers");
65
66 static int nrx_large = 64;
67 CFS_MODULE_PARM(nrx_large, "i", int, 0444,
68                 "# large rx message buffers");
69
70 gmnal_tunables_t gmnal_tunables = {
71         .gm_port            = &port,
72         .gm_ntx             = &ntx,
73         .gm_credits         = &credits,
74         .gm_peer_credits    = &peer_credits,
75         .gm_nlarge_tx_bufs  = &nlarge_tx_bufs,
76         .gm_nrx_small       = &nrx_small,
77         .gm_nrx_large       = &nrx_large,
78 };
79
80 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
81
82 #ifndef HAVE_SYSCTL_UNNUMBERED
83
84 enum {
85         GMLND_PORT = 1,
86         GMLND_NTX,
87         GMLND_CREDITS,
88         GMLND_PEERCREDITS,
89         GMLND_NLARGE_TX_BUFS,
90         GMLND_NRX_SMALL,
91         GMLND_NRX_LARGE
92 };
93
94 #else
95
96 #define GMLND_PORT              CTL_UNNUMBERED
97 #define GMLND_NTX               CTL_UNNUMBERED
98 #define GMLND_CREDITS           CTL_UNNUMBERED
99 #define GMLND_PEERCREDITS       CTL_UNNUMBERED
100 #define GMLND_NLARGE_TX_BUFS    CTL_UNNUMBERED
101 #define GMLND_NRX_SMALL         CTL_UNNUMBERED
102 #define GMLND_NRX_LARGE         CTL_UNNUMBERED
103
104 #endif
105
106 static cfs_sysctl_table_t gmnal_ctl_table[] = {
107         {
108                 .ctl_name = GMLND_PORT,
109                 .procname = "port",
110                 .data     = &port,
111                 .maxlen   = sizeof (int),
112                 .mode     = 0444,
113                 .proc_handler = &proc_dointvec
114         },
115         {
116                 .ctl_name = GMLND_NTX,
117                 .procname = "ntx",
118                 .data     = &ntx,
119                 .maxlen   = sizeof (int),
120                 .mode     = 0444,
121                 .proc_handler = &proc_dointvec
122         },
123         {
124                 .ctl_name = GMLND_CREDITS,
125                 .procname = "credits",
126                 .data     = &credits,
127                 .maxlen   = sizeof (int),
128                 .mode     = 0444,
129                 .proc_handler = &proc_dointvec
130         },
131         {
132                 .ctl_name = GMLND_PEERCREDITS,
133                 .procname = "peer_credits",
134                 .data     = &peer_credits,
135                 .maxlen   = sizeof (int),
136                 .mode     = 0444,
137                 .proc_handler = &proc_dointvec
138         },
139         {
140                 .ctl_name = GMLND_NLARGE_TX_BUFS,
141                 .procname = "nlarge_tx_bufs",
142                 .data     = &nlarge_tx_bufs,
143                 .maxlen   = sizeof (int),
144                 .mode     = 0444,
145                 .proc_handler = &proc_dointvec
146         },
147         {
148                 .ctl_name = GMLND_NRX_SMALL,
149                 .procname = "nrx_small",
150                 .data     = &nrx_small,
151                 .maxlen   = sizeof (int),
152                 .mode     = 0444,
153                 .proc_handler = &proc_dointvec
154         },
155         {
156                 .ctl_name = GMLND_NRX_LARGE,
157                 .procname = "nrx_large",
158                 .data     = &nrx_large,
159                 .maxlen   = sizeof (int),
160                 .mode     = 0444,
161                 .proc_handler = &proc_dointvec
162         },
163         {0}
164 };
165
166 static cfs_sysctl_table_t gmnal_top_ctl_table[] = {
167         {
168                 .ctl_name = CTL_GMLND,
169                 .procname = "gmnal",
170                 .data     = NULL,
171                 .maxlen   = 0,
172                 .mode     = 0555,
173                 .child    = gmnal_ctl_table
174         },
175         {0}
176 };
177 #endif
178
179 static int __init
180 gmnal_load(void)
181 {
182         int     status;
183         CDEBUG(D_TRACE, "This is the gmnal module initialisation routine\n");
184
185 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
186         gmnal_tunables.gm_sysctl =
187                 cfs_register_sysctl_table(gmnal_top_ctl_table, 0);
188
189         if (gmnal_tunables.gm_sysctl == NULL)
190                 CWARN("Can't setup /proc tunables\n");
191 #endif
192         CDEBUG(D_NET, "Calling gmnal_init\n");
193         status = gmnal_init();
194         if (status == 0) {
195                 CDEBUG(D_NET, "Portals GMNAL initialised ok\n");
196         } else {
197                 CDEBUG(D_NET, "Portals GMNAL Failed to initialise\n");
198                 return(-ENODEV);
199         }
200
201         CDEBUG(D_NET, "This is the end of the gmnal init routine");
202
203         return(0);
204 }
205
206 static void __exit
207 gmnal_unload(void)
208 {
209         gmnal_fini();
210 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
211         if (gmnal_tunables.gm_sysctl != NULL)
212                 cfs_unregister_sysctl_table(gmnal_tunables.gm_sysctl);
213 #endif
214 }
215
216 module_init(gmnal_load);
217 module_exit(gmnal_unload);
218
219 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
220 MODULE_DESCRIPTION("Kernel GM LND v1.01");
221 MODULE_LICENSE("GPL");