Whamcloud - gitweb
b=2776
[fs/lustre-release.git] / lnet / lnet / api-init.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * api/api-init.c
5  * Initialization and global data for the p30 user side library
6  *
7  *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
8  *  Copyright (c) 2001-2002 Sandia National Laboratories
9  *
10  *   This file is part of Lustre, http://www.sf.net/projects/lustre/
11  *
12  *   Lustre is free software; you can redistribute it and/or
13  *   modify it under the terms of version 2 of the GNU General Public
14  *   License as published by the Free Software Foundation.
15  *
16  *   Lustre is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with Lustre; if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #include <portals/api-support.h>
27
28 int ptl_init;
29
30 int __p30_initialized;
31 int __p30_myr_initialized;
32 int __p30_ip_initialized;
33 ptl_handle_ni_t __myr_ni_handle;
34 ptl_handle_ni_t __ip_ni_handle;
35
36 int PtlInit(int *max_interfaces)
37 {
38         if (max_interfaces != NULL)
39                 *max_interfaces = NAL_ENUM_END_MARKER;
40
41         if (ptl_init)
42                 return PTL_OK;
43
44         LASSERT(!strcmp(ptl_err_str[PTL_MAX_ERRNO], "PTL_MAX_ERRNO"));
45
46         ptl_ni_init();
47         ptl_me_init();
48         ptl_eq_init();
49         ptl_init = 1;
50
51         return PTL_OK;
52 }
53
54
55 void PtlFini(void)
56 {
57
58         /* Reverse order of initialization */
59         ptl_eq_fini();
60         ptl_me_fini();
61         ptl_ni_fini();
62         ptl_init = 0;
63 }
64
65
66 void PtlSnprintHandle(char *str, int len, ptl_handle_any_t h)
67 {
68         snprintf(str, len, "0x%lx."LPX64, h.nal_idx, h.cookie);
69 }