Whamcloud - gitweb
landing b_cmobd_merge on HEAD
[fs/lustre-release.git] / lustre / portals / portals / 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_MEATTACH] {do_PtlMEAttach, "PtlMEAttach"},
39         [PTL_MEINSERT] {do_PtlMEInsert, "PtlMEInsert"},
40         [PTL_MEUNLINK] {do_PtlMEUnlink, "PtlMEUnlink"},
41         [PTL_TBLDUMP] {do_PtlTblDump, "PtlTblDump"},
42         [PTL_MEDUMP] {do_PtlMEDump, "PtlMEDump"},
43         [PTL_MDATTACH] {do_PtlMDAttach, "PtlMDAttach"},
44         [PTL_MDBIND] {do_PtlMDBind, "PtlMDBind"},
45         [PTL_MDUPDATE] {do_PtlMDUpdate_internal, "PtlMDUpdate_internal"},
46         [PTL_MDUNLINK] {do_PtlMDUnlink, "PtlMDUnlink"},
47         [PTL_EQALLOC] {do_PtlEQAlloc_internal, "PtlEQAlloc_internal"},
48         [PTL_EQFREE] {do_PtlEQFree_internal, "PtlEQFree_internal"},
49         [PTL_PUT] {do_PtlPut, "PtlPut"},
50         [PTL_GET] {do_PtlGet, "PtlGet"},
51         [PTL_FAILNID] {do_PtlFailNid, "PtlFailNid"},
52         /*    */ {0, ""}
53 };
54
55 /*
56  * This really should be elsewhere, but lib-p30/dispatch.c is
57  * an automatically generated file.
58  */
59 void lib_dispatch(nal_cb_t * nal, void *private, int index, void *arg_block,
60                   void *ret_block)
61 {
62         lib_ni_t *ni = &nal->ni;
63
64         if (index < 0 || index > LIB_MAX_DISPATCH ||
65             !dispatch_table[index].fun) {
66                 CDEBUG(D_NET, LPU64": Invalid API call %d\n", ni->nid, index);
67                 return;
68         }
69
70         CDEBUG(D_NET, LPU64": API call %s (%d)\n", ni->nid,
71                dispatch_table[index].name, index);
72
73         dispatch_table[index].fun(nal, private, arg_block, ret_block);
74 }
75
76 char *dispatch_name(int index)
77 {
78         return dispatch_table[index].name;
79 }