1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef _TIPC_PORT_H
38#define _TIPC_PORT_H
39
40#include "core.h"
41#include "ref.h"
42#include "net.h"
43#include "msg.h"
44#include "dbg.h"
45#include "node_subscr.h"
46
47
48
49
50
51
52
53
54
55
56struct user_port {
57 u32 user_ref;
58 void *usr_handle;
59 u32 ref;
60 tipc_msg_err_event err_cb;
61 tipc_named_msg_err_event named_err_cb;
62 tipc_conn_shutdown_event conn_err_cb;
63 tipc_msg_event msg_cb;
64 tipc_named_msg_event named_msg_cb;
65 tipc_conn_msg_event conn_msg_cb;
66 tipc_continue_event continue_event_cb;
67 struct list_head uport_list;
68};
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91struct port {
92 struct tipc_port publ;
93 struct list_head port_list;
94 u32 (*dispatcher)(struct tipc_port *, struct sk_buff *);
95 void (*wakeup)(struct tipc_port *);
96 struct user_port *user_port;
97 struct list_head wait_list;
98 struct link *congested_link;
99 u32 waiting_pkts;
100 u32 sent;
101 u32 acked;
102 struct list_head publications;
103 u32 pub_count;
104 u32 probing_state;
105 u32 probing_interval;
106 u32 last_in_seqno;
107 struct timer_list timer;
108 struct node_subscr subscription;
109};
110
111extern spinlock_t tipc_port_list_lock;
112struct port_list;
113
114int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect,
115 struct iovec const *msg_sect);
116int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
117 struct iovec const *msg_sect, u32 num_sect,
118 int err);
119struct sk_buff *tipc_port_get_ports(void);
120struct sk_buff *port_show_stats(const void *req_tlv_area, int req_tlv_space);
121void tipc_port_recv_proto_msg(struct sk_buff *buf);
122void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp);
123void tipc_port_reinit(void);
124
125
126
127
128
129static inline struct port *tipc_port_lock(u32 ref)
130{
131 return (struct port *)tipc_ref_lock(ref);
132}
133
134
135
136
137
138
139
140static inline void tipc_port_unlock(struct port *p_ptr)
141{
142 spin_unlock_bh(p_ptr->publ.lock);
143}
144
145static inline struct port* tipc_port_deref(u32 ref)
146{
147 return (struct port *)tipc_ref_deref(ref);
148}
149
150static inline u32 tipc_peer_port(struct port *p_ptr)
151{
152 return msg_destport(&p_ptr->publ.phdr);
153}
154
155static inline u32 tipc_peer_node(struct port *p_ptr)
156{
157 return msg_destnode(&p_ptr->publ.phdr);
158}
159
160static inline int tipc_port_congested(struct port *p_ptr)
161{
162 return((p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2));
163}
164
165
166
167
168
169static inline int tipc_port_recv_msg(struct sk_buff *buf)
170{
171 struct port *p_ptr;
172 struct tipc_msg *msg = buf_msg(buf);
173 u32 destport = msg_destport(msg);
174 u32 dsz = msg_data_sz(msg);
175 u32 err;
176
177
178 if (unlikely(!destport)) {
179 tipc_net_route_msg(buf);
180 return dsz;
181 }
182
183
184 p_ptr = tipc_port_lock(destport);
185 if (likely(p_ptr)) {
186 if (likely(p_ptr->publ.connected)) {
187 if ((unlikely(msg_origport(msg) != tipc_peer_port(p_ptr))) ||
188 (unlikely(msg_orignode(msg) != tipc_peer_node(p_ptr))) ||
189 (unlikely(!msg_connected(msg)))) {
190 err = TIPC_ERR_NO_PORT;
191 tipc_port_unlock(p_ptr);
192 goto reject;
193 }
194 }
195 err = p_ptr->dispatcher(&p_ptr->publ, buf);
196 tipc_port_unlock(p_ptr);
197 if (likely(!err))
198 return dsz;
199 } else {
200 err = TIPC_ERR_NO_PORT;
201 }
202reject:
203 dbg("port->rejecting, err = %x..\n",err);
204 return tipc_reject_msg(buf, err);
205}
206
207#endif
208