Commit 23dd4cce authored by Allan Stephens's avatar Allan Stephens Committed by Paul Gortmaker

tipc: Combine port structure with tipc_port structure

Merge two distinct structures containing information about a TIPC port
into a single structure. The structures were previously kept separate
so that public information about a port could be made available to
applications using TIPC's native API, while the remaining information
was kept private for use by TIPC itself. However, now that the native
API has been removed there is no longer any need for this somewhat
confusing arrangement.

Since one of the structures was already embedded within the other, the
change largely involves replacing instances of "publ.foo" with "foo".
The changes do not otherwise alter the operation of TIPC ports.
Signed-off-by: default avatarAllan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent dee9f4bc
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/link.c: TIPC link code * net/tipc/link.c: TIPC link code
* *
* Copyright (c) 1996-2007, Ericsson AB * Copyright (c) 1996-2007, Ericsson AB
* Copyright (c) 2004-2007, Wind River Systems * Copyright (c) 2004-2007, 2010-2011, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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, ...@@ -90,7 +90,7 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf); static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf);
static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf); static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf);
static void link_set_supervision_props(struct link *l_ptr, u32 tolerance); static void link_set_supervision_props(struct link *l_ptr, u32 tolerance);
static int link_send_sections_long(struct port *sender, static int link_send_sections_long(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
u32 num_sect, u32 destnode); u32 num_sect, u32 destnode);
static void link_check_defragm_bufs(struct link *l_ptr); static void link_check_defragm_bufs(struct link *l_ptr);
...@@ -406,7 +406,7 @@ static void link_start(struct link *l_ptr) ...@@ -406,7 +406,7 @@ static void link_start(struct link *l_ptr)
static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
{ {
struct port *p_ptr; struct tipc_port *p_ptr;
spin_lock_bh(&tipc_port_list_lock); spin_lock_bh(&tipc_port_list_lock);
p_ptr = tipc_port_lock(origport); p_ptr = tipc_port_lock(origport);
...@@ -415,7 +415,7 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) ...@@ -415,7 +415,7 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
goto exit; goto exit;
if (!list_empty(&p_ptr->wait_list)) if (!list_empty(&p_ptr->wait_list))
goto exit; goto exit;
p_ptr->publ.congested = 1; p_ptr->congested = 1;
p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt); p_ptr->waiting_pkts = 1 + ((sz - 1) / l_ptr->max_pkt);
list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports); list_add_tail(&p_ptr->wait_list, &l_ptr->waiting_ports);
l_ptr->stats.link_congs++; l_ptr->stats.link_congs++;
...@@ -428,8 +428,8 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) ...@@ -428,8 +428,8 @@ static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz)
void tipc_link_wakeup_ports(struct link *l_ptr, int all) void tipc_link_wakeup_ports(struct link *l_ptr, int all)
{ {
struct port *p_ptr; struct tipc_port *p_ptr;
struct port *temp_p_ptr; struct tipc_port *temp_p_ptr;
int win = l_ptr->queue_limit[0] - l_ptr->out_queue_size; int win = l_ptr->queue_limit[0] - l_ptr->out_queue_size;
if (all) if (all)
...@@ -445,11 +445,11 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all) ...@@ -445,11 +445,11 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
if (win <= 0) if (win <= 0)
break; break;
list_del_init(&p_ptr->wait_list); list_del_init(&p_ptr->wait_list);
spin_lock_bh(p_ptr->publ.lock); spin_lock_bh(p_ptr->lock);
p_ptr->publ.congested = 0; p_ptr->congested = 0;
p_ptr->wakeup(&p_ptr->publ); p_ptr->wakeup(p_ptr);
win -= p_ptr->waiting_pkts; win -= p_ptr->waiting_pkts;
spin_unlock_bh(p_ptr->publ.lock); spin_unlock_bh(p_ptr->lock);
} }
exit: exit:
...@@ -1027,12 +1027,12 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) ...@@ -1027,12 +1027,12 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
* except for total message length. * except for total message length.
* Returns user data length or errno. * Returns user data length or errno.
*/ */
int tipc_link_send_sections_fast(struct port *sender, int tipc_link_send_sections_fast(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
const u32 num_sect, const u32 num_sect,
u32 destaddr) u32 destaddr)
{ {
struct tipc_msg *hdr = &sender->publ.phdr; struct tipc_msg *hdr = &sender->phdr;
struct link *l_ptr; struct link *l_ptr;
struct sk_buff *buf; struct sk_buff *buf;
struct tipc_node *node; struct tipc_node *node;
...@@ -1045,7 +1045,7 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1045,7 +1045,7 @@ int tipc_link_send_sections_fast(struct port *sender,
* (Must not hold any locks while building message.) * (Must not hold any locks while building message.)
*/ */
res = tipc_msg_build(hdr, msg_sect, num_sect, sender->publ.max_pkt, res = tipc_msg_build(hdr, msg_sect, num_sect, sender->max_pkt,
!sender->user_port, &buf); !sender->user_port, &buf);
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
...@@ -1056,7 +1056,7 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1056,7 +1056,7 @@ int tipc_link_send_sections_fast(struct port *sender,
if (likely(l_ptr)) { if (likely(l_ptr)) {
if (likely(buf)) { if (likely(buf)) {
res = link_send_buf_fast(l_ptr, buf, res = link_send_buf_fast(l_ptr, buf,
&sender->publ.max_pkt); &sender->max_pkt);
if (unlikely(res < 0)) if (unlikely(res < 0))
buf_discard(buf); buf_discard(buf);
exit: exit:
...@@ -1075,7 +1075,7 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1075,7 +1075,7 @@ int tipc_link_send_sections_fast(struct port *sender,
if (link_congested(l_ptr) || if (link_congested(l_ptr) ||
!list_empty(&l_ptr->b_ptr->cong_links)) { !list_empty(&l_ptr->b_ptr->cong_links)) {
res = link_schedule_port(l_ptr, res = link_schedule_port(l_ptr,
sender->publ.ref, res); sender->ref, res);
goto exit; goto exit;
} }
...@@ -1084,12 +1084,12 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1084,12 +1084,12 @@ int tipc_link_send_sections_fast(struct port *sender,
* then re-try fast path or fragment the message * then re-try fast path or fragment the message
*/ */
sender->publ.max_pkt = l_ptr->max_pkt; sender->max_pkt = l_ptr->max_pkt;
tipc_node_unlock(node); tipc_node_unlock(node);
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
if ((msg_hdr_sz(hdr) + res) <= sender->publ.max_pkt) if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt)
goto again; goto again;
return link_send_sections_long(sender, msg_sect, return link_send_sections_long(sender, msg_sect,
...@@ -1123,14 +1123,14 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1123,14 +1123,14 @@ int tipc_link_send_sections_fast(struct port *sender,
* *
* Returns user data length or errno. * Returns user data length or errno.
*/ */
static int link_send_sections_long(struct port *sender, static int link_send_sections_long(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
u32 num_sect, u32 num_sect,
u32 destaddr) u32 destaddr)
{ {
struct link *l_ptr; struct link *l_ptr;
struct tipc_node *node; struct tipc_node *node;
struct tipc_msg *hdr = &sender->publ.phdr; struct tipc_msg *hdr = &sender->phdr;
u32 dsz = msg_data_sz(hdr); u32 dsz = msg_data_sz(hdr);
u32 max_pkt, fragm_sz, rest; u32 max_pkt, fragm_sz, rest;
struct tipc_msg fragm_hdr; struct tipc_msg fragm_hdr;
...@@ -1142,7 +1142,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -1142,7 +1142,7 @@ static int link_send_sections_long(struct port *sender,
again: again:
fragm_no = 1; fragm_no = 1;
max_pkt = sender->publ.max_pkt - INT_H_SIZE; max_pkt = sender->max_pkt - INT_H_SIZE;
/* leave room for tunnel header in case of link changeover */ /* leave room for tunnel header in case of link changeover */
fragm_sz = max_pkt - INT_H_SIZE; fragm_sz = max_pkt - INT_H_SIZE;
/* leave room for fragmentation header in each fragment */ /* leave room for fragmentation header in each fragment */
...@@ -1157,7 +1157,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -1157,7 +1157,7 @@ static int link_send_sections_long(struct port *sender,
tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT, tipc_msg_init(&fragm_hdr, MSG_FRAGMENTER, FIRST_FRAGMENT,
INT_H_SIZE, msg_destnode(hdr)); INT_H_SIZE, msg_destnode(hdr));
msg_set_link_selector(&fragm_hdr, sender->publ.ref); msg_set_link_selector(&fragm_hdr, sender->ref);
msg_set_size(&fragm_hdr, max_pkt); msg_set_size(&fragm_hdr, max_pkt);
msg_set_fragm_no(&fragm_hdr, 1); msg_set_fragm_no(&fragm_hdr, 1);
...@@ -1238,13 +1238,13 @@ static int link_send_sections_long(struct port *sender, ...@@ -1238,13 +1238,13 @@ static int link_send_sections_long(struct port *sender,
node = tipc_node_find(destaddr); node = tipc_node_find(destaddr);
if (likely(node)) { if (likely(node)) {
tipc_node_lock(node); tipc_node_lock(node);
l_ptr = node->active_links[sender->publ.ref & 1]; l_ptr = node->active_links[sender->ref & 1];
if (!l_ptr) { if (!l_ptr) {
tipc_node_unlock(node); tipc_node_unlock(node);
goto reject; goto reject;
} }
if (l_ptr->max_pkt < max_pkt) { if (l_ptr->max_pkt < max_pkt) {
sender->publ.max_pkt = l_ptr->max_pkt; sender->max_pkt = l_ptr->max_pkt;
tipc_node_unlock(node); tipc_node_unlock(node);
for (; buf_chain; buf_chain = buf) { for (; buf_chain; buf_chain = buf) {
buf = buf_chain->next; buf = buf_chain->next;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/link.h: Include file for TIPC link code * net/tipc/link.h: Include file for TIPC link code
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, 2010-2011, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -211,7 +211,7 @@ struct link { ...@@ -211,7 +211,7 @@ struct link {
} stats; } stats;
}; };
struct port; struct tipc_port;
struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
const struct tipc_media_addr *media_addr); const struct tipc_media_addr *media_addr);
...@@ -230,7 +230,7 @@ void tipc_link_reset(struct link *l_ptr); ...@@ -230,7 +230,7 @@ void tipc_link_reset(struct link *l_ptr);
int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector); int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf); int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf);
u32 tipc_link_get_max_pkt(u32 dest, u32 selector); u32 tipc_link_get_max_pkt(u32 dest, u32 selector);
int tipc_link_send_sections_fast(struct port *sender, int tipc_link_send_sections_fast(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
const u32 num_sect, const u32 num_sect,
u32 destnode); u32 destnode);
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/port.h: Include file for TIPC port code * net/tipc/port.h: Include file for TIPC port code
* *
* Copyright (c) 1994-2007, Ericsson AB * Copyright (c) 1994-2007, Ericsson AB
* Copyright (c) 2004-2007, Wind River Systems * Copyright (c) 2004-2007, 2010-2011, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -95,7 +95,7 @@ struct user_port { ...@@ -95,7 +95,7 @@ struct user_port {
}; };
/** /**
* struct tipc_port - TIPC port info available to socket API * struct tipc_port - TIPC port structure
* @usr_handle: pointer to additional user-defined information about port * @usr_handle: pointer to additional user-defined information about port
* @lock: pointer to spinlock for controlling access to port * @lock: pointer to spinlock for controlling access to port
* @connected: non-zero if port is currently connected to a peer port * @connected: non-zero if port is currently connected to a peer port
...@@ -107,24 +107,6 @@ struct user_port { ...@@ -107,24 +107,6 @@ struct user_port {
* @max_pkt: maximum packet size "hint" used when building messages sent by port * @max_pkt: maximum packet size "hint" used when building messages sent by port
* @ref: unique reference to port in TIPC object registry * @ref: unique reference to port in TIPC object registry
* @phdr: preformatted message header used when sending messages * @phdr: preformatted message header used when sending messages
*/
struct tipc_port {
void *usr_handle;
spinlock_t *lock;
int connected;
u32 conn_type;
u32 conn_instance;
u32 conn_unacked;
int published;
u32 congested;
u32 max_pkt;
u32 ref;
struct tipc_msg phdr;
};
/**
* struct port - TIPC port structure
* @publ: TIPC port info available to privileged users
* @port_list: adjacent ports in TIPC's global list of ports * @port_list: adjacent ports in TIPC's global list of ports
* @dispatcher: ptr to routine which handles received messages * @dispatcher: ptr to routine which handles received messages
* @wakeup: ptr to routine to call when port is no longer congested * @wakeup: ptr to routine to call when port is no longer congested
...@@ -141,9 +123,18 @@ struct tipc_port { ...@@ -141,9 +123,18 @@ struct tipc_port {
* @timer_ref: * @timer_ref:
* @subscription: "node down" subscription used to terminate failed connections * @subscription: "node down" subscription used to terminate failed connections
*/ */
struct tipc_port {
struct port { void *usr_handle;
struct tipc_port publ; spinlock_t *lock;
int connected;
u32 conn_type;
u32 conn_instance;
u32 conn_unacked;
int published;
u32 congested;
u32 max_pkt;
u32 ref;
struct tipc_msg phdr;
struct list_head port_list; struct list_head port_list;
u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); u32 (*dispatcher)(struct tipc_port *, struct sk_buff *);
void (*wakeup)(struct tipc_port *); void (*wakeup)(struct tipc_port *);
...@@ -230,7 +221,7 @@ int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest, ...@@ -230,7 +221,7 @@ int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest,
int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, int tipc_multicast(u32 portref, struct tipc_name_seq const *seq,
unsigned int section_count, struct iovec const *msg); unsigned int section_count, struct iovec const *msg);
int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
struct iovec const *msg_sect, u32 num_sect, struct iovec const *msg_sect, u32 num_sect,
int err); int err);
struct sk_buff *tipc_port_get_ports(void); struct sk_buff *tipc_port_get_ports(void);
...@@ -242,9 +233,9 @@ void tipc_port_reinit(void); ...@@ -242,9 +233,9 @@ void tipc_port_reinit(void);
* tipc_port_lock - lock port instance referred to and return its pointer * tipc_port_lock - lock port instance referred to and return its pointer
*/ */
static inline struct port *tipc_port_lock(u32 ref) static inline struct tipc_port *tipc_port_lock(u32 ref)
{ {
return (struct port *)tipc_ref_lock(ref); return (struct tipc_port *)tipc_ref_lock(ref);
} }
/** /**
...@@ -253,27 +244,27 @@ static inline struct port *tipc_port_lock(u32 ref) ...@@ -253,27 +244,27 @@ static inline struct port *tipc_port_lock(u32 ref)
* Can use pointer instead of tipc_ref_unlock() since port is already locked. * Can use pointer instead of tipc_ref_unlock() since port is already locked.
*/ */
static inline void tipc_port_unlock(struct port *p_ptr) static inline void tipc_port_unlock(struct tipc_port *p_ptr)
{ {
spin_unlock_bh(p_ptr->publ.lock); spin_unlock_bh(p_ptr->lock);
} }
static inline struct port *tipc_port_deref(u32 ref) static inline struct tipc_port *tipc_port_deref(u32 ref)
{ {
return (struct port *)tipc_ref_deref(ref); return (struct tipc_port *)tipc_ref_deref(ref);
} }
static inline u32 tipc_peer_port(struct port *p_ptr) static inline u32 tipc_peer_port(struct tipc_port *p_ptr)
{ {
return msg_destport(&p_ptr->publ.phdr); return msg_destport(&p_ptr->phdr);
} }
static inline u32 tipc_peer_node(struct port *p_ptr) static inline u32 tipc_peer_node(struct tipc_port *p_ptr)
{ {
return msg_destnode(&p_ptr->publ.phdr); return msg_destnode(&p_ptr->phdr);
} }
static inline int tipc_port_congested(struct port *p_ptr) static inline int tipc_port_congested(struct tipc_port *p_ptr)
{ {
return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2);
} }
...@@ -284,7 +275,7 @@ static inline int tipc_port_congested(struct port *p_ptr) ...@@ -284,7 +275,7 @@ static inline int tipc_port_congested(struct port *p_ptr)
static inline int tipc_port_recv_msg(struct sk_buff *buf) static inline int tipc_port_recv_msg(struct sk_buff *buf)
{ {
struct port *p_ptr; struct tipc_port *p_ptr;
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
u32 destport = msg_destport(msg); u32 destport = msg_destport(msg);
u32 dsz = msg_data_sz(msg); u32 dsz = msg_data_sz(msg);
...@@ -299,7 +290,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) ...@@ -299,7 +290,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf)
/* validate destination & pass to port, otherwise reject message */ /* validate destination & pass to port, otherwise reject message */
p_ptr = tipc_port_lock(destport); p_ptr = tipc_port_lock(destport);
if (likely(p_ptr)) { if (likely(p_ptr)) {
if (likely(p_ptr->publ.connected)) { if (likely(p_ptr->connected)) {
if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) || if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) ||
(unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) || (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) ||
(unlikely(!msg_connected(msg)))) { (unlikely(!msg_connected(msg)))) {
...@@ -308,7 +299,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) ...@@ -308,7 +299,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf)
goto reject; goto reject;
} }
} }
err = p_ptr->dispatcher(&p_ptr->publ, buf); err = p_ptr->dispatcher(p_ptr, buf);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
if (likely(!err)) if (likely(!err))
return dsz; return dsz;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/subscr.c: TIPC network topology service * net/tipc/subscr.c: TIPC network topology service
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005-2007, Wind River Systems * Copyright (c) 2005-2007, 2010-2011, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -160,7 +160,7 @@ void tipc_subscr_report_overlap(struct subscription *sub, ...@@ -160,7 +160,7 @@ void tipc_subscr_report_overlap(struct subscription *sub,
static void subscr_timeout(struct subscription *sub) static void subscr_timeout(struct subscription *sub)
{ {
struct port *server_port; struct tipc_port *server_port;
/* Validate server port reference (in case subscriber is terminating) */ /* Validate server port reference (in case subscriber is terminating) */
...@@ -508,7 +508,7 @@ static void subscr_named_msg_event(void *usr_handle, ...@@ -508,7 +508,7 @@ static void subscr_named_msg_event(void *usr_handle,
/* Lock server port (& save lock address for future use) */ /* Lock server port (& save lock address for future use) */
subscriber->lock = tipc_port_lock(subscriber->port_ref)->publ.lock; subscriber->lock = tipc_port_lock(subscriber->port_ref)->lock;
/* Add subscriber to topology server's subscriber list */ /* Add subscriber to topology server's subscriber list */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment