[shortcut-fe] Change code style to match Linux kernel

1. Move ANSI types to Linux types.
2. Change all global variables to static defined variables.
3. Removed macro SFE_HOOK_ABOVE_BRIDGE since it is always true
   in current code.
4. move extern declarations to header files.
5. Rework some comments to make them meaningful.
6. Some code style changes, such as space/newline/alignment/brackets.

Change-Id: I131071a3522e79662f092b20259d07e5458f0f73
Signed-off-by: Xiaoping Fan <xfan@codeaurora.org>
diff --git a/shortcut-fe/sfe_cm.h b/shortcut-fe/sfe_cm.h
index 12f2ffa..23cbde8 100644
--- a/shortcut-fe/sfe_cm.h
+++ b/shortcut-fe/sfe_cm.h
@@ -2,7 +2,7 @@
  * sfe_cm.h
  *	Shortcut forwarding engine.
  *
- * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -18,11 +18,11 @@
 /*
  * connection flags.
  */
-#define SFE_CREATE_FLAG_NO_SEQ_CHECK (1<<0)
+#define SFE_CREATE_FLAG_NO_SEQ_CHECK BIT(0)
 					/* Indicates that we should not check sequence numbers */
-#define SFE_CREATE_FLAG_REMARK_PRIORITY (1<<1)
+#define SFE_CREATE_FLAG_REMARK_PRIORITY BIT(1)
 					/* Indicates that we should remark priority of skb */
-#define SFE_CREATE_FLAG_REMARK_DSCP (1<<2)
+#define SFE_CREATE_FLAG_REMARK_DSCP BIT(2)
 					/* Indicates that we should remark DSCP of packet */
 
 /*
@@ -44,9 +44,9 @@
 	int protocol;
 	struct net_device *src_dev;
 	struct net_device *dest_dev;
-	uint32_t flags;
-	uint32_t src_mtu;
-	uint32_t dest_mtu;
+	u32 flags;
+	u32 src_mtu;
+	u32 dest_mtu;
 	sfe_ip_addr_t src_ip;
 	sfe_ip_addr_t src_ip_xlate;
 	sfe_ip_addr_t dest_ip;
@@ -55,27 +55,27 @@
 	__be16 src_port_xlate;
 	__be16 dest_port;
 	__be16 dest_port_xlate;
-	uint8_t src_mac[ETH_ALEN];
-	uint8_t src_mac_xlate[ETH_ALEN];
-	uint8_t dest_mac[ETH_ALEN];
-	uint8_t dest_mac_xlate[ETH_ALEN];
-	uint8_t src_td_window_scale;
-	uint32_t src_td_max_window;
-	uint32_t src_td_end;
-	uint32_t src_td_max_end;
-	uint8_t dest_td_window_scale;
-	uint32_t dest_td_max_window;
-	uint32_t dest_td_end;
-	uint32_t dest_td_max_end;
-	uint32_t mark;
+	u8 src_mac[ETH_ALEN];
+	u8 src_mac_xlate[ETH_ALEN];
+	u8 dest_mac[ETH_ALEN];
+	u8 dest_mac_xlate[ETH_ALEN];
+	u8 src_td_window_scale;
+	u32 src_td_max_window;
+	u32 src_td_end;
+	u32 src_td_max_end;
+	u8 dest_td_window_scale;
+	u32 dest_td_max_window;
+	u32 dest_td_end;
+	u32 dest_td_max_end;
+	u32 mark;
 #ifdef CONFIG_XFRM
-	uint32_t original_accel;
-	uint32_t reply_accel;
+	u32 original_accel;
+	u32 reply_accel;
 #endif
-	uint32_t src_priority;
-	uint32_t dest_priority;
-	uint32_t src_dscp;
-	uint32_t dest_dscp;
+	u32 src_priority;
+	u32 dest_priority;
+	u32 src_dscp;
+	u32 dest_dscp;
 };
 
 /*
@@ -114,22 +114,22 @@
 	sfe_ip_addr_t dest_ip_xlate;	/* NATed destination address */
 	__be16 dest_port;		/* Non-NAT destination port */
 	__be16 dest_port_xlate;		/* NATed destination port */
-	uint32_t src_td_max_window;
-	uint32_t src_td_end;
-	uint32_t src_td_max_end;
-	uint64_t src_packet_count;
-	uint64_t src_byte_count;
-	uint32_t src_new_packet_count;
-	uint32_t src_new_byte_count;
-	uint32_t dest_td_max_window;
-	uint32_t dest_td_end;
-	uint32_t dest_td_max_end;
-	uint64_t dest_packet_count;
-	uint64_t dest_byte_count;
-	uint32_t dest_new_packet_count;
-	uint32_t dest_new_byte_count;
-	uint32_t reason;		/* reason for stats sync message, i.e. destroy, flush, period sync */
-	uint64_t delta_jiffies;		/* Time to be added to the current timeout to keep the connection alive */
+	u32 src_td_max_window;
+	u32 src_td_end;
+	u32 src_td_max_end;
+	u64 src_packet_count;
+	u64 src_byte_count;
+	u32 src_new_packet_count;
+	u32 src_new_byte_count;
+	u32 dest_td_max_window;
+	u32 dest_td_end;
+	u32 dest_td_max_end;
+	u64 dest_packet_count;
+	u64 dest_byte_count;
+	u32 dest_new_packet_count;
+	u32 dest_new_byte_count;
+	u32 reason;		/* reason for stats sync message, i.e. destroy, flush, period sync */
+	u64 delta_jiffies;		/* Time to be added to the current timeout to keep the connection alive */
 };
 
 /*
@@ -141,36 +141,51 @@
 	sfe_ip_addr_t dest_ip;
 	__be16 src_port;
 	__be16 dest_port;
-	uint32_t mark;
+	u32 mark;
 };
 
 /*
- * Type used for a sync rule callback.
+ * Expose the hook for the receive processing.
+ */
+extern int (*athrs_fast_nat_recv)(struct sk_buff *skb);
+
+/*
+ * Expose what should be a static flag in the TCP connection tracker.
+ */
+extern int nf_ct_tcp_no_window_check;
+
+/*
+ * This callback will be called in a timer
+ * at 100 times per second to sync stats back to
+ * Linux connection track.
+ *
+ * A RCU lock is taken to prevent this callback
+ * from unregistering.
  */
 typedef void (*sfe_sync_rule_callback_t)(struct sfe_connection_sync *);
 
 /*
  * IPv4 APIs used by connection manager
  */
-extern int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb);
-extern int sfe_ipv4_create_rule(struct sfe_connection_create *sic);
-extern void sfe_ipv4_destroy_rule(struct sfe_connection_destroy *sid);
-extern void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev);
-extern void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
-extern void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
-extern void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
+int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb);
+int sfe_ipv4_create_rule(struct sfe_connection_create *sic);
+void sfe_ipv4_destroy_rule(struct sfe_connection_destroy *sid);
+void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev);
+void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
+void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
+void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
 
 #ifdef SFE_SUPPORT_IPV6
 /*
  * IPv6 APIs used by connection manager
  */
-extern int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb);
-extern int sfe_ipv6_create_rule(struct sfe_connection_create *sic);
-extern void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid);
-extern void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev);
-extern void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
-extern void sfe_ipv6_update_rule(struct sfe_connection_create *sic);
-extern void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark);
+int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb);
+int sfe_ipv6_create_rule(struct sfe_connection_create *sic);
+void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid);
+void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev);
+void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
+void sfe_ipv6_update_rule(struct sfe_connection_create *sic);
+void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark);
 #else
 static inline int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb)
 {
@@ -179,7 +194,7 @@
 
 static inline int sfe_ipv6_create_rule(struct sfe_connection_create *sic)
 {
-	return -1;
+	return 0;
 }
 
 static inline void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid)
@@ -229,7 +244,7 @@
  *
  * return: 1, equal; 0, no equal
  */
-#define sfe_ipv4_addr_equal(a, b) ((uint32_t)(a) == (uint32_t)(b))
+#define sfe_ipv4_addr_equal(a, b) ((u32)(a) == (u32)(b))
 
 /*
  * sfe_addr_equal()