Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / portals / router / router.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Portals
7  *   http://sourceforge.net/projects/sandiaportals/
8  *
9  *   Portals is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Portals is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Portals; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #ifndef _KPTLROUTER_H
25 #define _KPTLROUTER_H
26 #ifndef EXPORT_SYMTAB
27 # define EXPORT_SYMTAB
28 #endif
29
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/mm.h>
34 #include <linux/string.h>
35 #include <linux/errno.h>
36 #include <linux/proc_fs.h>
37 #include <linux/init.h>
38
39 #define DEBUG_SUBSYSTEM S_PTLROUTER
40
41 #include <linux/kp30.h>
42 #include <portals/p30.h>
43 #include <portals/lib-p30.h>
44
45 typedef struct
46 {
47         struct list_head        kpne_list;
48         kpr_nal_interface_t     kpne_interface;
49         atomic_t                kpne_refcount;
50         int                     kpne_shutdown;
51 } kpr_nal_entry_t;
52
53 typedef struct
54 {
55         struct list_head        kpge_list;
56         atomic_t                kpge_weight;
57         time_t                  kpge_timestamp;
58         int                     kpge_alive;
59         int                     kpge_nalid;
60         int                     kpge_refcount;
61         ptl_nid_t               kpge_nid;
62 } kpr_gateway_entry_t;
63
64 typedef struct
65 {
66         struct list_head        kpre_list;
67         kpr_gateway_entry_t    *kpre_gateway;
68         ptl_nid_t               kpre_lo_nid;
69         ptl_nid_t               kpre_hi_nid;
70 } kpr_route_entry_t;
71
72 typedef struct
73 {
74         work_struct_t           kpru_tq;
75         int                     kpru_nal_id;
76         ptl_nid_t               kpru_nid;
77         int                     kpru_alive;
78         time_t                  kpru_when;
79 } kpr_upcall_t;
80
81 extern int kpr_register_nal (kpr_nal_interface_t *nalif, void **argp);
82 extern int kpr_lookup_target (void *arg, ptl_nid_t target_nid, int nob, 
83                               ptl_nid_t *gateway_nidp);
84 extern kpr_nal_entry_t *kpr_find_nal_entry_locked (int nal_id);
85 extern void kpr_forward_packet (void *arg, kpr_fwd_desc_t *fwd);
86 extern void kpr_complete_packet (void *arg, kpr_fwd_desc_t *fwd, int error);
87 extern void kpr_nal_notify (void *arg, ptl_nid_t peer,
88                             int alive, time_t when);
89 extern void kpr_shutdown_nal (void *arg);
90 extern void kpr_deregister_nal (void *arg);
91
92 extern void kpr_proc_init (void);
93 extern void kpr_proc_fini (void);
94
95 extern int kpr_add_route (int gateway_nal, ptl_nid_t gateway_nid, 
96                           ptl_nid_t lo_nid, ptl_nid_t hi_nid);
97 extern int kpr_del_route (int gw_nal, ptl_nid_t gw_nid,
98                           ptl_nid_t lo, ptl_nid_t hi);
99 extern int kpr_get_route (int idx, int *gateway_nal, ptl_nid_t *gateway_nid, 
100                           ptl_nid_t *lo_nid, ptl_nid_t *hi_nid, int *alive);
101 extern int kpr_sys_notify (int gw_nalid, ptl_nid_t gw_nid,
102                            int alive, time_t when);
103
104 extern unsigned long long kpr_fwd_bytes;
105 extern unsigned long      kpr_fwd_packets;
106 extern unsigned long      kpr_fwd_errors;
107 extern atomic_t           kpr_queue_depth;
108
109 #endif /* _KPLROUTER_H */