diff options
Diffstat (limited to 'net/tipc/port.h')
-rw-r--r-- | net/tipc/port.h | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/net/tipc/port.h b/net/tipc/port.h index 8e84b989949c..f8722afb2bc5 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/port.h: Include file for TIPC port code | 2 | * net/tipc/port.h: Include file for TIPC port code |
3 | * | 3 | * |
4 | * Copyright (c) 1994-2007, Ericsson AB | 4 | * Copyright (c) 1994-2007, Ericsson AB |
5 | * Copyright (c) 2004-2007, Wind River Systems | 5 | * Copyright (c) 2004-2007, 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 |
@@ -95,7 +95,7 @@ struct user_port { | |||
95 | }; | 95 | }; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * struct tipc_port - TIPC port info available to socket API | 98 | * struct tipc_port - TIPC port structure |
99 | * @usr_handle: pointer to additional user-defined information about port | 99 | * @usr_handle: pointer to additional user-defined information about port |
100 | * @lock: pointer to spinlock for controlling access to port | 100 | * @lock: pointer to spinlock for controlling access to port |
101 | * @connected: non-zero if port is currently connected to a peer port | 101 | * @connected: non-zero if port is currently connected to a peer port |
@@ -107,24 +107,6 @@ struct user_port { | |||
107 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | 107 | * @max_pkt: maximum packet size "hint" used when building messages sent by port |
108 | * @ref: unique reference to port in TIPC object registry | 108 | * @ref: unique reference to port in TIPC object registry |
109 | * @phdr: preformatted message header used when sending messages | 109 | * @phdr: preformatted message header used when sending messages |
110 | */ | ||
111 | struct tipc_port { | ||
112 | void *usr_handle; | ||
113 | spinlock_t *lock; | ||
114 | int connected; | ||
115 | u32 conn_type; | ||
116 | u32 conn_instance; | ||
117 | u32 conn_unacked; | ||
118 | int published; | ||
119 | u32 congested; | ||
120 | u32 max_pkt; | ||
121 | u32 ref; | ||
122 | struct tipc_msg phdr; | ||
123 | }; | ||
124 | |||
125 | /** | ||
126 | * struct port - TIPC port structure | ||
127 | * @publ: TIPC port info available to privileged users | ||
128 | * @port_list: adjacent ports in TIPC's global list of ports | 110 | * @port_list: adjacent ports in TIPC's global list of ports |
129 | * @dispatcher: ptr to routine which handles received messages | 111 | * @dispatcher: ptr to routine which handles received messages |
130 | * @wakeup: ptr to routine to call when port is no longer congested | 112 | * @wakeup: ptr to routine to call when port is no longer congested |
@@ -141,9 +123,18 @@ struct tipc_port { | |||
141 | * @timer_ref: | 123 | * @timer_ref: |
142 | * @subscription: "node down" subscription used to terminate failed connections | 124 | * @subscription: "node down" subscription used to terminate failed connections |
143 | */ | 125 | */ |
144 | 126 | struct tipc_port { | |
145 | struct port { | 127 | void *usr_handle; |
146 | struct tipc_port publ; | 128 | spinlock_t *lock; |
129 | int connected; | ||
130 | u32 conn_type; | ||
131 | u32 conn_instance; | ||
132 | u32 conn_unacked; | ||
133 | int published; | ||
134 | u32 congested; | ||
135 | u32 max_pkt; | ||
136 | u32 ref; | ||
137 | struct tipc_msg phdr; | ||
147 | struct list_head port_list; | 138 | struct list_head port_list; |
148 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); | 139 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); |
149 | void (*wakeup)(struct tipc_port *); | 140 | void (*wakeup)(struct tipc_port *); |
@@ -230,7 +221,7 @@ int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest, | |||
230 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, | 221 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, |
231 | unsigned int section_count, struct iovec const *msg); | 222 | unsigned int section_count, struct iovec const *msg); |
232 | 223 | ||
233 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | 224 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
234 | struct iovec const *msg_sect, u32 num_sect, | 225 | struct iovec const *msg_sect, u32 num_sect, |
235 | int err); | 226 | int err); |
236 | struct sk_buff *tipc_port_get_ports(void); | 227 | struct sk_buff *tipc_port_get_ports(void); |
@@ -242,9 +233,9 @@ void tipc_port_reinit(void); | |||
242 | * tipc_port_lock - lock port instance referred to and return its pointer | 233 | * tipc_port_lock - lock port instance referred to and return its pointer |
243 | */ | 234 | */ |
244 | 235 | ||
245 | static inline struct port *tipc_port_lock(u32 ref) | 236 | static inline struct tipc_port *tipc_port_lock(u32 ref) |
246 | { | 237 | { |
247 | return (struct port *)tipc_ref_lock(ref); | 238 | return (struct tipc_port *)tipc_ref_lock(ref); |
248 | } | 239 | } |
249 | 240 | ||
250 | /** | 241 | /** |
@@ -253,27 +244,27 @@ static inline struct port *tipc_port_lock(u32 ref) | |||
253 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. | 244 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. |
254 | */ | 245 | */ |
255 | 246 | ||
256 | static inline void tipc_port_unlock(struct port *p_ptr) | 247 | static inline void tipc_port_unlock(struct tipc_port *p_ptr) |
257 | { | 248 | { |
258 | spin_unlock_bh(p_ptr->publ.lock); | 249 | spin_unlock_bh(p_ptr->lock); |
259 | } | 250 | } |
260 | 251 | ||
261 | static inline struct port *tipc_port_deref(u32 ref) | 252 | static inline struct tipc_port *tipc_port_deref(u32 ref) |
262 | { | 253 | { |
263 | return (struct port *)tipc_ref_deref(ref); | 254 | return (struct tipc_port *)tipc_ref_deref(ref); |
264 | } | 255 | } |
265 | 256 | ||
266 | static inline u32 tipc_peer_port(struct port *p_ptr) | 257 | static inline u32 tipc_peer_port(struct tipc_port *p_ptr) |
267 | { | 258 | { |
268 | return msg_destport(&p_ptr->publ.phdr); | 259 | return msg_destport(&p_ptr->phdr); |
269 | } | 260 | } |
270 | 261 | ||
271 | static inline u32 tipc_peer_node(struct port *p_ptr) | 262 | static inline u32 tipc_peer_node(struct tipc_port *p_ptr) |
272 | { | 263 | { |
273 | return msg_destnode(&p_ptr->publ.phdr); | 264 | return msg_destnode(&p_ptr->phdr); |
274 | } | 265 | } |
275 | 266 | ||
276 | static inline int tipc_port_congested(struct port *p_ptr) | 267 | static inline int tipc_port_congested(struct tipc_port *p_ptr) |
277 | { | 268 | { |
278 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); | 269 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); |
279 | } | 270 | } |
@@ -284,7 +275,7 @@ static inline int tipc_port_congested(struct port *p_ptr) | |||
284 | 275 | ||
285 | static inline int tipc_port_recv_msg(struct sk_buff *buf) | 276 | static inline int tipc_port_recv_msg(struct sk_buff *buf) |
286 | { | 277 | { |
287 | struct port *p_ptr; | 278 | struct tipc_port *p_ptr; |
288 | struct tipc_msg *msg = buf_msg(buf); | 279 | struct tipc_msg *msg = buf_msg(buf); |
289 | u32 destport = msg_destport(msg); | 280 | u32 destport = msg_destport(msg); |
290 | u32 dsz = msg_data_sz(msg); | 281 | u32 dsz = msg_data_sz(msg); |
@@ -299,7 +290,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) | |||
299 | /* validate destination & pass to port, otherwise reject message */ | 290 | /* validate destination & pass to port, otherwise reject message */ |
300 | p_ptr = tipc_port_lock(destport); | 291 | p_ptr = tipc_port_lock(destport); |
301 | if (likely(p_ptr)) { | 292 | if (likely(p_ptr)) { |
302 | if (likely(p_ptr->publ.connected)) { | 293 | if (likely(p_ptr->connected)) { |
303 | if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || | 294 | if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || |
304 | (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || | 295 | (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || |
305 | (unlikely(!msg_connected(msg)))) { | 296 | (unlikely(!msg_connected(msg)))) { |
@@ -308,7 +299,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) | |||
308 | goto reject; | 299 | goto reject; |
309 | } | 300 | } |
310 | } | 301 | } |
311 | err = p_ptr->dispatcher(&p_ptr->publ, buf); | 302 | err = p_ptr->dispatcher(p_ptr, buf); |
312 | tipc_port_unlock(p_ptr); | 303 | tipc_port_unlock(p_ptr); |
313 | if (likely(!err)) | 304 | if (likely(!err)) |
314 | return dsz; | 305 | return dsz; |