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_PORTALS
27 #include <portals/lib-p30.h>
28 #include <portals/p30.h>
29 #include <portals/nal.h>
30 #include <libcfs/kp30.h>
31 #include <portals/kpr.h>
33 extern void (kping_client)(struct portal_ioctl_data *);
35 static int kportal_ioctl(struct portal_ioctl_data *data,
36 unsigned int cmd, unsigned long arg)
39 char str[PTL_NALFMT_SIZE];
43 case IOC_PORTAL_PING: {
44 void (*ping)(struct portal_ioctl_data *);
46 CDEBUG(D_IOCTL, "doing %d pings to nid "LPX64" (%s)\n",
47 data->ioc_count, data->ioc_nid,
48 portals_nid2str(data->ioc_nal, data->ioc_nid, str));
49 ping = PORTAL_SYMBOL_GET(kping_client);
51 CERROR("PORTAL_SYMBOL_GET failed\n");
54 PORTAL_SYMBOL_PUT(kping_client);
59 case IOC_PORTAL_GET_NID: {
63 CDEBUG (D_IOCTL, "Getting nid for nal [%x]\n", data->ioc_nal);
65 err = PtlNIInit(data->ioc_nal, LUSTRE_SRV_PTL_PID, NULL,
67 if (!(err == PTL_OK || err == PTL_IFACE_DUP))
70 err = PtlGetId (nih, &pid);
71 LASSERT (err == PTL_OK);
75 data->ioc_nid = pid.nid;
76 if (copy_to_user ((char *)arg, data, sizeof (*data)))
81 case IOC_PORTAL_FAIL_NID: {
84 CDEBUG (D_IOCTL, "fail nid: [%d] "LPU64" count %d\n",
85 data->ioc_nal, data->ioc_nid, data->ioc_count);
87 err = PtlNIInit(data->ioc_nal, LUSTRE_SRV_PTL_PID, NULL,
89 if (!(err == PTL_OK || err == PTL_IFACE_DUP))
93 /* There's no point in failing an interface that
94 * came into existance just for this */
97 err = PtlFailNid (nih, data->ioc_nid, data->ioc_count);
106 case IOC_PORTAL_LOOPBACK: {
108 int enabled = data->ioc_flags;
109 int set = data->ioc_misc;
111 CDEBUG (D_IOCTL, "loopback: [%d] %d %d\n",
112 data->ioc_nal, enabled, set);
114 err = PtlNIInit(data->ioc_nal, LUSTRE_SRV_PTL_PID, NULL,
116 if (!(err == PTL_OK || err == PTL_IFACE_DUP))
120 /* There's no point in failing an interface that
121 * came into existance just for this */
124 err = PtlLoopback (nih, set, &enabled);
128 data->ioc_flags = enabled;
129 if (copy_to_user ((char *)arg, data,
146 DECLARE_IOCTL_HANDLER(kportal_ioctl_handler, kportal_ioctl);
147 extern struct semaphore ptl_mutex;
149 static int init_kportals_module(void)
154 init_mutex(&ptl_mutex);
157 CERROR("PtlInit: error %d\n", rc);
161 rc = libcfs_register_ioctl(&kportal_ioctl_handler);
167 static void exit_kportals_module(void)
171 rc = libcfs_deregister_ioctl(&kportal_ioctl_handler);
177 EXPORT_SYMBOL(ptl_register_nal);
178 EXPORT_SYMBOL(ptl_unregister_nal);
180 EXPORT_SYMBOL(ptl_err_str);
181 EXPORT_SYMBOL(PtlMEAttach);
182 EXPORT_SYMBOL(PtlMEInsert);
183 EXPORT_SYMBOL(PtlMEUnlink);
184 EXPORT_SYMBOL(PtlEQAlloc);
185 EXPORT_SYMBOL(PtlMDAttach);
186 EXPORT_SYMBOL(PtlMDUnlink);
187 EXPORT_SYMBOL(PtlNIInit);
188 EXPORT_SYMBOL(PtlNIFini);
189 EXPORT_SYMBOL(PtlInit);
190 EXPORT_SYMBOL(PtlFini);
191 EXPORT_SYMBOL(PtlSnprintHandle);
192 EXPORT_SYMBOL(PtlPut);
193 EXPORT_SYMBOL(PtlGet);
194 EXPORT_SYMBOL(PtlEQWait);
195 EXPORT_SYMBOL(PtlEQFree);
196 EXPORT_SYMBOL(PtlEQGet);
197 EXPORT_SYMBOL(PtlGetId);
198 EXPORT_SYMBOL(PtlMDBind);
199 EXPORT_SYMBOL(lib_iov_nob);
200 EXPORT_SYMBOL(lib_copy_iov2buf);
201 EXPORT_SYMBOL(lib_copy_buf2iov);
202 EXPORT_SYMBOL(lib_extract_iov);
203 EXPORT_SYMBOL(lib_kiov_nob);
204 EXPORT_SYMBOL(lib_copy_kiov2buf);
205 EXPORT_SYMBOL(lib_copy_buf2kiov);
206 EXPORT_SYMBOL(lib_extract_kiov);
207 EXPORT_SYMBOL(lib_finalize);
208 EXPORT_SYMBOL(lib_parse);
209 EXPORT_SYMBOL(lib_create_reply_msg);
210 EXPORT_SYMBOL(lib_init);
211 EXPORT_SYMBOL(lib_fini);
213 MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
214 MODULE_DESCRIPTION("Portals v3.1");
215 MODULE_LICENSE("GPL");
217 cfs_module(portals, "1.0.0", init_kportals_module, exit_kportals_module);