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_LINK_H
38#define _TIPC_LINK_H
39
40#include "log.h"
41#include "msg.h"
42#include "node.h"
43
44#define PUSH_FAILED 1
45#define PUSH_FINISHED 2
46
47
48
49
50
51#define INVALID_LINK_SEQ 0x10000
52
53
54
55
56
57#define WORKING_WORKING 560810u
58#define WORKING_UNKNOWN 560811u
59#define RESET_UNKNOWN 560812u
60#define RESET_RESET 560813u
61
62
63
64
65
66
67#define MAX_PKT_DEFAULT 1500
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118struct tipc_link {
119 u32 addr;
120 char name[TIPC_MAX_LINK_NAME];
121 struct tipc_media_addr media_addr;
122 struct timer_list timer;
123 struct tipc_node *owner;
124 struct list_head link_list;
125
126
127 int started;
128 u32 checkpoint;
129 u32 peer_session;
130 u32 peer_bearer_id;
131 struct tipc_bearer *b_ptr;
132 u32 tolerance;
133 u32 continuity_interval;
134 u32 abort_limit;
135 int state;
136 int blocked;
137 u32 fsm_msg_cnt;
138 struct {
139 unchar hdr[INT_H_SIZE];
140 unchar body[TIPC_MAX_IF_NAME];
141 } proto_msg;
142 struct tipc_msg *pmsg;
143 u32 priority;
144 u32 queue_limit[15];
145
146
147 u32 exp_msg_count;
148 u32 reset_checkpoint;
149
150
151 u32 max_pkt;
152 u32 max_pkt_target;
153 u32 max_pkt_probes;
154
155
156 u32 out_queue_size;
157 struct sk_buff *first_out;
158 struct sk_buff *last_out;
159 u32 next_out_no;
160 u32 last_retransmitted;
161 u32 stale_count;
162
163
164 u32 next_in_no;
165 u32 deferred_inqueue_sz;
166 struct sk_buff *oldest_deferred_in;
167 struct sk_buff *newest_deferred_in;
168 u32 unacked_window;
169
170
171 struct sk_buff *proto_msg_queue;
172 u32 retransm_queue_size;
173 u32 retransm_queue_head;
174 struct sk_buff *next_out;
175 struct list_head waiting_ports;
176
177
178 u32 long_msg_seq_no;
179 struct sk_buff *defragm_buf;
180
181
182 struct {
183 u32 sent_info;
184 u32 recv_info;
185 u32 sent_states;
186 u32 recv_states;
187 u32 sent_probes;
188 u32 recv_probes;
189 u32 sent_nacks;
190 u32 recv_nacks;
191 u32 sent_acks;
192 u32 sent_bundled;
193 u32 sent_bundles;
194 u32 recv_bundled;
195 u32 recv_bundles;
196 u32 retransmitted;
197 u32 sent_fragmented;
198 u32 sent_fragments;
199 u32 recv_fragmented;
200 u32 recv_fragments;
201 u32 link_congs;
202 u32 bearer_congs;
203 u32 deferred_recv;
204 u32 duplicates;
205 u32 max_queue_sz;
206 u32 accu_queue_sz;
207 u32 queue_sz_counts;
208 u32 msg_length_counts;
209 u32 msg_lengths_total;
210 u32 msg_length_profile[7];
211 } stats;
212};
213
214struct tipc_port;
215
216struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
217 struct tipc_bearer *b_ptr,
218 const struct tipc_media_addr *media_addr);
219void tipc_link_delete(struct tipc_link *l_ptr);
220void tipc_link_changeover(struct tipc_link *l_ptr);
221void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *dest);
222void tipc_link_reset_fragments(struct tipc_link *l_ptr);
223int tipc_link_is_up(struct tipc_link *l_ptr);
224int tipc_link_is_active(struct tipc_link *l_ptr);
225u32 tipc_link_push_packet(struct tipc_link *l_ptr);
226void tipc_link_stop(struct tipc_link *l_ptr);
227struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, u16 cmd);
228struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space);
229struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space);
230void tipc_link_reset(struct tipc_link *l_ptr);
231int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
232void tipc_link_send_names(struct list_head *message_list, u32 dest);
233int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf);
234u32 tipc_link_get_max_pkt(u32 dest, u32 selector);
235int tipc_link_send_sections_fast(struct tipc_port *sender,
236 struct iovec const *msg_sect,
237 const u32 num_sect,
238 unsigned int total_len,
239 u32 destnode);
240void tipc_link_recv_bundle(struct sk_buff *buf);
241int tipc_link_recv_fragment(struct sk_buff **pending,
242 struct sk_buff **fb,
243 struct tipc_msg **msg);
244void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, int prob,
245 u32 gap, u32 tolerance, u32 priority,
246 u32 acked_mtu);
247void tipc_link_push_queue(struct tipc_link *l_ptr);
248u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
249 struct sk_buff *buf);
250void tipc_link_wakeup_ports(struct tipc_link *l_ptr, int all);
251void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window);
252void tipc_link_retransmit(struct tipc_link *l_ptr,
253 struct sk_buff *start, u32 retransmits);
254
255
256
257
258
259static inline u32 buf_seqno(struct sk_buff *buf)
260{
261 return msg_seqno(buf_msg(buf));
262}
263
264static inline u32 mod(u32 x)
265{
266 return x & 0xffffu;
267}
268
269static inline int between(u32 lower, u32 upper, u32 n)
270{
271 if ((lower < n) && (n < upper))
272 return 1;
273 if ((upper < lower) && ((n > lower) || (n < upper)))
274 return 1;
275 return 0;
276}
277
278static inline int less_eq(u32 left, u32 right)
279{
280 return mod(right - left) < 32768u;
281}
282
283static inline int less(u32 left, u32 right)
284{
285 return less_eq(left, right) && (mod(right) != mod(left));
286}
287
288static inline u32 lesser(u32 left, u32 right)
289{
290 return less_eq(left, right) ? left : right;
291}
292
293
294
295
296
297
298static inline int link_working_working(struct tipc_link *l_ptr)
299{
300 return l_ptr->state == WORKING_WORKING;
301}
302
303static inline int link_working_unknown(struct tipc_link *l_ptr)
304{
305 return l_ptr->state == WORKING_UNKNOWN;
306}
307
308static inline int link_reset_unknown(struct tipc_link *l_ptr)
309{
310 return l_ptr->state == RESET_UNKNOWN;
311}
312
313static inline int link_reset_reset(struct tipc_link *l_ptr)
314{
315 return l_ptr->state == RESET_RESET;
316}
317
318static inline int link_blocked(struct tipc_link *l_ptr)
319{
320 return l_ptr->exp_msg_count || l_ptr->blocked;
321}
322
323static inline int link_congested(struct tipc_link *l_ptr)
324{
325 return l_ptr->out_queue_size >= l_ptr->queue_limit[0];
326}
327
328#endif
329