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