aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/node.h')
-rw-r--r--net/tipc/node.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/net/tipc/node.h b/net/tipc/node.h
new file mode 100644
index 000000000000..1f616873a724
--- /dev/null
+++ b/net/tipc/node.h
@@ -0,0 +1,141 @@
1/*
2 * net/tipc/node.h: Include file for TIPC node management routines
3 *
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _TIPC_NODE_H
35#define _TIPC_NODE_H
36
37#include "node_subscr.h"
38#include "addr.h"
39#include "cluster.h"
40#include "bearer.h"
41
42/**
43 * struct node - TIPC node structure
44 * @addr: network address of node
45 * @lock: spinlock governing access to structure
46 * @owner: pointer to cluster that node belongs to
47 * @next: pointer to next node in sorted list of cluster's nodes
48 * @nsub: list of "node down" subscriptions monitoring node
49 * @active_links: pointers to active links to node
50 * @links: pointers to all links to node
51 * @link_cnt: number of links to node
52 * @permit_changeover: non-zero if node has redundant links to this system
53 * @routers: bitmap (used for multicluster communication)
54 * @last_router: (used for multicluster communication)
55 * @bclink: broadcast-related info
56 * @supported: non-zero if node supports TIPC b'cast capability
57 * @acked: sequence # of last outbound b'cast message acknowledged by node
58 * @last_in: sequence # of last in-sequence b'cast message received from node
59 * @gap_after: sequence # of last message not requiring a NAK request
60 * @gap_to: sequence # of last message requiring a NAK request
61 * @nack_sync: counter that determines when NAK requests should be sent
62 * @deferred_head: oldest OOS b'cast message received from node
63 * @deferred_tail: newest OOS b'cast message received from node
64 * @defragm: list of partially reassembled b'cast message fragments from node
65 */
66
67struct node {
68 u32 addr;
69 spinlock_t lock;
70 struct cluster *owner;
71 struct node *next;
72 struct list_head nsub;
73 struct link *active_links[2];
74 struct link *links[MAX_BEARERS];
75 int link_cnt;
76 int permit_changeover;
77 u32 routers[512/32];
78 int last_router;
79 struct {
80 int supported;
81 u32 acked;
82 u32 last_in;
83 u32 gap_after;
84 u32 gap_to;
85 u32 nack_sync;
86 struct sk_buff *deferred_head;
87 struct sk_buff *deferred_tail;
88 struct sk_buff *defragm;
89 } bclink;
90};
91
92extern struct node *nodes;
93extern u32 tipc_own_tag;
94
95struct node *node_create(u32 addr);
96void node_delete(struct node *n_ptr);
97struct node *node_attach_link(struct link *l_ptr);
98void node_detach_link(struct node *n_ptr, struct link *l_ptr);
99void node_link_down(struct node *n_ptr, struct link *l_ptr);
100void node_link_up(struct node *n_ptr, struct link *l_ptr);
101int node_has_active_links(struct node *n_ptr);
102int node_has_redundant_links(struct node *n_ptr);
103u32 node_select_router(struct node *n_ptr, u32 ref);
104struct node *node_select_next_hop(u32 addr, u32 selector);
105int node_is_up(struct node *n_ptr);
106void node_add_router(struct node *n_ptr, u32 router);
107void node_remove_router(struct node *n_ptr, u32 router);
108struct sk_buff *node_get_links(const void *req_tlv_area, int req_tlv_space);
109struct sk_buff *node_get_nodes(const void *req_tlv_area, int req_tlv_space);
110
111static inline struct node *node_find(u32 addr)
112{
113 if (likely(in_own_cluster(addr)))
114 return local_nodes[tipc_node(addr)];
115 else if (addr_domain_valid(addr)) {
116 struct cluster *c_ptr = cluster_find(addr);
117
118 if (c_ptr)
119 return c_ptr->nodes[tipc_node(addr)];
120 }
121 return 0;
122}
123
124static inline struct node *node_select(u32 addr, u32 selector)
125{
126 if (likely(in_own_cluster(addr)))
127 return local_nodes[tipc_node(addr)];
128 return node_select_next_hop(addr, selector);
129}
130
131static inline void node_lock(struct node *n_ptr)
132{
133 spin_lock_bh(&n_ptr->lock);
134}
135
136static inline void node_unlock(struct node *n_ptr)
137{
138 spin_unlock_bh(&n_ptr->lock);
139}
140
141#endif