1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre 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.
12 * Lustre 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.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # define EXPORT_SYMTAB
25 #define DEBUG_SUBSYSTEM S_LNET
26 #include <lnet/lib-lnet.h>
28 static int config_on_load = 0;
29 CFS_MODULE_PARM(config_on_load, "i", int, 0444,
30 "configure network at module load");
32 static struct semaphore lnet_config_mutex;
35 lnet_configure (void *arg)
37 /* 'arg' only there so I can be passed to cfs_kernel_thread() */
40 LNET_MUTEX_DOWN(&lnet_config_mutex);
42 if (!the_lnet.ln_niinit_self) {
43 rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
45 the_lnet.ln_niinit_self = 1;
50 LNET_MUTEX_UP(&lnet_config_mutex);
55 lnet_unconfigure (void)
59 LNET_MUTEX_DOWN(&lnet_config_mutex);
61 if (the_lnet.ln_niinit_self) {
62 the_lnet.ln_niinit_self = 0;
66 LNET_MUTEX_DOWN(&the_lnet.ln_api_mutex);
67 refcount = the_lnet.ln_refcount;
68 LNET_MUTEX_UP(&the_lnet.ln_api_mutex);
70 LNET_MUTEX_UP(&lnet_config_mutex);
71 return (refcount == 0) ? 0 : -EBUSY;
75 lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
80 case IOC_LIBCFS_CONFIGURE:
81 return lnet_configure(NULL);
83 case IOC_LIBCFS_UNCONFIGURE:
84 return lnet_unconfigure();
87 /* Passing LNET_PID_ANY only gives me a ref if the net is up
88 * already; I'll need it to ensure the net can't go down while
89 * I'm called into it */
90 rc = LNetNIInit(LNET_PID_ANY);
92 rc = LNetCtl(cmd, data);
99 DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
107 init_mutex(&lnet_config_mutex);
111 CERROR("LNetInit: error %d\n", rc);
115 rc = libcfs_register_ioctl(&lnet_ioctl_handler);
118 if (config_on_load) {
119 /* Have to schedule a separate thread to avoid deadlocking
121 (void) cfs_kernel_thread(lnet_configure, NULL, 0);
132 rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
138 EXPORT_SYMBOL(lnet_register_lnd);
139 EXPORT_SYMBOL(lnet_unregister_lnd);
141 EXPORT_SYMBOL(LNetMEAttach);
142 EXPORT_SYMBOL(LNetMEInsert);
143 EXPORT_SYMBOL(LNetMEUnlink);
144 EXPORT_SYMBOL(LNetEQAlloc);
145 EXPORT_SYMBOL(LNetMDAttach);
146 EXPORT_SYMBOL(LNetMDUnlink);
147 EXPORT_SYMBOL(LNetNIInit);
148 EXPORT_SYMBOL(LNetNIFini);
149 EXPORT_SYMBOL(LNetInit);
150 EXPORT_SYMBOL(LNetFini);
151 EXPORT_SYMBOL(LNetSnprintHandle);
152 EXPORT_SYMBOL(LNetPut);
153 EXPORT_SYMBOL(LNetGet);
154 EXPORT_SYMBOL(LNetEQWait);
155 EXPORT_SYMBOL(LNetEQFree);
156 EXPORT_SYMBOL(LNetEQGet);
157 EXPORT_SYMBOL(LNetGetId);
158 EXPORT_SYMBOL(LNetMDBind);
159 EXPORT_SYMBOL(LNetDist);
160 EXPORT_SYMBOL(LNetSetAsync);
161 EXPORT_SYMBOL(LNetCtl);
162 EXPORT_SYMBOL(LNetSetLazyPortal);
163 EXPORT_SYMBOL(LNetClearLazyPortal);
164 EXPORT_SYMBOL(the_lnet);
165 EXPORT_SYMBOL(lnet_iov_nob);
166 EXPORT_SYMBOL(lnet_extract_iov);
167 EXPORT_SYMBOL(lnet_kiov_nob);
168 EXPORT_SYMBOL(lnet_extract_kiov);
169 EXPORT_SYMBOL(lnet_copy_iov2iov);
170 EXPORT_SYMBOL(lnet_copy_iov2kiov);
171 EXPORT_SYMBOL(lnet_copy_kiov2iov);
172 EXPORT_SYMBOL(lnet_copy_kiov2kiov);
173 EXPORT_SYMBOL(lnet_finalize);
174 EXPORT_SYMBOL(lnet_parse);
175 EXPORT_SYMBOL(lnet_create_reply_msg);
176 EXPORT_SYMBOL(lnet_set_reply_msg_len);
177 EXPORT_SYMBOL(lnet_msgtyp2str);
178 EXPORT_SYMBOL(lnet_net2ni_locked);
180 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
181 MODULE_DESCRIPTION("Portals v3.1");
182 MODULE_LICENSE("GPL");
184 cfs_module(lnet, "1.0.0", init_lnet, fini_lnet);