Whamcloud - gitweb
b=16098
[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 static cfs_sysctl_table_t gmnal_ctl_table[] = {
82         {
83                 .ctl_name = 1,
84                 .procname = "port",
85                 .data     = &port,
86                 .maxlen   = sizeof (int),
87                 .mode     = 0444,
88                 .proc_handler = &proc_dointvec
89         },
90         {
91                 .ctl_name = 2,
92                 .procname = "ntx",
93                 .data     = &ntx,
94                 .maxlen   = sizeof (int),
95                 .mode     = 0444,
96                 .proc_handler = &proc_dointvec
97         },
98         {
99                 .ctl_name = 3,
100                 .procname = "credits",
101                 .data     = &credits,
102                 .maxlen   = sizeof (int),
103                 .mode     = 0444,
104                 .proc_handler = &proc_dointvec
105         },
106         {
107                 .ctl_name = 4,
108                 .procname = "peer_credits",
109                 .data     = &peer_credits,
110                 .maxlen   = sizeof (int),
111                 .mode     = 0444,
112                 .proc_handler = &proc_dointvec
113         },
114         {
115                 .ctl_name = 5,
116                 .procname = "nlarge_tx_bufs",
117                 .data     = &nlarge_tx_bufs,
118                 .maxlen   = sizeof (int),
119                 .mode     = 0444,
120                 .proc_handler = &proc_dointvec
121         },
122         {
123                 .ctl_name = 6,
124                 .procname = "nrx_small",
125                 .data     = &nrx_small,
126                 .maxlen   = sizeof (int),
127                 .mode     = 0444,
128                 .proc_handler = &proc_dointvec
129         },
130         {
131                 .ctl_name = 7,
132                 .procname = "nrx_large",
133                 .data     = &nrx_large,
134                 .maxlen   = sizeof (int),
135                 .mode     = 0444,
136                 .proc_handler = &proc_dointvec
137         },
138         {0}
139 };
140
141 static cfs_sysctl_table_t gmnal_top_ctl_table[] = {
142         {
143                 .ctl_name = 207,
144                 .procname = "gmnal",
145                 .data     = NULL,
146                 .maxlen   = 0,
147                 .mode     = 0555,
148                 .child    = gmnal_ctl_table
149         },
150         {0}
151 };
152 #endif
153
154 static int __init
155 gmnal_load(void)
156 {
157         int     status;
158         CDEBUG(D_TRACE, "This is the gmnal module initialisation routine\n");
159
160 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
161         gmnal_tunables.gm_sysctl =
162                 cfs_register_sysctl_table(gmnal_top_ctl_table, 0);
163
164         if (gmnal_tunables.gm_sysctl == NULL)
165                 CWARN("Can't setup /proc tunables\n");
166 #endif
167         CDEBUG(D_NET, "Calling gmnal_init\n");
168         status = gmnal_init();
169         if (status == 0) {
170                 CDEBUG(D_NET, "Portals GMNAL initialised ok\n");
171         } else {
172                 CDEBUG(D_NET, "Portals GMNAL Failed to initialise\n");
173                 return(-ENODEV);
174         }
175
176         CDEBUG(D_NET, "This is the end of the gmnal init routine");
177
178         return(0);
179 }
180
181 static void __exit
182 gmnal_unload(void)
183 {
184         gmnal_fini();
185 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
186         if (gmnal_tunables.gm_sysctl != NULL)
187                 cfs_unregister_sysctl_table(gmnal_tunables.gm_sysctl);
188 #endif
189 }
190
191 module_init(gmnal_load);
192 module_exit(gmnal_unload);
193
194 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
195 MODULE_DESCRIPTION("Kernel GM LND v1.01");
196 MODULE_LICENSE("GPL");