diff options
Diffstat (limited to 'net/tipc/port.h')
| -rw-r--r-- | net/tipc/port.h | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/net/tipc/port.h b/net/tipc/port.h index 8e84b989949c..87b9424ae0ec 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,43 +107,33 @@ 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 |
| 131 | * @user_port: ptr to user port associated with port (if any) | 113 | * @user_port: ptr to user port associated with port (if any) |
| 132 | * @wait_list: adjacent ports in list of ports waiting on link congestion | 114 | * @wait_list: adjacent ports in list of ports waiting on link congestion |
| 133 | * @waiting_pkts: | 115 | * @waiting_pkts: |
| 134 | * @sent: | 116 | * @sent: # of non-empty messages sent by port |
| 135 | * @acked: | 117 | * @acked: # of non-empty message acknowledgements from connected port's peer |
| 136 | * @publications: list of publications for port | 118 | * @publications: list of publications for port |
| 137 | * @pub_count: total # of publications port has made during its lifetime | 119 | * @pub_count: total # of publications port has made during its lifetime |
| 138 | * @probing_state: | 120 | * @probing_state: |
| 139 | * @probing_interval: | 121 | * @probing_interval: |
| 140 | * @last_in_seqno: | ||
| 141 | * @timer_ref: | 122 | * @timer_ref: |
| 142 | * @subscription: "node down" subscription used to terminate failed connections | 123 | * @subscription: "node down" subscription used to terminate failed connections |
| 143 | */ | 124 | */ |
| 144 | 125 | struct tipc_port { | |
| 145 | struct port { | 126 | void *usr_handle; |
| 146 | struct tipc_port publ; | 127 | spinlock_t *lock; |
| 128 | int connected; | ||
| 129 | u32 conn_type; | ||
| 130 | u32 conn_instance; | ||
| 131 | u32 conn_unacked; | ||
| 132 | int published; | ||
| 133 | u32 congested; | ||
| 134 | u32 max_pkt; | ||
| 135 | u32 ref; | ||
| 136 | struct tipc_msg phdr; | ||
| 147 | struct list_head port_list; | 137 | struct list_head port_list; |
| 148 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); | 138 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); |
| 149 | void (*wakeup)(struct tipc_port *); | 139 | void (*wakeup)(struct tipc_port *); |
| @@ -156,7 +146,6 @@ struct port { | |||
| 156 | u32 pub_count; | 146 | u32 pub_count; |
| 157 | u32 probing_state; | 147 | u32 probing_state; |
| 158 | u32 probing_interval; | 148 | u32 probing_interval; |
| 159 | u32 last_in_seqno; | ||
| 160 | struct timer_list timer; | 149 | struct timer_list timer; |
| 161 | struct tipc_node_subscr subscription; | 150 | struct tipc_node_subscr subscription; |
| 162 | }; | 151 | }; |
| @@ -230,7 +219,7 @@ int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest, | |||
| 230 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, | 219 | int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, |
| 231 | unsigned int section_count, struct iovec const *msg); | 220 | unsigned int section_count, struct iovec const *msg); |
| 232 | 221 | ||
| 233 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | 222 | int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr, |
| 234 | struct iovec const *msg_sect, u32 num_sect, | 223 | struct iovec const *msg_sect, u32 num_sect, |
| 235 | int err); | 224 | int err); |
| 236 | struct sk_buff *tipc_port_get_ports(void); | 225 | struct sk_buff *tipc_port_get_ports(void); |
| @@ -242,9 +231,9 @@ void tipc_port_reinit(void); | |||
| 242 | * tipc_port_lock - lock port instance referred to and return its pointer | 231 | * tipc_port_lock - lock port instance referred to and return its pointer |
| 243 | */ | 232 | */ |
| 244 | 233 | ||
| 245 | static inline struct port *tipc_port_lock(u32 ref) | 234 | static inline struct tipc_port *tipc_port_lock(u32 ref) |
| 246 | { | 235 | { |
| 247 | return (struct port *)tipc_ref_lock(ref); | 236 | return (struct tipc_port *)tipc_ref_lock(ref); |
| 248 | } | 237 | } |
| 249 | 238 | ||
| 250 | /** | 239 | /** |
| @@ -253,27 +242,27 @@ static inline struct port *tipc_port_lock(u32 ref) | |||
| 253 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. | 242 | * Can use pointer instead of tipc_ref_unlock() since port is already locked. |
| 254 | */ | 243 | */ |
| 255 | 244 | ||
| 256 | static inline void tipc_port_unlock(struct port *p_ptr) | 245 | static inline void tipc_port_unlock(struct tipc_port *p_ptr) |
| 257 | { | 246 | { |
| 258 | spin_unlock_bh(p_ptr->publ.lock); | 247 | spin_unlock_bh(p_ptr->lock); |
| 259 | } | 248 | } |
| 260 | 249 | ||
| 261 | static inline struct port *tipc_port_deref(u32 ref) | 250 | static inline struct tipc_port *tipc_port_deref(u32 ref) |
| 262 | { | 251 | { |
| 263 | return (struct port *)tipc_ref_deref(ref); | 252 | return (struct tipc_port *)tipc_ref_deref(ref); |
| 264 | } | 253 | } |
| 265 | 254 | ||
| 266 | static inline u32 tipc_peer_port(struct port *p_ptr) | 255 | static inline u32 tipc_peer_port(struct tipc_port *p_ptr) |
| 267 | { | 256 | { |
| 268 | return msg_destport(&p_ptr->publ.phdr); | 257 | return msg_destport(&p_ptr->phdr); |
| 269 | } | 258 | } |
| 270 | 259 | ||
| 271 | static inline u32 tipc_peer_node(struct port *p_ptr) | 260 | static inline u32 tipc_peer_node(struct tipc_port *p_ptr) |
| 272 | { | 261 | { |
| 273 | return msg_destnode(&p_ptr->publ.phdr); | 262 | return msg_destnode(&p_ptr->phdr); |
| 274 | } | 263 | } |
| 275 | 264 | ||
| 276 | static inline int tipc_port_congested(struct port *p_ptr) | 265 | static inline int tipc_port_congested(struct tipc_port *p_ptr) |
| 277 | { | 266 | { |
| 278 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); | 267 | return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); |
| 279 | } | 268 | } |
| @@ -284,7 +273,7 @@ static inline int tipc_port_congested(struct port *p_ptr) | |||
| 284 | 273 | ||
| 285 | static inline int tipc_port_recv_msg(struct sk_buff *buf) | 274 | static inline int tipc_port_recv_msg(struct sk_buff *buf) |
| 286 | { | 275 | { |
| 287 | struct port *p_ptr; | 276 | struct tipc_port *p_ptr; |
| 288 | struct tipc_msg *msg = buf_msg(buf); | 277 | struct tipc_msg *msg = buf_msg(buf); |
| 289 | u32 destport = msg_destport(msg); | 278 | u32 destport = msg_destport(msg); |
| 290 | u32 dsz = msg_data_sz(msg); | 279 | u32 dsz = msg_data_sz(msg); |
| @@ -299,7 +288,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 299 | /* validate destination & pass to port, otherwise reject message */ | 288 | /* validate destination & pass to port, otherwise reject message */ |
| 300 | p_ptr = tipc_port_lock(destport); | 289 | p_ptr = tipc_port_lock(destport); |
| 301 | if (likely(p_ptr)) { | 290 | if (likely(p_ptr)) { |
| 302 | if (likely(p_ptr->publ.connected)) { | 291 | if (likely(p_ptr->connected)) { |
| 303 | if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || | 292 | if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || |
| 304 | (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || | 293 | (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || |
| 305 | (unlikely(!msg_connected(msg)))) { | 294 | (unlikely(!msg_connected(msg)))) { |
| @@ -308,7 +297,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) | |||
| 308 | goto reject; | 297 | goto reject; |
| 309 | } | 298 | } |
| 310 | } | 299 | } |
| 311 | err = p_ptr->dispatcher(&p_ptr->publ, buf); | 300 | err = p_ptr->dispatcher(p_ptr, buf); |
| 312 | tipc_port_unlock(p_ptr); | 301 | tipc_port_unlock(p_ptr); |
| 313 | if (likely(!err)) | 302 | if (likely(!err)) |
| 314 | return dsz; | 303 | return dsz; |
