1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_LNET
41 #include <lnet/lib-lnet.h>
43 static int config_on_load = 0;
44 CFS_MODULE_PARM(config_on_load, "i", int, 0444,
45 "configure network at module load");
47 static struct semaphore lnet_config_mutex;
50 lnet_configure (void *arg)
52 /* 'arg' only there so I can be passed to cfs_kernel_thread() */
55 LNET_MUTEX_DOWN(&lnet_config_mutex);
57 if (!the_lnet.ln_niinit_self) {
58 rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
60 the_lnet.ln_niinit_self = 1;
65 LNET_MUTEX_UP(&lnet_config_mutex);
70 lnet_unconfigure (void)
74 LNET_MUTEX_DOWN(&lnet_config_mutex);
76 if (the_lnet.ln_niinit_self) {
77 the_lnet.ln_niinit_self = 0;
81 LNET_MUTEX_DOWN(&the_lnet.ln_api_mutex);
82 refcount = the_lnet.ln_refcount;
83 LNET_MUTEX_UP(&the_lnet.ln_api_mutex);
85 LNET_MUTEX_UP(&lnet_config_mutex);
86 return (refcount == 0) ? 0 : -EBUSY;
90 lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
95 case IOC_LIBCFS_CONFIGURE:
96 return lnet_configure(NULL);
98 case IOC_LIBCFS_UNCONFIGURE:
99 return lnet_unconfigure();
102 /* Passing LNET_PID_ANY only gives me a ref if the net is up
103 * already; I'll need it to ensure the net can't go down while
104 * I'm called into it */
105 rc = LNetNIInit(LNET_PID_ANY);
107 rc = LNetCtl(cmd, data);
114 DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
122 init_mutex(&lnet_config_mutex);
126 CERROR("LNetInit: error %d\n", rc);
130 rc = libcfs_register_ioctl(&lnet_ioctl_handler);
133 if (config_on_load) {
134 /* Have to schedule a separate thread to avoid deadlocking
136 (void) cfs_kernel_thread(lnet_configure, NULL, 0);
147 rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
153 EXPORT_SYMBOL(lnet_register_lnd);
154 EXPORT_SYMBOL(lnet_unregister_lnd);
156 EXPORT_SYMBOL(LNetMEAttach);
157 EXPORT_SYMBOL(LNetMEInsert);
158 EXPORT_SYMBOL(LNetMEUnlink);
159 EXPORT_SYMBOL(LNetEQAlloc);
160 EXPORT_SYMBOL(LNetMDAttach);
161 EXPORT_SYMBOL(LNetMDUnlink);
162 EXPORT_SYMBOL(LNetNIInit);
163 EXPORT_SYMBOL(LNetNIFini);
164 EXPORT_SYMBOL(LNetInit);
165 EXPORT_SYMBOL(LNetFini);
166 EXPORT_SYMBOL(LNetSnprintHandle);
167 EXPORT_SYMBOL(LNetPut);
168 EXPORT_SYMBOL(LNetGet);
169 EXPORT_SYMBOL(LNetEQWait);
170 EXPORT_SYMBOL(LNetEQFree);
171 EXPORT_SYMBOL(LNetEQGet);
172 EXPORT_SYMBOL(LNetGetId);
173 EXPORT_SYMBOL(LNetMDBind);
174 EXPORT_SYMBOL(LNetDist);
175 EXPORT_SYMBOL(LNetSetAsync);
176 EXPORT_SYMBOL(LNetCtl);
177 EXPORT_SYMBOL(LNetSetLazyPortal);
178 EXPORT_SYMBOL(LNetClearLazyPortal);
179 EXPORT_SYMBOL(the_lnet);
180 EXPORT_SYMBOL(lnet_iov_nob);
181 EXPORT_SYMBOL(lnet_extract_iov);
182 EXPORT_SYMBOL(lnet_kiov_nob);
183 EXPORT_SYMBOL(lnet_extract_kiov);
184 EXPORT_SYMBOL(lnet_copy_iov2iov);
185 EXPORT_SYMBOL(lnet_copy_iov2kiov);
186 EXPORT_SYMBOL(lnet_copy_kiov2iov);
187 EXPORT_SYMBOL(lnet_copy_kiov2kiov);
188 EXPORT_SYMBOL(lnet_finalize);
189 EXPORT_SYMBOL(lnet_parse);
190 EXPORT_SYMBOL(lnet_create_reply_msg);
191 EXPORT_SYMBOL(lnet_set_reply_msg_len);
192 EXPORT_SYMBOL(lnet_msgtyp2str);
193 EXPORT_SYMBOL(lnet_net2ni_locked);
195 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
196 MODULE_DESCRIPTION("Portals v3.1");
197 MODULE_LICENSE("GPL");
199 cfs_module(lnet, "1.0.0", init_lnet, fini_lnet);