Whamcloud - gitweb
* Landed b_cray_portals_merge.
[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  *  Copyright (c) 2003 Los Alamos National Laboratory (LANL)
5  *
6  *   This file is part of Lustre, http://www.lustre.org/
7  *
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.
11  *
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.
16  *
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.
20  */
21
22 #include "gmnal.h"
23
24
25 int gmnal_small_msg_size = 525312;
26 /*
27  *      -1 indicates default value.
28  *      This is 1 thread per cpu
29  *      See start_kernel_threads
30  */
31 int num_rx_threads = -1;
32 int num_stxds = 5;
33 int gm_port = 4;
34
35 int 
36 gmnal_cmd(struct portals_cfg *pcfg, void *private)
37 {
38         gmnal_data_t    *nal_data = NULL;
39         char            *name = NULL;
40         int             nid = -2;
41         int             gnid;
42         gm_status_t     gm_status;
43
44
45         CDEBUG(D_TRACE, "gmnal_cmd [%d] private [%p]\n", 
46                pcfg->pcfg_command, private);
47         nal_data = (gmnal_data_t*)private;
48         switch(pcfg->pcfg_command) {
49         /*
50          * just reuse already defined GET_NID. Should define GMNAL version
51          */
52         case(GMNAL_IOC_GET_GNID):
53
54                 PORTAL_ALLOC(name, pcfg->pcfg_plen1);
55                 copy_from_user(name, pcfg->pcfg_pbuf1, pcfg->pcfg_plen1);
56         
57                 GMNAL_GM_LOCK(nal_data);
58                 nid = gm_host_name_to_node_id(nal_data->gm_port, name);
59                 GMNAL_GM_UNLOCK(nal_data);
60                 CDEBUG(D_INFO, "Local node id is [%d]\n", nid);
61                 GMNAL_GM_LOCK(nal_data);
62                 gm_status = gm_node_id_to_global_id(nal_data->gm_port, 
63                                                     nid, &gnid);
64                 GMNAL_GM_UNLOCK(nal_data);
65                 if (gm_status != GM_SUCCESS) {
66                         CDEBUG(D_INFO, "gm_node_id_to_global_id failed[%d]\n", 
67                                gm_status);
68                         return(-1);
69                 }
70                 CDEBUG(D_INFO, "Global node is is [%u][%x]\n", gnid, gnid);
71                 copy_to_user(pcfg->pcfg_pbuf2, &gnid, pcfg->pcfg_plen2);
72         break;
73         default:
74                 CDEBUG(D_INFO, "gmnal_cmd UNKNOWN[%d]\n", pcfg->pcfg_command);
75                 pcfg->pcfg_nid2 = -1;
76         }
77
78
79         return(0);
80 }
81
82
83 static int __init
84 gmnal_load(void)
85 {
86         int     status;
87         CDEBUG(D_TRACE, "This is the gmnal module initialisation routine\n");
88
89
90
91         CDEBUG(D_INFO, "Calling gmnal_init\n");
92         statud = gmnal_init();
93         if (status == PTL_OK) {
94                 CDEBUG(D_INFO, "Portals GMNAL initialised ok\n");
95         } else {
96                 CDEBUG(D_INFO, "Portals GMNAL Failed to initialise\n");
97                 return(-ENODEV);
98                 
99         }
100
101         CDEBUG(D_INFO, "This is the end of the gmnal init routine");
102
103
104         return(0);
105 }
106
107
108 static void __exit
109 gmnal_unload(void)
110 {
111         gmnal_fini();
112         return;
113 }
114
115
116 module_init(gmnal_load);
117
118 module_exit(gmnal_unload);
119
120 MODULE_PARM(gmnal_small_msg_size, "i");
121 MODULE_PARM(num_rx_threads, "i");
122 MODULE_PARM(num_stxds, "i");
123 MODULE_PARM(gm_port, "i");
124
125 MODULE_AUTHOR("Morgan Doyle");
126
127 MODULE_DESCRIPTION("A Portals kernel NAL for Myrinet GM.");
128
129 MODULE_LICENSE("GPL");