diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2015-07-16 16:54:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-07-20 23:41:14 -0400 |
commit | 9d13ec65ede775f896c3da1cfa35283afe2f796c (patch) | |
tree | 34ac0c21607481a2377b3201c3fe58c3f6ac7947 /net/tipc/node.h | |
parent | 6acc23266054a9969737b435fa012f87465dbc50 (diff) |
tipc: introduce link entry structure to struct tipc_node
struct 'tipc_node' currently contains two arrays for link attributes,
one for the link pointers, and one for the usable link MTUs.
We now group those into a new struct 'tipc_link_entry', and intoduce
one single array consisting of such enties. Apart from being a cosmetic
improvement, this is a starting point for the strict master-slave
relation between node and link that we will introduce in the following
commits.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.h')
-rw-r--r-- | net/tipc/node.h | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/net/tipc/node.h b/net/tipc/node.h index 5a834cf142c8..320cea313bdc 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -89,6 +89,11 @@ struct tipc_node_bclink { | |||
89 | bool recv_permitted; | 89 | bool recv_permitted; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | struct tipc_link_entry { | ||
93 | struct tipc_link *link; | ||
94 | u32 mtu; | ||
95 | }; | ||
96 | |||
92 | /** | 97 | /** |
93 | * struct tipc_node - TIPC node structure | 98 | * struct tipc_node - TIPC node structure |
94 | * @addr: network address of node | 99 | * @addr: network address of node |
@@ -98,9 +103,8 @@ struct tipc_node_bclink { | |||
98 | * @hash: links to adjacent nodes in unsorted hash chain | 103 | * @hash: links to adjacent nodes in unsorted hash chain |
99 | * @inputq: pointer to input queue containing messages for msg event | 104 | * @inputq: pointer to input queue containing messages for msg event |
100 | * @namedq: pointer to name table input queue with name table messages | 105 | * @namedq: pointer to name table input queue with name table messages |
101 | * @curr_link: the link holding the node lock, if any | 106 | * @active_links: pointer into links[] array, identifying which links are active |
102 | * @active_links: pointers to active links to node | 107 | * @links: array containing references to all links to node |
103 | * @links: pointers to all links to node | ||
104 | * @action_flags: bit mask of different types of node actions | 108 | * @action_flags: bit mask of different types of node actions |
105 | * @bclink: broadcast-related info | 109 | * @bclink: broadcast-related info |
106 | * @list: links to adjacent nodes in sorted list of cluster's nodes | 110 | * @list: links to adjacent nodes in sorted list of cluster's nodes |
@@ -120,9 +124,8 @@ struct tipc_node { | |||
120 | struct hlist_node hash; | 124 | struct hlist_node hash; |
121 | struct sk_buff_head *inputq; | 125 | struct sk_buff_head *inputq; |
122 | struct sk_buff_head *namedq; | 126 | struct sk_buff_head *namedq; |
123 | struct tipc_link *active_links[2]; | 127 | struct tipc_link_entry *active_links[2]; |
124 | u32 act_mtus[2]; | 128 | struct tipc_link_entry links[MAX_BEARERS]; |
125 | struct tipc_link *links[MAX_BEARERS]; | ||
126 | int action_flags; | 129 | int action_flags; |
127 | struct tipc_node_bclink bclink; | 130 | struct tipc_node_bclink bclink; |
128 | struct list_head list; | 131 | struct list_head list; |
@@ -142,10 +145,9 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr); | |||
142 | void tipc_node_stop(struct net *net); | 145 | void tipc_node_stop(struct net *net); |
143 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 146 | void tipc_node_attach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
144 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 147 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr); |
145 | void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 148 | void tipc_node_link_down(struct tipc_node *n_ptr, int bearer_id); |
146 | void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr); | 149 | void tipc_node_link_up(struct tipc_node *n_ptr, int bearer_id); |
147 | int tipc_node_active_links(struct tipc_node *n_ptr); | 150 | bool tipc_node_is_up(struct tipc_node *n); |
148 | int tipc_node_is_up(struct tipc_node *n_ptr); | ||
149 | int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node, | 151 | int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node, |
150 | char *linkname, size_t len); | 152 | char *linkname, size_t len); |
151 | void tipc_node_unlock(struct tipc_node *node); | 153 | void tipc_node_unlock(struct tipc_node *node); |
@@ -165,20 +167,28 @@ static inline bool tipc_node_blocked(struct tipc_node *node) | |||
165 | TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); | 167 | TIPC_NOTIFY_NODE_DOWN | TIPC_WAIT_OWN_LINKS_DOWN)); |
166 | } | 168 | } |
167 | 169 | ||
168 | static inline uint tipc_node_get_mtu(struct net *net, u32 addr, u32 selector) | 170 | static inline struct tipc_link *node_active_link(struct tipc_node *n, int sel) |
169 | { | 171 | { |
170 | struct tipc_node *node; | 172 | struct tipc_link_entry *le = n->active_links[sel & 1]; |
171 | u32 mtu; | ||
172 | 173 | ||
173 | node = tipc_node_find(net, addr); | 174 | if (likely(le)) |
175 | return le->link; | ||
176 | return NULL; | ||
177 | } | ||
174 | 178 | ||
175 | if (likely(node)) { | 179 | static inline uint tipc_node_get_mtu(struct net *net, u32 addr, u32 selector) |
176 | mtu = node->act_mtus[selector & 1]; | 180 | { |
177 | tipc_node_put(node); | 181 | struct tipc_node *n; |
178 | } else { | 182 | struct tipc_link_entry *le; |
179 | mtu = MAX_MSG_SIZE; | 183 | unsigned int mtu = MAX_MSG_SIZE; |
180 | } | ||
181 | 184 | ||
185 | n = tipc_node_find(net, addr); | ||
186 | if (unlikely(!n)) | ||
187 | return mtu; | ||
188 | le = n->active_links[selector & 1]; | ||
189 | if (likely(le)) | ||
190 | mtu = le->mtu; | ||
191 | tipc_node_put(n); | ||
182 | return mtu; | 192 | return mtu; |
183 | } | 193 | } |
184 | 194 | ||