aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/msg.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/msg.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/msg.h')
-rw-r--r--net/tipc/msg.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index e1d3595e2ee9..6ca2366f3a53 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -313,12 +313,12 @@ static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n)
313 msg_set_bits(m, 1, 19, 0x3, n); 313 msg_set_bits(m, 1, 19, 0x3, n);
314} 314}
315 315
316static inline u32 msg_bcast_ack(struct tipc_msg *m) 316static inline u16 msg_bcast_ack(struct tipc_msg *m)
317{ 317{
318 return msg_bits(m, 1, 0, 0xffff); 318 return msg_bits(m, 1, 0, 0xffff);
319} 319}
320 320
321static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) 321static inline void msg_set_bcast_ack(struct tipc_msg *m, u16 n)
322{ 322{
323 msg_set_bits(m, 1, 0, 0xffff, n); 323 msg_set_bits(m, 1, 0, 0xffff, n);
324} 324}
@@ -327,22 +327,22 @@ static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
327/* 327/*
328 * Word 2 328 * Word 2
329 */ 329 */
330static inline u32 msg_ack(struct tipc_msg *m) 330static inline u16 msg_ack(struct tipc_msg *m)
331{ 331{
332 return msg_bits(m, 2, 16, 0xffff); 332 return msg_bits(m, 2, 16, 0xffff);
333} 333}
334 334
335static inline void msg_set_ack(struct tipc_msg *m, u32 n) 335static inline void msg_set_ack(struct tipc_msg *m, u16 n)
336{ 336{
337 msg_set_bits(m, 2, 16, 0xffff, n); 337 msg_set_bits(m, 2, 16, 0xffff, n);
338} 338}
339 339
340static inline u32 msg_seqno(struct tipc_msg *m) 340static inline u16 msg_seqno(struct tipc_msg *m)
341{ 341{
342 return msg_bits(m, 2, 0, 0xffff); 342 return msg_bits(m, 2, 0, 0xffff);
343} 343}
344 344
345static inline void msg_set_seqno(struct tipc_msg *m, u32 n) 345static inline void msg_set_seqno(struct tipc_msg *m, u16 n)
346{ 346{
347 msg_set_bits(m, 2, 0, 0xffff, n); 347 msg_set_bits(m, 2, 0, 0xffff, n);
348} 348}
@@ -782,6 +782,11 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, u32 *dnode,
782 int *err); 782 int *err);
783struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list); 783struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list);
784 784
785static inline u16 buf_seqno(struct sk_buff *skb)
786{
787 return msg_seqno(buf_msg(skb));
788}
789
785/* tipc_skb_peek(): peek and reserve first buffer in list 790/* tipc_skb_peek(): peek and reserve first buffer in list
786 * @list: list to be peeked in 791 * @list: list to be peeked in
787 * Returns pointer to first buffer in list, if any 792 * Returns pointer to first buffer in list, if any