Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[fs/lustre-release.git] / lnet / lnet / lib-dispatch.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * lib/lib-dispatch.c
5  *
6  *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
7  *  Copyright (c) 2001-2002 Sandia National Laboratories
8  *
9  *   This file is part of Lustre, http://www.sf.net/projects/lustre/
10  *
11  *   Lustre is free software; you can redistribute it and/or
12  *   modify it under the terms of version 2 of the GNU General Public
13  *   License as published by the Free Software Foundation.
14  *
15  *   Lustre is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with Lustre; if not, write to the Free Software
22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 #define DEBUG_SUBSYSTEM S_PORTALS
26 #include <portals/lib-p30.h>
27 #include <portals/lib-dispatch.h>
28
29 typedef struct {
30         int (*fun) (nal_cb_t * nal, void *private, void *in, void *out);
31         char *name;
32 } dispatch_table_t;
33
34 static dispatch_table_t dispatch_table[] = {
35         [PTL_GETID] {do_PtlGetId, "PtlGetId"},
36         [PTL_NISTATUS] {do_PtlNIStatus, "PtlNIStatus"},
37         [PTL_NIDIST] {do_PtlNIDist, "PtlNIDist"},
38         [PTL_NIDEBUG] {do_PtlNIDebug, "PtlNIDebug"},
39         [PTL_MEATTACH] {do_PtlMEAttach, "PtlMEAttach"},
40         [PTL_MEINSERT] {do_PtlMEInsert, "PtlMEInsert"},
41         [PTL_MEUNLINK] {do_PtlMEUnlink, "PtlMEUnlink"},
42         [PTL_TBLDUMP] {do_PtlTblDump, "PtlTblDump"},
43         [PTL_MEDUMP] {do_PtlMEDump, "PtlMEDump"},
44         [PTL_MDATTACH] {do_PtlMDAttach, "PtlMDAttach"},
45         [PTL_MDBIND] {do_PtlMDBind, "PtlMDBind"},
46         [PTL_MDUPDATE] {do_PtlMDUpdate_internal, "PtlMDUpdate_internal"},
47         [PTL_MDUNLINK] {do_PtlMDUnlink, "PtlMDUnlink"},
48         [PTL_EQALLOC] {do_PtlEQAlloc_internal, "PtlEQAlloc_internal"},
49         [PTL_EQFREE] {do_PtlEQFree_internal, "PtlEQFree_internal"},
50         [PTL_PUT] {do_PtlPut, "PtlPut"},
51         [PTL_GET] {do_PtlGet, "PtlGet"},
52         [PTL_FAILNID] {do_PtlFailNid, "PtlFailNid"},
53         /*    */ {0, ""}
54 };
55
56 /*
57  * This really should be elsewhere, but lib-p30/dispatch.c is
58  * an automatically generated file.
59  */
60 void lib_dispatch(nal_cb_t * nal, void *private, int index, void *arg_block,
61                   void *ret_block)
62 {
63         lib_ni_t *ni = &nal->ni;
64
65         if (index < 0 || index > LIB_MAX_DISPATCH ||
66             !dispatch_table[index].fun) {
67                 CDEBUG(D_NET, LPU64": Invalid API call %d\n", ni->nid, index);
68                 return;
69         }
70
71         CDEBUG(D_NET, LPU64": API call %s (%d)\n", ni->nid,
72                dispatch_table[index].name, index);
73
74         dispatch_table[index].fun(nal, private, arg_block, ret_block);
75 }
76
77 char *dispatch_name(int index)
78 {
79         return dispatch_table[index].name;
80 }