aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.h
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-05-14 10:46:14 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-14 12:24:46 -0400
commite4bf4f76962b0869d1048ac6c52a46e7d90eb46f (patch)
treeae6a57dd200627e3a3226652700a4a3d6c3a59b3 /net/tipc/link.h
parenta6bf70f792963b32e410e5c3d2f96903265b090a (diff)
tipc: simplify packet sequence number handling
Although the sequence number in the TIPC protocol is 16 bits, we have until now stored it internally as an unsigned 32 bits integer. We got around this by always doing explicit modulo-65535 operations whenever we need to access a sequence number. We now make the incoming and outgoing sequence numbers to unsigned 16-bit integers, and remove the modulo operations where applicable. We also move the arithmetic inline functions for 16 bit integers to core.h, and the function buf_seqno() to msg.h, so they can easily be accessed from anywhere in the code. Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.h')
-rw-r--r--net/tipc/link.h41
1 files changed, 4 insertions, 37 deletions
diff --git a/net/tipc/link.h b/net/tipc/link.h
index dc27bb62b1f5..a65770bf647c 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -151,7 +151,7 @@ struct tipc_link {
151 151
152 /* Management and link supervision data */ 152 /* Management and link supervision data */
153 unsigned int flags; 153 unsigned int flags;
154 u32 checkpoint; 154 u16 checkpoint;
155 u32 peer_session; 155 u32 peer_session;
156 u32 peer_bearer_id; 156 u32 peer_bearer_id;
157 u32 bearer_id; 157 u32 bearer_id;
@@ -185,13 +185,13 @@ struct tipc_link {
185 u16 len; 185 u16 len;
186 u16 limit; 186 u16 limit;
187 } backlog[5]; 187 } backlog[5];
188 u32 next_out_no; 188 u16 next_out_no;
189 u16 last_retransmitted;
189 u32 window; 190 u32 window;
190 u32 last_retransmitted;
191 u32 stale_count; 191 u32 stale_count;
192 192
193 /* Reception */ 193 /* Reception */
194 u32 next_in_no; 194 u16 next_in_no;
195 u32 rcv_unacked; 195 u32 rcv_unacked;
196 struct sk_buff_head deferdq; 196 struct sk_buff_head deferdq;
197 struct sk_buff_head inputq; 197 struct sk_buff_head inputq;
@@ -245,39 +245,6 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info);
245int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]); 245int tipc_nl_parse_link_prop(struct nlattr *prop, struct nlattr *props[]);
246void link_prepare_wakeup(struct tipc_link *l); 246void link_prepare_wakeup(struct tipc_link *l);
247 247
248/*
249 * Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
250 */
251static inline u32 buf_seqno(struct sk_buff *buf)
252{
253 return msg_seqno(buf_msg(buf));
254}
255
256static inline u32 mod(u32 x)
257{
258 return x & 0xffffu;
259}
260
261static inline int less_eq(u32 left, u32 right)
262{
263 return mod(right - left) < 32768u;
264}
265
266static inline int more(u32 left, u32 right)
267{
268 return !less_eq(left, right);
269}
270
271static inline int less(u32 left, u32 right)
272{
273 return less_eq(left, right) && (mod(right) != mod(left));
274}
275
276static inline u32 lesser(u32 left, u32 right)
277{
278 return less_eq(left, right) ? left : right;
279}
280
281static inline u32 link_own_addr(struct tipc_link *l) 248static inline u32 link_own_addr(struct tipc_link *l)
282{ 249{
283 return msg_prevnode(l->pmsg); 250 return msg_prevnode(l->pmsg);