diff options
Diffstat (limited to 'net/tipc/node.h')
-rw-r--r-- | net/tipc/node.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/net/tipc/node.h b/net/tipc/node.h index c510a2afcc67..02e4927216fa 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/node.h: Include file for TIPC node management routines | 2 | * net/tipc/node.h: Include file for TIPC node management routines |
3 | * | 3 | * |
4 | * Copyright (c) 2000-2006, Ericsson AB | 4 | * Copyright (c) 2000-2006, Ericsson AB |
5 | * Copyright (c) 2005, Wind River Systems | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -46,7 +46,8 @@ | |||
46 | * struct tipc_node - TIPC node structure | 46 | * struct tipc_node - TIPC node structure |
47 | * @addr: network address of node | 47 | * @addr: network address of node |
48 | * @lock: spinlock governing access to structure | 48 | * @lock: spinlock governing access to structure |
49 | * @next: pointer to next node in sorted list of cluster's nodes | 49 | * @hash: links to adjacent nodes in unsorted hash chain |
50 | * @list: links to adjacent nodes in sorted list of cluster's nodes | ||
50 | * @nsub: list of "node down" subscriptions monitoring node | 51 | * @nsub: list of "node down" subscriptions monitoring node |
51 | * @active_links: pointers to active links to node | 52 | * @active_links: pointers to active links to node |
52 | * @links: pointers to all links to node | 53 | * @links: pointers to all links to node |
@@ -69,7 +70,8 @@ | |||
69 | struct tipc_node { | 70 | struct tipc_node { |
70 | u32 addr; | 71 | u32 addr; |
71 | spinlock_t lock; | 72 | spinlock_t lock; |
72 | struct tipc_node *next; | 73 | struct hlist_node hash; |
74 | struct list_head list; | ||
73 | struct list_head nsub; | 75 | struct list_head nsub; |
74 | struct link *active_links[2]; | 76 | struct link *active_links[2]; |
75 | struct link *links[MAX_BEARERS]; | 77 | struct link *links[MAX_BEARERS]; |
@@ -90,8 +92,23 @@ struct tipc_node { | |||
90 | } bclink; | 92 | } bclink; |
91 | }; | 93 | }; |
92 | 94 | ||
95 | #define NODE_HTABLE_SIZE 512 | ||
96 | extern struct list_head tipc_node_list; | ||
97 | |||
98 | /* | ||
99 | * A trivial power-of-two bitmask technique is used for speed, since this | ||
100 | * operation is done for every incoming TIPC packet. The number of hash table | ||
101 | * entries has been chosen so that no hash chain exceeds 8 nodes and will | ||
102 | * usually be much smaller (typically only a single node). | ||
103 | */ | ||
104 | static inline unsigned int tipc_hashfn(u32 addr) | ||
105 | { | ||
106 | return addr & (NODE_HTABLE_SIZE - 1); | ||
107 | } | ||
108 | |||
93 | extern u32 tipc_own_tag; | 109 | extern u32 tipc_own_tag; |
94 | 110 | ||
111 | struct tipc_node *tipc_node_find(u32 addr); | ||
95 | struct tipc_node *tipc_node_create(u32 addr); | 112 | struct tipc_node *tipc_node_create(u32 addr); |
96 | void tipc_node_delete(struct tipc_node *n_ptr); | 113 | void tipc_node_delete(struct tipc_node *n_ptr); |
97 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr); | 114 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr); |
@@ -104,13 +121,6 @@ int tipc_node_is_up(struct tipc_node *n_ptr); | |||
104 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); | 121 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); |
105 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); | 122 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); |
106 | 123 | ||
107 | static inline struct tipc_node *tipc_node_find(u32 addr) | ||
108 | { | ||
109 | if (likely(in_own_cluster(addr))) | ||
110 | return tipc_nodes[tipc_node(addr)]; | ||
111 | return NULL; | ||
112 | } | ||
113 | |||
114 | static inline void tipc_node_lock(struct tipc_node *n_ptr) | 124 | static inline void tipc_node_lock(struct tipc_node *n_ptr) |
115 | { | 125 | { |
116 | spin_lock_bh(&n_ptr->lock); | 126 | spin_lock_bh(&n_ptr->lock); |