1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2003 Los Alamos National Laboratory (LANL)
6 * This file is part of Lustre, http://www.lustre.org/
8 * This file is free software; you can redistribute it and/or
9 * modify it under the terms of version 2.1 of the GNU Lesser General
10 * Public 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 Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Portals; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <netinet/tcp.h>
30 #include <sys/ioctl.h>
35 #include <portals/api-support.h>
36 #include <portals/lib-types.h>
40 #define GMNAL_IOC_GET_GNID 1
42 * portals always uses unit 0
43 * Can this be configurable?
48 usage(char *prg, int h)
50 fprintf(stderr, "usage %s -n hostname | -l | -h\n", prg);
52 printf("\nGet Myrinet Global network ids for specified host\n"
53 "-l gets network id for local host\n");
58 u_getgmnid(char *name, int get_local_id)
60 struct gm_port *gm_port;
62 gm_status_t gm_status = GM_SUCCESS;
63 unsigned global_nid = 0, local_nid = 0; /* gm ids never 0 */
65 gm_status = gm_init();
66 if (gm_status != GM_SUCCESS) {
67 fprintf(stderr, "gm_init: %s\n", gm_strerror(gm_status));
71 gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id, "gmnalnid",
73 if (gm_status != GM_SUCCESS) {
74 int num_ports = gm_num_ports(gm_port);
76 /* Couldn't open port 2, try 4 ... num_ports */
77 for (gm_port_id = 4; gm_port_id < num_ports; gm_port_id++) {
78 gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id,
79 "gmnalnid", GM_API_VERSION);
80 if (gm_status == GM_SUCCESS)
84 if (gm_status != GM_SUCCESS) {
85 fprintf(stderr, "gm_open: %s\n",gm_strerror(gm_status));
94 gm_status = gm_host_name_to_node_id_ex(gm_port, 1000000, name,
96 if (gm_status != GM_SUCCESS) {
97 fprintf(stderr, "gm_host_name_to_node_id_ex: %s\n",
98 gm_strerror(gm_status));
105 gm_status = gm_node_id_to_global_id(gm_port, local_nid, &global_nid) ;
106 if (gm_status != GM_SUCCESS) {
107 fprintf(stderr, "gm_node_id_to_global_id: %s\n",
108 gm_strerror(gm_status));
118 int main(int argc, char **argv)
120 unsigned int nid = 0;
123 int get_local_id = 0;
125 while ((c = getopt(argc, argv, "n:lh")) != -1) {
151 if (!name && !get_local_id) {
156 nid = u_getgmnid(name, get_local_id);