aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/tipc/link.c46
-rw-r--r--net/tipc/link.h6
-rw-r--r--net/tipc/port.c234
-rw-r--r--net/tipc/port.h67
-rw-r--r--net/tipc/subscr.c6
5 files changed, 175 insertions, 184 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 18702f58d111..e30770d007f5 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2,7 +2,7 @@
2 * net/tipc/link.c: TIPC link code 2 * net/tipc/link.c: TIPC link code
3 * 3 *
4 * Copyright (c) 1996-2007, Ericsson AB 4 * Copyright (c) 1996-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
@@ -90,7 +90,7 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
90static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf); 90static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf);
91static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf); 91static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf);
92static void link_set_supervision_props(struct link *l_ptr, u32 tolerance); 92static void link_set_supervision_props(struct link *l_ptr, u32 tolerance);
93static int link_send_sections_long(struct port *sender, 93static int link_send_sections_long(struct tipc_port *sender,
94 struct iovec const *msg_sect, 94 struct iovec const *msg_sect,
95 u32 num_sect, u32 destnode); 95 u32 num_sect, u32 destnode);
96static void link_check_defragm_bufs(struct link *l_ptr); 96static void link_check_defragm_bufs(struct link *l_ptr);
@@ -406,7 +406,7 @@ static void link_start(struct link *l_ptr)
406 406
407static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) 407static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
408{ 408{
409 struct port *p_ptr; 409 struct tipc_port *p_ptr;
410 410
411 spin_lock_bh(&tipc_port_list_lock); 411 spin_lock_bh(&tipc_port_list_lock);
412 p_ptr = tipc_port_lock(origport); 412 p_ptr = tipc_port_lock(origport);
@@ -415,7 +415,7 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
415 goto exit; 415 goto exit;
416 if (!list_empty(&p_ptr->wait_list)) 416 if (!list_empty(&p_ptr->wait_list))
417 goto exit; 417 goto exit;
418 p_ptr->publ.congested = 1; 418 p_ptr->congested = 1;
419 p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt); 419 p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt);
420 list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports); 420 list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports);
421 l_ptr->stats.link_congs++; 421 l_ptr->stats.link_congs++;
@@ -428,8 +428,8 @@ exit:
428 428
429void tipc_link_wakeup_ports(struct link *l_ptr, int all) 429void tipc_link_wakeup_ports(struct link *l_ptr, int all)
430{ 430{
431 struct port *p_ptr; 431 struct tipc_port *p_ptr;
432 struct port *temp_p_ptr; 432 struct tipc_port *temp_p_ptr;
433 int win = l_ptr->queue_limit[0] - l_ptr->out_queue_size; 433 int win = l_ptr->queue_limit[0] - l_ptr->out_queue_size;
434 434
435 if (all) 435 if (all)
@@ -445,11 +445,11 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
445 if (win <= 0) 445 if (win <= 0)
446 break; 446 break;
447 list_del_init(&p_ptr->wait_list); 447 list_del_init(&p_ptr->wait_list);
448 spin_lock_bh(p_ptr->publ.lock); 448 spin_lock_bh(p_ptr->lock);
449 p_ptr->publ.congested = 0; 449 p_ptr->congested = 0;
450 p_ptr->wakeup(&p_ptr->publ); 450 p_ptr->wakeup(p_ptr);
451 win -= p_ptr->waiting_pkts; 451 win -= p_ptr->waiting_pkts;
452 spin_unlock_bh(p_ptr->publ.lock); 452 spin_unlock_bh(p_ptr->lock);
453 } 453 }
454 454
455exit: 455exit:
@@ -1027,12 +1027,12 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
1027 * except for total message length. 1027 * except for total message length.
1028 * Returns user data length or errno. 1028 * Returns user data length or errno.
1029 */ 1029 */
1030int tipc_link_send_sections_fast(struct port *sender, 1030int tipc_link_send_sections_fast(struct tipc_port *sender,
1031 struct iovec const *msg_sect, 1031 struct iovec const *msg_sect,
1032 const u32 num_sect, 1032 const u32 num_sect,
1033 u32 destaddr) 1033 u32 destaddr)
1034{ 1034{
1035 struct tipc_msg *hdr = &sender->publ.phdr; 1035 struct tipc_msg *hdr = &sender->phdr;
1036 struct link *l_ptr; 1036 struct link *l_ptr;
1037 struct sk_buff *buf; 1037 struct sk_buff *buf;
1038 struct tipc_node *node; 1038 struct tipc_node *node;
@@ -1045,7 +1045,7 @@ again:
1045 * (Must not hold any locks while building message.) 1045 * (Must not hold any locks while building message.)
1046 */ 1046 */
1047 1047
1048 res = tipc_msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, 1048 res = tipc_msg_build(hdr, msg_sect, num_sect, sender->max_pkt,
1049 !sender->user_port, &buf); 1049 !sender->user_port, &buf);
1050 1050
1051 read_lock_bh(&tipc_net_lock); 1051 read_lock_bh(&tipc_net_lock);
@@ -1056,7 +1056,7 @@ again:
1056 if (likely(l_ptr)) { 1056 if (likely(l_ptr)) {
1057 if (likely(buf)) { 1057 if (likely(buf)) {
1058 res = link_send_buf_fast(l_ptr, buf, 1058 res = link_send_buf_fast(l_ptr, buf,
1059 &sender->publ.max_pkt); 1059 &sender->max_pkt);
1060 if (unlikely(res < 0)) 1060 if (unlikely(res < 0))
1061 buf_discard(buf); 1061 buf_discard(buf);
1062exit: 1062exit:
@@ -1075,7 +1075,7 @@ exit:
1075 if (link_congested(l_ptr) || 1075 if (link_congested(l_ptr) ||
1076 !list_empty(&l_ptr->b_ptr->cong_links)) { 1076 !list_empty(&l_ptr->b_ptr->cong_links)) {
1077 res = link_schedule_port(l_ptr, 1077 res = link_schedule_port(l_ptr,
1078 sender->publ.ref, res); 1078 sender->ref, res);
1079 goto exit; 1079 goto exit;
1080 } 1080 }
1081 1081
@@ -1084,12 +1084,12 @@ exit:
1084 * then re-try fast path or fragment the message 1084 * then re-try fast path or fragment the message
1085 */ 1085 */
1086 1086
1087 sender->publ.max_pkt = l_ptr->max_pkt; 1087 sender->max_pkt = l_ptr->max_pkt;
1088 tipc_node_unlock(node); 1088 tipc_node_unlock(node);
1089 read_unlock_bh(&tipc_net_lock); 1089 read_unlock_bh(&tipc_net_lock);
1090 1090
1091 1091
1092 if ((msg_hdr_sz(hdr) + res) <= sender->publ.max_pkt) 1092 if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt)
1093 goto again; 1093 goto again;
1094 1094
1095 return link_send_sections_long(sender, msg_sect, 1095 return link_send_sections_long(sender, msg_sect,
@@ -1123,14 +1123,14 @@ exit:
1123 * 1123 *
1124 * Returns user data length or errno. 1124 * Returns user data length or errno.
1125 */ 1125 */
1126static int link_send_sections_long(struct port *sender, 1126static int link_send_sections_long(struct tipc_port *sender,
1127 struct iovec const *msg_sect, 1127 struct iovec const *msg_sect,
1128 u32 num_sect, 1128 u32 num_sect,
1129 u32 destaddr) 1129 u32 destaddr)
1130{ 1130{
1131 struct link *l_ptr; 1131 struct link *l_ptr;
1132 struct tipc_node *node; 1132 struct tipc_node *node;
1133 struct tipc_msg *hdr = &sender->publ.phdr; 1133 struct tipc_msg *hdr = &sender->phdr;
1134 u32 dsz = msg_data_sz(hdr); 1134 u32 dsz = msg_data_sz(hdr);
1135 u32 max_pkt, fragm_sz, rest; 1135 u32 max_pkt, fragm_sz, rest;
1136 struct tipc_msg fragm_hdr; 1136 struct tipc_msg fragm_hdr;
@@ -1142,7 +1142,7 @@ static int link_send_sections_long(struct port *sender,
1142 1142
1143again: 1143again:
1144 fragm_no = 1; 1144 fragm_no = 1;
1145 max_pkt = sender->publ.max_pkt - INT_H_SIZE; 1145 max_pkt = sender->max_pkt - INT_H_SIZE;
1146 /* leave room for tunnel header in case of link changeover */ 1146 /* leave room for tunnel header in case of link changeover */
1147 fragm_sz = max_pkt - INT_H_SIZE; 1147 fragm_sz = max_pkt - INT_H_SIZE;
1148 /* leave room for fragmentation header in each fragment */ 1148 /* leave room for fragmentation header in each fragment */
@@ -1157,7 +1157,7 @@ again:
1157 1157
1158 tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, 1158 tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
1159 INT_H_SIZE, msg_destnode(hdr)); 1159 INT_H_SIZE, msg_destnode(hdr));
1160 msg_set_link_selector(&fragm_hdr, sender->publ.ref); 1160 msg_set_link_selector(&fragm_hdr, sender->ref);
1161 msg_set_size(&fragm_hdr, max_pkt); 1161 msg_set_size(&fragm_hdr, max_pkt);
1162 msg_set_fragm_no(&fragm_hdr, 1); 1162 msg_set_fragm_no(&fragm_hdr, 1);
1163 1163
@@ -1238,13 +1238,13 @@ error:
1238 node = tipc_node_find(destaddr); 1238 node = tipc_node_find(destaddr);
1239 if (likely(node)) { 1239 if (likely(node)) {
1240 tipc_node_lock(node); 1240 tipc_node_lock(node);
1241 l_ptr = node->active_links[sender->publ.ref & 1]; 1241 l_ptr = node->active_links[sender->ref & 1];
1242 if (!l_ptr) { 1242 if (!l_ptr) {
1243 tipc_node_unlock(node); 1243 tipc_node_unlock(node);
1244 goto reject; 1244 goto reject;
1245 } 1245 }
1246 if (l_ptr->max_pkt < max_pkt) { 1246 if (l_ptr->max_pkt < max_pkt) {
1247 sender->publ.max_pkt = l_ptr->max_pkt; 1247 sender->max_pkt = l_ptr->max_pkt;
1248 tipc_node_unlock(node); 1248 tipc_node_unlock(node);
1249 for (; buf_chain; buf_chain = buf) { 1249 for (; buf_chain; buf_chain = buf) {
1250 buf = buf_chain->next; 1250 buf = buf_chain->next;
diff --git a/net/tipc/link.h b/net/tipc/link.h
index 70967e637027..85fd3bcb5ed9 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -2,7 +2,7 @@
2 * net/tipc/link.h: Include file for TIPC link code 2 * net/tipc/link.h: Include file for TIPC link code
3 * 3 *
4 * Copyright (c) 1995-2006, Ericsson AB 4 * Copyright (c) 1995-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems 5 * Copyright (c) 2004-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
@@ -211,7 +211,7 @@ struct link {
211 } stats; 211 } stats;
212}; 212};
213 213
214struct port; 214struct tipc_port;
215 215
216struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, 216struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
217 const struct tipc_media_addr *media_addr); 217 const struct tipc_media_addr *media_addr);
@@ -230,7 +230,7 @@ void tipc_link_reset(struct link *l_ptr);
230int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector); 230int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
231int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf); 231int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf);
232u32 tipc_link_get_max_pkt(u32 dest, u32 selector); 232u32 tipc_link_get_max_pkt(u32 dest, u32 selector);
233int tipc_link_send_sections_fast(struct port *sender, 233int tipc_link_send_sections_fast(struct tipc_port *sender,
234 struct iovec const *msg_sect, 234 struct iovec const *msg_sect,
235 const u32 num_sect, 235 const u32 num_sect,
236 u32 destnode); 236 u32 destnode);
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 067bab2a0b98..aff5dc0c3773 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -2,7 +2,7 @@
2 * net/tipc/port.c: TIPC port code 2 * net/tipc/port.c: TIPC port code
3 * 3 *
4 * Copyright (c) 1992-2007, Ericsson AB 4 * Copyright (c) 1992-2007, Ericsson AB
5 * Copyright (c) 2004-2008, Wind River Systems 5 * Copyright (c) 2004-2008, 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
@@ -54,29 +54,29 @@ static DEFINE_SPINLOCK(queue_lock);
54 54
55static LIST_HEAD(ports); 55static LIST_HEAD(ports);
56static void port_handle_node_down(unsigned long ref); 56static void port_handle_node_down(unsigned long ref);
57static struct sk_buff *port_build_self_abort_msg(struct port *, u32 err); 57static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err);
58static struct sk_buff *port_build_peer_abort_msg(struct port *, u32 err); 58static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
59static void port_timeout(unsigned long ref); 59static void port_timeout(unsigned long ref);
60 60
61 61
62static u32 port_peernode(struct port *p_ptr) 62static u32 port_peernode(struct tipc_port *p_ptr)
63{ 63{
64 return msg_destnode(&p_ptr->publ.phdr); 64 return msg_destnode(&p_ptr->phdr);
65} 65}
66 66
67static u32 port_peerport(struct port *p_ptr) 67static u32 port_peerport(struct tipc_port *p_ptr)
68{ 68{
69 return msg_destport(&p_ptr->publ.phdr); 69 return msg_destport(&p_ptr->phdr);
70} 70}
71 71
72static u32 port_out_seqno(struct port *p_ptr) 72static u32 port_out_seqno(struct tipc_port *p_ptr)
73{ 73{
74 return msg_transp_seqno(&p_ptr->publ.phdr); 74 return msg_transp_seqno(&p_ptr->phdr);
75} 75}
76 76
77static void port_incr_out_seqno(struct port *p_ptr) 77static void port_incr_out_seqno(struct tipc_port *p_ptr)
78{ 78{
79 struct tipc_msg *m = &p_ptr->publ.phdr; 79 struct tipc_msg *m = &p_ptr->phdr;
80 80
81 if (likely(!msg_routed(m))) 81 if (likely(!msg_routed(m)))
82 return; 82 return;
@@ -94,7 +94,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
94 struct sk_buff *buf; 94 struct sk_buff *buf;
95 struct sk_buff *ibuf = NULL; 95 struct sk_buff *ibuf = NULL;
96 struct port_list dports = {0, NULL, }; 96 struct port_list dports = {0, NULL, };
97 struct port *oport = tipc_port_deref(ref); 97 struct tipc_port *oport = tipc_port_deref(ref);
98 int ext_targets; 98 int ext_targets;
99 int res; 99 int res;
100 100
@@ -103,7 +103,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
103 103
104 /* Create multicast message */ 104 /* Create multicast message */
105 105
106 hdr = &oport->publ.phdr; 106 hdr = &oport->phdr;
107 msg_set_type(hdr, TIPC_MCAST_MSG); 107 msg_set_type(hdr, TIPC_MCAST_MSG);
108 msg_set_nametype(hdr, seq->type); 108 msg_set_nametype(hdr, seq->type);
109 msg_set_namelower(hdr, seq->lower); 109 msg_set_namelower(hdr, seq->lower);
@@ -211,7 +211,7 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
211 void (*wakeup)(struct tipc_port *), 211 void (*wakeup)(struct tipc_port *),
212 const u32 importance) 212 const u32 importance)
213{ 213{
214 struct port *p_ptr; 214 struct tipc_port *p_ptr;
215 struct tipc_msg *msg; 215 struct tipc_msg *msg;
216 u32 ref; 216 u32 ref;
217 217
@@ -220,17 +220,17 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
220 warn("Port creation failed, no memory\n"); 220 warn("Port creation failed, no memory\n");
221 return NULL; 221 return NULL;
222 } 222 }
223 ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); 223 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock);
224 if (!ref) { 224 if (!ref) {
225 warn("Port creation failed, reference table exhausted\n"); 225 warn("Port creation failed, reference table exhausted\n");
226 kfree(p_ptr); 226 kfree(p_ptr);
227 return NULL; 227 return NULL;
228 } 228 }
229 229
230 p_ptr->publ.usr_handle = usr_handle; 230 p_ptr->usr_handle = usr_handle;
231 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 231 p_ptr->max_pkt = MAX_PKT_DEFAULT;
232 p_ptr->publ.ref = ref; 232 p_ptr->ref = ref;
233 msg = &p_ptr->publ.phdr; 233 msg = &p_ptr->phdr;
234 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); 234 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0);
235 msg_set_origport(msg, ref); 235 msg_set_origport(msg, ref);
236 p_ptr->last_in_seqno = 41; 236 p_ptr->last_in_seqno = 41;
@@ -246,12 +246,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
246 INIT_LIST_HEAD(&p_ptr->port_list); 246 INIT_LIST_HEAD(&p_ptr->port_list);
247 list_add_tail(&p_ptr->port_list, &ports); 247 list_add_tail(&p_ptr->port_list, &ports);
248 spin_unlock_bh(&tipc_port_list_lock); 248 spin_unlock_bh(&tipc_port_list_lock);
249 return &(p_ptr->publ); 249 return p_ptr;
250} 250}
251 251
252int tipc_deleteport(u32 ref) 252int tipc_deleteport(u32 ref)
253{ 253{
254 struct port *p_ptr; 254 struct tipc_port *p_ptr;
255 struct sk_buff *buf = NULL; 255 struct sk_buff *buf = NULL;
256 256
257 tipc_withdraw(ref, 0, NULL); 257 tipc_withdraw(ref, 0, NULL);
@@ -263,7 +263,7 @@ int tipc_deleteport(u32 ref)
263 tipc_port_unlock(p_ptr); 263 tipc_port_unlock(p_ptr);
264 264
265 k_cancel_timer(&p_ptr->timer); 265 k_cancel_timer(&p_ptr->timer);
266 if (p_ptr->publ.connected) { 266 if (p_ptr->connected) {
267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); 267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
268 tipc_nodesub_unsubscribe(&p_ptr->subscription); 268 tipc_nodesub_unsubscribe(&p_ptr->subscription);
269 } 269 }
@@ -279,14 +279,14 @@ int tipc_deleteport(u32 ref)
279 return 0; 279 return 0;
280} 280}
281 281
282static int port_unreliable(struct port *p_ptr) 282static int port_unreliable(struct tipc_port *p_ptr)
283{ 283{
284 return msg_src_droppable(&p_ptr->publ.phdr); 284 return msg_src_droppable(&p_ptr->phdr);
285} 285}
286 286
287int tipc_portunreliable(u32 ref, unsigned int *isunreliable) 287int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
288{ 288{
289 struct port *p_ptr; 289 struct tipc_port *p_ptr;
290 290
291 p_ptr = tipc_port_lock(ref); 291 p_ptr = tipc_port_lock(ref);
292 if (!p_ptr) 292 if (!p_ptr)
@@ -298,24 +298,24 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
298 298
299int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) 299int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
300{ 300{
301 struct port *p_ptr; 301 struct tipc_port *p_ptr;
302 302
303 p_ptr = tipc_port_lock(ref); 303 p_ptr = tipc_port_lock(ref);
304 if (!p_ptr) 304 if (!p_ptr)
305 return -EINVAL; 305 return -EINVAL;
306 msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0)); 306 msg_set_src_droppable(&p_ptr->phdr, (isunreliable != 0));
307 tipc_port_unlock(p_ptr); 307 tipc_port_unlock(p_ptr);
308 return 0; 308 return 0;
309} 309}
310 310
311static int port_unreturnable(struct port *p_ptr) 311static int port_unreturnable(struct tipc_port *p_ptr)
312{ 312{
313 return msg_dest_droppable(&p_ptr->publ.phdr); 313 return msg_dest_droppable(&p_ptr->phdr);
314} 314}
315 315
316int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) 316int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
317{ 317{
318 struct port *p_ptr; 318 struct tipc_port *p_ptr;
319 319
320 p_ptr = tipc_port_lock(ref); 320 p_ptr = tipc_port_lock(ref);
321 if (!p_ptr) 321 if (!p_ptr)
@@ -327,12 +327,12 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
327 327
328int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) 328int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
329{ 329{
330 struct port *p_ptr; 330 struct tipc_port *p_ptr;
331 331
332 p_ptr = tipc_port_lock(ref); 332 p_ptr = tipc_port_lock(ref);
333 if (!p_ptr) 333 if (!p_ptr)
334 return -EINVAL; 334 return -EINVAL;
335 msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0)); 335 msg_set_dest_droppable(&p_ptr->phdr, (isunrejectable != 0));
336 tipc_port_unlock(p_ptr); 336 tipc_port_unlock(p_ptr);
337 return 0; 337 return 0;
338} 338}
@@ -413,10 +413,10 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
413 /* send self-abort message when rejecting on a connected port */ 413 /* send self-abort message when rejecting on a connected port */
414 if (msg_connected(msg)) { 414 if (msg_connected(msg)) {
415 struct sk_buff *abuf = NULL; 415 struct sk_buff *abuf = NULL;
416 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 416 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
417 417
418 if (p_ptr) { 418 if (p_ptr) {
419 if (p_ptr->publ.connected) 419 if (p_ptr->connected)
420 abuf = port_build_self_abort_msg(p_ptr, err); 420 abuf = port_build_self_abort_msg(p_ptr, err);
421 tipc_port_unlock(p_ptr); 421 tipc_port_unlock(p_ptr);
422 } 422 }
@@ -429,7 +429,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
429 return data_sz; 429 return data_sz;
430} 430}
431 431
432int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, 432int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
433 struct iovec const *msg_sect, u32 num_sect, 433 struct iovec const *msg_sect, u32 num_sect,
434 int err) 434 int err)
435{ 435{
@@ -446,13 +446,13 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
446 446
447static void port_timeout(unsigned long ref) 447static void port_timeout(unsigned long ref)
448{ 448{
449 struct port *p_ptr = tipc_port_lock(ref); 449 struct tipc_port *p_ptr = tipc_port_lock(ref);
450 struct sk_buff *buf = NULL; 450 struct sk_buff *buf = NULL;
451 451
452 if (!p_ptr) 452 if (!p_ptr)
453 return; 453 return;
454 454
455 if (!p_ptr->publ.connected) { 455 if (!p_ptr->connected) {
456 tipc_port_unlock(p_ptr); 456 tipc_port_unlock(p_ptr);
457 return; 457 return;
458 } 458 }
@@ -463,7 +463,7 @@ static void port_timeout(unsigned long ref)
463 } else { 463 } else {
464 buf = port_build_proto_msg(port_peerport(p_ptr), 464 buf = port_build_proto_msg(port_peerport(p_ptr),
465 port_peernode(p_ptr), 465 port_peernode(p_ptr),
466 p_ptr->publ.ref, 466 p_ptr->ref,
467 tipc_own_addr, 467 tipc_own_addr,
468 CONN_MANAGER, 468 CONN_MANAGER,
469 CONN_PROBE, 469 CONN_PROBE,
@@ -481,7 +481,7 @@ static void port_timeout(unsigned long ref)
481 481
482static void port_handle_node_down(unsigned long ref) 482static void port_handle_node_down(unsigned long ref)
483{ 483{
484 struct port *p_ptr = tipc_port_lock(ref); 484 struct tipc_port *p_ptr = tipc_port_lock(ref);
485 struct sk_buff *buf = NULL; 485 struct sk_buff *buf = NULL;
486 486
487 if (!p_ptr) 487 if (!p_ptr)
@@ -492,15 +492,15 @@ static void port_handle_node_down(unsigned long ref)
492} 492}
493 493
494 494
495static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err) 495static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err)
496{ 496{
497 u32 imp = msg_importance(&p_ptr->publ.phdr); 497 u32 imp = msg_importance(&p_ptr->phdr);
498 498
499 if (!p_ptr->publ.connected) 499 if (!p_ptr->connected)
500 return NULL; 500 return NULL;
501 if (imp < TIPC_CRITICAL_IMPORTANCE) 501 if (imp < TIPC_CRITICAL_IMPORTANCE)
502 imp++; 502 imp++;
503 return port_build_proto_msg(p_ptr->publ.ref, 503 return port_build_proto_msg(p_ptr->ref,
504 tipc_own_addr, 504 tipc_own_addr,
505 port_peerport(p_ptr), 505 port_peerport(p_ptr),
506 port_peernode(p_ptr), 506 port_peernode(p_ptr),
@@ -512,17 +512,17 @@ static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err)
512} 512}
513 513
514 514
515static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err) 515static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err)
516{ 516{
517 u32 imp = msg_importance(&p_ptr->publ.phdr); 517 u32 imp = msg_importance(&p_ptr->phdr);
518 518
519 if (!p_ptr->publ.connected) 519 if (!p_ptr->connected)
520 return NULL; 520 return NULL;
521 if (imp < TIPC_CRITICAL_IMPORTANCE) 521 if (imp < TIPC_CRITICAL_IMPORTANCE)
522 imp++; 522 imp++;
523 return port_build_proto_msg(port_peerport(p_ptr), 523 return port_build_proto_msg(port_peerport(p_ptr),
524 port_peernode(p_ptr), 524 port_peernode(p_ptr),
525 p_ptr->publ.ref, 525 p_ptr->ref,
526 tipc_own_addr, 526 tipc_own_addr,
527 imp, 527 imp,
528 TIPC_CONN_MSG, 528 TIPC_CONN_MSG,
@@ -534,31 +534,31 @@ static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err)
534void tipc_port_recv_proto_msg(struct sk_buff *buf) 534void tipc_port_recv_proto_msg(struct sk_buff *buf)
535{ 535{
536 struct tipc_msg *msg = buf_msg(buf); 536 struct tipc_msg *msg = buf_msg(buf);
537 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 537 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
538 u32 err = TIPC_OK; 538 u32 err = TIPC_OK;
539 struct sk_buff *r_buf = NULL; 539 struct sk_buff *r_buf = NULL;
540 struct sk_buff *abort_buf = NULL; 540 struct sk_buff *abort_buf = NULL;
541 541
542 if (!p_ptr) { 542 if (!p_ptr) {
543 err = TIPC_ERR_NO_PORT; 543 err = TIPC_ERR_NO_PORT;
544 } else if (p_ptr->publ.connected) { 544 } else if (p_ptr->connected) {
545 if ((port_peernode(p_ptr) != msg_orignode(msg)) || 545 if ((port_peernode(p_ptr) != msg_orignode(msg)) ||
546 (port_peerport(p_ptr) != msg_origport(msg))) { 546 (port_peerport(p_ptr) != msg_origport(msg))) {
547 err = TIPC_ERR_NO_PORT; 547 err = TIPC_ERR_NO_PORT;
548 } else if (msg_type(msg) == CONN_ACK) { 548 } else if (msg_type(msg) == CONN_ACK) {
549 int wakeup = tipc_port_congested(p_ptr) && 549 int wakeup = tipc_port_congested(p_ptr) &&
550 p_ptr->publ.congested && 550 p_ptr->congested &&
551 p_ptr->wakeup; 551 p_ptr->wakeup;
552 p_ptr->acked += msg_msgcnt(msg); 552 p_ptr->acked += msg_msgcnt(msg);
553 if (tipc_port_congested(p_ptr)) 553 if (tipc_port_congested(p_ptr))
554 goto exit; 554 goto exit;
555 p_ptr->publ.congested = 0; 555 p_ptr->congested = 0;
556 if (!wakeup) 556 if (!wakeup)
557 goto exit; 557 goto exit;
558 p_ptr->wakeup(&p_ptr->publ); 558 p_ptr->wakeup(p_ptr);
559 goto exit; 559 goto exit;
560 } 560 }
561 } else if (p_ptr->publ.published) { 561 } else if (p_ptr->published) {
562 err = TIPC_ERR_NO_PORT; 562 err = TIPC_ERR_NO_PORT;
563 } 563 }
564 if (err) { 564 if (err) {
@@ -596,29 +596,29 @@ exit:
596 buf_discard(buf); 596 buf_discard(buf);
597} 597}
598 598
599static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id) 599static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id)
600{ 600{
601 struct publication *publ; 601 struct publication *publ;
602 602
603 if (full_id) 603 if (full_id)
604 tipc_printf(buf, "<%u.%u.%u:%u>:", 604 tipc_printf(buf, "<%u.%u.%u:%u>:",
605 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 605 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
606 tipc_node(tipc_own_addr), p_ptr->publ.ref); 606 tipc_node(tipc_own_addr), p_ptr->ref);
607 else 607 else
608 tipc_printf(buf, "%-10u:", p_ptr->publ.ref); 608 tipc_printf(buf, "%-10u:", p_ptr->ref);
609 609
610 if (p_ptr->publ.connected) { 610 if (p_ptr->connected) {
611 u32 dport = port_peerport(p_ptr); 611 u32 dport = port_peerport(p_ptr);
612 u32 destnode = port_peernode(p_ptr); 612 u32 destnode = port_peernode(p_ptr);
613 613
614 tipc_printf(buf, " connected to <%u.%u.%u:%u>", 614 tipc_printf(buf, " connected to <%u.%u.%u:%u>",
615 tipc_zone(destnode), tipc_cluster(destnode), 615 tipc_zone(destnode), tipc_cluster(destnode),
616 tipc_node(destnode), dport); 616 tipc_node(destnode), dport);
617 if (p_ptr->publ.conn_type != 0) 617 if (p_ptr->conn_type != 0)
618 tipc_printf(buf, " via {%u,%u}", 618 tipc_printf(buf, " via {%u,%u}",
619 p_ptr->publ.conn_type, 619 p_ptr->conn_type,
620 p_ptr->publ.conn_instance); 620 p_ptr->conn_instance);
621 } else if (p_ptr->publ.published) { 621 } else if (p_ptr->published) {
622 tipc_printf(buf, " bound to"); 622 tipc_printf(buf, " bound to");
623 list_for_each_entry(publ, &p_ptr->publications, pport_list) { 623 list_for_each_entry(publ, &p_ptr->publications, pport_list) {
624 if (publ->lower == publ->upper) 624 if (publ->lower == publ->upper)
@@ -639,7 +639,7 @@ struct sk_buff *tipc_port_get_ports(void)
639 struct sk_buff *buf; 639 struct sk_buff *buf;
640 struct tlv_desc *rep_tlv; 640 struct tlv_desc *rep_tlv;
641 struct print_buf pb; 641 struct print_buf pb;
642 struct port *p_ptr; 642 struct tipc_port *p_ptr;
643 int str_len; 643 int str_len;
644 644
645 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); 645 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY));
@@ -650,9 +650,9 @@ struct sk_buff *tipc_port_get_ports(void)
650 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); 650 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY);
651 spin_lock_bh(&tipc_port_list_lock); 651 spin_lock_bh(&tipc_port_list_lock);
652 list_for_each_entry(p_ptr, &ports, port_list) { 652 list_for_each_entry(p_ptr, &ports, port_list) {
653 spin_lock_bh(p_ptr->publ.lock); 653 spin_lock_bh(p_ptr->lock);
654 port_print(p_ptr, &pb, 0); 654 port_print(p_ptr, &pb, 0);
655 spin_unlock_bh(p_ptr->publ.lock); 655 spin_unlock_bh(p_ptr->lock);
656 } 656 }
657 spin_unlock_bh(&tipc_port_list_lock); 657 spin_unlock_bh(&tipc_port_list_lock);
658 str_len = tipc_printbuf_validate(&pb); 658 str_len = tipc_printbuf_validate(&pb);
@@ -665,12 +665,12 @@ struct sk_buff *tipc_port_get_ports(void)
665 665
666void tipc_port_reinit(void) 666void tipc_port_reinit(void)
667{ 667{
668 struct port *p_ptr; 668 struct tipc_port *p_ptr;
669 struct tipc_msg *msg; 669 struct tipc_msg *msg;
670 670
671 spin_lock_bh(&tipc_port_list_lock); 671 spin_lock_bh(&tipc_port_list_lock);
672 list_for_each_entry(p_ptr, &ports, port_list) { 672 list_for_each_entry(p_ptr, &ports, port_list) {
673 msg = &p_ptr->publ.phdr; 673 msg = &p_ptr->phdr;
674 if (msg_orignode(msg) == tipc_own_addr) 674 if (msg_orignode(msg) == tipc_own_addr)
675 break; 675 break;
676 msg_set_prevnode(msg, tipc_own_addr); 676 msg_set_prevnode(msg, tipc_own_addr);
@@ -695,7 +695,7 @@ static void port_dispatcher_sigh(void *dummy)
695 spin_unlock_bh(&queue_lock); 695 spin_unlock_bh(&queue_lock);
696 696
697 while (buf) { 697 while (buf) {
698 struct port *p_ptr; 698 struct tipc_port *p_ptr;
699 struct user_port *up_ptr; 699 struct user_port *up_ptr;
700 struct tipc_portid orig; 700 struct tipc_portid orig;
701 struct tipc_name_seq dseq; 701 struct tipc_name_seq dseq;
@@ -720,8 +720,8 @@ static void port_dispatcher_sigh(void *dummy)
720 orig.node = msg_orignode(msg); 720 orig.node = msg_orignode(msg);
721 up_ptr = p_ptr->user_port; 721 up_ptr = p_ptr->user_port;
722 usr_handle = up_ptr->usr_handle; 722 usr_handle = up_ptr->usr_handle;
723 connected = p_ptr->publ.connected; 723 connected = p_ptr->connected;
724 published = p_ptr->publ.published; 724 published = p_ptr->published;
725 725
726 if (unlikely(msg_errcode(msg))) 726 if (unlikely(msg_errcode(msg)))
727 goto err; 727 goto err;
@@ -742,10 +742,10 @@ static void port_dispatcher_sigh(void *dummy)
742 } else if ((msg_origport(msg) != peer_port) || 742 } else if ((msg_origport(msg) != peer_port) ||
743 (msg_orignode(msg) != peer_node)) 743 (msg_orignode(msg) != peer_node))
744 goto reject; 744 goto reject;
745 if (unlikely(++p_ptr->publ.conn_unacked >= 745 if (unlikely(++p_ptr->conn_unacked >=
746 TIPC_FLOW_CONTROL_WIN)) 746 TIPC_FLOW_CONTROL_WIN))
747 tipc_acknowledge(dref, 747 tipc_acknowledge(dref,
748 p_ptr->publ.conn_unacked); 748 p_ptr->conn_unacked);
749 skb_pull(buf, msg_hdr_sz(msg)); 749 skb_pull(buf, msg_hdr_sz(msg));
750 cb(usr_handle, dref, &buf, msg_data(msg), 750 cb(usr_handle, dref, &buf, msg_data(msg),
751 msg_data_sz(msg)); 751 msg_data_sz(msg));
@@ -872,7 +872,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
872 872
873static void port_wakeup_sh(unsigned long ref) 873static void port_wakeup_sh(unsigned long ref)
874{ 874{
875 struct port *p_ptr; 875 struct tipc_port *p_ptr;
876 struct user_port *up_ptr; 876 struct user_port *up_ptr;
877 tipc_continue_event cb = NULL; 877 tipc_continue_event cb = NULL;
878 void *uh = NULL; 878 void *uh = NULL;
@@ -898,14 +898,14 @@ static void port_wakeup(struct tipc_port *p_ptr)
898 898
899void tipc_acknowledge(u32 ref, u32 ack) 899void tipc_acknowledge(u32 ref, u32 ack)
900{ 900{
901 struct port *p_ptr; 901 struct tipc_port *p_ptr;
902 struct sk_buff *buf = NULL; 902 struct sk_buff *buf = NULL;
903 903
904 p_ptr = tipc_port_lock(ref); 904 p_ptr = tipc_port_lock(ref);
905 if (!p_ptr) 905 if (!p_ptr)
906 return; 906 return;
907 if (p_ptr->publ.connected) { 907 if (p_ptr->connected) {
908 p_ptr->publ.conn_unacked -= ack; 908 p_ptr->conn_unacked -= ack;
909 buf = port_build_proto_msg(port_peerport(p_ptr), 909 buf = port_build_proto_msg(port_peerport(p_ptr),
910 port_peernode(p_ptr), 910 port_peernode(p_ptr),
911 ref, 911 ref,
@@ -936,14 +936,14 @@ int tipc_createport(void *usr_handle,
936 u32 *portref) 936 u32 *portref)
937{ 937{
938 struct user_port *up_ptr; 938 struct user_port *up_ptr;
939 struct port *p_ptr; 939 struct tipc_port *p_ptr;
940 940
941 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); 941 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
942 if (!up_ptr) { 942 if (!up_ptr) {
943 warn("Port creation failed, no memory\n"); 943 warn("Port creation failed, no memory\n");
944 return -ENOMEM; 944 return -ENOMEM;
945 } 945 }
946 p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher, 946 p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher,
947 port_wakeup, importance); 947 port_wakeup, importance);
948 if (!p_ptr) { 948 if (!p_ptr) {
949 kfree(up_ptr); 949 kfree(up_ptr);
@@ -952,7 +952,7 @@ int tipc_createport(void *usr_handle,
952 952
953 p_ptr->user_port = up_ptr; 953 p_ptr->user_port = up_ptr;
954 up_ptr->usr_handle = usr_handle; 954 up_ptr->usr_handle = usr_handle;
955 up_ptr->ref = p_ptr->publ.ref; 955 up_ptr->ref = p_ptr->ref;
956 up_ptr->err_cb = error_cb; 956 up_ptr->err_cb = error_cb;
957 up_ptr->named_err_cb = named_error_cb; 957 up_ptr->named_err_cb = named_error_cb;
958 up_ptr->conn_err_cb = conn_error_cb; 958 up_ptr->conn_err_cb = conn_error_cb;
@@ -960,26 +960,26 @@ int tipc_createport(void *usr_handle,
960 up_ptr->named_msg_cb = named_msg_cb; 960 up_ptr->named_msg_cb = named_msg_cb;
961 up_ptr->conn_msg_cb = conn_msg_cb; 961 up_ptr->conn_msg_cb = conn_msg_cb;
962 up_ptr->continue_event_cb = continue_event_cb; 962 up_ptr->continue_event_cb = continue_event_cb;
963 *portref = p_ptr->publ.ref; 963 *portref = p_ptr->ref;
964 tipc_port_unlock(p_ptr); 964 tipc_port_unlock(p_ptr);
965 return 0; 965 return 0;
966} 966}
967 967
968int tipc_portimportance(u32 ref, unsigned int *importance) 968int tipc_portimportance(u32 ref, unsigned int *importance)
969{ 969{
970 struct port *p_ptr; 970 struct tipc_port *p_ptr;
971 971
972 p_ptr = tipc_port_lock(ref); 972 p_ptr = tipc_port_lock(ref);
973 if (!p_ptr) 973 if (!p_ptr)
974 return -EINVAL; 974 return -EINVAL;
975 *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr); 975 *importance = (unsigned int)msg_importance(&p_ptr->phdr);
976 tipc_port_unlock(p_ptr); 976 tipc_port_unlock(p_ptr);
977 return 0; 977 return 0;
978} 978}
979 979
980int tipc_set_portimportance(u32 ref, unsigned int imp) 980int tipc_set_portimportance(u32 ref, unsigned int imp)
981{ 981{
982 struct port *p_ptr; 982 struct tipc_port *p_ptr;
983 983
984 if (imp > TIPC_CRITICAL_IMPORTANCE) 984 if (imp > TIPC_CRITICAL_IMPORTANCE)
985 return -EINVAL; 985 return -EINVAL;
@@ -987,7 +987,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
987 p_ptr = tipc_port_lock(ref); 987 p_ptr = tipc_port_lock(ref);
988 if (!p_ptr) 988 if (!p_ptr)
989 return -EINVAL; 989 return -EINVAL;
990 msg_set_importance(&p_ptr->publ.phdr, (u32)imp); 990 msg_set_importance(&p_ptr->phdr, (u32)imp);
991 tipc_port_unlock(p_ptr); 991 tipc_port_unlock(p_ptr);
992 return 0; 992 return 0;
993} 993}
@@ -995,7 +995,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
995 995
996int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 996int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
997{ 997{
998 struct port *p_ptr; 998 struct tipc_port *p_ptr;
999 struct publication *publ; 999 struct publication *publ;
1000 u32 key; 1000 u32 key;
1001 int res = -EINVAL; 1001 int res = -EINVAL;
@@ -1004,7 +1004,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1004 if (!p_ptr) 1004 if (!p_ptr)
1005 return -EINVAL; 1005 return -EINVAL;
1006 1006
1007 if (p_ptr->publ.connected) 1007 if (p_ptr->connected)
1008 goto exit; 1008 goto exit;
1009 if (seq->lower > seq->upper) 1009 if (seq->lower > seq->upper)
1010 goto exit; 1010 goto exit;
@@ -1016,11 +1016,11 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1016 goto exit; 1016 goto exit;
1017 } 1017 }
1018 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, 1018 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper,
1019 scope, p_ptr->publ.ref, key); 1019 scope, p_ptr->ref, key);
1020 if (publ) { 1020 if (publ) {
1021 list_add(&publ->pport_list, &p_ptr->publications); 1021 list_add(&publ->pport_list, &p_ptr->publications);
1022 p_ptr->pub_count++; 1022 p_ptr->pub_count++;
1023 p_ptr->publ.published = 1; 1023 p_ptr->published = 1;
1024 res = 0; 1024 res = 0;
1025 } 1025 }
1026exit: 1026exit:
@@ -1030,7 +1030,7 @@ exit:
1030 1030
1031int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 1031int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1032{ 1032{
1033 struct port *p_ptr; 1033 struct tipc_port *p_ptr;
1034 struct publication *publ; 1034 struct publication *publ;
1035 struct publication *tpubl; 1035 struct publication *tpubl;
1036 int res = -EINVAL; 1036 int res = -EINVAL;
@@ -1063,37 +1063,37 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1063 } 1063 }
1064 } 1064 }
1065 if (list_empty(&p_ptr->publications)) 1065 if (list_empty(&p_ptr->publications))
1066 p_ptr->publ.published = 0; 1066 p_ptr->published = 0;
1067 tipc_port_unlock(p_ptr); 1067 tipc_port_unlock(p_ptr);
1068 return res; 1068 return res;
1069} 1069}
1070 1070
1071int tipc_connect2port(u32 ref, struct tipc_portid const *peer) 1071int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1072{ 1072{
1073 struct port *p_ptr; 1073 struct tipc_port *p_ptr;
1074 struct tipc_msg *msg; 1074 struct tipc_msg *msg;
1075 int res = -EINVAL; 1075 int res = -EINVAL;
1076 1076
1077 p_ptr = tipc_port_lock(ref); 1077 p_ptr = tipc_port_lock(ref);
1078 if (!p_ptr) 1078 if (!p_ptr)
1079 return -EINVAL; 1079 return -EINVAL;
1080 if (p_ptr->publ.published || p_ptr->publ.connected) 1080 if (p_ptr->published || p_ptr->connected)
1081 goto exit; 1081 goto exit;
1082 if (!peer->ref) 1082 if (!peer->ref)
1083 goto exit; 1083 goto exit;
1084 1084
1085 msg = &p_ptr->publ.phdr; 1085 msg = &p_ptr->phdr;
1086 msg_set_destnode(msg, peer->node); 1086 msg_set_destnode(msg, peer->node);
1087 msg_set_destport(msg, peer->ref); 1087 msg_set_destport(msg, peer->ref);
1088 msg_set_orignode(msg, tipc_own_addr); 1088 msg_set_orignode(msg, tipc_own_addr);
1089 msg_set_origport(msg, p_ptr->publ.ref); 1089 msg_set_origport(msg, p_ptr->ref);
1090 msg_set_transp_seqno(msg, 42); 1090 msg_set_transp_seqno(msg, 42);
1091 msg_set_type(msg, TIPC_CONN_MSG); 1091 msg_set_type(msg, TIPC_CONN_MSG);
1092 msg_set_hdr_sz(msg, SHORT_H_SIZE); 1092 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1093 1093
1094 p_ptr->probing_interval = PROBING_INTERVAL; 1094 p_ptr->probing_interval = PROBING_INTERVAL;
1095 p_ptr->probing_state = CONFIRMED; 1095 p_ptr->probing_state = CONFIRMED;
1096 p_ptr->publ.connected = 1; 1096 p_ptr->connected = 1;
1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval); 1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
1098 1098
1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node, 1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node,
@@ -1102,7 +1102,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1102 res = 0; 1102 res = 0;
1103exit: 1103exit:
1104 tipc_port_unlock(p_ptr); 1104 tipc_port_unlock(p_ptr);
1105 p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); 1105 p_ptr->max_pkt = tipc_link_get_max_pkt(peer->node, ref);
1106 return res; 1106 return res;
1107} 1107}
1108 1108
@@ -1120,7 +1120,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1120 tp_ptr->connected = 0; 1120 tp_ptr->connected = 0;
1121 /* let timer expire on it's own to avoid deadlock! */ 1121 /* let timer expire on it's own to avoid deadlock! */
1122 tipc_nodesub_unsubscribe( 1122 tipc_nodesub_unsubscribe(
1123 &((struct port *)tp_ptr)->subscription); 1123 &((struct tipc_port *)tp_ptr)->subscription);
1124 res = 0; 1124 res = 0;
1125 } else { 1125 } else {
1126 res = -ENOTCONN; 1126 res = -ENOTCONN;
@@ -1135,7 +1135,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1135 1135
1136int tipc_disconnect(u32 ref) 1136int tipc_disconnect(u32 ref)
1137{ 1137{
1138 struct port *p_ptr; 1138 struct tipc_port *p_ptr;
1139 int res; 1139 int res;
1140 1140
1141 p_ptr = tipc_port_lock(ref); 1141 p_ptr = tipc_port_lock(ref);
@@ -1151,15 +1151,15 @@ int tipc_disconnect(u32 ref)
1151 */ 1151 */
1152int tipc_shutdown(u32 ref) 1152int tipc_shutdown(u32 ref)
1153{ 1153{
1154 struct port *p_ptr; 1154 struct tipc_port *p_ptr;
1155 struct sk_buff *buf = NULL; 1155 struct sk_buff *buf = NULL;
1156 1156
1157 p_ptr = tipc_port_lock(ref); 1157 p_ptr = tipc_port_lock(ref);
1158 if (!p_ptr) 1158 if (!p_ptr)
1159 return -EINVAL; 1159 return -EINVAL;
1160 1160
1161 if (p_ptr->publ.connected) { 1161 if (p_ptr->connected) {
1162 u32 imp = msg_importance(&p_ptr->publ.phdr); 1162 u32 imp = msg_importance(&p_ptr->phdr);
1163 if (imp < TIPC_CRITICAL_IMPORTANCE) 1163 if (imp < TIPC_CRITICAL_IMPORTANCE)
1164 imp++; 1164 imp++;
1165 buf = port_build_proto_msg(port_peerport(p_ptr), 1165 buf = port_build_proto_msg(port_peerport(p_ptr),
@@ -1182,13 +1182,13 @@ int tipc_shutdown(u32 ref)
1182 * message for this node. 1182 * message for this node.
1183 */ 1183 */
1184 1184
1185static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, 1185static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect,
1186 struct iovec const *msg_sect) 1186 struct iovec const *msg_sect)
1187{ 1187{
1188 struct sk_buff *buf; 1188 struct sk_buff *buf;
1189 int res; 1189 int res;
1190 1190
1191 res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect, 1191 res = tipc_msg_build(&sender->phdr, msg_sect, num_sect,
1192 MAX_MSG_SIZE, !sender->user_port, &buf); 1192 MAX_MSG_SIZE, !sender->user_port, &buf);
1193 if (likely(buf)) 1193 if (likely(buf))
1194 tipc_port_recv_msg(buf); 1194 tipc_port_recv_msg(buf);
@@ -1201,15 +1201,15 @@ static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
1201 1201
1202int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) 1202int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1203{ 1203{
1204 struct port *p_ptr; 1204 struct tipc_port *p_ptr;
1205 u32 destnode; 1205 u32 destnode;
1206 int res; 1206 int res;
1207 1207
1208 p_ptr = tipc_port_deref(ref); 1208 p_ptr = tipc_port_deref(ref);
1209 if (!p_ptr || !p_ptr->publ.connected) 1209 if (!p_ptr || !p_ptr->connected)
1210 return -EINVAL; 1210 return -EINVAL;
1211 1211
1212 p_ptr->publ.congested = 1; 1212 p_ptr->congested = 1;
1213 if (!tipc_port_congested(p_ptr)) { 1213 if (!tipc_port_congested(p_ptr)) {
1214 destnode = port_peernode(p_ptr); 1214 destnode = port_peernode(p_ptr);
1215 if (likely(destnode != tipc_own_addr)) 1215 if (likely(destnode != tipc_own_addr))
@@ -1220,13 +1220,13 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1220 1220
1221 if (likely(res != -ELINKCONG)) { 1221 if (likely(res != -ELINKCONG)) {
1222 port_incr_out_seqno(p_ptr); 1222 port_incr_out_seqno(p_ptr);
1223 p_ptr->publ.congested = 0; 1223 p_ptr->congested = 0;
1224 p_ptr->sent++; 1224 p_ptr->sent++;
1225 return res; 1225 return res;
1226 } 1226 }
1227 } 1227 }
1228 if (port_unreliable(p_ptr)) { 1228 if (port_unreliable(p_ptr)) {
1229 p_ptr->publ.congested = 0; 1229 p_ptr->congested = 0;
1230 /* Just calculate msg length and return */ 1230 /* Just calculate msg length and return */
1231 return tipc_msg_calc_data_size(msg_sect, num_sect); 1231 return tipc_msg_calc_data_size(msg_sect, num_sect);
1232 } 1232 }
@@ -1240,17 +1240,17 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1240int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, 1240int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1241 unsigned int num_sect, struct iovec const *msg_sect) 1241 unsigned int num_sect, struct iovec const *msg_sect)
1242{ 1242{
1243 struct port *p_ptr; 1243 struct tipc_port *p_ptr;
1244 struct tipc_msg *msg; 1244 struct tipc_msg *msg;
1245 u32 destnode = domain; 1245 u32 destnode = domain;
1246 u32 destport; 1246 u32 destport;
1247 int res; 1247 int res;
1248 1248
1249 p_ptr = tipc_port_deref(ref); 1249 p_ptr = tipc_port_deref(ref);
1250 if (!p_ptr || p_ptr->publ.connected) 1250 if (!p_ptr || p_ptr->connected)
1251 return -EINVAL; 1251 return -EINVAL;
1252 1252
1253 msg = &p_ptr->publ.phdr; 1253 msg = &p_ptr->phdr;
1254 msg_set_type(msg, TIPC_NAMED_MSG); 1254 msg_set_type(msg, TIPC_NAMED_MSG);
1255 msg_set_orignode(msg, tipc_own_addr); 1255 msg_set_orignode(msg, tipc_own_addr);
1256 msg_set_origport(msg, ref); 1256 msg_set_origport(msg, ref);
@@ -1287,15 +1287,15 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1287int tipc_send2port(u32 ref, struct tipc_portid const *dest, 1287int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1288 unsigned int num_sect, struct iovec const *msg_sect) 1288 unsigned int num_sect, struct iovec const *msg_sect)
1289{ 1289{
1290 struct port *p_ptr; 1290 struct tipc_port *p_ptr;
1291 struct tipc_msg *msg; 1291 struct tipc_msg *msg;
1292 int res; 1292 int res;
1293 1293
1294 p_ptr = tipc_port_deref(ref); 1294 p_ptr = tipc_port_deref(ref);
1295 if (!p_ptr || p_ptr->publ.connected) 1295 if (!p_ptr || p_ptr->connected)
1296 return -EINVAL; 1296 return -EINVAL;
1297 1297
1298 msg = &p_ptr->publ.phdr; 1298 msg = &p_ptr->phdr;
1299 msg_set_type(msg, TIPC_DIRECT_MSG); 1299 msg_set_type(msg, TIPC_DIRECT_MSG);
1300 msg_set_orignode(msg, tipc_own_addr); 1300 msg_set_orignode(msg, tipc_own_addr);
1301 msg_set_origport(msg, ref); 1301 msg_set_origport(msg, ref);
@@ -1322,15 +1322,15 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, 1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
1323 struct sk_buff *buf, unsigned int dsz) 1323 struct sk_buff *buf, unsigned int dsz)
1324{ 1324{
1325 struct port *p_ptr; 1325 struct tipc_port *p_ptr;
1326 struct tipc_msg *msg; 1326 struct tipc_msg *msg;
1327 int res; 1327 int res;
1328 1328
1329 p_ptr = (struct port *)tipc_ref_deref(ref); 1329 p_ptr = (struct tipc_port *)tipc_ref_deref(ref);
1330 if (!p_ptr || p_ptr->publ.connected) 1330 if (!p_ptr || p_ptr->connected)
1331 return -EINVAL; 1331 return -EINVAL;
1332 1332
1333 msg = &p_ptr->publ.phdr; 1333 msg = &p_ptr->phdr;
1334 msg_set_type(msg, TIPC_DIRECT_MSG); 1334 msg_set_type(msg, TIPC_DIRECT_MSG);
1335 msg_set_orignode(msg, tipc_own_addr); 1335 msg_set_orignode(msg, tipc_own_addr);
1336 msg_set_origport(msg, ref); 1336 msg_set_origport(msg, ref);
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 */
111struct 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 126struct tipc_port {
145struct 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,
230int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, 221int 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
233int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, 224int 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);
236struct sk_buff *tipc_port_get_ports(void); 227struct 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
245static inline struct port *tipc_port_lock(u32 ref) 236static 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
256static inline void tipc_port_unlock(struct port *p_ptr) 247static 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
261static inline struct port *tipc_port_deref(u32 ref) 252static 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
266static inline u32 tipc_peer_port(struct port *p_ptr) 257static 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
271static inline u32 tipc_peer_node(struct port *p_ptr) 262static 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
276static inline int tipc_port_congested(struct port *p_ptr) 267static 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
285static inline int tipc_port_recv_msg(struct sk_buff *buf) 276static 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;
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index ca04479c3d42..98ee50b332ae 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -2,7 +2,7 @@
2 * net/tipc/subscr.c: TIPC network topology service 2 * net/tipc/subscr.c: TIPC network topology service
3 * 3 *
4 * Copyright (c) 2000-2006, Ericsson AB 4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2005-2007, Wind River Systems 5 * Copyright (c) 2005-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
@@ -160,7 +160,7 @@ void tipc_subscr_report_overlap(struct subscription *sub,
160 160
161static void subscr_timeout(struct subscription *sub) 161static void subscr_timeout(struct subscription *sub)
162{ 162{
163 struct port *server_port; 163 struct tipc_port *server_port;
164 164
165 /* Validate server port reference (in case subscriber is terminating) */ 165 /* Validate server port reference (in case subscriber is terminating) */
166 166
@@ -508,7 +508,7 @@ static void subscr_named_msg_event(void *usr_handle,
508 508
509 /* Lock server port (& save lock address for future use) */ 509 /* Lock server port (& save lock address for future use) */
510 510
511 subscriber->lock = tipc_port_lock(subscriber->port_ref)->publ.lock; 511 subscriber->lock = tipc_port_lock(subscriber->port_ref)->lock;
512 512
513 /* Add subscriber to topology server's subscriber list */ 513 /* Add subscriber to topology server's subscriber list */
514 514