Adds flowstats changes
These changes are based on flowstats changes in shortcut-fe
Tests:
1. Verified that connection stats are present in /proc/net/ip_conn_addr
when enabled on R920 kernel and R920 running firmware with these changes.
Also verified that counters increase when routed traffic is passed
between WAN and LAN
2. Verified that latency measured to 3 sites (www.cnn.com,
www.oxford.co.uk, www.ufl.edu) via ping, is the same as measured in
proc file ip_conn_addr
Change-Id: Ibf087a5ca80727e0e4617a9afde78d271f1a55ff
diff --git a/sfe_ipv4.h b/sfe_ipv4.h
index 49fd0ff..ea74338 100644
--- a/sfe_ipv4.h
+++ b/sfe_ipv4.h
@@ -26,6 +26,23 @@
#include <linux/version.h>
/*
+ * By default Linux IP header and transport layer header structures are
+ * unpacked, assuming that such headers should be 32-bit aligned.
+ * Unfortunately some wireless adaptors can't cope with this requirement and
+ * some CPUs can't handle misaligned accesses. For those platforms we
+ * define SFE_IPV4_UNALIGNED_IP_HEADER and mark the structures as packed.
+ * When we do this the compiler will generate slightly worse code than for the
+ * aligned case (on most platforms) but will be much quicker than fixing
+ * things up in an unaligned trap handler.
+ */
+#define SFE_IPV4_UNALIGNED_IP_HEADER 1
+#if SFE_IPV4_UNALIGNED_IP_HEADER
+#define SFE_IPV4_UNALIGNED_STRUCT __attribute__((packed))
+#else
+#define SFE_IPV4_UNALIGNED_STRUCT
+#endif
+
+/*
* Specifies the lower bound on ACK numbers carried in the TCP header
*/
#define SFE_IPV4_TCP_MAX_ACK_WINDOW 65520
@@ -40,6 +57,7 @@
u32 max_end; /* Sequence number of the last byte to ack */
};
+
/*
* Bit flags for IPv4 connection matching entry.
*/
@@ -129,6 +147,21 @@
struct net_device *match_dev; /* Network device */
+#ifdef CONFIG_NETFILTER_CP_FLOWSTATS
+ u32 cp_fs_original; /* Flag indicating if this is original */
+ u32 last_seq_num; /* Sequence number saved*/
+ u32 last_seq_time;
+ u32 tot_delta; /* added samples of latency
+ to compute average*/
+ u32 tot_delta_square; /* sum of squares of delta;
+ to calculate std deviation.*/
+ u32 num_samples;
+/*
+ * Stats used for Latency flowstats.
+ */
+ u64 fs_rx_packet_count;
+ u64 fs_rx_byte_count;
+#endif //CONFIG_NETFILTER_CP_FLOWSTATS
/*
* Control the operations of the match.
*/
@@ -240,8 +273,18 @@
u32 debug_read_seq; /* sequence number for debug dump */
bool removed; /* Indicates the connection is removed */
struct rcu_head rcu; /* delay rcu free */
+#ifdef CONFIG_NETFILTER_CP_FLOWSTATS
+ int start_time; /* Jiffies to track when the flow started */
+#endif
};
+#ifdef CONFIG_NETFILTER_CP_FLOWSTATS /* CP_LATENCY_IP*/
+#define MIN_IP_PKT_SIZE 84
+#define CP_IP_REC_TIMEOUT_SFE 15 /* In seconds: */
+#define MSEC_IN_SEC 1000
+#define MAX_RTT_THRESHOLD (700)*(HZ)/(MSEC_IN_SEC)
+#endif
+
/*
* IPv4 connections and hash table size information.
*/