summaryrefslogtreecommitdiffstats
path: root/net/tipc/core.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/core.h
parenta6bf70f792963b32e410e5c3d2f96903265b090a (diff)
downloadlinux-e4bf4f76962b0869d1048ac6c52a46e7d90eb46f.tar.gz
linux-e4bf4f76962b0869d1048ac6c52a46e7d90eb46f.tar.bz2
linux-e4bf4f76962b0869d1048ac6c52a46e7d90eb46f.zip
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/core.h')
-rw-r--r--net/tipc/core.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 53e8146b14e0..0fcf133d5cb7 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -109,6 +109,26 @@ struct tipc_net {
atomic_t subscription_count;
};
+static inline u16 mod(u16 x)
+{
+ return x & 0xffffu;
+}
+
+static inline int less_eq(u16 left, u16 right)
+{
+ return mod(right - left) < 32768u;
+}
+
+static inline int more(u16 left, u16 right)
+{
+ return !less_eq(left, right);
+}
+
+static inline int less(u16 left, u16 right)
+{
+ return less_eq(left, right) && (mod(right) != mod(left));
+}
+
#ifdef CONFIG_SYSCTL
int tipc_register_sysctl(void);
void tipc_unregister_sysctl(void);